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 #include <oox/token/tokens.hxx>
28 
29 namespace oox::core {
30 
31 using namespace ::com::sun::star;
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::xml::sax;
34 
35 FragmentHandler2::FragmentHandler2( XmlFilterBase& rFilter, const OUString& rFragmentPath, bool bEnableTrimSpace ) :
36  FragmentHandler( rFilter, rFragmentPath ),
37  ContextHandler2Helper( bEnableTrimSpace, rFilter )
38 {
39 }
40 
42 {
43 }
44 
45 // com.sun.star.xml.sax.XFastDocumentHandler interface --------------------
46 
48 {
50 }
51 
53 {
55 }
56 
57 // com.sun.star.xml.sax.XFastContextHandler interface -------------------------
58 
59 Reference< XFastContextHandler > SAL_CALL FragmentHandler2::createFastChildContext(
60  sal_Int32 nElement, const Reference< XFastAttributeList >& rxAttribs )
61 {
62  if( getNamespace( nElement ) == NMSP_mce ) // TODO for checking 'Ignorable'
63  {
64  if( prepareMceContext( nElement, AttributeList( rxAttribs ) ) )
65  return getFastContextHandler();
66  return nullptr;
67  }
68  return implCreateChildContext( nElement, rxAttribs );
69 }
70 
72  sal_Int32 nElement, const Reference< XFastAttributeList >& rxAttribs )
73 {
74  implStartElement( nElement, rxAttribs );
75 }
76 
77 void SAL_CALL FragmentHandler2::characters( const OUString& rChars )
78 {
79  implCharacters( rChars );
80 }
81 
82 void SAL_CALL FragmentHandler2::endFastElement( sal_Int32 nElement )
83 {
84  /* If MCE */
85  switch( nElement )
86  {
87  case MCE_TOKEN( AlternateContent ):
89  break;
90  }
91 
92  implEndElement( nElement );
93 }
94 
95 // oox.core.ContextHandler interface ------------------------------------------
96 
98 {
99  return implCreateRecordContext( nRecId, rStrm );
100 }
101 
102 void FragmentHandler2::startRecord( sal_Int32 nRecId, SequenceInputStream& rStrm )
103 {
104  implStartRecord( nRecId, rStrm );
105 }
106 
107 void FragmentHandler2::endRecord( sal_Int32 nRecId )
108 {
109  implEndRecord( nRecId );
110 }
111 
112 // oox.core.ContextHandler2Helper interface -----------------------------------
113 
115 {
116  return nullptr;
117 }
118 
120 {
121 }
122 
123 void FragmentHandler2::onCharacters( const OUString& )
124 {
125 }
126 
128 {
129 }
130 
132 {
133  return nullptr;
134 }
135 
137 {
138 }
139 
141 {
142 }
143 
144 // oox.core.FragmentHandler2 interface ----------------------------------------
145 
147 {
148 }
149 
151 {
152 }
153 
154 } // namespace oox::core
155 
156 /* 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.