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