1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_xmlsecurity.hxx"
31 #include "elementmark.hxx"
32 #include "elementcollector.hxx"
33 #include "buffernode.hxx"
34 #include <com/sun/star/xml/crypto/sax/ConstOfSecurityId.hpp>
36 namespace cssu
= com::sun::star::uno
;
37 namespace cssxc
= com::sun::star::xml::crypto
;
39 ElementCollector::ElementCollector(
40 sal_Int32 nSecurityId
,
42 cssxc::sax::ElementMarkPriority nPriority
,
44 const com::sun::star::uno::Reference
<
45 com::sun::star::xml::crypto::sax::XReferenceResolvedListener
>&
46 xReferenceResolvedListener
)
47 :ElementMark(nSecurityId
, nBufferId
),
48 m_nPriority(nPriority
),
49 m_bToModify(bToModify
),
50 m_bAbleToNotify(false),
52 m_xReferenceResolvedListener(xReferenceResolvedListener
)
53 /****** ElementCollector/ElementCollector *************************************
56 * ElementCollector -- constructor method
59 * ElementCollector(nSecurityId, nBufferId, nPriority, bToModify
60 * xReferenceResolvedListener);
63 * construct an ElementCollector object.
66 * nSecurityId - represents which security entity the buffer node is
67 * related with. Either a signature or an encryption is
69 * nBufferId - the id of the element bufferred in the document
70 * wrapper component. The document wrapper component
71 * uses this id to search the particular bufferred
73 * nPriority - the priority value. ElementCollector with lower
74 * priority value can't notify until all ElementCollectors
75 * with higher priority value have notified.
76 * bToModify - A flag representing whether this ElementCollector
77 * notification will cause the modification of its working
79 * xReferenceResolvedListener
80 * - the listener that this ElementCollector notifies to.
86 * 05.01.2004 - implemented
90 * Email: michael.mi@sun.com
91 ******************************************************************************/
93 m_type
= cssxc::sax::ElementMarkType_ELEMENTCOLLECTOR
;
97 bool ElementCollector::isInternalNotificationSuppressed() const
99 return m_bInternalNotificationSuppressed;
103 cssxc::sax::ElementMarkPriority
ElementCollector::getPriority() const
108 bool ElementCollector::getModify() const
113 void ElementCollector::notifyListener()
114 /****** ElementCollector/notifyListener ***************************************
117 * notifyListener -- enable the ability to notify the listener
123 * enable the ability to notify the listener and try to notify then.
132 * 05.01.2004 - implemented
136 * Email: michael.mi@sun.com
137 ******************************************************************************/
139 m_bAbleToNotify
= true;
143 bool ElementCollector::isAbleToNotify() const
145 return m_bAbleToNotify
;
148 void ElementCollector::setReferenceResolvedListener(
149 const cssu::Reference
< cssxc::sax::XReferenceResolvedListener
>& xReferenceResolvedListener
)
150 /****** ElementCollector/setReferenceResolvedListener *************************
153 * setReferenceResolvedListener -- configures a listener for the buffer
154 * node in this object
157 * setReferenceResolvedListener(xReferenceResolvedListener);
160 * configures a new listener and try to notify then.
163 * xReferenceResolvedListener - the new listener
169 * 05.01.2004 - implemented
173 * Email: michael.mi@sun.com
174 ******************************************************************************/
176 m_xReferenceResolvedListener
= xReferenceResolvedListener
;
180 void ElementCollector::setSecurityId(sal_Int32 nSecurityId
)
181 /****** ElementCollector/setSecurityId ****************************************
184 * setSecurityId -- configures the security Id of the buffer node
187 * setSecurityId(nSecurityId);
190 * configures the security Id and try to notify then
193 * nSecurityId - the security Id
199 * 05.01.2004 - implemented
203 * Email: michael.mi@sun.com
204 ******************************************************************************/
206 m_nSecurityId
= nSecurityId
;
210 void ElementCollector::doNotify()
211 /****** ElementCollector/doNotify *********************************************
214 * doNotify -- tries to notify the listener
220 * notifies the listener when all below conditions are satisfied:
221 * the listener has not been notified;
222 * the notify right is granted;
223 * the listener has already been configured;
224 * the security id has already been configure
233 * 05.01.2004 - implemented
237 * Email: michael.mi@sun.com
238 ******************************************************************************/
242 m_xReferenceResolvedListener
.is() &&
243 m_nSecurityId
!= cssxc::sax::ConstOfSecurityId::UNDEFINEDSECURITYID
)
246 m_xReferenceResolvedListener
->referenceResolved(m_nBufferId
);
250 ElementCollector
* ElementCollector::clone(
252 cssxc::sax::ElementMarkPriority nPriority
) const
253 /****** ElementCollector/clone ************************************************
256 * clone -- duplicates this ElementCollector object
259 * cloned = clone(nBufferId, nPriority);
262 * duplicates this ElementCollector object with new buffer Id, priority.
265 * nBufferId - the buffer node's Id
266 * nPriority - the priority
269 * clone - a new ElementCollector
272 * 05.01.2004 - implemented
276 * Email: michael.mi@sun.com
277 ******************************************************************************/
279 ElementCollector
* pClonedOne
280 = new ElementCollector(m_nSecurityId
,
281 nBufferId
, nPriority
, m_bToModify
,
282 m_xReferenceResolvedListener
);
286 pClonedOne
->notifyListener();
289 if (m_pBufferNode
!= NULL
)
291 m_pBufferNode
->addElementCollector(pClonedOne
);