bump product version to 7.6.3.2-android
[LibreOffice.git] / forms / qa / org / openoffice / xforms / Model.java
blob37c3915b2a070aaf004578d36e66079c4b9f03b8
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 final XModel m_model;
30 private final XPropertySet m_modelProps;
31 private final 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 );
43 protected XFormsUIHelper1 getUIHelper()
45 return m_helper;
48 public Instance getDefaultInstance()
50 return new Instance( this, m_model.getDefaultInstance() );
53 /** creates a binding for the given DOM node
55 * @param _node the DOM node to create a binding for
56 * @param _dataTypeClass the data type to be used for the binding
58 public XPropertySet createBindingForNode( XNode _node, short _dataTypeClass )
60 XPropertySet binding = m_helper.getBindingForNode(_node, true);
61 try
63 String basicTypeName = (String)m_model.getDataTypeRepository().getBasicDataType( _dataTypeClass ).
64 getPropertyValue( "Name" );
65 binding.setPropertyValue( "Type", basicTypeName );
67 catch (Exception ex)
69 ex.printStackTrace();
71 return binding;
74 public void setIsDocumentInternalData( boolean _internalData )
76 try
78 m_modelProps.setPropertyValue("ExternalData", Boolean.valueOf(!_internalData));
80 catch (Exception ex)
82 ex.printStackTrace();
86 public boolean getIsDocumentInternalData()
88 boolean isInternalData = false;
89 try
91 isInternalData = !((Boolean)m_modelProps.getPropertyValue( "ExternalData" )).booleanValue();
93 catch (Exception ex)
95 ex.printStackTrace();
97 return isInternalData;