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 <com/sun/star/xml/crypto/sax/ConstOfSecurityId.hpp>
24 #include <com/sun/star/xml/crypto/sax/XReferenceResolvedListener.hpp>
26 ElementCollector::ElementCollector(
28 css::xml::crypto::sax::ElementMarkPriority nPriority
,
30 const css::uno::Reference
< css::xml::crypto::sax::XReferenceResolvedListener
>& xReferenceResolvedListener
)
31 :ElementMark(css::xml::crypto::sax::ConstOfSecurityId::UNDEFINEDSECURITYID
, nBufferId
),
32 m_nPriority(nPriority
),
33 m_bToModify(bToModify
),
34 m_bAbleToNotify(false),
36 m_xReferenceResolvedListener(xReferenceResolvedListener
)
37 /****** ElementCollector/ElementCollector *************************************
40 * ElementCollector -- constructor method
43 * ElementCollector(nSecurityId, nBufferId, nPriority, bToModify
44 * xReferenceResolvedListener);
47 * construct an ElementCollector object.
50 * nSecurityId - represents which security entity the buffer node is
51 * related with. Either a signature or an encryption is
53 * nBufferId - the id of the element buffered in the document
54 * wrapper component. The document wrapper component
55 * uses this id to search the particular buffered
57 * nPriority - the priority value. ElementCollector with lower
58 * priority value can't notify until all ElementCollectors
59 * with higher priority value have notified.
60 * bToModify - A flag representing whether this ElementCollector
61 * notification will cause the modification of its working
63 * xReferenceResolvedListener
64 * - the listener that this ElementCollector notifies to.
65 ******************************************************************************/
67 m_type
= css::xml::crypto::sax::ElementMarkType_ELEMENTCOLLECTOR
;
71 void ElementCollector::notifyListener()
72 /****** ElementCollector/notifyListener ***************************************
75 * notifyListener -- enable the ability to notify the listener
81 * enable the ability to notify the listener and try to notify then.
82 ******************************************************************************/
84 m_bAbleToNotify
= true;
88 void ElementCollector::setReferenceResolvedListener(
89 const css::uno::Reference
< css::xml::crypto::sax::XReferenceResolvedListener
>& xReferenceResolvedListener
)
90 /****** ElementCollector/setReferenceResolvedListener *************************
93 * setReferenceResolvedListener -- configures a listener for the buffer
97 * setReferenceResolvedListener(xReferenceResolvedListener);
100 * configures a new listener and try to notify then.
103 * xReferenceResolvedListener - the new listener
104 ******************************************************************************/
106 m_xReferenceResolvedListener
= xReferenceResolvedListener
;
110 void ElementCollector::doNotify()
111 /****** ElementCollector/doNotify *********************************************
114 * doNotify -- tries to notify the listener
120 * notifies the listener when all below conditions are satisfied:
121 * the listener has not been notified;
122 * the notify right is granted;
123 * the listener has already been configured;
124 * the security id has already been configure
125 ******************************************************************************/
129 m_xReferenceResolvedListener
.is() &&
130 m_nSecurityId
!= css::xml::crypto::sax::ConstOfSecurityId::UNDEFINEDSECURITYID
)
133 m_xReferenceResolvedListener
->referenceResolved(m_nBufferId
);
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */