1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_chart2.hxx" 30 #include "ViewElementListProvider.hxx" 31 #include "chartview/DrawModelWrapper.hxx" 32 #include "chartview/DataPointSymbolSupplier.hxx" 33 #include "macros.hxx" 34 #include "DrawViewWrapper.hxx" 35 #include <svx/xtable.hxx> 36 #include <svx/XPropertyTable.hxx> 37 #include <svx/unofill.hxx> 38 #include <svx/unoapi.hxx> 39 40 // header for class NameOrIndex 41 #include <svx/xit.hxx> 42 // header for class XFillBitmapItem 43 #include <svx/xbtmpit.hxx> 44 #include <svx/xflftrit.hxx> 45 #include <svx/xlndsit.hxx> 46 #include <svx/xflhtit.hxx> 47 #include <svx/xflgrit.hxx> 48 // header for class XLineStartItem 49 #include <svx/xlnstit.hxx> 50 // header for class XLineEndItem 51 #include <svx/xlnedit.hxx> 52 53 //------------ 54 //oldChartModelWrapper 55 56 // header for class SfxItemPool 57 #include <svl/itempool.hxx> 58 // header for class FontList 59 #include <svtools/ctrltool.hxx> 60 // header for class Application 61 #include <vcl/svapp.hxx> 62 //------------ 63 // header for class SdrObject 64 #include <svx/svdobj.hxx> 65 66 67 //--------------- 68 //for creation of a symbol Graphic 69 // header for class VirtualDevice 70 #include <vcl/virdev.hxx> 71 // header for class SdrView 72 #include <svx/svdview.hxx> 73 //--------------- 74 75 //............................................................................. 76 namespace chart 77 { 78 //............................................................................. 79 using namespace ::com::sun::star; 80 81 ViewElementListProvider::ViewElementListProvider( DrawModelWrapper* pDrawModelWrapper ) 82 : m_pDrawModelWrapper( pDrawModelWrapper ) 83 , m_pFontList(NULL) 84 { 85 } 86 87 ViewElementListProvider::~ViewElementListProvider() 88 { 89 if(m_pFontList) 90 delete m_pFontList; 91 } 92 93 //----------------------------------------------------------------------------- 94 //----------------------------------------------------------------------------- 95 96 XColorTable* ViewElementListProvider::GetColorTable() const 97 { 98 if(m_pDrawModelWrapper) 99 return m_pDrawModelWrapper->GetColorTable(); 100 return NULL; 101 } 102 XDashList* ViewElementListProvider::GetDashList() const 103 { 104 if(m_pDrawModelWrapper) 105 return m_pDrawModelWrapper->GetDashList(); 106 return NULL; 107 } 108 XLineEndList* ViewElementListProvider::GetLineEndList() const 109 { 110 if(m_pDrawModelWrapper) 111 return m_pDrawModelWrapper->GetLineEndList(); 112 return NULL; 113 } 114 XGradientList* ViewElementListProvider::GetGradientList() const 115 { 116 if(m_pDrawModelWrapper) 117 return m_pDrawModelWrapper->GetGradientList(); 118 return NULL; 119 } 120 XHatchList* ViewElementListProvider::GetHatchList() const 121 { 122 if(m_pDrawModelWrapper) 123 return m_pDrawModelWrapper->GetHatchList(); 124 return NULL; 125 } 126 XBitmapList* ViewElementListProvider::GetBitmapList() const 127 { 128 if(m_pDrawModelWrapper) 129 return m_pDrawModelWrapper->GetBitmapList(); 130 return NULL; 131 } 132 133 //----------------------------------------------------------------------------- 134 //----------------------------------------------------------------------------- 135 136 //create chartspecific symbols for linecharts 137 SdrObjList* ViewElementListProvider::GetSymbolList() const 138 { 139 SdrObjList* m_pSymbolList = NULL; 140 uno::Reference< drawing::XShapes > m_xSymbols(NULL);//@todo this keeps the first drawinglayer alive ... 141 try 142 { 143 if(!m_pSymbolList || !m_pSymbolList->GetObjCount()) 144 { 145 //@todo use mutex 146 147 //get shape factory 148 uno::Reference< lang::XMultiServiceFactory > xShapeFactory( m_pDrawModelWrapper->getShapeFactory() ); 149 150 //get hidden draw page (target): 151 uno::Reference<drawing::XShapes> xTarget( m_pDrawModelWrapper->getHiddenDrawPage(), uno::UNO_QUERY ); 152 153 //create symbols via uno and convert to native sdr objects 154 drawing::Direction3D aSymbolSize(220,220,0); // should be 250, but 250 -> 280 ?? 155 m_xSymbols = DataPointSymbolSupplier::create2DSymbolList( xShapeFactory, xTarget, aSymbolSize ); 156 157 SdrObject* pSdrObject = DrawViewWrapper::getSdrObject( uno::Reference< drawing::XShape >( m_xSymbols, uno::UNO_QUERY ) ); 158 if(pSdrObject) 159 m_pSymbolList = pSdrObject->GetSubList(); 160 } 161 } 162 catch( uno::Exception& e ) 163 { 164 ASSERT_EXCEPTION( e ); 165 } 166 return m_pSymbolList; 167 } 168 169 Graphic ViewElementListProvider::GetSymbolGraphic( sal_Int32 nStandardSymbol, const SfxItemSet* pSymbolShapeProperties ) const 170 { 171 SdrObjList* pSymbolList = this->GetSymbolList(); 172 if( !pSymbolList->GetObjCount() ) 173 return Graphic(); 174 if(nStandardSymbol<0) 175 nStandardSymbol*=-1; 176 if( nStandardSymbol >= static_cast<sal_Int32>(pSymbolList->GetObjCount()) ) 177 nStandardSymbol %= pSymbolList->GetObjCount(); 178 SdrObject* pObj = pSymbolList->GetObj(nStandardSymbol); 179 180 VirtualDevice aVDev; 181 aVDev.SetMapMode(MapMode(MAP_100TH_MM)); 182 SdrModel* pModel = new SdrModel(); 183 pModel->GetItemPool().FreezeIdRanges(); 184 SdrPage* pPage = new SdrPage( *pModel, sal_False ); 185 pPage->SetSize(Size(1000,1000)); 186 pModel->InsertPage( pPage, 0 ); 187 SdrView* pView = new SdrView( pModel, &aVDev ); 188 pView->hideMarkHandles(); 189 SdrPageView* pPageView = pView->ShowSdrPage(pPage); 190 191 pObj=pObj->Clone(); 192 pPage->NbcInsertObject(pObj); 193 pView->MarkObj(pObj,pPageView); 194 if( pSymbolShapeProperties ) 195 pObj->SetMergedItemSet(*pSymbolShapeProperties); 196 197 GDIMetaFile aMeta(pView->GetAllMarkedMetaFile()); 198 199 Graphic aGraph(aMeta); 200 Size aSize = pObj->GetSnapRect().GetSize(); 201 aGraph.SetPrefSize(aSize); 202 aGraph.SetPrefMapMode(MAP_100TH_MM); 203 204 pView->UnmarkAll(); 205 pObj=pPage->RemoveObject(0); 206 SdrObject::Free( pObj ); 207 delete pView; 208 delete pModel; 209 210 return aGraph; 211 } 212 213 //----------------------------------------------------------------------------- 214 //----------------------------------------------------------------------------- 215 216 FontList* ViewElementListProvider::getFontList() const 217 { 218 //was old chart: 219 //SvxFontListItem* SfxObjectShell::.GetItem(SID_ATTR_CHAR_FONTLIST) 220 221 if(!m_pFontList) 222 { 223 OutputDevice* pRefDev = m_pDrawModelWrapper ? m_pDrawModelWrapper->getReferenceDevice() : NULL; 224 OutputDevice* pDefaultOut = Application::GetDefaultDevice(); // #67730# 225 m_pFontList = new FontList( pRefDev ? pRefDev : pDefaultOut 226 , pRefDev ? pDefaultOut : NULL 227 , sal_False ); 228 } 229 return m_pFontList; 230 } 231 232 /* 233 SfxPrinter* ObjectPropertiesDialogParameter::getPrinter() 234 { 235 //was old chart: 236 //SfxPrinter* SchChartDocShell::GetPrinter() 237 238 // OLE-Objekt: kein Printer anlegen ??? see old chart: :UpdateTablePointers 239 //@todo get printer from calc or other container 240 //return NULL; 241 242 SfxPrinter* pPrinter = NULL; 243 bool bOwnPrinter = true; 244 if (!pPrinter) 245 { 246 SfxBoolItem aItem(SID_PRINTER_NOTFOUND_WARN, sal_True); 247 // ItemSet mit speziellem Poolbereich anlegen 248 SfxItemSet* pSet = new SfxItemSet(GetPool(), 249 SID_PRINTER_NOTFOUND_WARN, 250 SID_PRINTER_NOTFOUND_WARN, 0); 251 pSet->Put(aItem); 252 pPrinter = new SfxPrinter(pSet); //@todo ->need to remember and delete 253 bOwnPrinter = sal_True; 254 255 MapMode aMapMode = pPrinter->GetMapMode(); 256 aMapMode.SetMapUnit(MAP_100TH_MM); 257 pPrinter->SetMapMode(aMapMode); 258 259 if (pChDoc) 260 { 261 if (pPrinter != pChDoc->GetRefDevice()) 262 pChDoc->SetRefDevice(pPrinter); 263 264 if (pPrinter != pChDoc->GetOutliner()->GetRefDevice()) 265 pChDoc->GetOutliner()->SetRefDevice(pPrinter); 266 } 267 } 268 return pPrinter; 269 } 270 */ 271 272 //............................................................................. 273 } //namespace chart 274 //............................................................................. 275