using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::uno::UNO_SET_THROW; using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::RuntimeException; using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Sequence; using ::com::sun::star::frame::XFrame; using ::com::sun::star::frame::XController; using ::com::sun::star::frame::XModel; using ::com::sun::star::lang::EventObject; using ::com::sun::star::lang::XComponent; using ::com::sun::star::frame::XModel2; using ::com::sun::star::container::XEnumeration; using ::com::sun::star::util::XCloseable; using ::com::sun::star::awt::XTopWindow; using ::com::sun::star::embed::XComponentSupplier; using ::com::sun::star::ucb::XCommandProcessor; using ::com::sun::star::ucb::Command; using ::com::sun::star::document::XDocumentEventBroadcaster; using ::com::sun::star::beans::XPropertySet; using ::com::sun::star::beans::PropertyChangeEvent;
// helper structs namespace
{ struct SubComponentDescriptor
{ /// the name of the sub component, empty if it is yet unsaved
OUString sName; /// type of the component - an ElementType value, except for relation design
sal_Int32 nComponentType; /// the mode in which the sub component has been opened
ElementOpenMode eOpenMode; /// the frame which the component resides in. Must not be <NULL/>
Reference< XFrame > xFrame; /// the controller of the sub component. Must not be <NULL/>
Reference< XController > xController; /// the model of the sub component. Might be <NULL/>
Reference< XModel > xModel; /// the document definition which holds the component, if any; as CommandProcessor
Reference< XCommandProcessor > xComponentCommandProcessor; /// the document definition which holds the component, if any; as PropertySet
Reference< XPropertySet > xDocumentDefinitionProperties;
xFallback.set( _rCompDesc.xModel->getCurrentController() ); if ( xFallback == _rCompDesc.xController ) // don't accept the very same controller as fallback
xFallback.clear();
if ( !xFallback.is() )
{ // perhaps XModel2 can be of help here
Reference< XModel2 > xModel2( _rCompDesc.xModel, UNO_QUERY );
Reference< XEnumeration > xControllerEnum; if ( xModel2.is() )
xControllerEnum = xModel2->getControllers(); while ( xControllerEnum.is() && xControllerEnum->hasMoreElements() )
{
xFallback.set( xControllerEnum->nextElement(), UNO_QUERY ); if ( xFallback == _rCompDesc.xController )
xFallback.clear();
}
}
void SAL_CALL SubComponentManager::propertyChange( const PropertyChangeEvent& i_rEvent )
{ if ( i_rEvent.PropertyName != PROPERTY_NAME ) // by definition, it's allowed to broadcast more than what we've registered for return;
// find the sub component whose name changed for (auto & component : m_pData->m_aComponents)
{ if ( component.xDocumentDefinitionProperties != i_rEvent.Source ) continue;
if ( comp->xController == _rSource.Source )
{ if ( !comp->xModel.is() )
{
bRemove = true;
} else
{ // maybe this is just one view to the sub document, and only this view is closed if ( !lcl_fallbackToAnotherController( *comp ) )
{
bRemove = true;
}
}
} elseif ( comp->xModel == _rSource.Source )
{
bRemove = true;
}
#if OSL_DEBUG_LEVEL > 0 if ( !_rName.isEmpty() )
{ // check there does not already exist such a component auto subComponentNotExists = std::none_of(
m_pData->m_aComponents.begin(),
m_pData->m_aComponents.end(),
SubComponentMatch( _rName, _nComponentType, _eOpenMode )
);
OSL_ENSURE( subComponentNotExists, "already existent!" );
} #endif
SubComponentDescriptor aElement( _rName, _nComponentType, _eOpenMode, _rxComponent );
ENSURE_OR_THROW( aElement.xModel.is() || aElement.xController.is(), "illegal component" );
m_pData->m_aComponents.push_back( aElement );
// add as listener if ( aElement.xController.is() )
aElement.xController->addEventListener( this ); if ( aElement.xModel.is() )
aElement.xModel->addEventListener( this ); if ( aElement.xDocumentDefinitionProperties.is() )
aElement.xDocumentDefinitionProperties->addPropertyChangeListener( PROPERTY_NAME, this );
// notify this to interested parties
aGuard.clear();
lcl_notifySubComponentEvent( *m_pData, u"OnSubComponentOpened"_ustr, aElement );
}
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.