LCOV - code coverage report
Current view: top level - xmlsecurity/source/framework - elementcollector.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 27 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 "buffernode.hxx"
      24             : #include <com/sun/star/xml/crypto/sax/ConstOfSecurityId.hpp>
      25             : 
      26             : namespace cssu = com::sun::star::uno;
      27             : namespace cssxc = com::sun::star::xml::crypto;
      28             : 
      29           0 : ElementCollector::ElementCollector(
      30             :     sal_Int32 nSecurityId,
      31             :     sal_Int32 nBufferId,
      32             :     cssxc::sax::ElementMarkPriority nPriority,
      33             :     bool bToModify,
      34             :     const com::sun::star::uno::Reference<
      35             :         com::sun::star::xml::crypto::sax::XReferenceResolvedListener >&
      36             :         xReferenceResolvedListener)
      37             :     :ElementMark(nSecurityId, nBufferId),
      38             :      m_nPriority(nPriority),
      39             :      m_bToModify(bToModify),
      40             :       m_bAbleToNotify(false),
      41             :       m_bNotified(false),
      42           0 :      m_xReferenceResolvedListener(xReferenceResolvedListener)
      43             : /****** ElementCollector/ElementCollector *************************************
      44             :  *
      45             :  *   NAME
      46             :  *  ElementCollector -- constructor method
      47             :  *
      48             :  *   SYNOPSIS
      49             :  *  ElementCollector(nSecurityId, nBufferId, nPriority, bToModify
      50             :  *                   xReferenceResolvedListener);
      51             :  *
      52             :  *   FUNCTION
      53             :  *  construct an ElementCollector object.
      54             :  *
      55             :  *   INPUTS
      56             :  *  nSecurityId -   represents which security entity the buffer node is
      57             :  *          related with. Either a signature or an encryption is
      58             :  *          a security entity.
      59             :  *  nBufferId - the id of the element bufferred in the document
      60             :  *          wrapper component. The document wrapper component
      61             :  *          uses this id to search the particular bufferred
      62             :  *          element.
      63             :  *  nPriority - the priority value. ElementCollector with lower
      64             :  *          priority value can't notify until all ElementCollectors
      65             :  *          with higher priority value have notified.
      66             :  *  bToModify - A flag representing whether this ElementCollector
      67             :  *          notification will cause the modification of its working
      68             :  *                  element.
      69             :  *  xReferenceResolvedListener
      70             :  *            - the listener that this ElementCollector notifies to.
      71             :  *
      72             :  *   RESULT
      73             :  *  empty
      74             :  *
      75             :  *   AUTHOR
      76             :  *  Michael Mi
      77             :  *  Email: michael.mi@sun.com
      78             :  ******************************************************************************/
      79             : {
      80           0 :     m_type = cssxc::sax::ElementMarkType_ELEMENTCOLLECTOR;
      81           0 : }
      82             : 
      83             : 
      84             : 
      85           0 : void ElementCollector::notifyListener()
      86             : /****** ElementCollector/notifyListener ***************************************
      87             :  *
      88             :  *   NAME
      89             :  *  notifyListener -- enable the ability to notify the listener
      90             :  *
      91             :  *   SYNOPSIS
      92             :  *  notifyListener();
      93             :  *
      94             :  *   FUNCTION
      95             :  *  enable the ability to notify the listener and try to notify then.
      96             :  *
      97             :  *   INPUTS
      98             :  *  empty
      99             :  *
     100             :  *   RESULT
     101             :  *  empty
     102             :  *
     103             :  *   AUTHOR
     104             :  *  Michael Mi
     105             :  *  Email: michael.mi@sun.com
     106             :  ******************************************************************************/
     107             : {
     108           0 :     m_bAbleToNotify = true;
     109           0 :     doNotify();
     110           0 : }
     111             : 
     112           0 : void ElementCollector::setReferenceResolvedListener(
     113             :     const cssu::Reference< cssxc::sax::XReferenceResolvedListener >& xReferenceResolvedListener)
     114             : /****** ElementCollector/setReferenceResolvedListener *************************
     115             :  *
     116             :  *   NAME
     117             :  *  setReferenceResolvedListener -- configures a listener for the buffer
     118             :  *  node in this object
     119             :  *
     120             :  *   SYNOPSIS
     121             :  *  setReferenceResolvedListener(xReferenceResolvedListener);
     122             :  *
     123             :  *   FUNCTION
     124             :  *  configures a new listener and try to notify then.
     125             :  *
     126             :  *   INPUTS
     127             :  *  xReferenceResolvedListener - the new listener
     128             :  *
     129             :  *   RESULT
     130             :  *  empty
     131             :  *
     132             :  *   AUTHOR
     133             :  *  Michael Mi
     134             :  *  Email: michael.mi@sun.com
     135             :  ******************************************************************************/
     136             : {
     137           0 :     m_xReferenceResolvedListener = xReferenceResolvedListener;
     138           0 :     doNotify();
     139           0 : }
     140             : 
     141           0 : void ElementCollector::doNotify()
     142             : /****** ElementCollector/doNotify *********************************************
     143             :  *
     144             :  *   NAME
     145             :  *  doNotify -- tries to notify the listener
     146             :  *
     147             :  *   SYNOPSIS
     148             :  *  doNotify();
     149             :  *
     150             :  *   FUNCTION
     151             :  *  notifies the listener when all below conditions are satisfied:
     152             :  *  the listener has not been notified;
     153             :  *  the notify right is granted;
     154             :  *  the listener has already been configured;
     155             :  *  the security id has already been configure
     156             :  *
     157             :  *   INPUTS
     158             :  *  empty
     159             :  *
     160             :  *   RESULT
     161             :  *  empty
     162             :  *
     163             :  *   AUTHOR
     164             :  *  Michael Mi
     165             :  *  Email: michael.mi@sun.com
     166             :  ******************************************************************************/
     167             : {
     168           0 :     if (!m_bNotified &&
     169           0 :         m_bAbleToNotify &&
     170           0 :         m_xReferenceResolvedListener.is() &&
     171           0 :         m_nSecurityId != cssxc::sax::ConstOfSecurityId::UNDEFINEDSECURITYID)
     172             :     {
     173           0 :         m_bNotified = true;
     174           0 :         m_xReferenceResolvedListener->referenceResolved(m_nBufferId);
     175             :     }
     176           0 : }
     177             : 
     178           0 : ElementCollector* ElementCollector::clone(
     179             :     sal_Int32 nBufferId,
     180             :     cssxc::sax::ElementMarkPriority nPriority ) const
     181             : /****** ElementCollector/clone ************************************************
     182             :  *
     183             :  *   NAME
     184             :  *  clone -- duplicates this ElementCollector object
     185             :  *
     186             :  *   SYNOPSIS
     187             :  *  cloned = clone(nBufferId, nPriority);
     188             :  *
     189             :  *   FUNCTION
     190             :  *  duplicates this ElementCollector object with new buffer Id, priority.
     191             :  *
     192             :  *   INPUTS
     193             :  *  nBufferId - the buffer node's Id
     194             :  *  nPriority - the priority
     195             :  *
     196             :  *   RESULT
     197             :  *  clone -     a new ElementCollector
     198             :  *
     199             :  *   AUTHOR
     200             :  *  Michael Mi
     201             :  *  Email: michael.mi@sun.com
     202             :  ******************************************************************************/
     203             : {
     204             :     ElementCollector* pClonedOne
     205             :         = new ElementCollector(m_nSecurityId,
     206             :                        nBufferId, nPriority, m_bToModify,
     207           0 :                        m_xReferenceResolvedListener);
     208             : 
     209           0 :     if (m_bAbleToNotify)
     210             :     {
     211           0 :         pClonedOne->notifyListener();
     212             :     }
     213             : 
     214           0 :     if (m_pBufferNode != NULL)
     215             :     {
     216           0 :         m_pBufferNode->addElementCollector(pClonedOne);
     217             :     }
     218             : 
     219           0 :     return pClonedOne;
     220             : }
     221             : 
     222             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11