LCOV - code coverage report
Current view: top level - forms/source/xforms - model_helper.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 5 28 17.9 %
Date: 2015-06-13 12:38:46 Functions: 9 16 56.2 %
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             : #ifndef INCLUDED_FORMS_SOURCE_XFORMS_MODEL_HELPER_HXX
      20             : #define INCLUDED_FORMS_SOURCE_XFORMS_MODEL_HELPER_HXX
      21             : 
      22             : 
      23             : // some helper definitions that must be available for model.cxx and
      24             : // model_ui.cxx
      25             : 
      26             : 
      27             : #include "namedcollection.hxx"
      28             : #include "binding.hxx"
      29             : #include "submission.hxx"
      30             : #include "unohelper.hxx"
      31             : 
      32             : #include <com/sun/star/uno/Reference.hxx>
      33             : #include <com/sun/star/uno/Sequence.hxx>
      34             : #include <com/sun/star/lang/XUnoTunnel.hpp>
      35             : #include <com/sun/star/beans/XPropertySet.hpp>
      36             : #include <com/sun/star/beans/PropertyValue.hpp>
      37             : 
      38             : namespace xforms
      39             : {
      40             :     class Model;
      41             : }
      42             : 
      43             : 
      44             : // BindingCollection
      45             : 
      46             : 
      47             : namespace xforms
      48             : {
      49             : 
      50             : class BindingCollection : public NamedCollection<com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> >
      51             : {
      52             :     Model* mpModel;
      53             : 
      54             : public:
      55           1 :     BindingCollection( Model* pModel ) : mpModel( pModel ) {}
      56           2 :     virtual ~BindingCollection() {}
      57             : 
      58           0 :     virtual bool isValid( const T& t ) const SAL_OVERRIDE
      59             :     {
      60           0 :         return Binding::getBinding( t ) != NULL;
      61             :     }
      62             : 
      63             : protected:
      64           0 :     virtual void _insert( const T& t ) SAL_OVERRIDE
      65             :     {
      66             :         OSL_ENSURE( Binding::getBinding( t ) != NULL, "invalid item?" );
      67           0 :         Binding::getBinding( t )->_setModel( Binding::Model_t( mpModel ) );
      68           0 :     }
      69             : 
      70           0 :     virtual void _remove( const T& t ) SAL_OVERRIDE
      71             :     {
      72             :         OSL_ENSURE( Binding::getBinding( t ) != NULL, "invalid item?" );
      73           0 :         Binding::getBinding( t )->_setModel( Binding::Model_t() );
      74           0 :     }
      75             : };
      76             : 
      77             : class SubmissionCollection : public NamedCollection<com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> >
      78             : {
      79             :     Model* mpModel;
      80             : 
      81             : public:
      82           1 :     SubmissionCollection( Model* pModel ) : mpModel( pModel ) {}
      83           2 :     virtual ~SubmissionCollection() {}
      84             : 
      85             : public:
      86           0 :     virtual bool isValid( const T& t ) const SAL_OVERRIDE
      87             :     {
      88           0 :         return Submission::getSubmission( t ) != NULL;
      89             :     }
      90             : 
      91             : protected:
      92           0 :     virtual void _insert( const T& t ) SAL_OVERRIDE
      93             :     {
      94             :         OSL_ENSURE( Submission::getSubmission( t ) != NULL, "invalid item?" );
      95           0 :         Submission::getSubmission( t )->setModel( com::sun::star::uno::Reference<com::sun::star::xforms::XModel>( mpModel ) );
      96           0 :     }
      97             : 
      98           0 :     virtual void _remove( const T& t ) SAL_OVERRIDE
      99             :     {
     100             :         OSL_ENSURE( Submission::getSubmission( t ) != NULL, "invalid item?" );
     101           0 :         Submission::getSubmission( t )->setModel( com::sun::star::uno::Reference<com::sun::star::xforms::XModel>( ) );
     102           0 :     }
     103             : };
     104             : 
     105           3 : class InstanceCollection : public Collection<com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> >
     106             : {
     107             : public:
     108           0 :     virtual bool isValid( const T& t ) const SAL_OVERRIDE
     109             :     {
     110           0 :         const com::sun::star::beans::PropertyValue* pValues = t.getConstArray();
     111           0 :         OUString sInstance( "Instance" );
     112           0 :         bool bFound = false;
     113           0 :         for( sal_Int32 i = 0; ( ! bFound ) && ( i < t.getLength() ); i++ )
     114             :         {
     115           0 :             bFound |= ( pValues[i].Name == sInstance );
     116             :         }
     117           0 :         return bFound;
     118             :     }
     119             : };
     120             : 
     121             : 
     122             : 
     123             : // helper functions
     124             : 
     125             : 
     126             : sal_Int32 lcl_findInstance( const InstanceCollection*,
     127             :                             const OUString& );
     128             : 
     129             : 
     130             : // get values from Sequence<PropertyValue> describing an Instance
     131             : void getInstanceData(
     132             :     const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>&,
     133             :     OUString* pID,
     134             :     com::sun::star::uno::Reference<com::sun::star::xml::dom::XDocument>*,
     135             :     OUString* pURL,
     136             :     bool* pURLOnce );
     137             : 
     138             : // set values on Sequence<PropertyValue> for an Instance
     139             : void setInstanceData(
     140             :     com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>&,
     141             :     const OUString* pID,
     142             :     const com::sun::star::uno::Reference<com::sun::star::xml::dom::XDocument>*,
     143             :     const OUString* pURL,
     144             :     const bool* pURLOnce );
     145             : 
     146             : } // namespace xforms
     147             : 
     148             : #endif
     149             : 
     150             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11