merge the formfield patch from ooo-build
[ooovba.git] / oox / source / vml / vmldrawingfragment.cxx
blob6eab7efdba0e59a8d5201437d20f825af4a8c40b
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: vmldrawingfragmenthandler.cxx,v $
10 * $Revision: 1.6 $
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/vml/vmldrawingfragment.hxx"
32 #include "oox/vml/vmldrawing.hxx"
33 #include "oox/vml/vmlinputstream.hxx"
34 #include "oox/vml/vmlshapecontext.hxx"
36 using ::rtl::OUString;
37 using ::com::sun::star::uno::Reference;
38 using ::com::sun::star::io::XInputStream;
39 using ::oox::core::ContextHandlerRef;
40 using ::oox::core::FragmentHandler2;
41 using ::oox::core::XmlFilterBase;
43 namespace oox {
44 namespace vml {
46 // ============================================================================
48 DrawingFragment::DrawingFragment( XmlFilterBase& rFilter, const OUString& rFragmentPath, Drawing& rDrawing ) :
49 FragmentHandler2( rFilter, rFragmentPath ),
50 mrDrawing( rDrawing )
54 Reference< XInputStream > DrawingFragment::openFragmentStream() const
56 return new InputStream( FragmentHandler2::openFragmentStream() );
59 ContextHandlerRef DrawingFragment::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
61 switch( mrDrawing.getType() )
63 // DOCX filter handles plain shape elements with this fragment handler
64 case VMLDRAWING_WORD:
65 if( isRootElement() )
66 return ShapeContextBase::createShapeContext( *this, nElement, rAttribs, mrDrawing.getShapes() );
67 break;
69 // XLSX and PPTX filters load the entire VML fragment
70 case VMLDRAWING_EXCEL:
71 case VMLDRAWING_POWERPOINT:
72 switch( getCurrentElement() )
74 case XML_ROOT_CONTEXT:
75 if( nElement == XML_xml ) return this;
76 break;
77 case XML_xml:
78 return ShapeContextBase::createShapeContext( *this, nElement, rAttribs, mrDrawing.getShapes() );
80 break;
82 return 0;
85 void DrawingFragment::finalizeImport()
87 // resolve shape template references for all shapes
88 mrDrawing.finalizeFragmentImport();
91 // ============================================================================
93 } // namespace vml
94 } // namespace oox