/src/libreoffice/oox/source/vml/vmldrawingfragment.cxx
Line | Count | Source |
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/token/namespaces.hxx> |
24 | | #include <oox/token/tokens.hxx> |
25 | | #include <oox/vml/vmldrawing.hxx> |
26 | | #include <oox/vml/vmlinputstream.hxx> |
27 | | #include <oox/vml/vmlshapecontext.hxx> |
28 | | |
29 | | namespace oox::vml { |
30 | | |
31 | | using namespace ::com::sun::star::io; |
32 | | using namespace ::com::sun::star::uno; |
33 | | using namespace ::oox::core; |
34 | | |
35 | | DrawingFragment::DrawingFragment( XmlFilterBase& rFilter, const OUString& rFragmentPath, Drawing& rDrawing ) : |
36 | 2.88k | FragmentHandler2( rFilter, rFragmentPath, false ), // do not trim whitespace, has been preprocessed by the input stream |
37 | 2.88k | mrDrawing( rDrawing ) |
38 | 2.88k | { |
39 | 2.88k | } |
40 | | |
41 | | Reference< XInputStream > DrawingFragment::openFragmentStream() const |
42 | 435 | { |
43 | | // #i104719# create an input stream that preprocesses the VML data |
44 | 435 | return new InputStream( getFilter().getComponentContext(), FragmentHandler2::openFragmentStream() ); |
45 | 435 | } |
46 | | |
47 | | ContextHandlerRef DrawingFragment::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) |
48 | 8.70k | { |
49 | 8.70k | switch( mrDrawing.getType() ) |
50 | 8.70k | { |
51 | | // DOCX filter handles plain shape elements with this fragment handler |
52 | 2.46k | case VMLDRAWING_WORD: |
53 | 2.46k | if ( getNamespace( nElement ) == NMSP_vml |
54 | 0 | || nElement == W_TOKEN(control) ) // Control shape also defined as a vml shape |
55 | 2.46k | return ShapeContextBase::createShapeContext( *this, mrDrawing.getShapes(), nElement, rAttribs ); |
56 | 0 | break; |
57 | | |
58 | | // XLSX and PPTX filters load the entire VML fragment |
59 | 6.23k | case VMLDRAWING_EXCEL: |
60 | 6.23k | case VMLDRAWING_POWERPOINT: |
61 | 6.23k | switch( getCurrentElement() ) |
62 | 6.23k | { |
63 | 286 | case XML_ROOT_CONTEXT: |
64 | 286 | if( nElement == XML_xml ) return this; |
65 | 0 | break; |
66 | 5.95k | case XML_xml: |
67 | 5.95k | return ShapeContextBase::createShapeContext( *this, mrDrawing.getShapes(), nElement, rAttribs ); |
68 | 6.23k | } |
69 | 0 | break; |
70 | 8.70k | } |
71 | 0 | return nullptr; |
72 | 8.70k | } |
73 | | |
74 | | void DrawingFragment::finalizeImport() |
75 | 185 | { |
76 | | // resolve shape template references for all shapes |
77 | 185 | mrDrawing.finalizeFragmentImport(); |
78 | 185 | } |
79 | | |
80 | | } // namespace oox::vml |
81 | | |
82 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |