LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/xmloff - xmlevent.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 15 15 100.0 %
Date: 2013-07-09 Functions: 11 13 84.6 %
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 _XMLOFF_XMLEVENT_HXX
      21             : #define _XMLOFF_XMLEVENT_HXX
      22             : 
      23             : #include <com/sun/star/uno/Sequence.hxx>
      24             : #include <com/sun/star/uno/Reference.hxx>
      25             : 
      26             : 
      27             : /**
      28             :  * @#file
      29             :  *
      30             :  * Several definition used in im- and export of events
      31             :  */
      32             : 
      33             : namespace com { namespace sun { namespace star {
      34             :     namespace xml { namespace sax { class XAttributeList; } }
      35             :     namespace beans { struct PropertyValue; }
      36             : } } }
      37             : 
      38             : class SvXMLExport;
      39             : class SvXMLImportContext;
      40             : class SvXMLImport;
      41             : class XMLEventsImportContext;
      42             : 
      43             : 
      44       31426 : struct XMLEventName
      45             : {
      46             :     sal_uInt16 m_nPrefix;
      47             :     OUString m_aName;
      48             : 
      49        9729 :     XMLEventName() : m_nPrefix( 0 ) {}
      50       10473 :     XMLEventName( sal_uInt16 n, const sal_Char *p ) :
      51             :         m_nPrefix( n ),
      52       10473 :         m_aName( OUString::createFromAscii(p) )
      53       10473 :        {}
      54             : 
      55           7 :     XMLEventName( sal_uInt16 n, const OUString& r ) :
      56             :         m_nPrefix( n ),
      57           7 :         m_aName( r )
      58           7 :        {}
      59             : 
      60        5766 :     bool operator<( const XMLEventName& r ) const
      61             :     {
      62       14857 :         return m_nPrefix < r.m_nPrefix ||
      63       16095 :                (m_nPrefix == r.m_nPrefix && m_aName < r.m_aName );
      64             :     }
      65             : 
      66             : };
      67             : 
      68             : /**
      69             :  * XMLEventNameTranslation: define tables that translate between event names
      70             :  * as used in the XML file format and in the StarOffice API.
      71             :  * The last entry in the table must be { NULL, 0, NULL }.
      72             :  */
      73             : struct XMLEventNameTranslation
      74             : {
      75             :     const sal_Char* sAPIName;
      76             :     sal_uInt16      nPrefix;    // namespace prefix
      77             :     const sal_Char* sXMLName;
      78             : };
      79             : 
      80             : /// a translation table for the events defined in the XEventsSupplier service
      81             : /// (implemented in XMLEventExport.cxx)
      82             : extern const XMLEventNameTranslation aStandardEventTable[];
      83             : 
      84             : 
      85             : /**
      86             :  * Handle export of an event for a certain event type (event type as
      87             :  * defined by the PropertyValue "EventType" in API).
      88             :  *
      89             :  * The Handler has to generate the full <script:event> element.
      90             :  */
      91         288 : class XMLEventExportHandler
      92             : {
      93             : public:
      94         288 :     virtual ~XMLEventExportHandler() {};
      95             : 
      96             :     virtual void Export(
      97             :         SvXMLExport& rExport,                   /// the current XML export
      98             :         const OUString& rEventQName,     /// the XML name of the event
      99             :         ::com::sun::star::uno::Sequence<        /// the values for the event
     100             :             ::com::sun::star::beans::PropertyValue> & rValues,
     101             :          sal_Bool bUseWhitespace) = 0;  /// create whitespace around elements?
     102             : };
     103             : 
     104             : 
     105             : /**
     106             :  * Handle import of an event for a certain event type (as defined by
     107             :  * the PropertyValue "EventType" in the API).
     108             :  *
     109             :  * EventContextFactories must be registered with the EventImportHelper
     110             :  * that is attached to the SvXMLImport.
     111             :  *
     112             :  * The factory has to create an import context for a <script:event>
     113             :  * element.  The context has to call the
     114             :  * EventsImportContext::AddEventValues() method to fave its event
     115             :  * registered with the enclosing element. For events consisting only
     116             :  * of attributes (and an empty element) an easy solution is to handle
     117             :  * all attributes in the CreateContext()-method and return a default
     118             :  * context.
     119             :  *
     120             :  * EventContextFactory objects have to be registered with the
     121             :  * EventsImportHelper.
     122             :  */
     123          24 : class XMLEventContextFactory
     124             : {
     125             : public:
     126          24 :     virtual ~XMLEventContextFactory() {};
     127             : 
     128             :     virtual SvXMLImportContext* CreateContext(
     129             :         SvXMLImport& rImport,               /// import context
     130             :         sal_uInt16 nPrefix,                 /// element: namespace prefix
     131             :         const OUString& rLocalName,  /// element: local name
     132             :         const ::com::sun::star::uno::Reference<     /// attribute list
     133             :             ::com::sun::star::xml::sax::XAttributeList> & xAttrList,
     134             :         /// the context for the enclosing <script:events> element
     135             :         XMLEventsImportContext* rEvents,
     136             :         /// the event name (as understood by the API)
     137             :         const OUString& rApiEventName,
     138             :         /// the event type name (as registered)
     139             :         const OUString& rApiLanguage) = 0;
     140             : };
     141             : 
     142             : 
     143             : #endif
     144             : 
     145             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10