merge the formfield patch from ooo-build
[ooovba.git] / oox / source / ppt / pptimport.cxx
blob0559d5377e45a66b2760d4e0941a35979e27ca92
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: pptimport.cxx,v $
10 * $Revision: 1.8.6.1 $
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 #include "oox/ppt/pptimport.hxx"
32 #include "oox/drawingml/chart/chartconverter.hxx"
33 #include "oox/dump/pptxdumper.hxx"
34 #include "oox/drawingml/table/tablestylelistfragmenthandler.hxx"
36 using ::rtl::OUString;
37 using namespace ::com::sun::star;
38 using namespace ::com::sun::star::uno;
39 using namespace ::com::sun::star::xml::sax;
40 using namespace oox::core;
42 namespace oox { namespace ppt {
44 OUString SAL_CALL PowerPointImport_getImplementationName() throw()
46 return CREATE_OUSTRING( "com.sun.star.comp.Impress.oox.PowerPointImport" );
49 uno::Sequence< OUString > SAL_CALL PowerPointImport_getSupportedServiceNames() throw()
51 const OUString aServiceName = CREATE_OUSTRING( "com.sun.star.comp.ooxpptx" );
52 const Sequence< OUString > aSeq( &aServiceName, 1 );
53 return aSeq;
56 uno::Reference< uno::XInterface > SAL_CALL PowerPointImport_createInstance(const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception )
58 return (cppu::OWeakObject*)new PowerPointImport( rSMgr );
61 PowerPointImport::PowerPointImport( const uno::Reference< lang::XMultiServiceFactory > & rSMgr )
62 : XmlFilterBase( rSMgr )
63 , mxChartConv( new ::oox::drawingml::chart::ChartConverter )
67 PowerPointImport::~PowerPointImport()
71 bool PowerPointImport::importDocument() throw()
73 /* to activate the PPTX dumper, define the environment variable
74 OOO_PPTXDUMPER and insert the full path to the file
75 file:///<path-to-oox-module>/source/dump/pptxdumper.ini. */
76 OOX_DUMP_FILE( ::oox::dump::pptx::Dumper );
78 OUString aFragmentPath = getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATIONSTYPE( "officeDocument" ) );
79 FragmentHandlerRef xPresentationFragmentHandler( new PresentationFragmentHandler( *this, aFragmentPath ) );
80 maTableStyleListPath = xPresentationFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATIONSTYPE( "tableStyles" ) );
81 return importFragment( xPresentationFragmentHandler );
86 bool PowerPointImport::exportDocument() throw()
88 return false;
91 sal_Int32 PowerPointImport::getSchemeColor( sal_Int32 nToken ) const
93 sal_Int32 nColor = 0;
94 if ( mpActualSlidePersist )
96 sal_Bool bColorMapped = sal_False;
97 oox::drawingml::ClrMapPtr pClrMapPtr( mpActualSlidePersist->getClrMap() );
98 if ( pClrMapPtr )
99 bColorMapped = pClrMapPtr->getColorMap( nToken );
101 if ( !bColorMapped ) // try masterpage mapping
103 SlidePersistPtr pMasterPersist = mpActualSlidePersist->getMasterPersist();
104 if ( pMasterPersist )
106 pClrMapPtr = pMasterPersist->getClrMap();
107 if ( pClrMapPtr )
108 bColorMapped = pClrMapPtr->getColorMap( nToken );
111 oox::drawingml::ClrSchemePtr pClrSchemePtr( mpActualSlidePersist->getClrScheme() );
112 if ( pClrSchemePtr )
113 pClrSchemePtr->getColor( nToken, nColor );
114 else
116 ::oox::drawingml::ThemePtr pTheme = mpActualSlidePersist->getTheme();
117 if( pTheme )
119 pTheme->getClrScheme().getColor( nToken, nColor );
121 else
123 OSL_TRACE("OOX: PowerPointImport::mpThemePtr is NULL");
127 return nColor;
130 const ::oox::drawingml::Theme* PowerPointImport::getCurrentTheme() const
132 return mpActualSlidePersist ? mpActualSlidePersist->getTheme().get() : 0;
135 ::oox::vml::Drawing* PowerPointImport::getVmlDrawing()
137 return mpActualSlidePersist ? mpActualSlidePersist->getDrawing() : 0;
140 const oox::drawingml::table::TableStyleListPtr PowerPointImport::getTableStyles()
142 if ( !mpTableStyleList && maTableStyleListPath.getLength() )
144 mpTableStyleList = oox::drawingml::table::TableStyleListPtr( new oox::drawingml::table::TableStyleList() );
145 importFragment( new oox::drawingml::table::TableStyleListFragmentHandler(
146 *this, maTableStyleListPath, *mpTableStyleList ) );
148 return mpTableStyleList;;
151 ::oox::drawingml::chart::ChartConverter& PowerPointImport::getChartConverter()
153 return *mxChartConv;
156 OUString PowerPointImport::implGetImplementationName() const
158 return PowerPointImport_getImplementationName();