/* -*- 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 .
*/
// copy the uno control model const uno::Reference< awt::XControlModel >& xSourceControlModel = rSource.GetUnoControlModel(); if ( xSourceControlModel.is() )
{ try
{
uno::Reference< util::XCloneable > xClone( xSourceControlModel, uno::UNO_QUERY_THROW );
m_xUnoControlModel.set( xClone->createClone(), uno::UNO_QUERY_THROW );
} catch( const uno::Exception& )
{
DBG_UNHANDLED_EXCEPTION("svx");
}
}
// get service name of the control from the control model
uno::Reference< beans::XPropertySet > xSet(m_xUnoControlModel, uno::UNO_QUERY); if (xSet.is())
{
uno::Any aValue( xSet->getPropertyValue(u"DefaultControl"_ustr) );
OUString aStr;
m_pImpl->pEventListener = new SdrControlEventListenerImpl(this);
// only an owner may create independently if (!rModelName.isEmpty())
CreateUnoControlModel(rModelName,rxSFac);
}
SdrUnoObj::~SdrUnoObj()
{ try
{ // clean up the control model
uno::Reference< lang::XComponent > xComp(m_xUnoControlModel, uno::UNO_QUERY); if (xComp.is())
{ // is the control model owned by its environment?
uno::Reference< container::XChild > xContent(m_xUnoControlModel, uno::UNO_QUERY); if (xContent.is() && !xContent->getParent().is())
xComp->dispose(); else
m_pImpl->pEventListener->StopListening(xComp);
}
} catch( const uno::Exception& )
{
TOOLS_WARN_EXCEPTION( "svx", "SdrUnoObj::~SdrUnoObj" );
}
}
bool SdrUnoObj::hasSpecialDrag() const
{ // no special drag; we have no rounding rect and // do want frame handles returnfalse;
}
void SdrUnoObj::NbcSetLayer( SdrLayerID _nLayer )
{ if ( GetLayer() == _nLayer )
{ // redundant call -> not interested in doing anything here
SdrRectObj::NbcSetLayer( _nLayer ); return;
}
// we need some special handling here in case we're moved from an invisible layer // to a visible one, or vice versa // (relative to a layer. Remember that the visibility of a layer is a view attribute // - the same layer can be visible in one view, and invisible in another view, at the // same time)
// collect all views in which our old layer is visible
o3tl::sorted_vector< SdrView* > aPreviouslyVisible;
// collect all views in which our new layer is visible
o3tl::sorted_vector< SdrView* > aNewlyVisible;
SdrViewIter::ForAllViews( this,
[&aPreviouslyVisible, &aNewlyVisible] (SdrView* pView)
{ if ( aPreviouslyVisible.erase(pView) == 0 )
{ // in pView, we were visible _before_ the layer change, and are // _not_ visible after the layer change // => remember this view, as our visibility there changed
aNewlyVisible.insert( pView );
}
});
// now aPreviouslyVisible contains all views where we became invisible for (constauto& rpView : aPreviouslyVisible)
{
lcl_ensureControlVisibility( rpView, this, false );
}
// and aNewlyVisible all views where we became visible for (constauto& rpView : aNewlyVisible)
{
lcl_ensureControlVisibility( rpView, this, true );
}
}
void SdrUnoObj::SetUnoControlModel( const uno::Reference< awt::XControlModel >& xModel)
{ if (m_xUnoControlModel.is())
{
uno::Reference< lang::XComponent > xComp(m_xUnoControlModel, uno::UNO_QUERY); if (xComp.is())
m_pImpl->pEventListener->StopListening(xComp);
}
m_xUnoControlModel = xModel;
// control model has to contain service name of the control if (m_xUnoControlModel.is())
{
uno::Reference< beans::XPropertySet > xSet(m_xUnoControlModel, uno::UNO_QUERY); if (xSet.is())
{
uno::Any aValue( xSet->getPropertyValue(u"DefaultControl"_ustr) );
OUString aStr; if( aValue >>= aStr )
m_aUnoControlTypeName = aStr;
}
uno::Reference< lang::XComponent > xComp(m_xUnoControlModel, uno::UNO_QUERY); if (xComp.is())
m_pImpl->pEventListener->StartListening(xComp);
}
// invalidate all ViewObject contacts
ViewContactOfUnoControl* pVC = nullptr; if ( impl_getViewContact( pVC ) )
{ // flushViewObjectContacts() removes all existing VOCs for the local DrawHierarchy. This // is always allowed since they will be re-created on demand (and with the changed model)
GetViewContact().flushViewObjectContacts();
}
}
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.