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 .
22 // some helper definitions that must be available for model.cxx and
26 #include "namedcollection.hxx"
27 #include "binding.hxx"
28 #include "submission.hxx"
29 #include "unohelper.hxx"
31 #include <com/sun/star/uno/Reference.hxx>
32 #include <com/sun/star/uno/Sequence.hxx>
33 #include <com/sun/star/lang/XUnoTunnel.hpp>
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 #include <com/sun/star/beans/PropertyValue.hpp>
36 #include <comphelper/servicehelper.hxx>
50 class BindingCollection
: public NamedCollection
<css::uno::Reference
<css::beans::XPropertySet
> >
55 explicit BindingCollection( Model
* pModel
) : mpModel( pModel
) {}
57 virtual bool isValid( const T
& t
) const override
59 return comphelper::getFromUnoTunnel
<Binding
>( t
) != nullptr;
63 virtual void _insert( const T
& t
) override
65 auto pBinding
= comphelper::getFromUnoTunnel
<Binding
>( t
);
66 OSL_ENSURE( pBinding
!= nullptr, "invalid item?" );
67 pBinding
->_setModel( mpModel
);
70 virtual void _remove( const T
& t
) override
72 auto pBinding
= comphelper::getFromUnoTunnel
<Binding
>( t
);
73 OSL_ENSURE( pBinding
!= nullptr, "invalid item?" );
74 pBinding
->_setModel( nullptr );
78 class SubmissionCollection
: public NamedCollection
<css::uno::Reference
<css::beans::XPropertySet
> >
83 explicit SubmissionCollection( Model
* pModel
) : mpModel( pModel
) {}
85 virtual bool isValid( const T
& t
) const override
87 return dynamic_cast<Submission
*>( t
.get() ) != nullptr;
91 virtual void _insert( const T
& t
) override
93 auto pSubmission
= dynamic_cast<Submission
*>( t
.get() );
94 assert(pSubmission
&& "invalid item?");
95 pSubmission
->setModel( mpModel
);
98 virtual void _remove( const T
& t
) override
100 auto pSubmission
= dynamic_cast<Submission
*>( t
.get() );
101 assert(pSubmission
&& "invalid item?");
102 pSubmission
->setModel( nullptr );
106 class InstanceCollection
: public Collection
<css::uno::Sequence
<css::beans::PropertyValue
> >
109 virtual bool isValid( const T
& t
) const override
111 for( const css::beans::PropertyValue
& rProp
: t
)
113 if (rProp
.Name
== "Instance" )
124 sal_Int32
lcl_findInstance( const InstanceCollection
*,
125 std::u16string_view
);
128 // get values from Sequence<PropertyValue> describing an Instance
129 void getInstanceData(
130 const css::uno::Sequence
<css::beans::PropertyValue
>&,
132 css::uno::Reference
<css::xml::dom::XDocument
>*,
136 // set values on Sequence<PropertyValue> for an Instance
137 void setInstanceData(
138 css::uno::Sequence
<css::beans::PropertyValue
>&,
140 const css::uno::Reference
<css::xml::dom::XDocument
>*,
141 const OUString
* pURL
,
142 const bool* pURLOnce
);
144 } // namespace xforms
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */