Files
loongoffice/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx
Armin Le Grand 4be44a7a6f SOSAW080: Cleanup of SdrModel
First step: Find all constructors/derivations, mark
all of them.

Removed two-value-constructors, adapted code as needed

Reduced constructors for SdrModel/FmFormModel
to a single one.

Removed PathName for List creation, this is not
needed and anyways all calls used the default
SvtPathOptions().GetPalettePath(). This is also
true for usage of IsFuzzing() that is also part
of the default creation process (without path).
All usages that need an extra-List were setting
it after construction explicitely.

Removed UseExtColorTable. This prevents a single
List to be not created by default, the ColorTable
which is replaced later by all callers that used
this. This is not needed since the default
ColorTable gets constructed just by default, no
expensive stuff is triggered (e.g. loading the
ColorTable). Thus now a default ColorTable is
created and kept for a short moment, destructed
again when a ColorTable is explicitely set.
Doing so is also more safe - it avoids not
creating a default-ColorTable and then not setting
one (what would be urgently required).

f23c24a8548d5246b77b1cc359ba89564538e81a
f124468c3898c5842d37123bdeb87d79a2b19c62

Change-Id: I865de4bb23f673c6684d83c2c6390439506dc5b6
Reviewed-on: https://gerrit.libreoffice.org/55028
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
2018-05-31 15:53:51 +02:00

210 lines
6.7 KiB
C++

/* -*- 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 .
*/
#include <memory>
#include <ViewElementListProvider.hxx>
#include <chartview/DrawModelWrapper.hxx>
#include <chartview/DataPointSymbolSupplier.hxx>
#include <DrawViewWrapper.hxx>
#include <svx/xtable.hxx>
#include <svx/XPropertyTable.hxx>
#include <svx/unofill.hxx>
#include <svx/unoapi.hxx>
#include <svx/xit.hxx>
#include <svx/xbtmpit.hxx>
#include <svx/xflftrit.hxx>
#include <svx/xlndsit.hxx>
#include <svx/xflhtit.hxx>
#include <svx/xflgrit.hxx>
#include <svx/xlnstit.hxx>
#include <svx/xlnedit.hxx>
#include <svl/itempool.hxx>
#include <svtools/ctrltool.hxx>
#include <vcl/svapp.hxx>
#include <svx/svdobj.hxx>
#include <vcl/virdev.hxx>
#include <svx/svdview.hxx>
namespace chart
{
using namespace ::com::sun::star;
ViewElementListProvider::ViewElementListProvider( DrawModelWrapper* pDrawModelWrapper )
: m_pDrawModelWrapper( pDrawModelWrapper )
, m_pFontList(nullptr)
{
}
ViewElementListProvider::ViewElementListProvider( ViewElementListProvider&& rOther )
{
m_pDrawModelWrapper = rOther.m_pDrawModelWrapper;
m_pFontList = std::move(rOther.m_pFontList);
}
ViewElementListProvider::~ViewElementListProvider()
{
}
XColorListRef ViewElementListProvider::GetColorTable() const
{
if(m_pDrawModelWrapper)
return m_pDrawModelWrapper->GetColorList();
return XColorListRef();
}
XDashListRef ViewElementListProvider::GetDashList() const
{
if(m_pDrawModelWrapper)
return m_pDrawModelWrapper->GetDashList();
return XDashListRef();
}
XLineEndListRef ViewElementListProvider::GetLineEndList() const
{
if(m_pDrawModelWrapper)
return m_pDrawModelWrapper->GetLineEndList();
return XLineEndListRef();
}
XGradientListRef ViewElementListProvider::GetGradientList() const
{
if(m_pDrawModelWrapper)
return m_pDrawModelWrapper->GetGradientList();
return XGradientListRef();
}
XHatchListRef ViewElementListProvider::GetHatchList() const
{
if(m_pDrawModelWrapper)
return m_pDrawModelWrapper->GetHatchList();
return nullptr;
}
XBitmapListRef ViewElementListProvider::GetBitmapList() const
{
if(m_pDrawModelWrapper)
return m_pDrawModelWrapper->GetBitmapList();
return XBitmapListRef();
}
XPatternListRef ViewElementListProvider::GetPatternList() const
{
if(m_pDrawModelWrapper)
return m_pDrawModelWrapper->GetPatternList();
return XPatternListRef();
}
//create chartspecific symbols for linecharts
SdrObjList* ViewElementListProvider::GetSymbolList() const
{
SdrObjList* pSymbolList = nullptr;
uno::Reference< drawing::XShapes > xSymbols(nullptr);//@todo this keeps the first drawinglayer alive ...
try
{
if(!pSymbolList || !pSymbolList->GetObjCount())
{
//@todo use mutex
//get shape factory
uno::Reference< lang::XMultiServiceFactory > xShapeFactory( m_pDrawModelWrapper->getShapeFactory() );
//get hidden draw page (target):
uno::Reference<drawing::XShapes> xTarget( m_pDrawModelWrapper->getHiddenDrawPage(), uno::UNO_QUERY );
//create symbols via uno and convert to native sdr objects
drawing::Direction3D aSymbolSize(220,220,0); // should be 250, but 250 -> 280 ??
xSymbols = DataPointSymbolSupplier::create2DSymbolList( xShapeFactory, xTarget, aSymbolSize );
SdrObject* pSdrObject = DrawViewWrapper::getSdrObject( uno::Reference< drawing::XShape >( xSymbols, uno::UNO_QUERY ) );
if(pSdrObject)
pSymbolList = pSdrObject->GetSubList();
}
}
catch( const uno::Exception& e )
{
SAL_WARN("chart2", "Exception caught. " << e );
}
return pSymbolList;
}
Graphic ViewElementListProvider::GetSymbolGraphic( sal_Int32 nStandardSymbol, const SfxItemSet* pSymbolShapeProperties ) const
{
SdrObjList* pSymbolList = GetSymbolList();
if( !pSymbolList->GetObjCount() )
return Graphic();
if(nStandardSymbol<0)
nStandardSymbol*=-1;
if( static_cast<size_t>(nStandardSymbol) >= pSymbolList->GetObjCount() )
nStandardSymbol %= pSymbolList->GetObjCount();
SdrObject* pObj = pSymbolList->GetObj(nStandardSymbol);
ScopedVclPtrInstance< VirtualDevice > pVDev;
pVDev->SetMapMode(MapMode(MapUnit::Map100thMM));
std::unique_ptr<SdrModel> pModel(
new SdrModel());
pModel->GetItemPool().FreezeIdRanges();
SdrPage* pPage = new SdrPage( *pModel, false );
pPage->SetSize(Size(1000,1000));
pModel->InsertPage( pPage, 0 );
std::unique_ptr<SdrView> pView( new SdrView( *pModel.get(), pVDev ) );
pView->hideMarkHandles();
SdrPageView* pPageView = pView->ShowSdrPage(pPage);
// directly clone to target SdrModel
pObj = pObj->CloneSdrObject(*pModel);
pPage->NbcInsertObject(pObj);
pView->MarkObj(pObj,pPageView);
if( pSymbolShapeProperties )
pObj->SetMergedItemSet(*pSymbolShapeProperties);
GDIMetaFile aMeta(pView->GetMarkedObjMetaFile());
Graphic aGraph(aMeta);
Size aSize = pObj->GetSnapRect().GetSize();
aGraph.SetPrefSize(aSize);
aGraph.SetPrefMapMode(MapMode(MapUnit::Map100thMM));
pView->UnmarkAll();
pObj=pPage->RemoveObject(0);
SdrObject::Free( pObj );
return aGraph;
}
FontList* ViewElementListProvider::getFontList() const
{
//was old chart:
//SvxFontListItem* SfxObjectShell::.GetItem(SID_ATTR_CHAR_FONTLIST)
if(!m_pFontList)
{
OutputDevice* pRefDev = m_pDrawModelWrapper ? m_pDrawModelWrapper->getReferenceDevice() : nullptr;
OutputDevice* pDefaultOut = Application::GetDefaultDevice();
m_pFontList.reset( new FontList( pRefDev ? pRefDev : pDefaultOut
, pRefDev ? pDefaultOut : nullptr) );
}
return m_pFontList.get();
}
} //namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */