nss: upgrade to release 3.73
[LibreOffice.git] / xmlsecurity / source / framework / elementcollector.cxx
blob7801d6328b7f95ec784f30d804558cc361aeabd9
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 .
21 #include "elementmark.hxx"
22 #include "elementcollector.hxx"
23 #include <com/sun/star/xml/crypto/sax/ConstOfSecurityId.hpp>
24 #include <com/sun/star/xml/crypto/sax/XReferenceResolvedListener.hpp>
26 ElementCollector::ElementCollector(
27 sal_Int32 nBufferId,
28 css::xml::crypto::sax::ElementMarkPriority nPriority,
29 bool bToModify,
30 const css::uno::Reference< css::xml::crypto::sax::XReferenceResolvedListener >& xReferenceResolvedListener)
31 :ElementMark(css::xml::crypto::sax::ConstOfSecurityId::UNDEFINEDSECURITYID, nBufferId),
32 m_nPriority(nPriority),
33 m_bToModify(bToModify),
34 m_bAbleToNotify(false),
35 m_bNotified(false),
36 m_xReferenceResolvedListener(xReferenceResolvedListener)
37 /****** ElementCollector/ElementCollector *************************************
39 * NAME
40 * ElementCollector -- constructor method
42 * SYNOPSIS
43 * ElementCollector(nSecurityId, nBufferId, nPriority, bToModify
44 * xReferenceResolvedListener);
46 * FUNCTION
47 * construct an ElementCollector object.
49 * INPUTS
50 * nSecurityId - represents which security entity the buffer node is
51 * related with. Either a signature or an encryption is
52 * a security entity.
53 * nBufferId - the id of the element buffered in the document
54 * wrapper component. The document wrapper component
55 * uses this id to search the particular buffered
56 * element.
57 * nPriority - the priority value. ElementCollector with lower
58 * priority value can't notify until all ElementCollectors
59 * with higher priority value have notified.
60 * bToModify - A flag representing whether this ElementCollector
61 * notification will cause the modification of its working
62 * element.
63 * xReferenceResolvedListener
64 * - the listener that this ElementCollector notifies to.
65 ******************************************************************************/
67 m_type = css::xml::crypto::sax::ElementMarkType_ELEMENTCOLLECTOR;
71 void ElementCollector::notifyListener()
72 /****** ElementCollector/notifyListener ***************************************
74 * NAME
75 * notifyListener -- enable the ability to notify the listener
77 * SYNOPSIS
78 * notifyListener();
80 * FUNCTION
81 * enable the ability to notify the listener and try to notify then.
82 ******************************************************************************/
84 m_bAbleToNotify = true;
85 doNotify();
88 void ElementCollector::setReferenceResolvedListener(
89 const css::uno::Reference< css::xml::crypto::sax::XReferenceResolvedListener >& xReferenceResolvedListener)
90 /****** ElementCollector/setReferenceResolvedListener *************************
92 * NAME
93 * setReferenceResolvedListener -- configures a listener for the buffer
94 * node in this object
96 * SYNOPSIS
97 * setReferenceResolvedListener(xReferenceResolvedListener);
99 * FUNCTION
100 * configures a new listener and try to notify then.
102 * INPUTS
103 * xReferenceResolvedListener - the new listener
104 ******************************************************************************/
106 m_xReferenceResolvedListener = xReferenceResolvedListener;
107 doNotify();
110 void ElementCollector::doNotify()
111 /****** ElementCollector/doNotify *********************************************
113 * NAME
114 * doNotify -- tries to notify the listener
116 * SYNOPSIS
117 * doNotify();
119 * FUNCTION
120 * notifies the listener when all below conditions are satisfied:
121 * the listener has not been notified;
122 * the notify right is granted;
123 * the listener has already been configured;
124 * the security id has already been configure
125 ******************************************************************************/
127 if (!m_bNotified &&
128 m_bAbleToNotify &&
129 m_xReferenceResolvedListener.is() &&
130 m_nSecurityId != css::xml::crypto::sax::ConstOfSecurityId::UNDEFINEDSECURITYID)
132 m_bNotified = true;
133 m_xReferenceResolvedListener->referenceResolved(m_nBufferId);
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */