2010-10-12 15:53:47 +02:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2012-11-12 17:21:24 +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 .
*/
2003-10-21 07:39:21 +00:00
# include "formcellbinding.hxx"
2004-04-02 09:30:57 +00:00
# include <com/sun/star/form/binding/XBindableValue.hpp>
# include <com/sun/star/form/binding/XListEntrySink.hpp>
2003-10-21 07:39:21 +00:00
# include <com/sun/star/form/XGridColumnFactory.hpp>
# include <com/sun/star/frame/XModel.hpp>
# include <com/sun/star/container/XChild.hpp>
# include <com/sun/star/container/XNamed.hpp>
# include <com/sun/star/drawing/XDrawPageSupplier.hpp>
# include <com/sun/star/table/XCellRange.hpp>
# include <com/sun/star/form/XFormsSupplier.hpp>
# include <com/sun/star/form/XForm.hpp>
# include <com/sun/star/lang/XServiceInfo.hpp>
# include <com/sun/star/lang/XMultiServiceFactory.hpp>
# include <com/sun/star/beans/NamedValue.hpp>
# include "strings.hxx"
# include <osl/diagnose.h>
2009-04-23 10:42:05 +00:00
# include <rtl/logfile.hxx>
2003-10-21 07:39:21 +00:00
# include <functional>
# include <algorithm>
//............................................................................
namespace xmloff
{
//............................................................................
using namespace : : com : : sun : : star : : uno ;
using namespace : : com : : sun : : star : : beans ;
using namespace : : com : : sun : : star : : frame ;
using namespace : : com : : sun : : star : : sheet ;
using namespace : : com : : sun : : star : : container ;
using namespace : : com : : sun : : star : : drawing ;
using namespace : : com : : sun : : star : : table ;
using namespace : : com : : sun : : star : : form ;
using namespace : : com : : sun : : star : : lang ;
2004-04-02 09:30:57 +00:00
using namespace : : com : : sun : : star : : form : : binding ;
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
namespace
{
using : : com : : sun : : star : : uno : : Reference ;
using : : com : : sun : : star : : uno : : XInterface ;
using : : com : : sun : : star : : container : : XChild ;
using : : com : : sun : : star : : frame : : XModel ;
using : : com : : sun : : star : : uno : : UNO_QUERY ;
//....................................................................
template < class TYPE >
Reference < TYPE > getTypedModelNode ( const Reference < XInterface > & _rxModelNode )
2003-10-21 07:39:21 +00:00
{
2009-04-23 10:42:05 +00:00
Reference < TYPE > xTypedNode ( _rxModelNode , UNO_QUERY ) ;
if ( xTypedNode . is ( ) )
return xTypedNode ;
else
2003-10-21 07:39:21 +00:00
{
2009-04-23 10:42:05 +00:00
Reference < XChild > xChild ( _rxModelNode , UNO_QUERY ) ;
if ( xChild . is ( ) )
return getTypedModelNode < TYPE > ( xChild - > getParent ( ) ) ;
2003-10-21 07:39:21 +00:00
else
2009-04-23 10:42:05 +00:00
return NULL ;
2003-10-21 07:39:21 +00:00
}
}
2009-04-23 10:42:05 +00:00
//....................................................................
Reference < XModel > getDocument ( const Reference < XInterface > & _rxModelNode )
2003-10-21 07:39:21 +00:00
{
2009-04-23 10:42:05 +00:00
return getTypedModelNode < XModel > ( _rxModelNode ) ;
2003-10-21 07:39:21 +00:00
}
2009-04-23 10:42:05 +00:00
//....................................................................
2013-04-07 12:06:47 +02:00
struct StringCompare : public : : std : : unary_function < OUString , bool >
2003-10-21 07:39:21 +00:00
{
2009-04-23 10:42:05 +00:00
private :
2013-04-07 12:06:47 +02:00
const OUString m_sReference ;
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
public :
2013-04-07 12:06:47 +02:00
StringCompare ( const OUString & _rReference ) : m_sReference ( _rReference ) { }
2003-10-21 07:39:21 +00:00
2013-04-07 12:06:47 +02:00
inline bool operator ( ) ( const OUString & _rCompare )
2009-04-23 10:42:05 +00:00
{
return ( _rCompare = = m_sReference ) ;
}
} ;
}
//========================================================================
//= FormCellBindingHelper
//========================================================================
//------------------------------------------------------------------------
FormCellBindingHelper : : FormCellBindingHelper ( const Reference < XPropertySet > & _rxControlModel , const Reference < XModel > & _rxDocument )
: m_xControlModel ( _rxControlModel )
, m_xDocument ( _rxDocument , UNO_QUERY )
{
OSL_ENSURE ( m_xControlModel . is ( ) , " FormCellBindingHelper::FormCellBindingHelper: invalid control model! " ) ;
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
if ( ! m_xDocument . is ( ) )
m_xDocument = m_xDocument . query ( getDocument ( m_xControlModel ) ) ;
OSL_ENSURE ( m_xDocument . is ( ) , " FormCellBindingHelper::FormCellBindingHelper: Did not find the spreadsheet document! " ) ;
}
//------------------------------------------------------------------------
sal_Bool FormCellBindingHelper : : livesInSpreadsheetDocument ( const Reference < XPropertySet > & _rxControlModel )
{
Reference < XSpreadsheetDocument > xDocument ( getDocument ( _rxControlModel ) , UNO_QUERY ) ;
return xDocument . is ( ) ;
}
//------------------------------------------------------------------------
2013-04-07 12:06:47 +02:00
bool FormCellBindingHelper : : convertStringAddress ( const OUString & _rAddressDescription , CellAddress & /* [out] */ _rAddress , sal_Int16 /*_nAssumeSheet*/ ) const
2009-04-23 10:42:05 +00:00
{
Any aAddress ;
return doConvertAddressRepresentations (
PROPERTY_FILE_REPRESENTATION ,
makeAny ( _rAddressDescription ) ,
PROPERTY_ADDRESS ,
aAddress ,
false
)
& & ( aAddress > > = _rAddress ) ;
}
//------------------------------------------------------------------------
2013-04-07 12:06:47 +02:00
bool FormCellBindingHelper : : convertStringAddress ( const OUString & _rAddressDescription ,
2009-04-23 10:42:05 +00:00
CellRangeAddress & /* [out] */ _rAddress ) const
{
Any aAddress ;
return doConvertAddressRepresentations (
PROPERTY_FILE_REPRESENTATION ,
makeAny ( _rAddressDescription ) ,
PROPERTY_ADDRESS ,
aAddress ,
true
)
& & ( aAddress > > = _rAddress ) ;
}
//------------------------------------------------------------------------
2013-04-07 12:06:47 +02:00
Reference < XValueBinding > FormCellBindingHelper : : createCellBindingFromStringAddress ( const OUString & _rAddress , bool _bUseIntegerBinding ) const
2009-04-23 10:42:05 +00:00
{
Reference < XValueBinding > xBinding ;
if ( ! m_xDocument . is ( ) )
// very bad ...
return xBinding ;
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
// get the UNO representation of the address
CellAddress aAddress ;
2012-01-25 21:59:48 -02:00
if ( _rAddress . isEmpty ( ) | | ! convertStringAddress ( _rAddress , aAddress ) )
2003-10-21 07:39:21 +00:00
return xBinding ;
2009-04-23 10:42:05 +00:00
xBinding = xBinding . query ( createDocumentDependentInstance (
2013-03-01 10:31:52 +01:00
_bUseIntegerBinding ? OUString ( SERVICE_LISTINDEXCELLBINDING ) : OUString ( SERVICE_CELLVALUEBINDING ) ,
2009-04-23 10:42:05 +00:00
PROPERTY_BOUND_CELL ,
makeAny ( aAddress )
) ) ;
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
return xBinding ;
}
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
//------------------------------------------------------------------------
2013-04-07 12:06:47 +02:00
Reference < XListEntrySource > FormCellBindingHelper : : createCellListSourceFromStringAddress ( const OUString & _rAddress ) const
2009-04-23 10:42:05 +00:00
{
Reference < XListEntrySource > xSource ;
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
CellRangeAddress aRangeAddress ;
if ( ! convertStringAddress ( _rAddress , aRangeAddress ) )
2003-10-21 07:39:21 +00:00
return xSource ;
2009-04-23 10:42:05 +00:00
// create a range object for this address
xSource = xSource . query ( createDocumentDependentInstance (
SERVICE_CELLRANGELISTSOURCE ,
PROPERTY_LIST_CELL_RANGE ,
makeAny ( aRangeAddress )
) ) ;
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
return xSource ;
}
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
//------------------------------------------------------------------------
2013-04-07 12:06:47 +02:00
OUString FormCellBindingHelper : : getStringAddressFromCellBinding ( const Reference < XValueBinding > & _rxBinding ) const
2009-04-23 10:42:05 +00:00
{
OSL_PRECOND ( ! _rxBinding . is ( ) | | isCellBinding ( _rxBinding ) , " FormCellBindingHelper::getStringAddressFromCellBinding: this is no cell binding! " ) ;
2003-10-21 07:39:21 +00:00
2013-04-07 12:06:47 +02:00
OUString sAddress ;
2009-04-23 10:42:05 +00:00
try
{
Reference < XPropertySet > xBindingProps ( _rxBinding , UNO_QUERY ) ;
OSL_ENSURE ( xBindingProps . is ( ) | | ! _rxBinding . is ( ) , " FormCellBindingHelper::getStringAddressFromCellBinding: no property set for the binding! " ) ;
if ( xBindingProps . is ( ) )
2003-10-21 07:39:21 +00:00
{
2009-04-23 10:42:05 +00:00
CellAddress aAddress ;
xBindingProps - > getPropertyValue ( PROPERTY_BOUND_CELL ) > > = aAddress ;
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
Any aStringAddress ;
doConvertAddressRepresentations ( PROPERTY_ADDRESS , makeAny ( aAddress ) ,
PROPERTY_FILE_REPRESENTATION , aStringAddress , false ) ;
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
aStringAddress > > = sAddress ;
}
}
catch ( const Exception & )
2003-10-21 07:39:21 +00:00
{
2011-03-19 14:09:49 +01:00
OSL_FAIL ( " FormCellBindingHelper::getStringAddressFromCellBinding: caught an exception! " ) ;
2009-04-23 10:42:05 +00:00
}
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
return sAddress ;
}
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
//------------------------------------------------------------------------
2013-04-07 12:06:47 +02:00
OUString FormCellBindingHelper : : getStringAddressFromCellListSource ( const Reference < XListEntrySource > & _rxSource ) const
2009-04-23 10:42:05 +00:00
{
OSL_PRECOND ( ! _rxSource . is ( ) | | isCellRangeListSource ( _rxSource ) , " FormCellBindingHelper::getStringAddressFromCellListSource: this is no cell list source! " ) ;
2003-10-21 07:39:21 +00:00
2013-04-07 12:06:47 +02:00
OUString sAddress ;
2009-04-23 10:42:05 +00:00
try
2003-10-21 07:39:21 +00:00
{
2009-04-23 10:42:05 +00:00
Reference < XPropertySet > xSourceProps ( _rxSource , UNO_QUERY ) ;
OSL_ENSURE ( xSourceProps . is ( ) | | ! _rxSource . is ( ) , " FormCellBindingHelper::getStringAddressFromCellListSource: no property set for the list source! " ) ;
if ( xSourceProps . is ( ) )
2003-10-21 07:39:21 +00:00
{
2009-04-23 10:42:05 +00:00
CellRangeAddress aRangeAddress ;
xSourceProps - > getPropertyValue ( PROPERTY_LIST_CELL_RANGE ) > > = aRangeAddress ;
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
Any aStringAddress ;
doConvertAddressRepresentations ( PROPERTY_ADDRESS , makeAny ( aRangeAddress ) ,
PROPERTY_FILE_REPRESENTATION , aStringAddress , true ) ;
aStringAddress > > = sAddress ;
}
2003-10-21 07:39:21 +00:00
}
2009-04-23 10:42:05 +00:00
catch ( const Exception & )
2003-10-21 07:39:21 +00:00
{
2011-03-19 14:09:49 +01:00
OSL_FAIL ( " FormCellBindingHelper::getStringAddressFromCellListSource: caught an exception! " ) ;
2003-10-21 07:39:21 +00:00
}
2009-04-23 10:42:05 +00:00
return sAddress ;
}
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
//------------------------------------------------------------------------
2013-04-07 12:06:47 +02:00
bool FormCellBindingHelper : : isSpreadsheetDocumentWhichSupplies ( const Reference < XSpreadsheetDocument > & _rxDocument , const OUString & _rService ) SAL_THROW ( ( ) )
2009-04-23 10:42:05 +00:00
{
bool bYesItIs = false ;
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
try
{
Reference < XServiceInfo > xSI ( _rxDocument , UNO_QUERY ) ;
if ( xSI . is ( ) & & xSI - > supportsService ( SERVICE_SPREADSHEET_DOCUMENT ) )
2003-10-21 07:39:21 +00:00
{
2009-04-23 10:42:05 +00:00
Reference < XMultiServiceFactory > xDocumentFactory ( _rxDocument , UNO_QUERY ) ;
OSL_ENSURE ( xDocumentFactory . is ( ) , " FormCellBindingHelper::isSpreadsheetDocumentWhichSupplies: spreadsheet document, but no factory? " ) ;
2013-04-07 12:06:47 +02:00
Sequence < OUString > aAvailableServices ;
2009-04-23 10:42:05 +00:00
if ( xDocumentFactory . is ( ) )
aAvailableServices = xDocumentFactory - > getAvailableServiceNames ( ) ;
2013-04-07 12:06:47 +02:00
const OUString * pFound = : : std : : find_if (
2009-04-23 10:42:05 +00:00
aAvailableServices . getConstArray ( ) ,
aAvailableServices . getConstArray ( ) + aAvailableServices . getLength ( ) ,
StringCompare ( _rService )
) ;
if ( pFound - aAvailableServices . getConstArray ( ) < aAvailableServices . getLength ( ) )
{
bYesItIs = true ;
}
2003-10-21 07:39:21 +00:00
}
}
2009-04-23 10:42:05 +00:00
catch ( const Exception & )
2003-10-21 07:39:21 +00:00
{
2011-03-19 14:09:49 +01:00
OSL_FAIL ( " FormCellBindingHelper::isSpreadsheetDocumentWhichSupplies: caught an exception! " ) ;
2009-04-23 10:42:05 +00:00
}
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
return bYesItIs ;
}
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
//------------------------------------------------------------------------
2013-04-07 12:06:47 +02:00
bool FormCellBindingHelper : : isSpreadsheetDocumentWhichSupplies ( const OUString & _rService ) const SAL_THROW ( ( ) )
2009-04-23 10:42:05 +00:00
{
return isSpreadsheetDocumentWhichSupplies ( m_xDocument , _rService ) ;
}
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
//------------------------------------------------------------------------
bool FormCellBindingHelper : : isListCellRangeAllowed ( const Reference < XModel > & _rxDocument )
{
return isSpreadsheetDocumentWhichSupplies (
Reference < XSpreadsheetDocument > ( _rxDocument , UNO_QUERY ) ,
SERVICE_CELLRANGELISTSOURCE
) ;
}
//------------------------------------------------------------------------
bool FormCellBindingHelper : : isListCellRangeAllowed ( ) const
{
bool bAllow ( false ) ;
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
Reference < XListEntrySink > xSink ( m_xControlModel , UNO_QUERY ) ;
if ( xSink . is ( ) )
2003-10-21 07:39:21 +00:00
{
2009-04-23 10:42:05 +00:00
bAllow = isSpreadsheetDocumentWhichSupplies ( SERVICE_CELLRANGELISTSOURCE ) ;
2003-10-21 07:39:21 +00:00
}
2009-04-23 10:42:05 +00:00
return bAllow ;
}
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
//------------------------------------------------------------------------
bool FormCellBindingHelper : : isCellBindingAllowed ( ) const
{
bool bAllow ( false ) ;
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
Reference < XBindableValue > xBindable ( m_xControlModel , UNO_QUERY ) ;
if ( xBindable . is ( ) )
2003-10-21 07:39:21 +00:00
{
2009-04-23 10:42:05 +00:00
// the control can potentially be bound to an external value
// Does it live within a Calc document, and is able to supply CellBindings?
bAllow = isSpreadsheetDocumentWhichSupplies ( SERVICE_CELLVALUEBINDING ) ;
2003-10-21 07:39:21 +00:00
}
2009-04-23 10:42:05 +00:00
return bAllow ;
}
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
//------------------------------------------------------------------------
bool FormCellBindingHelper : : isCellBindingAllowed ( const Reference < XModel > & _rxDocument )
{
return isSpreadsheetDocumentWhichSupplies (
Reference < XSpreadsheetDocument > ( _rxDocument , UNO_QUERY ) ,
SERVICE_CELLVALUEBINDING
) ;
}
//------------------------------------------------------------------------
bool FormCellBindingHelper : : isCellBinding ( const Reference < XValueBinding > & _rxBinding ) const
{
return doesComponentSupport ( _rxBinding . get ( ) , SERVICE_CELLVALUEBINDING ) ;
}
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
//------------------------------------------------------------------------
bool FormCellBindingHelper : : isCellIntegerBinding ( const Reference < XValueBinding > & _rxBinding ) const
{
return doesComponentSupport ( _rxBinding . get ( ) , SERVICE_LISTINDEXCELLBINDING ) ;
}
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
//------------------------------------------------------------------------
bool FormCellBindingHelper : : isCellRangeListSource ( const Reference < XListEntrySource > & _rxSource ) const
{
return doesComponentSupport ( _rxSource . get ( ) , SERVICE_CELLRANGELISTSOURCE ) ;
}
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
//------------------------------------------------------------------------
2013-04-07 12:06:47 +02:00
bool FormCellBindingHelper : : doesComponentSupport ( const Reference < XInterface > & _rxComponent , const OUString & _rService ) const
2009-04-23 10:42:05 +00:00
{
Reference < XServiceInfo > xSI ( _rxComponent , UNO_QUERY ) ;
2013-04-02 23:00:47 +02:00
bool bDoes = xSI . is ( ) & & xSI - > supportsService ( _rService ) ;
2009-04-23 10:42:05 +00:00
return bDoes ;
}
//------------------------------------------------------------------------
Reference < XValueBinding > FormCellBindingHelper : : getCurrentBinding ( ) const
{
Reference < XValueBinding > xBinding ;
Reference < XBindableValue > xBindable ( m_xControlModel , UNO_QUERY ) ;
if ( xBindable . is ( ) )
xBinding = xBindable - > getValueBinding ( ) ;
return xBinding ;
}
//------------------------------------------------------------------------
Reference < XListEntrySource > FormCellBindingHelper : : getCurrentListSource ( ) const
{
Reference < XListEntrySource > xSource ;
Reference < XListEntrySink > xSink ( m_xControlModel , UNO_QUERY ) ;
if ( xSink . is ( ) )
xSource = xSink - > getListEntrySource ( ) ;
return xSource ;
}
//------------------------------------------------------------------------
void FormCellBindingHelper : : setBinding ( const Reference < XValueBinding > & _rxBinding )
{
Reference < XBindableValue > xBindable ( m_xControlModel , UNO_QUERY ) ;
OSL_PRECOND ( xBindable . is ( ) , " FormCellBindingHelper::setBinding: the object is not bindable! " ) ;
if ( xBindable . is ( ) )
xBindable - > setValueBinding ( _rxBinding ) ;
}
//------------------------------------------------------------------------
void FormCellBindingHelper : : setListSource ( const Reference < XListEntrySource > & _rxSource )
{
Reference < XListEntrySink > xSink ( m_xControlModel , UNO_QUERY ) ;
OSL_PRECOND ( xSink . is ( ) , " FormCellBindingHelper::setListSource: the object is no list entry sink! " ) ;
if ( xSink . is ( ) )
xSink - > setListEntrySource ( _rxSource ) ;
}
//------------------------------------------------------------------------
2013-04-07 12:06:47 +02:00
Reference < XInterface > FormCellBindingHelper : : createDocumentDependentInstance ( const OUString & _rService , const OUString & _rArgumentName ,
2009-04-23 10:42:05 +00:00
const Any & _rArgumentValue ) const
{
Reference < XInterface > xReturn ;
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
Reference < XMultiServiceFactory > xDocumentFactory ( m_xDocument , UNO_QUERY ) ;
OSL_ENSURE ( xDocumentFactory . is ( ) , " FormCellBindingHelper::createDocumentDependentInstance: no document service factory! " ) ;
if ( xDocumentFactory . is ( ) )
{
try
2003-10-21 07:39:21 +00:00
{
2012-01-25 21:59:48 -02:00
if ( ! _rArgumentName . isEmpty ( ) )
2003-10-21 07:39:21 +00:00
{
2009-04-23 10:42:05 +00:00
NamedValue aArg ;
aArg . Name = _rArgumentName ;
aArg . Value = _rArgumentValue ;
Sequence < Any > aArgs ( 1 ) ;
aArgs [ 0 ] < < = aArg ;
xReturn = xDocumentFactory - > createInstanceWithArguments ( _rService , aArgs ) ;
2003-10-21 07:39:21 +00:00
}
2009-04-23 10:42:05 +00:00
else
2003-10-21 07:39:21 +00:00
{
2009-04-23 10:42:05 +00:00
xReturn = xDocumentFactory - > createInstance ( _rService ) ;
2003-10-21 07:39:21 +00:00
}
}
2009-04-23 10:42:05 +00:00
catch ( const Exception & )
{
2011-03-19 14:09:49 +01:00
OSL_FAIL ( " FormCellBindingHelper::createDocumentDependentInstance: could not create the binding at the document! " ) ;
2009-04-23 10:42:05 +00:00
}
2003-10-21 07:39:21 +00:00
}
2009-04-23 10:42:05 +00:00
return xReturn ;
}
2003-10-21 07:39:21 +00:00
2009-04-23 10:42:05 +00:00
//------------------------------------------------------------------------
2013-04-07 12:06:47 +02:00
bool FormCellBindingHelper : : doConvertAddressRepresentations ( const OUString & _rInputProperty , const Any & _rInputValue ,
const OUString & _rOutputProperty , Any & _rOutputValue , bool _bIsRange ) const SAL_THROW ( ( ) )
2009-04-23 10:42:05 +00:00
{
bool bSuccess = false ;
Reference < XPropertySet > xConverter (
createDocumentDependentInstance (
2013-03-01 10:31:52 +01:00
_bIsRange ? OUString ( SERVICE_RANGEADDRESS_CONVERSION ) : OUString ( SERVICE_ADDRESS_CONVERSION ) ,
2013-04-07 12:06:47 +02:00
OUString ( ) ,
2009-04-23 10:42:05 +00:00
Any ( )
) ,
UNO_QUERY
) ;
OSL_ENSURE ( xConverter . is ( ) , " FormCellBindingHelper::doConvertAddressRepresentations: could not get a converter service! " ) ;
if ( xConverter . is ( ) )
2003-10-21 07:39:21 +00:00
{
2009-04-23 10:42:05 +00:00
try
2003-10-21 07:39:21 +00:00
{
2009-04-23 10:42:05 +00:00
xConverter - > setPropertyValue ( _rInputProperty , _rInputValue ) ;
_rOutputValue = xConverter - > getPropertyValue ( _rOutputProperty ) ;
bSuccess = true ;
}
catch ( const Exception & )
{
2011-03-19 14:09:49 +01:00
OSL_FAIL ( " FormCellBindingHelper::doConvertAddressRepresentations: caught an exception! " ) ;
2003-10-21 07:39:21 +00:00
}
}
2009-04-23 10:42:05 +00:00
return bSuccess ;
}
2003-10-21 07:39:21 +00:00
//............................................................................
} // namespace xmloff
//............................................................................
2010-10-12 15:53:47 +02:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */