Kaydet (Commit) b313e37a authored tarafından Noel Grandin's avatar Noel Grandin

fdo#46808, convert xforms::Model to new style

the service already existed, it just needed an IDL file.

Change-Id: Id8f33183d9332f9defd855b3a3c7413fde24a61b
üst fb0f7c24
......@@ -22,7 +22,7 @@
#include <cppuhelper/implbase4.hxx>
#include <propertysetbase.hxx>
#include <com/sun/star/xforms/XModel.hpp>
#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/XUnoTunnel.hpp>
......@@ -68,7 +68,7 @@ namespace xforms
*/
typedef cppu::ImplInheritanceHelper4<
PropertySetBase,
com::sun::star::xforms::XModel,
com::sun::star::xforms::XModel2,
com::sun::star::xforms::XFormsUIHelper1,
com::sun::star::util::XUpdatable,
com::sun::star::lang::XUnoTunnel
......@@ -281,7 +281,35 @@ public:
virtual XSet_t SAL_CALL getSubmissions()
throw( RuntimeException_t );
// XPropertySet
virtual css::uno::Any SAL_CALL getPropertyValue(const rtl::OUString& p)
throw( css::uno::RuntimeException )
{ return PropertySetBase::getPropertyValue(p); }
virtual void SAL_CALL addPropertyChangeListener(const rtl::OUString& p1, const css::uno::Reference<css::beans::XPropertyChangeListener>& p2)
throw( css::uno::RuntimeException )
{ PropertySetBase::addPropertyChangeListener(p1, p2); }
virtual void SAL_CALL removePropertyChangeListener(const rtl::OUString& p1, const css::uno::Reference<css::beans::XPropertyChangeListener>& p2)
throw( css::uno::RuntimeException )
{ PropertySetBase::removePropertyChangeListener(p1, p2); }
virtual void SAL_CALL addVetoableChangeListener(const rtl::OUString& p1, const css::uno::Reference<css::beans::XVetoableChangeListener>& p2)
throw( css::uno::RuntimeException )
{ PropertySetBase::addVetoableChangeListener(p1, p2); }
virtual void SAL_CALL removeVetoableChangeListener(const rtl::OUString& p1, const css::uno::Reference<css::beans::XVetoableChangeListener>& p2)
throw( css::uno::RuntimeException )
{ PropertySetBase::removeVetoableChangeListener(p1, p2); }
virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo()
throw( css::uno::RuntimeException )
{ return PropertySetBase::getPropertySetInfo(); }
virtual void SAL_CALL setPropertyValue(const rtl::OUString& p1, const com::sun::star::uno::Any& p2)
throw( css::uno::RuntimeException )
{ PropertySetBase::setPropertyValue(p1, p2); }
//
// XFormsUIHelper1 & friends:
......
......@@ -46,7 +46,7 @@ Reference<XInterface> Model_CreateInstance(
const Reference<XMultiServiceFactory>& )
throw( RuntimeException )
{
return static_cast<XPropertySet*>( new xforms::Model );
return static_cast<XPropertySet*>( static_cast<PropertySetBase*>( new xforms::Model ) );
}
Reference<XInterface> XForms_CreateInstance(
......
......@@ -366,6 +366,9 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/util,\
UriAbbreviation \
URLTransformer \
))
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/xforms,\
Model \
))
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/xml/crypto,\
NSSInitializer \
SEInitializer \
......@@ -4072,6 +4075,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/xforms,\
XFormsSupplier \
XFormsUIHelper1 \
XModel \
XModel2 \
XSubmission \
))
$(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/xml,\
......
/* -*- 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 __com_sun_star_xforms_Model_idl__
#define __com_sun_star_xforms_Model_idl__
#include <com/sun/star/xforms/XModel2.idl>
module com { module sun { module star { module xforms {
/**
@since LibreOffice 4.1
*/
service Model : XModel2;
}; }; }; };
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 __com_sun_star_xforms_XModel2_idl__
#define __com_sun_star_xforms_XModel2_idl__
#include <com/sun/star/xforms/XModel.idl>
module com { module sun { module star { module xforms {
/**
@since LibreOffice 4.1
*/
interface XModel2
{
interface com::sun::star::xforms::XModel;
interface com::sun::star::beans::XPropertySet;
};
}; }; }; };
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -23,7 +23,8 @@
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/frame/XModule.hpp>
#include <com/sun/star/xforms/XModel.hpp>
#include <com/sun/star/xforms/Model.hpp>
#include <com/sun/star/xforms/XModel2.hpp>
#include <com/sun/star/xforms/XFormsUIHelper1.hpp>
#include <comphelper/processfactory.hxx>
#include <tools/diagnose_ex.h>
......@@ -37,7 +38,7 @@ using uno::UNO_QUERY;
using uno::makeAny;
using uno::Exception;
using container::XNameContainer;
using xforms::XModel;
using xforms::XModel2;
using frame::XModule;
using xforms::XFormsUIHelper1;
using ::rtl::OUString;
......@@ -84,19 +85,13 @@ void SwDoc::initXForms( bool bCreateDefaultModel )
if( bCreateDefaultModel && mxXForms.is() )
{
OUString sName("Model 1");
Reference<XModel> xModel(
lcl_createInstance( "com.sun.star.xforms.Model" ),
UNO_QUERY );
OSL_ENSURE( xModel.is(), "no model?" );
if( xModel.is() )
{
xModel->setID( sName );
Reference<XFormsUIHelper1>( xModel, UNO_QUERY )->newInstance(
OUString("Instance 1"),
OUString(), sal_True );
xModel->initialize();
mxXForms->insertByName( sName, makeAny( xModel ) );
}
Reference<XModel2> xModel = xforms::Model::create( comphelper::getProcessComponentContext() );
xModel->setID( sName );
Reference<XFormsUIHelper1>( xModel, uno::UNO_QUERY_THROW )->newInstance(
OUString("Instance 1"),
OUString(), sal_True );
xModel->initialize();
mxXForms->insertByName( sName, makeAny( xModel ) );
OSL_ENSURE( mxXForms->hasElements(), "can't create XForms model" );
}
......
......@@ -30,7 +30,7 @@
#include <xmloff/nmspmap.hxx>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/xforms/XModel.hpp>
#include <com/sun/star/xforms/XModel2.hpp>
#include <tools/debug.hxx>
......@@ -42,7 +42,7 @@ using com::sun::star::uno::UNO_QUERY;
using com::sun::star::uno::UNO_QUERY_THROW;
using com::sun::star::container::XNameContainer;
using com::sun::star::xml::sax::XAttributeList;
using com::sun::star::xforms::XModel;
using com::sun::star::xforms::XModel2;
using namespace xmloff::token;
......@@ -69,9 +69,9 @@ XFormsBindContext::XFormsBindContext(
SvXMLImport& rImport,
sal_uInt16 nPrefix,
const OUString& rLocalName,
const Reference<XPropertySet>& xModel ) :
const Reference<XModel2>& xModel ) :
TokenContext( rImport, nPrefix, rLocalName, aAttributeMap, aEmptyMap ),
mxModel( xModel, UNO_QUERY_THROW ),
mxModel( xModel ),
mxBinding( NULL )
{
// attach binding to model
......
......@@ -31,7 +31,7 @@
namespace com { namespace sun { namespace star {
namespace xml { namespace sax { class XAttributeList; } }
namespace beans { class XPropertySet; }
namespace xforms { class XModel; }
namespace xforms { class XModel2; }
} } }
namespace rtl { class OUString; }
class SvXMLImport;
......@@ -41,7 +41,7 @@ class SvXMLImportContext;
/** import the xforms:binding element */
class XFormsBindContext : public TokenContext
{
const com::sun::star::uno::Reference<com::sun::star::xforms::XModel> mxModel;
const com::sun::star::uno::Reference<com::sun::star::xforms::XModel2> mxModel;
com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> mxBinding;
public:
......@@ -49,7 +49,7 @@ public:
XFormsBindContext( SvXMLImport& rImport,
sal_uInt16 nPrefix,
const rtl::OUString& rLocalName,
const com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet>& xModel );
const com::sun::star::uno::Reference<com::sun::star::xforms::XModel2>& xModel );
virtual ~XFormsBindContext();
......
......@@ -28,7 +28,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/xml/dom/XDocument.hpp>
#include <com/sun/star/xforms/XModel.hpp>
#include <com/sun/star/xforms/XModel2.hpp>
#include <tools/debug.hxx>
#include <xmloff/xmlnmspe.hxx>
......@@ -43,7 +43,7 @@ using com::sun::star::uno::Reference;
using com::sun::star::uno::makeAny;
using com::sun::star::uno::UNO_QUERY;
using com::sun::star::uno::Sequence;
using com::sun::star::xforms::XModel;
using com::sun::star::xforms::XModel2;
using com::sun::star::beans::XPropertySet;
using com::sun::star::beans::PropertyValue;
using com::sun::star::xml::sax::XAttributeList;
......@@ -64,9 +64,9 @@ XFormsInstanceContext::XFormsInstanceContext(
SvXMLImport& rImport,
sal_uInt16 nPrefix,
const OUString& rLocalName,
Reference<XPropertySet> xModel ) :
const Reference<XModel2> & xModel ) :
TokenContext( rImport, nPrefix, rLocalName, aAttributes, aEmptyMap ),
mxModel( Reference<XModel>( xModel, UNO_QUERY ) )
mxModel( xModel )
{
DBG_ASSERT( mxModel.is(), "need model" );
}
......
......@@ -32,7 +32,7 @@ namespace com { namespace sun { namespace star {
namespace xml { namespace sax { class XAttributeList; } }
namespace xml { namespace dom { class XDocument; } }
namespace beans { class XPropertySet; }
namespace xforms { class XModel; }
namespace xforms { class XModel2; }
} } }
namespace rtl { class OUString; }
class SvXMLImport;
......@@ -42,7 +42,7 @@ class SvXMLImportContext;
/** import the xforms:instance element */
class XFormsInstanceContext : public TokenContext
{
com::sun::star::uno::Reference<com::sun::star::xforms::XModel> mxModel;
com::sun::star::uno::Reference<com::sun::star::xforms::XModel2> mxModel;
com::sun::star::uno::Reference<com::sun::star::xml::dom::XDocument> mxInstance;
rtl::OUString msId;
rtl::OUString msURL;
......@@ -52,7 +52,7 @@ public:
XFormsInstanceContext( SvXMLImport& rImport,
sal_uInt16 nPrfx,
const ::rtl::OUString& rLName,
com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> xModel );
const com::sun::star::uno::Reference<com::sun::star::xforms::XModel2> & xModel );
virtual ~XFormsInstanceContext();
......
......@@ -35,7 +35,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/xml/dom/XDocument.hpp>
#include <com/sun/star/util/XUpdatable.hpp>
#include <com/sun/star/xforms/XModel.hpp>
#include <com/sun/star/xforms/XModel2.hpp>
using rtl::OUString;
......@@ -78,7 +78,7 @@ XFormsModelContext::~XFormsModelContext()
}
Reference<XPropertySet> XFormsModelContext::getModel()
Reference<css::xforms::XModel2> XFormsModelContext::getModel()
{
return mxModel;
}
......@@ -126,10 +126,7 @@ SvXMLImportContext* XFormsModelContext::HandleChild(
break;
case XML_SCHEMA:
pContext = new SchemaContext(
GetImport(), nPrefix, rLocalName,
Reference<com::sun::star::xforms::XModel>( mxModel,
UNO_QUERY_THROW )
->getDataTypeRepository() );
GetImport(), nPrefix, rLocalName, mxModel->getDataTypeRepository() );
break;
default:
OSL_FAIL( "Boooo!" );
......
......@@ -22,6 +22,7 @@
#include "TokenContext.hxx"
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/xforms/XModel2.hpp>
//
......@@ -39,7 +40,7 @@ class SvXMLImportContext;
/** import the xforms:model element */
class XFormsModelContext : public TokenContext
{
com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> mxModel;
com::sun::star::uno::Reference<com::sun::star::xforms::XModel2> mxModel;
public:
......@@ -48,7 +49,7 @@ public:
const ::rtl::OUString& rLName );
virtual ~XFormsModelContext();
com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> getModel();
com::sun::star::uno::Reference<com::sun::star::xforms::XModel2> getModel();
//
// implement SvXMLImportContext & TokenContext methods:
......
......@@ -32,7 +32,7 @@
#include <sax/tools/converter.hxx>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/xforms/XModel.hpp>
#include <com/sun/star/xforms/XModel2.hpp>
#include <tools/debug.hxx>
......@@ -40,7 +40,7 @@ using rtl::OUString;
using com::sun::star::beans::XPropertySet;
using com::sun::star::container::XNameContainer;
using com::sun::star::xml::sax::XAttributeList;
using com::sun::star::xforms::XModel;
using com::sun::star::xforms::XModel2;
using namespace com::sun::star::uno;
using namespace xmloff::token;
......@@ -72,17 +72,15 @@ XFormsSubmissionContext::XFormsSubmissionContext(
SvXMLImport& rImport,
sal_uInt16 nPrefix,
const OUString& rLocalName,
const Reference<XPropertySet>& xModel ) :
const Reference<XModel2>& xModel ) :
TokenContext( rImport, nPrefix, rLocalName, aAttributeMap, aEmptyMap ),
mxSubmission()
{
// register submission with model
DBG_ASSERT( xModel.is(), "need model" );
Reference<XModel> xXModel( xModel, UNO_QUERY );
DBG_ASSERT( xXModel.is(), "need XModel" );
mxSubmission = xXModel->createSubmission().get();
mxSubmission = xModel->createSubmission().get();
DBG_ASSERT( mxSubmission.is(), "can't create submission" );
xXModel->getSubmissions()->insert( makeAny( mxSubmission ) );
xModel->getSubmissions()->insert( makeAny( mxSubmission ) );
}
XFormsSubmissionContext::~XFormsSubmissionContext()
......
......@@ -31,6 +31,7 @@
namespace com { namespace sun { namespace star {
namespace xml { namespace sax { class XAttributeList; } }
namespace beans { class XPropertySet; }
namespace xforms { class XModel2; }
} } }
namespace rtl { class OUString; }
class SvXMLImport;
......@@ -47,7 +48,7 @@ public:
XFormsSubmissionContext( SvXMLImport& rImport,
sal_uInt16 nPrefix,
const rtl::OUString& rLocalName,
const com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet>& xModel );
const com::sun::star::uno::Reference<com::sun::star::xforms::XModel2>& xModel );
virtual ~XFormsSubmissionContext();
......
......@@ -26,7 +26,8 @@
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/xforms/XFormsSupplier.hpp>
#include <com/sun/star/xforms/XDataTypeRepository.hpp>
#include <com/sun/star/xforms/XModel.hpp>
#include <com/sun/star/xforms/Model.hpp>
#include <com/sun/star/xforms/XModel2.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/xsd/DataTypeClass.hpp>
......@@ -48,8 +49,9 @@ using com::sun::star::container::XNameAccess;
using com::sun::star::lang::XMultiServiceFactory;
using com::sun::star::xforms::XFormsSupplier;
using com::sun::star::xforms::XDataTypeRepository;
using com::sun::star::xforms::Model;
using com::sun::star::xforms::XModel2;
using com::sun::star::container::XNameContainer;
using comphelper::getProcessServiceFactory;
using com::sun::star::uno::makeAny;
using com::sun::star::uno::Any;
using com::sun::star::uno::Exception;
......@@ -57,26 +59,16 @@ using com::sun::star::uno::Exception;
using namespace com::sun::star;
using namespace xmloff::token;
static Reference<XPropertySet> lcl_createPropertySet( const OUString& rServiceName )
Reference<XModel2> xforms_createXFormsModel()
{
Reference<XMultiServiceFactory> xFactory = getProcessServiceFactory();
DBG_ASSERT( xFactory.is(), "can't get service factory" );
Reference<XPropertySet> xModel( xFactory->createInstance( rServiceName ),
UNO_QUERY_THROW );
DBG_ASSERT( xModel.is(), "can't create model" );
Reference<XModel2> xModel = Model::create( comphelper::getProcessComponentContext() );
return xModel;
}
Reference<XPropertySet> xforms_createXFormsModel()
{
return lcl_createPropertySet( "com.sun.star.xforms.Model" );
}
void xforms_addXFormsModel(
const Reference<frame::XModel>& xDocument,
const Reference<XPropertySet>& xModel )
const Reference<xforms::XModel2>& xModel )
{
bool bSuccess = false;
try
......@@ -129,7 +121,7 @@ static Reference<XPropertySet> lcl_findXFormsBindingOrSubmission(
sal_Int32 nNames = aNames.getLength();
for( sal_Int32 n = 0; (n < nNames) && !xRet.is(); n++ )
{
Reference<xforms::XModel> xModel(
Reference<xforms::XModel2> xModel(
xForms->getByName( pNames[n] ), UNO_QUERY );
if( xModel.is() )
{
......
......@@ -31,15 +31,15 @@ namespace com { namespace sun { namespace star {
namespace beans { class XPropertySet; }
namespace frame { class XModel; }
namespace uno { template<class A> class Reference; }
namespace xforms { class XDataTypeRepository; }
namespace xforms { class XDataTypeRepository; class XModel2; }
} } }
class SvXMLNamespaceMap;
com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> xforms_createXFormsModel();
com::sun::star::uno::Reference<com::sun::star::xforms::XModel2> xforms_createXFormsModel();
void xforms_addXFormsModel(
const com::sun::star::uno::Reference<com::sun::star::frame::XModel>& xDocument,
const com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet>& xModel );
const com::sun::star::uno::Reference<com::sun::star::xforms::XModel2>& xModel );
com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> xforms_findXFormsBinding( com::sun::star::uno::Reference<com::sun::star::frame::XModel>&, const rtl::OUString& );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment