/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * 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 .
*/
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 )
{
Reference< TYPE > xTypedNode( _rxModelNode, UNO_QUERY ); if ( xTypedNode.is() ) return xTypedNode; else
{
Reference< XChild > xChild( _rxModelNode, UNO_QUERY ); if ( xChild.is() ) return getTypedModelNode< TYPE >( xChild->getParent() ); else return nullptr;
}
}
if ( !m_xDocument.is() )
m_xDocument.set(getDocument( m_xControlModel ), css::uno::UNO_QUERY);
OSL_ENSURE( m_xDocument.is(), "FormCellBindingHelper::FormCellBindingHelper: Did not find the spreadsheet document!" );
}
Reference< XValueBinding > FormCellBindingHelper::createCellBindingFromStringAddress( const OUString& _rAddress, bool _bUseIntegerBinding ) const
{
Reference< XValueBinding > xBinding; if ( !m_xDocument.is() ) // very bad ... return xBinding;
// get the UNO representation of the address
CellAddress aAddress; if ( _rAddress.isEmpty() || !convertStringAddress( _rAddress, aAddress ) ) return xBinding;
// create a range object for this address
xSource.set(createDocumentDependentInstance(
SERVICE_CELLRANGELISTSOURCE,
PROPERTY_LIST_CELL_RANGE,
Any( aRangeAddress )
), css::uno::UNO_QUERY);
return xSource;
}
OUString FormCellBindingHelper::getStringAddressFromCellBinding( const Reference< XValueBinding >& _rxBinding ) const
{
OSL_PRECOND( !_rxBinding.is() || isCellBinding( _rxBinding ), "FormCellBindingHelper::getStringAddressFromCellBinding: this is no cell binding!" );
OUString sAddress; try
{
Reference< XPropertySet > xBindingProps( _rxBinding, UNO_QUERY );
OSL_ENSURE( xBindingProps.is() || !_rxBinding.is(), "FormCellBindingHelper::getStringAddressFromCellBinding: no property set for the binding!" ); if ( xBindingProps.is() )
{
CellAddress aAddress;
xBindingProps->getPropertyValue( PROPERTY_BOUND_CELL ) >>= aAddress;
Reference< XBindableValue > xBindable( m_xControlModel, UNO_QUERY ); if ( xBindable.is() )
{ // 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 );
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.