LCOV - code coverage report
Current view: top level - libreoffice/forms/source/xforms - model_helper.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 28 0.0 %
Date: 2012-12-17 Functions: 0 16 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             : #ifndef _MODEL_HELPER_HXX
      20             : #define _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           0 :     BindingCollection( Model* pModel ) : mpModel( pModel ) {}
      56           0 :     virtual ~BindingCollection() {}
      57             : 
      58           0 :     virtual bool isValid( const T& t ) const
      59             :     {
      60           0 :         return Binding::getBinding( t ) != NULL;
      61             :     }
      62             : 
      63             : protected:
      64           0 :     virtual void _insert( const T& t )
      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 )
      71             :     {
      72             :         OSL_ENSURE( Binding::getBinding( t ) != NULL, "invalid item?" );
      73           0 :         Binding::getBinding( t )->_setModel( Binding::Model_t() );
      74           0 :     }
      75             : };
      76             : 
      77             : 
      78             : 
      79             : //
      80             : // SubmissionCollection
      81             : //
      82             : 
      83             : class SubmissionCollection : public NamedCollection<com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> >
      84             : {
      85             :     Model* mpModel;
      86             : 
      87             : public:
      88           0 :     SubmissionCollection( Model* pModel ) : mpModel( pModel ) {}
      89           0 :     virtual ~SubmissionCollection() {}
      90             : 
      91             : public:
      92           0 :     virtual bool isValid( const T& t ) const
      93             :     {
      94           0 :         return Submission::getSubmission( t ) != NULL;
      95             :     }
      96             : 
      97             : protected:
      98           0 :     virtual void _insert( const T& t )
      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>( mpModel ) );
     102           0 :     }
     103             : 
     104           0 :     virtual void _remove( const T& t )
     105             :     {
     106             :         OSL_ENSURE( Submission::getSubmission( t ) != NULL, "invalid item?" );
     107           0 :         Submission::getSubmission( t )->setModel( com::sun::star::uno::Reference<com::sun::star::xforms::XModel>( ) );
     108           0 :     }
     109             : };
     110             : 
     111             : 
     112             : //
     113             : // InstanceCollection
     114             : //
     115             : 
     116           0 : class InstanceCollection : public Collection<com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> >
     117             : {
     118             : public:
     119           0 :     virtual bool isValid( const T& t ) const
     120             :     {
     121           0 :         const com::sun::star::beans::PropertyValue* pValues = t.getConstArray();
     122           0 :         rtl::OUString sInstance( OUSTRING("Instance") );
     123           0 :         sal_Bool bFound = sal_False;
     124           0 :         for( sal_Int32 i = 0; ( ! bFound ) && ( i < t.getLength() ); i++ )
     125             :         {
     126           0 :             bFound |= ( pValues[i].Name == sInstance );
     127             :         }
     128           0 :         return bFound ? true : false;
     129             :     }
     130             : };
     131             : 
     132             : 
     133             : //
     134             : // helper functions
     135             : //
     136             : 
     137             : sal_Int32 lcl_findInstance( const InstanceCollection*,
     138             :                             const rtl::OUString& );
     139             : 
     140             : 
     141             : // get values from Sequence<PropertyValue> describing an Instance
     142             : void getInstanceData(
     143             :     const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>&,
     144             :     rtl::OUString* pID,
     145             :     com::sun::star::uno::Reference<com::sun::star::xml::dom::XDocument>*,
     146             :     rtl::OUString* pURL,
     147             :     bool* pURLOnce );
     148             : 
     149             : // set values on Sequence<PropertyValue> for an Instance
     150             : void setInstanceData(
     151             :     com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>&,
     152             :     const rtl::OUString* pID,
     153             :     const com::sun::star::uno::Reference<com::sun::star::xml::dom::XDocument>*,
     154             :     const rtl::OUString* pURL,
     155             :     const bool* pURLOnce );
     156             : 
     157             : } // namespace xforms
     158             : 
     159             : #endif
     160             : 
     161             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10