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>
27 ElementCollector::ElementCollector(
29 css::xml::crypto::sax::ElementMarkPriority nPriority
,
31 css::uno::Reference
< css::xml::crypto::sax::XReferenceResolvedListener
> xReferenceResolvedListener
)
32 :ElementMark(css::xml::crypto::sax::ConstOfSecurityId::UNDEFINEDSECURITYID
, nBufferId
),
33 m_nPriority(nPriority
),
34 m_bToModify(bToModify
),
35 m_bAbleToNotify(false),
37 m_xReferenceResolvedListener(std::move(xReferenceResolvedListener
))
38 /****** ElementCollector/ElementCollector *************************************
41 * ElementCollector -- constructor method
44 * ElementCollector(nSecurityId, nBufferId, nPriority, bToModify
45 * xReferenceResolvedListener);
48 * construct an ElementCollector object.
51 * nSecurityId - represents which security entity the buffer node is
52 * related with. Either a signature or an encryption is
54 * nBufferId - the id of the element buffered in the document
55 * wrapper component. The document wrapper component
56 * uses this id to search the particular buffered
58 * nPriority - the priority value. ElementCollector with lower
59 * priority value can't notify until all ElementCollectors
60 * with higher priority value have notified.
61 * bToModify - A flag representing whether this ElementCollector
62 * notification will cause the modification of its working
64 * xReferenceResolvedListener
65 * - the listener that this ElementCollector notifies to.
66 ******************************************************************************/
68 m_type
= css::xml::crypto::sax::ElementMarkType_ELEMENTCOLLECTOR
;
72 void ElementCollector::notifyListener()
73 /****** ElementCollector/notifyListener ***************************************
76 * notifyListener -- enable the ability to notify the listener
82 * enable the ability to notify the listener and try to notify then.
83 ******************************************************************************/
85 m_bAbleToNotify
= true;
89 void ElementCollector::setReferenceResolvedListener(
90 const css::uno::Reference
< css::xml::crypto::sax::XReferenceResolvedListener
>& xReferenceResolvedListener
)
91 /****** ElementCollector/setReferenceResolvedListener *************************
94 * setReferenceResolvedListener -- configures a listener for the buffer
98 * setReferenceResolvedListener(xReferenceResolvedListener);
101 * configures a new listener and try to notify then.
104 * xReferenceResolvedListener - the new listener
105 ******************************************************************************/
107 m_xReferenceResolvedListener
= xReferenceResolvedListener
;
111 void ElementCollector::doNotify()
112 /****** ElementCollector/doNotify *********************************************
115 * doNotify -- tries to notify the listener
121 * notifies the listener when all below conditions are satisfied:
122 * the listener has not been notified;
123 * the notify right is granted;
124 * the listener has already been configured;
125 * the security id has already been configure
126 ******************************************************************************/
130 m_xReferenceResolvedListener
.is() &&
131 m_nSecurityId
!= css::xml::crypto::sax::ConstOfSecurityId::UNDEFINEDSECURITYID
)
134 m_xReferenceResolvedListener
->referenceResolved(m_nBufferId
);
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */