LibreOffice Module oox (master)  1
vmldrawingfragment.cxx
Go to the documentation of this file.
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 
21 
23 #include <oox/token/namespaces.hxx>
24 #include <oox/token/tokens.hxx>
25 #include <oox/vml/vmldrawing.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  FragmentHandler2( rFilter, rFragmentPath, false ), // do not trim whitespace, has been preprocessed by the input stream
37  mrDrawing( rDrawing )
38 {
39 }
40 
42 {
43  // #i104719# create an input stream that preprocesses the VML data
44  return new InputStream( getFilter().getComponentContext(), FragmentHandler2::openFragmentStream() );
45 }
46 
48 {
49  switch( mrDrawing.getType() )
50  {
51  // DOCX filter handles plain shape elements with this fragment handler
52  case VMLDRAWING_WORD:
53  if ( getNamespace( nElement ) == NMSP_vml
54  || nElement == W_TOKEN(control) ) // Control shape also defined as a vml shape
55  return ShapeContextBase::createShapeContext( *this, mrDrawing.getShapes(), nElement, rAttribs );
56  break;
57 
58  // XLSX and PPTX filters load the entire VML fragment
59  case VMLDRAWING_EXCEL:
61  switch( getCurrentElement() )
62  {
63  case XML_ROOT_CONTEXT:
64  if( nElement == XML_xml ) return this;
65  break;
66  case XML_xml:
67  return ShapeContextBase::createShapeContext( *this, mrDrawing.getShapes(), nElement, rAttribs );
68  }
69  break;
70  }
71  return nullptr;
72 }
73 
75 {
76  // resolve shape template references for all shapes
78 }
79 
80 } // namespace oox::vml
81 
82 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
exports com.sun.star.form. control
ShapeContainer & getShapes()
Returns read/write access to the container of shapes and templates.
Definition: vmldrawing.hxx:108
DrawingFragment(::oox::core::XmlFilterBase &rFilter, const OUString &rFragmentPath, Drawing &rDrawing)
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
Will be called to create a context handler for the passed element.
::oox::core::ContextHandlerRef createShapeContext(::oox::core::ContextHandler2Helper const &rParent, ShapeContainer &rShapes, sal_Int32 nElement, const AttributeList &rAttribs)
An input stream class for VML streams, implementing the UNO interface com.sun.star.io.XInputStream needed by the Expat XML parsers.
virtual css::uno::Reference< css::io::XInputStream > openFragmentStream() const override
Opens the fragment stream referred by the own fragment path.
void finalizeFragmentImport()
Final processing after import of the fragment.
Definition: vmldrawing.cxx:142
PowerPoint: OLE objects are part of DrawingML.
Definition: vmldrawing.hxx:57
sal_Int32 getCurrentElement() const
Returns the identifier of the currently processed element.
DrawingType getType() const
Returns the application type containing the drawing.
Definition: vmldrawing.hxx:106
Excel: OLE objects are part of VML.
Definition: vmldrawing.hxx:56
Reference< XComponentContext > getComponentContext(Reference< XMultiServiceFactory > const &factory)
Provides access to attribute values of an element.
Word: One shape per drawing.
Definition: vmldrawing.hxx:55
::rtl::Reference< ContextHandler > ContextHandlerRef
const sal_Int32 XML_ROOT_CONTEXT
virtual void finalizeImport() override