LCOV - code coverage report
Current view: top level - libreoffice/extensions/source/logging - loghandler.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 12 0.0 %
Date: 2012-12-27 Functions: 0 8 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             : #ifndef LOGHANDLER_HXX
      21             : #define LOGHANDLER_HXX
      22             : 
      23             : #include <com/sun/star/logging/XLogFormatter.hpp>
      24             : #include <com/sun/star/uno/XComponentContext.hpp>
      25             : #include <com/sun/star/logging/LogRecord.hpp>
      26             : 
      27             : #include <comphelper/namedvaluecollection.hxx>
      28             : #include <cppuhelper/interfacecontainer.hxx>
      29             : #include <rtl/string.hxx>
      30             : 
      31             : //........................................................................
      32             : namespace logging
      33             : {
      34             : //........................................................................
      35             : 
      36             :     //====================================================================
      37             :     //=
      38             :     //====================================================================
      39           0 :     class LogHandlerHelper
      40             :     {
      41             :     private:
      42             :         // <attributes>
      43             :         rtl_TextEncoding    m_eEncoding;
      44             :         sal_Int32           m_nLevel;
      45             :         ::com::sun::star::uno::Reference< ::com::sun::star::logging::XLogFormatter >
      46             :                             m_xFormatter;
      47             :         // <//attributes>
      48             : 
      49             :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
      50             :                                     m_xContext;
      51             :         ::osl::Mutex&               m_rMutex;
      52             :         ::cppu::OBroadcastHelper&   m_rBHelper;
      53             :         bool                        m_bInitialized;
      54             : 
      55             :     public:
      56             :         LogHandlerHelper(
      57             :             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
      58             :             ::osl::Mutex& _rMutex,
      59             :             ::cppu::OBroadcastHelper& _rBHelper
      60             :         );
      61             : 
      62             :     public:
      63           0 :         bool    getIsInitialized() const { return m_bInitialized; }
      64           0 :         void    setIsInitialized() { m_bInitialized = true; }
      65             : 
      66             :         bool    getEncoding(        ::rtl::OUString& _out_rEncoding ) const;
      67             :         bool    setEncoding( const  ::rtl::OUString& _rEncoding     );
      68             : 
      69             :         inline  rtl_TextEncoding
      70           0 :                 getTextEncoding() const { return m_eEncoding; }
      71             : 
      72             :         inline  ::com::sun::star::uno::Reference< ::com::sun::star::logging::XLogFormatter >
      73           0 :                 getFormatter() const { return m_xFormatter; }
      74             :         inline  void
      75           0 :                 setFormatter( const ::com::sun::star::uno::Reference< ::com::sun::star::logging::XLogFormatter >& _rxFormatter )
      76             :                 {
      77           0 :                     m_xFormatter = _rxFormatter;
      78           0 :                 }
      79             : 
      80             :         inline  sal_Int32
      81           0 :                 getLevel() const { return m_nLevel; }
      82             :         inline  void
      83           0 :                 setLevel( const sal_Int32 _nLevel )
      84             :                 {
      85           0 :                     m_nLevel = _nLevel;
      86           0 :                 }
      87             : 
      88             :         /** prepares implementation of an public accessible method of a log handler
      89             : 
      90             :             <code>enterMethod</code> does the following things:
      91             :             <ul><li>It acquires the mutex given in the constructor.</li>
      92             :                 <li>It checks whether the component is already initialized, and throws an exception if not os.</li>
      93             :                 <li>It checks whether the component is already disposed, and throws an exception if not os.</li>
      94             :                 <li>It creates a default formatter (PlainTextFormatter), if no formatter exists at this time.</li>
      95             :             </ul>
      96             :         */
      97             :         void enterMethod();
      98             : 
      99             :         /** formats a record for publishing it
     100             : 
     101             :             The method first checks whether the records log level is greater or equal our own
     102             :             log level. If not, <FALSE/> is returned.
     103             : 
     104             :             Second, our formatter is used to create a unicode string from the log record. If an error occurs
     105             :             during this, e.g. if the formatter is <NULL/> or throws an exception during formatting,
     106             :             <FALSE/> is returned.
     107             : 
     108             :             Finally, the unicode string is encoded into a byte string, using our encoding setting. Then,
     109             :             <TRUE/> is returned.
     110             :         */
     111             :         bool    formatForPublishing( const ::com::sun::star::logging::LogRecord& _rRecord, ::rtl::OString& _out_rEntry ) const;
     112             : 
     113             :         /** retrieves our formatter's heading, encoded with our encoding
     114             : 
     115             :             @return <TRUE/> in case of success, <FALSE/> if any error occurred
     116             :         */
     117             :         bool    getEncodedHead( ::rtl::OString& _out_rHead ) const;
     118             : 
     119             :         /** retrieves our formatter's tail, encoded with our encoding
     120             : 
     121             :             @return <TRUE/> in case of success, <FALSE/> if any error occurred
     122             :         */
     123             :         bool    getEncodedTail( ::rtl::OString& _out_rTail ) const;
     124             : 
     125             :         /** initializes the instance from a collection of named settings
     126             : 
     127             :             The recognized named settings are <code>Encoding</code>, <code>Formatter</code>, and <code>Level</code>,
     128             :             which initialize the respective attributes.
     129             : 
     130             :             Settings which are recognized are remove from the given collection. This allows
     131             :             the caller to determine whether or not the collection contained any unsupported
     132             :             items, and react appropriately.
     133             : 
     134             :             @throws IllegalArgumentException
     135             :                 if one of the values in the collection is of wrong type.
     136             :         */
     137             :         void    initFromSettings( const ::comphelper::NamedValueCollection& _rSettings );
     138             :     };
     139             : 
     140             : //........................................................................
     141             : } // namespace logging
     142             : //........................................................................
     143             : 
     144             : #endif // LOGHANDLER_HXX
     145             : 
     146             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10