LibreOffice Module oox (master)  1
fragmenthandler2.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 
20 #include <sal/config.h>
21 
22 #include <com/sun/star/frame/XModel.hpp>
26 #include <oox/token/namespaces.hxx>
27 
28 namespace oox::core {
29 
30 using namespace ::com::sun::star;
31 using namespace ::com::sun::star::uno;
32 using namespace ::com::sun::star::xml::sax;
33 
34 FragmentHandler2::FragmentHandler2( XmlFilterBase& rFilter, const OUString& rFragmentPath, bool bEnableTrimSpace ) :
35  FragmentHandler( rFilter, rFragmentPath ),
36  ContextHandler2Helper( bEnableTrimSpace, rFilter )
37 {
38 }
39 
41 {
42 }
43 
44 // com.sun.star.xml.sax.XFastDocumentHandler interface --------------------
45 
47 {
49 }
50 
52 {
54 }
55 
56 // com.sun.star.xml.sax.XFastContextHandler interface -------------------------
57 
58 Reference< XFastContextHandler > SAL_CALL FragmentHandler2::createFastChildContext(
59  sal_Int32 nElement, const Reference< XFastAttributeList >& rxAttribs )
60 {
61  if( getNamespace( nElement ) == NMSP_mce ) // TODO for checking 'Ignorable'
62  {
63  if( prepareMceContext( nElement, AttributeList( rxAttribs ) ) )
64  return getFastContextHandler();
65  return nullptr;
66  }
67  return implCreateChildContext( nElement, rxAttribs );
68 }
69 
71  sal_Int32 nElement, const Reference< XFastAttributeList >& rxAttribs )
72 {
73  implStartElement( nElement, rxAttribs );
74 }
75 
76 void SAL_CALL FragmentHandler2::characters( const OUString& rChars )
77 {
78  implCharacters( rChars );
79 }
80 
81 void SAL_CALL FragmentHandler2::endFastElement( sal_Int32 nElement )
82 {
83  /* If MCE */
84  switch( nElement )
85  {
86  case MCE_TOKEN( AlternateContent ):
88  break;
89  }
90 
91  implEndElement( nElement );
92 }
93 
94 // oox.core.ContextHandler interface ------------------------------------------
95 
97 {
98  return implCreateRecordContext( nRecId, rStrm );
99 }
100 
101 void FragmentHandler2::startRecord( sal_Int32 nRecId, SequenceInputStream& rStrm )
102 {
103  implStartRecord( nRecId, rStrm );
104 }
105 
106 void FragmentHandler2::endRecord( sal_Int32 nRecId )
107 {
108  implEndRecord( nRecId );
109 }
110 
111 // oox.core.ContextHandler2Helper interface -----------------------------------
112 
114 {
115  return nullptr;
116 }
117 
119 {
120 }
121 
122 void FragmentHandler2::onCharacters( const OUString& )
123 {
124 }
125 
127 {
128 }
129 
131 {
132  return nullptr;
133 }
134 
136 {
137 }
138 
140 {
141 }
142 
143 // oox.core.FragmentHandler2 interface ----------------------------------------
144 
146 {
147 }
148 
150 {
151 }
152 
153 } // namespace oox::core
154 
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ContextHandlerRef createRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
void implEndRecord(sal_Int32 nRecId)
Must be called from endRecord() in derived classes.
css::uno::Reference< css::xml::sax::XFastContextHandler > getFastContextHandler()
Returns the com.sun.star.xml.sax.XFastContextHandler interface of this context.
css::uno::Reference< css::xml::sax::XFastContextHandler > implCreateChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &rxAttribs)
Must be called from createFastChildContext() in derived classes.
void implStartElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &rxAttribs)
Must be called from startFastElement() in derived classes.
virtual void startRecord(sal_Int32 nRecId, SequenceInputStream &rStrm) override
bool prepareMceContext(sal_Int32 nElement, const AttributeList &rAttribs)
virtual void SAL_CALL characters(const OUString &rChars) final override
void implStartRecord(sal_Int32 nRecId, SequenceInputStream &rStrm)
Must be called from startRecord() in derived classes.
virtual void onStartRecord(SequenceInputStream &rStrm) override
Will be called when a new record block in a binary stream has been started.
virtual ~FragmentHandler2() override
virtual void SAL_CALL startDocument() override
virtual ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
Will be called to create a context handler for the passed element.
Provides access to attribute values of an element.
virtual void onCharacters(const OUString &rChars) override
Will be called before a new child element starts, or if the current element is about to be left...
virtual void SAL_CALL endDocument() override
virtual void endRecord(sal_Int32 nRecId) override
virtual void SAL_CALL endFastElement(sal_Int32 nElement) final override
void implEndElement(sal_Int32 nElement)
Must be called from endFastElement() in derived classes.
FragmentHandler2(XmlFilterBase &rFilter, const OUString &rFragmentPath, bool bEnableTrimSpace=true)
void implCharacters(std::u16string_view rChars)
Must be called from characters() in derived classes.
virtual void onEndElement() override
Will be called when the current element is about to be left.
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &rxAttribs) final override
virtual void onStartElement(const AttributeList &rAttribs) override
Will be called when a new element has been started.
Wraps a StreamDataSequence and provides convenient access functions.
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &rxAttribs) final override
ContextHandlerRef implCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm)
Must be called from createRecordContext() in derived classes.
Helper class that provides a context stack.
virtual ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
Will be called to create a context handler for the passed record.
virtual void onEndRecord() override
Will be called when the current record block is about to be left.