1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
,
32 cssxc::sax::ElementMarkPriority nPriority
,
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),
42 m_xReferenceResolvedListener(xReferenceResolvedListener
)
43 /****** ElementCollector/ElementCollector *************************************
46 * ElementCollector -- constructor method
49 * ElementCollector(nSecurityId, nBufferId, nPriority, bToModify
50 * xReferenceResolvedListener);
53 * construct an ElementCollector object.
56 * nSecurityId - represents which security entity the buffer node is
57 * related with. Either a signature or an encryption is
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
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
69 * xReferenceResolvedListener
70 * - the listener that this ElementCollector notifies to.
77 * Email: michael.mi@sun.com
78 ******************************************************************************/
80 m_type
= cssxc::sax::ElementMarkType_ELEMENTCOLLECTOR
;
83 cssxc::sax::ElementMarkPriority
ElementCollector::getPriority() const
88 bool ElementCollector::getModify() const
93 void ElementCollector::notifyListener()
94 /****** ElementCollector/notifyListener ***************************************
97 * notifyListener -- enable the ability to notify the listener
103 * enable the ability to notify the listener and try to notify then.
113 * Email: michael.mi@sun.com
114 ******************************************************************************/
116 m_bAbleToNotify
= true;
120 void ElementCollector::setReferenceResolvedListener(
121 const cssu::Reference
< cssxc::sax::XReferenceResolvedListener
>& xReferenceResolvedListener
)
122 /****** ElementCollector/setReferenceResolvedListener *************************
125 * setReferenceResolvedListener -- configures a listener for the buffer
126 * node in this object
129 * setReferenceResolvedListener(xReferenceResolvedListener);
132 * configures a new listener and try to notify then.
135 * xReferenceResolvedListener - the new listener
142 * Email: michael.mi@sun.com
143 ******************************************************************************/
145 m_xReferenceResolvedListener
= xReferenceResolvedListener
;
149 void ElementCollector::doNotify()
150 /****** ElementCollector/doNotify *********************************************
153 * doNotify -- tries to notify the listener
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
173 * Email: michael.mi@sun.com
174 ******************************************************************************/
178 m_xReferenceResolvedListener
.is() &&
179 m_nSecurityId
!= cssxc::sax::ConstOfSecurityId::UNDEFINEDSECURITYID
)
182 m_xReferenceResolvedListener
->referenceResolved(m_nBufferId
);
186 ElementCollector
* ElementCollector::clone(
188 cssxc::sax::ElementMarkPriority nPriority
) const
189 /****** ElementCollector/clone ************************************************
192 * clone -- duplicates this ElementCollector object
195 * cloned = clone(nBufferId, nPriority);
198 * duplicates this ElementCollector object with new buffer Id, priority.
201 * nBufferId - the buffer node's Id
202 * nPriority - the priority
205 * clone - a new ElementCollector
209 * Email: michael.mi@sun.com
210 ******************************************************************************/
212 ElementCollector
* pClonedOne
213 = new ElementCollector(m_nSecurityId
,
214 nBufferId
, nPriority
, m_bToModify
,
215 m_xReferenceResolvedListener
);
219 pClonedOne
->notifyListener();
222 if (m_pBufferNode
!= NULL
)
224 m_pBufferNode
->addElementCollector(pClonedOne
);
230 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */