LCOV - code coverage report
Current view: top level - xmloff/source/forms - propertyimport.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 15 0.0 %
Date: 2014-04-14 Functions: 0 14 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 INCLUDED_XMLOFF_SOURCE_FORMS_PROPERTYIMPORT_HXX
      21             : #define INCLUDED_XMLOFF_SOURCE_FORMS_PROPERTYIMPORT_HXX
      22             : 
      23             : #include <sal/config.h>
      24             : 
      25             : #include <set>
      26             : 
      27             : #include <xmloff/xmlictxt.hxx>
      28             : #include "formattributes.hxx"
      29             : #include <rtl/ref.hxx>
      30             : #include <com/sun/star/beans/PropertyValue.hpp>
      31             : #include "layerimport.hxx"
      32             : 
      33             : namespace com { namespace sun { namespace star { namespace util {
      34             :     struct Time;
      35             :     struct Date;
      36             : } } } }
      37             : 
      38             : namespace xmloff
      39             : {
      40             : 
      41             :     //= PropertyConversion
      42             :     class PropertyConversion
      43             :     {
      44             :     public:
      45             :         static ::com::sun::star::uno::Any convertString(
      46             :             SvXMLImport& _rImporter,
      47             :             const ::com::sun::star::uno::Type& _rExpectedType,
      48             :             const OUString& _rReadCharacters,
      49             :             const SvXMLEnumMapEntry* _pEnumMap = NULL,
      50             :             const sal_Bool _bInvertBoolean = sal_False
      51             :         );
      52             : 
      53             :         static ::com::sun::star::uno::Type xmlTypeToUnoType( const OUString& _rType );
      54             :     };
      55             : 
      56             :     class OFormLayerXMLImport_Impl;
      57             :     //= OPropertyImport
      58             :     /** Helper class for importing property values
      59             : 
      60             :         <p>This class imports properties which are stored as attributes as well as properties which
      61             :         are stored in </em>&lt;form:properties&gt;</em> elements.</p>
      62             :     */
      63           0 :     class OPropertyImport : public SvXMLImportContext
      64             :     {
      65             :         friend class OSinglePropertyContext;
      66             :         friend class OListPropertyContext;
      67             : 
      68             :     protected:
      69             :         typedef ::std::vector< ::com::sun::star::beans::PropertyValue > PropertyValueArray;
      70             :         PropertyValueArray          m_aValues;
      71             :         PropertyValueArray          m_aGenericValues;
      72             :             // the values which the instance collects between StartElement and EndElement
      73             : 
      74             :         typedef std::set<OUString> StringSet;
      75             :         StringSet                   m_aEncounteredAttributes;
      76             : 
      77             :         OFormLayerXMLImport_Impl&       m_rContext;
      78             : 
      79             :         sal_Bool                    m_bTrackAttributes;
      80             : 
      81             :         // TODO: think about the restriction that the class does not know anything about the object it is importing.
      82             :         // Perhaps this object should be known to the class, so setting the properties ('normal' ones as well as
      83             :         // style properties) can be done in our own EndElement instead of letting derived classes do this.
      84             : 
      85             :     public:
      86             :         OPropertyImport(OFormLayerXMLImport_Impl& _rImport, sal_uInt16 _nPrefix, const OUString& _rName);
      87             : 
      88             :         virtual SvXMLImportContext* CreateChildContext(
      89             :             sal_uInt16 _nPrefix, const OUString& _rLocalName,
      90             :             const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList) SAL_OVERRIDE;
      91             : 
      92             :         virtual void StartElement(
      93             :             const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList) SAL_OVERRIDE;
      94             :         virtual void Characters(const OUString& _rChars) SAL_OVERRIDE;
      95             : 
      96             :     protected:
      97             :         /** handle one single attribute.
      98             : 
      99             :             <p>This is called for every attribute of the element. This class' implementaion checks if the attribute
     100             :             describes a property, if so, it is added to <member>m_aValues</member>.</p>
     101             : 
     102             :             <p>All non-property attributes should be handled in derived classes.</p>
     103             : 
     104             :             @param _nNamespaceKey
     105             :                 key of the namespace used in the attribute
     106             :             @param _rLocalName
     107             :                 local (relative to the namespace) attribute name
     108             :             @param _rValue
     109             :                 attribute value
     110             :         */
     111             :         virtual bool handleAttribute(sal_uInt16 _nNamespaceKey,
     112             :             const OUString& _rLocalName,
     113             :             const OUString& _rValue);
     114             : 
     115             :         /** determine if the element imported by the object had an given attribute.
     116             :             <p>Please be aware of the fact that the name given must be a local name, i.e. not contain a namespace.
     117             :             All form relevant attributes are in the same namespace, so this would be an redundant information.</p>
     118             :         */
     119             :         sal_Bool    encounteredAttribute(const OUString& _rAttributeName) const;
     120             : 
     121             :         /** determine if the element imported by the object had an given attribute.
     122             :             <p>Please be aware of the fact that the name given must be a local name, i.e. not contain a namespace.
     123             :             All form relevant attributes are in the same namespace, so this would be an redundant information.</p>
     124             :         */
     125             :         sal_Bool    encounteredAttribute(const sal_Char* _pAttributeName) const { return encounteredAttribute(OUString::createFromAscii(_pAttributeName)); }
     126             : 
     127             :         /** enables the tracking of the encountered attributes
     128             :             <p>The tracking will raise the import costs a little bit, but it's cheaper than
     129             :             derived classes tracking this themself.</p>
     130             :         */
     131           0 :         void        enableTrackAttributes() { m_bTrackAttributes = sal_True; }
     132             : 
     133           0 :         inline void implPushBackPropertyValue(const ::com::sun::star::beans::PropertyValue& _rProp)
     134             :         {
     135           0 :             m_aValues.push_back(_rProp);
     136           0 :         }
     137             : 
     138           0 :         inline void implPushBackPropertyValue( const OUString& _rName, const ::com::sun::star::uno::Any& _rValue )
     139             :         {
     140             :             m_aValues.push_back( ::com::sun::star::beans::PropertyValue(
     141           0 :                 _rName, -1, _rValue, ::com::sun::star::beans::PropertyState_DIRECT_VALUE ) );
     142           0 :         }
     143             : 
     144           0 :         inline void implPushBackGenericPropertyValue(const ::com::sun::star::beans::PropertyValue& _rProp)
     145             :         {
     146           0 :             m_aGenericValues.push_back(_rProp);
     147           0 :         }
     148             :     };
     149             :     typedef tools::SvRef<OPropertyImport> OPropertyImportRef;
     150             : 
     151             :     //= OPropertyElementsContext
     152             :     /** helper class for importing the &lt;form:properties&gt; element
     153             :     */
     154           0 :     class OPropertyElementsContext : public SvXMLImportContext
     155             :     {
     156             :     protected:
     157             :         OPropertyImportRef  m_xPropertyImporter;    // to add the properties
     158             : 
     159             :     public:
     160             :         OPropertyElementsContext(SvXMLImport& _rImport, sal_uInt16 _nPrefix, const OUString& _rName,
     161             :                 const OPropertyImportRef& _rPropertyImporter);
     162             : 
     163             :         virtual SvXMLImportContext* CreateChildContext(
     164             :             sal_uInt16 _nPrefix, const OUString& _rLocalName,
     165             :             const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList) SAL_OVERRIDE;
     166             : 
     167             : #if OSL_DEBUG_LEVEL > 0
     168             :         virtual void StartElement(
     169             :             const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList) SAL_OVERRIDE;
     170             :         virtual void Characters(const OUString& _rChars) SAL_OVERRIDE;
     171             : #endif
     172             :     };
     173             : 
     174             :     //= OSinglePropertyContext
     175             :     /** helper class for importing a single &lt;form:property&gt; element
     176             :     */
     177           0 :     class OSinglePropertyContext : public SvXMLImportContext
     178             :     {
     179             :         OPropertyImportRef          m_xPropertyImporter;    // to add the properties
     180             : 
     181             :     public:
     182             :         OSinglePropertyContext(SvXMLImport& _rImport, sal_uInt16 _nPrefix, const OUString& _rName,
     183             :                 const OPropertyImportRef& _rPropertyImporter);
     184             : 
     185             :         virtual SvXMLImportContext* CreateChildContext(
     186             :             sal_uInt16 _nPrefix, const OUString& _rLocalName,
     187             :             const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList) SAL_OVERRIDE;
     188             : 
     189             :         virtual void StartElement(
     190             :             const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList) SAL_OVERRIDE;
     191             :     };
     192             : 
     193             :     //= OListPropertyContext
     194           0 :     class OListPropertyContext : public SvXMLImportContext
     195             :     {
     196             :         OPropertyImportRef                  m_xPropertyImporter;
     197             :         OUString                     m_sPropertyName;
     198             :         OUString                     m_sPropertyType;
     199             :         ::std::vector< OUString >    m_aListValues;
     200             : 
     201             :     public:
     202             :         OListPropertyContext( SvXMLImport& _rImport, sal_uInt16 _nPrefix, const OUString& _rName,
     203             :                 const OPropertyImportRef& _rPropertyImporter );
     204             : 
     205             :         virtual void StartElement(
     206             :             const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList ) SAL_OVERRIDE;
     207             : 
     208             :         virtual void EndElement() SAL_OVERRIDE;
     209             : 
     210             :         virtual SvXMLImportContext* CreateChildContext(
     211             :             sal_uInt16 _nPrefix, const OUString& _rLocalName,
     212             :             const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList) SAL_OVERRIDE;
     213             :     };
     214             : 
     215             :     //= OListValueContext
     216           0 :     class OListValueContext : public SvXMLImportContext
     217             :     {
     218             :         OUString& m_rListValueHolder;
     219             : 
     220             :     public:
     221             :         OListValueContext( SvXMLImport& _rImport, sal_uInt16 _nPrefix, const OUString& _rName,
     222             :             OUString& _rListValueHolder );
     223             : 
     224             :         virtual void StartElement(
     225             :             const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList ) SAL_OVERRIDE;
     226             :     };
     227             : 
     228             : }   // namespace xmloff
     229             : 
     230             : #endif // INCLUDED_XMLOFF_SOURCE_FORMS_PROPERTYIMPORT_HXX
     231             : 
     232             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10