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 : :
30 : : #include <svtools/chartprettypainter.hxx>
31 : :
32 : : #include <tools/globname.hxx>
33 : : #include <sot/clsids.hxx>
34 : : #include <vcl/pdfextoutdevdata.hxx>
35 : : #include <comphelper/servicehelper.hxx>
36 : : #include <com/sun/star/lang/XUnoTunnel.hpp>
37 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 : : #include <svtools/embedhlp.hxx>
39 : :
40 : : using namespace ::com::sun::star;
41 : :
42 : 0 : ChartPrettyPainter::ChartPrettyPainter()
43 : : {
44 : 0 : }
45 : :
46 : 0 : ChartPrettyPainter::~ChartPrettyPainter()
47 : : {
48 [ # # ]: 0 : }
49 : :
50 : 0 : bool ChartPrettyPainter::DoPaint(OutputDevice* /*pOutDev*/, const Rectangle& /*rLogicObjectRect*/) const
51 : : {
52 : 0 : return false;
53 : : }
54 : :
55 : : namespace
56 : : {
57 : : class theChartPrettyPainterUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theChartPrettyPainterUnoTunnelId > {};
58 : : }
59 : :
60 : 0 : const uno::Sequence<sal_Int8>& ChartPrettyPainter::getUnoTunnelId()
61 : : {
62 : 0 : return theChartPrettyPainterUnoTunnelId::get().getSeq();
63 : : }
64 : :
65 : 426 : bool ChartPrettyPainter::IsChart( const svt::EmbeddedObjectRef& xObjRef )
66 : : {
67 [ + + ]: 426 : if ( !xObjRef.is() )
68 : 2 : return false;
69 : :
70 [ + - ][ + - ]: 424 : SvGlobalName aObjClsId( xObjRef->getClassID() );
[ + - ][ + - ]
71 [ + - ][ + - ]: 2120 : if(
[ + - ][ + + ]
[ + + ]
72 [ + - ][ + - ]: 848 : SvGlobalName(SO3_SCH_CLASSID_30) == aObjClsId
[ + - ][ + - ]
[ # # ]
73 [ + - ][ + - ]: 848 : || SvGlobalName(SO3_SCH_CLASSID_40) == aObjClsId
[ + - ][ + - ]
[ # # ]
74 [ + - ][ + - ]: 848 : || SvGlobalName(SO3_SCH_CLASSID_50) == aObjClsId
[ + - ][ + - ]
[ # # ]
75 [ + - ][ + - ]: 848 : || SvGlobalName(SO3_SCH_CLASSID_60) == aObjClsId)
[ + - ][ + - ]
[ # # ]
76 : : {
77 : 76 : return true;
78 : : }
79 : :
80 [ + - ]: 426 : return false;
81 : : }
82 : :
83 : 29 : bool ChartPrettyPainter::ShouldPrettyPaintChartOnThisDevice( OutputDevice* pOutDev )
84 : : {
85 [ - + ]: 29 : if( !pOutDev )
86 : 0 : return false;
87 : : //at least the print preview in calc has a paint loop due to too much invalidate calls deep in sdr
88 : : //to avoid the paint loop we use the metafile replacement in this case instead of direct rendering
89 [ - + ]: 29 : if( OUTDEV_WINDOW == pOutDev->GetOutDevType() )
90 : 0 : return false;
91 [ - + ]: 29 : if( OUTDEV_PRINTER == pOutDev->GetOutDevType() )
92 : 0 : return true;
93 [ - + ][ # # ]: 29 : vcl::PDFExtOutDevData* pPDFData = PTR_CAST( vcl::PDFExtOutDevData, pOutDev->GetExtOutDevData() );
94 [ - + ]: 29 : if( pPDFData )
95 : 0 : return true;
96 : 29 : return false;
97 : : }
98 : :
99 : 0 : bool ChartPrettyPainter::DoPrettyPaintChart( uno::Reference< frame::XModel > xChartModel, OutputDevice* pOutDev, const Rectangle& rLogicObjectRect )
100 : : {
101 : : //charts must be painted resolution dependent!! #i82893#, #i75867#
102 [ # # ][ # # ]: 0 : if( !xChartModel.is() || !ShouldPrettyPaintChartOnThisDevice( pOutDev ) )
[ # # ]
103 : 0 : return false;
104 : :
105 : : try
106 : : {
107 [ # # ]: 0 : uno::Reference< lang::XMultiServiceFactory > xFact( xChartModel, uno::UNO_QUERY );
108 : : OSL_ENSURE( xFact.is(), "Chart cannot be painted pretty!\n" );
109 [ # # ]: 0 : if( xFact.is() )
110 : : {
111 [ # # ]: 0 : uno::Reference< lang::XUnoTunnel > xChartRenderer( xFact->createInstance(
112 [ # # ][ # # ]: 0 : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart2.ChartRenderer" ) ) ), uno::UNO_QUERY );
[ # # ]
113 : : OSL_ENSURE( xChartRenderer.is(), "Chart cannot be painted pretty!\n" );
114 [ # # ]: 0 : if( xChartRenderer.is() )
115 : : {
116 : : ChartPrettyPainter* pPrettyPainter = reinterpret_cast<ChartPrettyPainter*>(
117 [ # # ][ # # ]: 0 : xChartRenderer->getSomething( ChartPrettyPainter::getUnoTunnelId() ));
[ # # ]
118 [ # # ]: 0 : if( pPrettyPainter )
119 [ # # ]: 0 : return pPrettyPainter->DoPaint(pOutDev, rLogicObjectRect);
120 [ # # ]: 0 : }
121 [ # # ][ # # ]: 0 : }
122 : : }
123 : 0 : catch( uno::Exception& )
124 : : {
125 : : OSL_FAIL( "Chart cannot be painted pretty!" );
126 : : }
127 : 0 : return false;
128 : : }
129 : :
130 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|