bump product version to 4.1.6.2
[LibreOffice.git] / forms / qa / org / openoffice / xforms / Model.java
blobd0af835e80537f87bbec83a87dfc65e9c6421859
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package org.openoffice.xforms;
21 import com.sun.star.beans.XPropertySet;
22 import com.sun.star.uno.UnoRuntime;
23 import com.sun.star.xforms.XFormsUIHelper1;
24 import com.sun.star.xforms.XModel;
25 import com.sun.star.xml.dom.XNode;
27 public class Model
29 private XModel m_model;
30 private XPropertySet m_modelProps;
31 private XFormsUIHelper1 m_helper;
33 protected Model( Object _model )
35 m_model = UnoRuntime.queryInterface( XModel.class, _model );
36 m_modelProps = UnoRuntime.queryInterface( XPropertySet.class, _model );
37 m_helper = UnoRuntime.queryInterface( XFormsUIHelper1.class,
38 m_model );
41 protected XModel getXModel()
43 return m_model;
46 protected XFormsUIHelper1 getUIHelper()
48 return m_helper;
51 public Instance getDefaultInstance()
53 return new Instance( this, m_model.getDefaultInstance() );
56 /** creates a binding for the given DOM node
58 * @param _node
59 * the DOM node to create a binding for
60 * @param _dataType
61 * the data type to be used for the binding
62 * @return
64 public XPropertySet createBindingForNode( XNode _node, short _dataTypeClass )
66 XPropertySet binding = m_helper.getBindingForNode(_node, true);
67 try
69 String basicTypeName = (String)m_model.getDataTypeRepository().getBasicDataType( _dataTypeClass ).
70 getPropertyValue( "Name" );
71 binding.setPropertyValue( "Type", basicTypeName );
73 catch (Exception ex)
75 ex.printStackTrace();
77 return binding;
80 public void setIsDocumentInternalData( boolean _internalData )
82 try
84 m_modelProps.setPropertyValue("ExternalData", new Boolean(!_internalData));
86 catch (Exception ex)
88 ex.printStackTrace();
92 public boolean getIsDocumentInternalData()
94 boolean isInternalData = false;
95 try
97 isInternalData = !((Boolean)m_modelProps.getPropertyValue( "ExternalData" )).booleanValue();
99 catch (Exception ex)
101 ex.printStackTrace();
103 return isInternalData;