1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: elementcollector.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmlsecurity.hxx"
34 #include "elementmark.hxx"
35 #include "elementcollector.hxx"
36 #include "buffernode.hxx"
37 #include <com/sun/star/xml/crypto/sax/ConstOfSecurityId.hpp>
39 namespace cssu
= com::sun::star::uno
;
40 namespace cssxc
= com::sun::star::xml::crypto
;
42 ElementCollector::ElementCollector(
43 sal_Int32 nSecurityId
,
45 cssxc::sax::ElementMarkPriority nPriority
,
47 const com::sun::star::uno::Reference
<
48 com::sun::star::xml::crypto::sax::XReferenceResolvedListener
>&
49 xReferenceResolvedListener
)
50 :ElementMark(nSecurityId
, nBufferId
),
51 m_nPriority(nPriority
),
52 m_bToModify(bToModify
),
53 m_bAbleToNotify(false),
55 m_xReferenceResolvedListener(xReferenceResolvedListener
)
56 /****** ElementCollector/ElementCollector *************************************
59 * ElementCollector -- constructor method
62 * ElementCollector(nSecurityId, nBufferId, nPriority, bToModify
63 * xReferenceResolvedListener);
66 * construct an ElementCollector object.
69 * nSecurityId - represents which security entity the buffer node is
70 * related with. Either a signature or an encryption is
72 * nBufferId - the id of the element bufferred in the document
73 * wrapper component. The document wrapper component
74 * uses this id to search the particular bufferred
76 * nPriority - the priority value. ElementCollector with lower
77 * priority value can't notify until all ElementCollectors
78 * with higher priority value have notified.
79 * bToModify - A flag representing whether this ElementCollector
80 * notification will cause the modification of its working
82 * xReferenceResolvedListener
83 * - the listener that this ElementCollector notifies to.
89 * 05.01.2004 - implemented
93 * Email: michael.mi@sun.com
94 ******************************************************************************/
96 m_type
= cssxc::sax::ElementMarkType_ELEMENTCOLLECTOR
;
100 bool ElementCollector::isInternalNotificationSuppressed() const
102 return m_bInternalNotificationSuppressed;
106 cssxc::sax::ElementMarkPriority
ElementCollector::getPriority() const
111 bool ElementCollector::getModify() const
116 void ElementCollector::notifyListener()
117 /****** ElementCollector/notifyListener ***************************************
120 * notifyListener -- enable the ability to notify the listener
126 * enable the ability to notify the listener and try to notify then.
135 * 05.01.2004 - implemented
139 * Email: michael.mi@sun.com
140 ******************************************************************************/
142 m_bAbleToNotify
= true;
146 bool ElementCollector::isAbleToNotify() const
148 return m_bAbleToNotify
;
151 void ElementCollector::setReferenceResolvedListener(
152 const cssu::Reference
< cssxc::sax::XReferenceResolvedListener
>& xReferenceResolvedListener
)
153 /****** ElementCollector/setReferenceResolvedListener *************************
156 * setReferenceResolvedListener -- configures a listener for the buffer
157 * node in this object
160 * setReferenceResolvedListener(xReferenceResolvedListener);
163 * configures a new listener and try to notify then.
166 * xReferenceResolvedListener - the new listener
172 * 05.01.2004 - implemented
176 * Email: michael.mi@sun.com
177 ******************************************************************************/
179 m_xReferenceResolvedListener
= xReferenceResolvedListener
;
183 void ElementCollector::setSecurityId(sal_Int32 nSecurityId
)
184 /****** ElementCollector/setSecurityId ****************************************
187 * setSecurityId -- configures the security Id of the buffer node
190 * setSecurityId(nSecurityId);
193 * configures the security Id and try to notify then
196 * nSecurityId - the security Id
202 * 05.01.2004 - implemented
206 * Email: michael.mi@sun.com
207 ******************************************************************************/
209 m_nSecurityId
= nSecurityId
;
213 void ElementCollector::doNotify()
214 /****** ElementCollector/doNotify *********************************************
217 * doNotify -- tries to notify the listener
223 * notifies the listener when all below conditions are satisfied:
224 * the listener has not been notified;
225 * the notify right is granted;
226 * the listener has already been configured;
227 * the security id has already been configure
236 * 05.01.2004 - implemented
240 * Email: michael.mi@sun.com
241 ******************************************************************************/
245 m_xReferenceResolvedListener
.is() &&
246 m_nSecurityId
!= cssxc::sax::ConstOfSecurityId::UNDEFINEDSECURITYID
)
249 m_xReferenceResolvedListener
->referenceResolved(m_nBufferId
);
253 ElementCollector
* ElementCollector::clone(
255 cssxc::sax::ElementMarkPriority nPriority
) const
256 /****** ElementCollector/clone ************************************************
259 * clone -- duplicates this ElementCollector object
262 * cloned = clone(nBufferId, nPriority);
265 * duplicates this ElementCollector object with new buffer Id, priority.
268 * nBufferId - the buffer node's Id
269 * nPriority - the priority
272 * clone - a new ElementCollector
275 * 05.01.2004 - implemented
279 * Email: michael.mi@sun.com
280 ******************************************************************************/
282 ElementCollector
* pClonedOne
283 = new ElementCollector(m_nSecurityId
,
284 nBufferId
, nPriority
, m_bToModify
,
285 m_xReferenceResolvedListener
);
289 pClonedOne
->notifyListener();
292 if (m_pBufferNode
!= NULL
)
294 m_pBufferNode
->addElementCollector(pClonedOne
);