/* -*- 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 .
*/
// now the aggregate has a ref count of 2, but before setting the delegator it must be 1
_rxAggregateInstance.clear(); // now it should be the 1 we need here ...
Sequence< Type > SAL_CALL OGeometryControlModel_Base::getTypes( )
{ // our own types
Sequence< Type > aTypes = ::comphelper::concatSequences(
OPropertySetAggregationHelper::getTypes(),
getBaseTypes(),
OGCM_Base::getTypes()
);
if ( m_xAggregate.is() )
{ // retrieve the types of the aggregate
Reference< XTypeProvider > xAggregateTypeProv;
m_xAggregate->queryAggregation( cppu::UnoType<decltype(xAggregateTypeProv)>::get() ) >>= xAggregateTypeProv;
OSL_ENSURE( xAggregateTypeProv.is(), "OGeometryControlModel_Base::getTypes: aggregate should be a type provider!" );
Sequence< Type > aAggTypes; if ( xAggregateTypeProv.is() )
aAggTypes = xAggregateTypeProv->getTypes();
switch ( nHandle )
{ case GCM_PROPERTY_ID_POS_X: aValue <<= m_nPosX; break; case GCM_PROPERTY_ID_POS_Y: aValue <<= m_nPosY; break; case GCM_PROPERTY_ID_WIDTH: aValue <<= m_nWidth; break; case GCM_PROPERTY_ID_HEIGHT: aValue <<= m_nHeight; break; case GCM_PROPERTY_ID_NAME: aValue <<= m_aName; break; case GCM_PROPERTY_ID_TABINDEX: aValue <<= m_nTabIndex; break; case GCM_PROPERTY_ID_STEP: aValue <<= m_nStep; break; case GCM_PROPERTY_ID_TAG: aValue <<= m_aTag; break; case GCM_PROPERTY_ID_RESOURCERESOLVER: aValue <<= m_xStrResolver; break; default: OSL_FAIL( "ImplGetPropertyValueByHandle - unknown Property" );
}
return aValue;
}
void OGeometryControlModel_Base::ImplSetPropertyValueByHandle(sal_Int32 nHandle, const css::uno::Any& aValue)
{ switch ( nHandle )
{ case GCM_PROPERTY_ID_POS_X: aValue >>= m_nPosX; break; case GCM_PROPERTY_ID_POS_Y: aValue >>= m_nPosY; break; case GCM_PROPERTY_ID_WIDTH: aValue >>= m_nWidth; break; case GCM_PROPERTY_ID_HEIGHT: aValue >>= m_nHeight; break; case GCM_PROPERTY_ID_NAME: aValue >>= m_aName; break; case GCM_PROPERTY_ID_TABINDEX: aValue >>= m_nTabIndex; break; case GCM_PROPERTY_ID_STEP: aValue >>= m_nStep; break; case GCM_PROPERTY_ID_TAG: aValue >>= m_aTag; break; case GCM_PROPERTY_ID_RESOURCERESOLVER: aValue >>= m_xStrResolver; break; default: OSL_FAIL( "ImplSetPropertyValueByHandle - unknown Property" );
}
}
Any SAL_CALL OGeometryControlModel_Base::queryAggregation( const Type& _rType )
{
Any aReturn; if (_rType.equals(cppu::UnoType<XCloneable>::get()) && !m_bCloneable) // somebody is asking for the XCloneable interface, but our aggregate does not support it // -> outta here // (need this extra check, cause OGCM_Base::queryAggregation would return this interface // in every case) return aReturn;
aReturn = OGCM_Base::queryAggregation(_rType); // the basic interfaces (XInterface, XAggregation etc)
if (!aReturn.hasValue())
aReturn = OPropertySetAggregationHelper::queryInterface(_rType); // the property set related interfaces
if (!aReturn.hasValue() && m_xAggregate.is())
aReturn = m_xAggregate->queryAggregation(_rType); // the interfaces our aggregate can provide
// let the aggregate create its own clone // the interface
Reference< XCloneable > xCloneAccess;
m_xAggregate->queryAggregation(cppu::UnoType<decltype(xCloneAccess)>::get()) >>= xCloneAccess;
OSL_ENSURE(xCloneAccess.is(), "OGeometryControlModel_Base::createClone: suspicious aggregate!"); if (!xCloneAccess.is()) return Reference< XCloneable >(); // the aggregate's clone
Reference< XCloneable > xAggregateClone = xCloneAccess->createClone();
OSL_ENSURE(xAggregateClone.is(), "OGeometryControlModel_Base::createClone: suspicious return of the aggregate!");
// create a new wrapper aggregating this return value
rtl::Reference<OGeometryControlModel_Base> pOwnClone = createClone_Impl(xAggregateClone);
OSL_ENSURE(pOwnClone, "OGeometryControlModel_Base::createClone: invalid derivee behaviour!");
OSL_ENSURE(!xAggregateClone.is(), "OGeometryControlModel_Base::createClone: invalid ctor behaviour!"); // should have been reset
// for creating class-unique PropertySetInfo's, we need some info: namespace { HashMapString2Int gServiceSpecifierMap; } // this one maps from a String, which is the service specifier for our // aggregate, to a unique id
namespace { PropSeqArray gAggregateProperties; } // this one contains the properties which belong to all the unique ids // in ServiceSpecifierMap
namespace { IntArrayArray gAmbiguousPropertyIds; } // the ids of the properties which we as well as our aggregate supply // For such props, we let our base class handle them, and whenever such // a prop is set, we forward this to our aggregate.
// With this, we can ensure that two instances of this class share the // same PropertySetInfo if and only if both aggregates have the same // service specifier.
// look for duplicates, and remember them
IntArrayArray::value_type& rDuplicateIds = gAmbiguousPropertyIds[ _nId ]; // for this, sort the aggregate properties auto [begin, end] = asNonConstRange(aAggregateProps);
::std::sort(
begin,
end,
PropertyNameLess()
);
// now loop through our own props for (const Property& rProp : aProps)
{ // look for the current property in the properties of our aggregate const Property* pAggPropPos = ::std::find_if( std::cbegin(aAggregateProps), std::cend(aAggregateProps), PropertyNameEqual( rProp.Name ) ); if ( pAggPropPos != std::cend(aAggregateProps) )
{ // found a duplicate // -> remove from the aggregate property sequence
::comphelper::removeElementAt( aAggregateProps, pAggPropPos - std::cbegin(aAggregateProps) );
// and additionally, remember the id of this property
rDuplicateIds.push_back( rProp.Handle );
}
}
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.