1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_FORMS_SOURCE_XFORMS_MODEL_HELPER_HXX
20 #define INCLUDED_FORMS_SOURCE_XFORMS_MODEL_HELPER_HXX
23 // some helper definitions that must be available for model.cxx and
27 #include "namedcollection.hxx"
28 #include "binding.hxx"
29 #include "submission.hxx"
30 #include "unohelper.hxx"
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>
50 class BindingCollection
: public NamedCollection
<com::sun::star::uno::Reference
<com::sun::star::beans::XPropertySet
> >
55 BindingCollection( Model
* pModel
) : mpModel( pModel
) {}
56 virtual ~BindingCollection() {}
58 virtual bool isValid( const T
& t
) const SAL_OVERRIDE
60 return Binding::getBinding( t
) != NULL
;
64 virtual void _insert( const T
& t
) SAL_OVERRIDE
66 OSL_ENSURE( Binding::getBinding( t
) != NULL
, "invalid item?" );
67 Binding::getBinding( t
)->_setModel( Binding::Model_t( mpModel
) );
70 virtual void _remove( const T
& t
) SAL_OVERRIDE
72 OSL_ENSURE( Binding::getBinding( t
) != NULL
, "invalid item?" );
73 Binding::getBinding( t
)->_setModel( Binding::Model_t() );
77 class SubmissionCollection
: public NamedCollection
<com::sun::star::uno::Reference
<com::sun::star::beans::XPropertySet
> >
82 SubmissionCollection( Model
* pModel
) : mpModel( pModel
) {}
83 virtual ~SubmissionCollection() {}
86 virtual bool isValid( const T
& t
) const SAL_OVERRIDE
88 return Submission::getSubmission( t
) != NULL
;
92 virtual void _insert( const T
& t
) SAL_OVERRIDE
94 OSL_ENSURE( Submission::getSubmission( t
) != NULL
, "invalid item?" );
95 Submission::getSubmission( t
)->setModel( com::sun::star::uno::Reference
<com::sun::star::xforms::XModel
>( mpModel
) );
98 virtual void _remove( const T
& t
) SAL_OVERRIDE
100 OSL_ENSURE( Submission::getSubmission( t
) != NULL
, "invalid item?" );
101 Submission::getSubmission( t
)->setModel( com::sun::star::uno::Reference
<com::sun::star::xforms::XModel
>( ) );
105 class InstanceCollection
: public Collection
<com::sun::star::uno::Sequence
<com::sun::star::beans::PropertyValue
> >
108 virtual bool isValid( const T
& t
) const SAL_OVERRIDE
110 const com::sun::star::beans::PropertyValue
* pValues
= t
.getConstArray();
111 OUString
sInstance( "Instance" );
113 for( sal_Int32 i
= 0; ( ! bFound
) && ( i
< t
.getLength() ); i
++ )
115 bFound
|= ( pValues
[i
].Name
== sInstance
);
126 sal_Int32
lcl_findInstance( const InstanceCollection
*,
130 // get values from Sequence<PropertyValue> describing an Instance
131 void getInstanceData(
132 const com::sun::star::uno::Sequence
<com::sun::star::beans::PropertyValue
>&,
134 com::sun::star::uno::Reference
<com::sun::star::xml::dom::XDocument
>*,
138 // set values on Sequence<PropertyValue> for an Instance
139 void setInstanceData(
140 com::sun::star::uno::Sequence
<com::sun::star::beans::PropertyValue
>&,
142 const com::sun::star::uno::Reference
<com::sun::star::xml::dom::XDocument
>*,
143 const OUString
* pURL
,
144 const bool* pURLOnce
);
146 } // namespace xforms
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */