LibreOffice Module xmlsecurity (master) 1
elementcollector.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
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>
25#include <utility>
26
28 sal_Int32 nBufferId,
29 css::xml::crypto::sax::ElementMarkPriority nPriority,
30 bool bToModify,
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),
36 m_bNotified(false),
37 m_xReferenceResolvedListener(std::move(xReferenceResolvedListener))
38/****** ElementCollector/ElementCollector *************************************
39 *
40 * NAME
41 * ElementCollector -- constructor method
42 *
43 * SYNOPSIS
44 * ElementCollector(nSecurityId, nBufferId, nPriority, bToModify
45 * xReferenceResolvedListener);
46 *
47 * FUNCTION
48 * construct an ElementCollector object.
49 *
50 * INPUTS
51 * nSecurityId - represents which security entity the buffer node is
52 * related with. Either a signature or an encryption is
53 * a security entity.
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
57 * element.
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
63 * element.
64 * xReferenceResolvedListener
65 * - the listener that this ElementCollector notifies to.
66 ******************************************************************************/
67{
68 m_type = css::xml::crypto::sax::ElementMarkType_ELEMENTCOLLECTOR;
69}
70
71
73/****** ElementCollector/notifyListener ***************************************
74 *
75 * NAME
76 * notifyListener -- enable the ability to notify the listener
77 *
78 * SYNOPSIS
79 * notifyListener();
80 *
81 * FUNCTION
82 * enable the ability to notify the listener and try to notify then.
83 ******************************************************************************/
84{
85 m_bAbleToNotify = true;
86 doNotify();
87}
88
90 const css::uno::Reference< css::xml::crypto::sax::XReferenceResolvedListener >& xReferenceResolvedListener)
91/****** ElementCollector/setReferenceResolvedListener *************************
92 *
93 * NAME
94 * setReferenceResolvedListener -- configures a listener for the buffer
95 * node in this object
96 *
97 * SYNOPSIS
98 * setReferenceResolvedListener(xReferenceResolvedListener);
99 *
100 * FUNCTION
101 * configures a new listener and try to notify then.
102 *
103 * INPUTS
104 * xReferenceResolvedListener - the new listener
105 ******************************************************************************/
106{
107 m_xReferenceResolvedListener = xReferenceResolvedListener;
108 doNotify();
109}
110
112/****** ElementCollector/doNotify *********************************************
113 *
114 * NAME
115 * doNotify -- tries to notify the listener
116 *
117 * SYNOPSIS
118 * doNotify();
119 *
120 * FUNCTION
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 ******************************************************************************/
127{
128 if (!m_bNotified &&
131 m_nSecurityId != css::xml::crypto::sax::ConstOfSecurityId::UNDEFINEDSECURITYID)
132 {
133 m_bNotified = true;
134 m_xReferenceResolvedListener->referenceResolved(m_nBufferId);
135 }
136}
137
138/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::xml::crypto::sax::XReferenceResolvedListener > m_xReferenceResolvedListener
ElementCollector(sal_Int32 nBufferId, css::xml::crypto::sax::ElementMarkPriority nPriority, bool bToModify, css::uno::Reference< css::xml::crypto::sax::XReferenceResolvedListener > xReferenceResolvedListener)
void setReferenceResolvedListener(const css::uno::Reference< css::xml::crypto::sax::XReferenceResolvedListener > &referenceResolvedListener)
sal_Int32 const m_nBufferId
Definition: elementmark.hxx:45
sal_Int32 m_nSecurityId
Definition: elementmark.hxx:42
css::xml::crypto::sax::ElementMarkType m_type
Definition: elementmark.hxx:53