/* -*- 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 .
*/
/** Container for a specific type of drawing object in a spreadsheet.
Derived classes provide all required functionality specific to the type of shapes covered by the container.
*/ class ScVbaObjectContainer : public ::cppu::WeakImplHelper< container::XIndexAccess >
{ public: /// @throws uno::RuntimeException explicit ScVbaObjectContainer(
uno::Reference< XHelperInterface > xParent,
uno::Reference< uno::XComponentContext > xContext, const uno::Reference< frame::XModel >& rxModel, const uno::Reference< sheet::XSpreadsheet >& rxSheet, const uno::Type& rVbaType );
/** Returns the VBA helper interface of the VBA collection object. */ const uno::Reference< XHelperInterface >& getParent() const { return mxParent; } /** Returns the component context of the VBA collection object. */ const uno::Reference< uno::XComponentContext >& getContext() const { return mxContext; } /** Returns the VBA type information of the objects in this container. */ const uno::Type& getVbaType() const { return maVbaType; }
/** Collects all shapes supported by this instance and inserts them into the internal shape vector.
@throws uno::RuntimeException
*/ void collectShapes(); /** Creates and returns a new UNO shape.
@throws uno::RuntimeException
*/
uno::Reference< drawing::XShape > createShape( const awt::Point& rPos, const awt::Size& rSize ); /** Inserts the passed shape into the draw page and into this container, and returns its index in the draw page.
@throws uno::RuntimeException
*/
sal_Int32 insertShape( const uno::Reference< drawing::XShape >& rxShape ); /** Creates and returns a new VBA implementation object for the passed shape.
@throws uno::RuntimeException
*/
::rtl::Reference< ScVbaSheetObjectBase > createVbaObject( const uno::Reference< drawing::XShape >& rxShape ); /** Creates and returns a new VBA implementation object for the passed shape in an Any.
@throws uno::RuntimeException
*/
uno::Any createCollectionObject( const uno::Any& rSource ); /** Returns the VBA implementation object with the specified name.
protected: /** Derived classes return true, if the passed shape is supported by the instance. */ virtualbool implPickShape( const uno::Reference< drawing::XShape >& rxShape ) const = 0; /** Derived classes create and return a new VBA implementation object for the passed shape.
@throws uno::RuntimeException
*/ virtual rtl::Reference<ScVbaSheetObjectBase> implCreateVbaObject( const uno::Reference< drawing::XShape >& rxShape ) = 0; /** Derived classes return the service name of the UNO shape. */ virtual OUString implGetShapeServiceName() const = 0;
/** Returns the shape name via 'Name' property of the UNO shape. May be overwritten.
@throws uno::RuntimeException
*/ virtual OUString implGetShapeName( const uno::Reference< drawing::XShape >& rxShape ) const; /** Is called when a new UNO shape has been created but not yet inserted into the drawing page.
void ScVbaControlContainer::implOnShapeCreated( const uno::Reference< drawing::XShape >& rxShape )
{ // passed shape must be a control shape
uno::Reference< drawing::XControlShape > xControlShape( rxShape, uno::UNO_QUERY_THROW );
// create the UNO control model
uno::Reference< form::XFormComponent > xFormComponent( mxFactory->createInstance( maModelServiceName ), uno::UNO_QUERY_THROW );
uno::Reference< awt::XControlModel > xControlModel( xFormComponent, uno::UNO_QUERY_THROW );
// insert the control model into the form and the shape
createForm();
mxFormIC->insertByIndex( mxFormIC->getCount(), uno::Any( xFormComponent ) );
xControlShape->setControl( xControlModel );
}
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 und die Messung sind noch experimentell.