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>
37 #include <comphelper/servicehelper.hxx>
51 class BindingCollection
: public NamedCollection
<css::uno::Reference
<css::beans::XPropertySet
> >
56 explicit BindingCollection( Model
* pModel
) : mpModel( pModel
) {}
58 virtual bool isValid( const T
& t
) const override
60 return comphelper::getUnoTunnelImplementation
<Binding
>( t
) != nullptr;
64 virtual void _insert( const T
& t
) override
66 auto pBinding
= comphelper::getUnoTunnelImplementation
<Binding
>( t
);
67 OSL_ENSURE( pBinding
!= nullptr, "invalid item?" );
68 pBinding
->_setModel( css::uno::Reference
<css::xforms::XModel
>( mpModel
) );
71 virtual void _remove( const T
& t
) override
73 auto pBinding
= comphelper::getUnoTunnelImplementation
<Binding
>( t
);
74 OSL_ENSURE( pBinding
!= nullptr, "invalid item?" );
75 pBinding
->_setModel( css::uno::Reference
<css::xforms::XModel
>() );
79 class SubmissionCollection
: public NamedCollection
<css::uno::Reference
<css::beans::XPropertySet
> >
84 explicit SubmissionCollection( Model
* pModel
) : mpModel( pModel
) {}
86 virtual bool isValid( const T
& t
) const override
88 return comphelper::getUnoTunnelImplementation
<Submission
>( t
) != nullptr;
92 virtual void _insert( const T
& t
) override
94 auto pSubmission
= comphelper::getUnoTunnelImplementation
<Submission
>( t
);
95 OSL_ENSURE( pSubmission
!= nullptr, "invalid item?" );
96 pSubmission
->setModel( css::uno::Reference
<css::xforms::XModel
>( mpModel
) );
99 virtual void _remove( const T
& t
) override
101 auto pSubmission
= comphelper::getUnoTunnelImplementation
<Submission
>( t
);
102 OSL_ENSURE( pSubmission
!= nullptr, "invalid item?" );
103 pSubmission
->setModel( css::uno::Reference
<css::xforms::XModel
>( ) );
107 class InstanceCollection
: public Collection
<css::uno::Sequence
<css::beans::PropertyValue
> >
110 virtual bool isValid( const T
& t
) const override
112 for( const css::beans::PropertyValue
& rProp
: t
)
114 if (rProp
.Name
== "Instance" )
125 sal_Int32
lcl_findInstance( const InstanceCollection
*,
129 // get values from Sequence<PropertyValue> describing an Instance
130 void getInstanceData(
131 const css::uno::Sequence
<css::beans::PropertyValue
>&,
133 css::uno::Reference
<css::xml::dom::XDocument
>*,
137 // set values on Sequence<PropertyValue> for an Instance
138 void setInstanceData(
139 css::uno::Sequence
<css::beans::PropertyValue
>&,
141 const css::uno::Reference
<css::xml::dom::XDocument
>*,
142 const OUString
* pURL
,
143 const bool* pURLOnce
);
145 } // namespace xforms
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */