/* -*- 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 .
*/
m_xDocument.set(_rxContextDocument, css::uno::UNO_QUERY);
OSL_ENSURE( m_xDocument.is(), "CellBindingHelper::CellBindingHelper: This is no spreadsheet document!" );
sal_Int16 CellBindingHelper::getControlSheetIndex( Reference< XSpreadsheet >& _out_rxSheet ) const
{
sal_Int16 nSheetIndex = -1; // every sheet has a draw page, and every draw page has a forms collection. // Our control, OTOH, belongs to a forms collection. Match these... try
{ // for determining the draw page, we need the forms collection which // the object belongs to. This is the first object up the hierarchy which is // *no* XForm (and, well, no XGridColumnFactory)
Reference< XChild > xCheck( m_xControlModel, UNO_QUERY );
Reference< XForm > xParentAsForm; if ( xCheck.is() ) xParentAsForm.set(xCheck->getParent(), css::uno::UNO_QUERY);
Reference< XGridColumnFactory > xParentAsGrid; if ( xCheck.is() ) xParentAsGrid.set(xCheck->getParent(), css::uno::UNO_QUERY);
Reference< XValueBinding > CellBindingHelper::createCellBindingFromStringAddress( const OUString& _rAddress, bool _bSupportIntegerExchange ) 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_SHEET_CELLRANGE_LISTSOURCE,
PROPERTY_LIST_CELL_RANGE,
Any( aRangeAddress )
), css::uno::UNO_QUERY);
// first, we only offer this for controls which allow bindings in general
Reference< XBindableValue > xBindable( m_xControlModel, UNO_QUERY ); if ( !xBindable.is() )
bAllow = false;
// then, we must live in a spreadsheet document which can provide the special // service needed for exchanging integer values if ( bAllow )
bAllow = isSpreadsheetDocumentWhichSupplies( SERVICE_SHEET_CELL_INT_BINDING );
// then, we only offer this for list boxes if ( bAllow )
{ try
{
sal_Int16 nClassId = FormComponentType::CONTROL;
m_xControlModel->getPropertyValue( PROPERTY_CLASSID ) >>= nClassId; if ( FormComponentType::LISTBOX != nClassId )
bAllow = false;
} catch( const Exception& )
{
TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "CellBindingHelper::isCellIntegerBindingAllowed" ); // are there really control models which survive isCellBindingAllowed, but don't have a ClassId // property?
bAllow = false;
}
}
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_SHEET_CELL_BINDING );
}
// disallow for some types // TODO: shouldn't the XBindableValue supply a list of supported types, and we can distinguish // using this list? The current behavior below is somewhat hackish... if ( bAllow )
{ try
{
sal_Int16 nClassId = FormComponentType::CONTROL;
m_xControlModel->getPropertyValue( PROPERTY_CLASSID ) >>= nClassId; if ( ( FormComponentType::DATEFIELD == nClassId ) || ( FormComponentType::TIMEFIELD == nClassId ) )
bAllow = false;
} catch( const Exception& )
{
TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "CellBindingHelper::isCellBindingAllowed" );
bAllow = false;
}
} return bAllow;
}
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.