1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_FORMS_SOURCE_XFORMS_MODEL_HXX
#define INCLUDED_FORMS_SOURCE_XFORMS_MODEL_HXX
#include <cppuhelper/implbase.hxx>
#include <propertysetbase.hxx>
#include <com/sun/star/xforms/XModel2.hpp>
#include <com/sun/star/xforms/XFormsUIHelper1.hpp>
#include <com/sun/star/util/XUpdatable.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include "mip.hxx"
#include <map>
// forward declaractions
namespace com { namespace sun { namespace star
{
namespace xml { namespace dom { class XDocument; } }
namespace xml { namespace dom { class XNode; } }
namespace uno { template<typename T> class Sequence; }
namespace lang { class IndexOutOfBoundsException; }
namespace lang { class IllegalArgumentException; }
namespace beans { class XPropertySet; }
namespace container { class XSet; }
namespace container { class XNameContainer; }
namespace frame { class XModel; }
} } }
namespace xforms
{
class BindingCollection;
class SubmissionCollection;
class InstanceCollection;
class EvaluationContext;
}
namespace xforms
{
/** An XForms Model. Contains:
* # (set of) instance data (XML DOM tree)
* # (set of) bindings
* # (set of) submissions
* # (NOT YET IMPLEMENTED) actions (set of)
*
* See http://www.w3.org/TR/xforms/ for more information.
*/
typedef cppu::ImplInheritanceHelper<
PropertySetBase,
com::sun::star::xforms::XModel2,
com::sun::star::xforms::XFormsUIHelper1,
com::sun::star::util::XUpdatable,
com::sun::star::lang::XUnoTunnel,
css::lang::XServiceInfo
> Model_t;
class Model : public Model_t
{
// a number of local typedefs, to make the remaining header readable
typedef com::sun::star::uno::Reference<com::sun::star::xml::dom::XDocument> XDocument_t;
typedef com::sun::star::uno::Reference<com::sun::star::xml::dom::XNode> XNode_t;
typedef com::sun::star::lang::IndexOutOfBoundsException IndexOutOfBoundsException_t;
typedef com::sun::star::lang::IllegalArgumentException IllegalArgumentException_t;
typedef com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> XPropertySet_t;
typedef com::sun::star::uno::Reference<com::sun::star::xforms::XDataTypeRepository> XDataTypeRepository_t;
typedef com::sun::star::uno::Reference<com::sun::star::container::XNameContainer> XNameContainer_t;
typedef com::sun::star::uno::Reference<com::sun::star::xforms::XSubmission> XSubmission_t;
typedef com::sun::star::uno::Reference<com::sun::star::frame::XModel> Frame_XModel_t;
typedef com::sun::star::uno::Reference<com::sun::star::xforms::XModel> XModel_t;
typedef com::sun::star::uno::Reference<com::sun::star::task::XInteractionHandler> XInteractionHandler_t;
typedef com::sun::star::uno::Reference<com::sun::star::container::XSet> XSet_t;
typedef com::sun::star::beans::PropertyVetoException PropertyVetoException_t;
typedef com::sun::star::beans::UnknownPropertyException UnknownPropertyException_t;
typedef com::sun::star::util::VetoException VetoException_t;
typedef com::sun::star::lang::WrappedTargetException WrappedTargetException_t;
typedef com::sun::star::uno::RuntimeException RuntimeException_t;
typedef com::sun::star::uno::Any Any_t;
typedef com::sun::star::uno::Sequence<sal_Int8> IntSequence_t;
typedef std::multimap<XNode_t,std::pair<void*,MIP> > MIPs_t;
private:
OUString msID; /// the model ID
BindingCollection* mpBindings; /// the bindings
SubmissionCollection* mpSubmissions; /// the submissions
InstanceCollection* mpInstances; /// the instance(s)
XDataTypeRepository_t mxDataTypes; /// the XSD data-types used
XDocument_t mxForeignSchema; /// the XSD-schema part we cannot
/// map onto data types
OUString msSchemaRef; /// xforms:model/@schema attribute
XNameContainer_t mxNamespaces; /// namespaces for entire model
// references to mpBindings/mpSubmissions, for UNO reference counting
XSet_t mxBindings;
XSet_t mxSubmissions;
XSet_t mxInstances;
MIPs_t maMIPs; /// map nodes to their MIPs
bool mbInitialized; /// has model been initialized ?
bool mbExternalData; /// is the data of this model to be considered an ingegral part of the document?
void initializePropertySet();
void ensureAtLeastOneInstance();
public:
/// create a new model with an empty, default instance
Model();
virtual ~Model() throw();
// get Model implementation from API object
static Model* getModel( const com::sun::star::uno::Reference<com::sun::star::xforms::XModel>& );
xforms::EvaluationContext getEvaluationContext();
static IntSequence_t getUnoTunnelID();
// get/set that part of the schema, that we can't interpret as data types
XDocument_t getForeignSchema() const { return mxForeignSchema;}
void setForeignSchema( const XDocument_t& );
// get/set the xforms:model/@schema attribute
OUString getSchemaRef() const { return msSchemaRef;}
void setSchemaRef( const OUString& );
// get/set namespaces for entire model
XNameContainer_t getNamespaces() const { return mxNamespaces;}
void setNamespaces( const XNameContainer_t& );
// get/set the ExternalData property
bool getExternalData() const { return mbExternalData;}
void setExternalData( bool _bData );
#if OSL_DEBUG_LEVEL > 1
void dbg_assertInvariant() const;
#endif
// MIP (model item property) management
// register MIPs which apply to a given node; only to be called by bindings
// (The pTag parameter serves only to be able to remove the MIPs
// that were added using the same tag. No functions will be
// performed on it; hence the void* type.)
void addMIP( void* pTag, const XNode_t&, const MIP& );
void removeMIPs( void* pTag );
/// query which MIPs appy to the given node
MIP queryMIP( const XNode_t& xNode ) const;
/// re-bind all bindings
void rebind();
/// call defer notifications on all bindings
void deferNotifications( bool );
/// set a data value in the instance
/// (also defers notifications)
bool setSimpleContent( const XNode_t&, const OUString& );
/// load instance data
void loadInstance( sal_Int32 nInstance );
void loadInstances();
/// has model been initialized?
bool isInitialized() const { return mbInitialized;}
/// is model currently valid (for submission)?
bool isValid() const;
// XModel
// implement the xforms::XModel implementation
virtual OUString SAL_CALL getID()
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual void SAL_CALL setID( const OUString& sID )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual void SAL_CALL initialize()
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual void SAL_CALL rebuild()
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual void SAL_CALL recalculate()
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual void SAL_CALL revalidate()
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual void SAL_CALL refresh()
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual void SAL_CALL submit( const OUString& sID )
throw( VetoException_t, WrappedTargetException_t, RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual void SAL_CALL submitWithInteraction( const OUString& id, const XInteractionHandler_t& _rxHandler )
throw( VetoException_t, WrappedTargetException_t, RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual XDataTypeRepository_t SAL_CALL getDataTypeRepository( )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
// XModel: instance management
virtual XSet_t SAL_CALL getInstances()
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual XDocument_t SAL_CALL getInstanceDocument( const OUString& )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual XDocument_t SAL_CALL getDefaultInstance()
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
// XModel: binding management
virtual XPropertySet_t SAL_CALL createBinding()
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual XPropertySet_t SAL_CALL cloneBinding( const XPropertySet_t& )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual XPropertySet_t SAL_CALL getBinding( const OUString& )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual XSet_t SAL_CALL getBindings()
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
// XModel: submission management
virtual XSubmission_t SAL_CALL createSubmission()
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual XSubmission_t SAL_CALL cloneSubmission( const XPropertySet_t& )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual XSubmission_t SAL_CALL getSubmission( const OUString& )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual XSet_t SAL_CALL getSubmissions()
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
// XPropertySet
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& p)
throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE
{ return PropertySetBase::getPropertyValue(p); }
virtual void SAL_CALL addPropertyChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XPropertyChangeListener>& p2)
throw (css::beans::UnknownPropertyException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE
{ PropertySetBase::addPropertyChangeListener(p1, p2); }
virtual void SAL_CALL removePropertyChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XPropertyChangeListener>& p2)
throw (css::beans::UnknownPropertyException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE
{ PropertySetBase::removePropertyChangeListener(p1, p2); }
virtual void SAL_CALL addVetoableChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XVetoableChangeListener>& p2)
throw (css::beans::UnknownPropertyException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE
{ PropertySetBase::addVetoableChangeListener(p1, p2); }
virtual void SAL_CALL removeVetoableChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XVetoableChangeListener>& p2)
throw( css::beans::UnknownPropertyException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE
{ PropertySetBase::removeVetoableChangeListener(p1, p2); }
virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo()
throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE
{ return PropertySetBase::getPropertySetInfo(); }
virtual void SAL_CALL setPropertyValue(const OUString& p1, const com::sun::star::uno::Any& p2)
throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE
{ PropertySetBase::setPropertyValue(p1, p2); }
// XFormsUIHelper1 & friends:
// (implementation in model_ui.cxx)
/// determine a reasonable control service for a given node
/// (based on data type MIP assigned to the node)
virtual OUString SAL_CALL getDefaultServiceNameForNode( const XNode_t& xNode ) throw (RuntimeException_t, std::exception) SAL_OVERRIDE;
/// call getDefaultBindingExpressionForNode with default evaluation context
virtual OUString SAL_CALL getDefaultBindingExpressionForNode( const XNode_t& xNode ) throw (RuntimeException_t, std::exception) SAL_OVERRIDE;
/// determine a reasonable default binding expression for a given node
/// and a given evaluation context
/// @returns expression, or empty string if no expression could be derived
OUString getDefaultBindingExpressionForNode(
const XNode_t&,
const EvaluationContext& );
virtual OUString SAL_CALL getNodeDisplayName( const XNode_t&,
sal_Bool bDetail )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual OUString SAL_CALL getNodeName( const XNode_t& )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual OUString SAL_CALL getBindingName( const XPropertySet_t&,
sal_Bool bDetail )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual OUString SAL_CALL getSubmissionName( const XPropertySet_t&,
sal_Bool bDetail )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual XPropertySet_t SAL_CALL cloneBindingAsGhost( const XPropertySet_t& )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual void SAL_CALL removeBindingIfUseless( const XPropertySet_t& )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual XDocument_t SAL_CALL newInstance( const OUString& sName,
const OUString& sURL,
sal_Bool bURLOnce )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual void SAL_CALL renameInstance( const OUString& sFrom,
const OUString& sTo,
const OUString& sURL,
sal_Bool bURLOnce )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual void SAL_CALL removeInstance( const OUString& sName )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual XModel_t SAL_CALL newModel( const Frame_XModel_t& xComponent,
const OUString& sName )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual void SAL_CALL renameModel( const Frame_XModel_t& xComponent,
const OUString& sFrom,
const OUString& sTo )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual void SAL_CALL removeModel( const Frame_XModel_t& xComponent,
const OUString& sName )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual XNode_t SAL_CALL createElement( const XNode_t& xParent,
const OUString& sName )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual XNode_t SAL_CALL createAttribute( const XNode_t& xParent,
const OUString& sName )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual XNode_t SAL_CALL renameNode( const XNode_t& xNode,
const OUString& sName )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual XPropertySet_t SAL_CALL getBindingForNode( const XNode_t&,
sal_Bool bCreate )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual void SAL_CALL removeBindingForNode( const XNode_t& )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual OUString SAL_CALL getResultForExpression(
const XPropertySet_t& xBinding,
sal_Bool bIsBindingExpression,
const OUString& sExpression )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual sal_Bool SAL_CALL isValidXMLName( const OUString& sName )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual sal_Bool SAL_CALL isValidPrefixName( const OUString& sName )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
virtual void SAL_CALL setNodeValue(
const XNode_t& xNode,
const OUString& sValue )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
// XUpdatable
public:
virtual void SAL_CALL update()
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
// XUnoTunnel
public:
virtual sal_Int64 SAL_CALL getSomething( const IntSequence_t& )
throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
// XTypeProvider::getImplementationId
public:
virtual IntSequence_t SAL_CALL getImplementationId()
throw( RuntimeException_t ) SAL_OVERRIDE;
OUString SAL_CALL getImplementationName()
throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
};
} // namespace
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|