/* -*- 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 .
*/
uno::Reference< frame::XController > ChartModel::impl_getCurrentController()
{ //@todo? hold only weak references to controllers
// get the last active controller of this model if( m_xCurrentController.is() ) return m_xCurrentController;
// get the first controller of this model if( m_aControllers.getLength() )
{
uno::Reference<uno::XInterface> xI = m_aControllers.getInterface(0); return uno::Reference<frame::XController>( xI, uno::UNO_QUERY );
}
//return nothing if no controllers are connected at all return uno::Reference< frame::XController > ();
}
sal_Bool SAL_CALL ChartModel::attachResource( const OUString& rURL
, const uno::Sequence< beans::PropertyValue >& rMediaDescriptor )
{ /* The method attachResource() is used by the frame loader implementations to inform the model about its URL and MediaDescriptor.
*/
LifeTimeGuard aGuard(m_aLifeTimeManager); if(!aGuard.startApiCall()) returnfalse; //behave passive if already disposed or closed or throw exception @todo? //mutex is acquired
if(!m_aResource.isEmpty())//we have a resource already //@todo? or is setting a new resource allowed? returnfalse;
m_aResource = rURL;
m_aMediaDescriptor = rMediaDescriptor;
//@todo ? check rURL ?? //@todo ? evaluate m_aMediaDescriptor; //@todo ? ... ??? --> nothing, this method is only for setting information
uno::Sequence< beans::PropertyValue > SAL_CALL ChartModel::getArgs()
{ /* The method getArgs() returns a sequence of property values that report the resource description according to com.sun.star.document.MediaDescriptor, specified on loading or saving with storeAsURL.
*/
LifeTimeGuard aGuard(m_aLifeTimeManager); if(!aGuard.startApiCall()) return uno::Sequence< beans::PropertyValue >(); //behave passive if already disposed or closed or throw exception @todo? //mutex is acquired
return m_aMediaDescriptor;
}
void SAL_CALL ChartModel::connectController( const uno::Reference< frame::XController >& xController )
{ //@todo? this method is declared as oneway -> ...?
LifeTimeGuard aGuard(m_aLifeTimeManager); if(!aGuard.startApiCall()) return ; //behave passive if already disposed or closed //mutex is acquired
//case: current controller is disconnected: if( m_xCurrentController == xController )
m_xCurrentController.clear();
if (m_xRangeHighlighter)
{
m_xRangeHighlighter->dispose();
m_xRangeHighlighter.clear();
}
DisposeHelper::DisposeAndClear(m_xPopupRequest);
}
void SAL_CALL ChartModel::lockControllers()
{ /* suspends some notifications to the controllers which are used for display updates.
The calls to lockControllers() and unlockControllers() may be nested and even overlapping, but they must be in pairs. While there is at least one lock remaining, some notifications for display updates are not broadcasted.
*/
//@todo? this method is declared as oneway -> ...?
LifeTimeGuard aGuard(m_aLifeTimeManager); if(!aGuard.startApiCall()) return; //behave passive if already disposed or closed or throw exception @todo?
++m_nControllerLockCount;
}
void SAL_CALL ChartModel::unlockControllers()
{ /* resumes the notifications which were suspended by lockControllers() .
The calls to lockControllers() and unlockControllers() may be nested and even overlapping, but they must be in pairs. While there is at least one lock remaining, some notifications for display updates are not broadcasted.
*/
//@todo? this method is declared as oneway -> ...?
LifeTimeGuard aGuard(m_aLifeTimeManager); if(!aGuard.startApiCall()) return; //behave passive if already disposed or closed or throw exception @todo? if( m_nControllerLockCount == 0 )
{
SAL_WARN("chart2", "ChartModel: unlockControllers called with m_nControllerLockCount == 0" ); return;
}
--m_nControllerLockCount; if( m_nControllerLockCount == 0 && m_bUpdateNotificationsPending )
{
aGuard.clear();
impl_notifyModifiedListeners();
}
}
sal_Bool SAL_CALL ChartModel::hasControllersLocked()
{
LifeTimeGuard aGuard(m_aLifeTimeManager); if(!aGuard.startApiCall()) returnfalse; //behave passive if already disposed or closed or throw exception @todo? return ( m_nControllerLockCount != 0 ) ;
}
uno::Reference< frame::XController > SAL_CALL ChartModel::getCurrentController()
{
LifeTimeGuard aGuard(m_aLifeTimeManager); if(!aGuard.startApiCall()) throw lang::DisposedException(
u"getCurrentController was called on an already disposed or closed model"_ustr, static_cast< ::cppu::OWeakObject* >(this) );
return impl_getCurrentController();
}
void SAL_CALL ChartModel::setCurrentController( const uno::Reference< frame::XController >& xController )
{
LifeTimeGuard aGuard(m_aLifeTimeManager); if(!aGuard.startApiCall()) throw lang::DisposedException(
u"setCurrentController was called on an already disposed or closed model"_ustr, static_cast< ::cppu::OWeakObject* >(this) );
//OSL_ENSURE( impl_isControllerConnected(xController), "setCurrentController is called with a Controller which is not connected" ); if(!impl_isControllerConnected(xController)) throw container::NoSuchElementException(
u"setCurrentController is called with a Controller which is not connected"_ustr, static_cast< ::cppu::OWeakObject* >(this) );
m_xCurrentController = xController;
if (m_xRangeHighlighter)
{
m_xRangeHighlighter->dispose();
m_xRangeHighlighter.clear();
}
DisposeHelper::DisposeAndClear(m_xPopupRequest);
}
uno::Reference< uno::XInterface > SAL_CALL ChartModel::getCurrentSelection()
{
LifeTimeGuard aGuard(m_aLifeTimeManager); if(!aGuard.startApiCall()) throw lang::DisposedException(
u"getCurrentSelection was called on an already disposed or closed model"_ustr, static_cast< ::cppu::OWeakObject* >(this) );
//This object should release all resources and references in the //easiest possible manner //This object must notify all registered listeners using the method //<member>XEventListener::disposing</member>
//hold no mutex if( !m_aLifeTimeManager.dispose() ) return;
//--release all resources and references //// @todo
if ( m_xDiagram.is() )
m_xDiagram->removeModifyListener( this );
if ( m_xDataProvider.is() )
{
Reference<util::XModifyBroadcaster> xModifyBroadcaster( m_xDataProvider, uno::UNO_QUERY ); if ( xModifyBroadcaster.is() )
xModifyBroadcaster->removeModifyListener( this );
}
m_xStorage.clear(); // just clear, don't dispose - we're not the owner
if ( m_pUndoManager.is() )
m_pUndoManager->disposing();
m_pUndoManager.clear(); // that's important, since the UndoManager implementation delegates its ref counting to ourself.
if( m_xOldModelAgg.is()) // #i120828#, to release cyclic reference to ChartModel object
m_xOldModelAgg->setDelegator( nullptr );
m_aControllers.disposeAndClear( lang::EventObject( static_cast< cppu::OWeakObject * >( this )));
m_xCurrentController.clear();
if (m_xRangeHighlighter)
{
m_xRangeHighlighter->dispose();
m_xRangeHighlighter.clear();
}
DisposeHelper::DisposeAndClear(m_xPopupRequest);
if( !m_aLifeTimeManager.g_close_startTryClose( bDeliverOwnership ) ) return; //no mutex is acquired
// At the end of this method may we must dispose ourself ... // and may nobody from outside hold a reference to us ... // then it's a good idea to do that by ourself.
uno::Reference< uno::XInterface > xSelfHold( static_cast< ::cppu::OWeakObject* >(this) );
//the listeners have had no veto //check whether we self can close
{
util::CloseVetoException aVetoException(
u"the model itself could not be closed"_ustr, static_cast< ::cppu::OWeakObject* >(this) );
void SAL_CALL ChartModel::createInternalDataProvider( sal_Bool bCloneExistingData )
{ // don't lock the mutex, because this call calls out to code that tries to // lock the solar mutex. On the other hand, a paint locks the solar mutex // and calls to the model lock the model's mutex => deadlock // @todo: lock a separate mutex in the InternalData class if( !hasInternalDataProvider() )
{ if( bCloneExistingData )
m_xInternalDataProvider = new InternalDataProvider( this, /*bConnectToModel*/true, /*bDefaultDataInColumns*/ true ); else
{
m_xInternalDataProvider = new InternalDataProvider( nullptr, /*bConnectToModel*/true, /*bDefaultDataInColumns*/ true );
m_xInternalDataProvider->setChartModel(this);
}
m_xDataProvider.set( m_xInternalDataProvider );
}
setModified( true );
}
void ChartModel::removeDataProviders()
{ if (m_xInternalDataProvider.is())
m_xInternalDataProvider.clear(); if (m_xDataProvider.is())
m_xDataProvider.clear();
}
//the numberformatter is kept independent of the data provider!
}
setModified( true );
}
void SAL_CALL ChartModel::attachNumberFormatsSupplier( const uno::Reference< util::XNumberFormatsSupplier >& xNewSupplier )
{
{ // Mostly the supplier is SvNumberFormatsSupplierObj, but sometimes it is reportdesign::OReportDefinition
MutexGuard aGuard( m_aModelMutex ); if( xNewSupplier == m_xNumberFormatsSupplier ) return; if( xNewSupplier == uno::Reference<XNumberFormatsSupplier>(m_xOwnNumberFormatsSupplier) ) return; if( m_xOwnNumberFormatsSupplier.is() && xNewSupplier.is() )
{ //@todo //merge missing numberformats from own to new formatter
} elseif( !xNewSupplier.is() )
{ if( m_xNumberFormatsSupplier.is() )
{ //@todo //merge missing numberformats from old numberformatter to own numberformatter //create own numberformatter if necessary
}
}
awt::Size SAL_CALL ChartModel::getVisualAreaSize( ::sal_Int64 nAspect )
{
OSL_ENSURE( nAspect == embed::Aspects::MSOLE_CONTENT, "No aspects other than content are supported" ); // other possible aspects are MSOLE_THUMBNAIL, MSOLE_ICON and MSOLE_DOCPRINT
return m_aVisualAreaSize;
}
embed::VisualRepresentation SAL_CALL ChartModel::getPreferredVisualRepresentation( ::sal_Int64 nAspect )
{
OSL_ENSURE( nAspect == embed::Aspects::MSOLE_CONTENT, "No aspects other than content are supported" );
embed::VisualRepresentation aResult;
try
{
Sequence< sal_Int8 > aMetafile;
//get view from old api wrapper
Reference< datatransfer::XTransferable > xTransferable(
createInstance( CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY ); if( xTransferable.is() )
{
datatransfer::DataFlavor aDataFlavor( lcl_aGDIMetaFileMIMEType,
u"GDIMetaFile"_ustr,
cppu::UnoType<uno::Sequence< sal_Int8 >>::get() );
std::optional<ChartColorPalette> ChartModel::getCurrentColorPalette() const
{ if (!usesColorPalette())
{
SAL_WARN("chart2", "ChartModel::getCurrentColorPalette: no palette is in use"); return std::nullopt;
}
const std::shared_ptr<model::Theme> pTheme = getDocumentTheme(); // when pTheme is null, ChartColorPaletteHelper uses a default theme const ChartColorPaletteHelper aColorPaletteHelper(pTheme); return aColorPaletteHelper.getColorPalette(getColorPaletteType(), getColorPaletteIndex());
}
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.