bump product version to 7.6.3.2-android
[LibreOffice.git] / xmlsecurity / inc / xmlsec / xmldocumentwrapper_xmlsecimpl.hxx
blob8f5695d10dfe9792f4dd31580a15efdeb58822ae
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <com/sun/star/xml/wrapper/XXMLDocumentWrapper.hpp>
23 #include <com/sun/star/xml/csax/XCompressedDocumentHandler.hpp>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <cppuhelper/implbase.hxx>
27 #include <xmlsec/saxhelper.hxx>
28 #include <xsecxmlsecdllapi.h>
30 #define NODEPOSITION_NORMAL 1
31 #define NODEPOSITION_STARTELEMENT 2
32 #define NODEPOSITION_ENDELEMENT 3
34 #include <libxml/tree.h>
36 class XSECXMLSEC_DLLPUBLIC XMLDocumentWrapper_XmlSecImpl final : public cppu::WeakImplHelper
38 css::xml::wrapper::XXMLDocumentWrapper,
39 css::xml::sax::XDocumentHandler,
40 css::xml::csax::XCompressedDocumentHandler,
41 css::lang::XServiceInfo
43 /**
44 * NAME
45 * XMLDocumentWrapper_XmlSecImpl -- Class to manipulate a libxml2
46 * document
48 * FUNCTION
49 * Converts SAX events into a libxml2 document, converts the document back
50 * into SAX event stream, and manipulate nodes in the document.
51 ******************************************************************************/
53 private:
54 /* the sax helper */
55 SAXHelper saxHelper;
57 /* the document used to convert SAX events to */
58 xmlDocPtr m_pDocument;
60 /* the root element */
61 xmlNodePtr m_pRootElement;
64 * the current active element. The next incoming SAX event will be
65 * appended to this element
67 xmlNodePtr m_pCurrentElement;
70 * This variable is used when converting the document or part of it into
71 * SAX events. See getNextSAXEvent method.
73 sal_Int32 m_nCurrentPosition;
76 * used for recursive deletion. See recursiveDelete method
78 xmlNodePtr m_pStopAtNode;
79 xmlNodePtr m_pCurrentReservedNode;
80 css::uno::Sequence< css::uno::Reference< css::xml::wrapper::XXMLElementWrapper > > m_aReservedNodes;
81 sal_Int32 m_nReservedNodeIndex;
83 private:
84 void getNextSAXEvent();
86 /// @throws css::xml::sax::SAXException
87 static void sendStartElement(
88 const css::uno::Reference< css::xml::sax::XDocumentHandler >& xHandler,
89 const css::uno::Reference< css::xml::sax::XDocumentHandler >& xHandler2,
90 const xmlNodePtr pNode);
92 /// @throws css::xml::sax::SAXException
93 static void sendEndElement(
94 const css::uno::Reference< css::xml::sax::XDocumentHandler >& xHandler,
95 const css::uno::Reference< css::xml::sax::XDocumentHandler >& xHandler2,
96 const xmlNodePtr pNode);
98 /// @throws css::xml::sax::SAXException
99 static void sendNode(
100 const css::uno::Reference< css::xml::sax::XDocumentHandler >& xHandler,
101 const css::uno::Reference< css::xml::sax::XDocumentHandler >& xHandler2,
102 const xmlNodePtr pNode);
104 static OString getNodeQName(const xmlNodePtr pNode);
106 sal_Int32 recursiveDelete( const xmlNodePtr pNode);
108 void getNextReservedNode();
110 void removeNode( const xmlNodePtr pNode) const;
112 static xmlNodePtr checkElement(
113 const css::uno::Reference< css::xml::wrapper::XXMLElementWrapper >& xXMLElement);
115 void buildIDAttr( xmlNodePtr pNode ) const;
116 void rebuildIDLink( xmlNodePtr pNode ) const;
118 public:
119 XMLDocumentWrapper_XmlSecImpl();
120 virtual ~XMLDocumentWrapper_XmlSecImpl() override;
122 /* css::xml::wrapper::XXMLDocumentWrapper */
123 virtual css::uno::Reference< css::xml::wrapper::XXMLElementWrapper > SAL_CALL getCurrentElement( ) override;
125 virtual void SAL_CALL setCurrentElement( const css::uno::Reference<
126 css::xml::wrapper::XXMLElementWrapper >& element ) override;
128 virtual void SAL_CALL removeCurrentElement( ) override;
130 virtual sal_Bool SAL_CALL isCurrent( const css::uno::Reference<
131 css::xml::wrapper::XXMLElementWrapper >& node ) override;
133 virtual sal_Bool SAL_CALL isCurrentElementEmpty( ) override;
135 virtual OUString SAL_CALL getNodeName( const css::uno::Reference<
136 css::xml::wrapper::XXMLElementWrapper >& node ) override;
138 virtual void SAL_CALL clearUselessData(
139 const css::uno::Reference< css::xml::wrapper::XXMLElementWrapper >& node,
140 const css::uno::Sequence< css::uno::Reference< css::xml::wrapper::XXMLElementWrapper > >& reservedDescendants,
141 const css::uno::Reference< css::xml::wrapper::XXMLElementWrapper >& stopAtNode ) override;
143 virtual void SAL_CALL collapse( const css::uno::Reference<
144 css::xml::wrapper::XXMLElementWrapper >& node ) override;
146 virtual void SAL_CALL generateSAXEvents(
147 const css::uno::Reference< css::xml::sax::XDocumentHandler >& handler,
148 const css::uno::Reference< css::xml::sax::XDocumentHandler >& xEventKeeperHandler,
149 const css::uno::Reference< css::xml::wrapper::XXMLElementWrapper >& startNode,
150 const css::uno::Reference< css::xml::wrapper::XXMLElementWrapper >& endNode ) override;
152 virtual void SAL_CALL getTree(
153 const css::uno::Reference< css::xml::sax::XDocumentHandler >& handler ) override;
155 virtual void SAL_CALL rebuildIDLink(
156 const css::uno::Reference< css::xml::wrapper::XXMLElementWrapper >& node ) override;
158 /* css::xml::sax::XDocumentHandler */
159 virtual void SAL_CALL startDocument( ) override;
161 virtual void SAL_CALL endDocument( ) override;
163 virtual void SAL_CALL startElement(
164 const OUString& aName,
165 const css::uno::Reference< css::xml::sax::XAttributeList >& xAttribs ) override;
167 virtual void SAL_CALL endElement( const OUString& aName ) override;
169 virtual void SAL_CALL characters( const OUString& aChars ) override;
171 virtual void SAL_CALL ignorableWhitespace( const OUString& aWhitespaces ) override;
173 virtual void SAL_CALL processingInstruction( const OUString& aTarget, const OUString& aData ) override;
175 virtual void SAL_CALL setDocumentLocator( const css::uno::Reference< css::xml::sax::XLocator >& xLocator ) override;
177 /* css::xml::csax::XCompressedDocumentHandler */
178 virtual void SAL_CALL compressedStartDocument( ) override;
180 virtual void SAL_CALL compressedEndDocument( ) override;
182 virtual void SAL_CALL compressedStartElement(
183 const OUString& aName,
184 const css::uno::Sequence< css::xml::csax::XMLAttribute >& aAttributes ) override;
186 virtual void SAL_CALL compressedEndElement( const OUString& aName ) override;
188 virtual void SAL_CALL compressedCharacters( const OUString& aChars ) override;
190 virtual void SAL_CALL compressedIgnorableWhitespace( const OUString& aWhitespaces ) override;
192 virtual void SAL_CALL compressedProcessingInstruction( const OUString& aTarget, const OUString& aData ) override;
194 virtual void SAL_CALL compressedSetDocumentLocator(
195 sal_Int32 columnNumber,
196 sal_Int32 lineNumber,
197 const OUString& publicId,
198 const OUString& systemId ) override;
200 /* css::lang::XServiceInfo */
201 virtual OUString SAL_CALL getImplementationName( ) override;
203 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
205 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */