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(
31 cssxc::sax::ElementMarkPriority nPriority
,
33 const css::uno::Reference
< css::xml::crypto::sax::XReferenceResolvedListener
>& xReferenceResolvedListener
)
34 :ElementMark(cssxc::sax::ConstOfSecurityId::UNDEFINEDSECURITYID
, nBufferId
),
35 m_nPriority(nPriority
),
36 m_bToModify(bToModify
),
37 m_bAbleToNotify(false),
39 m_xReferenceResolvedListener(xReferenceResolvedListener
)
40 /****** ElementCollector/ElementCollector *************************************
43 * ElementCollector -- constructor method
46 * ElementCollector(nSecurityId, nBufferId, nPriority, bToModify
47 * xReferenceResolvedListener);
50 * construct an ElementCollector object.
53 * nSecurityId - represents which security entity the buffer node is
54 * related with. Either a signature or an encryption is
56 * nBufferId - the id of the element bufferred in the document
57 * wrapper component. The document wrapper component
58 * uses this id to search the particular bufferred
60 * nPriority - the priority value. ElementCollector with lower
61 * priority value can't notify until all ElementCollectors
62 * with higher priority value have notified.
63 * bToModify - A flag representing whether this ElementCollector
64 * notification will cause the modification of its working
66 * xReferenceResolvedListener
67 * - the listener that this ElementCollector notifies to.
68 ******************************************************************************/
70 m_type
= cssxc::sax::ElementMarkType_ELEMENTCOLLECTOR
;
74 void ElementCollector::notifyListener()
75 /****** ElementCollector/notifyListener ***************************************
78 * notifyListener -- enable the ability to notify the listener
84 * enable the ability to notify the listener and try to notify then.
85 ******************************************************************************/
87 m_bAbleToNotify
= true;
91 void ElementCollector::setReferenceResolvedListener(
92 const cssu::Reference
< cssxc::sax::XReferenceResolvedListener
>& xReferenceResolvedListener
)
93 /****** ElementCollector/setReferenceResolvedListener *************************
96 * setReferenceResolvedListener -- configures a listener for the buffer
100 * setReferenceResolvedListener(xReferenceResolvedListener);
103 * configures a new listener and try to notify then.
106 * xReferenceResolvedListener - the new listener
107 ******************************************************************************/
109 m_xReferenceResolvedListener
= xReferenceResolvedListener
;
113 void ElementCollector::doNotify()
114 /****** ElementCollector/doNotify *********************************************
117 * doNotify -- tries to notify the listener
123 * notifies the listener when all below conditions are satisfied:
124 * the listener has not been notified;
125 * the notify right is granted;
126 * the listener has already been configured;
127 * the security id has already been configure
128 ******************************************************************************/
132 m_xReferenceResolvedListener
.is() &&
133 m_nSecurityId
!= cssxc::sax::ConstOfSecurityId::UNDEFINEDSECURITYID
)
136 m_xReferenceResolvedListener
->referenceResolved(m_nBufferId
);
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */