2010-10-27 12:45:03 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-21 14:30:25 +01:00
|
|
|
/*
|
|
|
|
* 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 .
|
|
|
|
*/
|
2013-11-05 02:31:05 +01:00
|
|
|
#ifndef INCLUDED_FORMS_SOURCE_XFORMS_MODEL_HELPER_HXX
|
|
|
|
#define INCLUDED_FORMS_SOURCE_XFORMS_MODEL_HELPER_HXX
|
2004-11-16 09:54:22 +00:00
|
|
|
|
2014-02-25 18:50:02 +01:00
|
|
|
|
2004-11-16 09:54:22 +00:00
|
|
|
// some helper definitions that must be available for model.cxx and
|
|
|
|
// model_ui.cxx
|
2014-02-25 18:50:02 +01:00
|
|
|
|
2004-11-16 09:54:22 +00:00
|
|
|
|
|
|
|
#include "namedcollection.hxx"
|
|
|
|
#include "binding.hxx"
|
|
|
|
#include "submission.hxx"
|
|
|
|
#include "unohelper.hxx"
|
|
|
|
|
|
|
|
#include <com/sun/star/uno/Reference.hxx>
|
|
|
|
#include <com/sun/star/uno/Sequence.hxx>
|
|
|
|
#include <com/sun/star/lang/XUnoTunnel.hpp>
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
|
|
|
#include <com/sun/star/beans/PropertyValue.hpp>
|
|
|
|
|
|
|
|
namespace xforms
|
|
|
|
{
|
|
|
|
class Model;
|
|
|
|
}
|
|
|
|
|
2014-02-25 18:50:02 +01:00
|
|
|
|
2004-11-16 09:54:22 +00:00
|
|
|
// BindingCollection
|
2014-02-25 18:50:02 +01:00
|
|
|
|
2004-11-16 09:54:22 +00:00
|
|
|
|
|
|
|
namespace xforms
|
|
|
|
{
|
|
|
|
|
2015-10-01 15:32:00 +02:00
|
|
|
class BindingCollection : public NamedCollection<css::uno::Reference<css::beans::XPropertySet> >
|
2004-11-16 09:54:22 +00:00
|
|
|
{
|
|
|
|
Model* mpModel;
|
|
|
|
|
|
|
|
public:
|
2015-10-07 14:36:11 +01:00
|
|
|
explicit BindingCollection( Model* pModel ) : mpModel( pModel ) {}
|
2004-11-16 09:54:22 +00:00
|
|
|
|
2015-10-12 16:04:04 +02:00
|
|
|
virtual bool isValid( const T& t ) const override
|
2004-11-16 09:54:22 +00:00
|
|
|
{
|
2015-11-10 10:15:45 +01:00
|
|
|
return Binding::getBinding( t ) != nullptr;
|
2004-11-16 09:54:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2015-10-12 16:04:04 +02:00
|
|
|
virtual void _insert( const T& t ) override
|
2004-11-16 09:54:22 +00:00
|
|
|
{
|
2015-11-10 10:15:45 +01:00
|
|
|
OSL_ENSURE( Binding::getBinding( t ) != nullptr, "invalid item?" );
|
2015-06-30 14:35:23 +02:00
|
|
|
Binding::getBinding( t )->_setModel( css::uno::Reference<css::xforms::XModel>( mpModel ) );
|
2004-11-16 09:54:22 +00:00
|
|
|
}
|
|
|
|
|
2015-10-12 16:04:04 +02:00
|
|
|
virtual void _remove( const T& t ) override
|
2004-11-16 09:54:22 +00:00
|
|
|
{
|
2015-11-10 10:15:45 +01:00
|
|
|
OSL_ENSURE( Binding::getBinding( t ) != nullptr, "invalid item?" );
|
2015-06-30 14:35:23 +02:00
|
|
|
Binding::getBinding( t )->_setModel( css::uno::Reference<css::xforms::XModel>() );
|
2004-11-16 09:54:22 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-10-01 15:32:00 +02:00
|
|
|
class SubmissionCollection : public NamedCollection<css::uno::Reference<css::beans::XPropertySet> >
|
2004-11-16 09:54:22 +00:00
|
|
|
{
|
|
|
|
Model* mpModel;
|
|
|
|
|
|
|
|
public:
|
2015-10-07 14:36:11 +01:00
|
|
|
explicit SubmissionCollection( Model* pModel ) : mpModel( pModel ) {}
|
2004-11-16 09:54:22 +00:00
|
|
|
|
2015-10-12 16:04:04 +02:00
|
|
|
virtual bool isValid( const T& t ) const override
|
2004-11-16 09:54:22 +00:00
|
|
|
{
|
2015-11-10 10:15:45 +01:00
|
|
|
return Submission::getSubmission( t ) != nullptr;
|
2004-11-16 09:54:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2015-10-12 16:04:04 +02:00
|
|
|
virtual void _insert( const T& t ) override
|
2004-11-16 09:54:22 +00:00
|
|
|
{
|
2015-11-10 10:15:45 +01:00
|
|
|
OSL_ENSURE( Submission::getSubmission( t ) != nullptr, "invalid item?" );
|
2015-10-01 15:32:00 +02:00
|
|
|
Submission::getSubmission( t )->setModel( css::uno::Reference<css::xforms::XModel>( mpModel ) );
|
2004-11-16 09:54:22 +00:00
|
|
|
}
|
|
|
|
|
2015-10-12 16:04:04 +02:00
|
|
|
virtual void _remove( const T& t ) override
|
2004-11-16 09:54:22 +00:00
|
|
|
{
|
2015-11-10 10:15:45 +01:00
|
|
|
OSL_ENSURE( Submission::getSubmission( t ) != nullptr, "invalid item?" );
|
2015-10-01 15:32:00 +02:00
|
|
|
Submission::getSubmission( t )->setModel( css::uno::Reference<css::xforms::XModel>( ) );
|
2004-11-16 09:54:22 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-10-01 15:32:00 +02:00
|
|
|
class InstanceCollection : public Collection<css::uno::Sequence<css::beans::PropertyValue> >
|
2004-11-16 09:54:22 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-10-12 16:04:04 +02:00
|
|
|
virtual bool isValid( const T& t ) const override
|
2004-11-16 09:54:22 +00:00
|
|
|
{
|
2015-10-01 15:32:00 +02:00
|
|
|
const css::beans::PropertyValue* pValues = t.getConstArray();
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sInstance( "Instance" );
|
2014-01-23 18:43:53 +01:00
|
|
|
bool bFound = false;
|
2004-11-16 09:54:22 +00:00
|
|
|
for( sal_Int32 i = 0; ( ! bFound ) && ( i < t.getLength() ); i++ )
|
|
|
|
{
|
|
|
|
bFound |= ( pValues[i].Name == sInstance );
|
|
|
|
}
|
2014-01-23 18:43:53 +01:00
|
|
|
return bFound;
|
2004-11-16 09:54:22 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// helper functions
|
2014-02-25 18:50:02 +01:00
|
|
|
|
2004-11-16 09:54:22 +00:00
|
|
|
|
|
|
|
sal_Int32 lcl_findInstance( const InstanceCollection*,
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString& );
|
2004-11-16 09:54:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
// get values from Sequence<PropertyValue> describing an Instance
|
|
|
|
void getInstanceData(
|
2015-10-01 15:32:00 +02:00
|
|
|
const css::uno::Sequence<css::beans::PropertyValue>&,
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString* pID,
|
2015-10-01 15:32:00 +02:00
|
|
|
css::uno::Reference<css::xml::dom::XDocument>*,
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString* pURL,
|
2004-11-16 09:54:22 +00:00
|
|
|
bool* pURLOnce );
|
|
|
|
|
|
|
|
// set values on Sequence<PropertyValue> for an Instance
|
|
|
|
void setInstanceData(
|
2015-10-01 15:32:00 +02:00
|
|
|
css::uno::Sequence<css::beans::PropertyValue>&,
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString* pID,
|
2015-10-01 15:32:00 +02:00
|
|
|
const css::uno::Reference<css::xml::dom::XDocument>*,
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString* pURL,
|
2004-11-16 09:54:22 +00:00
|
|
|
const bool* pURLOnce );
|
|
|
|
|
|
|
|
} // namespace xforms
|
|
|
|
|
|
|
|
#endif
|
2010-10-27 12:45:03 +01:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|