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
;
85 void ElementCollector::notifyListener()
86 /****** ElementCollector/notifyListener ***************************************
89 * notifyListener -- enable the ability to notify the listener
95 * enable the ability to notify the listener and try to notify then.
105 * Email: michael.mi@sun.com
106 ******************************************************************************/
108 m_bAbleToNotify
= true;
112 void ElementCollector::setReferenceResolvedListener(
113 const cssu::Reference
< cssxc::sax::XReferenceResolvedListener
>& xReferenceResolvedListener
)
114 /****** ElementCollector/setReferenceResolvedListener *************************
117 * setReferenceResolvedListener -- configures a listener for the buffer
118 * node in this object
121 * setReferenceResolvedListener(xReferenceResolvedListener);
124 * configures a new listener and try to notify then.
127 * xReferenceResolvedListener - the new listener
134 * Email: michael.mi@sun.com
135 ******************************************************************************/
137 m_xReferenceResolvedListener
= xReferenceResolvedListener
;
141 void ElementCollector::doNotify()
142 /****** ElementCollector/doNotify *********************************************
145 * doNotify -- tries to notify the listener
151 * notifies the listener when all below conditions are satisfied:
152 * the listener has not been notified;
153 * the notify right is granted;
154 * the listener has already been configured;
155 * the security id has already been configure
165 * Email: michael.mi@sun.com
166 ******************************************************************************/
170 m_xReferenceResolvedListener
.is() &&
171 m_nSecurityId
!= cssxc::sax::ConstOfSecurityId::UNDEFINEDSECURITYID
)
174 m_xReferenceResolvedListener
->referenceResolved(m_nBufferId
);
178 ElementCollector
* ElementCollector::clone(
180 cssxc::sax::ElementMarkPriority nPriority
) const
181 /****** ElementCollector/clone ************************************************
184 * clone -- duplicates this ElementCollector object
187 * cloned = clone(nBufferId, nPriority);
190 * duplicates this ElementCollector object with new buffer Id, priority.
193 * nBufferId - the buffer node's Id
194 * nPriority - the priority
197 * clone - a new ElementCollector
201 * Email: michael.mi@sun.com
202 ******************************************************************************/
204 ElementCollector
* pClonedOne
205 = new ElementCollector(m_nSecurityId
,
206 nBufferId
, nPriority
, m_bToModify
,
207 m_xReferenceResolvedListener
);
211 pClonedOne
->notifyListener();
214 if (m_pBufferNode
!= NULL
)
216 m_pBufferNode
->addElementCollector(pClonedOne
);
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */