2010-10-12 15:59:00 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2003-10-06 08:58:36 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 19:29:01 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2003-10-06 08:58:36 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2003-10-06 08:58:36 +00:00
|
|
|
*
|
2008-04-10 19:29:01 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2003-10-06 08:58:36 +00:00
|
|
|
*
|
2008-04-10 19:29:01 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2003-10-06 08:58:36 +00:00
|
|
|
*
|
2008-04-10 19:29:01 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2003-10-06 08:58:36 +00:00
|
|
|
*
|
2008-04-10 19:29:01 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2003-10-06 08:58:36 +00:00
|
|
|
*
|
2008-04-10 19:29:01 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2003-10-06 08:58:36 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-17 12:01:03 +00:00
|
|
|
|
2003-10-06 08:58:36 +00:00
|
|
|
#include "ViewElementListProvider.hxx"
|
2007-05-22 16:51:19 +00:00
|
|
|
#include "chartview/DrawModelWrapper.hxx"
|
2003-11-12 17:13:41 +00:00
|
|
|
#include "chartview/DataPointSymbolSupplier.hxx"
|
|
|
|
#include "macros.hxx"
|
2007-05-22 16:51:19 +00:00
|
|
|
#include "DrawViewWrapper.hxx"
|
|
|
|
#include <svx/xtable.hxx>
|
|
|
|
#include <svx/XPropertyTable.hxx>
|
|
|
|
#include <svx/unofill.hxx>
|
|
|
|
#include <svx/unoapi.hxx>
|
|
|
|
|
|
|
|
// header for class NameOrIndex
|
|
|
|
#include <svx/xit.hxx>
|
|
|
|
// header for class XFillBitmapItem
|
|
|
|
#include <svx/xbtmpit.hxx>
|
|
|
|
#include <svx/xflftrit.hxx>
|
|
|
|
#include <svx/xlndsit.hxx>
|
|
|
|
#include <svx/xflhtit.hxx>
|
|
|
|
#include <svx/xflgrit.hxx>
|
|
|
|
// header for class XLineStartItem
|
|
|
|
#include <svx/xlnstit.hxx>
|
|
|
|
// header for class XLineEndItem
|
|
|
|
#include <svx/xlnedit.hxx>
|
2003-10-06 08:58:36 +00:00
|
|
|
|
|
|
|
//------------
|
|
|
|
//oldChartModelWrapper
|
2007-05-22 16:51:19 +00:00
|
|
|
|
|
|
|
// header for class SfxItemPool
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/itempool.hxx>
|
2003-10-06 08:58:36 +00:00
|
|
|
// header for class FontList
|
|
|
|
#include <svtools/ctrltool.hxx>
|
|
|
|
// header for class Application
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
//------------
|
2003-11-12 17:13:41 +00:00
|
|
|
// header for class SdrObject
|
|
|
|
#include <svx/svdobj.hxx>
|
|
|
|
|
2003-11-13 14:15:28 +00:00
|
|
|
|
|
|
|
//---------------
|
|
|
|
//for creation of a symbol Graphic
|
|
|
|
// header for class VirtualDevice
|
|
|
|
#include <vcl/virdev.hxx>
|
|
|
|
// header for class SdrView
|
|
|
|
#include <svx/svdview.hxx>
|
|
|
|
//---------------
|
|
|
|
|
2003-10-06 08:58:36 +00:00
|
|
|
//.............................................................................
|
|
|
|
namespace chart
|
|
|
|
{
|
|
|
|
//.............................................................................
|
2003-11-12 17:13:41 +00:00
|
|
|
using namespace ::com::sun::star;
|
2003-10-06 08:58:36 +00:00
|
|
|
|
2007-05-22 16:51:19 +00:00
|
|
|
ViewElementListProvider::ViewElementListProvider( DrawModelWrapper* pDrawModelWrapper )
|
2003-10-06 08:58:36 +00:00
|
|
|
: m_pDrawModelWrapper( pDrawModelWrapper )
|
|
|
|
, m_pFontList(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ViewElementListProvider::~ViewElementListProvider()
|
|
|
|
{
|
|
|
|
if(m_pFontList)
|
|
|
|
delete m_pFontList;
|
|
|
|
}
|
|
|
|
|
2007-05-22 16:51:19 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2011-09-23 14:05:07 +01:00
|
|
|
XColorListRef ViewElementListProvider::GetColorTable() const
|
2003-10-06 08:58:36 +00:00
|
|
|
{
|
|
|
|
if(m_pDrawModelWrapper)
|
2011-09-23 14:05:07 +01:00
|
|
|
return m_pDrawModelWrapper->GetColorList();
|
|
|
|
return XColorListRef();
|
2003-10-06 08:58:36 +00:00
|
|
|
}
|
2011-09-23 14:05:07 +01:00
|
|
|
|
|
|
|
XDashListRef ViewElementListProvider::GetDashList() const
|
2003-10-06 08:58:36 +00:00
|
|
|
{
|
|
|
|
if(m_pDrawModelWrapper)
|
|
|
|
return m_pDrawModelWrapper->GetDashList();
|
2011-09-23 14:05:07 +01:00
|
|
|
return XDashListRef();
|
2003-10-06 08:58:36 +00:00
|
|
|
}
|
2011-09-23 14:05:07 +01:00
|
|
|
|
|
|
|
XLineEndListRef ViewElementListProvider::GetLineEndList() const
|
2003-10-06 08:58:36 +00:00
|
|
|
{
|
|
|
|
if(m_pDrawModelWrapper)
|
|
|
|
return m_pDrawModelWrapper->GetLineEndList();
|
2011-09-23 14:05:07 +01:00
|
|
|
return XLineEndListRef();
|
2003-10-06 08:58:36 +00:00
|
|
|
}
|
2011-09-23 14:05:07 +01:00
|
|
|
|
|
|
|
XGradientListRef ViewElementListProvider::GetGradientList() const
|
2003-10-06 08:58:36 +00:00
|
|
|
{
|
|
|
|
if(m_pDrawModelWrapper)
|
|
|
|
return m_pDrawModelWrapper->GetGradientList();
|
2011-09-23 14:05:07 +01:00
|
|
|
return XGradientListRef();
|
2003-10-06 08:58:36 +00:00
|
|
|
}
|
2011-09-23 14:05:07 +01:00
|
|
|
XHatchListRef ViewElementListProvider::GetHatchList() const
|
2003-10-06 08:58:36 +00:00
|
|
|
{
|
|
|
|
if(m_pDrawModelWrapper)
|
|
|
|
return m_pDrawModelWrapper->GetHatchList();
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-09-23 14:05:07 +01:00
|
|
|
|
|
|
|
XBitmapListRef ViewElementListProvider::GetBitmapList() const
|
2003-10-06 08:58:36 +00:00
|
|
|
{
|
|
|
|
if(m_pDrawModelWrapper)
|
|
|
|
return m_pDrawModelWrapper->GetBitmapList();
|
2011-09-23 14:05:07 +01:00
|
|
|
return XBitmapListRef();
|
2003-10-06 08:58:36 +00:00
|
|
|
}
|
|
|
|
|
2007-05-22 16:51:19 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2003-10-06 08:58:36 +00:00
|
|
|
//create chartspecific symbols for linecharts
|
2003-11-13 14:15:28 +00:00
|
|
|
SdrObjList* ViewElementListProvider::GetSymbolList() const
|
2003-10-06 08:58:36 +00:00
|
|
|
{
|
2007-05-22 16:51:19 +00:00
|
|
|
SdrObjList* m_pSymbolList = NULL;
|
|
|
|
uno::Reference< drawing::XShapes > m_xSymbols(NULL);//@todo this keeps the first drawinglayer alive ...
|
2003-11-12 17:13:41 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
if(!m_pSymbolList || !m_pSymbolList->GetObjCount())
|
|
|
|
{
|
|
|
|
//@todo use mutex
|
|
|
|
|
2007-05-22 16:51:19 +00:00
|
|
|
//get shape factory
|
|
|
|
uno::Reference< lang::XMultiServiceFactory > xShapeFactory( m_pDrawModelWrapper->getShapeFactory() );
|
2003-11-12 17:13:41 +00:00
|
|
|
|
2007-05-22 16:51:19 +00:00
|
|
|
//get hidden draw page (target):
|
|
|
|
uno::Reference<drawing::XShapes> xTarget( m_pDrawModelWrapper->getHiddenDrawPage(), uno::UNO_QUERY );
|
2003-11-12 17:13:41 +00:00
|
|
|
|
|
|
|
//create symbols via uno and convert to native sdr objects
|
2007-05-22 16:51:19 +00:00
|
|
|
drawing::Direction3D aSymbolSize(220,220,0); // should be 250, but 250 -> 280 ??
|
2003-11-12 17:13:41 +00:00
|
|
|
m_xSymbols = DataPointSymbolSupplier::create2DSymbolList( xShapeFactory, xTarget, aSymbolSize );
|
2007-05-22 16:51:19 +00:00
|
|
|
|
|
|
|
SdrObject* pSdrObject = DrawViewWrapper::getSdrObject( uno::Reference< drawing::XShape >( m_xSymbols, uno::UNO_QUERY ) );
|
|
|
|
if(pSdrObject)
|
|
|
|
m_pSymbolList = pSdrObject->GetSubList();
|
2003-11-12 17:13:41 +00:00
|
|
|
}
|
|
|
|
}
|
2011-11-29 02:06:57 +09:00
|
|
|
catch( const uno::Exception& e )
|
2003-11-12 17:13:41 +00:00
|
|
|
{
|
|
|
|
ASSERT_EXCEPTION( e );
|
|
|
|
}
|
|
|
|
return m_pSymbolList;
|
2003-10-06 08:58:36 +00:00
|
|
|
}
|
|
|
|
|
2003-11-13 14:15:28 +00:00
|
|
|
Graphic ViewElementListProvider::GetSymbolGraphic( sal_Int32 nStandardSymbol, const SfxItemSet* pSymbolShapeProperties ) const
|
|
|
|
{
|
|
|
|
SdrObjList* pSymbolList = this->GetSymbolList();
|
|
|
|
if( !pSymbolList->GetObjCount() )
|
|
|
|
return Graphic();
|
|
|
|
if(nStandardSymbol<0)
|
|
|
|
nStandardSymbol*=-1;
|
|
|
|
if( nStandardSymbol >= static_cast<sal_Int32>(pSymbolList->GetObjCount()) )
|
|
|
|
nStandardSymbol %= pSymbolList->GetObjCount();
|
|
|
|
SdrObject* pObj = pSymbolList->GetObj(nStandardSymbol);
|
|
|
|
|
|
|
|
VirtualDevice aVDev;
|
|
|
|
aVDev.SetMapMode(MapMode(MAP_100TH_MM));
|
|
|
|
SdrModel* pModel = new SdrModel();
|
|
|
|
pModel->GetItemPool().FreezeIdRanges();
|
2011-01-14 15:18:08 +01:00
|
|
|
SdrPage* pPage = new SdrPage( *pModel, sal_False );
|
2003-11-13 14:15:28 +00:00
|
|
|
pPage->SetSize(Size(1000,1000));
|
|
|
|
pModel->InsertPage( pPage, 0 );
|
|
|
|
SdrView* pView = new SdrView( pModel, &aVDev );
|
2006-12-12 15:45:38 +00:00
|
|
|
pView->hideMarkHandles();
|
2006-11-14 14:31:00 +00:00
|
|
|
SdrPageView* pPageView = pView->ShowSdrPage(pPage);
|
2003-11-13 14:15:28 +00:00
|
|
|
|
|
|
|
pObj=pObj->Clone();
|
|
|
|
pPage->NbcInsertObject(pObj);
|
|
|
|
pView->MarkObj(pObj,pPageView);
|
|
|
|
if( pSymbolShapeProperties )
|
2003-12-04 15:31:17 +00:00
|
|
|
pObj->SetMergedItemSet(*pSymbolShapeProperties);
|
2003-11-13 14:15:28 +00:00
|
|
|
|
|
|
|
GDIMetaFile aMeta(pView->GetAllMarkedMetaFile());
|
|
|
|
|
|
|
|
Graphic aGraph(aMeta);
|
|
|
|
Size aSize = pObj->GetSnapRect().GetSize();
|
|
|
|
aGraph.SetPrefSize(aSize);
|
|
|
|
aGraph.SetPrefMapMode(MAP_100TH_MM);
|
|
|
|
|
|
|
|
pView->UnmarkAll();
|
|
|
|
pObj=pPage->RemoveObject(0);
|
2007-07-06 08:59:32 +00:00
|
|
|
SdrObject::Free( pObj );
|
2003-11-13 14:15:28 +00:00
|
|
|
delete pView;
|
|
|
|
delete pModel;
|
|
|
|
|
|
|
|
return aGraph;
|
|
|
|
}
|
|
|
|
|
2007-05-22 16:51:19 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2003-10-06 08:58:36 +00:00
|
|
|
FontList* ViewElementListProvider::getFontList() const
|
|
|
|
{
|
|
|
|
//was old chart:
|
|
|
|
//SvxFontListItem* SfxObjectShell::.GetItem(SID_ATTR_CHAR_FONTLIST)
|
|
|
|
|
|
|
|
if(!m_pFontList)
|
|
|
|
{
|
2007-05-22 16:51:19 +00:00
|
|
|
OutputDevice* pRefDev = m_pDrawModelWrapper ? m_pDrawModelWrapper->getReferenceDevice() : NULL;
|
2011-02-07 20:20:44 +01:00
|
|
|
OutputDevice* pDefaultOut = Application::GetDefaultDevice();
|
2007-05-22 16:51:19 +00:00
|
|
|
m_pFontList = new FontList( pRefDev ? pRefDev : pDefaultOut
|
|
|
|
, pRefDev ? pDefaultOut : NULL
|
2011-01-14 15:18:08 +01:00
|
|
|
, sal_False );
|
2003-10-06 08:58:36 +00:00
|
|
|
}
|
|
|
|
return m_pFontList;
|
|
|
|
}
|
|
|
|
//.............................................................................
|
|
|
|
} //namespace chart
|
|
|
|
//.............................................................................
|
2010-10-12 15:59:00 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|