/* -*- 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 .
*/
// Same behavior as with old chart: Always assume data series in columns
chart::ChartDataRowSource eDataRowSource = chart::ChartDataRowSource_COLUMNS; bool bHasCategories = false; bool bFirstCellAsLabel = false;
// use ScChartPositioner to auto-detect column/row headers (like ScChartArray in old version)
ScRangeListRef aRangeListRef( new ScRangeList );
aRangeListRef->Parse( aRangeString, rScDoc, rScDoc.GetAddressConvention() ); if ( !aRangeListRef->empty() )
{
rScDoc.LimitChartIfAll( aRangeListRef ); // limit whole columns/rows to used area
// update string from modified ranges. The ranges must be in the current formula syntax.
OUString aTmpStr;
aRangeListRef->Format( aTmpStr, ScRefFlags::RANGE_ABS_3D, rScDoc, rScDoc.GetAddressConvention() );
aRangeString = aTmpStr;
try
{
xReceiver->setArguments( aArgs );
} catch (const lang::IllegalArgumentException&)
{ // Can happen for invalid aRangeString, in which case a Chart // will be created nevertheless and the range string can be // edited.
TOOLS_WARN_EXCEPTION("sc.ui", "lcl_ChartInit - caught IllegalArgumentException might be due to aRangeString: " << aRangeString);
}
// don't create chart listener here (range may be modified in chart dialog)
}
if ( xObj.is() )
rViewSh.GetObjectShell()->GetEmbeddedObjectContainer().InsertEmbeddedObject( xObj, aName ); // to activate DrawShell (no need to activate Object)
bIsFromFile = !pDlg->IsCreateNew();
}
break;
}
}
}
// SvInsertObjectDialog (everything in one Dialog) are not used anymore if (xObj.is())
{
pView->UnmarkAll();
Point aPnt = rViewSh.GetInsertPos(); if ( rData.GetDocument().IsNegativePage( rData.GetTabNo() ) )
aPnt.AdjustX( -(aSize.Width()) ); // move position to left edge
tools::Rectangle aRect (aPnt, aSize);
rtl::Reference<SdrOle2Obj> pObj = new SdrOle2Obj(
rDoc,
aObjRef,
aName,
aRect);
SdrPageView* pPV = pView->GetSdrPageView(); bool bSuccess = pView->InsertObjectAtView(pObj.get(), *pPV);
if (bSuccess && nAspect != embed::Aspects::MSOLE_ICON)
{ // Math objects change their object size during InsertObject. // New size must be set in SdrObject, or a wrong scale will be set at // ActivateObject.
// get "total" range for positioning if ( !aRanges.empty() )
{
aPositionRange = aRanges[ 0 ]; for ( size_t i = 1, nCount = aRanges.size(); i < nCount; ++i )
{
aPositionRange.ExtendTo( aRanges[ i ] );
}
}
uno::Reference<chart2::XChartDocument> xChartDoc(xReceiver, uno::UNO_QUERY); if (xChartDoc.is())
xChartDoc->createDefaultChart();
// lock the model to suppress any internal updates
uno::Reference< frame::XModel > xChartModel( xReceiver, uno::UNO_QUERY ); if( xChartModel.is() )
xChartModel->lockControllers();
if( pReqArgs->HasItem( FN_PARAM_4, &pItem ) )
{ if ( auto pUInt16Item = dynamic_cast<const SfxUInt16Item*>( pItem) )
nToTable = pUInt16Item->GetValue(); elseif ( auto pBoolItem = dynamic_cast<const SfxBoolItem*>( pItem) )
{ // In IDL for Basic FN_PARAM_4 means SfxBoolItem // -> if set new table, else current table
// #i121334# This call will change the chart's default background fill from white to transparent. // Add here again if this is wanted (see task description for details) // ChartHelper::AdaptDefaultsForChart( xObj );
// pView->InsertObjectAtView(pObj, *pPV);//this call leads to an immediate redraw and asks the chart for a visual representation
// use the page instead of the view to insert, so no undo action is created yet
SdrPage* pPage = pPV->GetPage();
pPage->InsertObject( pObj.get() );
pView->UnmarkAllObj();
pView->MarkObj( pObj.get(), pPV );
if (rReq.IsAPI())
{ if( xChartModel.is() )
xChartModel->unlockControllers();
} elseif (!rViewSh.isLOKMobilePhone())
{ //the controller will be unlocked by the dialog when the dialog is told to do so
// only activate object if not called via API (e.g. macro) if (!comphelper::LibreOfficeKit::isActive())
rViewShell.ActivateObject(pObj.get(), embed::EmbedVerbs::MS_OLEVERB_SHOW);
// try to set the dialog's position so it doesn't hide the chart
uno::Reference < beans::XPropertySet > xDialogProps( xDialog, uno::UNO_QUERY ); if ( xDialogProps.is() )
{ try
{ //get dialog size:
awt::Size aDialogAWTSize; if( xDialogProps->getPropertyValue(u"Size"_ustr)
>>= aDialogAWTSize )
{
Size aDialogSize( aDialogAWTSize.Width, aDialogAWTSize.Height ); if ( !aDialogSize.IsEmpty() )
{ //calculate and set new position
Point aDialogPos = rViewShell.GetChartDialogPos( aDialogSize, aRect );
xDialogProps->setPropertyValue(u"Position"_ustr,
uno::Any( awt::Point(aDialogPos.getX(),aDialogPos.getY()) ) );
}
} //tell the dialog to unlock controller
xDialogProps->setPropertyValue(u"UnlockControllersOnExecute"_ustr,
uno::Any( true ) );
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.