nss: upgrade to release 3.73
[LibreOffice.git] / forms / source / xforms / model_helper.hxx
blob59056bf26e6285521f333f6a41a5262396c55a69
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
24 // model_ui.cxx
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>
39 namespace xforms
41 class Model;
45 // BindingCollection
48 namespace xforms
51 class BindingCollection : public NamedCollection<css::uno::Reference<css::beans::XPropertySet> >
53 Model* mpModel;
55 public:
56 explicit BindingCollection( Model* pModel ) : mpModel( pModel ) {}
58 virtual bool isValid( const T& t ) const override
60 return comphelper::getUnoTunnelImplementation<Binding>( t ) != nullptr;
63 protected:
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> >
81 Model* mpModel;
83 public:
84 explicit SubmissionCollection( Model* pModel ) : mpModel( pModel ) {}
86 virtual bool isValid( const T& t ) const override
88 return comphelper::getUnoTunnelImplementation<Submission>( t ) != nullptr;
91 protected:
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> >
109 public:
110 virtual bool isValid( const T& t ) const override
112 for( const css::beans::PropertyValue& rProp : t )
114 if (rProp.Name == "Instance" )
115 return true;
117 return false;
122 // helper functions
125 sal_Int32 lcl_findInstance( const InstanceCollection*,
126 const OUString& );
129 // get values from Sequence<PropertyValue> describing an Instance
130 void getInstanceData(
131 const css::uno::Sequence<css::beans::PropertyValue>&,
132 OUString* pID,
133 css::uno::Reference<css::xml::dom::XDocument>*,
134 OUString* pURL,
135 bool* pURLOnce );
137 // set values on Sequence<PropertyValue> for an Instance
138 void setInstanceData(
139 css::uno::Sequence<css::beans::PropertyValue>&,
140 const OUString* pID,
141 const css::uno::Reference<css::xml::dom::XDocument>*,
142 const OUString* pURL,
143 const bool* pURLOnce );
145 } // namespace xforms
147 #endif
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */