Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #include "oox/vml/vmldrawingfragment.hxx"
21 : :
22 : : #include "oox/core/xmlfilterbase.hxx"
23 : : #include "oox/vml/vmldrawing.hxx"
24 : : #include "oox/vml/vmlinputstream.hxx"
25 : : #include "oox/vml/vmlshapecontext.hxx"
26 : :
27 : : namespace oox {
28 : : namespace vml {
29 : :
30 : : // ============================================================================
31 : :
32 : : using namespace ::com::sun::star::io;
33 : : using namespace ::com::sun::star::uno;
34 : : using namespace ::oox::core;
35 : :
36 : : using ::rtl::OUString;
37 : :
38 : : // ============================================================================
39 : :
40 : 39 : DrawingFragment::DrawingFragment( XmlFilterBase& rFilter, const OUString& rFragmentPath, Drawing& rDrawing ) :
41 : : FragmentHandler2( rFilter, rFragmentPath, false ), // do not trim whitespace, has been preprocessed by the input stream
42 : 39 : mrDrawing( rDrawing )
43 : : {
44 : 39 : }
45 : :
46 : 6 : Reference< XInputStream > DrawingFragment::openFragmentStream() const
47 : : {
48 : : // #i104719# create an input stream that preprocesses the VML data
49 [ + - ][ + - ]: 6 : return new InputStream( getFilter().getComponentContext(), FragmentHandler2::openFragmentStream() );
[ + - ]
50 : : }
51 : :
52 : 84 : ContextHandlerRef DrawingFragment::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
53 : : {
54 [ + + - ]: 84 : switch( mrDrawing.getType() )
55 : : {
56 : : // DOCX filter handles plain shape elements with this fragment handler
57 : : case VMLDRAWING_WORD:
58 [ + - ]: 63 : if ( getNamespace( nElement ) == NMSP_vml )
59 : 63 : return ShapeContextBase::createShapeContext( *this, mrDrawing.getShapes(), nElement, rAttribs );
60 : 0 : break;
61 : :
62 : : // XLSX and PPTX filters load the entire VML fragment
63 : : case VMLDRAWING_EXCEL:
64 : : case VMLDRAWING_POWERPOINT:
65 [ + + - ]: 21 : switch( getCurrentElement() )
66 : : {
67 : : case XML_ROOT_CONTEXT:
68 [ + - ]: 6 : if( nElement == XML_xml ) return this;
69 : 0 : break;
70 : : case XML_xml:
71 : 15 : return ShapeContextBase::createShapeContext( *this, mrDrawing.getShapes(), nElement, rAttribs );
72 : : }
73 : 0 : break;
74 : : }
75 : 84 : return 0;
76 : : }
77 : :
78 : 6 : void DrawingFragment::finalizeImport()
79 : : {
80 : : // resolve shape template references for all shapes
81 : 6 : mrDrawing.finalizeFragmentImport();
82 : 6 : }
83 : :
84 : : // ============================================================================
85 : :
86 : : } // namespace vml
87 [ + - ][ + - ]: 285 : } // namespace oox
88 : :
89 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|