Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <com/sun/star/embed/XEmbeddedObject.hpp>
30 : : #include <com/sun/star/embed/XVisualObject.hpp>
31 : : #include <com/sun/star/embed/Aspects.hpp>
32 : :
33 : :
34 : : using namespace com::sun::star;
35 : :
36 : : #include <unotools/moduleoptions.hxx>
37 : : #include <svx/svdoole2.hxx>
38 : : #include <svx/svdpage.hxx>
39 : : #include <sfx2/objsh.hxx>
40 : : #include <sot/storage.hxx>
41 : : #include <sfx2/app.hxx>
42 : : #include <sot/clsids.hxx>
43 : : #include "address.hxx"
44 : :
45 : : #include "scfobj.hxx"
46 : : #include "document.hxx"
47 : : #include "drwlayer.hxx"
48 : : #include "chartarr.hxx"
49 : :
50 : :
51 : : // STATIC DATA -----------------------------------------------------------
52 : :
53 : :
54 : : //==================================================================
55 : :
56 : 0 : void Sc10InsertObject::InsertChart( ScDocument* pDoc, SCTAB nDestTab, const Rectangle& rRect,
57 : : SCTAB nSrcTab, sal_uInt16 nX1, sal_uInt16 nY1, sal_uInt16 nX2, sal_uInt16 nY2 )
58 : : {
59 : : // wenn Chart nicht installiert ist, darf nicht auf SCH_MOD zugegriffen werden!
60 [ # # ][ # # ]: 0 : if ( !SvtModuleOptions().IsChart() )
[ # # ][ # # ]
61 : 0 : return;
62 : :
63 : 0 : ::rtl::OUString aName;
64 : : uno::Reference < embed::XEmbeddedObject > xObj = pDoc->GetDocumentShell()->
65 [ # # ][ # # ]: 0 : GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_SCH_CLASSID ).GetByteSequence(), aName );
[ # # ][ # # ]
[ # # ][ # # ]
66 [ # # ]: 0 : if ( xObj.is() )
67 : : {
68 [ # # ][ # # ]: 0 : SdrOle2Obj* pSdrOle2Obj = new SdrOle2Obj( ::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ), aName, rRect );
[ # # ][ # # ]
[ # # ][ # # ]
69 : :
70 [ # # ]: 0 : ScDrawLayer* pModel = pDoc->GetDrawLayer();
71 [ # # ]: 0 : if (!pModel)
72 : : {
73 [ # # ]: 0 : pDoc->InitDrawLayer();
74 [ # # ]: 0 : pModel = pDoc->GetDrawLayer();
75 : : OSL_ENSURE(pModel,"Draw Layer ?");
76 : : }
77 : :
78 [ # # ]: 0 : SdrPage* pPage = pModel->GetPage(static_cast<sal_uInt16>(nDestTab));
79 : : OSL_ENSURE(pPage,"Page ?");
80 [ # # ]: 0 : pPage->InsertObject(pSdrOle2Obj);
81 : :
82 [ # # ]: 0 : pSdrOle2Obj->SetLogicRect(rRect); // erst nach InsertObject !!!
83 : 0 : awt::Size aSz;
84 [ # # ]: 0 : aSz.Width = rRect.GetSize().Width();
85 [ # # ]: 0 : aSz.Height = rRect.GetSize().Height();
86 [ # # ][ # # ]: 0 : xObj->setVisualAreaSize( embed::Aspects::MSOLE_CONTENT, aSz );
87 : :
88 : : // hier kann das Chart noch nicht mit Daten gefuettert werden,
89 : : // weil die Formeln noch nicht berechnet sind.
90 : : // Deshalb in die ChartCollection, die Daten werden dann im
91 : : // Sc10Import dtor geholt.
92 : :
93 [ # # ]: 0 : ScChartCollection* pColl = pDoc->GetChartCollection();
94 [ # # ][ # # ]: 0 : pColl->push_back( new ScChartArray( pDoc, nSrcTab, static_cast<SCCOL>(nX1), static_cast<SCROW>(nY1), static_cast<SCCOL>(nX2), static_cast<SCROW>(nY2), aName ) );
[ # # ]
95 : 0 : }
96 : : }
97 : :
98 : :
99 : :
100 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|