1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ViewElementListProvider.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
33 #include "ViewElementListProvider.hxx"
34 #include "chartview/DrawModelWrapper.hxx"
35 #include "chartview/DataPointSymbolSupplier.hxx"
37 #include "DrawViewWrapper.hxx"
38 #include <svx/xtable.hxx>
39 #include <svx/XPropertyTable.hxx>
40 #include <svx/unofill.hxx>
41 #include <svx/unoapi.hxx>
43 // header for class NameOrIndex
44 #include <svx/xit.hxx>
45 // header for class XFillBitmapItem
46 #include <svx/xbtmpit.hxx>
47 #include <svx/xflftrit.hxx>
48 #include <svx/xlndsit.hxx>
49 #include <svx/xflhtit.hxx>
50 #include <svx/xflgrit.hxx>
51 // header for class XLineStartItem
52 #include <svx/xlnstit.hxx>
53 // header for class XLineEndItem
54 #include <svx/xlnedit.hxx>
57 //oldChartModelWrapper
59 // header for class SfxItemPool
60 #include <svtools/itempool.hxx>
61 // header for class FontList
62 #include <svtools/ctrltool.hxx>
63 // header for class Application
64 #include <vcl/svapp.hxx>
66 // header for class SdrObject
67 #include <svx/svdobj.hxx>
71 //for creation of a symbol Graphic
72 // header for class VirtualDevice
73 #include <vcl/virdev.hxx>
74 // header for class SdrView
75 #include <svx/svdview.hxx>
78 //.............................................................................
81 //.............................................................................
82 using namespace ::com::sun::star
;
84 ViewElementListProvider::ViewElementListProvider( DrawModelWrapper
* pDrawModelWrapper
)
85 : m_pDrawModelWrapper( pDrawModelWrapper
)
90 ViewElementListProvider::~ViewElementListProvider()
96 //-----------------------------------------------------------------------------
97 //-----------------------------------------------------------------------------
99 XColorTable
* ViewElementListProvider::GetColorTable() const
101 if(m_pDrawModelWrapper
)
102 return m_pDrawModelWrapper
->GetColorTable();
105 XDashList
* ViewElementListProvider::GetDashList() const
107 if(m_pDrawModelWrapper
)
108 return m_pDrawModelWrapper
->GetDashList();
111 XLineEndList
* ViewElementListProvider::GetLineEndList() const
113 if(m_pDrawModelWrapper
)
114 return m_pDrawModelWrapper
->GetLineEndList();
117 XGradientList
* ViewElementListProvider::GetGradientList() const
119 if(m_pDrawModelWrapper
)
120 return m_pDrawModelWrapper
->GetGradientList();
123 XHatchList
* ViewElementListProvider::GetHatchList() const
125 if(m_pDrawModelWrapper
)
126 return m_pDrawModelWrapper
->GetHatchList();
129 XBitmapList
* ViewElementListProvider::GetBitmapList() const
131 if(m_pDrawModelWrapper
)
132 return m_pDrawModelWrapper
->GetBitmapList();
136 //-----------------------------------------------------------------------------
137 //-----------------------------------------------------------------------------
139 //create chartspecific symbols for linecharts
140 SdrObjList
* ViewElementListProvider::GetSymbolList() const
142 SdrObjList
* m_pSymbolList
= NULL
;
143 uno::Reference
< drawing::XShapes
> m_xSymbols(NULL
);//@todo this keeps the first drawinglayer alive ...
146 if(!m_pSymbolList
|| !m_pSymbolList
->GetObjCount())
151 uno::Reference
< lang::XMultiServiceFactory
> xShapeFactory( m_pDrawModelWrapper
->getShapeFactory() );
153 //get hidden draw page (target):
154 uno::Reference
<drawing::XShapes
> xTarget( m_pDrawModelWrapper
->getHiddenDrawPage(), uno::UNO_QUERY
);
156 //create symbols via uno and convert to native sdr objects
157 drawing::Direction3D
aSymbolSize(220,220,0); // should be 250, but 250 -> 280 ??
158 m_xSymbols
= DataPointSymbolSupplier::create2DSymbolList( xShapeFactory
, xTarget
, aSymbolSize
);
160 SdrObject
* pSdrObject
= DrawViewWrapper::getSdrObject( uno::Reference
< drawing::XShape
>( m_xSymbols
, uno::UNO_QUERY
) );
162 m_pSymbolList
= pSdrObject
->GetSubList();
165 catch( uno::Exception
& e
)
167 ASSERT_EXCEPTION( e
);
169 return m_pSymbolList
;
172 Graphic
ViewElementListProvider::GetSymbolGraphic( sal_Int32 nStandardSymbol
, const SfxItemSet
* pSymbolShapeProperties
) const
174 SdrObjList
* pSymbolList
= this->GetSymbolList();
175 if( !pSymbolList
->GetObjCount() )
177 if(nStandardSymbol
<0)
179 if( nStandardSymbol
>= static_cast<sal_Int32
>(pSymbolList
->GetObjCount()) )
180 nStandardSymbol
%= pSymbolList
->GetObjCount();
181 SdrObject
* pObj
= pSymbolList
->GetObj(nStandardSymbol
);
184 aVDev
.SetMapMode(MapMode(MAP_100TH_MM
));
185 SdrModel
* pModel
= new SdrModel();
186 pModel
->GetItemPool().FreezeIdRanges();
187 SdrPage
* pPage
= new SdrPage( *pModel
, FALSE
);
188 pPage
->SetSize(Size(1000,1000));
189 pModel
->InsertPage( pPage
, 0 );
190 SdrView
* pView
= new SdrView( pModel
, &aVDev
);
191 pView
->hideMarkHandles();
192 SdrPageView
* pPageView
= pView
->ShowSdrPage(pPage
);
195 pPage
->NbcInsertObject(pObj
);
196 pView
->MarkObj(pObj
,pPageView
);
197 if( pSymbolShapeProperties
)
198 pObj
->SetMergedItemSet(*pSymbolShapeProperties
);
200 GDIMetaFile
aMeta(pView
->GetAllMarkedMetaFile());
202 Graphic
aGraph(aMeta
);
203 Size aSize
= pObj
->GetSnapRect().GetSize();
204 aGraph
.SetPrefSize(aSize
);
205 aGraph
.SetPrefMapMode(MAP_100TH_MM
);
208 pObj
=pPage
->RemoveObject(0);
209 SdrObject::Free( pObj
);
216 //-----------------------------------------------------------------------------
217 //-----------------------------------------------------------------------------
219 FontList
* ViewElementListProvider::getFontList() const
222 //SvxFontListItem* SfxObjectShell::.GetItem(SID_ATTR_CHAR_FONTLIST)
226 OutputDevice
* pRefDev
= m_pDrawModelWrapper
? m_pDrawModelWrapper
->getReferenceDevice() : NULL
;
227 OutputDevice
* pDefaultOut
= Application::GetDefaultDevice(); // #67730#
228 m_pFontList
= new FontList( pRefDev
? pRefDev
: pDefaultOut
229 , pRefDev
? pDefaultOut
: NULL
236 SfxPrinter* ObjectPropertiesDialogParameter::getPrinter()
239 //SfxPrinter* SchChartDocShell::GetPrinter()
241 // OLE-Objekt: kein Printer anlegen ??? see old chart: :UpdateTablePointers
242 //@todo get printer from calc or other container
245 SfxPrinter* pPrinter = NULL;
246 bool bOwnPrinter = true;
249 SfxBoolItem aItem(SID_PRINTER_NOTFOUND_WARN, TRUE);
250 // ItemSet mit speziellem Poolbereich anlegen
251 SfxItemSet* pSet = new SfxItemSet(GetPool(),
252 SID_PRINTER_NOTFOUND_WARN,
253 SID_PRINTER_NOTFOUND_WARN, 0);
255 pPrinter = new SfxPrinter(pSet); //@todo ->need to remember and delete
258 MapMode aMapMode = pPrinter->GetMapMode();
259 aMapMode.SetMapUnit(MAP_100TH_MM);
260 pPrinter->SetMapMode(aMapMode);
264 if (pPrinter != pChDoc->GetRefDevice())
265 pChDoc->SetRefDevice(pPrinter);
267 if (pPrinter != pChDoc->GetOutliner()->GetRefDevice())
268 pChDoc->GetOutliner()->SetRefDevice(pPrinter);
275 //.............................................................................
277 //.............................................................................