fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / xmlsecurity / source / framework / elementcollector.cxx
blob137491049665c8ec36cb7a0e7e54cf61008d9a2f
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 nSecurityId,
31 sal_Int32 nBufferId,
32 cssxc::sax::ElementMarkPriority nPriority,
33 bool bToModify,
34 const com::sun::star::uno::Reference<
35 com::sun::star::xml::crypto::sax::XReferenceResolvedListener >&
36 xReferenceResolvedListener)
37 :ElementMark(nSecurityId, nBufferId),
38 m_nPriority(nPriority),
39 m_bToModify(bToModify),
40 m_bAbleToNotify(false),
41 m_bNotified(false),
42 m_xReferenceResolvedListener(xReferenceResolvedListener)
43 /****** ElementCollector/ElementCollector *************************************
45 * NAME
46 * ElementCollector -- constructor method
48 * SYNOPSIS
49 * ElementCollector(nSecurityId, nBufferId, nPriority, bToModify
50 * xReferenceResolvedListener);
52 * FUNCTION
53 * construct an ElementCollector object.
55 * INPUTS
56 * nSecurityId - represents which security entity the buffer node is
57 * related with. Either a signature or an encryption is
58 * a security entity.
59 * nBufferId - the id of the element bufferred in the document
60 * wrapper component. The document wrapper component
61 * uses this id to search the particular bufferred
62 * element.
63 * nPriority - the priority value. ElementCollector with lower
64 * priority value can't notify until all ElementCollectors
65 * with higher priority value have notified.
66 * bToModify - A flag representing whether this ElementCollector
67 * notification will cause the modification of its working
68 * element.
69 * xReferenceResolvedListener
70 * - the listener that this ElementCollector notifies to.
72 * RESULT
73 * empty
75 * AUTHOR
76 * Michael Mi
77 * Email: michael.mi@sun.com
78 ******************************************************************************/
80 m_type = cssxc::sax::ElementMarkType_ELEMENTCOLLECTOR;
83 cssxc::sax::ElementMarkPriority ElementCollector::getPriority() const
85 return m_nPriority;
88 bool ElementCollector::getModify() const
90 return m_bToModify;
93 void ElementCollector::notifyListener()
94 /****** ElementCollector/notifyListener ***************************************
96 * NAME
97 * notifyListener -- enable the ability to notify the listener
99 * SYNOPSIS
100 * notifyListener();
102 * FUNCTION
103 * enable the ability to notify the listener and try to notify then.
105 * INPUTS
106 * empty
108 * RESULT
109 * empty
111 * AUTHOR
112 * Michael Mi
113 * Email: michael.mi@sun.com
114 ******************************************************************************/
116 m_bAbleToNotify = true;
117 doNotify();
120 void ElementCollector::setReferenceResolvedListener(
121 const cssu::Reference< cssxc::sax::XReferenceResolvedListener >& xReferenceResolvedListener)
122 /****** ElementCollector/setReferenceResolvedListener *************************
124 * NAME
125 * setReferenceResolvedListener -- configures a listener for the buffer
126 * node in this object
128 * SYNOPSIS
129 * setReferenceResolvedListener(xReferenceResolvedListener);
131 * FUNCTION
132 * configures a new listener and try to notify then.
134 * INPUTS
135 * xReferenceResolvedListener - the new listener
137 * RESULT
138 * empty
140 * AUTHOR
141 * Michael Mi
142 * Email: michael.mi@sun.com
143 ******************************************************************************/
145 m_xReferenceResolvedListener = xReferenceResolvedListener;
146 doNotify();
149 void ElementCollector::doNotify()
150 /****** ElementCollector/doNotify *********************************************
152 * NAME
153 * doNotify -- tries to notify the listener
155 * SYNOPSIS
156 * doNotify();
158 * FUNCTION
159 * notifies the listener when all below conditions are satisfied:
160 * the listener has not been notified;
161 * the notify right is granted;
162 * the listener has already been configured;
163 * the security id has already been configure
165 * INPUTS
166 * empty
168 * RESULT
169 * empty
171 * AUTHOR
172 * Michael Mi
173 * Email: michael.mi@sun.com
174 ******************************************************************************/
176 if (!m_bNotified &&
177 m_bAbleToNotify &&
178 m_xReferenceResolvedListener.is() &&
179 m_nSecurityId != cssxc::sax::ConstOfSecurityId::UNDEFINEDSECURITYID)
181 m_bNotified = true;
182 m_xReferenceResolvedListener->referenceResolved(m_nBufferId);
186 ElementCollector* ElementCollector::clone(
187 sal_Int32 nBufferId,
188 cssxc::sax::ElementMarkPriority nPriority ) const
189 /****** ElementCollector/clone ************************************************
191 * NAME
192 * clone -- duplicates this ElementCollector object
194 * SYNOPSIS
195 * cloned = clone(nBufferId, nPriority);
197 * FUNCTION
198 * duplicates this ElementCollector object with new buffer Id, priority.
200 * INPUTS
201 * nBufferId - the buffer node's Id
202 * nPriority - the priority
204 * RESULT
205 * clone - a new ElementCollector
207 * AUTHOR
208 * Michael Mi
209 * Email: michael.mi@sun.com
210 ******************************************************************************/
212 ElementCollector* pClonedOne
213 = new ElementCollector(m_nSecurityId,
214 nBufferId, nPriority, m_bToModify,
215 m_xReferenceResolvedListener);
217 if (m_bAbleToNotify)
219 pClonedOne->notifyListener();
222 if (m_pBufferNode != NULL)
224 m_pBufferNode->addElementCollector(pClonedOne);
227 return pClonedOne;
230 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */