summaryrefslogtreecommitdiff
path: root/forms/source/component
diff options
context:
space:
mode:
authorJens-Heiner Rechtien <hr@openoffice.org>2000-09-18 15:33:13 +0000
committerJens-Heiner Rechtien <hr@openoffice.org>2000-09-18 15:33:13 +0000
commitbf4154eb5307ec8c35f000fd1df39ef3abb2eb6d (patch)
tree6f31c3697d45522bc58de2252bfba3f22a9e2315 /forms/source/component
parent95117e7fefa9ae82431dcdffd1e58495730f6f54 (diff)
initial import
Diffstat (limited to 'forms/source/component')
-rw-r--r--forms/source/component/BaseListBox.hxx77
-rw-r--r--forms/source/component/Button.cxx382
-rw-r--r--forms/source/component/Button.hxx171
-rw-r--r--forms/source/component/CheckBox.cxx435
-rw-r--r--forms/source/component/CheckBox.hxx159
-rw-r--r--forms/source/component/Columns.cxx676
-rw-r--r--forms/source/component/Columns.hxx268
-rw-r--r--forms/source/component/ComboBox.cxx908
-rw-r--r--forms/source/component/ComboBox.hxx199
-rw-r--r--forms/source/component/Currency.cxx295
-rw-r--r--forms/source/component/Currency.hxx138
-rw-r--r--forms/source/component/DatabaseForm.cxx3904
-rw-r--r--forms/source/component/DatabaseForm.hxx554
-rw-r--r--forms/source/component/Date.cxx303
-rw-r--r--forms/source/component/Date.hxx142
-rw-r--r--forms/source/component/Edit.cxx643
-rw-r--r--forms/source/component/Edit.hxx199
-rw-r--r--forms/source/component/EditBase.cxx429
-rw-r--r--forms/source/component/EditBase.hxx158
-rw-r--r--forms/source/component/EventThread.cxx225
-rw-r--r--forms/source/component/EventThread.hxx165
-rw-r--r--forms/source/component/File.cxx329
-rw-r--r--forms/source/component/File.hxx138
-rw-r--r--forms/source/component/FixedText.cxx174
-rw-r--r--forms/source/component/FixedText.hxx117
-rw-r--r--forms/source/component/FormComponent.cxx1458
-rw-r--r--forms/source/component/FormattedField.cxx1186
-rw-r--r--forms/source/component/FormattedField.hxx212
-rw-r--r--forms/source/component/FormattedFieldWrapper.cxx350
-rw-r--r--forms/source/component/FormattedFieldWrapper.hxx120
-rw-r--r--forms/source/component/FormsCollection.cxx207
-rw-r--r--forms/source/component/FormsCollection.hxx138
-rw-r--r--forms/source/component/Grid.cxx1302
-rw-r--r--forms/source/component/Grid.hxx228
-rw-r--r--forms/source/component/GroupBox.cxx211
-rw-r--r--forms/source/component/GroupBox.hxx125
-rw-r--r--forms/source/component/GroupManager.cxx532
-rw-r--r--forms/source/component/GroupManager.hxx264
-rw-r--r--forms/source/component/Hidden.cxx216
-rw-r--r--forms/source/component/Hidden.hxx121
-rw-r--r--forms/source/component/ImageButton.cxx316
-rw-r--r--forms/source/component/ImageButton.hxx147
-rw-r--r--forms/source/component/ImageControl.cxx673
-rw-r--r--forms/source/component/ImageControl.hxx201
-rw-r--r--forms/source/component/ListBox.cxx1330
-rw-r--r--forms/source/component/ListBox.hxx254
-rw-r--r--forms/source/component/Numeric.cxx256
-rw-r--r--forms/source/component/Numeric.hxx138
-rw-r--r--forms/source/component/Pattern.cxx251
-rw-r--r--forms/source/component/Pattern.hxx139
-rw-r--r--forms/source/component/RadioButton.cxx510
-rw-r--r--forms/source/component/RadioButton.hxx162
-rw-r--r--forms/source/component/Time.cxx310
-rw-r--r--forms/source/component/Time.hxx142
-rw-r--r--forms/source/component/makefile.mk145
55 files changed, 22832 insertions, 0 deletions
diff --git a/forms/source/component/BaseListBox.hxx b/forms/source/component/BaseListBox.hxx
new file mode 100644
index 000000000000..f3b43029b055
--- /dev/null
+++ b/forms/source/component/BaseListBox.hxx
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * $RCSfile: BaseListBox.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:04 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_BASELISTBOX_HXX_
+#define _FORMS_BASELISTBOX_HXX_
+
+//.........................................................................
+namespace frm
+{
+
+const sal_uInt16 ENTRY_NOT_FOUND = 0xFFFF;
+const sal_uInt16 BOUNDCOLUMN = 0x0001;
+
+//.........................................................................
+}
+//.........................................................................
+
+#endif // _FORMS_BASELISTBOX_HXX_
+
diff --git a/forms/source/component/Button.cxx b/forms/source/component/Button.cxx
new file mode 100644
index 000000000000..d8facdb67c32
--- /dev/null
+++ b/forms/source/component/Button.cxx
@@ -0,0 +1,382 @@
+/*************************************************************************
+ *
+ * $RCSfile: Button.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:04 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FRM_BUTTON_HXX_
+#include "Button.hxx"
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+//==================================================================
+//= OButtonModel
+//==================================================================
+DBG_NAME(OButtonModel)
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OButtonModel_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new OButtonModel(_rxFactory));
+}
+
+//------------------------------------------------------------------
+OButtonModel::OButtonModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OImageModel(_rxFactory, VCL_CONTROLMODEL_COMMANDBUTTON, FRM_CONTROL_COMMANDBUTTON)
+ // use the old control name for compytibility reasons
+{
+ DBG_CTOR(OButtonModel, NULL);
+ m_nClassId = starform::FormComponentType::COMMANDBUTTON;
+}
+
+//------------------------------------------------------------------------------
+OButtonModel::~OButtonModel()
+{
+ DBG_DTOR(OButtonModel, NULL);
+}
+
+//------------------------------------------------------------------------------
+staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL OButtonModel::getPropertySetInfo() throw( staruno::RuntimeException )
+{
+ staruno::Reference<starbeans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//------------------------------------------------------------------------------
+void OButtonModel::fillProperties(
+ staruno::Sequence< starbeans::Property >& _rProps,
+ staruno::Sequence< starbeans::Property >& _rAggregateProps ) const
+{
+ FRM_BEGIN_PROP_HELPER(8)
+ DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT);
+ DECL_PROP1(BUTTONTYPE, starform::FormButtonType, BOUND);
+ DECL_PROP1(TARGET_URL, ::rtl::OUString, BOUND);
+ DECL_PROP1(TARGET_FRAME, ::rtl::OUString, BOUND);
+ DECL_PROP1(NAME, ::rtl::OUString, BOUND);
+ DECL_PROP1(TAG, ::rtl::OUString, BOUND);
+ DECL_PROP1(TABINDEX, sal_Int16, BOUND);
+ DECL_PROP1(HELPTEXT, ::rtl::OUString, BOUND);
+ FRM_END_PROP_HELPER();
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OButtonModel::getInfoHelper()
+{
+ return *const_cast<OButtonModel*>(this)->getArrayHelper();
+}
+
+// starlang::XServiceInfo
+//------------------------------------------------------------------------------
+StringSequence OButtonModel::getSupportedServiceNames() throw()
+{
+ StringSequence aSupported = OControlModel::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 1);
+
+ ::rtl::OUString*pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_COMMANDBUTTON;
+ return aSupported;
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString OButtonModel::getServiceName()
+{
+ return FRM_COMPONENT_COMMANDBUTTON; // old (non-sun) name for compatibility !
+}
+
+//------------------------------------------------------------------------------
+void OButtonModel::write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream)
+{
+ OImageModel::write(_rxOutStream);
+
+ _rxOutStream->writeShort(0x0002); // Version
+ _rxOutStream->writeShort( (sal_uInt16)m_eButtonType );
+
+ ::rtl::OUString sTmp = INetURLObject::decode(INetURLObject::AbsToRel( m_sTargetURL ), '%', INetURLObject::DECODE_UNAMBIGUOUS);
+ _rxOutStream << sTmp;
+ _rxOutStream << m_sTargetFrame;
+ _rxOutStream << m_aHelpText;
+}
+
+//------------------------------------------------------------------------------
+void OButtonModel::read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream)
+{
+ OImageModel::read(_rxInStream);
+
+ sal_uInt16 nVersion = _rxInStream->readShort(); // Version
+ switch (nVersion)
+ {
+ case 0x0001:
+ {
+ m_eButtonType = (starform::FormButtonType)_rxInStream->readShort();
+
+ ::rtl::OUString sTmp;
+ _rxInStream >> sTmp;
+ m_sTargetURL = INetURLObject::RelToAbs( sTmp );
+ _rxInStream >> m_sTargetFrame;
+ }
+ break;
+ case 0x0002:
+ {
+ m_eButtonType = (starform::FormButtonType)_rxInStream->readShort();
+
+ ::rtl::OUString sTmp;
+ _rxInStream >> sTmp;
+ m_sTargetURL = INetURLObject::RelToAbs( sTmp );
+ _rxInStream >> m_sTargetFrame;
+ _rxInStream >> m_aHelpText;
+ }
+ break;
+ default :
+ DBG_ERROR("OButtonModel::read : unknown version !");
+ m_eButtonType = starform::FormButtonType_PUSH;
+ m_sTargetURL = ::rtl::OUString();
+ m_sTargetFrame = ::rtl::OUString();
+ break;
+ }
+}
+
+//==================================================================
+// OButtonControl
+//==================================================================
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OButtonControl_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new OButtonControl(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> OButtonControl::_getTypes()
+{
+ static staruno::Sequence<staruno::Type> aTypes;
+ if (!aTypes.getLength())
+ {
+ // my base class
+ staruno::Sequence<staruno::Type> aBaseClassTypes = OImageControl::_getTypes();
+
+ staruno::Sequence<staruno::Type> aOwnTypes(2);
+ staruno::Type* pOwnTypes = aOwnTypes.getArray();
+ pOwnTypes[0] = getCppuType((staruno::Reference<starawt::XButton>*)NULL);
+ pOwnTypes[1] = getCppuType((staruno::Reference<starawt::XActionListener>*)NULL);
+
+ aTypes = concatSequences(aBaseClassTypes, aOwnTypes);
+ }
+ return aTypes;
+}
+
+//------------------------------------------------------------------------------
+StringSequence OButtonControl::getSupportedServiceNames() throw()
+{
+ StringSequence aSupported = OControl::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 1);
+
+ ::rtl::OUString*pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_COMMANDBUTTON;
+ return aSupported;
+}
+
+//------------------------------------------------------------------------------
+OButtonControl::OButtonControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OImageControl(_rxFactory, VCL_CONTROL_COMMANDBUTTON)
+ ,nClickEvent(0)
+{
+ increment(m_refCount);
+ {
+ // als ActionListener anmelden
+ staruno::Reference<starawt::XButton> xButton;
+ query_aggregation( m_xAggregate, xButton);
+ if (xButton.is())
+ xButton->addActionListener(this);
+ }
+ // Refcount bei 1 fuer Listener
+ sal_Int32 n = decrement(m_refCount);
+}
+
+//------------------------------------------------------------------------------
+OButtonControl::~OButtonControl()
+{
+ if (nClickEvent)
+ Application::RemoveUserEvent(nClickEvent);
+}
+
+// UNO Anbindung
+//------------------------------------------------------------------------------
+staruno::Any SAL_CALL OButtonControl::queryAggregation(const staruno::Type& _rType) throw (staruno::RuntimeException)
+{
+ staruno::Any aReturn;
+
+ aReturn = OImageControl::queryAggregation(_rType);
+ if (!aReturn.hasValue())
+ aReturn = ::cppu::queryInterface(_rType
+ ,static_cast<starawt::XActionListener*>(this)
+ ,static_cast<starawt::XButton*>(this)
+ );
+
+ return aReturn;
+}
+
+// ActionListener
+//------------------------------------------------------------------------------
+void OButtonControl::actionPerformed(const starawt::ActionEvent& rEvent)
+{
+ // Asynchron fuer starutil::URL-Button
+ sal_uInt32 n = Application::PostUserEvent( LINK(this, OButtonControl,
+ OnClick) );
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ nClickEvent = n;
+ }
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OButtonControl, OnClick, void*, EMPTYARG )
+{
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+ nClickEvent = 0;
+
+ if (m_aApproveActionListeners.getLength())
+ {
+ // Wenn es ApproveAction-Lisener gibt, muss ein eigener Thread
+ // aufgemacht werden.
+ if( !m_pThread )
+ {
+ m_pThread = new OImageControlThread_Impl( this );
+ m_pThread->acquire();
+ m_pThread->create();
+ }
+ m_pThread->addEvent();
+ }
+ else
+ {
+ // Sonst nicht. Dann darf man aber auf keinen Fal die Listener
+ // benachrichtigen, auch dann nicht, wenn er spaeter hinzukommt.
+ aGuard.clear();
+
+ // recognize the button type
+ staruno::Reference<starbeans::XPropertySet> xSet(getModel(), staruno::UNO_QUERY);
+ if (!xSet.is())
+ return 0L;
+
+ if (starform::FormButtonType_PUSH == *(starform::FormButtonType*)xSet->getPropertyValue(PROPERTY_BUTTONTYPE).getValue())
+ {
+ // notify the action listeners for a push button
+ ::cppu::OInterfaceIteratorHelper aIter(m_aActionListeners);
+ starawt::ActionEvent aEvt(static_cast<staruno::XWeak*>(this), m_aActionCommand);
+ while(aIter.hasMoreElements() )
+ {
+ ((starawt::XActionListener*)aIter.next())->actionPerformed(aEvt);
+ }
+ }
+ else
+ actionPerformed_Impl( sal_False );
+ }
+ return 0L;
+}
+
+// starawt::XButton
+//------------------------------------------------------------------------------
+void OButtonControl::setLabel(const ::rtl::OUString& Label) throw( staruno::RuntimeException )
+{
+ staruno::Reference<starawt::XButton> xButton;
+ query_aggregation( m_xAggregate, xButton);
+ if (xButton.is())
+ xButton->setLabel(Label);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OButtonControl::setActionCommand(const ::rtl::OUString& _rCommand) throw( staruno::RuntimeException )
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_aActionCommand = _rCommand;
+ }
+
+ staruno::Reference<starawt::XButton> xButton;
+ query_aggregation( m_xAggregate, xButton);
+ if (xButton.is())
+ xButton->setActionCommand(_rCommand);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OButtonControl::addActionListener(const staruno::Reference<starawt::XActionListener>& _rxListener) throw( staruno::RuntimeException )
+{
+ m_aActionListeners.addInterface(_rxListener);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OButtonControl::removeActionListener(const staruno::Reference<starawt::XActionListener>& _rxListener) throw( staruno::RuntimeException )
+{
+ m_aActionListeners.removeInterface(_rxListener);
+}
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
diff --git a/forms/source/component/Button.hxx b/forms/source/component/Button.hxx
new file mode 100644
index 000000000000..056d06bbd932
--- /dev/null
+++ b/forms/source/component/Button.hxx
@@ -0,0 +1,171 @@
+/*************************************************************************
+ *
+ * $RCSfile: Button.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:04 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FRM_BUTTON_HXX_
+#define _FRM_BUTTON_HXX_
+
+#ifndef _FRM_IMAGE_HXX_
+#include "Image.hxx"
+#endif
+
+#ifndef _COM_SUN_STAR_AWT_MOUSEEVENT_HPP_
+#include <com/sun/star/awt/MouseEvent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_EVENTOBJECT_HPP_
+#include <com/sun/star/lang/EventObject.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_ACTIONEVENT_HPP_
+#include <com/sun/star/awt/ActionEvent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XACTIONLISTENER_HPP_
+#include <com/sun/star/awt/XActionListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XBUTTON_HPP_
+#include <com/sun/star/awt/XButton.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYCHANGEEVENT_HPP_
+#include <com/sun/star/beans/PropertyChangeEvent.hpp>
+#endif
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+//==================================================================
+// OButtonModel
+//==================================================================
+class OButtonModel
+ :public OImageModel
+ ,public ::utl::OAggregationArrayUsageHelper<OButtonModel>
+{
+public:
+ OButtonModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+ ~OButtonModel();
+
+// starlang::XServiceInfo
+ IMPLEMENTATION_NAME(OButtonModel);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
+
+// staruno::Reference<starbeans::XPropertySet>
+ virtual staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(staruno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+// stario::XPersistObject
+ virtual ::rtl::OUString SAL_CALL getServiceName();
+ virtual void SAL_CALL write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream);
+ virtual void SAL_CALL read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream);
+
+ virtual void fillProperties(
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rProps,
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rAggregateProps
+ ) const;
+ IMPLEMENT_INFO_SERVICE()
+};
+
+//==================================================================
+// OButtonControl
+//==================================================================
+class OButtonControl: public starawt::XButton,
+ public starawt::XActionListener,
+ public OImageControl
+{
+ sal_uInt32 nClickEvent;
+
+protected:
+
+ // UNO Anbindung
+ virtual staruno::Sequence<staruno::Type> _getTypes();
+
+public:
+ OButtonControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+ virtual ~OButtonControl();
+
+// starlang::XServiceInfo
+ IMPLEMENTATION_NAME(OButtonControl);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
+
+// UNO Anbindung
+ DECLARE_UNO3_AGG_DEFAULTS(OButtonControl, OImageControl);
+ virtual staruno::Any SAL_CALL queryAggregation(const staruno::Type& _rType) throw(staruno::RuntimeException);
+
+// starawt::XActionListener
+ virtual void SAL_CALL actionPerformed(const starawt::ActionEvent& rEvent);
+
+// starawt::XButton
+ virtual void SAL_CALL addActionListener(const staruno::Reference<starawt::XActionListener>& _rxListener) throw(staruno::RuntimeException);
+ virtual void SAL_CALL removeActionListener(const staruno::Reference<starawt::XActionListener>& _rxListener) throw(staruno::RuntimeException);
+ virtual void SAL_CALL setLabel(const ::rtl::OUString& Label) throw(staruno::RuntimeException);
+ virtual void SAL_CALL setActionCommand(const ::rtl::OUString& _rCommand) throw(staruno::RuntimeException);
+
+// starlang::XEventListener
+ virtual void SAL_CALL disposing(const starlang::EventObject& _rSource) throw(staruno::RuntimeException)
+ { OControl::disposing(_rSource); }
+private:
+ DECL_LINK( OnClick, void* );
+};
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
+#endif // _FRM_BUTTON_HXX_
+
diff --git a/forms/source/component/CheckBox.cxx b/forms/source/component/CheckBox.cxx
new file mode 100644
index 000000000000..b4ec521670de
--- /dev/null
+++ b/forms/source/component/CheckBox.cxx
@@ -0,0 +1,435 @@
+/*************************************************************************
+ *
+ * $RCSfile: CheckBox.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:04 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_CHECKBOX_HXX_
+#include "CheckBox.hxx"
+#endif
+#ifndef _FRM_PROPERTY_HXX_
+#include "property.hxx"
+#endif
+#ifndef _FRM_PROPERTY_HRC_
+#include "property.hrc"
+#endif
+#ifndef _FRM_SERVICES_HXX_
+#include "services.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+//.........................................................................
+namespace frm
+{
+
+//==================================================================
+//= OCheckBoxControl
+//==================================================================
+
+//------------------------------------------------------------------
+OCheckBoxControl::OCheckBoxControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OBoundControl(_rxFactory, VCL_CONTROL_CHECKBOX)
+{
+}
+
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OCheckBoxControl_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory) throw (staruno::RuntimeException)
+{
+ return *(new OCheckBoxControl(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+StringSequence SAL_CALL OCheckBoxControl::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException)
+{
+ StringSequence aSupported = OBoundControl::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 1);
+
+ ::rtl::OUString* pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_CHECKBOX;
+ return aSupported;
+}
+
+//==================================================================
+//= OCheckBoxModel
+//==================================================================
+
+//==================================================================
+InterfaceRef SAL_CALL OCheckBoxModel_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory) throw (staruno::RuntimeException)
+{
+ return *(new OCheckBoxModel(_rxFactory));
+}
+
+//------------------------------------------------------------------
+OCheckBoxModel::OCheckBoxModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OBoundControlModel(_rxFactory, VCL_CONTROLMODEL_CHECKBOX, FRM_CONTROL_CHECKBOX, sal_False)
+ // use the old control name for compytibility reasons
+ ,OPropertyChangeListener(m_aMutex)
+ ,m_bInReset(sal_False)
+{
+ m_nClassId = starform::FormComponentType::CHECKBOX;
+ m_nDefaultChecked = CB_NOCHECK;
+ m_sDataFieldConnectivityProperty = PROPERTY_STATE;
+
+ increment(m_refCount);
+ if (m_xAggregateSet.is())
+ {
+ OPropertyChangeMultiplexer* pMultiplexer = new OPropertyChangeMultiplexer(this, m_xAggregateSet);
+ pMultiplexer->addProperty(PROPERTY_STATE);
+ }
+ decrement(m_refCount);
+}
+
+//------------------------------------------------------------------------------
+void OCheckBoxModel::_propertyChanged(const starbeans::PropertyChangeEvent& _rEvent) throw(staruno::RuntimeException)
+{
+ // as we aren't commitable we have to take care of the field we are bound to ourself
+ osl::MutexGuard aGuard(m_aMutex);
+ if (m_xField.is() && !m_bInReset)
+ {
+
+ sal_uInt16 nState;
+ _rEvent.NewValue >>= nState;
+ switch (nState)
+ {
+ case CB_DONTKNOW:
+ m_xColumnUpdate->updateNull();
+ break;
+ case CB_CHECK:
+ m_xColumnUpdate->updateBoolean(sal_True);
+ break;
+ case CB_NOCHECK:
+ m_xColumnUpdate->updateBoolean(sal_False);
+ break;
+ default:
+ DBG_ERROR("OCheckBoxModel::_commit : invalid value !");
+ }
+ }
+}
+
+
+// XServiceInfo
+//------------------------------------------------------------------------------
+StringSequence SAL_CALL OCheckBoxModel::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException)
+{
+ StringSequence aSupported = OBoundControlModel::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 2);
+
+ ::rtl::OUString* pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-2] = ::rtl::OUString::createFromAscii("com.sun.star.form.component.DatabaseCheckBox");
+ pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_CHECKBOX;
+ return aSupported;
+}
+
+//------------------------------------------------------------------------------
+void OCheckBoxModel::getFastPropertyValue(staruno::Any& _rValue, sal_Int32 _nHandle) const
+{
+ switch (_nHandle)
+ {
+ case PROPERTY_ID_REFVALUE: _rValue <<= m_sReferenceValue; break;
+ case PROPERTY_ID_DEFAULTCHECKED : _rValue <<= m_nDefaultChecked; break;
+ default:
+ OBoundControlModel::getFastPropertyValue(_rValue, _nHandle);
+ }
+}
+
+//------------------------------------------------------------------------------
+void OCheckBoxModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const staruno::Any& _rValue) throw (com::sun::star::uno::Exception)
+{
+ switch (_nHandle)
+ {
+ case PROPERTY_ID_REFVALUE :
+ DBG_ASSERT(_rValue.getValueType().getTypeClass() == staruno::TypeClass_STRING, "OCheckBoxModel::setFastPropertyValue_NoBroadcast : invalid type !" );
+ _rValue >>= m_sReferenceValue;
+ break;
+
+ case PROPERTY_ID_DEFAULTCHECKED :
+ DBG_ASSERT(_rValue.getValueType().getTypeClass() == staruno::TypeClass_SHORT, "OCheckBoxModel::setFastPropertyValue_NoBroadcast : invalid type !" );
+ _rValue >>= m_nDefaultChecked;
+ _reset();
+ break;
+
+ default:
+ OBoundControlModel::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OCheckBoxModel::convertFastPropertyValue(
+ staruno::Any& _rConvertedValue, staruno::Any& _rOldValue, sal_Int32 _nHandle, const staruno::Any& _rValue)
+ throw (starlang::IllegalArgumentException)
+{
+ sal_Bool bModified(sal_False);
+ switch (_nHandle)
+ {
+ case PROPERTY_ID_REFVALUE :
+ bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_sReferenceValue);
+ break;
+ case PROPERTY_ID_DEFAULTCHECKED :
+ bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_nDefaultChecked);
+ break;
+ default:
+ bModified = OBoundControlModel::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
+ break;
+ }
+ return bModified;
+}
+
+//------------------------------------------------------------------------------
+staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL OCheckBoxModel::getPropertySetInfo() throw(staruno::RuntimeException)
+{
+ staruno::Reference<starbeans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//------------------------------------------------------------------------------
+cppu::IPropertyArrayHelper& OCheckBoxModel::getInfoHelper()
+{
+ return *const_cast<OCheckBoxModel*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+void OCheckBoxModel::fillProperties(
+ staruno::Sequence< starbeans::Property >& _rProps,
+ staruno::Sequence< starbeans::Property >& _rAggregateProps ) const
+{
+ FRM_BEGIN_PROP_HELPER(11)
+ // the "State" property is transient, so change this
+// ModifyPropertyAttributes(_rAggregateProps, PROPERTY_STATE, starbeans::PropertyAttribute::TRANSIENT, 0);
+
+ DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT);
+ DECL_PROP1(REFVALUE, ::rtl::OUString, BOUND);
+ DECL_PROP1(DEFAULTCHECKED, sal_Int16, BOUND);
+ DECL_PROP1(NAME, rtl::OUString, BOUND);
+ DECL_PROP1(TAG, rtl::OUString, BOUND);
+ DECL_PROP1(TABINDEX, sal_Int16, BOUND);
+ DECL_PROP1(CONTROLSOURCE, rtl::OUString, BOUND);
+ DECL_PROP1(HELPTEXT, rtl::OUString, BOUND);
+ DECL_IFACE_PROP2(BOUNDFIELD, starbeans::XPropertySet, READONLY, TRANSIENT);
+ DECL_IFACE_PROP2(CONTROLLABEL, starbeans::XPropertySet, BOUND, MAYBEVOID);
+ DECL_PROP2(CONTROLSOURCEPROPERTY, rtl::OUString, READONLY, TRANSIENT);
+ FRM_END_PROP_HELPER();
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OCheckBoxModel::getServiceName() throw(staruno::RuntimeException)
+{
+ return FRM_COMPONENT_CHECKBOX; // old (non-sun) name for compatibility !
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OCheckBoxModel::write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream)
+ throw(stario::IOException, staruno::RuntimeException)
+{
+ OBoundControlModel::write(_rxOutStream);
+
+ // Version
+ _rxOutStream->writeShort(0x0003);
+ // Properties
+ _rxOutStream << m_sReferenceValue;
+ _rxOutStream << (sal_Int16)m_nDefaultChecked;
+ _rxOutStream << m_aHelpText;
+ // from version 0x0003 : common properties
+ writeCommonProperties(_rxOutStream);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OCheckBoxModel::read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream) throw(stario::IOException, staruno::RuntimeException)
+{
+ OBoundControlModel::read(_rxInStream);
+ osl::MutexGuard aGuard(m_aMutex);
+
+ // Version
+ sal_uInt16 nVersion = _rxInStream->readShort();
+
+ switch (nVersion)
+ {
+ case 0x0001 : _rxInStream >> m_sReferenceValue; m_nDefaultChecked = _rxInStream->readShort(); break;
+ case 0x0002 :
+ _rxInStream >> m_sReferenceValue;
+ _rxInStream >> (sal_Int16)m_nDefaultChecked;
+ _rxInStream >> m_aHelpText;
+ break;
+ case 0x0003 :
+ _rxInStream >> m_sReferenceValue;
+ _rxInStream >> (sal_Int16)m_nDefaultChecked;
+ _rxInStream >> m_aHelpText;
+ readCommonProperties(_rxInStream);
+ break;
+ default :
+ DBG_ERROR("OCheckBoxModel::read : unknown version !");
+ m_sReferenceValue = ::rtl::OUString();
+ m_nDefaultChecked = 0;
+ defaultCommonProperties();
+ break;
+ }
+
+ // Nach dem Lesen die Defaultwerte anzeigen
+ if (m_aControlSource.getLength())
+ // (not if we don't have a control source - the "State" property acts like it is persistent, then
+ _reset();
+}
+
+//------------------------------------------------------------------------------
+void OCheckBoxModel::_loaded(const starlang::EventObject& rEvent)
+{
+ OBoundControlModel::_loaded(rEvent);
+}
+
+//------------------------------------------------------------------------------
+void OCheckBoxModel::_onValueChanged()
+{
+ //////////////////////////////////////////////////////////////////
+ // Wert an ControlModel setzen
+ if (m_xAggregateSet.is())
+ {
+ staruno::Any aValue;
+ if (m_xColumn->getBoolean())
+ aValue <<= (sal_Int16)CB_CHECK;
+ else if (m_xColumn->wasNull())
+ {
+ sal_Bool bTriState;
+ m_xAggregateSet->getPropertyValue(PROPERTY_TRISTATE) >>= bTriState;
+ aValue <<= (sal_Int16)(bTriState ? CB_DONTKNOW : m_nDefaultChecked);
+ }
+ else
+ aValue <<= (sal_Int16)CB_NOCHECK;
+ m_bInReset = sal_True;
+ { // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
+ // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
+ // our own mutex locked
+ // FS - 72451 - 31.01.00
+ MutexRelease aRelease(m_aMutex);
+ m_xAggregateSet->setPropertyValue(PROPERTY_STATE, aValue);
+ }
+ m_bInReset = sal_False;
+ }
+}
+
+//------------------------------------------------------------------------------
+staruno::Any OCheckBoxModel::_getControlValue() const
+{
+ return m_xAggregateSet->getPropertyValue(PROPERTY_STATE);
+}
+
+//------------------------------------------------------------------------------
+void OCheckBoxModel::_reset( void )
+{
+ staruno::Any aValue;
+ aValue <<= (sal_Int16)m_nDefaultChecked;
+ { // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
+ // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
+ // our own mutex locked
+ // FS - 72451 - 31.01.00
+ MutexRelease aRelease(m_aMutex);
+ m_xAggregateSet->setPropertyValue(PROPERTY_STATE, aValue);
+ }
+}
+
+//-----------------------------------------------------------------------------
+sal_Bool OCheckBoxModel::_commit()
+{
+ if (!m_bInReset)
+ // normally we don't have a commit as we forward all state changes immediately to our field we're bound to
+ return sal_True;
+
+ // we're in reset, so this commit means "put the value into the field you're bound to"
+ // 72769 - 08.02.00 - FS
+ DBG_ASSERT(m_xField.is(), "OCheckBoxModel::_commit : committing while resetting, but not bound ?");
+ if (m_xField.is())
+ {
+ try
+ {
+ sal_Int16 nValue;
+ m_xAggregateSet->getPropertyValue(PROPERTY_STATE) >>= nValue;
+ switch (nValue)
+ {
+ case CB_DONTKNOW:
+ m_xColumnUpdate->updateNull();
+ break;
+ case CB_CHECK:
+ m_xColumnUpdate->updateBoolean(sal_True);
+ break;
+ case CB_NOCHECK:
+ m_xColumnUpdate->updateBoolean(sal_False);
+ break;
+ default:
+ DBG_ERROR("OCheckBoxModel::_commit : invalid value !");
+ }
+ }
+ catch(...)
+ {
+ DBG_ERROR("OCheckBoxModel::_commit : could not commit !");
+ }
+ }
+ return sal_True;
+}
+
+//-----------------------------------------------------------------------------
+void OCheckBoxModel::reset(void) throw (com::sun::star::uno::RuntimeException)
+{
+ m_bInReset = sal_True;
+ OBoundControlModel::reset();
+ m_bInReset = sal_False;
+}
+
+//.........................................................................
+}
+//.........................................................................
+
diff --git a/forms/source/component/CheckBox.hxx b/forms/source/component/CheckBox.hxx
new file mode 100644
index 000000000000..17c21aa4c83e
--- /dev/null
+++ b/forms/source/component/CheckBox.hxx
@@ -0,0 +1,159 @@
+/*************************************************************************
+ *
+ * $RCSfile: CheckBox.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:04 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_CHECKBOX_HXX_
+#define _FORMS_CHECKBOX_HXX_
+
+#ifndef _FORMS_FORMCOMPONENT_HXX_
+#include "FormComponent.hxx"
+#endif
+
+#ifndef _UNOTOOLS_PROPERTY_MULTIPLEX_HXX_
+#include <unotools/propmultiplex.hxx>
+#endif
+
+//.........................................................................
+namespace frm
+{
+
+enum { CB_NOCHECK, CB_CHECK, CB_DONTKNOW };
+
+//==================================================================
+//= OCheckBoxModel
+//==================================================================
+class OCheckBoxModel :public OBoundControlModel
+ ,public OPropertyChangeListener
+ ,public ::utl::OAggregationArrayUsageHelper< OCheckBoxModel >
+{
+ ::rtl::OUString m_sReferenceValue; // Referenzwert zum Checken des Buttons
+ sal_Int16 m_nDefaultChecked; // Soll beim Reset gecheckt werden ?
+ sal_Bool m_bInReset;
+
+protected:
+ sal_Int16 getState(const staruno::Any& rValue);
+
+ virtual void _onValueChanged();
+ virtual void _loaded(const starlang::EventObject& rEvent);
+ virtual staruno::Any _getControlValue() const;
+
+public:
+ OCheckBoxModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+
+ // XServiceInfo
+ IMPLEMENTATION_NAME(OCheckBoxModel);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // OPropertySetHelper
+ virtual void SAL_CALL getFastPropertyValue(staruno::Any& rValue, sal_Int32 nHandle) const;
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const staruno::Any& rValue )
+ throw (staruno::Exception);
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(
+ staruno::Any& _rConvertedValue, staruno::Any& _rOldValue, sal_Int32 _nHandle, const staruno::Any& _rValue )
+ throw (starlang::IllegalArgumentException);
+
+ // XPropertySetRef
+ virtual staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(staruno::RuntimeException);
+ virtual cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // XPersistObject
+ virtual ::rtl::OUString SAL_CALL getServiceName() throw(staruno::RuntimeException);
+ virtual void SAL_CALL
+ write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream) throw(stario::IOException, staruno::RuntimeException);
+ virtual void SAL_CALL
+ read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream) throw(stario::IOException, staruno::RuntimeException);
+
+ // OPropertyChangeListener
+ virtual void _propertyChanged(const starbeans::PropertyChangeEvent& evt) throw(staruno::RuntimeException);
+
+ // XReset
+ virtual void SAL_CALL reset() throw(staruno::RuntimeException);
+
+// OAggregationArrayUsageHelper
+ virtual void fillProperties(
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rProps,
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rAggregateProps
+ ) const;
+ IMPLEMENT_INFO_SERVICE()
+
+protected:
+ virtual void _reset();
+ virtual sal_Bool _commit();
+};
+
+//==================================================================
+//= OCheckBoxControl
+//==================================================================
+class OCheckBoxControl : public OBoundControl
+{
+public:
+ OCheckBoxControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+
+ // XServiceInfo
+ IMPLEMENTATION_NAME(OCheckBoxControl);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+};
+
+//.........................................................................
+}
+//.........................................................................
+
+#endif // _FORMS_CHECKBOX_HXX_
+
diff --git a/forms/source/component/Columns.cxx b/forms/source/component/Columns.cxx
new file mode 100644
index 000000000000..a39f8366eda7
--- /dev/null
+++ b/forms/source/component/Columns.cxx
@@ -0,0 +1,676 @@
+/*************************************************************************
+ *
+ * $RCSfile: Columns.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:04 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FRM_COLUMNS_HXX
+#include "Columns.hxx"
+#endif
+#ifndef _FRM_PROPERTY_HRC_
+#include "property.hrc"
+#endif
+#ifndef _FRM_PROPERTY_HXX_
+#include "property.hxx"
+#endif
+#ifndef _FRM_IDS_HXX_
+#include "ids.hxx"
+#endif
+
+#ifndef _COM_SUN_STAR_IO_XPERSISTOBJECT_HPP_
+#include <com/sun/star/io/XPersistObject.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XOBJECTOUTPUTSTREAM_HPP_
+#include <com/sun/star/io/XObjectOutputStream.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XOBJECTINPUTSTREAM_HPP_
+#include <com/sun/star/io/XObjectInputStream.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XMARKABLESTREAM_HPP_
+#include <com/sun/star/io/XMarkableStream.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORMCOMPONENT_HPP_
+#include <com/sun/star/form/XFormComponent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _UTL_SEQUENCE_HXX_
+#include <unotools/sequence.hxx>
+#endif
+#ifndef _UTL_PROPERTY_HXX_
+#include <unotools/property.hxx>
+#endif
+#ifndef _UTL_BASIC_IO_HXX_
+#include <unotools/basicio.hxx>
+#endif
+
+#ifndef _FRM_SERVICES_HXX_
+#include "services.hxx"
+#endif
+#ifndef _FRM_RESOURCE_HRC_
+#include "frm_resource.hrc"
+#endif
+#ifndef _TOOLS_DEBUG_HXX //autogen
+#include <tools/debug.hxx>
+#endif
+#ifndef _RTL_UUID_H_
+#include <rtl/uuid.h>
+#endif
+#ifndef _RTL_MEMORY_H_
+#include <rtl/memory.h>
+#endif
+
+namespace internal {
+sal_Int32 findPos(const ::rtl::OUString& aStr, const StringSequence& rList);
+}
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+ namespace starform = ::com::sun::star::form;
+
+const sal_uInt16 WIDTH = 0x0001;
+const sal_uInt16 ALIGN = 0x0002;
+const sal_uInt16 OLD_HIDDEN = 0x0004;
+const sal_uInt16 COMPATIBLE_HIDDEN = 0x0008;
+
+IMPLEMENT_CONSTASCII_USTRING(FRM_COL_TEXTFIELD, "TextField");
+IMPLEMENT_CONSTASCII_USTRING(FRM_COL_COMBOBOX, "ComboBox");
+IMPLEMENT_CONSTASCII_USTRING(FRM_COL_CHECKBOX, "CheckBox");
+IMPLEMENT_CONSTASCII_USTRING(FRM_COL_TIMEFIELD, "TimeField");
+IMPLEMENT_CONSTASCII_USTRING(FRM_COL_DATEFIELD, "DateField");
+IMPLEMENT_CONSTASCII_USTRING(FRM_COL_NUMERICFIELD, "NumericField");
+IMPLEMENT_CONSTASCII_USTRING(FRM_COL_CURRENCYFIELD, "CurrencyField");
+IMPLEMENT_CONSTASCII_USTRING(FRM_COL_PATTERNFIELD, "PatternField");
+IMPLEMENT_CONSTASCII_USTRING(FRM_COL_LISTBOX, "ListBox");
+IMPLEMENT_CONSTASCII_USTRING(FRM_COL_FORMATTEDFIELD, "FormattedField");
+
+//------------------------------------------------------------------------------
+const StringSequence& getColumnTypes()
+{
+ static StringSequence aColumnTypes(10);
+ if (!aColumnTypes.getConstArray()[0].getLength())
+ {
+ ::rtl::OUString* pNames = aColumnTypes.getArray();
+ pNames[TYPE_CHECKBOX] = FRM_COL_CHECKBOX;
+ pNames[TYPE_COMBOBOX] = FRM_COL_COMBOBOX;
+ pNames[TYPE_CURRENCYFIELD] = FRM_COL_CURRENCYFIELD;
+ pNames[TYPE_DATEFIELD] = FRM_COL_DATEFIELD;
+ pNames[TYPE_FORMATTEDFIELD] = FRM_COL_FORMATTEDFIELD;
+ pNames[TYPE_LISTBOX] = FRM_COL_LISTBOX;
+ pNames[TYPE_NUMERICFIELD] = FRM_COL_NUMERICFIELD;
+ pNames[TYPE_PATTERNFIELD] = FRM_COL_PATTERNFIELD;
+ pNames[TYPE_TEXTFIELD] = FRM_COL_TEXTFIELD;
+ pNames[TYPE_TIMEFIELD] = FRM_COL_TIMEFIELD;
+ }
+ return aColumnTypes;
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 getColumnTypeByModelName(const ::rtl::OUString& aModelName)
+{
+ const ::rtl::OUString aModelPrefix = ::rtl::OUString::createFromAscii("com.sun.star.form.component.");
+ const ::rtl::OUString aCompatibleModelPrefix = ::rtl::OUString::createFromAscii("stardiv.one.form.component.");
+
+ sal_Int32 nTypeId = -1;
+ if (aModelName == FRM_COMPONENT_EDIT)
+ nTypeId = TYPE_TEXTFIELD;
+ else
+ {
+ sal_Int32 nPrefixPos = aModelName.search(aModelPrefix);
+ sal_Int32 nCampatiblePrefixPos = aModelName.search(aCompatibleModelPrefix);
+ DBG_ASSERT( (nPrefixPos != -1) || (nCampatiblePrefixPos != -1),
+ "::getColumnTypeByModelName() : wrong servivce !");
+
+ ::rtl::OUString aColumnType = (nPrefixPos != -1)
+ ? aModelName.copy(aModelPrefix.len())
+ : aModelName.copy(aCompatibleModelPrefix.len());
+
+ const StringSequence& rColumnTypes = getColumnTypes();
+ nTypeId = ::internal::findPos(aColumnType, rColumnTypes);
+ }
+ return nTypeId;
+}
+
+/*************************************************************************/
+
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OGridColumn_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new OGridColumn(_rxFactory));
+}
+
+//------------------------------------------------------------------
+const staruno::Sequence<sal_Int8>& OGridColumn::getUnoTunnelImplementationId()
+{
+ static staruno::Sequence< sal_Int8 > * pSeq = 0;
+ if( !pSeq )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static staruno::Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+//------------------------------------------------------------------
+sal_Int64 SAL_CALL OGridColumn::getSomething( const staruno::Sequence<sal_Int8>& _rIdentifier) throw(staruno::RuntimeException)
+{
+ sal_Int64 nReturn(0);
+
+ if ( (_rIdentifier.getLength() == 16)
+ && (0 == rtl_compareMemory( getUnoTunnelImplementationId().getConstArray(), _rIdentifier.getConstArray(), 16 ))
+ )
+ {
+ nReturn = reinterpret_cast<sal_Int64>(this);
+ }
+ else
+ {
+ staruno::Reference<starlang::XUnoTunnel> xAggregateTunnel(m_xAggregate, staruno::UNO_QUERY);
+ if (xAggregateTunnel.is())
+ nReturn = xAggregateTunnel->getSomething(_rIdentifier);
+ }
+ return nReturn;
+}
+
+//------------------------------------------------------------------
+staruno::Sequence<sal_Int8> SAL_CALL OGridColumn::getImplementationId() throw(staruno::RuntimeException)
+{
+ return OImplementationIds::getImplementationId(getTypes());
+}
+
+//------------------------------------------------------------------
+staruno::Sequence<staruno::Type> SAL_CALL OGridColumn::getTypes() throw(staruno::RuntimeException)
+{
+ staruno::Sequence<staruno::Type> aOwnTypes(5);
+ aOwnTypes.getArray()[0] = ::getCppuType((staruno::Reference<starbeans::XPropertySet>*)NULL);
+ aOwnTypes.getArray()[1] = ::getCppuType((staruno::Reference<starbeans::XFastPropertySet>*)NULL);
+ aOwnTypes.getArray()[2] = ::getCppuType((staruno::Reference<starbeans::XMultiPropertySet>*)NULL);
+ aOwnTypes.getArray()[3] = ::getCppuType((staruno::Reference<starbeans::XPropertyState>*)NULL);
+ aOwnTypes.getArray()[4] = ::getCppuType((staruno::Reference<starcontainer::XChild>*)NULL);
+
+ staruno::Reference<starlang::XTypeProvider> xProv;
+
+ if (query_aggregation(m_xAggregate, xProv))
+ return concatSequences(aOwnTypes, OComponentHelper::getTypes(), xProv->getTypes());
+ else
+ return concatSequences(aOwnTypes, OComponentHelper::getTypes(), xProv->getTypes());
+}
+
+//------------------------------------------------------------------
+staruno::Any SAL_CALL OGridColumn::queryAggregation( const staruno::Type& _rType ) throw (staruno::RuntimeException)
+{
+ staruno::Any aReturn = OComponentHelper::queryAggregation(_rType);
+
+ if (!aReturn.hasValue())
+ aReturn = OPropertySetAggregationHelper::queryInterface(_rType);
+
+ if (!aReturn.hasValue())
+ aReturn = ::cppu::queryInterface(_rType,
+ static_cast<starcontainer::XChild*>(this),
+ static_cast<starlang::XUnoTunnel*>(this),
+ static_cast<starform::XFormComponent*>(NULL),
+ // though our aggregate may be an XFormComponent, we aren't anymore
+ static_cast<starlang::XServiceInfo*>(NULL)
+ // though our aggregate may be an XServiceInfo, we aren't anymore
+ );
+
+ if (!aReturn.hasValue() && m_xAggregate.is())
+ aReturn = m_xAggregate->queryAggregation(_rType);
+
+ return aReturn;
+}
+
+DBG_NAME(OGridColumn);
+//------------------------------------------------------------------------------
+OGridColumn::OGridColumn(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory, const ::rtl::OUString& _sModelName)
+ :OComponentHelper(m_aMutex)
+ ,OPropertySetAggregationHelper(OComponentHelper::rBHelper)
+ ,m_aModelName(_sModelName)
+{
+ DBG_CTOR(OGridColumn,NULL);
+ // Anlegen des UnoControlModels
+ if (m_aModelName.getLength()) // gibt es ein zu aggregierendes Model
+ {
+ increment(m_refCount);
+
+ // Muss im eigenen Block,
+ // da xAgg vor dem delegator setzen wieder freigesetzt sein muß !
+ {
+ m_xAggregate = staruno::Reference<staruno::XAggregation> (_rxFactory->createInstance(m_aModelName), staruno::UNO_QUERY);
+ setAggregation(m_xAggregate);
+ }
+
+ if (m_xAggregate.is())
+ {
+ m_xAggregate->setDelegator(static_cast< ::cppu::OWeakObject* >(this));
+ }
+
+ // Refcount wieder bei NULL
+ decrement(m_refCount);
+ }
+
+ m_aHidden <<= (sal_Bool)sal_False;
+}
+
+//------------------------------------------------------------------------------
+OGridColumn::~OGridColumn()
+{
+ if (!OComponentHelper::rBHelper.bDisposed)
+ {
+ acquire();
+ dispose();
+ }
+
+ // freigeben der Agg
+ if (m_xAggregate.is())
+ {
+ InterfaceRef xIface;
+ m_xAggregate->setDelegator(xIface);
+ }
+ DBG_DTOR(OGridColumn,NULL);
+}
+
+// starcontainer::XChild
+//------------------------------------------------------------------------------
+void SAL_CALL OGridColumn::setParent(const InterfaceRef& Parent) throw(starlang::NoSupportException, staruno::RuntimeException)
+{
+ m_xParent = Parent;
+}
+
+// starlang::XEventListener
+//------------------------------------------------------------------------------
+void SAL_CALL OGridColumn::disposing(const starlang::EventObject& _rSource) throw(staruno::RuntimeException)
+{
+ OPropertySetAggregationHelper::disposing(_rSource);
+
+ staruno::Reference<starlang::XEventListener> xEvtLstner;
+ if (query_aggregation(m_xAggregate, xEvtLstner))
+ xEvtLstner->disposing(_rSource);
+}
+
+// OComponentHelper
+//-----------------------------------------------------------------------------
+void OGridColumn::disposing()
+{
+ OComponentHelper::disposing();
+ OPropertySetAggregationHelper::disposing();
+
+ staruno::Reference<starlang::XComponent> xComp;
+ if (query_aggregation(m_xAggregate, xComp))
+ xComp->dispose();
+
+ setParent(InterfaceRef ());
+}
+
+//------------------------------------------------------------------------------
+void OGridColumn::clearAggregateProperties(staruno::Sequence<starbeans::Property>& seqProps, sal_Bool bAllowDropDown)
+{
+ RemoveProperty(seqProps, PROPERTY_ALIGN);
+ RemoveProperty(seqProps, PROPERTY_AUTOCOMPLETE);
+ RemoveProperty(seqProps, PROPERTY_BACKGROUNDCOLOR);
+ RemoveProperty(seqProps, PROPERTY_BORDER);
+ if (!bAllowDropDown)
+ RemoveProperty(seqProps, PROPERTY_DROPDOWN);
+ RemoveProperty(seqProps, PROPERTY_ECHO_CHAR);
+ RemoveProperty(seqProps, PROPERTY_FILLCOLOR);
+ RemoveProperty(seqProps, PROPERTY_FONT);
+ RemoveProperty(seqProps, PROPERTY_FONT_NAME);
+ RemoveProperty(seqProps, PROPERTY_FONT_STYLENAME);
+ RemoveProperty(seqProps, PROPERTY_FONT_FAMILY);
+ RemoveProperty(seqProps, PROPERTY_FONT_CHARSET);
+ RemoveProperty(seqProps, PROPERTY_FONT_HEIGHT);
+ RemoveProperty(seqProps, PROPERTY_FONT_WEIGHT);
+ RemoveProperty(seqProps, PROPERTY_FONT_SLANT);
+ RemoveProperty(seqProps, PROPERTY_FONT_UNDERLINE);
+ RemoveProperty(seqProps, PROPERTY_FONT_STRIKEOUT);
+ RemoveProperty(seqProps, PROPERTY_HARDLINEBREAKS);
+ RemoveProperty(seqProps, PROPERTY_HSCROLL);
+ RemoveProperty(seqProps, PROPERTY_LABEL);
+ RemoveProperty(seqProps, PROPERTY_LINECOLOR);
+ RemoveProperty(seqProps, PROPERTY_MULTI);
+ RemoveProperty(seqProps, PROPERTY_MULTILINE);
+ RemoveProperty(seqProps, PROPERTY_MULTISELECTION);
+ RemoveProperty(seqProps, PROPERTY_PRINTABLE);
+ RemoveProperty(seqProps, PROPERTY_TABINDEX);
+ RemoveProperty(seqProps, PROPERTY_TABSTOP);
+ RemoveProperty(seqProps, PROPERTY_TEXTCOLOR);
+ RemoveProperty(seqProps, PROPERTY_TRISTATE);
+ RemoveProperty(seqProps, PROPERTY_VSCROLL);
+ RemoveProperty(seqProps, PROPERTY_CONTROLLABEL);
+}
+
+//------------------------------------------------------------------------------
+void OGridColumn::setOwnProperties(staruno::Sequence<starbeans::Property>& aDescriptor)
+{
+ aDescriptor.realloc(5);
+ starbeans::Property* pProps = aDescriptor.getArray();
+ sal_Int32 nPos = 0;
+ DECL_PROP1(LABEL, ::rtl::OUString, BOUND);
+ DECL_PROP3(WIDTH, sal_Int32, BOUND, MAYBEVOID, MAYBEDEFAULT);
+ DECL_PROP3(ALIGN, sal_Int16, BOUND, MAYBEVOID, MAYBEDEFAULT);
+ DECL_BOOL_PROP2(HIDDEN, BOUND, MAYBEDEFAULT);
+ DECL_PROP1(COLUMNSERVICENAME, ::rtl::OUString, READONLY);
+}
+
+// staruno::Reference<starbeans::XPropertySet>
+//------------------------------------------------------------------------------
+staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL OGridColumn::getPropertySetInfo() throw(staruno::RuntimeException)
+{
+ DBG_ERROR("OGridColumn::getPropertySetInfo() : Dummy Called");
+ return staruno::Reference<starbeans::XPropertySetInfo> ();
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OGridColumn::getInfoHelper()
+{
+ DBG_ERROR("OGridColumn::getInfoHelper() : Dummy Called");
+
+ staruno::Sequence<starbeans::Property> aDescriptor, aAggProperties;
+ static OPropertyArrayAggregationHelper aDescAry(aDescriptor, aAggProperties);
+ return aDescAry;
+}
+
+//------------------------------------------------------------------------------
+void OGridColumn::getFastPropertyValue(staruno::Any& rValue, sal_Int32 nHandle ) const
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_COLUMNSERVICENAME:
+ rValue <<= m_aModelName;
+ break;
+ case PROPERTY_ID_LABEL:
+ rValue <<= m_aLabel;
+ break;
+ case PROPERTY_ID_WIDTH:
+ rValue = m_aWidth;
+ break;
+ case PROPERTY_ID_ALIGN:
+ rValue = m_aAlign;
+ break;
+ case PROPERTY_ID_HIDDEN:
+ rValue = m_aHidden;
+ break;
+ default:
+ OPropertySetAggregationHelper::getFastPropertyValue(rValue, nHandle);
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OGridColumn::convertFastPropertyValue( staruno::Any& rConvertedValue, staruno::Any& rOldValue,
+ sal_Int32 nHandle, const staruno::Any& rValue )throw( starlang::IllegalArgumentException )
+{
+ sal_Bool bModified(sal_False);
+ switch (nHandle)
+ {
+ case PROPERTY_ID_LABEL:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aLabel);
+ break;
+ case PROPERTY_ID_WIDTH:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aWidth, ::getCppuType((const sal_Int32*)NULL));
+ break;
+ case PROPERTY_ID_ALIGN:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aAlign, ::getCppuType((const sal_Int16*)NULL));
+ break;
+ case PROPERTY_ID_HIDDEN:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, getBOOL(m_aHidden));
+ break;
+ }
+ return bModified;
+}
+
+//------------------------------------------------------------------------------
+void OGridColumn::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const staruno::Any& rValue )
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_LABEL:
+ DBG_ASSERT(rValue.getValueType().getTypeClass() == staruno::TypeClass_STRING, "invalid type" );
+ rValue >>= m_aLabel;
+ break;
+ case PROPERTY_ID_WIDTH:
+ m_aWidth = rValue;
+ break;
+ case PROPERTY_ID_ALIGN:
+ m_aAlign = rValue;
+ break;
+ case PROPERTY_ID_HIDDEN:
+ m_aHidden = rValue;
+ break;
+ }
+}
+
+
+// starbeans::XPropertyState
+//------------------------------------------------------------------------------
+starbeans::PropertyState OGridColumn::getPropertyStateByHandle(sal_Int32 nHandle)
+{
+ starbeans::PropertyState eState;
+ switch (nHandle)
+ {
+ case PROPERTY_ID_WIDTH:
+ if (!m_aWidth.hasValue())
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ else
+ eState = starbeans::PropertyState_DIRECT_VALUE;
+ break;
+ case PROPERTY_ID_ALIGN:
+ if (!m_aAlign.hasValue())
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ else
+ eState = starbeans::PropertyState_DIRECT_VALUE;
+ break;
+ default:
+ eState = OPropertySetAggregationHelper::getPropertyStateByHandle(nHandle);
+ }
+ return eState;
+}
+
+//------------------------------------------------------------------------------
+void OGridColumn::setPropertyToDefaultByHandle(sal_Int32 nHandle)
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_WIDTH:
+ case PROPERTY_ID_ALIGN:
+ setFastPropertyValue(nHandle, staruno::Any());
+ break;
+ case PROPERTY_ID_HIDDEN:
+ setFastPropertyValue(nHandle, staruno::makeAny((sal_Bool)sal_True));
+ break;
+ default:
+ OPropertySetAggregationHelper::setPropertyToDefaultByHandle(nHandle);
+ }
+}
+
+//------------------------------------------------------------------------------
+staruno::Any OGridColumn::getPropertyDefaultByHandle( sal_Int32 nHandle ) const
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_WIDTH:
+ case PROPERTY_ID_ALIGN:
+ return staruno::Any();
+ case PROPERTY_ID_HIDDEN:
+ return staruno::makeAny((sal_Bool)sal_False);
+ default:
+ return OPropertySetAggregationHelper::getPropertyDefaultByHandle(nHandle);
+ }
+}
+
+//XPersistObject
+//------------------------------------------------------------------------------
+void SAL_CALL OGridColumn::write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream)
+{
+ // 1. Schreiben des UnoControls
+ staruno::Reference<stario::XMarkableStream> xMark(_rxOutStream, staruno::UNO_QUERY);
+ sal_Int32 nMark = xMark->createMark();
+
+ sal_Int32 nLen = 0;
+ _rxOutStream->writeLong(nLen);
+
+ staruno::Reference<stario::XPersistObject> xPersist;
+ if (query_aggregation(m_xAggregate, xPersist))
+ xPersist->write(_rxOutStream);
+
+ // feststellen der Laenge
+ nLen = xMark->offsetToMark(nMark) - 4;
+ xMark->jumpToMark(nMark);
+ _rxOutStream->writeLong(nLen);
+ xMark->jumpToFurthest();
+ xMark->deleteMark(nMark);
+
+ // 2. Schreiben einer VersionsNummer
+ _rxOutStream->writeShort(0x0002);
+
+ sal_uInt16 nAnyMask = 0;
+ if (m_aWidth.getValueType().getTypeClass() == staruno::TypeClass_LONG)
+ nAnyMask |= WIDTH;
+
+ if (m_aAlign.getValueType().getTypeClass() == staruno::TypeClass_SHORT)
+ nAnyMask |= ALIGN;
+
+ nAnyMask |= COMPATIBLE_HIDDEN;
+
+ _rxOutStream->writeShort(nAnyMask);
+
+ if (nAnyMask & WIDTH)
+ _rxOutStream->writeLong(getINT32(m_aWidth));
+ if (nAnyMask & ALIGN)
+ _rxOutStream->writeShort(getINT16(m_aAlign));
+
+ // Name
+ _rxOutStream << m_aLabel;
+
+ // the new place for the hidden flag : after m_aLabel, so older office version read the correct label, too
+ if (nAnyMask & COMPATIBLE_HIDDEN)
+ _rxOutStream->writeBoolean(getBOOL(m_aHidden));
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OGridColumn::read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream)
+{
+ // 1. Lesen des UnoControls
+ sal_Int32 nLen = _rxInStream->readLong();
+ if (nLen)
+ {
+ staruno::Reference<stario::XMarkableStream> xMark(_rxInStream, staruno::UNO_QUERY);
+ sal_Int32 nMark = xMark->createMark();
+ staruno::Reference<stario::XPersistObject> xPersist;
+ if (query_aggregation(m_xAggregate, xPersist))
+ xPersist->read(_rxInStream);
+
+ xMark->jumpToMark(nMark);
+ _rxInStream->skipBytes(nLen);
+ xMark->deleteMark(nMark);
+ }
+
+ // 2. Lesen des Versionsnummer
+ sal_uInt16 nVersion = _rxInStream->readShort();
+ sal_uInt16 nAnyMask = _rxInStream->readShort();
+
+ if (nAnyMask & WIDTH)
+ {
+ sal_Int32 nValue = _rxInStream->readLong();
+ m_aWidth <<= (sal_Int32)nValue;
+ }
+
+ if (nAnyMask & ALIGN)
+ {
+ sal_Int16 nValue = _rxInStream->readShort();
+ m_aAlign <<= nValue;
+ }
+ if (nAnyMask & OLD_HIDDEN)
+ {
+ sal_Bool bValue = _rxInStream->readBoolean();
+ m_aHidden <<= (sal_Bool)bValue;
+ }
+
+ // Name
+ _rxInStream >> m_aLabel;
+
+ if (nAnyMask & COMPATIBLE_HIDDEN)
+ {
+ sal_Bool bValue = _rxInStream->readBoolean();
+ m_aHidden <<= (sal_Bool)bValue;
+ }
+}
+
+//------------------------------------------------------------------------------
+IMPL_COLUMN(TextFieldColumn, FRM_SUN_COMPONENT_TEXTFIELD, sal_False);
+IMPL_COLUMN(PatternFieldColumn, FRM_SUN_COMPONENT_PATTERNFIELD, sal_False);
+IMPL_COLUMN(DateFieldColumn, FRM_SUN_COMPONENT_DATEFIELD, sal_True);
+IMPL_COLUMN(TimeFieldColumn, FRM_SUN_COMPONENT_TIMEFIELD, sal_False);
+IMPL_COLUMN(NumericFieldColumn, FRM_SUN_COMPONENT_NUMERICFIELD, sal_False);
+IMPL_COLUMN(CurrencyFieldColumn, FRM_SUN_COMPONENT_CURRENCYFIELD, sal_False);
+IMPL_COLUMN(CheckBoxColumn, FRM_SUN_COMPONENT_CHECKBOX, sal_False);
+IMPL_COLUMN(ComboBoxColumn, FRM_SUN_COMPONENT_COMBOBOX, sal_False);
+IMPL_COLUMN(ListBoxColumn, FRM_SUN_COMPONENT_LISTBOX, sal_False);
+IMPL_COLUMN(FormattedFieldColumn, FRM_SUN_COMPONENT_FORMATTEDFIELD, sal_False);
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
diff --git a/forms/source/component/Columns.hxx b/forms/source/component/Columns.hxx
new file mode 100644
index 000000000000..954d77b9aad1
--- /dev/null
+++ b/forms/source/component/Columns.hxx
@@ -0,0 +1,268 @@
+/*************************************************************************
+ *
+ * $RCSfile: Columns.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:04 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FRM_COLUMNS_HXX
+#define _FRM_COLUMNS_HXX
+
+#ifndef _CPPUHELPER_COMPONENT_HXX_
+#include <cppuhelper/component.hxx>
+#endif
+#ifndef _UNOTOOLS_PROPERTY_ARRAY_HELPER_HXX_
+#include <unotools/proparrhlp.hxx>
+#endif
+#ifndef _UNOTOOLS_PROPERTY_AGGREGATION_HXX_
+#include <unotools/propagg.hxx>
+#endif
+#ifndef _UTL_UNO3_HXX_
+#include <unotools/uno3.hxx>
+#endif
+#include "strings.hxx"
+
+#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
+#include <com/sun/star/container/XChild.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XOBJECTOUTPUTSTREAM_HPP_
+#include <com/sun/star/io/XObjectOutputStream.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XOBJECTINPUTSTREAM_HPP_
+#include <com/sun/star/io/XObjectInputStream.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#endif
+
+using namespace utl;
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+ namespace starcontainer = ::com::sun::star::container;
+ namespace stario = ::com::sun::star::io;
+
+//==================================================================
+// OGridColumn
+//==================================================================
+class OGridColumn
+ :public ::cppu::OComponentHelper
+ ,public OPropertySetAggregationHelper
+ ,public starcontainer::XChild
+ ,public starlang::XUnoTunnel
+{
+protected:
+// [properties]
+ staruno::Any m_aWidth; // Spaltenbreite
+ staruno::Any m_aAlign;
+ staruno::Any m_aHidden; // Spalte ist versteckt ?
+// [properties]
+
+ ::osl::Mutex m_aMutex;
+ InterfaceRef m_xParent;
+ staruno::Reference<staruno::XAggregation> m_xAggregate;
+ ::rtl::OUString m_aModelName;
+
+// [properties]
+ ::rtl::OUString m_aLabel; // Name der Spalte
+
+// [properties]
+
+public:
+ OGridColumn(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory, const ::rtl::OUString& _sModelName = ::rtl::OUString());
+ virtual ~OGridColumn();
+
+ // UNO Anbindung
+ DECLARE_UNO3_AGG_DEFAULTS(OGridControlModel, OComponentHelper);
+ virtual staruno::Any SAL_CALL queryAggregation( const staruno::Type& _rType ) throw (staruno::RuntimeException);
+
+ static const staruno::Sequence<sal_Int8>& getUnoTunnelImplementationId();
+ // XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething( const staruno::Sequence<sal_Int8>& _rIdentifier) throw(staruno::RuntimeException);
+
+// XTypeProvider
+ virtual staruno::Sequence<sal_Int8> SAL_CALL getImplementationId() throw(staruno::RuntimeException);
+ virtual staruno::Sequence<staruno::Type> SAL_CALL getTypes() throw(staruno::RuntimeException);
+
+// OComponentHelper
+ virtual void SAL_CALL disposing();
+
+// starlang::XEventListener
+ virtual void SAL_CALL disposing(const starlang::EventObject& _rSource) throw(staruno::RuntimeException);
+
+// starcontainer::XChild
+ virtual InterfaceRef SAL_CALL getParent() throw(staruno::RuntimeException){return m_xParent;}
+ virtual void SAL_CALL setParent(const InterfaceRef& Parent) throw(starlang::NoSupportException, staruno::RuntimeException);
+
+// stario::XPersistObject
+ virtual void SAL_CALL write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream);
+ virtual void SAL_CALL read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream);
+
+// starbeans::XPropertySet
+ virtual staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(staruno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+ virtual void SAL_CALL getFastPropertyValue(staruno::Any& rValue, sal_Int32 nHandle ) const;
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(staruno::Any& rConvertedValue, staruno::Any& rOldValue,
+ sal_Int32 nHandle, const staruno::Any& rValue )
+ throw(starlang::IllegalArgumentException);
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const staruno::Any& rValue);
+
+// starbeans::XPropertyState
+ virtual starbeans::PropertyState getPropertyStateByHandle(sal_Int32 nHandle);
+ virtual void setPropertyToDefaultByHandle(sal_Int32 nHandle);
+ virtual staruno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const;
+
+ const ::rtl::OUString& getModelName() const { return m_aModelName; }
+
+protected:
+ static void clearAggregateProperties(staruno::Sequence<starbeans::Property>& seqProps, sal_Bool bAllowDropDown);
+ static void setOwnProperties(staruno::Sequence<starbeans::Property>& seqProps);
+};
+
+#define DECL_COLUMN(ClassName) \
+class ClassName \
+ :public OGridColumn \
+ ,public OAggregationArrayUsageHelper< ClassName > \
+{ \
+public: \
+ ClassName(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);\
+ \
+ virtual staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(staruno::RuntimeException); \
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); \
+ \
+ virtual void fillProperties( \
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps, \
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps \
+ ) const; \
+};
+
+
+#define IMPL_COLUMN(ClassName, Model, bAllowDropDown) \
+ClassName::ClassName(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory) \
+ :OGridColumn(_rxFactory, Model){} \
+staruno::Reference<starbeans::XPropertySetInfo> ClassName::getPropertySetInfo() throw(staruno::RuntimeException)\
+{ \
+ staruno::Reference<starbeans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); \
+ return xInfo; \
+} \
+::cppu::IPropertyArrayHelper& ClassName::getInfoHelper() \
+{ \
+ return *const_cast<ClassName*>(this)->getArrayHelper(); \
+} \
+void ClassName::fillProperties( \
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps, \
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps \
+ ) const \
+{ \
+ if (m_xAggregateSet.is()) \
+ { \
+ _rAggregateProps = m_xAggregateSet->getPropertySetInfo()->getProperties(); \
+ clearAggregateProperties(_rAggregateProps, bAllowDropDown); \
+ setOwnProperties(_rProps); \
+ } \
+} \
+
+// liste der moeglichen Controls
+DECLARE_CONSTASCII_USTRING(FRM_COL_TEXTFIELD);
+DECLARE_CONSTASCII_USTRING(FRM_COL_CHECKBOX);
+DECLARE_CONSTASCII_USTRING(FRM_COL_COMBOBOX);
+DECLARE_CONSTASCII_USTRING(FRM_COL_LISTBOX);
+DECLARE_CONSTASCII_USTRING(FRM_COL_NUMERICFIELD);
+DECLARE_CONSTASCII_USTRING(FRM_COL_DATEFIELD);
+DECLARE_CONSTASCII_USTRING(FRM_COL_TIMEFIELD);
+DECLARE_CONSTASCII_USTRING(FRM_COL_CURRENCYFIELD);
+DECLARE_CONSTASCII_USTRING(FRM_COL_PATTERNFIELD);
+DECLARE_CONSTASCII_USTRING(FRM_COL_FORMATTEDFIELD);
+
+
+// column type ids
+#define TYPE_CHECKBOX 0
+#define TYPE_COMBOBOX 1
+#define TYPE_CURRENCYFIELD 2
+#define TYPE_DATEFIELD 3
+#define TYPE_FORMATTEDFIELD 4
+#define TYPE_LISTBOX 5
+#define TYPE_NUMERICFIELD 6
+#define TYPE_PATTERNFIELD 7
+#define TYPE_TEXTFIELD 8
+#define TYPE_TIMEFIELD 9
+
+// liste aller bekannten columns
+const StringSequence& getColumnTypes();
+sal_Int32 getColumnTypeByModelName(const ::rtl::OUString& aModelName);
+
+// Columns
+DECL_COLUMN(TextFieldColumn)
+DECL_COLUMN(PatternFieldColumn)
+DECL_COLUMN(DateFieldColumn)
+DECL_COLUMN(TimeFieldColumn)
+DECL_COLUMN(NumericFieldColumn)
+DECL_COLUMN(CurrencyFieldColumn)
+DECL_COLUMN(CheckBoxColumn)
+DECL_COLUMN(ComboBoxColumn)
+DECL_COLUMN(ListBoxColumn)
+DECL_COLUMN(FormattedFieldColumn)
+
+#endif // _FRM_COLUMNS_HXX
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
diff --git a/forms/source/component/ComboBox.cxx b/forms/source/component/ComboBox.cxx
new file mode 100644
index 000000000000..3e18ce861db3
--- /dev/null
+++ b/forms/source/component/ComboBox.cxx
@@ -0,0 +1,908 @@
+/*************************************************************************
+ *
+ * $RCSfile: ComboBox.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:04 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_COMBOBOX_HXX_
+#include "ComboBox.hxx"
+#endif
+#ifndef _FRM_PROPERTY_HXX_
+#include "property.hxx"
+#endif
+#ifndef _FRM_PROPERTY_HRC_
+#include "property.hrc"
+#endif
+#ifndef _FRM_SERVICES_HXX_
+#include "services.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _FRM_RESOURCE_HXX_
+#include "frm_resource.hxx"
+#endif
+#ifndef _FRM_RESOURCE_HRC_
+#include "frm_resource.hrc"
+#endif
+#ifndef _FORMS_BASELISTBOX_HXX_
+#include "BaseListBox.hxx"
+#endif
+#ifndef _UTL_NUMBERS_HXX_
+#include <unotools/numbers.hxx>
+#endif
+#ifndef _UNOTOOLS_DATETIME_HXX_
+#include <unotools/datetime.hxx>
+#endif
+#ifndef _UTL_UNO3_DB_TOOLS_HXX_
+#include <unotools/dbtools.hxx>
+#endif
+#ifndef _UTL_DB_CONVERSION_HXX_
+#include <unotools/dbconversion.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_SDB_SQLERROREVENT_HPP_
+#include <com/sun/star/sdb/SQLErrorEvent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROWSET_HPP_
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
+#include <com/sun/star/container/XIndexAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_
+#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_
+#include <com/sun/star/util/NumberFormat.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XLISTBOX_HPP_
+#include <com/sun/star/awt/XListBox.hpp>
+#endif
+
+//.........................................................................
+namespace frm
+{
+
+//========================================================================
+// class OComboBoxModel
+//========================================================================
+sal_Int32 OComboBoxModel::nTextHandle = -1;
+
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OComboBoxModel_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory) throw (staruno::RuntimeException)
+{
+ return (*new OComboBoxModel(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> OComboBoxModel::_getTypes()
+{
+ static staruno::Sequence<staruno::Type> aTypes;
+ if (!aTypes.getLength())
+ {
+ // my two base classes
+ staruno::Sequence<staruno::Type> aBaseClassTypes = OBoundControlModel::_getTypes();
+
+ staruno::Sequence<staruno::Type> aOwnTypes(1);
+ staruno::Type* pOwnTypes = aOwnTypes.getArray();
+ pOwnTypes[0] = getCppuType((staruno::Reference<starsdb::XSQLErrorBroadcaster>*)NULL);
+
+ aTypes = concatSequences(aBaseClassTypes, aOwnTypes);
+ }
+ return aTypes;
+}
+
+// XServiceInfo
+//------------------------------------------------------------------------------
+StringSequence SAL_CALL OComboBoxModel::getSupportedServiceNames() throw(staruno::RuntimeException)
+{
+ StringSequence aSupported = OBoundControlModel::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 2);
+
+ ::rtl::OUString* pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-2] = ::rtl::OUString::createFromAscii("com.sun.star.form.component.DatabaseComboBox");
+ pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_COMBOBOX;
+ return aSupported;
+}
+
+//------------------------------------------------------------------------------
+staruno::Any SAL_CALL OComboBoxModel::queryAggregation(const staruno::Type& _rType) throw (staruno::RuntimeException)
+{
+ staruno::Any aReturn;
+
+ aReturn = OBoundControlModel::queryAggregation(_rType);
+ if (!aReturn.hasValue())
+ aReturn = ::cppu::queryInterface(_rType
+ ,static_cast<starsdb::XSQLErrorBroadcaster*>(this)
+ );
+
+ return aReturn;
+}
+
+//------------------------------------------------------------------
+OComboBoxModel::OComboBoxModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OBoundControlModel(_rxFactory, VCL_CONTROLMODEL_COMBOBOX, FRM_CONTROL_COMBOBOX)
+ // use the old control name for compytibility reasons
+ ,m_eListSourceType(starform::ListSourceType_TABLE)
+ ,m_bEmptyIsNull(sal_True)
+ ,m_aNullDate(STANDARD_DB_DATE)
+ ,m_nKeyType(starutil::NumberFormat::UNDEFINED)
+ ,m_nFormatKey(0)
+ ,m_nFieldType(starsdbc::DataType::OTHER)
+ ,m_aErrorListeners(m_aMutex)
+{
+ m_nClassId = starform::FormComponentType::COMBOBOX;
+ m_sDataFieldConnectivityProperty = PROPERTY_TEXT;
+ if (OComboBoxModel::nTextHandle == -1)
+ OComboBoxModel::nTextHandle = getOriginalHandle(PROPERTY_ID_TEXT);
+}
+
+//------------------------------------------------------------------
+OComboBoxModel::~OComboBoxModel()
+{
+ if (!OComponentHelper::rBHelper.bDisposed)
+ {
+ acquire();
+ dispose();
+ }
+}
+
+//------------------------------------------------------------------------------
+void OComboBoxModel::disposing()
+{
+ OBoundControlModel::disposing();
+ m_xFormatter = NULL;
+}
+
+//------------------------------------------------------------------------------
+void OComboBoxModel::getFastPropertyValue(staruno::Any& _rValue, sal_Int32 _nHandle) const
+{
+ switch (_nHandle)
+ {
+ case PROPERTY_ID_LISTSOURCETYPE : _rValue <<= m_eListSourceType; break;
+ case PROPERTY_ID_LISTSOURCE : _rValue <<= m_aListSource; break;
+ case PROPERTY_ID_EMPTY_IS_NULL : _rValue <<= m_bEmptyIsNull; break;
+ case PROPERTY_ID_DEFAULT_TEXT : _rValue <<= m_aDefaultText; break;
+ default:
+ OBoundControlModel::getFastPropertyValue(_rValue, _nHandle);
+ }
+}
+
+//------------------------------------------------------------------------------
+void OComboBoxModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const staruno::Any& _rValue)
+ throw (staruno::Exception)
+{
+ switch (_nHandle)
+ {
+ case PROPERTY_ID_LISTSOURCETYPE :
+ DBG_ASSERT(_rValue.getValueType().equals(::getCppuType(reinterpret_cast<starform::ListSourceType*>(NULL))),
+ "OComboBoxModel::setFastPropertyValue_NoBroadcast : invalid type !" );
+ _rValue >>= m_eListSourceType;
+ break;
+
+ case PROPERTY_ID_LISTSOURCE :
+ DBG_ASSERT(_rValue.getValueType().getTypeClass() == staruno::TypeClass_STRING,
+ "OComboBoxModel::setFastPropertyValue_NoBroadcast : invalid type !" );
+ _rValue >>= m_aListSource;
+ // die ListSource hat sich geaendert -> neu laden
+ if (starform::ListSourceType_VALUELIST != m_eListSourceType)
+ {
+ if (m_xCursor.is() && !m_xField.is()) // combobox bereits mit Datenbank verbunden ?
+ // neu laden
+ loadData();
+ }
+ break;
+
+ case PROPERTY_ID_EMPTY_IS_NULL :
+ DBG_ASSERT(_rValue.getValueType().getTypeClass() == staruno::TypeClass_BOOLEAN,
+ "OComboBoxModel::setFastPropertyValue_NoBroadcast : invalid type !" );
+ _rValue >>= m_bEmptyIsNull;
+ break;
+
+ case PROPERTY_ID_DEFAULT_TEXT :
+ DBG_ASSERT(_rValue.getValueType().getTypeClass() == staruno::TypeClass_STRING,
+ "OComboBoxModel::setFastPropertyValue_NoBroadcast : invalid type !" );
+ _rValue >>= m_aDefaultText;
+ _reset();
+ break;
+
+ default:
+ OBoundControlModel::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OComboBoxModel::convertFastPropertyValue(
+ staruno::Any& _rConvertedValue, staruno::Any& _rOldValue, sal_Int32 _nHandle, const staruno::Any& _rValue)
+ throw (starlang::IllegalArgumentException)
+{
+ sal_Bool bModified(sal_False);
+ switch (_nHandle)
+ {
+ case PROPERTY_ID_LISTSOURCETYPE :
+ bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_eListSourceType);
+ break;
+
+ case PROPERTY_ID_LISTSOURCE :
+ bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_aListSource);
+ break;
+
+ case PROPERTY_ID_EMPTY_IS_NULL :
+ bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_bEmptyIsNull);
+ break;
+
+ case PROPERTY_ID_DEFAULT_TEXT :
+ bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_aDefaultText);
+ break;
+
+ default:
+ bModified = OBoundControlModel::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
+ break;
+ }
+ return bModified;
+}
+
+//------------------------------------------------------------------------------
+staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL OComboBoxModel::getPropertySetInfo() throw(staruno::RuntimeException)
+{
+ staruno::Reference<starbeans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//------------------------------------------------------------------------------
+cppu::IPropertyArrayHelper& OComboBoxModel::getInfoHelper()
+{
+ return *const_cast<OComboBoxModel*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+void OComboBoxModel::fillProperties(
+ staruno::Sequence< starbeans::Property >& _rProps,
+ staruno::Sequence< starbeans::Property >& _rAggregateProps ) const
+{
+ FRM_BEGIN_PROP_HELPER(13)
+ // Text auf transient setzen
+ ModifyPropertyAttributes(_rAggregateProps, PROPERTY_TEXT, starbeans::PropertyAttribute::TRANSIENT, 0);
+
+ DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT);
+ DECL_PROP1(NAME, ::rtl::OUString, BOUND);
+ DECL_PROP1(TAG, ::rtl::OUString, BOUND);
+ DECL_PROP1(TABINDEX, sal_Int16, BOUND);
+ DECL_PROP1(LISTSOURCETYPE, starform::ListSourceType, BOUND);
+ DECL_PROP1(LISTSOURCE, ::rtl::OUString, BOUND);
+ DECL_BOOL_PROP1(EMPTY_IS_NULL, BOUND);
+ DECL_PROP1(DEFAULT_TEXT, ::rtl::OUString, BOUND);
+ DECL_PROP1(CONTROLSOURCE, ::rtl::OUString, BOUND);
+ DECL_PROP1(HELPTEXT, ::rtl::OUString, BOUND);
+ DECL_IFACE_PROP2(BOUNDFIELD, starbeans::XPropertySet, READONLY, TRANSIENT);
+ DECL_IFACE_PROP2(CONTROLLABEL, starbeans::XPropertySet, BOUND, MAYBEVOID);
+ DECL_PROP2(CONTROLSOURCEPROPERTY, rtl::OUString, READONLY, TRANSIENT);
+ FRM_END_PROP_HELPER();
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OComboBoxModel::getServiceName() throw(staruno::RuntimeException)
+{
+ return FRM_COMPONENT_COMBOBOX; // old (non-sun) name for compatibility !
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OComboBoxModel::write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream)
+ throw(stario::IOException, staruno::RuntimeException)
+{
+ OBoundControlModel::write(_rxOutStream);
+
+ // Version
+ // Version 0x0002: EmptyIsNull
+ // Version 0x0003: ListSource->Seq
+ // Version 0x0004: DefaultText
+ // Version 0x0005: HelpText
+ _rxOutStream->writeShort(0x0006);
+
+ // Maskierung fuer any
+ sal_uInt16 nAnyMask = 0;
+ if (m_aBoundColumn.getValueType().getTypeClass() == staruno::TypeClass_SHORT)
+ nAnyMask |= BOUNDCOLUMN;
+ _rxOutStream << nAnyMask;
+
+ StringSequence aListSourceSeq(&m_aListSource, 1);
+ _rxOutStream << aListSourceSeq;
+ _rxOutStream << (sal_Int16)m_eListSourceType;
+
+ if ((nAnyMask & BOUNDCOLUMN) == BOUNDCOLUMN)
+ {
+ sal_Int16 nBoundColumn;
+ m_aBoundColumn >>= nBoundColumn;
+ _rxOutStream << nBoundColumn;
+ }
+
+ _rxOutStream << (sal_Bool)m_bEmptyIsNull;
+ _rxOutStream << m_aDefaultText;
+ _rxOutStream << m_aHelpText;
+
+ // from version 0x0006 : common properties
+ writeCommonProperties(_rxOutStream);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OComboBoxModel::read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream) throw(stario::IOException, staruno::RuntimeException)
+{
+ OBoundControlModel::read(_rxInStream);
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ // Version
+ sal_uInt16 nVersion = _rxInStream->readShort();
+ DBG_ASSERT(nVersion > 0, "OComboBoxModel::read : version 0 ? this should never have been written !");
+
+ if (nVersion > 0x0006)
+ {
+ DBG_ERROR("OComboBoxModel::read : invalid (means unknown) version !");
+ m_aListSource = ::rtl::OUString();
+ m_aBoundColumn <<= (sal_Int16)0;
+ m_aDefaultText = ::rtl::OUString();
+ m_eListSourceType = starform::ListSourceType_TABLE;
+ m_bEmptyIsNull = sal_True;
+ defaultCommonProperties();
+ return;
+ }
+
+ // Maskierung fuer any
+ sal_uInt16 nAnyMask;
+ _rxInStream >> nAnyMask;
+
+ // ListSource
+ if (nVersion < 0x0003)
+ {
+ ::rtl::OUString sListSource;
+ _rxInStream >> m_aListSource;
+ }
+ else // nVersion == 4
+ {
+ m_aListSource = ::rtl::OUString();
+ StringSequence aListSource;
+ _rxInStream >> aListSource;
+ const ::rtl::OUString* pToken = aListSource.getConstArray();
+ sal_Int32 nLen = aListSource.getLength();
+ for (sal_Int32 i = 0; i < nLen; ++i, ++pToken)
+ m_aListSource += *pToken;
+ }
+
+ sal_Int16 nValue;
+ _rxInStream >> nValue;
+ m_eListSourceType = (starform::ListSourceType)nValue;
+
+ if ((nAnyMask & BOUNDCOLUMN) == BOUNDCOLUMN)
+ {
+ sal_Int16 nValue;
+ _rxInStream >> nValue;
+ m_aBoundColumn <<= nValue;
+ }
+
+ if (nVersion > 0x0001)
+ {
+ sal_Bool bNull;
+ _rxInStream >> bNull;
+ m_bEmptyIsNull = bNull;
+ }
+
+ if (nVersion > 0x0003) // nVersion == 4
+ _rxInStream >> m_aDefaultText;
+
+ // Stringliste muß geleert werden, wenn eine Listenquelle gesetzt ist
+ // dieses kann der Fall sein wenn im alive modus gespeichert wird
+ if (m_aListSource.len() && m_xAggregateSet.is())
+ {
+ StringSequence aSequence;
+ m_xAggregateSet->setPropertyValue(PROPERTY_STRINGITEMLIST, staruno::makeAny(aSequence));
+ }
+
+ if (nVersion > 0x0004)
+ _rxInStream >> m_aHelpText;
+
+ if (nVersion > 0x0005)
+ readCommonProperties(_rxInStream);
+
+ // Nach dem Lesen die Defaultwerte anzeigen
+ if (m_aControlSource.getLength())
+ // (not if we don't have a control source - the "State" property acts like it is persistent, then
+ _reset();
+}
+
+//------------------------------------------------------------------------------
+void OComboBoxModel::loadData()
+{
+ DBG_ASSERT(m_eListSourceType != starform::ListSourceType_VALUELIST, "OComboBoxModel::loadData : do not call for a value list !");
+ ////
+ // Connection holen
+ staruno::Reference<starsdbc::XRowSet> xForm(m_xCursor, staruno::UNO_QUERY);
+ if (!xForm.is())
+ return;
+ staruno::Reference<starsdbc::XConnection> xConnection = getConnection(xForm);
+ if (!xConnection.is())
+ return;
+
+ // we need a com::sun::star::sdb::Connection for some of the code below ...
+ staruno::Reference<starlang::XServiceInfo> xServiceInfo(xConnection, staruno::UNO_QUERY);
+ if (!xServiceInfo.is() || !xServiceInfo->supportsService(SRV_SDB_CONNECTION))
+ {
+ DBG_ERROR("OComboBoxModel::loadData : invalid connection !");
+ return;
+ }
+
+ staruno::Reference<starsdbc::XResultSet> xListCursor;
+
+ if (!m_aListSource.len() || m_eListSourceType == starform::ListSourceType_VALUELIST)
+ return;
+
+ try
+ {
+ switch (m_eListSourceType)
+ {
+ case starform::ListSourceType_TABLEFIELDS:
+ // don't work with a statement here, the fields will be collected below
+ break;
+ case starform::ListSourceType_TABLE:
+ {
+ // does the bound field belong to the table ?
+ // if we use an alias for the bound field, we won't find it
+ // in that case we use the first field of the table
+
+ staruno::Reference<starcontainer::XNameAccess> xFieldsByName = getTableFields(xConnection, m_aListSource);
+ staruno::Reference<starcontainer::XIndexAccess> xFieldsByIndex(xFieldsByName, staruno::UNO_QUERY);
+
+ ::rtl::OUString aFieldName;
+ if (xFieldsByName.is() && xFieldsByName->hasByName(m_aControlSource))
+ {
+ aFieldName = m_aControlSource;
+ }
+ else
+ {
+ // otherwise look for the alias
+ staruno::Reference<starsdb::XSQLQueryComposerFactory> xFactory(xConnection, staruno::UNO_QUERY);
+ if (!xFactory.is())
+ break;
+
+ staruno::Reference<starsdb::XSQLQueryComposer> xComposer = xFactory->createQueryComposer();
+ try
+ {
+ staruno::Reference<starbeans::XPropertySet> xFormAsSet(xForm, staruno::UNO_QUERY);
+ ::rtl::OUString aStatement;
+ xFormAsSet->getPropertyValue(PROPERTY_ACTIVECOMMAND) >>= aStatement;
+ xComposer->setQuery(aStatement);
+ }
+ catch(...)
+ {
+ disposeComponent(xComposer);
+ break;
+ }
+
+ // search the field
+ staruno::Reference<starsdbcx::XColumnsSupplier> xSupplyFields(xComposer, staruno::UNO_QUERY);
+ DBG_ASSERT(xSupplyFields.is(), "OComboBoxModel::loadData : invalid query composer !");
+
+ staruno::Reference<starcontainer::XNameAccess> xFieldNames = xSupplyFields->getColumns();
+ if (xFieldNames->hasByName(m_aControlSource))
+ {
+ staruno::Reference<starbeans::XPropertySet> xComposerFieldAsSet(*(staruno::Reference<starbeans::XPropertySet>*)xFieldNames->getByName(m_aControlSource).getValue());
+ if (hasProperty(PROPERTY_FIELDSOURCE, xComposerFieldAsSet))
+ xComposerFieldAsSet->getPropertyValue(PROPERTY_FIELDSOURCE) >>= aFieldName;
+ }
+
+ disposeComponent(xComposer);
+ }
+
+ if (!aFieldName.len())
+ break;
+
+ staruno::Reference<starsdbc::XDatabaseMetaData> xMeta = xConnection->getMetaData();
+ ::rtl::OUString aQuote = xMeta->getIdentifierQuoteString();
+ ::rtl::OUString aStatement = ::rtl::OUString::createFromAscii("SELECT DISTINCT ");
+
+ aStatement += quoteName(aQuote, aFieldName);
+ aStatement += ::rtl::OUString::createFromAscii(" FROM ");
+ aStatement += quoteTableName(xMeta, m_aListSource);
+
+ staruno::Reference<starsdbc::XStatement> xStmt = xConnection->createStatement();
+ xListCursor = xStmt->executeQuery(aStatement);
+ } break;
+ case starform::ListSourceType_QUERY:
+ {
+ staruno::Reference<starsdb::XQueriesSupplier> xSupplyQueries(xConnection, staruno::UNO_QUERY);
+ staruno::Reference<starbeans::XPropertySet> xQuery(*(InterfaceRef*)xSupplyQueries->getQueries()->getByName(m_aListSource).getValue(), staruno::UNO_QUERY);
+ staruno::Reference<starsdbc::XStatement> xStmt = xConnection->createStatement();
+ staruno::Reference<starbeans::XPropertySet>(xStmt, staruno::UNO_QUERY)->setPropertyValue(PROPERTY_ESCAPE_PROCESSING, xQuery->getPropertyValue(PROPERTY_ESCAPE_PROCESSING));
+
+ ::rtl::OUString sStatement;
+ xQuery->getPropertyValue(PROPERTY_COMMAND) >>= sStatement;
+ xListCursor = xStmt->executeQuery(sStatement);
+ } break;
+ default:
+ {
+ staruno::Reference<starsdbc::XStatement> xStmt = xConnection->createStatement();
+ if (starform::ListSourceType_SQLPASSTHROUGH == m_eListSourceType)
+ {
+ staruno::Reference<starbeans::XPropertySet> xStatementProps(xStmt, staruno::UNO_QUERY);
+ xStatementProps->setPropertyValue(PROPERTY_ESCAPE_PROCESSING, staruno::makeAny(sal_Bool(sal_False)));
+ }
+ xListCursor = xStmt->executeQuery(m_aListSource);
+ }
+ }
+ }
+ catch(starsdbc::SQLException& eSQL)
+ {
+ onError(eSQL, FRM_RES_STRING(RID_BASELISTBOX_ERROR_FILLLIST));
+ disposeComponent(xListCursor);
+ return;
+ }
+ catch(staruno::Exception& eUnknown)
+ {
+ eUnknown;
+ disposeComponent(xListCursor);
+ return;
+ }
+
+ if (starform::ListSourceType_TABLEFIELDS != m_eListSourceType && !xListCursor.is())
+ // something went wrong ...
+ return;
+
+ vector< ::rtl::OUString > aStringList;
+ aStringList.reserve(16);
+ try
+ {
+ switch (m_eListSourceType)
+ {
+ case starform::ListSourceType_SQL:
+ case starform::ListSourceType_SQLPASSTHROUGH:
+ case starform::ListSourceType_TABLE:
+ case starform::ListSourceType_QUERY:
+ {
+ // die XDatabaseVAriant der ersten Spalte
+ staruno::Reference<starsdbcx::XColumnsSupplier> xSupplyCols(xListCursor, staruno::UNO_QUERY);
+ DBG_ASSERT(xSupplyCols.is(), "OComboBoxModel::loadData : cursor supports the row set service but is no column supplier ??!");
+ staruno::Reference<starcontainer::XIndexAccess> xColumns;
+ if (xSupplyCols.is())
+ {
+ xColumns = staruno::Reference<starcontainer::XIndexAccess>(xSupplyCols->getColumns(), staruno::UNO_QUERY);
+ DBG_ASSERT(xColumns.is(), "OComboBoxModel::loadData : no columns supplied by the row set !");
+ }
+ staruno::Reference<starsdb::XColumn> xDataField;
+ if (xColumns.is())
+ xDataField = staruno::Reference<starsdb::XColumn>(*(InterfaceRef*)xColumns->getByIndex(0).getValue(), staruno::UNO_QUERY);
+ if (!xDataField.is())
+ {
+ disposeComponent(xListCursor);
+ return;
+ }
+
+ // Listen fuellen
+ sal_Int16 i = 0;
+ // per definitionem the list cursor is positioned _before_ the first row at the moment
+ while (xListCursor->next() && (i++<SHRT_MAX)) // max anzahl eintraege
+ {
+
+ aStringList.push_back(DBTypeConversion::getValue(xDataField,
+ m_xFormatter,
+ m_aNullDate,
+ m_nFormatKey,
+ m_nKeyType));
+ }
+ }
+ break;
+ case starform::ListSourceType_TABLEFIELDS:
+ {
+ staruno::Reference<starcontainer::XNameAccess> xFieldNames = getTableFields(xConnection, m_aListSource);
+ if (xFieldNames.is())
+ {
+ StringSequence seqNames = xFieldNames->getElementNames();
+ sal_Int32 nFieldsCount = seqNames.getLength();
+ const ::rtl::OUString* pustrNames = seqNames.getConstArray();
+
+ for (sal_Int32 k=0; k<nFieldsCount; ++k)
+ aStringList.push_back(pustrNames[k]);
+ }
+ }
+ break;
+ }
+ }
+ catch(starsdbc::SQLException& eSQL)
+ {
+ onError(eSQL, FRM_RES_STRING(RID_BASELISTBOX_ERROR_FILLLIST));
+ disposeComponent(xListCursor);
+ return;
+ }
+ catch(staruno::Exception& eUnknown)
+ {
+ eUnknown;
+ disposeComponent(xListCursor);
+ return;
+ }
+
+ // String-staruno::Sequence fuer ListBox erzeugen
+ StringSequence aStringSeq(aStringList.size());
+ ::rtl::OUString* pStringAry = aStringSeq.getArray();
+ for (sal_Int32 i = 0; i<aStringSeq.getLength(); ++i)
+ pStringAry[i] = aStringList[i];
+
+ // String-staruno::Sequence an ListBox setzen
+ m_xAggregateSet->setPropertyValue(PROPERTY_STRINGITEMLIST, staruno::makeAny(aStringSeq));
+
+ // Statement + Cursor zerstoeren
+ disposeComponent(xListCursor);
+}
+
+//------------------------------------------------------------------------------
+void OComboBoxModel::_loaded(const starlang::EventObject& rEvent)
+{
+ if (m_xField.is())
+ {
+ // jetzt den Key und typ ermitteln
+ m_xField->getPropertyValue(PROPERTY_FIELDTYPE) >>= m_nFieldType;
+ m_xField->getPropertyValue(PROPERTY_FORMATKEY) >>= m_nFormatKey;
+
+ // XNumberFormatter besorgen
+ staruno::Reference<starsdbc::XRowSet> xRowSet(rEvent.Source, staruno::UNO_QUERY);
+ DBG_ASSERT(xRowSet.is(), "OComboBoxModel::_loaded : invalid event source !");
+ staruno::Reference<starutil::XNumberFormatsSupplier> xSupplier = getNumberFormats(getConnection(xRowSet), sal_False, m_xServiceFactory);
+ if (xSupplier.is())
+ {
+ m_xFormatter = staruno::Reference<starutil::XNumberFormatter>(
+ m_xServiceFactory->createInstance(FRM_NUMBER_FORMATTER), staruno::UNO_QUERY
+ );
+ if (m_xFormatter.is())
+ m_xFormatter->attachNumberFormatsSupplier(xSupplier);
+
+ m_nKeyType = getNumberFormatType(xSupplier->getNumberFormats(), m_nFormatKey);
+ typeConvert(*(starutil::Date*)xSupplier->getNumberFormatSettings()->getPropertyValue(::rtl::OUString::createFromAscii("NullDate")).getValue(),
+ m_aNullDate);
+ }
+ }
+
+ // Daten nur laden, wenn eine Listenquelle angegeben wurde
+ if (m_aListSource.len() && m_xCursor.is())
+ loadData();
+}
+
+//------------------------------------------------------------------------------
+void OComboBoxModel::_unloaded()
+{
+ if (m_xField.is())
+ {
+ m_xFormatter = 0;
+ m_nFieldType = starsdbc::DataType::OTHER;
+ m_nFormatKey = 0;
+ m_nKeyType = starutil::NumberFormat::UNDEFINED;
+ m_aNullDate = STANDARD_DB_DATE;
+ }
+
+ // Zuruecksetzen der Inhalte (s.o)
+ if (m_aListSource.len() && m_xCursor.is())
+ {
+ StringSequence aSequence;
+ m_xAggregateSet->setPropertyValue(PROPERTY_STRINGITEMLIST, staruno::makeAny(aSequence));
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OComboBoxModel::reloaded( const starlang::EventObject& aEvent ) throw(staruno::RuntimeException)
+{
+ OBoundControlModel::reloaded(aEvent);
+
+ // reload data if we have a list source
+ if (m_aListSource.len() && m_xCursor.is())
+ loadData();
+}
+
+// XBoundComponent
+//------------------------------------------------------------------------------
+sal_Bool OComboBoxModel::_commit()
+{
+ ::rtl::OUString aNewValue;
+ m_xAggregateFastSet->getFastPropertyValue(OComboBoxModel::nTextHandle) >>= aNewValue;
+ if (aNewValue != m_aSaveValue)
+ {
+ if (!aNewValue.getLength() && !m_bRequired && m_bEmptyIsNull)
+ m_xColumnUpdate->updateNull();
+ else
+ {
+ try
+ {
+ DBTypeConversion::setValue(m_xColumnUpdate, m_xFormatter, m_aNullDate, aNewValue,
+ m_nFormatKey, m_nFieldType, m_nKeyType);
+ }
+ catch(...)
+ {
+ return sal_False;
+ }
+ }
+ m_aSaveValue = aNewValue;
+ }
+
+ // add the new value to the list
+ sal_Bool bAddToList = sal_True;
+ // (only if this is not the "commit" triggered by a "reset")
+ if (m_bResetting)
+ bAddToList = sal_False;
+
+ staruno::Any aAnyList = m_xAggregateSet->getPropertyValue(PROPERTY_STRINGITEMLIST);
+ if (bAddToList && aAnyList.getValueType().equals(::getCppuType(reinterpret_cast<StringSequence*>(NULL))))
+ {
+ StringSequence aStringItemList = *(StringSequence*)aAnyList.getValue();
+ const ::rtl::OUString* pStringItems = aStringItemList.getConstArray();
+ sal_Int32 i;
+ for (i=0; i<aStringItemList.getLength(); ++i, ++pStringItems)
+ {
+ if (pStringItems->equals(aNewValue))
+ break;
+ }
+ // not found -> add
+ if (i >= aStringItemList.getLength())
+ {
+ sal_Int32 nOldLen = aStringItemList.getLength();
+ aStringItemList.realloc(nOldLen + 1);
+ ::rtl::OUString* pStringItems = aStringItemList.getArray() + nOldLen;
+ *pStringItems = aNewValue;
+
+ aAnyList <<= aStringItemList;
+ m_xAggregateSet->setPropertyValue(PROPERTY_STRINGITEMLIST, aAnyList);
+ }
+ }
+
+ return sal_True;
+}
+
+// XPropertiesChangeListener
+//------------------------------------------------------------------------------
+void OComboBoxModel::_onValueChanged()
+{
+ // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
+ // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
+ // our own mutex locked
+ // and in this special case do it before calling DBTypeConversion::getValue, as this uses the number formatter
+ // which's implementation locks the SM, too :(
+ // FS - 72451 - 31.01.00
+ MutexRelease aRelease(m_aMutex);
+ DBG_ASSERT(m_xColumn.is(), "OComboBoxModel::_onValueChanged : have no column !");
+ m_aSaveValue = DBTypeConversion::getValue(m_xColumn,
+ m_xFormatter,
+ m_aNullDate,
+ m_nFormatKey,
+ m_nKeyType);
+
+ m_xAggregateFastSet->setFastPropertyValue(OComboBoxModel::nTextHandle, staruno::makeAny(m_aSaveValue));
+}
+
+//------------------------------------------------------------------------------
+void OComboBoxModel::_reset()
+{
+ { // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
+ // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
+ // our own mutex locked
+ // FS - 72451 - 31.01.00
+ MutexRelease aRelease(m_aMutex);
+ m_xAggregateFastSet->setFastPropertyValue(OComboBoxModel::nTextHandle, staruno::makeAny(m_aDefaultText));
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OComboBoxModel::addSQLErrorListener(const staruno::Reference<starsdb::XSQLErrorListener>& _rxListener) throw(staruno::RuntimeException)
+{
+ m_aErrorListeners.addInterface(_rxListener);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OComboBoxModel::removeSQLErrorListener(const staruno::Reference<starsdb::XSQLErrorListener>& _rxListener) throw(staruno::RuntimeException)
+{
+ m_aErrorListeners.removeInterface(_rxListener);
+}
+
+//------------------------------------------------------------------------------
+void OComboBoxModel::onError(starsdbc::SQLException& _rException, const ::rtl::OUString& _rContextDescription)
+{
+ starsdb::SQLContext aError = prependContextInfo(_rException, static_cast<staruno::XWeak*>(this), _rContextDescription);
+
+ if (m_aErrorListeners.getLength())
+ {
+ starsdb::SQLErrorEvent aEvent(static_cast<staruno::XWeak*>(this), staruno::makeAny(aError));
+
+ ::cppu::OInterfaceIteratorHelper aIter(m_aErrorListeners);
+ while (aIter.hasMoreElements())
+ static_cast<starsdb::XSQLErrorListener*>(aIter.next())->errorOccured(aEvent);
+ }
+}
+
+//========================================================================
+//= OComboBoxControl
+//========================================================================
+
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OComboBoxControl_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory) throw (staruno::RuntimeException)
+{
+ return *(new OComboBoxControl(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+OComboBoxControl::OComboBoxControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OBoundControl(_rxFactory, VCL_CONTROL_COMBOBOX)
+{
+}
+
+//------------------------------------------------------------------------------
+StringSequence SAL_CALL OComboBoxControl::getSupportedServiceNames() throw(staruno::RuntimeException)
+{
+ StringSequence aSupported = OBoundControl::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 1);
+
+ ::rtl::OUString* pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_COMBOBOX;
+ return aSupported;
+}
+
+//.........................................................................
+}
+//.........................................................................
+
diff --git a/forms/source/component/ComboBox.hxx b/forms/source/component/ComboBox.hxx
new file mode 100644
index 000000000000..c313b2eeec14
--- /dev/null
+++ b/forms/source/component/ComboBox.hxx
@@ -0,0 +1,199 @@
+/*************************************************************************
+ *
+ * $RCSfile: ComboBox.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:04 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_COMBOBOX_HXX_
+#define _FORMS_COMBOBOX_HXX_
+
+#ifndef _FORMS_FORMCOMPONENT_HXX_
+#include "FormComponent.hxx"
+#endif
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+#ifndef _DATE_HXX
+#include <tools/date.hxx>
+#endif
+#ifndef _SV_TIMER_HXX
+#include <vcl/timer.hxx>
+#endif
+
+#include <com/sun/star/util/XRefreshable.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#include <com/sun/star/sdb/XSQLErrorBroadcaster.hpp>
+#include <com/sun/star/form/ListSourceType.hpp>
+#include <com/sun/star/awt/XItemListener.hpp>
+#include <com/sun/star/awt/XFocusListener.hpp>
+#include <com/sun/star/form/XChangeBroadcaster.hpp>
+
+//.........................................................................
+namespace frm
+{
+
+//==================================================================
+// OComboBoxModel
+//==================================================================
+class OComboBoxModel
+ :public OBoundControlModel
+ ,public starsdb::XSQLErrorBroadcaster
+ ,public ::utl::OAggregationArrayUsageHelper< OComboBoxModel >
+{
+ staruno::Reference<starutil::XNumberFormatter> m_xFormatter;
+ starform::ListSourceType m_eListSourceType; // type der list source
+ staruno::Any m_aBoundColumn; // obsolet
+ ::rtl::OUString m_aListSource; //
+ ::rtl::OUString m_aDefaultText; // DefaultText
+ ::rtl::OUString m_aSaveValue;
+ sal_Int32 m_nFormatKey;
+ Date m_aNullDate;
+ sal_Int32 m_nFieldType;
+ sal_Int16 m_nKeyType;
+ sal_Bool m_bEmptyIsNull; // LeerString wird als NULL interpretiert
+
+ ::cppu::OInterfaceContainerHelper m_aErrorListeners;
+
+ static sal_Int32 nTextHandle;
+
+protected:
+ virtual void _onValueChanged();
+ virtual staruno::Sequence<staruno::Type> _getTypes();
+
+public:
+ OComboBoxModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+ ~OComboBoxModel();
+
+ virtual void SAL_CALL disposing();
+
+ // OPropertySetHelper
+ virtual void SAL_CALL getFastPropertyValue(staruno::Any& rValue, sal_Int32 nHandle) const;
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const staruno::Any& rValue )
+ throw (staruno::Exception);
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(
+ staruno::Any& _rConvertedValue, staruno::Any& _rOldValue, sal_Int32 _nHandle, const staruno::Any& _rValue )
+ throw (starlang::IllegalArgumentException);
+
+ // XLoadListener
+ virtual void _loaded(const starlang::EventObject& rEvent);
+ virtual void _unloaded();
+
+ virtual void SAL_CALL reloaded( const starlang::EventObject& aEvent ) throw(staruno::RuntimeException);
+
+ // XServiceInfo
+ IMPLEMENTATION_NAME(OComboBoxModel);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw(staruno::RuntimeException);
+
+ // UNO
+ DECLARE_UNO3_AGG_DEFAULTS(OComboBoxModel, OBoundControlModel);
+ virtual staruno::Any SAL_CALL queryAggregation( const staruno::Type& _rType ) throw (staruno::RuntimeException);
+
+ // XBoundComponent
+ virtual sal_Bool _commit();
+
+ // XPropertySet
+ virtual staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(staruno::RuntimeException);
+ virtual cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // XPersistObject
+ virtual ::rtl::OUString SAL_CALL getServiceName() throw(staruno::RuntimeException);
+ virtual void SAL_CALL
+ write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream) throw(stario::IOException, staruno::RuntimeException);
+ virtual void SAL_CALL
+ read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream) throw(stario::IOException, staruno::RuntimeException);
+
+ // XReset
+ virtual void _reset();
+
+ // XSQLErrorBroadcaster
+ virtual void SAL_CALL addSQLErrorListener(const staruno::Reference<starsdb::XSQLErrorListener>& _rxListener) throw(staruno::RuntimeException);
+ virtual void SAL_CALL removeSQLErrorListener(const staruno::Reference<starsdb::XSQLErrorListener>& _rxListener) throw(staruno::RuntimeException);
+
+ // OAggregationArrayUsageHelper
+ virtual void fillProperties(
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rProps,
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rAggregateProps
+ ) const;
+ IMPLEMENT_INFO_SERVICE()
+
+protected:
+ void loadData();
+
+ void onError(starsdbc::SQLException& _rException, const ::rtl::OUString& _rContextDescription);
+};
+
+//==================================================================
+// OComboBoxControl
+//==================================================================
+
+class OComboBoxControl : public OBoundControl
+{
+public:
+ OComboBoxControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+
+ // XServiceInfo
+ IMPLEMENTATION_NAME(OComboBoxControl);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw(staruno::RuntimeException);
+};
+
+//.........................................................................
+}
+//.........................................................................
+
+#endif // _FORMS_COMBOBOX_HXX_
+
diff --git a/forms/source/component/Currency.cxx b/forms/source/component/Currency.cxx
new file mode 100644
index 000000000000..f06d300a92fc
--- /dev/null
+++ b/forms/source/component/Currency.cxx
@@ -0,0 +1,295 @@
+/*************************************************************************
+ *
+ * $RCSfile: Currency.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:04 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_CURRENCY_HXX_
+#include "Currency.hxx"
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _TOOLS_INTN_HXX
+#include <tools/intn.hxx>
+#endif
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+//==================================================================
+// OCurrencyControl
+//==================================================================
+//------------------------------------------------------------------
+OCurrencyControl::OCurrencyControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OBoundControl(_rxFactory, VCL_CONTROL_CURRENCYFIELD)
+{
+}
+
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OCurrencyControl_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new OCurrencyControl(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> OCurrencyControl::_getTypes()
+{
+ return OBoundControl::_getTypes();
+}
+
+//------------------------------------------------------------------------------
+StringSequence SAL_CALL OCurrencyControl::getSupportedServiceNames() throw()
+{
+ StringSequence aSupported = OBoundControl::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 1);
+
+ ::rtl::OUString*pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_CURRENCYFIELD;
+ return aSupported;
+}
+
+//==================================================================
+// OCurrencyModel
+//==================================================================
+sal_Int32 OCurrencyModel::nValueHandle = -1;
+
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OCurrencyModel_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new OCurrencyModel(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> OCurrencyModel::_getTypes()
+{
+ return OEditBaseModel::_getTypes();
+}
+
+//------------------------------------------------------------------
+OCurrencyModel::OCurrencyModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OEditBaseModel(_rxFactory, VCL_CONTROLMODEL_CURRENCYFIELD, FRM_CONTROL_CURRENCYFIELD)
+ // use the old control name for compytibility reasons
+{
+ m_nClassId = starform::FormComponentType::CURRENCYFIELD;
+ m_sDataFieldConnectivityProperty = PROPERTY_VALUE;
+ if (OCurrencyModel::nValueHandle == -1)
+ OCurrencyModel::nValueHandle = getOriginalHandle(PROPERTY_ID_VALUE);
+
+ if (m_xAggregateSet.is())
+ {
+ try
+ {
+ // get the system international informations
+ International aSystemIntl(LANGUAGE_SYSTEM);
+ ::rtl::OUString sCurrencySymbol;
+ sal_Bool bPrependCurrencySymbol;
+ switch (aSystemIntl.GetCurrPositiveFormat())
+ {
+ case 0: // $1
+ sCurrencySymbol = UniString(aSystemIntl.GetCurrSymbol());
+ bPrependCurrencySymbol = sal_True;
+ break;
+ case 1: // 1$
+ sCurrencySymbol = UniString(aSystemIntl.GetCurrSymbol());
+ bPrependCurrencySymbol = sal_False;
+ break;
+ case 2: // $ 1
+ sCurrencySymbol = ::rtl::OUString(UniString(aSystemIntl.GetCurrSymbol())) + ::rtl::OUString::createFromAscii(" ");
+ bPrependCurrencySymbol = sal_True;
+ break;
+ case 3: // 1 $
+ sCurrencySymbol = ::rtl::OUString::createFromAscii(" ") + ::rtl::OUString(UniString(aSystemIntl.GetCurrSymbol()));
+ bPrependCurrencySymbol = sal_False;
+ break;
+ }
+ if (sCurrencySymbol.getLength())
+ {
+ m_xAggregateSet->setPropertyValue(PROPERTY_CURRENCYSYMBOL, staruno::makeAny(sCurrencySymbol));
+ m_xAggregateSet->setPropertyValue(PROPERTY_CURRSYM_POSITION, staruno::makeAny(bPrependCurrencySymbol));
+ }
+ }
+ catch(...)
+ {
+ }
+ }
+}
+
+//------------------------------------------------------------------
+OCurrencyModel::~OCurrencyModel()
+{
+}
+
+// starlang::XServiceInfo
+//------------------------------------------------------------------------------
+StringSequence SAL_CALL OCurrencyModel::getSupportedServiceNames() throw()
+{
+ StringSequence aSupported = OBoundControlModel::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 2);
+
+ ::rtl::OUString*pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-2] = ::rtl::OUString::createFromAscii("com.sun.star.form.component.DatabaseCurrencyField");
+ pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_CURRENCYFIELD;
+ return aSupported;
+}
+
+//------------------------------------------------------------------------------
+staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL OCurrencyModel::getPropertySetInfo() throw( staruno::RuntimeException )
+{
+ staruno::Reference<starbeans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//------------------------------------------------------------------------------
+void OCurrencyModel::fillProperties(
+ staruno::Sequence< starbeans::Property >& _rProps,
+ staruno::Sequence< starbeans::Property >& _rAggregateProps ) const
+{
+ FRM_BEGIN_PROP_HELPER(10)
+ // Value auf transient setzen
+// ModifyPropertyAttributes(_rAggregateProps, PROPERTY_VALUE, starbeans::PropertyAttribute::TRANSIENT, 0);
+
+ DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT);
+ DECL_PROP3(DEFAULT_VALUE, double, BOUND, MAYBEDEFAULT, MAYBEVOID);
+ DECL_PROP1(NAME, ::rtl::OUString, BOUND);
+ DECL_PROP1(TAG, ::rtl::OUString, BOUND);
+ DECL_PROP1(TABINDEX, sal_Int16, BOUND);
+ DECL_PROP1(CONTROLSOURCE, ::rtl::OUString, BOUND);
+ DECL_PROP1(HELPTEXT, ::rtl::OUString, BOUND);
+ DECL_IFACE_PROP2(BOUNDFIELD, starbeans::XPropertySet, READONLY, TRANSIENT);
+ DECL_IFACE_PROP2(CONTROLLABEL, starbeans::XPropertySet, BOUND, MAYBEVOID);
+ DECL_PROP2(CONTROLSOURCEPROPERTY, rtl::OUString, READONLY, TRANSIENT);
+ FRM_END_PROP_HELPER();
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OCurrencyModel::getInfoHelper()
+{
+ return *const_cast<OCurrencyModel*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OCurrencyModel::getServiceName()
+{
+ return FRM_COMPONENT_CURRENCYFIELD; // old (non-sun) name for compatibility !
+}
+
+// starform::XBoundComponent
+//------------------------------------------------------------------------------
+sal_Bool OCurrencyModel::_commit()
+{
+ staruno::Any aNewValue = m_xAggregateFastSet->getFastPropertyValue( OCurrencyModel::nValueHandle );
+ if (!compare(aNewValue, m_aSaveValue))
+ {
+ if (aNewValue.getValueType().getTypeClass() == staruno::TypeClass_VOID)
+ m_xColumnUpdate->updateNull();
+ else
+ {
+ try
+ {
+ m_xColumnUpdate->updateDouble(getDouble(aNewValue));
+ }
+ catch(...)
+ {
+ return sal_False;
+ }
+ }
+ m_aSaveValue = aNewValue;
+ }
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+void OCurrencyModel::_onValueChanged()
+{
+ m_aSaveValue <<= m_xColumn->getDouble();
+ if (m_xColumn->wasNull())
+ m_aSaveValue.clear();
+ { // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
+ // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
+ // our own mutex locked
+ // FS - 72451 - 31.01.00
+ MutexRelease aRelease(m_aMutex);
+ m_xAggregateFastSet->setFastPropertyValue(OCurrencyModel::nValueHandle, m_aSaveValue);
+ }
+}
+
+// starform::XReset
+//------------------------------------------------------------------------------
+void OCurrencyModel::_reset( void )
+{
+ staruno::Any aValue;
+ if (m_aDefault.getValueType().getTypeClass() == staruno::TypeClass_DOUBLE)
+ aValue = m_aDefault;
+
+ { // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
+ // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
+ // our own mutex locked
+ // FS - 72451 - 31.01.00
+ MutexRelease aRelease(m_aMutex);
+ m_xAggregateFastSet->setFastPropertyValue(OCurrencyModel::nValueHandle, aValue);
+ }
+}
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
diff --git a/forms/source/component/Currency.hxx b/forms/source/component/Currency.hxx
new file mode 100644
index 000000000000..6ebab3bddb20
--- /dev/null
+++ b/forms/source/component/Currency.hxx
@@ -0,0 +1,138 @@
+/*************************************************************************
+ *
+ * $RCSfile: Currency.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:04 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_CURRENCY_HXX_
+#define _FORMS_CURRENCY_HXX_
+
+#ifndef _FORMS_EDITBASE_HXX_
+#include "EditBase.hxx"
+#endif
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+//==================================================================
+//= OCurrencyModel
+//==================================================================
+class OCurrencyModel
+ :public OEditBaseModel
+ ,public ::utl::OAggregationArrayUsageHelper< OCurrencyModel >
+{
+ staruno::Any m_aSaveValue;
+
+ static sal_Int32 nValueHandle;
+
+protected:
+ virtual void _onValueChanged();
+ virtual staruno::Sequence<staruno::Type> _getTypes();
+
+public:
+ OCurrencyModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+ virtual ~OCurrencyModel();
+
+ // starform::XBoundComponent
+ virtual sal_Bool _commit();
+
+ // starlang::XServiceInfo
+ IMPLEMENTATION_NAME(OCurrencyModel);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
+
+ // staruno::Reference<starbeans::XPropertySet>
+ virtual staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(staruno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // stario::XPersistObject
+ virtual ::rtl::OUString SAL_CALL getServiceName();
+
+ // starform::XReset
+ virtual void _reset();
+
+ // OAggregationArrayUsageHelper
+ virtual void fillProperties(
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rProps,
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rAggregateProps
+ ) const;
+ IMPLEMENT_INFO_SERVICE()
+};
+
+//==================================================================
+//= OCurrencyControl
+//==================================================================
+class OCurrencyControl: public OBoundControl
+{
+protected:
+ virtual staruno::Sequence<staruno::Type> _getTypes();
+
+public:
+ OCurrencyControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+ // starlang::XServiceInfo
+ IMPLEMENTATION_NAME(OCurrencyControl);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
+};
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
+#endif // _FORMS_CURRENCY_HXX_
+
diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx
new file mode 100644
index 000000000000..5decff5ff1f8
--- /dev/null
+++ b/forms/source/component/DatabaseForm.cxx
@@ -0,0 +1,3904 @@
+/*************************************************************************
+ *
+ * $RCSfile: DatabaseForm.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+
+#ifndef _FRM_DATABASEFORM_HXX_
+#include "DatabaseForm.hxx"
+#endif
+#ifndef _FRM_EVENT_THREAD_HXX_
+#include "EventThread.hxx"
+#endif
+#ifndef _FORMS_LISTBOX_HXX_
+#include "ListBox.hxx"
+#endif
+#ifndef _FRM_RESOURCE_HXX_
+#include "frm_resource.hxx"
+#endif
+#ifndef _FRM_RESOURCE_HRC_
+#include "frm_resource.hrc"
+#endif
+
+#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_
+#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XCANCELLABLE_HPP_
+#include <com/sun/star/util/XCancellable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DATA_DATABASECURSORTYPE_HPP_
+#include <com/sun/star/data/DatabaseCursorType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XOBJECTINPUTSTREAM_HPP_
+#include <com/sun/star/io/XObjectInputStream.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XOBJECTOUTPUTSTREAM_HPP_
+#include <com/sun/star/io/XObjectOutputStream.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_DATASELECTIONTYPE_HPP_
+#include <com/sun/star/form/DataSelectionType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
+#include <com/sun/star/sdb/SQLContext.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_FORMCOMPONENTTYPE_HPP_
+#include <com/sun/star/form/FormComponentType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDER_HPP_
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XDISPATCH_HPP_
+#include <com/sun/star/frame/XDispatch.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
+#include <com/sun/star/frame/XModel.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
+#include <com/sun/star/sdb/CommandType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_ROWSETVETOEXCEPTION_HPP_
+#include <com/sun/star/sdb/RowSetVetoException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XPARAMETERSSUPPLIER_HPP_
+#include <com/sun/star/sdb/XParametersSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROWSET_HPP_
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_TABULATORCYCLE_HPP_
+#include <com/sun/star/form/TabulatorCycle.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XCONTROLCONTAINER_HPP_
+#include <com/sun/star/awt/XControlContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XTEXTCOMPONENT_HPP_
+#include <com/sun/star/awt/XTextComponent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XURLTRANSFORMER_HPP_
+#include <com/sun/star/util/XURLTransformer.hpp>
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#ifndef _SV_TIMER_HXX
+#include <vcl/timer.hxx>
+#endif
+
+#ifndef _FRM_GROUPMANAGER_HXX_
+#include "GroupManager.hxx"
+#endif
+
+#ifndef _FRM_PROPERTY_HRC_
+#include "property.hrc"
+#endif
+#ifndef _FRM_PROPERTY_HXX_
+#include "property.hxx"
+#endif
+#ifndef _FRM_SERVICES_HXX_
+#include "services.hxx"
+#endif
+#ifndef _FRM_IDS_HXX_
+#include "ids.hxx"
+#endif
+
+#ifndef _FSYS_HXX
+#include <tools/fsys.hxx>
+#endif
+#ifndef _TOOLS_INETMSG_HXX
+#include <tools/inetmsg.hxx>
+#endif
+#ifndef _INETSTRM_HXX //autogen
+#include <svtools/inetstrm.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx>
+#endif
+#ifndef _UTL_STLTYPES_HXX_
+#include <unotools/stl_types.hxx>
+#endif
+#ifndef _UTL_SEQUENCE_HXX_
+#include <unotools/sequence.hxx>
+#endif
+#ifndef _UTL_STLTYPES_HXX_
+#include <unotools/stl_types.hxx>
+#endif
+#ifndef _UTL_UNO3_HXX_
+#include <unotools/uno3.hxx>
+#endif
+#ifndef _UNOTOOLS_ENUMHELPER_HXX_
+#include <unotools/enumhelper.hxx>
+#endif
+#ifndef _UTL_CONTAINER_HXX_
+#include <unotools/container.hxx>
+#endif
+#ifndef _UTL_UNO3_DB_TOOLS_HXX_
+#include <unotools/dbtools.hxx>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+#ifndef _TOOLS_SOLMATH_HXX
+#include <tools/solmath.hxx>
+#endif
+#ifndef _DATE_HXX
+#include <tools/Date.hxx>
+#endif
+#ifndef _TOOLS_TIME_HXX
+#include <tools/Time.hxx>
+#endif
+#ifndef _DATETIME_HXX
+#include <tools/DateTime.hxx>
+#endif
+#ifndef _INETTYPE_HXX
+#include <svtools/inettype.hxx>
+#endif
+#ifndef _CPPUHELPER_EXTRACT_HXX_
+#include <cppuhelper/extract.hxx>
+#endif
+#ifndef _VOS_MUTEX_HXX_
+#include <vos/mutex.hxx>
+#endif
+#ifndef _SV_SVAPP_HXX // because of the solar mutex
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _RTL_TENCINFO_H
+#include <rtl/tencinfo.h>
+#endif
+
+#define DATABASEFORM_IMPLEMENTATION_NAME ::rtl::OUString::createFromAscii("com.sun.star.form.component.ODatabaseForm")
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+ namespace starframe = ::com::sun::star::frame;
+ namespace stardata = ::com::sun::star::data;
+
+//------------------------------------------------------------------
+staruno::Reference< starframe::XModel> getXModel(const staruno::Reference< staruno::XInterface>& xIface)
+{
+ staruno::Reference< starframe::XModel> xModel(xIface, staruno::UNO_QUERY);
+ if (xModel.is())
+ return xModel;
+ else
+ {
+ staruno::Reference< starcontainer::XChild> xChild(xIface, staruno::UNO_QUERY);
+ if (xChild.is())
+ {
+ staruno::Reference< staruno::XInterface> xParent( xChild->getParent());
+ return getXModel(xParent);
+ }
+ else
+ return NULL;
+ }
+}
+
+//==================================================================
+//= OParameterWrapper
+//=-----------------------------------------------------------------
+//= wraps a parameter property set got from an starsdb::SQLQueryComposer
+//= so it has an additional property "Value", which is forwarded to
+//= an starsdbc::XParameters interface
+//==================================================================
+
+class OParameterWrapper
+ :public ::cppu::OWeakObject
+ ,public ::cppu::OPropertySetHelper
+ ,public ::utl::OAggregationArrayUsageHelper<OParameterWrapper>
+{
+ staruno::Any m_aValue;
+ ::osl::Mutex m_aMutex;
+ ::cppu::OBroadcastHelper m_aBroadcastHelper;
+ OImplementationIdsRef m_aHoldIdHelper;
+
+ staruno::Reference<starbeans::XPropertySet> m_xPseudoAggregate;
+ staruno::Reference<starsdbc::XParameters> m_xValueDestination;
+ sal_Int32 m_nIndex;
+
+
+ virtual ~OParameterWrapper();
+public:
+ OParameterWrapper(const staruno::Reference<starbeans::XPropertySet>& _rxColumn, const staruno::Reference<starsdbc::XParameters>& _rxAllParameters, sal_Int32 _nIndex);
+
+ // UNO
+ DECLARE_UNO3_DEFAULTS(OParameterWrapper, OWeakObject);
+ virtual staruno::Any SAL_CALL queryInterface(const staruno::Type& _rType) throw (staruno::RuntimeException);
+ virtual staruno::Sequence<sal_Int8> SAL_CALL getImplementationId() throw(staruno::RuntimeException);
+ virtual staruno::Sequence<staruno::Type> SAL_CALL getTypes() throw(staruno::RuntimeException);
+
+ // starbeans::XPropertySet
+ virtual staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw( staruno::RuntimeException );
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // OPropertySetHelper
+ virtual sal_Bool SAL_CALL convertFastPropertyValue( staruno::Any& rConvertedValue, staruno::Any& rOldValue, sal_Int32 nHandle, const staruno::Any& rValue) throw( starlang::IllegalArgumentException );
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const staruno::Any& rValue ) throw( staruno::Exception );
+ virtual void SAL_CALL getFastPropertyValue( staruno::Any& rValue, sal_Int32 nHandle ) const;
+
+ // OAggregationArrayUsageHelper
+ virtual void fillProperties(
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rProps,
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rAggregateProps
+ ) const;
+
+protected:
+ ::rtl::OUString getPseudoAggregatePropertyName(sal_Int32 _nHandle) const;
+};
+
+DBG_NAME(OParameterWrapper)
+//------------------------------------------------------------------------------
+OParameterWrapper::OParameterWrapper(const staruno::Reference<starbeans::XPropertySet>& _rxColumn, const staruno::Reference<starsdbc::XParameters>& _rxAllParameters, sal_Int32 _nIndex)
+ :OPropertySetHelper(m_aBroadcastHelper)
+ ,m_aBroadcastHelper(m_aMutex)
+ ,m_xPseudoAggregate(_rxColumn)
+ ,m_xValueDestination(_rxAllParameters)
+ ,m_nIndex(_nIndex)
+{
+ DBG_CTOR(OParameterWrapper, NULL);
+}
+
+//------------------------------------------------------------------------------
+OParameterWrapper::~OParameterWrapper()
+{
+ DBG_DTOR(OParameterWrapper, NULL);
+}
+
+//------------------------------------------------------------------------------
+staruno::Any SAL_CALL OParameterWrapper::queryInterface(const staruno::Type& _rType) throw (staruno::RuntimeException)
+{
+ staruno::Any aReturn;
+ aReturn = OWeakObject::queryInterface(_rType);
+
+ if (!aReturn.hasValue())
+ OPropertySetHelper::queryInterface(_rType);
+
+ return aReturn;
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence< staruno::Type > SAL_CALL OParameterWrapper::getTypes( ) throw(staruno::RuntimeException)
+{
+ staruno::Sequence< staruno::Type > aWeakTypes(1);
+ aWeakTypes.getArray()[0] = ::getCppuType(static_cast<staruno::Reference<staruno::XWeak>*>(NULL));
+
+ staruno::Sequence< staruno::Type > aPropertyTypes(3);
+ aPropertyTypes.getArray()[0] = ::getCppuType(static_cast<staruno::Reference<starbeans::XPropertySet>*>(NULL));
+ aPropertyTypes.getArray()[1] = ::getCppuType(static_cast<staruno::Reference<starbeans::XFastPropertySet>*>(NULL));
+ aPropertyTypes.getArray()[2] = ::getCppuType(static_cast<staruno::Reference<starbeans::XMultiPropertySet>*>(NULL));
+
+ return concatSequences(aWeakTypes, aPropertyTypes);
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<sal_Int8> SAL_CALL OParameterWrapper::getImplementationId() throw(staruno::RuntimeException)
+{
+ staruno::Reference<starlang::XTypeProvider> xMyTpes;
+ query_interface(static_cast<staruno::XWeak*>(this), xMyTpes);
+ return OImplementationIds::getImplementationId(xMyTpes);
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString OParameterWrapper::getPseudoAggregatePropertyName(sal_Int32 _nHandle) const
+{
+ staruno::Reference<starbeans::XPropertySetInfo> xInfo = const_cast<OParameterWrapper*>(this)->getPropertySetInfo();
+ staruno::Sequence<starbeans::Property> aProperties = xInfo->getProperties();
+ const starbeans::Property* pProperties = aProperties.getConstArray();
+ for (sal_Int32 i=0; i<aProperties.getLength(); ++i, ++pProperties)
+ {
+ if (pProperties->Handle == _nHandle)
+ return pProperties->Name;
+ }
+
+ DBG_ERROR("OParameterWrapper::getPseudoAggregatePropertyName : invalid argument !");
+ return ::rtl::OUString();
+}
+
+//------------------------------------------------------------------------------
+staruno::Reference<starbeans::XPropertySetInfo> OParameterWrapper::getPropertySetInfo() throw( staruno::RuntimeException )
+{
+ staruno::Reference<starbeans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//------------------------------------------------------------------------------
+void OParameterWrapper::fillProperties(
+ staruno::Sequence< starbeans::Property >& _rProps,
+ staruno::Sequence< starbeans::Property >& _rAggregateProps ) const
+{
+ BEGIN_AGGREGATION_PROPERTY_HELPER(1, m_xPseudoAggregate)
+ DECL_PROP2(VALUE, ::rtl::OUString, TRANSIENT, MAYBEVOID);
+ END_AGGREGATION_PROPERTY_HELPER();
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OParameterWrapper::getInfoHelper()
+{
+ return *const_cast<OParameterWrapper*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OParameterWrapper::convertFastPropertyValue(staruno::Any& rConvertedValue, staruno::Any& rOldValue, sal_Int32 nHandle, const staruno::Any& rValue) throw( starlang::IllegalArgumentException )
+{
+ DBG_ASSERT(PROPERTY_ID_VALUE == nHandle, "OParameterWrapper::convertFastPropertyValue : the only non-readonly prop should be our PROPERTY_VALUE");
+ // we're lazy here ...
+ rOldValue = m_aValue;
+ rConvertedValue = rValue;
+ return sal_True; // assume "modified" ...
+}
+
+//------------------------------------------------------------------------------
+void OParameterWrapper::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const staruno::Any& rValue ) throw( staruno::Exception )
+{
+ if (nHandle == PROPERTY_ID_VALUE)
+ {
+ // get the type of the param
+ staruno::Any aParamType = m_xPseudoAggregate->getPropertyValue(PROPERTY_FIELDTYPE);
+ DBG_ASSERT(aParamType.getValueType().getTypeClass() == staruno::TypeClass_LONG, "ODatabaseForm::setPropertyValue : invalid parameter field !");
+ sal_Int32 nScale = 0;
+ if (hasProperty(PROPERTY_SCALE, m_xPseudoAggregate))
+ {
+ staruno::Any aScale = m_xPseudoAggregate->getPropertyValue(PROPERTY_SCALE);
+ DBG_ASSERT(aScale.getValueType().getTypeClass() == staruno::TypeClass_LONG, "ODatabaseForm::setPropertyValue : invalid parameter field !");
+ nScale = getINT32(aScale);
+ }
+ // TODO : aParamType & nScale can be obtained within the constructor ....
+
+ try
+ {
+ m_xValueDestination->setObjectWithInfo(m_nIndex + 1, rValue, getINT32(aParamType), nScale);
+ // the index of the parameters is one-based
+ m_aValue = rValue;
+ }
+ catch(starsdbc::SQLException& e)
+ {
+ starlang::WrappedTargetException aExceptionWrapper;
+ aExceptionWrapper.Context = e.Context;
+ aExceptionWrapper.Message = e.Message;
+ aExceptionWrapper.TargetException <<= e;
+ throw starlang::WrappedTargetException(aExceptionWrapper);
+ }
+ }
+ else
+ {
+ ::rtl::OUString aName = getPseudoAggregatePropertyName(nHandle);
+ m_xPseudoAggregate->setPropertyValue(aName, rValue);
+ }
+}
+
+//------------------------------------------------------------------------------
+void OParameterWrapper::getFastPropertyValue( staruno::Any& rValue, sal_Int32 nHandle ) const
+{
+ if (nHandle == PROPERTY_ID_VALUE)
+ {
+ rValue = m_aValue;
+ }
+ else
+ {
+ ::rtl::OUString aName = getPseudoAggregatePropertyName(nHandle);
+ rValue = m_xPseudoAggregate->getPropertyValue(aName);
+ }
+}
+
+//==================================================================
+//= OParametersImpl
+//=-----------------------------------------------------------------
+//= class for the parameter event see approveParameter
+//==================================================================
+
+typedef ::cppu::WeakImplHelper2<starcontainer::XIndexAccess, starcontainer::XEnumerationAccess> OParametersImplBase;
+class OParametersImpl : public OParametersImplBase
+{
+public:
+ typedef ::std::vector<staruno::Reference<starbeans::XPropertySet> > Parameters;
+ typedef Parameters::iterator ParametersIterator;
+
+private:
+ Parameters m_aParameters;
+
+public:
+ // UNO
+ DECLARE_UNO3_AGG_DEFAULTS(OParametersImpl, OParametersImplBase);
+
+ // XElementAccess
+ virtual staruno::Type SAL_CALL getElementType() throw( staruno::RuntimeException );
+ virtual sal_Bool SAL_CALL hasElements() throw( staruno::RuntimeException );
+
+ // XEnumerationAccess
+ virtual staruno::Reference<starcontainer::XEnumeration> SAL_CALL createEnumeration() throw( staruno::RuntimeException );
+
+ // XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount() throw( staruno::RuntimeException );
+ virtual staruno::Any SAL_CALL getByIndex(sal_Int32 _rIndex) throw( starlang::IndexOutOfBoundsException, starlang::WrappedTargetException, staruno::RuntimeException );
+
+ Parameters& getParameters() { return m_aParameters; }
+};
+
+// starcontainer::XElementAccess
+//------------------------------------------------------------------------------
+staruno::Type SAL_CALL OParametersImpl::getElementType() throw( staruno::RuntimeException )
+{
+ return ::getCppuType(static_cast<staruno::Reference<starbeans::XPropertySet>*>(NULL));
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL OParametersImpl::hasElements() throw( staruno::RuntimeException )
+{
+ return m_aParameters.size() != 0;
+}
+
+// starcontainer::XIndexAccess
+//------------------------------------------------------------------------------
+sal_Int32 SAL_CALL OParametersImpl::getCount() throw( staruno::RuntimeException )
+{
+ return m_aParameters.size();
+}
+
+//------------------------------------------------------------------------------
+staruno::Any SAL_CALL OParametersImpl::getByIndex(sal_Int32 _nIndex) throw( starlang::IndexOutOfBoundsException, starlang::WrappedTargetException, staruno::RuntimeException )
+{
+ if (_nIndex < 0 ||
+ _nIndex >= m_aParameters.size())
+ throw starlang::IndexOutOfBoundsException();
+
+ return staruno::makeAny(m_aParameters[_nIndex]);
+}
+
+// starcontainer::XEnumerationAccess
+//------------------------------------------------------------------------------
+staruno::Reference<starcontainer::XEnumeration> OParametersImpl::createEnumeration() throw( staruno::RuntimeException )
+{
+ return new OEnumerationByIndex(reinterpret_cast<starcontainer::XIndexAccess*>(this));
+}
+
+//==================================================================
+//= OParameterInfoImpl
+//=-----------------------------------------------------------------
+//= class which collects all information for parameter filling
+//==================================================================
+DECLARE_STL_USTRINGACCESS_MAP(sal_Int32, MapUString2INT32);
+
+struct OParameterInfoImpl
+{
+ sal_Int32 nCount; // Number of Parameters
+ staruno::Reference<starsdb::XSQLQueryComposer> xComposer;
+ staruno::Reference<starcontainer::XNameAccess> xParamsAsNames;
+ OParametersImpl* pParameters;
+ MapUString2INT32 aParamMapping;
+
+ OParameterInfoImpl():nCount(0),pParameters(NULL){}
+ ~OParameterInfoImpl()
+ {
+ if (pParameters)
+ pParameters->release();
+ }
+};
+
+//==================================================================
+//= OFormSubmitResetThread
+//=-----------------------------------------------------------------
+//= submitting and resetting html-forms asynchronously
+//==================================================================
+
+//------------------------------------------------------------------
+class OFormSubmitResetThread: public OComponentEventThread
+{
+protected:
+
+ // duplicate an event with respect to it's type
+ virtual starlang::EventObject *cloneEvent( const starlang::EventObject *pEvt ) const;
+
+ // process an event. while processing the mutex isn't locked, and pCompImpl
+ // is made sure to remain valid
+ virtual void processEvent( ::cppu::OComponentHelper* _pCompImpl,
+ const starlang::EventObject* _pEvt,
+ const staruno::Reference<starawt::XControl>& _rControl,
+ sal_Bool _bSubmit);
+
+public:
+
+ OFormSubmitResetThread(ODatabaseForm* pControl) : OComponentEventThread(pControl) { }
+};
+
+//------------------------------------------------------------------
+starlang::EventObject* OFormSubmitResetThread::cloneEvent(
+ const starlang::EventObject *pEvt ) const
+{
+ return new starawt::MouseEvent( *(starawt::MouseEvent *)pEvt );
+}
+
+//------------------------------------------------------------------
+void OFormSubmitResetThread::processEvent(
+ ::cppu::OComponentHelper* pCompImpl,
+ const starlang::EventObject *_pEvt,
+ const staruno::Reference<starawt::XControl>& _rControl,
+ sal_Bool _bSubmit)
+{
+ if (_bSubmit)
+ ((ODatabaseForm *)pCompImpl)->submit_impl(_rControl, *reinterpret_cast<const starawt::MouseEvent*>(_pEvt), true);
+ else
+ ((ODatabaseForm *)pCompImpl)->reset_impl(true);
+}
+
+//==================================================================
+//= ODatabaseForm
+//==================================================================
+
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL ODatabaseForm_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new ODatabaseForm(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<sal_Int8> SAL_CALL ODatabaseForm::getImplementationId() throw(staruno::RuntimeException)
+{
+ return OImplementationIds::getImplementationId(getTypes());
+}
+
+//------------------------------------------------------------------
+staruno::Sequence<staruno::Type> SAL_CALL ODatabaseForm::getTypes() throw(staruno::RuntimeException)
+{
+ // ask the aggregate
+ staruno::Sequence<staruno::Type> aAggregateTypes;
+ staruno::Reference<starlang::XTypeProvider> xAggregateTypes;
+ if (query_aggregation(m_xAggregate, xAggregateTypes))
+ aAggregateTypes = xAggregateTypes->getTypes();
+
+ staruno::Sequence<staruno::Type> aOwnTypes(23);
+ aOwnTypes.getArray()[0] = ::getCppuType(static_cast<staruno::Reference<starbeans::XFastPropertySet>*>(NULL));
+ aOwnTypes.getArray()[1] = ::getCppuType(static_cast<staruno::Reference<starbeans::XMultiPropertySet>*>(NULL));
+ aOwnTypes.getArray()[2] = ::getCppuType(static_cast<staruno::Reference<starbeans::XPropertySet>*>(NULL));
+ aOwnTypes.getArray()[3] = ::getCppuType(static_cast<staruno::Reference<starbeans::XPropertyState>*>(NULL));
+ aOwnTypes.getArray()[4] = ::getCppuType(static_cast<staruno::Reference<starsdb::XSQLErrorBroadcaster>*>(NULL));
+ aOwnTypes.getArray()[5] = ::getCppuType(static_cast<staruno::Reference<starform::XForm>*>(NULL));
+ aOwnTypes.getArray()[6] = ::getCppuType(static_cast<staruno::Reference<starawt::XTabControllerModel>*>(NULL));
+ aOwnTypes.getArray()[7] = ::getCppuType(static_cast<staruno::Reference<starform::XReset>*>(NULL));
+ aOwnTypes.getArray()[8] = ::getCppuType(static_cast<staruno::Reference<starform::XSubmit>*>(NULL));
+ aOwnTypes.getArray()[9] = ::getCppuType(static_cast<staruno::Reference<starform::XLoadListener>*>(NULL));
+ aOwnTypes.getArray()[10] = ::getCppuType(static_cast<staruno::Reference<starform::XLoadable>*>(NULL));
+ aOwnTypes.getArray()[11] = ::getCppuType(static_cast<staruno::Reference<starsdbc::XCloseable>*>(NULL));
+ aOwnTypes.getArray()[12] = ::getCppuType(static_cast<staruno::Reference<starsdbc::XRowSet>*>(NULL));
+ aOwnTypes.getArray()[13] = ::getCppuType(static_cast<staruno::Reference<starsdbc::XRowSetListener>*>(NULL));
+ aOwnTypes.getArray()[14] = ::getCppuType(static_cast<staruno::Reference<starsdb::XRowSetApproveListener>*>(NULL));
+ aOwnTypes.getArray()[15] = ::getCppuType(static_cast<staruno::Reference<starsdb::XRowSetApproveBroadcaster>*>(NULL));
+ aOwnTypes.getArray()[16] = ::getCppuType(static_cast<staruno::Reference<starsdbc::XResultSetUpdate>*>(NULL));
+ aOwnTypes.getArray()[17] = ::getCppuType(static_cast<staruno::Reference<starsdbcx::XDeleteRows>*>(NULL));
+ aOwnTypes.getArray()[18] = ::getCppuType(static_cast<staruno::Reference<starsdbc::XParameters>*>(NULL));
+ aOwnTypes.getArray()[19] = ::getCppuType(static_cast<staruno::Reference<starform::XDatabaseParameterBroadcaster>*>(NULL));
+ aOwnTypes.getArray()[20] = ::getCppuType(static_cast<staruno::Reference<starsdb::XSQLErrorListener>*>(NULL));
+ aOwnTypes.getArray()[21] = ::getCppuType(static_cast<staruno::Reference<starcontainer::XNamed>*>(NULL));
+ aOwnTypes.getArray()[22] = ::getCppuType(static_cast<staruno::Reference<starlang::XServiceInfo>*>(NULL));
+
+ return concatSequences(aAggregateTypes, aOwnTypes, OFormComponents::getTypes());
+}
+
+//------------------------------------------------------------------
+staruno::Any SAL_CALL ODatabaseForm::queryAggregation(const staruno::Type& _rType) throw(staruno::RuntimeException)
+{
+ staruno::Any aReturn;
+ // our own interfaces
+ aReturn = ::cppu::queryInterface(_rType,
+ static_cast<starform::XForm*>(this),
+ static_cast<starawt::XTabControllerModel*>(this),
+ static_cast<starform::XLoadListener*>(this),
+ static_cast<starform::XLoadable*>(this),
+ static_cast<starsdbc::XRowSetListener*>(this),
+ static_cast<starsdb::XRowSetApproveListener*>(this),
+ static_cast<starform::XDatabaseParameterBroadcaster*>(this),
+ static_cast<starsdb::XSQLErrorListener*>(this),
+ static_cast<starsdb::XSQLErrorBroadcaster*>(this),
+ static_cast<stario::XPersistObject*>(this),
+ static_cast<starform::XReset*>(this),
+ static_cast<starform::XSubmit*>(this)
+ );
+ if (!aReturn.hasValue())
+ aReturn = ::cppu::queryInterface(_rType,
+ static_cast<starcontainer::XNamed*>(this),
+ static_cast<starlang::XServiceInfo*>(this),
+ static_cast<starlang::XEventListener*>(static_cast<starform::XLoadListener*>(this))
+ );
+ // interfaces already present in the aggregate which we want to reroute
+ // only available if we could create the aggregate
+ if (!aReturn.hasValue() && m_xAggregateAsRowSet.is())
+ aReturn = ::cppu::queryInterface(_rType,
+ static_cast<starsdb::XRowSetApproveBroadcaster*>(this),
+ static_cast<starsdbc::XRowSet*>(this),
+ static_cast<starsdbc::XResultSetUpdate*>(this),
+ static_cast<starsdbc::XResultSet*>(this),
+ static_cast<starsdbc::XCloseable*>(this),
+ static_cast<starsdbcx::XDeleteRows*>(this),
+ static_cast<starsdbc::XParameters*>(this)
+ );
+
+ // property set related interfaces
+ if (!aReturn.hasValue())
+ aReturn = OPropertySetAggregationHelper::queryInterface(_rType);
+
+ // form component collection related interfaces
+ if (!aReturn.hasValue())
+ aReturn = OFormComponents::queryAggregation(_rType);
+
+ // aggregate interfaces
+ // (ask the aggregated object _after_ the OComponentHelper (base of OFormComponents),
+ // so calls to the starlang::XComponent interface reach us and not the aggreagtion)
+ if (!aReturn.hasValue() && m_xAggregate.is())
+ aReturn = m_xAggregate->queryAggregation(_rType);
+
+ return aReturn;
+}
+
+DBG_NAME(ODatabaseForm);
+//------------------------------------------------------------------
+ODatabaseForm::ODatabaseForm(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OFormComponents(_rxFactory)
+ ,OPropertySetAggregationHelper(OComponentHelper::rBHelper)
+ ,OPropertyChangeListener(m_aMutex)
+ ,m_aLoadListeners(m_aMutex)
+ ,m_aRowSetApproveListeners(m_aMutex)
+ ,m_aRowSetListeners(m_aMutex)
+ ,m_aParameterListeners(m_aMutex)
+ ,m_aResetListeners(m_aMutex)
+ ,m_aSubmitListeners(m_aMutex)
+ ,m_aErrorListeners(m_aMutex)
+ ,m_bLoaded(sal_False)
+ ,m_bSubForm(sal_False)
+ ,m_eNavigation(starform::NavigationBarMode_CURRENT)
+ ,m_nPrivileges(0)
+ ,m_pParameterInfo(NULL)
+ ,m_pThread(NULL)
+ ,m_eSubmitMethod(starform::FormSubmitMethod_GET)
+ ,m_eSubmitEncoding(starform::FormSubmitEncoding_URL)
+ ,m_bAllowDelete(sal_True)
+ ,m_bAllowUpdate(sal_True)
+ ,m_bAllowInsert(sal_True)
+ ,m_pLoadTimer(NULL)
+ ,m_nResetsPending(0)
+{
+ DBG_CTOR(ODatabaseForm,NULL);
+
+ // aggregate a row set
+ increment(m_refCount);
+
+ {
+ m_xAggregate = staruno::Reference<staruno::XAggregation>(m_xServiceFactory->createInstance(SRV_SDB_ROWSET), staruno::UNO_QUERY);
+ DBG_ASSERT(m_xAggregate.is(), "ODatabaseForm::ODatabaseForm : could not instantiate an SDB rowset !");
+ m_xAggregateAsRowSet = staruno::Reference<starsdbc::XRowSet> (m_xAggregate,staruno::UNO_QUERY);
+ setAggregation(m_xAggregate);
+ }
+
+ if (m_xAggregate.is())
+ {
+ m_xAggregate->setDelegator(static_cast<staruno::XWeak*>(this));
+ }
+
+ // listen for the properties, important for Parameters
+ if (m_xAggregateSet.is())
+ {
+ OPropertyChangeMultiplexer* pMultiplexer = new OPropertyChangeMultiplexer(this, m_xAggregateSet);
+ pMultiplexer->addProperty(PROPERTY_COMMAND);
+ pMultiplexer->addProperty(PROPERTY_FILTER_CRITERIA);
+ pMultiplexer->addProperty(PROPERTY_APPLYFILTER);
+ }
+
+ decrement(m_refCount);
+
+ m_pGroupManager = new OGroupManager();
+ m_pGroupManager->acquire();
+ addContainerListener(m_pGroupManager);
+}
+
+//------------------------------------------------------------------
+ODatabaseForm::~ODatabaseForm()
+{
+ DBG_DTOR(ODatabaseForm,NULL);
+
+ m_pGroupManager->release();
+
+ if (m_xAggregate.is())
+ m_xAggregate->setDelegator(InterfaceRef());
+}
+
+//==============================================================================
+// html tools
+//------------------------------------------------------------------------
+::rtl::OUString ODatabaseForm::GetDataURLEncoded(const staruno::Reference<starawt::XControl>& SubmitButton, const starawt::MouseEvent& MouseEvt)
+{
+
+ // Liste von successful Controls fuellen
+ HtmlSuccessfulObjList aSuccObjList;
+ FillSuccessfulList( aSuccObjList, SubmitButton, MouseEvt );
+
+
+ // Liste zu ::rtl::OUString zusammensetzen
+ ::rtl::OUString aResult;
+ ::rtl::OUString aName;
+ ::rtl::OUString aValue;
+
+ for ( HtmlSuccessfulObjListIterator pSuccObj = aSuccObjList.begin();
+ pSuccObj < aSuccObjList.end();
+ ++pSuccObj
+ )
+ {
+ aName = pSuccObj->aName;
+ aValue = pSuccObj->aValue;
+ if( pSuccObj->nRepresentation == SUCCESSFUL_REPRESENT_FILE && aValue.getLength() )
+ {
+ // Bei File-URLs wird der Dateiname und keine starutil::URL uebertragen,
+ // weil Netscape dies so macht.
+ INetURLObject aURL;
+ aURL.SetSmartProtocol(INET_PROT_FILE);
+ aURL.SetSmartURL(aValue);
+ if( INET_PROT_FILE == aURL.GetProtocol() )
+ aValue = INetURLObject::decode(aURL.PathToFileName(), '%', INetURLObject::DECODE_UNAMBIGUOUS);
+ }
+ Encode( aName );
+ Encode( aValue );
+ aResult += aName;
+ aResult += UniString('=');
+ aResult += aValue;
+ if (pSuccObj < aSuccObjList.end() - 1)
+ aResult += UniString('&');
+ }
+
+
+ aSuccObjList.clear();
+
+ return aResult;
+}
+
+//==============================================================================
+// html tools
+//------------------------------------------------------------------------
+::rtl::OUString ODatabaseForm::GetDataTextEncoded(const staruno::Reference<starawt::XControl>& SubmitButton, const starawt::MouseEvent& MouseEvt)
+{
+
+ // Liste von successful Controls fuellen
+ HtmlSuccessfulObjList aSuccObjList;
+ FillSuccessfulList( aSuccObjList, SubmitButton, MouseEvt );
+ // Liste zu ::rtl::OUString zusammensetzen
+ ::rtl::OUString aResult;
+ ::rtl::OUString aName;
+ ::rtl::OUString aValue;
+
+ for ( HtmlSuccessfulObjListIterator pSuccObj = aSuccObjList.begin();
+ pSuccObj < aSuccObjList.end();
+ ++pSuccObj
+ )
+ {
+ aName = pSuccObj->aName;
+ aValue = pSuccObj->aValue;
+ if (pSuccObj->nRepresentation == SUCCESSFUL_REPRESENT_FILE && aValue.getLength())
+ {
+ // Bei File-URLs wird der Dateiname und keine starutil::URL uebertragen,
+ // weil Netscape dies so macht.
+ INetURLObject aURL;
+ aURL.SetSmartProtocol(INET_PROT_FILE);
+ aURL.SetSmartURL(aValue);
+ if( INET_PROT_FILE == aURL.GetProtocol() )
+ aValue = INetURLObject::decode(aURL.PathToFileName(), '%', INetURLObject::DECODE_UNAMBIGUOUS);
+ }
+ Encode( aName );
+ Encode( aValue );
+ aResult += pSuccObj->aName;
+ aResult += UniString('=');
+ aResult += pSuccObj->aValue;
+ if (pSuccObj < aSuccObjList.end() - 1)
+ aResult += ::rtl::OUString::createFromAscii("\r\n");
+ }
+
+
+ // Liste loeschen
+ aSuccObjList.clear();
+
+ return aResult;
+}
+
+//------------------------------------------------------------------------
+staruno::Sequence<sal_Int8> ODatabaseForm::GetDataMultiPartEncoded(const staruno::Reference<starawt::XControl>& SubmitButton, const starawt::MouseEvent& MouseEvt, ::rtl::OUString& rContentType)
+{
+
+ // Parent erzeugen
+ INetMIMEMessage aParent;
+ aParent.EnableAttachChild( INETMSG_MULTIPART_FORM_DATA );
+
+
+ // Liste von successful Controls fuellen
+ HtmlSuccessfulObjList aSuccObjList;
+ FillSuccessfulList( aSuccObjList, SubmitButton, MouseEvt );
+
+
+ // Liste zu ::rtl::OUString zusammensetzen
+ ::rtl::OUString aResult;
+ for ( HtmlSuccessfulObjListIterator pSuccObj = aSuccObjList.begin();
+ pSuccObj < aSuccObjList.end();
+ ++pSuccObj
+ )
+ {
+ if( pSuccObj->nRepresentation == SUCCESSFUL_REPRESENT_TEXT )
+ InsertTextPart( aParent, pSuccObj->aName, pSuccObj->aValue );
+ else if( pSuccObj->nRepresentation == SUCCESSFUL_REPRESENT_FILE )
+ InsertFilePart( aParent, pSuccObj->aName, pSuccObj->aValue );
+ }
+
+
+ // Liste loeschen
+ aSuccObjList.clear();
+
+ // Fuer Parent MessageStream erzeugen
+ INetMIMEMessageStream aMessStream;
+ aMessStream.SetSourceMessage( &aParent );
+ aMessStream.GenerateHeader( sal_False );
+
+ // MessageStream in SvStream kopieren
+ SvMemoryStream aMemStream;
+ char* pBuf = new char[1025];
+ int nRead;
+ while( (nRead = aMessStream.Read(pBuf, 1024)) > 0 )
+ aMemStream.Write( pBuf, nRead );
+ delete[] pBuf;
+
+ aMemStream.Flush();
+ aMemStream.Seek( 0 );
+ void* pData = (void*)aMemStream.GetData();
+ sal_Int32 nLen = aMemStream.Seek(STREAM_SEEK_TO_END);
+
+ rContentType = UniString(aParent.GetContentType());
+ return staruno::Sequence<sal_Int8>((sal_Int8*)pData, nLen);
+}
+
+//------------------------------------------------------------------------
+void ODatabaseForm::AppendComponent(HtmlSuccessfulObjList& rList, const staruno::Reference<starbeans::XPropertySet>& xComponentSet, const ::rtl::OUString& rNamePrefix,
+ const staruno::Reference<starawt::XControl>& rxSubmitButton, const starawt::MouseEvent& MouseEvt)
+{
+ if (!xComponentSet.is())
+ return;
+
+ // MIB 25.6.98: Geschachtelte Formulare abfangen ... oder muesste
+ // man sie submitten?
+ if (!hasProperty(PROPERTY_CLASSID, xComponentSet))
+ return;
+
+ // Namen ermitteln
+ if (!hasProperty(PROPERTY_NAME, xComponentSet))
+ return;
+
+ sal_Int16 nClassId;
+ xComponentSet->getPropertyValue(PROPERTY_CLASSID) >>= nClassId;
+ ::rtl::OUString aName;
+ xComponentSet->getPropertyValue( PROPERTY_NAME ) >>= aName;
+ if( !aName.getLength() && nClassId != starform::FormComponentType::IMAGEBUTTON)
+ return;
+ else // Name um den Prefix erweitern
+ aName = rNamePrefix + aName;
+
+ switch( nClassId )
+ {
+ // Buttons
+ case starform::FormComponentType::COMMANDBUTTON:
+ {
+ // Es wird nur der gedrueckte Submit-Button ausgewertet
+ // MIB: Sofern ueberhaupt einer uebergeben wurde
+ if( rxSubmitButton.is() )
+ {
+ staruno::Reference<starbeans::XPropertySet> xSubmitButtonComponent(rxSubmitButton->getModel(), staruno::UNO_QUERY);
+ if (xSubmitButtonComponent == xComponentSet && hasProperty(PROPERTY_LABEL, xComponentSet))
+ {
+ // <name>=<label>
+ ::rtl::OUString aLabel;
+ xComponentSet->getPropertyValue( PROPERTY_LABEL ) >>= aLabel;
+ rList.push_back( HtmlSuccessfulObj(aName, aLabel) );
+ }
+ }
+ } break;
+
+ // ImageButtons
+ case starform::FormComponentType::IMAGEBUTTON:
+ {
+ // Es wird nur der gedrueckte Submit-Button ausgewertet
+ // MIB: Sofern ueberhaupt einer uebergeben wurde
+ if( rxSubmitButton.is() )
+ {
+ staruno::Reference<starbeans::XPropertySet> xSubmitButtonComponent(rxSubmitButton->getModel(), staruno::UNO_QUERY);
+ if (xSubmitButtonComponent == xComponentSet)
+ {
+ // <name>.x=<pos.X>&<name>.y=<pos.Y>
+ ::rtl::OUString aLhs = aName;
+ ::rtl::OUString aRhs = ::rtl::OUString( MouseEvt.X );
+
+ // nur wenn ein Name vorhanden ist, kann ein name.x
+ aLhs += aName.getLength() ? UniString::CreateFromAscii(".x") : UniString::CreateFromAscii("x");
+ rList.push_back( HtmlSuccessfulObj(aLhs, aRhs) );
+
+ aLhs = aName;
+ aRhs = ::rtl::OUString( MouseEvt.Y );
+ aLhs += aName.getLength() ? UniString::CreateFromAscii(".y") : UniString::CreateFromAscii("y");
+ rList.push_back( HtmlSuccessfulObj(aLhs, aRhs) );
+
+ }
+ }
+ } break;
+
+ // CheckBoxen / RadioButtons
+ case starform::FormComponentType::CHECKBOX:
+ case starform::FormComponentType::RADIOBUTTON:
+ {
+ // <name>=<refValue>
+ if( !hasProperty(PROPERTY_STATE, xComponentSet) )
+ break;
+ sal_Int16 nChecked;
+ xComponentSet->getPropertyValue( PROPERTY_STATE ) >>= nChecked;
+ if( nChecked != 1 )
+ break;
+
+ ::rtl::OUString aStrValue;
+ if( hasProperty(PROPERTY_REFVALUE, xComponentSet) )
+ xComponentSet->getPropertyValue( PROPERTY_REFVALUE ) >>= aStrValue;
+
+ rList.push_back( HtmlSuccessfulObj(aName, aStrValue) );
+ } break;
+
+ // Edit
+ case starform::FormComponentType::TEXTFIELD:
+ {
+ // <name>=<text>
+ if( !hasProperty(PROPERTY_TEXT, xComponentSet) )
+ break;
+
+ // MIB: Spezial-Behandlung fuer Multiline-Edit nur dann, wenn
+ // es auch ein Control dazu gibt.
+ staruno::Any aTmp = xComponentSet->getPropertyValue( PROPERTY_MULTILINE );
+ sal_Bool bMulti = rxSubmitButton.is()
+ && (aTmp.getValueType().getTypeClass() == staruno::TypeClass_BOOLEAN)
+ && getBOOL(aTmp);
+ ::rtl::OUString sText;
+ if ( bMulti ) // Bei MultiLineEdit Text am Control abholen
+ {
+
+ staruno::Reference<starawt::XControlContainer> xControlContainer(rxSubmitButton->getContext(), staruno::UNO_QUERY);
+ if( !xControlContainer.is() ) break;
+
+ staruno::Sequence<staruno::Reference<starawt::XControl> > aControlSeq = xControlContainer->getControls();
+ staruno::Reference<starawt::XControl> xControl;
+ staruno::Reference<starform::XFormComponent> xControlComponent;
+
+ // Richtiges Control suchen
+ sal_Int32 i;
+ for( i=0; i<aControlSeq.getLength(); i++ )
+ {
+ xControl = aControlSeq.getConstArray()[i];
+ staruno::Reference<starbeans::XPropertySet> xModel(xControl->getModel(), staruno::UNO_QUERY);
+ if (xModel == xComponentSet)
+ {
+ staruno::Reference<starawt::XTextComponent> xTextComponent(xControl, staruno::UNO_QUERY);
+ if( xTextComponent.is() )
+ sText = xTextComponent->getText();
+ break;
+ }
+ }
+ // Control nicht gefunden oder nicht existent, (Edit im Grid)
+ if (i == aControlSeq.getLength())
+ xComponentSet->getPropertyValue( PROPERTY_TEXT ) >>= sText;
+ }
+ else
+ xComponentSet->getPropertyValue( PROPERTY_TEXT ) >>= sText;
+
+ rList.push_back( HtmlSuccessfulObj(aName, sText) );
+ } break;
+
+ // ComboBox, Patternfield
+ case starform::FormComponentType::COMBOBOX:
+ case starform::FormComponentType::PATTERNFIELD:
+ {
+ // <name>=<text>
+ if( hasProperty(PROPERTY_TEXT, xComponentSet) )
+ {
+ ::rtl::OUString aText;
+ xComponentSet->getPropertyValue( PROPERTY_TEXT ) >>= aText;
+ rList.push_back( HtmlSuccessfulObj(aName, aText) );
+ }
+ } break;
+ case starform::FormComponentType::CURRENCYFIELD:
+ case starform::FormComponentType::NUMERICFIELD:
+ {
+ // <name>=<wert> // wert wird als double mit Punkt als Decimaltrenner
+ // kein Wert angegeben (NULL) -> wert leer
+ if( hasProperty(PROPERTY_VALUE, xComponentSet) )
+ {
+ ::rtl::OUString aText;
+ staruno::Any aVal = xComponentSet->getPropertyValue( PROPERTY_VALUE );
+
+ double aDoubleVal;
+ if (aVal >>= aDoubleVal)
+ {
+ sal_Int16 nScale;
+ xComponentSet->getPropertyValue( PROPERTY_DECIMAL_ACCURACY ) >>= nScale;
+ String aTempText = UniString(aText);
+ // TODO : remove this if SolarMath works with unicode strings
+ SolarMath::DoubleToString(aTempText, aDoubleVal, 'F', nScale, '.', sal_True);
+ }
+ rList.push_back( HtmlSuccessfulObj(aName, aText) );
+ }
+ } break;
+ case starform::FormComponentType::DATEFIELD:
+ {
+ // <name>=<wert> // Wert wird als Datum im Format (MM-DD-YYYY)
+ // kein Wert angegeben (NULL) -> wert leer
+ if( hasProperty(PROPERTY_DATE, xComponentSet) )
+ {
+ ::rtl::OUString aText;
+ staruno::Any aVal = xComponentSet->getPropertyValue( PROPERTY_DATE );
+ sal_Int32 nInt32Val;
+ if (aVal >>= nInt32Val)
+ {
+ Date aDate(nInt32Val);
+ char s[11];
+ sprintf(s,"%02d-%02d-%04d",
+ (int)aDate.GetMonth(),
+ (int)aDate.GetDay(),
+ (int)aDate.GetYear());
+ s[10] = 0;
+ aText = ::rtl::OUString::createFromAscii(s);
+ }
+ rList.push_back( HtmlSuccessfulObj(aName, aText) );
+ }
+ } break;
+ case starform::FormComponentType::TIMEFIELD:
+ {
+ // <name>=<wert> // Wert wird als Zeit im Format (HH:MM:SS) angegeben
+ // kein Wert angegeben (NULL) -> wert leer
+ if( hasProperty(PROPERTY_TIME, xComponentSet) )
+ {
+ ::rtl::OUString aText;
+ staruno::Any aVal = xComponentSet->getPropertyValue( PROPERTY_TIME );
+ sal_Int32 nInt32Val;
+ if (aVal >>= nInt32Val)
+ {
+ Time aTime(nInt32Val);
+ char s[10];
+ sprintf(s,"%02d:%02d:%02d",
+ (int)aTime.GetHour(),
+ (int)aTime.GetMin(),
+ (int)aTime.GetSec());
+ s[8] = 0;
+ aText = ::rtl::OUString::createFromAscii(s);
+ }
+ rList.push_back( HtmlSuccessfulObj(aName, aText) );
+ }
+ } break;
+
+ // starform
+ case starform::FormComponentType::HIDDENCONTROL:
+ {
+
+ // <name>=<value>
+ if( hasProperty(PROPERTY_HIDDEN_VALUE, xComponentSet) )
+ {
+ ::rtl::OUString aText;
+ xComponentSet->getPropertyValue( PROPERTY_HIDDEN_VALUE ) >>= aText;
+ rList.push_back( HtmlSuccessfulObj(aName, aText) );
+ }
+ } break;
+
+ // starform
+ case starform::FormComponentType::FILECONTROL:
+ {
+ // <name>=<text>
+ if( hasProperty(PROPERTY_TEXT, xComponentSet) )
+ {
+
+ ::rtl::OUString aText;
+ xComponentSet->getPropertyValue( PROPERTY_TEXT ) >>= aText;
+ rList.push_back( HtmlSuccessfulObj(aName, aText, SUCCESSFUL_REPRESENT_FILE) );
+ }
+ } break;
+
+ // starform
+ case starform::FormComponentType::LISTBOX:
+ {
+
+ // <name>=<Token0>&<name>=<Token1>&...&<name>=<TokenN> (Mehrfachselektion)
+ if (!hasProperty(PROPERTY_SELECT_SEQ, xComponentSet) ||
+ !hasProperty(PROPERTY_STRINGITEMLIST, xComponentSet))
+ break;
+
+ // angezeigte Werte
+ staruno::Sequence< ::rtl::OUString > aVisibleList =
+ *(staruno::Sequence< ::rtl::OUString >*)xComponentSet->getPropertyValue( PROPERTY_STRINGITEMLIST ).getValue();
+ sal_Int32 nStringCnt = aVisibleList.getLength();
+ const ::rtl::OUString* pStrings = aVisibleList.getConstArray();
+
+ // Werte-Liste
+ staruno::Sequence< ::rtl::OUString > aValueList =
+ *(staruno::Sequence< ::rtl::OUString >*)xComponentSet->getPropertyValue( PROPERTY_VALUE_SEQ ).getValue();
+ sal_Int32 nValCnt = aValueList.getLength();
+ const ::rtl::OUString* pVals = aValueList.getConstArray();
+
+ // Selektion
+ staruno::Sequence<sal_Int16> aSelectList =
+ *(staruno::Sequence<sal_Int16>*)xComponentSet->getPropertyValue( PROPERTY_SELECT_SEQ ).getValue();
+ sal_Int32 nSelCount = aSelectList.getLength();
+ const sal_Int16* pSels = aSelectList.getConstArray();
+
+ // Einfach- oder Mehrfach-Selektion
+ // Bei Einfach-Selektionen beruecksichtigt MT nur den ersten Eintrag
+ // in der Liste.
+ if (nSelCount > 1 && !getBOOL(xComponentSet->getPropertyValue(PROPERTY_MULTISELECTION)))
+ nSelCount = 1;
+
+ // Die Indizes in der Selektions-Liste koennen auch ungueltig sein,
+ // also muss man die gueltigen erstmal raussuchen um die Laenge
+ // der neuen Liste zu bestimmen.
+ sal_Int32 nCurCnt = 0;
+ sal_Int32 i;
+ for( i=0; i<nSelCount; ++i )
+ {
+ if( pSels[i] < nStringCnt )
+ ++nCurCnt;
+ }
+
+ ::rtl::OUString aSubValue;
+ for(i=0; i<nCurCnt; ++i )
+ {
+ sal_Int16 nSelPos = pSels[i];
+ // Wenn starsdbcx::Index in WerteListe, Eintrag aus Werteliste holen
+ // ansonsten angezeigten Wert nehmen. Ein
+ // LISTBOX_EMPTY_VALUE entspricht einem leeren, aber
+ // vorhandenem VALUE des Option-Tags.
+ if (nSelPos < nValCnt && pVals[nSelPos].getLength())
+ {
+ if( pVals[nSelPos] == LISTBOX_EMPTY_VALUE )
+ aSubValue = ::rtl::OUString();
+ else
+ aSubValue = pVals[nSelPos];
+ }
+ else
+ {
+ aSubValue = pStrings[nSelPos];
+ }
+ rList.push_back( HtmlSuccessfulObj(aName, aSubValue) );
+ }
+ } break;
+ case starform::FormComponentType::GRIDCONTROL:
+ {
+ // Die einzelnen Spaltenwerte werden verschickt,
+ // der Name wird mit dem Prefix des Names des Grids erweitert
+ staruno::Reference<starcontainer::XIndexAccess> xContainer(xComponentSet, staruno::UNO_QUERY);
+ if (!xContainer.is())
+ break;
+
+ aName += UniString('.');
+
+ sal_Int32 nCount = xContainer->getCount();
+ for (sal_Int32 i = 0; i < nCount; ++i)
+ {
+ staruno::Reference<starbeans::XPropertySet> xSet(*(staruno::Reference<starbeans::XPropertySet> *)xContainer->getByIndex(i).getValue());
+ if (xSet.is())
+ AppendComponent(rList, xSet, aName, rxSubmitButton, MouseEvt);
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+void ODatabaseForm::FillSuccessfulList( HtmlSuccessfulObjList& rList,
+ const staruno::Reference<starawt::XControl>& rxSubmitButton, const starawt::MouseEvent& MouseEvt )
+{
+
+ // Liste loeschen
+ rList.clear();
+
+
+ // Ueber Components iterieren
+ InterfaceRef xIFace;
+ staruno::Reference<starform::XFormComponent> xComponent;
+ staruno::Reference<starbeans::XPropertySet> xComponentSet;
+ ::rtl::OUString aPrefix;
+
+ staruno::Any aElement;
+ for( sal_Int32 nIndex=0; nIndex < getCount(); nIndex++ )
+ {
+ aElement = getByIndex( nIndex );
+ xComponentSet = staruno::Reference<starbeans::XPropertySet> (*(InterfaceRef *) aElement.getValue(), staruno::UNO_QUERY);
+ AppendComponent(rList, xComponentSet, aPrefix, rxSubmitButton, MouseEvt);
+ }
+}
+
+//------------------------------------------------------------------------
+void ODatabaseForm::Encode( ::rtl::OUString& rString ) const
+{
+ ::rtl::OUString aResult;
+
+ // Immer ANSI #58641
+// rString.Convert(CHARSET_SYSTEM, CHARSET_ANSI);
+
+
+ // Zeilenendezeichen werden als CR dargestellt
+ UniString sConverter = rString;
+ sConverter.ConvertLineEnd( LINEEND_CR );
+ rString = sConverter;
+
+
+ // Jeden einzelnen Character ueberpruefen
+ sal_uInt16 nStrLen = rString.getLength();
+ sal_Unicode nCharCode;
+ for( sal_uInt16 nCurPos=0; nCurPos < nStrLen; ++nCurPos )
+ {
+ nCharCode = rString[nCurPos];
+
+ // Behandlung fuer chars, die kein alphanumerisches Zeichen sind
+ // und CharacterCodes > 127
+ if( (!isalnum(nCharCode) && nCharCode != (sal_Unicode)' ') || nCharCode > 127 )
+ {
+ switch( nCharCode )
+ {
+ case 13: // CR
+ aResult += ::rtl::OUString::createFromAscii("%0D%0A"); // Hex-Darstellung CR LF
+ break;
+
+
+ // Netscape Sonderbehandlung
+ case 42: // '*'
+ case 45: // '-'
+ case 46: // '.'
+ case 64: // '@'
+ case 95: // '_'
+ aResult += UniString(nCharCode);
+ break;
+
+ default:
+ {
+ // In Hex umrechnen
+ short nHi = ((sal_Int16)nCharCode) / 16;
+ short nLo = ((sal_Int16)nCharCode) - (nHi*16);
+ if( nHi > 9 ) nHi += (int)'A'-10; else nHi += (int)'0';
+ if( nLo > 9 ) nLo += (int)'A'-10; else nLo += (int)'0';
+ aResult += UniString('%');
+ aResult += UniString((sal_Unicode)nHi);
+ aResult += UniString((sal_Unicode)nLo);
+ }
+ }
+ }
+ else
+ aResult += UniString(nCharCode);
+ }
+
+
+ // Spaces durch '+' ersetzen
+ aResult = aResult.replace(' ', '+');
+
+ rString = aResult;
+}
+
+//------------------------------------------------------------------------
+void ODatabaseForm::InsertTextPart( INetMIMEMessage& rParent, const ::rtl::OUString& rName,
+ const ::rtl::OUString& rData )
+{
+
+ // Part als Message-Child erzeugen
+ INetMIMEMessage* pChild = new INetMIMEMessage();
+
+
+ // Header
+ ::rtl::OUString aContentDisp = ::rtl::OUString::createFromAscii("form-data; name=\"");
+ aContentDisp += rName;
+ aContentDisp += UniString('\"');
+ pChild->SetContentDisposition( aContentDisp );
+ pChild->SetContentType( UniString::CreateFromAscii("text/plain") );
+
+ rtl_TextEncoding eSystemEncoding = gsl_getSystemTextEncoding();
+ const sal_Char* pBestMatchingEncoding = rtl_getBestMimeCharsetFromTextEncoding( eSystemEncoding );
+ UniString aBestMatchingEncoding = UniString::CreateFromAscii( pBestMatchingEncoding );
+ pChild->SetContentTransferEncoding(aBestMatchingEncoding);
+
+ // Body
+ SvMemoryStream* pStream = new SvMemoryStream;
+ pStream->WriteLine( ByteString( UniString(rData), rtl_getTextEncodingFromMimeCharset(pBestMatchingEncoding) ) );
+ pStream->Flush();
+ pStream->Seek( 0 );
+ pChild->SetDocumentLB( new SvLockBytes(pStream, sal_True) );
+ rParent.AttachChild( *pChild );
+}
+
+//------------------------------------------------------------------------
+sal_Bool ODatabaseForm::InsertFilePart( INetMIMEMessage& rParent, const ::rtl::OUString& rName,
+ const ::rtl::OUString& rFileName )
+{
+ UniString aFileName( rFileName );
+ UniString aContentType(UniString::CreateFromAscii(CONTENT_TYPE_STR_TEXT_PLAIN));
+ SvStream *pStream = 0;
+
+ if( aFileName.Len() )
+ {
+ // Bisher koennen wir nur File-URLs verarbeiten
+ INetURLObject aURL;
+ aURL.SetSmartProtocol(INET_PROT_FILE);
+ aURL.SetSmartURL(rFileName);
+ if( INET_PROT_FILE == aURL.GetProtocol() )
+ {
+ aFileName = INetURLObject::decode(aURL.PathToFileName(), '%', INetURLObject::DECODE_UNAMBIGUOUS);
+ DirEntry aDirEntry( aFileName );
+ if( aDirEntry.Exists() )
+ {
+ pStream = new SvFileStream( aFileName, STREAM_READ );
+ if( pStream->GetError() != ERRCODE_NONE )
+ {
+ delete pStream;
+ pStream = 0;
+ }
+ }
+ INetContentType eContentType = INetContentTypes::GetContentType4Extension(
+ aDirEntry.GetExtension() );
+ if (eContentType != CONTENT_TYPE_UNKNOWN)
+ aContentType = INetContentTypes::GetContentType(eContentType);
+ }
+ }
+
+ // Wenn irgendetwas nicht geklappt hat, legen wir einen leeren
+ // MemoryStream an
+ if( !pStream )
+ pStream = new SvMemoryStream;
+
+
+ // Part als Message-Child erzeugen
+ INetMIMEMessage* pChild = new INetMIMEMessage;
+
+
+ // Header
+ ::rtl::OUString aContentDisp = ::rtl::OUString::createFromAscii( "form-data; name=\"" );
+ aContentDisp += rName;
+ aContentDisp += UniString('\"');
+ aContentDisp += ::rtl::OUString::createFromAscii("; filename=\"");
+ aContentDisp += aFileName;
+ aContentDisp += UniString('\"');
+ pChild->SetContentDisposition( aContentDisp );
+ pChild->SetContentType( aContentType );
+ pChild->SetContentTransferEncoding( UniString(::rtl::OUString::createFromAscii("8bit")) );
+
+
+ // Body
+ pChild->SetDocumentLB( new SvLockBytes(pStream, sal_True) );
+ rParent.AttachChild( *pChild );
+
+ return sal_True;
+}
+
+//==============================================================================
+// internals
+//------------------------------------------------------------------------------
+void ODatabaseForm::onError(const starsdb::SQLErrorEvent& _rEvent)
+{
+ NOTIFY_LISTENERS(m_aErrorListeners, starsdb::XSQLErrorListener, errorOccured, _rEvent);
+}
+
+//------------------------------------------------------------------------------
+void ODatabaseForm::onError(starsdbc::SQLException& _rException, const ::rtl::OUString& _rContextDescription)
+{
+ if (!m_aErrorListeners.getLength())
+ return;
+
+ starsdb::SQLContext aError = prependContextInfo(_rException, static_cast<staruno::XWeak*>(this), _rContextDescription);
+ starsdb::SQLErrorEvent aEvent(static_cast<staruno::XWeak*>(this), staruno::makeAny(aError));
+
+ onError(aEvent);
+}
+
+//------------------------------------------------------------------------------
+OParameterInfoImpl* ODatabaseForm::createParameterInfo() const
+{
+ OParameterInfoImpl* pParameterInfo = new OParameterInfoImpl();
+
+ // create and fill a composer
+ staruno::Reference<starsdb::XSQLQueryComposer> xComposer = getCurrentSettingsComposer(m_xAggregateSet, m_xServiceFactory);
+ staruno::Reference<starsdb::XParametersSupplier> xSetParameters = staruno::Reference<starsdb::XParametersSupplier> (xComposer, staruno::UNO_QUERY);
+
+ // if there is no parsable statement return
+ if (!xSetParameters.is())
+ return pParameterInfo;
+
+ staruno::Reference<starcontainer::XIndexAccess> xParamsAsIndicies = xSetParameters->getParameters();
+ staruno::Reference<starcontainer::XNameAccess> xParamsAsNames(xParamsAsIndicies, staruno::UNO_QUERY);
+ sal_Int32 nParamCount = xParamsAsIndicies.is() ? xParamsAsIndicies->getCount() : 0;
+ // without parameters return
+ if (!xParamsAsNames.is() || (nParamCount == 0))
+ return pParameterInfo;
+
+ // now evaluate the parameters
+ pParameterInfo->nCount = nParamCount;
+ pParameterInfo->xParamsAsNames = xParamsAsNames;
+ pParameterInfo->pParameters = new OParametersImpl();
+ pParameterInfo->pParameters->acquire();
+ OParametersImpl::Parameters& rParams = pParameterInfo->pParameters->getParameters();
+
+ // we need to map the parameter names (which is all we can get from our parent) to indicies (which are
+ // needed by the starsdbc::XParameters interface of the row set)
+ MapUString2INT32& rParamMapping = pParameterInfo->aParamMapping;
+ staruno::Reference<starbeans::XPropertySet> xParam;
+ for (sal_Int32 i = 0; i<nParamCount; ++i)
+ {
+ ::cppu::extractInterface(xParam, xParamsAsIndicies->getByIndex(i));
+
+ // remember the param fields
+ rParams.push_back(xParam);
+ ::rtl::OUString sName;
+ xParam->getPropertyValue(PROPERTY_NAME) >>= sName;
+ rParamMapping[sName] = i;
+ }
+
+ // check for a matching of my param master fields with the parent's columns
+ staruno::Reference<starsdbcx::XColumnsSupplier> xParentColsSuppl(m_xParent, staruno::UNO_QUERY);
+ if (xParentColsSuppl.is())
+ {
+ staruno::Reference<starcontainer::XNameAccess> xParentCols = xParentColsSuppl->getColumns();
+ if (xParentCols.is())
+ {
+ sal_Int32 nMasterLen = m_aMasterFields.getLength();
+ sal_Int32 nSlaveLen = m_aDetailFields.getLength();
+ if (xParentCols->hasElements() && (nMasterLen == nSlaveLen) && (nMasterLen > 0))
+ {
+ const ::rtl::OUString* pMasterFields = m_aMasterFields.getConstArray();
+ const ::rtl::OUString* pDetailFields = m_aDetailFields.getConstArray();
+
+ OParametersImpl::ParametersIterator iter;
+ for (sal_Int32 i = 0; i < nMasterLen; i++)
+ {
+ staruno::Reference<starbeans::XPropertySet> xMasterField, xDetailField;
+
+ if (xParentCols->hasByName(pMasterFields[i]) &&
+ xParamsAsNames->hasByName(pDetailFields[i]))
+ {
+ // parameter defined by master slave definition
+ ::cppu::extractInterface(xDetailField, xParamsAsNames->getByName(pDetailFields[i]));
+
+ DBG_ASSERT(rParamMapping.find(pDetailFields[i]) != rParamMapping.end(), "ODatabaseForm::fillParameters : invalid starsdb::XParametersSupplier !");
+ // the mapping was build from the starsdb::XParametersSupplier interface of the composer, and the
+ // starcontainer::XNameAccess interface of the composer said hasByName(...)==sal_True ... so what ?
+
+ // delete the wrapper as the parameter is set
+ iter = find(rParams.begin(), rParams.end(), xDetailField);
+ DBG_ASSERT(iter != rParams.end(), "ODatabaseForm::fillParameters : Parameter not found");
+ if (iter != rParams.end())
+ rParams.erase(iter);
+ }
+ }
+ }
+ }
+ }
+
+ // now set the remaining params
+ sal_Int32 nParamsLeft = rParams.size();
+ if (nParamsLeft)
+ {
+ staruno::Reference<starsdbc::XParameters> xExecutionParams(m_xAggregate, staruno::UNO_QUERY);
+ ::rtl::OUString sName;
+ staruno::Reference<starbeans::XPropertySet> xParam;
+ staruno::Reference<starbeans::XPropertySet> xWrapper;
+ for (sal_Int32 j = nParamsLeft; j; )
+ {
+ --j;
+ xParam = rParams[j];
+ xParam->getPropertyValue(PROPERTY_NAME) >>= sName;
+ // need a wrapper for this .... the params supplied by xMyParamsAsIndicies don't have a "Value"
+ // property, but the parameter listeners expect such a property. So we need an object "aggregating"
+ // xParam and supplying an additional property ("Value")
+ // (it's no real aggregation of course ...)
+
+ // get the position of the parameter
+ sal_Int32 nPos = rParamMapping[sName];
+ if (m_aParameterVisited.size() > nPos && m_aParameterVisited[nPos] == true)
+ {
+ // parameter already set from outside
+ OParametersImpl::ParametersIterator aPos = rParams.begin() + j;
+ if (aPos != rParams.end())
+ rParams.erase(aPos);
+ }
+ else
+ {
+ xWrapper = new OParameterWrapper(xParam, xExecutionParams, rParamMapping[sName]);
+ rParams[j] = xWrapper;
+ }
+ }
+ }
+ return pParameterInfo;
+}
+
+//------------------------------------------------------------------------------
+bool ODatabaseForm::hasValidParent() const
+{
+ // do we have to fill the parameters again?
+ if (m_bSubForm)
+ {
+ staruno::Reference<starsdbc::XResultSet> xResultSet(m_xParent, staruno::UNO_QUERY);
+ if (!xResultSet.is())
+ {
+ DBG_ERROR("ODatabaseForm::hasValidParent() : no parent resultset !");
+ return false;
+ }
+ try
+ {
+ staruno::Reference<starbeans::XPropertySet> xSet(m_xParent, staruno::UNO_QUERY);
+ // only if the parent has a command we have to check if the parent is positioned on a valid row
+ if (getString(xSet->getPropertyValue(PROPERTY_COMMAND)).getLength() &&
+ (xResultSet->isBeforeFirst() || xResultSet->isAfterLast() ||
+ getBOOL(xSet->getPropertyValue(PROPERTY_ISNEW))))
+ return false;
+ }
+ catch(...)
+ {
+ // parent could be forwardonly?
+ return false;
+ }
+ }
+ return true;
+}
+
+//------------------------------------------------------------------------------
+bool ODatabaseForm::fillParameters(ReusableMutexGuard& _rClearForNotifies)
+{
+ staruno::Reference<starsdbc::XParameters> xExecutionParams;
+ if (!query_aggregation( m_xAggregate, xExecutionParams))
+ {
+ DBG_ERROR("ODatabaseForm::fillParameters : invalid row set (doesn't support parameters) !");
+ // normally the row set should support parameters ...
+ return true;
+ }
+
+ // is there a valid parent?
+ if (m_bSubForm && !hasValidParent())
+ return true;
+
+ // do we have to fill the parameters again?
+ if (!m_pParameterInfo)
+ m_pParameterInfo = createParameterInfo();
+
+ if (!m_pParameterInfo || m_pParameterInfo->nCount == 0)
+ return true;
+
+ // do we have to fill the parent parameters?
+ OParametersImpl::Parameters& rParams = m_pParameterInfo->pParameters->getParameters();
+
+ // do we have to fill the parent parameters?
+ if (m_pParameterInfo->nCount > rParams.size())
+ {
+ staruno::Reference<starsdbcx::XColumnsSupplier> xParentColsSuppl(m_xParent, staruno::UNO_QUERY);
+ if (xParentColsSuppl.is())
+ {
+ staruno::Reference<starcontainer::XNameAccess> xParentCols = xParentColsSuppl->getColumns();
+ sal_Int32 nMasterLen = m_aMasterFields.getLength();
+ if (xParentCols->hasElements() && (nMasterLen > 0))
+ {
+ const ::rtl::OUString* pMasterFields = m_aMasterFields.getConstArray();
+ const ::rtl::OUString* pDetailFields = m_aDetailFields.getConstArray();
+
+ staruno::Any aParamType,aScale,aValue;
+ for (sal_Int32 i = 0; i < nMasterLen; i++)
+ {
+ staruno::Reference<starbeans::XPropertySet> xMasterField, xDetailField;
+ if (xParentCols->hasByName(pMasterFields[i]) &&
+ m_pParameterInfo->xParamsAsNames->hasByName(pDetailFields[i]))
+ {
+ // parameter defined by master slave definition
+ ::cppu::extractInterface(xMasterField, xParentCols->getByName(pMasterFields[i]));
+ ::cppu::extractInterface(xDetailField, m_pParameterInfo->xParamsAsNames->getByName(pDetailFields[i]));
+
+ // get the type of the param
+ aParamType = xDetailField->getPropertyValue(PROPERTY_FIELDTYPE);
+ DBG_ASSERT(aParamType.getValueType().getTypeClass() == staruno::TypeClass_LONG, "ODatabaseForm::fillParameters : invalid parameter field !");
+ sal_Int32 nScale = 0;
+ if (hasProperty(PROPERTY_SCALE, xDetailField))
+ {
+ aScale = xDetailField->getPropertyValue(PROPERTY_SCALE);
+ DBG_ASSERT(aScale.getValueType().getTypeClass() == staruno::TypeClass_LONG, "ODatabaseForm::fillParameters : invalid parameter field !");
+ nScale = getINT32(aScale);
+ }
+ // and fill the param value
+ aValue = xMasterField->getPropertyValue(PROPERTY_VALUE);
+ // parameters are based at 1
+ xExecutionParams->setObjectWithInfo(m_pParameterInfo->aParamMapping[pDetailFields[i]] + 1, aValue, getINT32(aParamType), nScale);
+ }
+ else
+ // no column matching so leave the parameter setting
+ return true;
+ }
+ }
+ }
+ }
+
+ // now fill the remaining params
+ bool bCanceled = false;
+ sal_Int32 nParamsLeft = rParams.size();
+ if (nParamsLeft)
+ {
+ ::cppu::OInterfaceIteratorHelper aIter(m_aParameterListeners);
+ starform::DatabaseParameterEvent aEvt(static_cast<staruno::XWeak*>(this), m_pParameterInfo->pParameters);
+
+ _rClearForNotifies.clear();
+ while (aIter.hasMoreElements() && !bCanceled)
+ bCanceled = !((starform::XDatabaseParameterListener*)aIter.next())->approveParameter(aEvt);
+ _rClearForNotifies.attach(m_aMutex);
+ }
+ return !bCanceled;
+}
+
+//------------------------------------------------------------------------------
+void ODatabaseForm::executeRowSet(ReusableMutexGuard& _rClearForNotifies, sal_Bool bMoveToFirst)
+{
+ if (!m_xAggregateAsRowSet.is())
+ return;
+
+ fillParameters(_rClearForNotifies);
+ sal_Bool bInsertOnly = sal_False;
+
+ // ensure the aggregated row set has the correct properties
+ sal_Int32 nConcurrency;
+ // if we have a parent, who is not positioned on a valid row
+ // we can't be updatable!
+ if (m_bSubForm && !hasValidParent())
+ {
+ // don't use any parameters if we don't have a valid parent
+ nConcurrency = starsdbc::ResultSetConcurrency::READ_ONLY;
+ clearParameters();
+ }
+ else if (m_bAllowInsert || m_bAllowUpdate || m_bAllowDelete)
+ nConcurrency = starsdbc::ResultSetConcurrency::UPDATABLE;
+ else
+ nConcurrency = starsdbc::ResultSetConcurrency::READ_ONLY;
+ m_xAggregateSet->setPropertyValue(PROPERTY_RESULTSET_CONCURRENCY, staruno::makeAny(nConcurrency));
+
+ sal_Int32 nResultSetType = starsdbc::ResultSetType::SCROLL_SENSITIVE;
+ m_xAggregateSet->setPropertyValue(PROPERTY_RESULTSET_TYPE, staruno::makeAny(nResultSetType));
+
+ sal_Bool bSuccess = sal_False;
+ try
+ {
+ m_xAggregateAsRowSet->execute();
+ bSuccess = sal_True;
+ }
+ catch(starsdb::RowSetVetoException& eVeto)
+ {
+ eVeto;
+ }
+ catch(starsdbc::SQLException& eDb)
+ {
+ _rClearForNotifies.clear();
+ if (m_sCurrentErrorContext.getLength())
+ onError(eDb, m_sCurrentErrorContext);
+ else
+ onError(eDb, FRM_RES_STRING(RID_STR_READERROR));
+ _rClearForNotifies.attach(m_aMutex);
+ }
+
+ if (bSuccess)
+ {
+ // adjust the privilege property
+ m_nPrivileges;
+ m_xAggregateSet->getPropertyValue(PROPERTY_PRIVILEGES) >>= m_nPrivileges;
+ if (!m_bAllowInsert)
+ m_nPrivileges &= ~starsdbcx::Privilege::INSERT;
+ if (!m_bAllowUpdate)
+ m_nPrivileges &= ~starsdbcx::Privilege::UPDATE;
+ if (!m_bAllowDelete)
+ m_nPrivileges &= ~starsdbcx::Privilege::DELETE;
+
+ if (bMoveToFirst)
+ {
+ // the row set is positioned _before_ the first row (per definitionem), so move the set ...
+ try
+ {
+ // if we have an insert only rowset we move to the insert row
+ next();
+ if (((m_nPrivileges & starsdbcx::Privilege::INSERT) == starsdbcx::Privilege::INSERT)
+ && isAfterLast())
+ {
+ // move on the insert row of set
+ // resetting must be done later, after the load events have been posted
+ // see :moveToInsertRow and load , reload
+ staruno::Reference<starsdbc::XResultSetUpdate> xUpdate;
+ if (query_aggregation( m_xAggregate, xUpdate))
+ xUpdate->moveToInsertRow();
+ }
+ }
+ catch(starsdbc::SQLException& eDB)
+ {
+ _rClearForNotifies.clear();
+ if (m_sCurrentErrorContext.getLength())
+ onError(eDB, m_sCurrentErrorContext);
+ else
+ onError(eDB, FRM_RES_STRING(RID_STR_READERROR));
+ _rClearForNotifies.attach(m_aMutex);
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------
+void ODatabaseForm::disposing()
+{
+ if (m_bLoaded)
+ unload();
+
+ // cancel the submit/reset-thread
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (m_pThread)
+ {
+ m_pThread->release();
+ m_pThread = NULL;
+ }
+ }
+
+ starlang::EventObject aEvt(static_cast<staruno::XWeak*>(this));
+ m_aLoadListeners.disposeAndClear(aEvt);
+ m_aRowSetApproveListeners.disposeAndClear(aEvt);
+ m_aParameterListeners.disposeAndClear(aEvt);
+ m_aResetListeners.disposeAndClear(aEvt);
+ m_aSubmitListeners.disposeAndClear(aEvt);
+ m_aErrorListeners.disposeAndClear(aEvt);
+
+ OFormComponents::disposing();
+ OPropertySetAggregationHelper::disposing();
+
+ // stop listening on the aggregate
+ m_xAggregateAsRowSet->removeRowSetListener(this);
+
+ staruno::Reference<starlang::XComponent> xAggregationComponent;
+ if (query_aggregation(m_xAggregate, xAggregationComponent))
+ xAggregationComponent->dispose();
+}
+
+//------------------------------------------------------------------------------
+staruno::Reference< starsdbc::XConnection > ODatabaseForm::getConnection()
+{
+ staruno::Reference< starsdbc::XConnection > xReturn;
+ try
+ {
+ ::cppu::extractInterface(xReturn, getPropertyValue(PROPERTY_ACTIVE_CONNECTION));
+ }
+ catch(...)
+ {
+ }
+
+ return xReturn;
+}
+
+//==============================================================================
+// property handling
+//------------------------------------------------------------------------------
+void ODatabaseForm::fillProperties(
+ staruno::Sequence< starbeans::Property >& _rProps,
+ staruno::Sequence< starbeans::Property >& _rAggregateProps ) const
+{
+ BEGIN_AGGREGATION_PROPERTY_HELPER(14, m_xAggregateSet)
+ // this property is overwritten by the form
+ RemoveProperty(_rAggregateProps, PROPERTY_PRIVILEGES);
+ ModifyPropertyAttributes(_rAggregateProps, PROPERTY_DATASOURCE, starbeans::PropertyAttribute::CONSTRAINED, 0);
+
+ DECL_PROP1(NAME, ::rtl::OUString, BOUND);
+ DECL_PROP1(MASTERFIELDS, StringSequence, BOUND);
+ DECL_PROP1(DETAILFIELDS, StringSequence, BOUND);
+ DECL_PROP3(CYCLE, starform::TabulatorCycle, BOUND, MAYBEVOID, MAYBEDEFAULT);
+ DECL_PROP1(NAVIGATION, starform::NavigationBarMode, BOUND);
+ DECL_BOOL_PROP1(ALLOWADDITIONS, BOUND);
+ DECL_BOOL_PROP1(ALLOWEDITS, BOUND);
+ DECL_BOOL_PROP1(ALLOWDELETIONS, BOUND);
+ DECL_BOOL_PROP2(THREADSAFE, TRANSIENT, READONLY);
+ DECL_PROP2(PRIVILEGES, sal_Int32, TRANSIENT, READONLY);
+ DECL_PROP1(TARGET_URL, ::rtl::OUString, BOUND);
+ DECL_PROP1(TARGET_FRAME, ::rtl::OUString, BOUND);
+ DECL_PROP1(SUBMIT_METHOD, starform::FormSubmitMethod, BOUND);
+ DECL_PROP1(SUBMIT_ENCODING, starform::FormSubmitEncoding, BOUND);
+ END_AGGREGATION_PROPERTY_HELPER();
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& ODatabaseForm::getInfoHelper()
+{
+ return *const_cast<ODatabaseForm*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+staruno::Reference<starbeans::XPropertySetInfo> ODatabaseForm::getPropertySetInfo() throw( staruno::RuntimeException )
+{
+ staruno::Reference<starbeans::XPropertySetInfo> xDescriptorInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xDescriptorInfo;
+}
+
+//------------------------------------------------------------------------------
+void ODatabaseForm::fire( sal_Int32* pnHandles, const staruno::Any* pNewValues, const staruno::Any* pOldValues, sal_Int32 nCount, sal_Bool bVetoable )
+{
+ // same as in getFastPropertyValue(INT32) : if we're resetting currently don't fire any changes of the
+ // IsModified property from FALSE to TRUE, as this is only temporary 'til the reset is done
+ if (m_nResetsPending > 0)
+ {
+ // look for the PROPERTY_ID_ISMODIFIED
+ sal_Int32 nPos = 0;
+ for (nPos=0; nPos<nCount; ++nPos)
+ if (pnHandles[nPos] == PROPERTY_ID_ISMODIFIED)
+ break;
+
+ if ((nPos < nCount) && (pNewValues[nPos].getValueType().getTypeClass() == staruno::TypeClass_BOOLEAN) && getBOOL(pNewValues[nPos]))
+ { // yeah, we found it, and it changed to TRUE
+ if (nPos == 0)
+ { // just cut the first element
+ ++pnHandles;
+ ++pNewValues;
+ ++pOldValues;
+ --nCount;
+ }
+ else if (nPos == nCount - 1)
+ // just cut the last element
+ --nCount;
+ else
+ { // split into two base class calls
+ OPropertySetAggregationHelper::fire(pnHandles, pNewValues, pOldValues, nPos, bVetoable);
+ ++nPos;
+ OPropertySetAggregationHelper::fire(pnHandles + nPos, pNewValues + nPos, pOldValues + nPos, nCount - nPos, bVetoable);
+ return;
+ }
+ }
+ }
+
+ OPropertySetAggregationHelper::fire(pnHandles, pNewValues, pOldValues, nCount, bVetoable);
+}
+
+//------------------------------------------------------------------------------
+staruno::Any SAL_CALL ODatabaseForm::getFastPropertyValue( sal_Int32 nHandle )
+ throw(starbeans::UnknownPropertyException, starlang::WrappedTargetException, staruno::RuntimeException)
+{
+ if ((nHandle == PROPERTY_ID_ISMODIFIED) && (m_nResetsPending > 0))
+ return staruno::makeAny(sal_Bool(sal_False));
+ // don't allow the aggregate which is currently reset to return a (temporary) "yes"
+ else
+ return OPropertySetAggregationHelper::getFastPropertyValue(nHandle);
+}
+
+//------------------------------------------------------------------------------
+void ODatabaseForm::getFastPropertyValue( staruno::Any& rValue, sal_Int32 nHandle ) const
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_THREADSAFE:
+ {
+ try
+ {
+ staruno::Reference< starsdbc::XConnection > xActiveConn =
+ calcConnection(staruno::Reference<starsdbc::XRowSet>(m_xAggregate, staruno::UNO_QUERY), m_xServiceFactory);
+ // if we're alive, our aggregate has an active connection which will be returned
+ // if we aren't and our aggregate has no active connection, the function will calculate one
+ // from the current settings and forward it to the row set
+ staruno::Reference<starbeans::XPropertySet> xConnProps(xActiveConn, staruno::UNO_QUERY);
+ if (xConnProps.is() && hasProperty(PROPERTY_THREADSAFE, xConnProps))
+ rValue = xConnProps->getPropertyValue(PROPERTY_THREADSAFE);
+ else
+ {
+ staruno::Reference<starcontainer::XChild> xConnAsChild(xActiveConn, staruno::UNO_QUERY);
+ if (xConnAsChild.is())
+ xConnProps = staruno::Reference<starbeans::XPropertySet> (xConnAsChild->getParent(), staruno::UNO_QUERY);
+ if (xConnProps.is() && hasProperty(PROPERTY_THREADSAFE, xConnProps))
+ rValue = xConnProps->getPropertyValue(PROPERTY_THREADSAFE);
+ else
+ rValue <<= (sal_Bool)sal_False;
+ }
+ }
+ catch(...)
+ {
+ rValue <<= (sal_Bool)sal_False;
+ }
+ }
+ break;
+ case PROPERTY_ID_TARGET_URL:
+ rValue <<= m_aTargetURL;
+ break;
+ case PROPERTY_ID_TARGET_FRAME:
+ rValue <<= m_aTargetFrame;
+ break;
+ case PROPERTY_ID_SUBMIT_METHOD:
+ rValue <<= m_eSubmitMethod;
+ break;
+ case PROPERTY_ID_SUBMIT_ENCODING:
+ rValue <<= m_eSubmitEncoding;
+ break;
+ case PROPERTY_ID_NAME:
+ rValue <<= m_sName;
+ break;
+ case PROPERTY_ID_MASTERFIELDS:
+ rValue <<= m_aMasterFields;
+ break;
+ case PROPERTY_ID_DETAILFIELDS:
+ rValue <<= m_aDetailFields;
+ break;
+ case PROPERTY_ID_CYCLE:
+ rValue = m_aCycle;
+ break;
+ case PROPERTY_ID_NAVIGATION:
+ rValue <<= m_eNavigation;
+ break;
+ case PROPERTY_ID_ALLOWADDITIONS:
+ rValue <<= (sal_Bool)m_bAllowInsert;
+ break;
+ case PROPERTY_ID_ALLOWEDITS:
+ rValue <<= (sal_Bool)m_bAllowUpdate;
+ break;
+ case PROPERTY_ID_ALLOWDELETIONS:
+ rValue <<= (sal_Bool)m_bAllowDelete;
+ break;
+ case PROPERTY_ID_PRIVILEGES:
+ rValue <<= (sal_Int32)m_nPrivileges;
+ break;
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool ODatabaseForm::convertFastPropertyValue( staruno::Any& rConvertedValue, staruno::Any& rOldValue,
+ sal_Int32 nHandle, const staruno::Any& rValue ) throw( starlang::IllegalArgumentException )
+{
+ sal_Bool bModified(sal_False);
+ switch (nHandle)
+ {
+ case PROPERTY_ID_TARGET_URL:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aTargetURL);
+ break;
+ case PROPERTY_ID_TARGET_FRAME:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aTargetFrame);
+ break;
+ case PROPERTY_ID_SUBMIT_METHOD:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_eSubmitMethod);
+ break;
+ case PROPERTY_ID_SUBMIT_ENCODING:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_eSubmitEncoding);
+ break;
+ case PROPERTY_ID_NAME:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_sName);
+ break;
+ case PROPERTY_ID_MASTERFIELDS:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aMasterFields);
+ break;
+ case PROPERTY_ID_DETAILFIELDS:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aDetailFields);
+ break;
+ case PROPERTY_ID_CYCLE:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aCycle, ::getCppuType(static_cast<const starform::TabulatorCycle*>(NULL)));
+ break;
+ case PROPERTY_ID_NAVIGATION:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_eNavigation);
+ break;
+ case PROPERTY_ID_ALLOWADDITIONS:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAllowInsert);
+ break;
+ case PROPERTY_ID_ALLOWEDITS:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAllowUpdate);
+ break;
+ case PROPERTY_ID_ALLOWDELETIONS:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAllowDelete);
+ break;
+ default:
+ DBG_ERROR("ODatabaseForm::convertFastPropertyValue : unknown property !");
+ }
+ return bModified;
+}
+
+//------------------------------------------------------------------------------
+void ODatabaseForm::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const staruno::Any& rValue )
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_TARGET_URL:
+ rValue >>= m_aTargetURL;
+ break;
+ case PROPERTY_ID_TARGET_FRAME:
+ rValue >>= m_aTargetFrame;
+ break;
+ case PROPERTY_ID_SUBMIT_METHOD:
+ rValue >>= m_eSubmitMethod;
+ break;
+ case PROPERTY_ID_SUBMIT_ENCODING:
+ rValue >>= m_eSubmitEncoding;
+ break;
+ case PROPERTY_ID_NAME:
+ rValue >>= m_sName;
+ break;
+ case PROPERTY_ID_MASTERFIELDS:
+ rValue >>= m_aMasterFields;
+ break;
+ case PROPERTY_ID_DETAILFIELDS:
+ rValue >>= m_aDetailFields;
+ break;
+ case PROPERTY_ID_CYCLE:
+ m_aCycle = rValue;
+ break;
+ case PROPERTY_ID_NAVIGATION:
+ rValue >>= m_eNavigation;
+ break;
+ case PROPERTY_ID_ALLOWADDITIONS:
+ m_bAllowInsert = getBOOL(rValue);
+ break;
+ case PROPERTY_ID_ALLOWEDITS:
+ m_bAllowUpdate = getBOOL(rValue);
+ break;
+ case PROPERTY_ID_ALLOWDELETIONS:
+ m_bAllowDelete = getBOOL(rValue);
+ break;
+ default:
+ DBG_ERROR("ODatabaseForm::setFastPropertyValue_NoBroadcast : unknown property !");
+ }
+}
+
+//==============================================================================
+// com::sun::star::beans::XPropertyState
+//------------------------------------------------------------------
+starbeans::PropertyState ODatabaseForm::getPropertyStateByHandle(sal_Int32 nHandle)
+{
+ starbeans::PropertyState eState;
+ switch (nHandle)
+ {
+ case PROPERTY_ID_CYCLE:
+ if (!m_aCycle.hasValue())
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ else
+ eState = starbeans::PropertyState_DIRECT_VALUE;
+ break;
+ default:
+ eState = OPropertySetAggregationHelper::getPropertyStateByHandle(nHandle);
+ }
+ return eState;
+}
+
+//------------------------------------------------------------------
+void ODatabaseForm::setPropertyToDefaultByHandle(sal_Int32 nHandle)
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_CYCLE:
+ setFastPropertyValue(nHandle, staruno::Any());
+ break;
+ default:
+ OPropertySetAggregationHelper::setPropertyToDefaultByHandle(nHandle);
+ }
+}
+
+//------------------------------------------------------------------
+staruno::Any ODatabaseForm::getPropertyDefaultByHandle( sal_Int32 nHandle ) const
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_CYCLE:
+ return staruno::Any();
+ default:
+ return OPropertySetAggregationHelper::getPropertyDefaultByHandle(nHandle);
+ }
+}
+
+//==============================================================================
+// com::sun::star::form::XReset
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::reset() throw( staruno::RuntimeException )
+{
+ ReusableMutexGuard aGuard(m_aMutex);
+
+ if (isLoaded())
+ {
+ ::osl::MutexGuard aResetGuard(m_aResetSafety);
+ ++m_nResetsPending;
+ reset_impl(true);
+ return;
+ }
+
+ if (m_aResetListeners.getLength())
+ {
+ ::osl::MutexGuard aResetGuard(m_aResetSafety);
+ ++m_nResetsPending;
+ // create an own thread if we have (approve-)reset-listeners (so the listeners can't do that much damage
+ // to this thread which is probably the main one)
+ if (!m_pThread)
+ {
+ m_pThread = new OFormSubmitResetThread(this);
+ m_pThread->acquire();
+ m_pThread->create();
+ }
+ starlang::EventObject aEvt;
+ m_pThread->addEvent(&aEvt, sal_False);
+ }
+ else
+ {
+ // direct call without any approving by the listeners
+ aGuard.clear();
+
+ ::osl::MutexGuard aResetGuard(m_aResetSafety);
+ ++m_nResetsPending;
+ reset_impl(false);
+ }
+}
+
+//-----------------------------------------------------------------------------
+void ODatabaseForm::reset_impl(bool _bAproveByListeners)
+{
+ if (_bAproveByListeners)
+ {
+ bool bCanceled = false;
+ ::cppu::OInterfaceIteratorHelper aIter(m_aResetListeners);
+ starlang::EventObject aEvt(static_cast<staruno::XWeak*>(this));
+
+ while (aIter.hasMoreElements() && !bCanceled)
+ if (!((starform::XResetListener*)aIter.next())->approveReset(aEvt))
+ bCanceled = true;
+ if (bCanceled)
+ return;
+ }
+
+ ReusableMutexGuard aResetGuard(m_aResetSafety);
+ // do we have a database connected form and stay on the insert row
+ sal_Bool bInsertRow = sal_False;
+ if (m_xAggregateSet.is())
+ bInsertRow = getBOOL(m_xAggregateSet->getPropertyValue(PROPERTY_ISNEW));
+ if (bInsertRow)
+ {
+ // Iterate through all columns and set the default value
+ staruno::Reference<starsdbcx::XColumnsSupplier> xColsSuppl(m_xAggregateSet, staruno::UNO_QUERY);
+ staruno::Reference<starcontainer::XIndexAccess> xIndexCols(xColsSuppl->getColumns(), staruno::UNO_QUERY);
+ for (sal_Int32 i = 0; i < xIndexCols->getCount(); i++)
+ {
+ staruno::Reference<starbeans::XPropertySet> xColAsSet;
+ ::cppu::extractInterface(xColAsSet, xIndexCols->getByIndex(i));
+ ::rtl::OUString aDefault;
+ xColAsSet->getPropertyValue(PROPERTY_DEFAULT_VALUE) >>= aDefault;
+ if (!getBOOL(xColAsSet->getPropertyValue(PROPERTY_ISREADONLY)))
+ {
+ try
+ {
+ staruno::Reference<starsdb::XColumnUpdate> xColUpdate(xColAsSet, staruno::UNO_QUERY);
+ if (aDefault.getLength())
+ xColUpdate->updateString(aDefault);
+ else
+ xColUpdate->updateNull();
+ }
+ catch(...)
+ {
+ }
+ }
+ }
+
+ // now set the values on which a subform depends
+ if (m_bSubForm)
+ {
+ staruno::Reference<starsdbcx::XColumnsSupplier> xParentColsSuppl(m_xParent, staruno::UNO_QUERY);
+ staruno::Reference<starcontainer::XNameAccess> xParentCols = xParentColsSuppl->getColumns();
+ sal_Int32 nMasterLen = m_aMasterFields.getLength();
+ if (xParentCols->hasElements() && (nMasterLen > 0))
+ {
+ staruno::Reference<starcontainer::XNameAccess> xCols(xColsSuppl->getColumns(), staruno::UNO_QUERY);
+ const ::rtl::OUString* pMasterFields = m_aMasterFields.getConstArray();
+ const ::rtl::OUString* pDetailFields = m_aDetailFields.getConstArray();
+
+ for (sal_Int32 i = 0; i < nMasterLen; ++i)
+ {
+ staruno::Reference<starbeans::XPropertySet> xMasterField, xField;
+ if (xParentCols->hasByName(pMasterFields[i]) &&
+ xCols->hasByName(pDetailFields[i]))
+ {
+ ::cppu::extractInterface(xMasterField, xParentCols->getByName(pMasterFields[i]));
+ ::cppu::extractInterface(xField, xCols->getByName(pDetailFields[i]));
+ xField->setPropertyValue(PROPERTY_VALUE, xMasterField->getPropertyValue(PROPERTY_VALUE));
+ }
+ }
+ }
+ }
+ }
+
+ aResetGuard.clear();
+ // iterate through all components. don't use an starcontainer::XIndexAccess as this will cause massive
+ // problems with the count.
+ staruno::Reference<starcontainer::XEnumeration> xIter = createEnumeration();
+ while (xIter->hasMoreElements())
+ {
+ staruno::Any aElement(xIter->nextElement());
+ staruno::Reference<starform::XReset> xReset;
+ ::cppu::extractInterface(xReset, aElement);
+ if (xReset.is())
+ {
+ // TODO : all reset-methods have to be thread-safe
+ xReset->reset();
+ }
+ }
+
+ aResetGuard.attach(m_aResetSafety);
+ // ensure that the row isn't modified
+ // (do this _before_ the listeners are notified ! their reaction (maybe asynchronous) may depend
+ // on the modified state of the row
+ // 21.02.00 - 73265 - FS)
+ if (bInsertRow)
+ m_xAggregateSet->setPropertyValue(PROPERTY_ISMODIFIED, staruno::makeAny(sal_Bool(sal_False)));
+
+ aResetGuard.clear();
+ {
+ starlang::EventObject aEvt(static_cast<staruno::XWeak*>(this));
+ NOTIFY_LISTENERS(m_aResetListeners, starform::XResetListener, resetted, aEvt);
+ }
+
+ aResetGuard.attach(m_aResetSafety);
+ // and again : ensure the row isn't modified
+ // we already did this after we (and maybe our dependents) resetted the values, but the listeners may have changed the row, too
+ if (bInsertRow)
+ m_xAggregateSet->setPropertyValue(PROPERTY_ISMODIFIED, staruno::makeAny(sal_Bool(sal_False)));
+
+ --m_nResetsPending;
+}
+
+//-----------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::addResetListener(const staruno::Reference<starform::XResetListener>& _rListener) throw( staruno::RuntimeException )
+{
+ m_aResetListeners.addInterface(_rListener);
+}
+
+//-----------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::removeResetListener(const staruno::Reference<starform::XResetListener>& _rListener) throw( staruno::RuntimeException )
+{
+ m_aResetListeners.removeInterface(_rListener);
+}
+
+//==============================================================================
+// com::sun::star::form::XSubmit
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::submit( const staruno::Reference<starawt::XControl>& Control,
+ const starawt::MouseEvent& MouseEvt ) throw( staruno::RuntimeException )
+{
+ {
+ ::osl::MutexGuard aGuard(m_aMutex);
+ // Sind Controls und eine Submit-starutil::URL vorhanden?
+ if( !getCount() || !m_aTargetURL.getLength() )
+ return;
+ }
+
+ ::osl::ClearableMutexGuard aGuard(m_aMutex);
+ if (m_aSubmitListeners.getLength())
+ {
+ // create an own thread if we have (approve-)submit-listeners (so the listeners can't do that much damage
+ // to this thread which is probably the main one)
+ if (!m_pThread)
+ {
+ m_pThread = new OFormSubmitResetThread(this);
+ m_pThread->acquire();
+ m_pThread->create();
+ }
+ m_pThread->addEvent(&MouseEvt, Control, sal_True);
+ }
+ else
+ {
+ // direct call without any approving by the listeners
+ aGuard.clear();
+ submit_impl( Control, MouseEvt, true );
+ }
+}
+
+//------------------------------------------------------------------------------
+void ODatabaseForm::submit_impl(const staruno::Reference<starawt::XControl>& Control, const starawt::MouseEvent& MouseEvt, bool _bAproveByListeners)
+{
+
+ if (_bAproveByListeners)
+ {
+ ::cppu::OInterfaceIteratorHelper aIter(m_aSubmitListeners);
+ starlang::EventObject aEvt(static_cast<staruno::XWeak*>(this));
+ sal_Bool bCanceled = sal_False;
+ while (aIter.hasMoreElements() && !bCanceled)
+ {
+ if (!((starform::XSubmitListener*)aIter.next())->approveSubmit(aEvt))
+ bCanceled = sal_True;
+ }
+
+ if (bCanceled)
+ return;
+ }
+
+ starform::FormSubmitEncoding eSubmitEncoding;
+ starform::FormSubmitMethod eSubmitMethod;
+ ::rtl::OUString aURLStr;
+ ::rtl::OUString aReferer;
+ ::rtl::OUString aTargetName;
+ staruno::Reference< starframe::XModel > xModel;
+ {
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ // starform->Forms
+
+ staruno::Reference<starcontainer::XChild> xParent(m_xParent, staruno::UNO_QUERY);
+
+ if (xParent.is())
+ xModel = getXModel(xParent->getParent());
+
+ if (xModel.is())
+ aReferer = xModel->getURL();
+
+ // TargetItem
+ aTargetName = m_aTargetFrame;
+
+ eSubmitEncoding = m_eSubmitEncoding;
+ eSubmitMethod = m_eSubmitMethod;
+ aURLStr = m_aTargetURL;
+ }
+
+ if (!xModel.is())
+ return;
+
+ staruno::Reference<starutil::XURLTransformer>
+ xTransformer(m_xServiceFactory->createInstance(
+ ::rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer")), staruno::UNO_QUERY);
+ DBG_ASSERT(xTransformer.is(), "ODatabaseForm::submit_impl : could not create an URL transformer !");
+
+ // starutil::URL-Encoding
+ if( eSubmitEncoding == starform::FormSubmitEncoding_URL )
+ {
+ ::rtl::OUString aData;
+ {
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ aData = GetDataURLEncoded( Control, MouseEvt );
+ }
+
+ staruno::Reference< starframe::XFrame > xFrame = xModel->getCurrentController()->getFrame();
+ if (!xFrame.is())
+ return;
+
+ starutil::URL aURL;
+ // FormMethod GET
+ if( eSubmitMethod == starform::FormSubmitMethod_GET )
+ {
+ INetURLObject aUrlObj( aURLStr );
+ aUrlObj.SetParam( aData );
+ ::rtl::OUString aMainURL = INetURLObject::decode(aUrlObj.GetMainURL(), '%', INetURLObject::DECODE_UNAMBIGUOUS);
+
+ aURL.Complete = aMainURL;
+ xTransformer->parseStrict(aURL);
+ staruno::Reference< starframe::XDispatch > xDisp = staruno::Reference< starframe::XDispatchProvider > (xFrame,staruno::UNO_QUERY)->queryDispatch(aURL, aTargetName,
+ starframe::FrameSearchFlag::SELF | starframe::FrameSearchFlag::PARENT | starframe::FrameSearchFlag::CHILDREN |
+ starframe::FrameSearchFlag::SIBLINGS | starframe::FrameSearchFlag::CREATE | starframe::FrameSearchFlag::TASKS);
+
+ if (xDisp.is())
+ {
+ staruno::Sequence<starbeans::PropertyValue> aArgs(1);
+ aArgs.getArray()->Name = ::rtl::OUString::createFromAscii("Referer");
+ aArgs.getArray()->Value <<= aReferer;
+ xDisp->dispatch(aURL, aArgs);
+ }
+ }
+ // FormMethod POST
+ else if( eSubmitMethod == starform::FormSubmitMethod_POST )
+ {
+ aURL.Complete = aURLStr;
+ xTransformer->parseStrict(aURL);
+
+ staruno::Reference< starframe::XDispatch > xDisp = staruno::Reference< starframe::XDispatchProvider > (xFrame,staruno::UNO_QUERY)->queryDispatch(aURL, aTargetName,
+ starframe::FrameSearchFlag::SELF | starframe::FrameSearchFlag::PARENT | starframe::FrameSearchFlag::CHILDREN |
+ starframe::FrameSearchFlag::SIBLINGS | starframe::FrameSearchFlag::CREATE | starframe::FrameSearchFlag::TASKS);
+
+ if (xDisp.is())
+ {
+ staruno::Sequence<starbeans::PropertyValue> aArgs(2);
+ aArgs.getArray()[0].Name = ::rtl::OUString::createFromAscii("Referer");
+ aArgs.getArray()[0].Value <<= aReferer;
+ aArgs.getArray()[1].Name = ::rtl::OUString::createFromAscii("PostString");
+ aArgs.getArray()[1].Value <<= aData;
+
+ xDisp->dispatch(aURL, aArgs);
+ }
+ }
+ }
+ else if( eSubmitEncoding == starform::FormSubmitEncoding_MULTIPART )
+ {
+ staruno::Reference< starframe::XFrame > xFrame = xModel->getCurrentController()->getFrame();
+ if (!xFrame.is())
+ return;
+
+ starutil::URL aURL;
+ aURL.Complete = aURLStr;
+ xTransformer->parseStrict(aURL);
+
+ staruno::Reference< starframe::XDispatch > xDisp = staruno::Reference< starframe::XDispatchProvider > (xFrame,staruno::UNO_QUERY)->queryDispatch(aURL, aTargetName,
+ starframe::FrameSearchFlag::SELF | starframe::FrameSearchFlag::PARENT | starframe::FrameSearchFlag::CHILDREN |
+ starframe::FrameSearchFlag::SIBLINGS | starframe::FrameSearchFlag::CREATE | starframe::FrameSearchFlag::TASKS);
+
+ if (xDisp.is())
+ {
+ ::rtl::OUString aContentType;
+ staruno::Sequence<sal_Int8> aData;
+ {
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ aData = GetDataMultiPartEncoded(Control, MouseEvt, aContentType);
+ }
+ if (!aData.getLength())
+ return;
+
+ staruno::Sequence<starbeans::PropertyValue> aArgs(3);
+ aArgs.getArray()[0].Name = ::rtl::OUString::createFromAscii("Referer");
+ aArgs.getArray()[0].Value <<= aReferer;
+ aArgs.getArray()[1].Name = ::rtl::OUString::createFromAscii("ContentType");
+ aArgs.getArray()[1].Value <<= aContentType;
+ aArgs.getArray()[2].Name = ::rtl::OUString::createFromAscii("PostData");
+ aArgs.getArray()[2].Value <<= aData;
+
+ xDisp->dispatch(aURL, aArgs);
+ }
+ }
+ else if( eSubmitEncoding == starform::FormSubmitEncoding_TEXT )
+ {
+ ::rtl::OUString aData;
+ {
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ aData = GetDataTextEncoded( staruno::Reference<starawt::XControl> (), MouseEvt );
+ }
+
+ staruno::Reference< starframe::XFrame > xFrame = xModel->getCurrentController()->getFrame();
+ if (!xFrame.is())
+ return;
+
+ starutil::URL aURL;
+
+ aURL.Complete = aURLStr;
+ xTransformer->parseStrict(aURL);
+
+ staruno::Reference< starframe::XDispatch > xDisp = staruno::Reference< starframe::XDispatchProvider > (xFrame,staruno::UNO_QUERY)->queryDispatch(aURL, aTargetName,
+ starframe::FrameSearchFlag::SELF | starframe::FrameSearchFlag::PARENT | starframe::FrameSearchFlag::CHILDREN |
+ starframe::FrameSearchFlag::SIBLINGS | starframe::FrameSearchFlag::CREATE | starframe::FrameSearchFlag::TASKS);
+
+ if (xDisp.is())
+ {
+ staruno::Sequence<starbeans::PropertyValue> aArgs(2);
+ aArgs.getArray()[0].Name = ::rtl::OUString::createFromAscii("Referer");
+ aArgs.getArray()[0].Value <<= aReferer;
+ aArgs.getArray()[1].Name = ::rtl::OUString::createFromAscii("PostString");
+ aArgs.getArray()[1].Value <<= aData;
+
+ xDisp->dispatch(aURL, aArgs);
+ }
+ }
+ else
+ DBG_ERROR("ODatabaseForm::submit_Impl : wrong encoding !");
+
+}
+
+// starform::XSubmit
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::addSubmitListener(const staruno::Reference<starform::XSubmitListener>& _rListener) throw( staruno::RuntimeException )
+{
+ m_aSubmitListeners.addInterface(_rListener);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::removeSubmitListener(const staruno::Reference<starform::XSubmitListener>& _rListener) throw( staruno::RuntimeException )
+{
+ m_aSubmitListeners.removeInterface(_rListener);
+}
+
+//==============================================================================
+// com::sun::star::sdbc::XSQLErrorBroadcaster
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::addSQLErrorListener(const staruno::Reference<starsdb::XSQLErrorListener>& _rListener) throw( staruno::RuntimeException )
+{
+ m_aErrorListeners.addInterface(_rListener);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::removeSQLErrorListener(const staruno::Reference<starsdb::XSQLErrorListener>& _rListener) throw( staruno::RuntimeException )
+{
+ m_aErrorListeners.removeInterface(_rListener);
+}
+
+//==============================================================================
+// OChangeListener
+//------------------------------------------------------------------------------
+void ODatabaseForm::_propertyChanged(const starbeans::PropertyChangeEvent& evt) throw( staruno::RuntimeException )
+{
+ // if the statement has changed we have to delete the parameter info
+ ::osl::MutexGuard aGuard(m_aMutex);
+ DELETEZ(m_pParameterInfo);
+ clearParameters();
+}
+
+//==============================================================================
+// smartstarcontainer::XChild
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setParent(const InterfaceRef& Parent)
+{
+ ReusableMutexGuard aGuard(m_aMutex);
+
+ staruno::Reference<starform::XForm> xParentForm(getParent(), staruno::UNO_QUERY);
+ if (xParentForm.is())
+ {
+ staruno::Reference<starsdb::XRowSetApproveBroadcaster> xParentApprBroadcast(xParentForm, staruno::UNO_QUERY);
+ if (xParentApprBroadcast.is())
+ xParentApprBroadcast->removeRowSetApproveListener(this);
+ staruno::Reference<starform::XLoadable> xParentLoadable(xParentForm, staruno::UNO_QUERY);
+ if (xParentLoadable.is())
+ xParentLoadable->removeLoadListener(this);
+ }
+
+ OFormComponents::setParent(Parent);
+
+ xParentForm = staruno::Reference<starform::XForm> (getParent(), staruno::UNO_QUERY);
+ if (xParentForm.is())
+ {
+ staruno::Reference<starsdb::XRowSetApproveBroadcaster> xParentApprBroadcast(xParentForm, staruno::UNO_QUERY);
+ if (xParentApprBroadcast.is())
+ xParentApprBroadcast->addRowSetApproveListener(this);
+ staruno::Reference<starform::XLoadable> xParentLoadable(xParentForm, staruno::UNO_QUERY);
+ if (xParentLoadable.is())
+ xParentLoadable->addLoadListener(this);
+ }
+}
+
+//==============================================================================
+// smartstarawt::XTabControllerModel
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseForm::getGroupControl() throw(com::sun::star::uno::RuntimeException)
+{
+ ReusableMutexGuard aGuard(m_aMutex);
+
+ // Sollen Controls in einer TabOrder gruppe zusammengefaßt werden?
+ if (m_aCycle.hasValue())
+ {
+ sal_Int32 nCycle;
+ ::cppu::enum2int(nCycle, m_aCycle);
+ return nCycle != starform::TabulatorCycle_PAGE;
+ }
+
+ if (isLoaded() && getConnection().is())
+ return sal_True;
+
+ return sal_False;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setControlModels(const staruno::Sequence<staruno::Reference<starawt::XControlModel> >& rControls) throw( staruno::RuntimeException )
+{
+ ReusableMutexGuard aGuard(m_aMutex);
+
+ // TabIndex in der Reihenfolge der Sequence setzen
+ const staruno::Reference<starawt::XControlModel>* pControls = rControls.getConstArray();
+ sal_Int16 nTabIndex = 1;
+ sal_Int32 nCount = getCount();
+ sal_Int32 nNewCount = rControls.getLength();
+
+ // HiddenControls und Formulare werden nicht aufgefuehrt
+ if (nNewCount <= nCount)
+ {
+ staruno::Any aElement;
+ for (sal_Int32 i=0; i < nNewCount; ++i, ++pControls)
+ {
+ staruno::Reference<starform::XFormComponent> xComp(*pControls, staruno::UNO_QUERY);
+ if (xComp.is())
+ {
+ // suchen der Componente in der Liste
+ for (sal_Int32 j = 0; j < nCount; ++j)
+ {
+ staruno::Reference<starform::XFormComponent> xElement;
+ ::cppu::extractInterface(xElement, getByIndex(j));
+ if (xComp == xElement)
+ {
+ staruno::Reference<starbeans::XPropertySet> xSet(xComp, staruno::UNO_QUERY);
+ if (xSet.is() && hasProperty(PROPERTY_TABINDEX, xSet))
+ xSet->setPropertyValue( PROPERTY_TABINDEX, staruno::makeAny(nTabIndex++) );
+ break;
+ }
+ }
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Reference<starawt::XControlModel> > SAL_CALL ODatabaseForm::getControlModels() throw( staruno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ return m_pGroupManager->getControlModels();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setGroup( const staruno::Sequence<staruno::Reference<starawt::XControlModel> >& _rGroup, const ::rtl::OUString& Name ) throw( staruno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ // Die Controls werden gruppiert, indem ihr Name dem Namen des ersten
+ // Controls der Sequenz angepasst wird
+ const staruno::Reference<starawt::XControlModel>* pControls = _rGroup.getConstArray();
+ staruno::Reference<starbeans::XPropertySet> xSet;
+ ::rtl::OUString sGroupName;
+
+ for( sal_Int32 i=0; i<_rGroup.getLength(); ++i, ++pControls )
+ {
+ staruno::Reference<starbeans::XPropertySet> xSet(*pControls, staruno::UNO_QUERY);
+
+ if (!sGroupName.getLength())
+ xSet->getPropertyValue(PROPERTY_NAME) >>= sGroupName;
+ else
+ xSet->setPropertyValue(PROPERTY_NAME, staruno::makeAny(sGroupName));
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseForm::getGroupCount() throw( staruno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ return m_pGroupManager->getGroupCount();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::getGroup( sal_Int32 nGroup, staruno::Sequence<staruno::Reference<starawt::XControlModel> >& _rGroup, ::rtl::OUString& Name ) throw( staruno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ m_pGroupManager->getGroup( nGroup, _rGroup, Name );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::getGroupByName(const ::rtl::OUString& Name, staruno::Sequence< staruno::Reference<starawt::XControlModel> >& _rGroup) throw( staruno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ m_pGroupManager->getGroupByName( Name, _rGroup );
+}
+
+//==============================================================================
+// com::sun::star::lang::XEventListener
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::disposing(const starlang::EventObject& Source) throw( staruno::RuntimeException )
+{
+ OInterfaceContainer::disposing(Source);
+}
+
+//==============================================================================
+// com::sun::star::form::XLoadListener
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::loaded(const starlang::EventObject& aEvent) throw( staruno::RuntimeException )
+{
+ // now start the rowset listening to recover cursor events
+ load_impl(sal_True);
+ {
+ ::osl::MutexGuard aGuard(m_aMutex);
+ staruno::Reference<starsdbc::XRowSet> xParentRowSet(m_xParent, staruno::UNO_QUERY);
+ if (xParentRowSet.is())
+ xParentRowSet->addRowSetListener(this);
+
+ m_pLoadTimer = new Timer();
+ m_pLoadTimer->SetTimeout(100);
+ m_pLoadTimer->SetTimeoutHdl(LINK(this,ODatabaseForm,OnTimeout));
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::unloading(const starlang::EventObject& aEvent) throw( staruno::RuntimeException )
+{
+ {
+ // now stop the rowset listening if we are a subform
+ ::osl::MutexGuard aGuard(m_aMutex);
+ DELETEZ(m_pLoadTimer);
+
+ staruno::Reference<starsdbc::XRowSet> xParentRowSet(m_xParent, staruno::UNO_QUERY);
+ if (xParentRowSet.is())
+ xParentRowSet->removeRowSetListener(this);
+ }
+ unload();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::unloaded(const starlang::EventObject& aEvent) throw( staruno::RuntimeException )
+{
+ // nothing to do
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::reloading(const starlang::EventObject& aEvent) throw( staruno::RuntimeException )
+{
+ // now stop the rowset listening if we are a subform
+ ::osl::MutexGuard aGuard(m_aMutex);
+ staruno::Reference<starsdbc::XRowSet> xParentRowSet(m_xParent, staruno::UNO_QUERY);
+ if (xParentRowSet.is())
+ xParentRowSet->removeRowSetListener(this);
+
+ if (m_pLoadTimer && m_pLoadTimer->IsActive())
+ m_pLoadTimer->Stop();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::reloaded(const starlang::EventObject& aEvent) throw( staruno::RuntimeException )
+{
+ reload_impl(sal_True);
+ {
+ ::osl::MutexGuard aGuard(m_aMutex);
+ staruno::Reference<starsdbc::XRowSet> xParentRowSet(m_xParent, staruno::UNO_QUERY);
+ if (xParentRowSet.is())
+ xParentRowSet->addRowSetListener(this);
+ }
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( ODatabaseForm, OnTimeout, void*, EMPTYARG )
+{
+ reload_impl(sal_True);
+ return 1;
+}
+
+//==============================================================================
+// com::sun::star::form::XLoadable
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::load() throw( staruno::RuntimeException )
+{
+ load_impl(sal_False);
+}
+
+//------------------------------------------------------------------------------
+void ODatabaseForm::load_impl(sal_Bool bCausedByParentForm, sal_Bool bMoveToFirst) throw( staruno::RuntimeException )
+{
+ ReusableMutexGuard aGuard(m_aMutex);
+
+ // are we already loaded?
+ if (isLoaded())
+ return;
+
+ m_bSubForm = bCausedByParentForm;
+
+ // if we don't have a connection, we are not intended to be a database form or the aggregate was not able
+ // to establish a connection
+ sal_Bool bConnected = sal_False;
+ try
+ {
+ if (m_xAggregateSet.is())
+ {
+ // do we have a connection in the hierarchy than take that connection
+ // this overwrites all the other connnections
+ staruno::Reference< starsdbc::XConnection > xConnection = calcConnection(
+ staruno::Reference<starsdbc::XRowSet> (m_xAggregate, staruno::UNO_QUERY),
+ m_xServiceFactory
+ ); // will set a calculated connection implicitly
+ bConnected = xConnection.is();
+ }
+ }
+ catch(starsdbc::SQLException& eDB)
+ {
+ onError(eDB, FRM_RES_STRING(RID_STR_CONNECTERROR));
+ }
+
+ // we don't have to execute if we do not have a command to execute
+ sal_Bool bExecute = bConnected && m_xAggregateSet.is() && getString(m_xAggregateSet->getPropertyValue(PROPERTY_COMMAND)).getLength();
+
+ // a database form always uses caching
+ // we use starting fetchsize with at least 10 rows
+ if (bConnected)
+ m_xAggregateSet->setPropertyValue(PROPERTY_FETCHSIZE, staruno::makeAny((sal_Int32)10));
+
+ // if we're loaded as sub form we got a "rowSetChanged" from the parent rowset _before_ we got the "loaded"
+ // so we don't need to execute the statement again, this was already done
+ // (and there were no relevant changes between these two listener calls, the "load" of a form is quite an
+ // atomar operation.)
+
+ if (bExecute)
+ {
+ m_sCurrentErrorContext = FRM_RES_STRING(RID_ERR_LOADING_FORM);
+ executeRowSet(aGuard, bMoveToFirst);
+ }
+
+ m_bLoaded = sal_True;
+ aGuard.clear();
+ starlang::EventObject aEvt(static_cast<staruno::XWeak*>(this));
+ NOTIFY_LISTENERS(m_aLoadListeners, starform::XLoadListener, loaded, aEvt);
+
+ // if we are on the insert row, we have to reset all controls
+ // to set the default values
+ if (bExecute && getBOOL(m_xAggregateSet->getPropertyValue(PROPERTY_ISNEW)))
+ reset();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::unload() throw( staruno::RuntimeException )
+{
+ ReusableMutexGuard aGuard(m_aMutex);
+ if (!isLoaded())
+ return;
+
+ DELETEZ(m_pLoadTimer);
+
+ aGuard.clear();
+ starlang::EventObject aEvt(static_cast<staruno::XWeak*>(this));
+ NOTIFY_LISTENERS(m_aLoadListeners, starform::XLoadListener, unloading, aEvt);
+
+ if (m_xAggregateAsRowSet.is())
+ {
+ // clear the parameters if there are any
+ DELETEZ(m_pParameterInfo);
+ clearParameters();
+
+ try
+ {
+ // close the aggregate
+ staruno::Reference<starsdbc::XCloseable> xCloseable;
+ query_aggregation( m_xAggregate, xCloseable);
+ aGuard.clear();
+ if (xCloseable.is())
+ xCloseable->close();
+ }
+ catch(starsdbc::SQLException& eDB)
+ {
+ eDB;
+ }
+ aGuard.attach(m_aMutex);
+ }
+
+ m_bLoaded = sal_False;
+
+ aGuard.clear();
+ NOTIFY_LISTENERS(m_aLoadListeners, starform::XLoadListener, unloaded, aEvt);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::reload() throw( staruno::RuntimeException )
+{
+ reload_impl(sal_True);
+}
+
+//------------------------------------------------------------------------------
+void ODatabaseForm::reload_impl(sal_Bool bMoveToFirst) throw( staruno::RuntimeException )
+{
+ ReusableMutexGuard aGuard(m_aMutex);
+ if (!isLoaded())
+ return;
+
+ starlang::EventObject aEvent(static_cast<staruno::XWeak*>(this));
+ {
+ // only if there is no approve listener we can post the event at this time
+ // otherwise see approveRowsetChange
+ // the aprrovement is done by the aggregate
+ if (!m_aRowSetApproveListeners.getLength())
+ {
+ ::cppu::OInterfaceIteratorHelper aIter(m_aLoadListeners);
+ aGuard.clear();
+
+ while (aIter.hasMoreElements())
+ ((starform::XLoadListener*)aIter.next())->reloading(aEvent);
+
+ aGuard.attach(m_aMutex);
+ }
+ }
+
+ try
+ {
+ m_sCurrentErrorContext = FRM_RES_STRING(RID_ERR_REFRESHING_FORM);
+ executeRowSet(aGuard, bMoveToFirst);
+ }
+ catch(starsdbc::SQLException& e)
+ {
+ DBG_ERROR("ODatabaseForm::reload_impl : shouldn't executeRowSet catch this exception ?");
+ e;
+ }
+
+ {
+ ::cppu::OInterfaceIteratorHelper aIter(m_aLoadListeners);
+ aGuard.clear();
+ while (aIter.hasMoreElements())
+ ((starform::XLoadListener*)aIter.next())->reloaded(aEvent);
+
+ // if we are on the insert row, we have to reset all controls
+ // to set the default values
+ if (getBOOL(m_xAggregateSet->getPropertyValue(PROPERTY_ISNEW)))
+ reset();
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseForm::isLoaded() throw( staruno::RuntimeException )
+{
+ return m_bLoaded;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::addLoadListener(const staruno::Reference<starform::XLoadListener>& aListener) throw( staruno::RuntimeException )
+{
+ m_aLoadListeners.addInterface(aListener);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::removeLoadListener(const staruno::Reference<starform::XLoadListener>& aListener) throw( staruno::RuntimeException )
+{
+ m_aLoadListeners.removeInterface(aListener);
+}
+
+//==============================================================================
+// com::sun::star::sdbc::XCloseable
+//==============================================================================
+void SAL_CALL ODatabaseForm::close() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ // unload will close the aggregate
+ unload();
+}
+
+//==============================================================================
+// com::sun::star::sdbc::XRowSetListener
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::cursorMoved(const starlang::EventObject& event) throw( staruno::RuntimeException )
+{
+ // reload the subform with the new parameters of the parent
+ // do this handling delayed to provide of execute too many SQL Statements
+ ReusableMutexGuard aGuard(m_aMutex);
+ if (m_pLoadTimer->IsActive())
+ m_pLoadTimer->Stop();
+
+ // and start the timer again
+ m_pLoadTimer->Start();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::rowChanged(const starlang::EventObject& event) throw( staruno::RuntimeException )
+{
+ // ignore it
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::rowSetChanged(const starlang::EventObject& event) throw( staruno::RuntimeException )
+{
+ // not interested in :
+ // if our parent is an ODatabaseForm, too, then after this rowSetChanged we'll get a "reloaded"
+ // or a "loaded" event.
+ // If somebody gave us another parent which is an starsdbc::XRowSet but doesn't handle an execute as
+ // "load" respectivly "reload" ... can't do anything ....
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseForm::approveCursorMove(const starlang::EventObject& event) throw( staruno::RuntimeException )
+{
+ // is our aggregate calling?
+ if (event.Source == InterfaceRef(static_cast<staruno::XWeak*>(this)))
+ {
+ // Our aggregate doesn't have any ApproveRowSetListeners (expect ourself), as we re-routed the queryInterface
+ // for starsdb::XRowSetApproveBroadcaster-interface.
+ // So we have to multiplex this approve request.
+ ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners);
+ while (aIter.hasMoreElements())
+ if (!((starsdb::XRowSetApproveListener*)aIter.next())->approveCursorMove(event))
+ return sal_False;
+ }
+ else
+ {
+ // this is a call from our parent ...
+ // a parent's cursor move will result in a re-execute of our own row-set, so we have to
+ // ask our own RowSetChangesListeners, too
+ ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners);
+ while (aIter.hasMoreElements())
+ if (!((starsdb::XRowSetApproveListener*)aIter.next())->approveRowSetChange(event))
+ return sal_False;
+ }
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseForm::approveRowChange(const starsdb::RowChangeEvent& event) throw( staruno::RuntimeException )
+{
+ // is our aggregate calling?
+ if (event.Source == InterfaceRef(static_cast<staruno::XWeak*>(this)))
+ {
+ // Our aggregate doesn't have any ApproveRowSetListeners (expect ourself), as we re-routed the queryInterface
+ // for starsdb::XRowSetApproveBroadcaster-interface.
+ // So we have to multiplex this approve request.
+ ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners);
+ while (aIter.hasMoreElements())
+ if (!((starsdb::XRowSetApproveListener*)aIter.next())->approveRowChange(event))
+ return sal_False;
+ }
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseForm::approveRowSetChange(const starlang::EventObject& event) throw( staruno::RuntimeException )
+{
+ if (event.Source == InterfaceRef(static_cast<staruno::XWeak*>(this))) // ignore our aggregate as we handle this approve ourself
+ {
+ ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners);
+ while (aIter.hasMoreElements())
+ if (!((starsdb::XRowSetApproveListener*)aIter.next())->approveRowSetChange(event))
+ return sal_False;
+
+ if (isLoaded())
+ {
+ ::cppu::OInterfaceIteratorHelper aLoadIter(m_aLoadListeners);
+ while (aLoadIter.hasMoreElements())
+ ((starform::XLoadListener*)aLoadIter.next())->reloading(event);
+ }
+ }
+ else
+ {
+ // this is a call from our parent ...
+ // a parent's cursor move will result in a re-execute of our own row-set, so we have to
+ // ask our own RowSetChangesListeners, too
+ ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners);
+ while (aIter.hasMoreElements())
+ if (!((starsdb::XRowSetApproveListener*)aIter.next())->approveRowSetChange(event))
+ return sal_False;
+ }
+ return sal_True;
+}
+
+//==============================================================================
+// com::sun::star::sdb::XRowSetApproveBroadcaster
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::addRowSetApproveListener(const staruno::Reference<starsdb::XRowSetApproveListener>& _rListener) throw( staruno::RuntimeException )
+{
+ ReusableMutexGuard aGuard(m_aMutex);
+ m_aRowSetApproveListeners.addInterface(_rListener);
+
+ // do we have to multiplex ?
+ if (m_aRowSetApproveListeners.getLength() == 1)
+ {
+ staruno::Reference<starsdb::XRowSetApproveBroadcaster> xBroadcaster;
+ if (query_aggregation( m_xAggregate, xBroadcaster))
+ {
+ staruno::Reference<starsdb::XRowSetApproveListener> xListener((starsdb::XRowSetApproveListener*)this);
+ xBroadcaster->addRowSetApproveListener(xListener);
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::removeRowSetApproveListener(const staruno::Reference<starsdb::XRowSetApproveListener>& _rListener) throw( staruno::RuntimeException )
+{
+ ReusableMutexGuard aGuard(m_aMutex);
+ // do we have to remove the multiplex ?
+ if (m_aRowSetApproveListeners.getLength() == 1)
+ {
+ staruno::Reference<starsdb::XRowSetApproveBroadcaster> xBroadcaster;
+ if (query_aggregation( m_xAggregate, xBroadcaster))
+ {
+ staruno::Reference<starsdb::XRowSetApproveListener> xListener((starsdb::XRowSetApproveListener*)this);
+ xBroadcaster->removeRowSetApproveListener(xListener);
+ }
+ }
+ m_aRowSetApproveListeners.removeInterface(_rListener);
+}
+
+//==============================================================================
+// com::sun:star::form::XDatabaseParameterBroadcaster
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::addParameterListener(const staruno::Reference<starform::XDatabaseParameterListener>& _rListener) throw( staruno::RuntimeException )
+{
+ m_aParameterListeners.addInterface(_rListener);
+}
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::removeParameterListener(const staruno::Reference<starform::XDatabaseParameterListener>& _rListener) throw( staruno::RuntimeException )
+{
+ m_aParameterListeners.removeInterface(_rListener);
+}
+
+//==============================================================================
+// com::sun::star::sdbc::XRowSet
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::execute() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ ReusableMutexGuard aGuard(m_aMutex);
+ // This methods is called only from outside, we ourself don't use our own starsdbc::XRowSet interface but the one of our
+ // aggregate when calling an execute.
+ // DBG_ASSERT(!isExecuting(), "ODatabaseForm::execute : oops ... our own erxecute ?");
+ // This thread shouldn't be within executeRowSet (as stated above) and any other thread should be blocked
+ // because of our mutex ....
+
+ // So if somebody calls an execute and we're not loaded we reroute this call to our load method.
+
+ // the difference between execute and load is, that we position on the first row in case of load
+ // after execute we remain before the first row
+ if (!isLoaded())
+ {
+ aGuard.clear();
+ load_impl(sal_False, sal_False);
+ }
+ else
+ {
+ starlang::EventObject event(static_cast< staruno::XWeak* >(this));
+ ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners);
+ aGuard.clear();
+
+ while (aIter.hasMoreElements())
+ if (!((starsdb::XRowSetApproveListener*)aIter.next())->approveRowSetChange(event))
+ return;
+
+ // we're loaded and somebody want's to execute ourself -> this means a reload
+ reload_impl(sal_False);
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::addRowSetListener(const staruno::Reference<starsdbc::XRowSetListener>& _rListener) throw( staruno::RuntimeException )
+{
+ if (m_xAggregateAsRowSet.is())
+ m_xAggregateAsRowSet->addRowSetListener(_rListener);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::removeRowSetListener(const staruno::Reference<starsdbc::XRowSetListener>& _rListener) throw( staruno::RuntimeException )
+{
+ if (m_xAggregateAsRowSet.is())
+ m_xAggregateAsRowSet->removeRowSetListener(_rListener);
+}
+
+//==============================================================================
+// com::sun::star::sdbc::XResultSet
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseForm::next() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ return m_xAggregateAsRowSet->next();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseForm::isBeforeFirst() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ return m_xAggregateAsRowSet->isBeforeFirst();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseForm::isAfterLast() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ return m_xAggregateAsRowSet->isAfterLast();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseForm::isFirst() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ return m_xAggregateAsRowSet->isFirst();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseForm::isLast() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ return m_xAggregateAsRowSet->isLast();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::beforeFirst() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ m_xAggregateAsRowSet->beforeFirst();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::afterLast() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ m_xAggregateAsRowSet->afterLast();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseForm::first() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ return m_xAggregateAsRowSet->first();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseForm::last() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ return m_xAggregateAsRowSet->last();
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseForm::getRow() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ return m_xAggregateAsRowSet->getRow();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseForm::absolute(sal_Int32 row) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ return m_xAggregateAsRowSet->absolute(row);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseForm::relative(sal_Int32 rows) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ return m_xAggregateAsRowSet->relative(rows);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseForm::previous() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ return m_xAggregateAsRowSet->previous();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::refreshRow() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ m_xAggregateAsRowSet->refreshRow();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseForm::rowUpdated() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ return m_xAggregateAsRowSet->rowUpdated();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseForm::rowInserted() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ return m_xAggregateAsRowSet->rowInserted();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseForm::rowDeleted() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ return m_xAggregateAsRowSet->rowDeleted();
+}
+
+//------------------------------------------------------------------------------
+InterfaceRef SAL_CALL ODatabaseForm::getStatement() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ return m_xAggregateAsRowSet->getStatement();
+}
+
+// com::sun::star::sdbc::XResultSetUpdate
+// exceptions during insert update and delete will be forwarded to the errorlistener
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::insertRow() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ try
+ {
+ staruno::Reference<starsdbc::XResultSetUpdate> xUpdate;
+ if (query_aggregation( m_xAggregate, xUpdate))
+ xUpdate->insertRow();
+ }
+ catch(starsdb::RowSetVetoException& eVeto)
+ {
+ eVeto;
+ throw;
+ }
+ catch(starsdbc::SQLException& eDb)
+ {
+ onError(eDb, FRM_RES_STRING(RID_STR_ERR_INSERTRECORD));
+ throw;
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::updateRow() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ try
+ {
+ staruno::Reference<starsdbc::XResultSetUpdate> xUpdate;
+ if (query_aggregation( m_xAggregate, xUpdate))
+ xUpdate->updateRow();
+ }
+ catch(starsdb::RowSetVetoException& eVeto)
+ {
+ eVeto;
+ throw;
+ }
+ catch(starsdbc::SQLException& eDb)
+ {
+ onError(eDb, FRM_RES_STRING(RID_STR_ERR_UPDATERECORD));
+ throw;
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::deleteRow() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ try
+ {
+ staruno::Reference<starsdbc::XResultSetUpdate> xUpdate;
+ if (query_aggregation( m_xAggregate, xUpdate))
+ xUpdate->deleteRow();
+ }
+ catch(starsdb::RowSetVetoException& eVeto)
+ {
+ eVeto;
+ throw;
+ }
+ catch(starsdbc::SQLException& eDb)
+ {
+ onError(eDb, FRM_RES_STRING(RID_STR_ERR_DELETERECORD));
+ throw;
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::cancelRowUpdates() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ staruno::Reference<starsdbc::XResultSetUpdate> xUpdate;
+ if (query_aggregation( m_xAggregate, xUpdate))
+ xUpdate->cancelRowUpdates();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::moveToInsertRow() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ staruno::Reference<starsdbc::XResultSetUpdate> xUpdate;
+ if (query_aggregation( m_xAggregate, xUpdate))
+ {
+ // do we go on the insert row?
+ if (!getBOOL(m_xAggregateSet->getPropertyValue(PROPERTY_ISNEW)))
+ xUpdate->moveToInsertRow();
+
+ // then set the default values and the parameters given from the parent
+ reset();
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::moveToCurrentRow() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ staruno::Reference<starsdbc::XResultSetUpdate> xUpdate;
+ if (query_aggregation( m_xAggregate, xUpdate))
+ xUpdate->moveToCurrentRow();
+}
+
+// com::sun::star::sdbcx::XDeleteRows
+//------------------------------------------------------------------------------
+staruno::Sequence<sal_Int32> SAL_CALL ODatabaseForm::deleteRows(const staruno::Sequence<staruno::Any>& rows) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ try
+ {
+ staruno::Reference<starsdbcx::XDeleteRows> xDelete;
+ if (query_aggregation( m_xAggregate, xDelete))
+ return xDelete->deleteRows(rows);
+ }
+ catch(starsdb::RowSetVetoException& eVeto)
+ {
+ eVeto; // make compiler happy
+ throw;
+ }
+ catch(starsdbc::SQLException& eDb)
+ {
+ onError(eDb, FRM_RES_STRING(RID_STR_ERR_DELETERECORDS));
+ throw;
+ }
+
+ return staruno::Sequence< sal_Int32 >();
+}
+
+// com::sun::star::sdbc::XParameters
+//------------------------------------------------------------------------------
+#define PARAMETER_VISITED(method) \
+ ::osl::MutexGuard aGuard(m_aMutex); \
+ staruno::Reference<starsdbc::XParameters> xParameters; \
+ if (query_aggregation( m_xAggregate, xParameters)) \
+ xParameters->method; \
+ \
+ if (m_aParameterVisited.size() < parameterIndex) \
+ { \
+ for (sal_Int32 i = 0; i < parameterIndex; i++) \
+ m_aParameterVisited.push_back(false); \
+ } \
+ m_aParameterVisited[parameterIndex - 1] = true
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setNull(sal_Int32 parameterIndex, sal_Int32 sqlType) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ PARAMETER_VISITED(setNull(parameterIndex, sqlType));
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setObjectNull(sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ PARAMETER_VISITED(setObjectNull(parameterIndex, sqlType, typeName));
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setBoolean(sal_Int32 parameterIndex, sal_Bool x) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ PARAMETER_VISITED(setBoolean(parameterIndex, x));
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setByte(sal_Int32 parameterIndex, sal_Int8 x) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ PARAMETER_VISITED(setByte(parameterIndex, x));
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setShort(sal_Int32 parameterIndex, sal_Int16 x) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ PARAMETER_VISITED(setShort(parameterIndex, x));
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setInt(sal_Int32 parameterIndex, sal_Int32 x) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ PARAMETER_VISITED(setInt(parameterIndex, x));
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setLong(sal_Int32 parameterIndex, Hyper x) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ PARAMETER_VISITED(setLong(parameterIndex, x));
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setFloat(sal_Int32 parameterIndex, float x) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ PARAMETER_VISITED(setFloat(parameterIndex, x));
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setDouble(sal_Int32 parameterIndex, double x) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ PARAMETER_VISITED(setDouble(parameterIndex, x));
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setString(sal_Int32 parameterIndex, const ::rtl::OUString& x) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ PARAMETER_VISITED(setString(parameterIndex, x));
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setBytes(sal_Int32 parameterIndex, const staruno::Sequence< sal_Int8 >& x) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ PARAMETER_VISITED(setBytes(parameterIndex, x));
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setDate(sal_Int32 parameterIndex, const starutil::Date& x) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ PARAMETER_VISITED(setDate(parameterIndex, x));
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setTime(sal_Int32 parameterIndex, const starutil::Time& x) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ PARAMETER_VISITED(setTime(parameterIndex, x));
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setTimestamp(sal_Int32 parameterIndex, const starutil::DateTime& x) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ PARAMETER_VISITED(setTimestamp(parameterIndex, x));
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setBinaryStream(sal_Int32 parameterIndex, const staruno::Reference<stario::XInputStream>& x, sal_Int32 length) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ PARAMETER_VISITED(setBinaryStream(parameterIndex, x, length));
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setCharacterStream(sal_Int32 parameterIndex, const staruno::Reference<stario::XInputStream>& x, sal_Int32 length) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ PARAMETER_VISITED(setCharacterStream(parameterIndex, x, length));
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setObjectWithInfo(sal_Int32 parameterIndex, const staruno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ PARAMETER_VISITED(setObjectWithInfo(parameterIndex, x, targetSqlType, scale));
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setObject(sal_Int32 parameterIndex, const staruno::Any& x) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ PARAMETER_VISITED(setObject(parameterIndex, x));
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setRef(sal_Int32 parameterIndex, const staruno::Reference<starsdbc::XRef>& x) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ PARAMETER_VISITED(setRef(parameterIndex, x));
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setBlob(sal_Int32 parameterIndex, const staruno::Reference<starsdbc::XBlob>& x) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ PARAMETER_VISITED(setBlob(parameterIndex, x));
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setClob(sal_Int32 parameterIndex, const staruno::Reference<starsdbc::XClob>& x) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ PARAMETER_VISITED(setClob(parameterIndex, x));
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setArray(sal_Int32 parameterIndex, const staruno::Reference<starsdbc::XArray>& x) throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ PARAMETER_VISITED(setArray(parameterIndex, x));
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::clearParameters() throw( starsdbc::SQLException, staruno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ staruno::Reference<starsdbc::XParameters> xParameters;
+ if (query_aggregation(m_xAggregate, xParameters))
+ xParameters->clearParameters();
+ m_aParameterVisited.clear();
+}
+
+// com::sun::star::lang::XServiceInfo
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseForm::getImplementationName() throw( staruno::RuntimeException )
+{
+ return DATABASEFORM_IMPLEMENTATION_NAME;
+}
+
+//------------------------------------------------------------------------------
+StringSequence SAL_CALL ODatabaseForm::getSupportedServiceNames() throw( staruno::RuntimeException )
+{
+ StringSequence aServices;
+ aServices.realloc(5);
+ aServices.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.form.FormComponent");
+ aServices.getArray()[1] = ::rtl::OUString::createFromAscii("com.sun.star.form.FormComponents");
+ aServices.getArray()[2] = FRM_SUN_COMPONENT_FORM;
+ aServices.getArray()[3] = FRM_SUN_COMPONENT_HTMLFORM;
+ aServices.getArray()[4] = FRM_SUN_COMPONENT_DATAFORM;
+ return aServices;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseForm::supportsService(const ::rtl::OUString& ServiceName) throw( staruno::RuntimeException )
+{
+ StringSequence aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pArray = aSupported.getConstArray();
+ for( sal_Int32 i = 0; i < aSupported.getLength(); ++i, ++pArray )
+ if( pArray->equals(ServiceName) )
+ return sal_True;
+ return sal_False;
+}
+
+//==============================================================================
+// com::sun::star::io::XPersistObject
+//------------------------------------------------------------------------------
+
+const sal_uInt16 CYCLE = 0x0001;
+const sal_uInt16 DONTAPPLYFILTER = 0x0002;
+
+//------------------------------------------------------------------------------
+::rtl::OUString ODatabaseForm::getServiceName() throw( staruno::RuntimeException )
+{
+ return FRM_COMPONENT_FORM; // old (non-sun) name for compatibility !
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream) throw( stario::IOException, staruno::RuntimeException )
+{
+ DBG_ASSERT(m_xAggregateSet.is(), "ODatabaseForm::write : only to be called if the aggregate exists !");
+
+ // all children
+ OFormComponents::write(_rxOutStream);
+
+ // version
+ _rxOutStream->writeShort(0x0003);
+
+ // Name
+ _rxOutStream << m_sName;
+
+ ::rtl::OUString sDataSource;
+ if (m_xAggregateSet.is())
+ m_xAggregateSet->getPropertyValue(PROPERTY_DATASOURCE) >>= sDataSource;
+ _rxOutStream << sDataSource;
+
+ // former CursorSource
+ ::rtl::OUString sCommand;
+ if (m_xAggregateSet.is())
+ m_xAggregateSet->getPropertyValue(PROPERTY_COMMAND) >>= sCommand;
+ _rxOutStream << sCommand;
+
+ // former MasterFields
+ _rxOutStream << m_aMasterFields;
+ // former DetailFields
+ _rxOutStream << m_aDetailFields;
+
+ // former DataSelectionType
+ starform::DataSelectionType eTranslated = starform::DataSelectionType_TABLE;
+ if (m_xAggregateSet.is())
+ {
+ sal_Int32 nCommandType;
+ m_xAggregateSet->getPropertyValue(PROPERTY_COMMANDTYPE) >>= nCommandType;
+ switch (nCommandType)
+ {
+ case starsdb::CommandType::TABLE : eTranslated = starform::DataSelectionType_TABLE; break;
+ case starsdb::CommandType::QUERY : eTranslated = starform::DataSelectionType_QUERY; break;
+ case starsdb::CommandType::COMMAND:
+ {
+ sal_Bool bEscapeProcessing = getBOOL(m_xAggregateSet->getPropertyValue(PROPERTY_ESCAPE_PROCESSING));
+ eTranslated = bEscapeProcessing ? starform::DataSelectionType_SQL : starform::DataSelectionType_SQLPASSTHROUGH;
+ }
+ break;
+ default : DBG_ERROR("ODatabaseForm::write : wrong CommandType !");
+ }
+ }
+ _rxOutStream->writeShort((sal_Int16)eTranslated); // former DataSelectionType
+
+ // very old versions expect a CursorType here
+ _rxOutStream->writeShort(stardata::DatabaseCursorType_KEYSET);
+
+ _rxOutStream->writeBoolean(m_eNavigation != starform::NavigationBarMode_NONE);
+
+ // former DataEntry
+ if (m_xAggregateSet.is())
+ _rxOutStream->writeBoolean(getBOOL(m_xAggregateSet->getPropertyValue(PROPERTY_INSERTONLY)));
+ else
+ _rxOutStream->writeBoolean(sal_False);
+
+ _rxOutStream->writeBoolean(m_bAllowInsert);
+ _rxOutStream->writeBoolean(m_bAllowUpdate);
+ _rxOutStream->writeBoolean(m_bAllowDelete);
+
+ // html form stuff
+ ::rtl::OUString sTmp = INetURLObject::decode(INetURLObject::AbsToRel( m_aTargetURL ), '%', INetURLObject::DECODE_UNAMBIGUOUS);
+ _rxOutStream << sTmp;
+ _rxOutStream->writeShort( (sal_Int16)m_eSubmitMethod );
+ _rxOutStream->writeShort( (sal_Int16)m_eSubmitEncoding );
+ _rxOutStream << m_aTargetFrame;
+
+ // version 2 didn't know some options and the "default" state
+ sal_Int32 nCycle = starform::TabulatorCycle_RECORDS;
+ if (m_aCycle.hasValue())
+ {
+ ::cppu::enum2int(nCycle, m_aCycle);
+ if (m_aCycle == starform::TabulatorCycle_PAGE)
+ // unknown in earlier versions
+ nCycle = starform::TabulatorCycle_RECORDS;
+ }
+ _rxOutStream->writeShort((sal_Int16) nCycle);
+
+ _rxOutStream->writeShort((sal_Int16)m_eNavigation);
+
+ ::rtl::OUString sFilter;
+ ::rtl::OUString sOrder;
+ if (m_xAggregateSet.is())
+ {
+ m_xAggregateSet->getPropertyValue(PROPERTY_FILTER_CRITERIA) >>= sFilter;
+ m_xAggregateSet->getPropertyValue(PROPERTY_SORT) >>= sOrder;
+ }
+ _rxOutStream << sFilter;
+ _rxOutStream << sOrder;
+
+
+ // version 3
+ sal_uInt16 nAnyMask = 0;
+ if (m_aCycle.hasValue())
+ nAnyMask |= CYCLE;
+
+ if (m_xAggregateSet.is() && !getBOOL(m_xAggregateSet->getPropertyValue(PROPERTY_APPLYFILTER)))
+ nAnyMask |= DONTAPPLYFILTER;
+
+ _rxOutStream->writeShort(nAnyMask);
+
+ if (nAnyMask & CYCLE)
+ {
+ sal_Int32 nCycle;
+ ::cppu::enum2int(nCycle, m_aCycle);
+ _rxOutStream->writeShort(nCycle);
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream) throw( stario::IOException, staruno::RuntimeException )
+{
+ DBG_ASSERT(m_xAggregateSet.is(), "ODatabaseForm::read : only to be called if the aggregate exists !");
+
+ OFormComponents::read(_rxInStream);
+
+ // version
+ sal_uInt16 nVersion = _rxInStream->readShort();
+
+ _rxInStream >> m_sName;
+
+ ::rtl::OUString sAggregateProp;
+ _rxInStream >> sAggregateProp;
+ if (m_xAggregateSet.is())
+ m_xAggregateSet->setPropertyValue(PROPERTY_DATASOURCE, staruno::makeAny(sAggregateProp));
+ _rxInStream >> sAggregateProp;
+ if (m_xAggregateSet.is())
+ m_xAggregateSet->setPropertyValue(PROPERTY_COMMAND, staruno::makeAny(sAggregateProp));
+
+ _rxInStream >> m_aMasterFields;
+ _rxInStream >> m_aDetailFields;
+
+ sal_Int16 nCursorSourceType = _rxInStream->readShort();
+ sal_Int32 nCommandType = 0;
+ switch ((starform::DataSelectionType)nCursorSourceType)
+ {
+ case starform::DataSelectionType_TABLE : nCommandType = starsdb::CommandType::TABLE; break;
+ case starform::DataSelectionType_QUERY : nCommandType = starsdb::CommandType::QUERY; break;
+ case starform::DataSelectionType_SQL:
+ case starform::DataSelectionType_SQLPASSTHROUGH:
+ {
+ nCommandType = starsdb::CommandType::COMMAND;
+ sal_Bool bEscapeProcessing = ((starform::DataSelectionType)nCursorSourceType) != starform::DataSelectionType_SQLPASSTHROUGH;
+ m_xAggregateSet->setPropertyValue(PROPERTY_ESCAPE_PROCESSING, staruno::makeAny((sal_Bool)bEscapeProcessing));
+ }
+ break;
+ default : DBG_ERROR("ODatabaseForm::read : wrong CommandType !");
+ }
+ if (m_xAggregateSet.is())
+ m_xAggregateSet->setPropertyValue(PROPERTY_COMMANDTYPE, staruno::makeAny(nCommandType));
+
+ // obsolete
+ sal_Int16 nDummy = _rxInStream->readShort();
+
+ // navigation mode was a boolean in version 1
+ // war in der version 1 ein sal_Bool
+ sal_Bool bNavigation = _rxInStream->readBoolean();
+ if (nVersion == 1)
+ m_eNavigation = bNavigation ? starform::NavigationBarMode_CURRENT : starform::NavigationBarMode_NONE;
+
+ sal_Bool bInsertOnly = _rxInStream->readBoolean();
+ if (m_xAggregateSet.is())
+ m_xAggregateSet->setPropertyValue(PROPERTY_INSERTONLY, staruno::makeAny(bInsertOnly));
+
+ m_bAllowInsert = _rxInStream->readBoolean();
+ m_bAllowUpdate = _rxInStream->readBoolean();
+ m_bAllowDelete = _rxInStream->readBoolean();
+
+ // html stuff
+ ::rtl::OUString sTmp;
+ _rxInStream >> sTmp;
+ m_aTargetURL = INetURLObject::decode(INetURLObject::RelToAbs( sTmp ), '%', INetURLObject::DECODE_UNAMBIGUOUS);
+ m_eSubmitMethod = (starform::FormSubmitMethod)_rxInStream->readShort();
+ m_eSubmitEncoding = (starform::FormSubmitEncoding)_rxInStream->readShort();
+ _rxInStream >> m_aTargetFrame;
+
+ if (nVersion > 1)
+ {
+ sal_Int32 nCycle = _rxInStream->readShort();
+ m_aCycle = ::cppu::int2enum(nCycle, ::getCppuType(static_cast<const starform::TabulatorCycle*>(NULL)));
+ m_eNavigation = (starform::NavigationBarMode)_rxInStream->readShort();
+
+ _rxInStream >> sAggregateProp;
+ if (m_xAggregateSet.is())
+ m_xAggregateSet->setPropertyValue(PROPERTY_FILTER_CRITERIA, staruno::makeAny(sAggregateProp));
+ _rxInStream >> sAggregateProp;
+ if (m_xAggregateSet.is())
+ m_xAggregateSet->setPropertyValue(PROPERTY_SORT, staruno::makeAny(sAggregateProp));
+ }
+
+ sal_uInt16 nAnyMask = 0;
+ if (nVersion > 2)
+ {
+ nAnyMask = _rxInStream->readShort();
+ if (nAnyMask & CYCLE)
+ {
+ sal_Int32 nCycle = _rxInStream->readShort();
+ m_aCycle = ::cppu::int2enum(nCycle, ::getCppuType(static_cast<const starform::TabulatorCycle*>(NULL)));
+ }
+ else
+ m_aCycle.clear();
+ }
+ if (m_xAggregateSet.is())
+ m_xAggregateSet->setPropertyValue(PROPERTY_APPLYFILTER, staruno::makeAny((sal_Bool)((nAnyMask & DONTAPPLYFILTER) == 0)));
+}
+
+//------------------------------------------------------------------------------
+void ODatabaseForm::implInserted(const InterfaceRef& _rxObject)
+{
+ OFormComponents::implInserted(_rxObject);
+
+ staruno::Reference<starsdb::XSQLErrorBroadcaster> xBroadcaster(_rxObject, staruno::UNO_QUERY);
+ staruno::Reference<starform::XForm> xForm(_rxObject, staruno::UNO_QUERY);
+ if (xBroadcaster.is() && !xForm.is())
+ { // the object is an error broadcaster, but no form itself -> add ourself as listener
+ xBroadcaster->addSQLErrorListener(this);
+ }
+}
+
+//------------------------------------------------------------------------------
+void ODatabaseForm::implRemoved(const InterfaceRef& _rxObject)
+{
+ OFormComponents::implInserted(_rxObject);
+
+ staruno::Reference<starsdb::XSQLErrorBroadcaster> xBroadcaster(_rxObject, staruno::UNO_QUERY);
+ staruno::Reference<starform::XForm> xForm(_rxObject, staruno::UNO_QUERY);
+ if (xBroadcaster.is() && !xForm.is())
+ { // the object is an error broadcaster, but no form itself -> remove ourself as listener
+ xBroadcaster->removeSQLErrorListener(this);
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::errorOccured(const starsdb::SQLErrorEvent& _rEvent) throw( staruno::RuntimeException )
+{
+ // give it to my own error listener
+ onError(_rEvent);
+ // TODO : think about extending the chain with an starsdb::SQLContext object saying
+ // "this was an error of one of my children"
+}
+
+// com::sun::star::container::XNamed
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseForm::getName() throw( staruno::RuntimeException )
+{
+ ::rtl::OUString sReturn;
+ OPropertySetHelper::getFastPropertyValue(PROPERTY_ID_NAME) >>= sReturn;
+ return sReturn;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseForm::setName(const ::rtl::OUString& aName) throw( staruno::RuntimeException )
+{
+ setFastPropertyValue(PROPERTY_ID_NAME, staruno::makeAny(aName));
+}
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
diff --git a/forms/source/component/DatabaseForm.hxx b/forms/source/component/DatabaseForm.hxx
new file mode 100644
index 000000000000..6d6549e17aed
--- /dev/null
+++ b/forms/source/component/DatabaseForm.hxx
@@ -0,0 +1,554 @@
+/*************************************************************************
+ *
+ * $RCSfile: DatabaseForm.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FRM_DATABASEFORM_HXX_
+#define _FRM_DATABASEFORM_HXX_
+
+#ifndef _COM_SUN_STAR_SDB_XSQLERRORLISTENER_HPP_
+#include <com/sun/star/sdb/XSQLErrorListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XPERSISTOBJECT_HPP_
+#include <com/sun/star/io/XPersistObject.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSQLERRORBROADCASTER_HPP_
+#include <com/sun/star/sdb/XSQLErrorBroadcaster.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_FORMSUBMITMETHOD_HPP_
+#include <com/sun/star/form/FormSubmitMethod.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_FORMSUBMITENCODING_HPP_
+#include <com/sun/star/form/FormSubmitEncoding.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XSUBMIT_HPP_
+#include <com/sun/star/form/XSubmit.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XRESET_HPP_
+#include <com/sun/star/form/XReset.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XDATABASEPARAMETERBROADCASTER_HPP_
+#include <com/sun/star/form/XDatabaseParameterBroadcaster.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROWSET_HPP_
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDELETEROWS_HPP_
+#include <com/sun/star/sdbcx/XDeleteRows.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETUPDATE_HPP_
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XROWSETAPPROVELISTENER_HPP_
+#include <com/sun/star/sdb/XRowSetApproveListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XROWSETAPPROVEBROADCASTER_HPP_
+#include <com/sun/star/sdb/XRowSetApproveBroadcaster.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_NAVIGATIONBARMODE_HPP_
+#include <com/sun/star/form/NavigationBarMode.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XLOADABLE_HPP_
+#include <com/sun/star/form/XLoadable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XLOADLISTENER_HPP_
+#include <com/sun/star/form/XLoadListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORM_HPP_
+#include <com/sun/star/form/XForm.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XTABCONTROLLERMODEL_HPP_
+#include <com/sun/star/awt/XTabControllerModel.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SCRIPT_XEVENTATTACHERMANAGER_HPP_
+#include <com/sun/star/script/XEventAttacherManager.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROWSETLISTENER_HPP_
+#include <com/sun/star/sdbc/XRowSetListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XRESULTSETACCESS_HPP_
+#include <com/sun/star/sdb/XResultSetAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCLOSEABLE_HPP_
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_
+#include <com/sun/star/container/XNamed.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XPARAMETERS_HPP_
+#include <com/sun/star/sdbc/XParameters.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+
+
+#ifndef _LINK_HXX
+#include <tools/link.hxx>
+#endif
+#ifndef _FRM_INTERFACE_CONTAINER_HXX_
+#include "InterfaceContainer.hxx"
+#endif
+#ifndef _FRM_IDS_HXX_
+#include "ids.hxx"
+#endif
+
+#ifndef _UNOTOOLS_PROPERTY_AGGREGATION_HXX_
+#include <unotools/propagg.hxx>
+#endif
+#ifndef _UNOTOOLS_PROPERTY_MULTIPLEX_HXX_
+#include <unotools/propmultiplex.hxx>
+#endif
+#ifndef _UTL_UNO3_HXX_
+#include <unotools/uno3.hxx>
+#endif
+#ifndef _UNOTOOLS_GUARDING_HXX_
+#include <unotools/guarding.hxx>
+#endif
+#ifndef _UNOTOOLS_PROPERTY_ARRAY_HELPER_HXX_
+#include <unotools/proparrhlp.hxx>
+#endif
+
+namespace com { namespace sun { namespace star { namespace sdbc {
+ class SQLException;
+} } } }
+
+class Timer;
+class INetMIMEMessage;
+
+typedef ::utl::OReusableGuard< ::osl::Mutex > ReusableMutexGuard;
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+ namespace starsdb = ::com::sun::star::sdb;
+ namespace starsdbc = ::com::sun::star::sdbc;
+ namespace starsdbcx = ::com::sun::star::sdbcx;
+ namespace starform = ::com::sun::star::form;
+ namespace starutil = ::com::sun::star::util;
+
+//========================================================================
+//= html tools
+//========================================================================
+
+const sal_uInt16 SUCCESSFUL_REPRESENT_TEXT = 0x0001;
+const sal_uInt16 SUCCESSFUL_REPRESENT_FILE = 0x0002;
+
+const ::rtl::OUString ALL_COMPONENTS_GROUP_NAME = ::rtl::OUString::createFromAscii("AllComponentGroup");
+
+//------------------------------------------------------------------------------
+class HtmlSuccessfulObj
+{
+public:
+ ::rtl::OUString aName;
+ ::rtl::OUString aValue;
+ sal_uInt16 nRepresentation;
+
+ HtmlSuccessfulObj( const ::rtl::OUString& _rName, const ::rtl::OUString& _rValue,
+ sal_uInt16 _nRepresent = SUCCESSFUL_REPRESENT_TEXT )
+ :aName( _rName )
+ ,aValue( _rValue )
+ ,nRepresentation( _nRepresent )
+ {
+ }
+
+ HtmlSuccessfulObj()
+ {
+ }
+};
+
+
+DECLARE_STL_VECTOR(HtmlSuccessfulObj, HtmlSuccessfulObjList);
+
+//========================================================================
+class OGroupManager;
+class OFormSubmitResetThread;
+struct OParameterInfoImpl;
+class ODatabaseForm :public OFormComponents
+ ,public OPropertySetAggregationHelper
+ ,public OPropertyChangeListener
+ ,public ::utl::OAggregationArrayUsageHelper<ODatabaseForm>
+ ,public starsdb::XSQLErrorBroadcaster
+ // service com::sun::star::form::component::Form (supported by com::sun::star::form::component::DataForm)
+ ,public starform::XForm
+ ,public starawt::XTabControllerModel
+ // already present (via OFormComponents) : com::sun::star::script::XEventAttacherManager
+ // service com::sun::star::form::component::HTMLForm
+ ,public starform::XReset
+ ,public starform::XSubmit
+ // other stuff (new or re-routed interfaces)
+ ,public starform::XLoadListener
+ ,public starform::XLoadable
+ ,public starsdbc::XCloseable
+ ,public starsdbc::XRowSet
+ ,public starsdbc::XRowSetListener
+ ,public starsdb::XRowSetApproveListener
+ ,public starsdb::XRowSetApproveBroadcaster
+ ,public starsdbc::XResultSetUpdate
+ ,public starsdbcx::XDeleteRows
+ ,public starsdbc::XParameters
+ ,public starform::XDatabaseParameterBroadcaster
+ // already preset (via OFormComponents) : stario::XPersistObject
+ ,public starsdb::XSQLErrorListener
+ ,public starcontainer::XNamed
+ ,public starlang::XServiceInfo
+{
+ friend class OFormSubmitResetThread;
+
+ OImplementationIdsRef m_aHoldIdHelper;
+
+ // listener administration
+ ::cppu::OInterfaceContainerHelper m_aLoadListeners;
+ ::cppu::OInterfaceContainerHelper m_aRowSetApproveListeners;
+ ::cppu::OInterfaceContainerHelper m_aRowSetListeners;
+ ::cppu::OInterfaceContainerHelper m_aParameterListeners;
+ ::cppu::OInterfaceContainerHelper m_aResetListeners;
+ ::cppu::OInterfaceContainerHelper m_aSubmitListeners;
+ ::cppu::OInterfaceContainerHelper m_aErrorListeners;
+
+ staruno::Any m_aCycle;
+ StringSequence m_aMasterFields;
+ StringSequence m_aDetailFields;
+ ::std::vector<bool> m_aParameterVisited;
+
+ // the object doin' most of the work - an SDB-rowset
+ staruno::Reference<staruno::XAggregation> m_xAggregate;
+ // same object, interface as member because of performance reasons
+ staruno::Reference<starsdbc::XRowSet> m_xAggregateAsRowSet;
+
+ // Verwaltung der ControlGruppen
+ OGroupManager* m_pGroupManager;
+ OParameterInfoImpl* m_pParameterInfo;
+ Timer* m_pLoadTimer;
+
+ OFormSubmitResetThread* m_pThread;
+ ::rtl::OUString m_sCurrentErrorContext;
+ // will be used as additional context information
+ // when an exception is catched and forwarded to the listeners
+
+ ::osl::Mutex m_aResetSafety;
+ INT32 m_nResetsPending;
+
+// <overwritten_properties>
+ sal_Int32 m_nPrivileges;
+// </overwritten_properties>
+
+// <properties>
+ ::rtl::OUString m_sName;
+ ::rtl::OUString m_aTargetURL;
+ ::rtl::OUString m_aTargetFrame;
+ starform::FormSubmitMethod m_eSubmitMethod;
+ starform::FormSubmitEncoding m_eSubmitEncoding;
+ starform::NavigationBarMode m_eNavigation;
+ sal_Bool m_bAllowInsert : 1;
+ sal_Bool m_bAllowUpdate : 1;
+ sal_Bool m_bAllowDelete : 1;
+// </properties>
+ sal_Bool m_bLoaded : 1;
+ sal_Bool m_bSubForm : 1;
+
+public:
+ ODatabaseForm(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+ ~ODatabaseForm();
+
+ // UNO binding
+ DECLARE_UNO3_AGG_DEFAULTS(ODatabaseForm, OFormComponents);
+ virtual staruno::Any SAL_CALL queryAggregation(const staruno::Type& _rType) throw(staruno::RuntimeException);
+
+ // XTypeProvider
+ virtual staruno::Sequence<staruno::Type> SAL_CALL getTypes( ) throw(staruno::RuntimeException);
+ virtual staruno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(staruno::RuntimeException);
+
+ // starlang::XComponent
+ virtual void SAL_CALL disposing();
+
+ // property handling
+ virtual staruno::Reference< starbeans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(staruno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+ virtual void SAL_CALL getFastPropertyValue(staruno::Any& rValue, sal_Int32 nHandle ) const;
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(staruno::Any& rConvertedValue, staruno::Any& rOldValue, sal_Int32 nHandle, const staruno::Any& rValue ) throw(starlang::IllegalArgumentException);
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const staruno::Any& rValue);
+
+ staruno::Any SAL_CALL getFastPropertyValue( sal_Int32 nHandle )
+ throw(starbeans::UnknownPropertyException, starlang::WrappedTargetException, staruno::RuntimeException);
+ void fire( sal_Int32 * pnHandles, const staruno::Any * pNewValues, const staruno::Any * pOldValues, sal_Int32 nCount, sal_Bool bVetoable );
+
+ virtual void fillProperties(
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rProps,
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rAggregateProps
+ ) const;
+
+ // com::sun::star::beans::XPropertyState
+ virtual starbeans::PropertyState getPropertyStateByHandle(sal_Int32 nHandle);
+ virtual void setPropertyToDefaultByHandle(sal_Int32 nHandle);
+ virtual staruno::Any getPropertyDefaultByHandle(sal_Int32 nHandle) const;
+
+ // com::sun::star::sdbc::XSQLErrorBroadcaster
+ virtual void SAL_CALL addSQLErrorListener(const staruno::Reference<starsdb::XSQLErrorListener>& _rxListener) throw(staruno::RuntimeException);
+ virtual void SAL_CALL removeSQLErrorListener(const staruno::Reference<starsdb::XSQLErrorListener>& _rxListener) throw(staruno::RuntimeException);
+
+ // com::sun::star::form::XForm
+ // nothing to implement
+
+ // com::sun::star::form::XReset
+ virtual void SAL_CALL reset() throw(staruno::RuntimeException);
+ virtual void SAL_CALL addResetListener(const staruno::Reference<starform::XResetListener>& _rxListener) throw(staruno::RuntimeException);
+ virtual void SAL_CALL removeResetListener(const staruno::Reference<starform::XResetListener>& _rxListener) throw(staruno::RuntimeException);
+
+ // com::sun::star::form::XSubmit
+ virtual void SAL_CALL submit(const staruno::Reference<starawt::XControl>& aControl, const starawt::MouseEvent& aMouseEvt) throw(staruno::RuntimeException);
+ virtual void SAL_CALL addSubmitListener(const staruno::Reference<starform::XSubmitListener>& _rxListener) throw(staruno::RuntimeException);
+ virtual void SAL_CALL removeSubmitListener(const staruno::Reference<starform::XSubmitListener>& _rxListener) throw(staruno::RuntimeException);
+
+ // com::sun::star::container::XChild
+ virtual InterfaceRef SAL_CALL getParent() { return OFormComponents::getParent(); }
+ virtual void SAL_CALL setParent(const InterfaceRef& Parent);
+
+ // com::sun::star::container::XNamed
+ virtual ::rtl::OUString SAL_CALL getName() throw(staruno::RuntimeException);
+ virtual void SAL_CALL setName(const ::rtl::OUString& aName) throw(staruno::RuntimeException);
+
+ // com::sun::star::awt::XTabControllerModel
+ virtual sal_Bool SAL_CALL getGroupControl() throw(staruno::RuntimeException);
+ virtual void SAL_CALL setGroupControl(sal_Bool _bGroupControl) throw(staruno::RuntimeException) { }
+ virtual void SAL_CALL setControlModels(const staruno::Sequence< staruno::Reference< starawt::XControlModel > >& _rControls) throw(staruno::RuntimeException);
+ virtual staruno::Sequence< staruno::Reference< starawt::XControlModel > > SAL_CALL getControlModels() throw(staruno::RuntimeException);
+ virtual void SAL_CALL setGroup(const staruno::Sequence< staruno::Reference< starawt::XControlModel > >& _rGroup, const ::rtl::OUString& _rGroupName) throw(staruno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getGroupCount() throw(staruno::RuntimeException);
+ virtual void SAL_CALL getGroup(sal_Int32 _nGroup, staruno::Sequence< staruno::Reference< starawt::XControlModel > >& _rxGroup, ::rtl::OUString& _rName) throw(staruno::RuntimeException);
+ virtual void SAL_CALL getGroupByName(const ::rtl::OUString& _rName, staruno::Sequence< staruno::Reference< starawt::XControlModel > >& _rxGroup) throw(staruno::RuntimeException);
+
+ // com::sun::star::lang::XEventListener
+ virtual void SAL_CALL disposing(const starlang::EventObject& _rSource) throw(staruno::RuntimeException);
+
+ // com::sun::star::form::XLoadListener
+ virtual void SAL_CALL loaded(const starlang::EventObject& aEvent) throw(staruno::RuntimeException);
+ virtual void SAL_CALL unloading(const starlang::EventObject& aEvent) throw(staruno::RuntimeException);
+ virtual void SAL_CALL unloaded(const starlang::EventObject& aEvent) throw(staruno::RuntimeException);
+ virtual void SAL_CALL reloading(const starlang::EventObject& aEvent) throw(staruno::RuntimeException);
+ virtual void SAL_CALL reloaded(const starlang::EventObject& aEvent) throw(staruno::RuntimeException);
+
+ // com::sun::star::form::XLoadable
+ virtual void SAL_CALL load() throw(staruno::RuntimeException);
+ virtual void SAL_CALL unload() throw(staruno::RuntimeException);
+ virtual void SAL_CALL reload() throw(staruno::RuntimeException);
+ virtual sal_Bool SAL_CALL isLoaded() throw(staruno::RuntimeException);
+ virtual void SAL_CALL addLoadListener(const staruno::Reference<starform::XLoadListener>& _rxListener) throw(staruno::RuntimeException);
+ virtual void SAL_CALL removeLoadListener(const staruno::Reference<starform::XLoadListener>& _rxListener) throw(staruno::RuntimeException);
+
+ // com::sun::star::sdbc::XCloseable
+ virtual void SAL_CALL close() throw(starsdbc::SQLException, staruno::RuntimeException);
+
+ // com::sun::star::sdbc::XRowSetListener
+ virtual void SAL_CALL cursorMoved(const starlang::EventObject& event) throw(staruno::RuntimeException);
+ virtual void SAL_CALL rowChanged(const starlang::EventObject& event) throw(staruno::RuntimeException);
+ virtual void SAL_CALL rowSetChanged(const starlang::EventObject& event) throw(staruno::RuntimeException);
+
+ // com::sun::star::sdb::XRowSetApproveListener
+ virtual sal_Bool SAL_CALL approveCursorMove(const starlang::EventObject& event) throw(staruno::RuntimeException);
+ virtual sal_Bool SAL_CALL approveRowChange(const starsdb::RowChangeEvent& event) throw(staruno::RuntimeException);
+ virtual sal_Bool SAL_CALL approveRowSetChange(const starlang::EventObject& event) throw(staruno::RuntimeException);
+
+ // com::sun::star::sdb::XRowSetApproveBroadcaster
+ virtual void SAL_CALL addRowSetApproveListener(const staruno::Reference<starsdb::XRowSetApproveListener>& _rxListener) throw(staruno::RuntimeException);
+ virtual void SAL_CALL removeRowSetApproveListener(const staruno::Reference<starsdb::XRowSetApproveListener>& _rxListener) throw(staruno::RuntimeException);
+
+ // com::sun:star::form::XDatabaseParameterBroadcaster
+ virtual void SAL_CALL addParameterListener(const staruno::Reference<starform::XDatabaseParameterListener>& _rxListener) throw(staruno::RuntimeException);
+ virtual void SAL_CALL removeParameterListener(const staruno::Reference<starform::XDatabaseParameterListener>& _rxListener) throw(staruno::RuntimeException);
+
+ // com::sun::star::sdbc::XRowSet
+ virtual void SAL_CALL execute() throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL addRowSetListener(const staruno::Reference<starsdbc::XRowSetListener>& _rxListener) throw(staruno::RuntimeException);
+ virtual void SAL_CALL removeRowSetListener(const staruno::Reference<starsdbc::XRowSetListener>& _rxListener) throw(staruno::RuntimeException);
+
+ // com::sun::star::sdbc::XResultSet
+ virtual sal_Bool SAL_CALL next() throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual sal_Bool SAL_CALL isBeforeFirst() throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual sal_Bool SAL_CALL isAfterLast() throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual sal_Bool SAL_CALL isFirst() throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual sal_Bool SAL_CALL isLast() throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL beforeFirst() throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL afterLast() throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual sal_Bool SAL_CALL first() throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual sal_Bool SAL_CALL last() throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getRow() throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual sal_Bool SAL_CALL absolute(sal_Int32 row) throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual sal_Bool SAL_CALL relative(sal_Int32 rows) throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual sal_Bool SAL_CALL previous() throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL refreshRow() throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual sal_Bool SAL_CALL rowUpdated() throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual sal_Bool SAL_CALL rowInserted() throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual sal_Bool SAL_CALL rowDeleted() throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual InterfaceRef SAL_CALL getStatement() throw(starsdbc::SQLException, staruno::RuntimeException);
+
+ // com::sun::star::sdbc::XResultSetUpdate
+ virtual void SAL_CALL insertRow() throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL updateRow() throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL deleteRow() throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL cancelRowUpdates() throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL moveToInsertRow() throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL moveToCurrentRow() throw(starsdbc::SQLException, staruno::RuntimeException);
+
+ // com::sun::star::sdbcx::XDeleteRows
+ virtual staruno::Sequence< sal_Int32 > SAL_CALL deleteRows(const staruno::Sequence<staruno::Any>& rows) throw(starsdbc::SQLException, staruno::RuntimeException);
+
+ // com::sun::star::lang::XServiceInfo
+ virtual sal_Bool SAL_CALL supportsService(const ::rtl::OUString& ServiceName) throw(staruno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(staruno::RuntimeException);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw(staruno::RuntimeException);
+
+ // com::sun::star::io::XPersistObject
+ virtual ::rtl::OUString SAL_CALL getServiceName() throw(staruno::RuntimeException);
+ virtual void SAL_CALL write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream) throw(stario::IOException, staruno::RuntimeException);
+ virtual void SAL_CALL read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream) throw(stario::IOException, staruno::RuntimeException);
+
+ // com::sun::star::sdbc::XSQLErrorListener
+ virtual void SAL_CALL errorOccured(const starsdb::SQLErrorEvent& aEvent) throw(staruno::RuntimeException);
+
+ // com::sun::star::sdbc::XParameters
+ virtual void SAL_CALL setNull(sal_Int32 parameterIndex, sal_Int32 sqlType) throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL setObjectNull(sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName) throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL setBoolean(sal_Int32 parameterIndex, sal_Bool x) throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL setByte(sal_Int32 parameterIndex, sal_Int8 x) throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL setShort(sal_Int32 parameterIndex, sal_Int16 x) throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL setInt(sal_Int32 parameterIndex, sal_Int32 x) throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL setLong(sal_Int32 parameterIndex, Hyper x) throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL setFloat(sal_Int32 parameterIndex, float x) throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL setDouble(sal_Int32 parameterIndex, double x) throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL setString(sal_Int32 parameterIndex, const ::rtl::OUString& x) throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL setBytes(sal_Int32 parameterIndex, const staruno::Sequence< sal_Int8 >& x) throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL setDate(sal_Int32 parameterIndex, const starutil::Date& x) throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL setTime(sal_Int32 parameterIndex, const starutil::Time& x) throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL setTimestamp(sal_Int32 parameterIndex, const starutil::DateTime& x) throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL setBinaryStream(sal_Int32 parameterIndex, const staruno::Reference<stario::XInputStream>& x, sal_Int32 length) throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL setCharacterStream(sal_Int32 parameterIndex, const staruno::Reference<stario::XInputStream>& x, sal_Int32 length) throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL setObject(sal_Int32 parameterIndex, const staruno::Any& x) throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL setObjectWithInfo(sal_Int32 parameterIndex, const staruno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale) throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL setRef(sal_Int32 parameterIndex, const staruno::Reference<starsdbc::XRef>& x) throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL setBlob(sal_Int32 parameterIndex, const staruno::Reference<starsdbc::XBlob>& x) throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL setClob(sal_Int32 parameterIndex, const staruno::Reference<starsdbc::XClob>& x) throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL setArray(sal_Int32 parameterIndex, const staruno::Reference<starsdbc::XArray>& x) throw(starsdbc::SQLException, staruno::RuntimeException);
+ virtual void SAL_CALL clearParameters() throw(starsdbc::SQLException, staruno::RuntimeException);
+
+
+ inline void submitNBC( const staruno::Reference<starawt::XControl>& Control, const starawt::MouseEvent& MouseEvt );
+
+protected:
+ virtual void implInserted(const InterfaceRef& _rxObject);
+ virtual void implRemoved(const InterfaceRef& _rxObject);
+
+ // OPropertyChangeListener
+ virtual void _propertyChanged( const starbeans::PropertyChangeEvent& ) throw(staruno::RuntimeException);
+
+private:
+ void executeRowSet(ReusableMutexGuard& _rClearForNotifies, sal_Bool bMoveToFirst = sal_True);
+ bool fillParameters(ReusableMutexGuard& _rClearForNotifies);
+ OParameterInfoImpl* createParameterInfo() const;
+ bool hasValidParent() const;
+ // if there are no parameter infos we now that we have a complete new statement to execute
+ bool needStatementRebuild() const {return m_pParameterInfo == NULL;}
+
+ // impl methods
+ void load_impl(sal_Bool bCausedByParentForm, sal_Bool bMoveToFirst = sal_True) throw(staruno::RuntimeException);
+ void reload_impl(sal_Bool bMoveToFirst) throw(staruno::RuntimeException);
+ void submit_impl(const staruno::Reference<starawt::XControl>& Control, const starawt::MouseEvent& MouseEvt, bool _bAproveByListeners);
+ void reset_impl(bool _bAproveByListeners);
+
+ // error handling
+ void onError(const starsdb::SQLErrorEvent& _rEvent);
+ void onError(starsdbc::SQLException&, const ::rtl::OUString& _rContextDescription);
+
+ // html tools
+ ::rtl::OUString GetDataURLEncoded(const staruno::Reference<starawt::XControl>& SubmitButton, const starawt::MouseEvent& MouseEvt);
+ ::rtl::OUString GetDataTextEncoded(const staruno::Reference<starawt::XControl>& SubmitButton, const starawt::MouseEvent& MouseEvt);
+ staruno::Sequence<sal_Int8> GetDataMultiPartEncoded(const staruno::Reference<starawt::XControl>& SubmitButton, const starawt::MouseEvent& MouseEvt,
+ ::rtl::OUString& rContentType);
+
+ void AppendComponent(HtmlSuccessfulObjList& rList, const staruno::Reference<starbeans::XPropertySet>& xComponentSet, const ::rtl::OUString& rNamePrefix,
+ const staruno::Reference<starawt::XControl>& rxSubmitButton, const starawt::MouseEvent& MouseEvt);
+
+ void FillSuccessfulList(HtmlSuccessfulObjList& rList, const staruno::Reference<starawt::XControl>& rxSubmitButton, const starawt::MouseEvent& MouseEvt);
+
+ void InsertTextPart(INetMIMEMessage& rParent, const ::rtl::OUString& rName, const ::rtl::OUString& rData);
+ sal_Bool InsertFilePart(INetMIMEMessage& rParent, const ::rtl::OUString& rName, const ::rtl::OUString& rFileName);
+ void Encode(::rtl::OUString& rString) const;
+
+ staruno::Reference< starsdbc::XConnection > getConnection();
+
+ DECL_LINK( OnTimeout, void* );
+};
+
+inline void ODatabaseForm::submitNBC(const staruno::Reference<starawt::XControl>& Control, const starawt::MouseEvent& MouseEvt)
+{
+ submit_impl(Control, MouseEvt, sal_False);
+}
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
+#endif // _FRM_DATABASEFORM_HXX_
+
+
diff --git a/forms/source/component/Date.cxx b/forms/source/component/Date.cxx
new file mode 100644
index 000000000000..a19f51a7c918
--- /dev/null
+++ b/forms/source/component/Date.cxx
@@ -0,0 +1,303 @@
+/*************************************************************************
+ *
+ * $RCSfile: Date.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_DATE_HXX_
+#include "Date.hxx"
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _DATE_HXX
+#include <tools/date.hxx>
+#endif
+#ifndef _UNOTOOLS_DATETIME_HXX_
+#include <unotools/datetime.hxx>
+#endif
+#ifndef _UTL_DB_CONVERSION_HXX_
+#include <unotools/dbconversion.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+//------------------------------------------------------------------
+ODateControl::ODateControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OBoundControl(_rxFactory, VCL_CONTROL_DATEFIELD)
+{
+}
+
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL ODateControl_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new ODateControl(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> ODateControl::_getTypes()
+{
+ return OBoundControl::_getTypes();
+}
+
+//------------------------------------------------------------------------------
+StringSequence SAL_CALL ODateControl::getSupportedServiceNames() throw()
+{
+ StringSequence aSupported = OBoundControl::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 1);
+
+ ::rtl::OUString*pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_DATEFIELD;
+ return aSupported;
+}
+
+/*************************************************************************/
+sal_Int32 ODateModel::nDateHandle = -1;
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL ODateModel_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new ODateModel(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> ODateModel::_getTypes()
+{
+ return OEditBaseModel::_getTypes();
+}
+
+//------------------------------------------------------------------
+ODateModel::ODateModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OEditBaseModel(_rxFactory, VCL_CONTROLMODEL_DATEFIELD, FRM_CONTROL_DATEFIELD )
+ // use the old control name for compytibility reasons
+{
+ m_nClassId = starform::FormComponentType::DATEFIELD;
+ m_sDataFieldConnectivityProperty = PROPERTY_DATE;
+ if (ODateModel::nDateHandle == -1)
+ ODateModel::nDateHandle = getOriginalHandle(PROPERTY_ID_DATE);
+}
+
+// starlang::XServiceInfo
+//------------------------------------------------------------------------------
+StringSequence SAL_CALL ODateModel::getSupportedServiceNames() throw()
+{
+ StringSequence aSupported = OBoundControlModel::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 2);
+
+ ::rtl::OUString*pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-2] = ::rtl::OUString::createFromAscii("com.sun.star.form.component.starform");
+ pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_DATEFIELD;
+ return aSupported;
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODateModel::getServiceName()
+{
+ return FRM_COMPONENT_DATEFIELD; // old (non-sun) name for compatibility !
+}
+
+// starbeans::XPropertySet
+//------------------------------------------------------------------------------
+staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL ODateModel::getPropertySetInfo() throw( staruno::RuntimeException )
+{
+ staruno::Reference<starbeans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//------------------------------------------------------------------------------
+void ODateModel::fillProperties(
+ staruno::Sequence< starbeans::Property >& _rProps,
+ staruno::Sequence< starbeans::Property >& _rAggregateProps ) const
+{
+ FRM_BEGIN_PROP_HELPER(10)
+ // Date auf transient setzen
+// ModifyPropertyAttributes(_rAggregateProps, PROPERTY_DATE, starbeans::PropertyAttribute::TRANSIENT, 0);
+
+ DECL_PROP1(NAME, ::rtl::OUString, BOUND);
+ DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT);
+ DECL_PROP3(DEFAULT_DATE, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID);
+ DECL_PROP1(TAG, ::rtl::OUString, BOUND);
+ DECL_PROP1(TABINDEX, sal_Int16, BOUND);
+ DECL_PROP1(CONTROLSOURCE, ::rtl::OUString, BOUND);
+ DECL_PROP1(HELPTEXT, ::rtl::OUString, BOUND);
+ DECL_IFACE_PROP2(BOUNDFIELD, starbeans::XPropertySet, READONLY, TRANSIENT);
+ DECL_IFACE_PROP2(CONTROLLABEL, starbeans::XPropertySet, BOUND, MAYBEVOID);
+ DECL_PROP2(CONTROLSOURCEPROPERTY, rtl::OUString, READONLY, TRANSIENT);
+ FRM_END_PROP_HELPER();
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& ODateModel::getInfoHelper()
+{
+ return *const_cast<ODateModel*>(this)->getArrayHelper();
+}
+
+// starform::XLoadListener
+//------------------------------------------------------------------------------
+void ODateModel::_loaded(const starlang::EventObject& rEvent)
+{
+ OBoundControlModel::_loaded(rEvent);
+ if (m_xField.is())
+ {
+ m_bDateTimeField = sal_False;
+ try
+ {
+ sal_Int32 nFieldType;
+ m_xField->getPropertyValue(PROPERTY_FIELDTYPE) >>= nFieldType;
+ m_bDateTimeField = (nFieldType == starsdbc::DataType::TIMESTAMP);
+ }
+ catch(...)
+ {
+ }
+ }
+}
+
+// starform::XBoundComponent
+//------------------------------------------------------------------------------
+sal_Bool ODateModel::_commit()
+{
+ staruno::Any aNewValue = m_xAggregateFastSet->getFastPropertyValue( ODateModel::nDateHandle );
+ if (!compare(aNewValue, m_aSaveValue))
+ {
+ if (!aNewValue.hasValue())
+ m_xColumnUpdate->updateNull();
+ else
+ {
+ try
+ {
+ starutil::Date aDate;
+ if (!(aNewValue >>= aDate))
+ {
+ sal_Int32 nAsInt(0);
+ aNewValue >>= nAsInt;
+ Date aToolsValue(nAsInt);
+ typeConvert(aToolsValue, aDate);
+ }
+
+ if (!m_bDateTimeField)
+ m_xColumnUpdate->updateDate(aDate);
+ else
+ {
+ starutil::DateTime aDateTime = m_xColumn->getTimestamp();
+ aDateTime.Day = aDate.Day;
+ aDateTime.Month = aDate.Month;
+ aDateTime.Year = aDate.Year;
+ m_xColumnUpdate->updateTimestamp(aDateTime);
+ }
+ }
+ catch(...)
+ {
+ return sal_False;
+ }
+ }
+ m_aSaveValue = aNewValue;
+ }
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+void ODateModel::_onValueChanged()
+{
+ starutil::Date aDate = m_xColumn->getDate();
+ if (m_xColumn->wasNull())
+ m_aSaveValue.clear();
+ else
+ // the aggregated set expects an Int32 as value ...
+ m_aSaveValue <<= DBTypeConversion::toINT32(aDate);
+
+ { // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
+ // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
+ // our own mutex locked
+ // FS - 72451 - 31.01.00
+ MutexRelease aRelease(m_aMutex);
+ m_xAggregateFastSet->setFastPropertyValue(ODateModel::nDateHandle, m_aSaveValue);
+ }
+}
+
+//------------------------------------------------------------------------------
+void ODateModel::_reset()
+{
+ staruno::Any aValue;
+ if (m_aDefault.getValueType().getTypeClass() == staruno::TypeClass_LONG)
+ aValue = m_aDefault;
+ else
+ { // aktuelles Datum einstellen
+ Date aCurrentDate;
+ aValue <<= DBTypeConversion::toINT32(aCurrentDate);
+ }
+
+ { // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
+ // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
+ // our own mutex locked
+ // FS - 72451 - 31.01.00
+ MutexRelease aRelease(m_aMutex);
+ m_xAggregateFastSet->setFastPropertyValue(ODateModel::nDateHandle, aValue);
+ }
+}
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
diff --git a/forms/source/component/Date.hxx b/forms/source/component/Date.hxx
new file mode 100644
index 000000000000..b7d7013f3a50
--- /dev/null
+++ b/forms/source/component/Date.hxx
@@ -0,0 +1,142 @@
+/*************************************************************************
+ *
+ * $RCSfile: Date.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_DATE_HXX_
+#define _FORMS_DATE_HXX_
+
+#ifndef _FORMS_EDITBASE_HXX_
+#include "EditBase.hxx"
+#endif
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+//==================================================================
+//= ODateModel
+//==================================================================
+class ODateModel
+ :public OEditBaseModel
+ ,public ::utl::OAggregationArrayUsageHelper< ODateModel >
+{
+ staruno::Any m_aSaveValue;
+ sal_Bool m_bDateTimeField;
+ static sal_Int32 nDateHandle;
+
+protected:
+ virtual void _onValueChanged();
+ virtual staruno::Sequence<staruno::Type> _getTypes();
+
+public:
+ ODateModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+
+// starform::XBoundComponent
+ virtual sal_Bool _commit();
+
+// stario::XPersistObject
+ virtual ::rtl::OUString SAL_CALL getServiceName();
+
+// starlang::XServiceInfo
+ IMPLEMENTATION_NAME(ODateModel);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
+
+// starbeans::XPropertySet
+ virtual staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(staruno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+// starform::XReset
+ virtual void _reset( void );
+
+// starform::XLoadListener
+ virtual void _loaded(const starlang::EventObject& rEvent);
+
+// OAggregationArrayUsageHelper
+ virtual void fillProperties(
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rProps,
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rAggregateProps
+ ) const;
+ IMPLEMENT_INFO_SERVICE()
+};
+
+//==================================================================
+//= ODateControl
+//==================================================================
+class ODateControl: public OBoundControl
+{
+protected:
+ virtual staruno::Sequence<staruno::Type> _getTypes();
+
+public:
+ ODateControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+ DECLARE_UNO3_AGG_DEFAULTS(ODateControl, OBoundControl);
+
+// starlang::XServiceInfo
+ IMPLEMENTATION_NAME(ODateControl);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
+};
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
+#endif // _FORMS_DATE_HXX_
+
diff --git a/forms/source/component/Edit.cxx b/forms/source/component/Edit.cxx
new file mode 100644
index 000000000000..64dd23a18b57
--- /dev/null
+++ b/forms/source/component/Edit.cxx
@@ -0,0 +1,643 @@
+/*************************************************************************
+ *
+ * $RCSfile: Edit.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_EDIT_HXX_
+#include "Edit.hxx"
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_TYPE_HXX_
+#include <com/sun/star/uno/Type.hxx>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_
+#include <com/sun/star/awt/XWindow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
+#include <com/sun/star/container/XIndexAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XSUBMIT_HPP_
+#include <com/sun/star/form/XSubmit.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_
+#include <com/sun/star/util/NumberFormat.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _TOOLS_VCLRSC_HXX
+#include <tools/vclrsc.hxx>
+#endif
+
+#ifndef _UTL_CONTAINER_HXX_
+#include <unotools/container.hxx>
+#endif
+#include <unotools/datetime.hxx>
+#include <unotools/numbers.hxx>
+
+#ifndef _UTL_UNO3_DB_TOOLS_HXX_
+#include <unotools/dbtools.hxx>
+#endif
+#ifndef _UTL_DB_CONVERSION_HXX_
+#include <unotools/dbconversion.hxx>
+#endif
+
+//.........................................................................
+namespace frm
+{
+
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OEditControl_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new OEditControl(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> OEditControl::_getTypes()
+{
+ static staruno::Sequence<staruno::Type> aTypes;
+ if (!aTypes.getLength())
+ {
+ // my two base classes
+ staruno::Sequence<staruno::Type> aBaseClassTypes = OBoundControl::_getTypes();
+
+ staruno::Sequence<staruno::Type> aOwnTypes(3);
+ staruno::Type* pOwnTypes = aOwnTypes.getArray();
+ pOwnTypes[0] = getCppuType((staruno::Reference<starawt::XFocusListener>*)NULL);
+ pOwnTypes[1] = getCppuType((staruno::Reference<starawt::XKeyListener>*)NULL);
+ pOwnTypes[2] = getCppuType((staruno::Reference<starform::XChangeBroadcaster>*)NULL);
+
+ aTypes = concatSequences(aBaseClassTypes, aOwnTypes);
+ }
+ return aTypes;
+}
+
+//------------------------------------------------------------------------------
+staruno::Any SAL_CALL OEditControl::queryAggregation(const staruno::Type& _rType) throw (staruno::RuntimeException)
+{
+ staruno::Any aReturn;
+
+ aReturn = OBoundControl::queryAggregation(_rType);
+ if (!aReturn.hasValue())
+ aReturn = ::cppu::queryInterface(_rType
+ ,static_cast<starawt::XFocusListener*>(this)
+ ,static_cast<starawt::XKeyListener*>(this)
+ ,static_cast<starform::XChangeBroadcaster*>(this)
+ );
+
+ return aReturn;
+}
+
+DBG_NAME(OEditControl);
+//------------------------------------------------------------------------------
+OEditControl::OEditControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OBoundControl(_rxFactory, VCL_CONTROL_EDIT)
+ ,m_aChangeListeners(m_aMutex)
+ ,m_nKeyEvent( 0 )
+{
+ DBG_CTOR(OEditControl,NULL);
+
+ increment(m_refCount);
+ { // als FocusListener anmelden
+ staruno::Reference<starawt::XWindow> xComp;
+ if (query_aggregation(m_xAggregate, xComp))
+ {
+ xComp->addFocusListener(this);
+ xComp->addKeyListener(this);
+ }
+ }
+ // Refcount wieder bei 2 fuer beide Listener
+ sal_Int32 n = decrement(m_refCount);
+}
+
+//------------------------------------------------------------------------------
+OEditControl::~OEditControl()
+{
+ if( m_nKeyEvent )
+ Application::RemoveUserEvent( m_nKeyEvent );
+
+ if (!OComponentHelper::rBHelper.bDisposed)
+ {
+ acquire();
+ dispose();
+ }
+
+ DBG_DTOR(OEditControl,NULL);
+}
+
+// starform::XChangeBroadcaster
+//------------------------------------------------------------------------------
+void OEditControl::addChangeListener(const staruno::Reference<starform::XChangeListener>& l)
+{
+ m_aChangeListeners.addInterface( l );
+}
+
+//------------------------------------------------------------------------------
+void OEditControl::removeChangeListener(const staruno::Reference<starform::XChangeListener>& l)
+{
+ m_aChangeListeners.removeInterface( l );
+}
+
+// OComponentHelper
+//------------------------------------------------------------------------------
+void OEditControl::disposing()
+{
+ OBoundControl::disposing();
+
+ starlang::EventObject aEvt(static_cast<staruno::XWeak*>(this));
+ m_aChangeListeners.disposeAndClear(aEvt);
+}
+
+// starlang::XServiceInfo
+//------------------------------------------------------------------------------
+StringSequence OEditControl::getSupportedServiceNames() throw()
+{
+ StringSequence aSupported = OBoundControl::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 1);
+
+ ::rtl::OUString*pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_TEXTFIELD;
+ return aSupported;
+}
+
+// starlang::XEventListener
+//------------------------------------------------------------------------------
+void OEditControl::disposing(const starlang::EventObject& Source) throw( staruno::RuntimeException )
+{
+ OBoundControl::disposing(Source);
+}
+
+// starawt::XFocusListener
+//------------------------------------------------------------------------------
+void OEditControl::focusGained( const starawt::FocusEvent& e )
+{
+ staruno::Reference<starbeans::XPropertySet> xSet(getModel(), staruno::UNO_QUERY);
+ if (xSet.is())
+ xSet->getPropertyValue( PROPERTY_TEXT ) >>= m_aHtmlChangeValue;
+}
+
+//------------------------------------------------------------------------------
+void OEditControl::focusLost( const starawt::FocusEvent& e )
+{
+ staruno::Reference<starbeans::XPropertySet> xSet(getModel(), staruno::UNO_QUERY);
+ if (xSet.is())
+ {
+ ::rtl::OUString sNewHtmlChangeValue;
+ xSet->getPropertyValue( PROPERTY_TEXT ) >>= sNewHtmlChangeValue;
+ if( sNewHtmlChangeValue != m_aHtmlChangeValue )
+ {
+ starlang::EventObject aEvt;
+ aEvt.Source = *this;
+ NOTIFY_LISTENERS(m_aChangeListeners, starform::XChangeListener, changed, aEvt);
+ }
+ }
+}
+
+// starawt::XKeyListener
+//------------------------------------------------------------------------------
+void OEditControl::keyPressed(const starawt::KeyEvent& e)
+{
+ if( e.KeyCode != KEY_RETURN || e.Modifiers != 0 )
+ return;
+
+ // Steht das Control in einem Formular mit einer Submit-starutil::URL?
+ staruno::Reference<starbeans::XPropertySet> xSet(getModel(), staruno::UNO_QUERY);
+ if( !xSet.is() )
+ return;
+
+ // nicht fuer multiline edits
+ staruno::Any aTmp( xSet->getPropertyValue(PROPERTY_MULTILINE));
+ if ((aTmp.getValueType().equals(::getBooleanCppuType())) && getBOOL(aTmp))
+ return;
+
+ staruno::Reference<starform::XFormComponent> xFComp(xSet, staruno::UNO_QUERY);
+ InterfaceRef xParent = xFComp->getParent();
+ if( !xParent.is() )
+ return;
+
+ staruno::Reference<starbeans::XPropertySet> xFormSet(xParent, staruno::UNO_QUERY);
+ if( !xFormSet.is() )
+ return;
+
+ aTmp = xFormSet->getPropertyValue( PROPERTY_TARGET_URL );
+ if (!aTmp.getValueType().equals(::getCppuType((const ::rtl::OUString*)NULL)) ||
+ !getString(aTmp).getLength() )
+ return;
+
+ staruno::Reference<starcontainer::XIndexAccess> xElements(xParent, staruno::UNO_QUERY);
+ sal_Int32 nCount = xElements->getCount();
+ if( nCount > 1 )
+ {
+ for( sal_Int32 nIndex=0; nIndex < nCount; nIndex++ )
+ {
+ // staruno::Any aElement(xElements->getByIndex(nIndex));
+ staruno::Reference<starbeans::XPropertySet> xFCSet(*(InterfaceRef *)xElements->getByIndex(nIndex).getValue(), staruno::UNO_QUERY);
+
+ if (hasProperty(PROPERTY_CLASSID, xFCSet) &&
+ getINT16(xFCSet->getPropertyValue(PROPERTY_CLASSID)) == starform::FormComponentType::TEXTFIELD)
+ {
+ // Noch ein weiteres Edit gefunden ==> dann nicht submitten
+ if (xFCSet != xSet)
+ return;
+ }
+ }
+ }
+
+ // Da wir noch im Haender stehen, submit asynchron ausloesen
+ if( m_nKeyEvent )
+ Application::RemoveUserEvent( m_nKeyEvent );
+ m_nKeyEvent = Application::PostUserEvent( LINK(this, OEditControl,
+ OnKeyPressed) );
+}
+
+//------------------------------------------------------------------------------
+void OEditControl::keyReleased(const starawt::KeyEvent& e)
+{
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(OEditControl, OnKeyPressed, void*, EMPTYARG)
+{
+ m_nKeyEvent = 0;
+
+ staruno::Reference<starform::XFormComponent> xFComp(getModel(), staruno::UNO_QUERY);
+ InterfaceRef xParent = xFComp->getParent();
+ staruno::Reference<starform::XSubmit> xSubmit(xParent, staruno::UNO_QUERY);
+ if (xSubmit.is())
+ xSubmit->submit( staruno::Reference<starawt::XControl>(), starawt::MouseEvent() );
+ return 0L;
+}
+
+/*************************************************************************/
+sal_Int32 OEditModel::nTextHandle = -1;
+
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OEditModel_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new OEditModel(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> OEditModel::_getTypes()
+{
+ return OEditBaseModel::_getTypes();
+}
+
+
+DBG_NAME(OEditModel);
+//------------------------------------------------------------------
+OEditModel::OEditModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OEditBaseModel( _rxFactory, VCL_CONTROLMODEL_EDIT, FRM_CONTROL_EDIT )
+ // use the old control name for compytibility reasons
+ ,m_nMaxLen(0)
+ ,m_aNullDate(STANDARD_DB_DATE)
+ ,m_nKeyType(starutil::NumberFormat::UNDEFINED)
+ ,m_nFormatKey(0)
+ ,m_nFieldType(starsdbc::DataType::OTHER)
+ ,m_bWritingFormattedFake(sal_False)
+{
+ DBG_CTOR(OEditModel,NULL);
+
+ m_nClassId = starform::FormComponentType::TEXTFIELD;
+ m_sDataFieldConnectivityProperty = PROPERTY_TEXT;
+ if (OEditModel::nTextHandle == -1)
+ OEditModel::nTextHandle = getOriginalHandle(PROPERTY_ID_TEXT);
+}
+
+//------------------------------------------------------------------
+OEditModel::~OEditModel()
+{
+ if (!OComponentHelper::rBHelper.bDisposed)
+ {
+ acquire();
+ dispose();
+ }
+
+ DBG_DTOR(OEditModel,NULL);
+}
+
+//------------------------------------------------------------------------------
+void OEditModel::disposing()
+{
+ OEditBaseModel::disposing();
+ m_xFormatter = NULL;
+}
+
+// stario::XPersistObject
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEditModel::getServiceName()
+{
+ return FRM_COMPONENT_EDIT; // old (non-sun) name for compatibility !
+}
+
+// starlang::XServiceInfo
+//------------------------------------------------------------------------------
+StringSequence SAL_CALL OEditModel::getSupportedServiceNames() throw()
+{
+ StringSequence aSupported = OBoundControlModel::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 2);
+
+ ::rtl::OUString*pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-1] = ::rtl::OUString::createFromAscii("com.sun.star.form.component.DatabaseTextField");
+ pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_TEXTFIELD;
+ return aSupported;
+}
+
+// starbeans::XPropertySet
+//------------------------------------------------------------------------------
+staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL OEditModel::getPropertySetInfo() throw(staruno::RuntimeException)
+{
+ staruno::Reference<starbeans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//------------------------------------------------------------------------------
+void OEditModel::fillProperties(
+ staruno::Sequence< starbeans::Property >& _rProps,
+ staruno::Sequence< starbeans::Property >& _rAggregateProps ) const
+{
+ FRM_BEGIN_PROP_HELPER(12)
+ // Text auf transient setzen
+// ModifyPropertyAttributes(_rAggregateProps, PROPERTY_TEXT, starbeans::PropertyAttribute::TRANSIENT, 0);
+
+ DECL_PROP1(NAME, ::rtl::OUString, BOUND);
+ DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT);
+ DECL_PROP2(DEFAULT_TEXT, ::rtl::OUString, BOUND, MAYBEDEFAULT);
+ DECL_BOOL_PROP1(EMPTY_IS_NULL, BOUND);
+ DECL_PROP1(TAG, ::rtl::OUString, BOUND);
+ DECL_PROP1(TABINDEX, sal_Int16, BOUND);
+ DECL_PROP1(CONTROLSOURCE, ::rtl::OUString, BOUND);
+ DECL_PROP1(HELPTEXT, ::rtl::OUString, BOUND);
+ DECL_IFACE_PROP2(BOUNDFIELD, starbeans::XPropertySet,READONLY, TRANSIENT);
+ DECL_BOOL_PROP2(FILTERPROPOSAL, BOUND, MAYBEDEFAULT);
+ DECL_IFACE_PROP2(CONTROLLABEL, starbeans::XPropertySet,BOUND, MAYBEVOID);
+ DECL_PROP2(CONTROLSOURCEPROPERTY, rtl::OUString, READONLY, TRANSIENT);
+ FRM_END_PROP_HELPER();
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OEditModel::getInfoHelper()
+{
+ return *const_cast<OEditModel*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+void OEditModel::write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream)
+{
+ staruno::Any aCurrentText;
+ // bin ich gerade loaded und habe dazu zeitweilig die MaxTextLen umgesetzt ?
+ if (m_nMaxLen)
+ { // -> fuer die Dauer des Speicherns meinem aggregierten Model die alte TextLen einreden
+
+ // before doing this we have to save the current text value of the aggregate, as this may be affected by resetting the text len
+ // FS - 08.12.99 - 70606
+ aCurrentText = m_xAggregateSet->getPropertyValue(PROPERTY_TEXT);
+
+ m_xAggregateSet->setPropertyValue(PROPERTY_MAXTEXTLEN, staruno::makeAny((sal_Int16)0));
+ }
+
+ OEditBaseModel::write(_rxOutStream);
+
+ if (m_nMaxLen)
+ { // wieder zuruecksetzen
+ m_xAggregateSet->setPropertyValue(PROPERTY_MAXTEXTLEN, staruno::makeAny((sal_Int16)m_nMaxLen));
+ // and reset the text
+ // First we set it to an empty string : Without this the second setPropertyValue would not do anything as it thinks
+ // we aren't changing the prop (it didn't notify the - implicite - change of the text prop while setting the max text len)
+ // This seems to be a bug with in toolkit's EditControl-implementation.
+ m_xAggregateSet->setPropertyValue(PROPERTY_TEXT, staruno::makeAny(::rtl::OUString()));
+ m_xAggregateSet->setPropertyValue(PROPERTY_TEXT, aCurrentText);
+ }
+}
+
+//------------------------------------------------------------------------------
+void OEditModel::read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream)
+{
+ OEditBaseModel::read(_rxInStream);
+
+ // Some versions (5.1 'til about 552) wrote a wrong DefaultControl-property value which is unknown
+ // to older versions (5.0).
+ // correct this ...
+ if (m_xAggregateSet.is())
+ {
+ staruno::Any aDefaultControl = m_xAggregateSet->getPropertyValue(PROPERTY_DEFAULTCONTROL);
+ if ( (aDefaultControl.getValueType().getTypeClass() == staruno::TypeClass_STRING)
+ && (getString(aDefaultControl).compareTo(FRM_CONTROL_TEXTFIELD) == COMPARE_EQUAL)
+ )
+ {
+ m_xAggregateSet->setPropertyValue(PROPERTY_DEFAULTCONTROL, staruno::makeAny(::rtl::OUString(FRM_CONTROL_EDIT)));
+ // Older as well as current versions should understand this : the former knew only the FRM_CONTROL_EDIT,
+ // the latter are registered for both FRM_CONTROL_EDIT and FRM_CONTROL_TEXTFIELD.
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Int16 OEditModel::getPersistenceFlags() const
+{
+ sal_Int16 nFlags = OEditBaseModel::getPersistenceFlags();
+
+ if (m_bWritingFormattedFake)
+ nFlags |= PF_FAKE_FORMATTED_FIELD;
+
+ return nFlags;
+}
+
+// starform::XLoadListener
+//------------------------------------------------------------------------------
+void OEditModel::_loaded(const starlang::EventObject& rEvent)
+{
+ if (m_xField.is())
+ {
+ // jetzt den Key und typ ermitteln
+ m_nFieldType = getINT32(m_xField->getPropertyValue(PROPERTY_FIELDTYPE));
+ m_nFormatKey = getINT32(m_xField->getPropertyValue(PROPERTY_FORMATKEY));
+
+ // starutil::XNumberFormatter besorgen
+ staruno::Reference<starsdbc::XRowSet> xRowSet(rEvent.Source, staruno::UNO_QUERY);
+ DBG_ASSERT(xRowSet.is(), "OEditModel::_loaded : source is not a row set ?");
+ staruno::Reference<starutil::XNumberFormatsSupplier> xSupplier = getNumberFormats(getConnection(xRowSet), sal_False, m_xServiceFactory);
+ if (xSupplier.is())
+ {
+ m_xFormatter = staruno::Reference<starutil::XNumberFormatter>(m_xServiceFactory
+ ->createInstance(FRM_NUMBER_FORMATTER), staruno::UNO_QUERY);
+ if (m_xFormatter.is())
+ m_xFormatter->attachNumberFormatsSupplier(xSupplier);
+
+ m_nKeyType = getNumberFormatType(xSupplier->getNumberFormats(), m_nFormatKey);
+ typeConvert(*(starutil::Date*)xSupplier->getNumberFormatSettings()->getPropertyValue(::rtl::OUString::createFromAscii("NullDate")).getValue(), m_aNullDate);
+ }
+
+ if (m_nKeyType != starutil::NumberFormat::SCIENTIFIC)
+ {
+ m_nMaxLen = getINT16(m_xAggregateSet->getPropertyValue(PROPERTY_MAXTEXTLEN));
+ if (!m_nMaxLen)
+ {
+ sal_Int32 nFieldLen;
+ m_xField->getPropertyValue(::rtl::OUString::createFromAscii("Precision")) >>= nFieldLen;
+
+ if (nFieldLen && nFieldLen <= USHRT_MAX)
+ {
+ staruno::Any aVal;
+ aVal <<= (sal_Int16)nFieldLen;
+ m_xAggregateSet->setPropertyValue(PROPERTY_MAXTEXTLEN, aVal);
+
+ m_nMaxLen = nFieldLen; // damit das Ganze beim _unloaded wieder zurueckgesetzt wird
+ }
+ }
+ else
+ m_nMaxLen = 0;
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void OEditModel::_unloaded()
+{
+ OEditBaseModel::_unloaded();
+ if (m_xField.is())
+ {
+ if (m_nMaxLen)
+ {
+ staruno::Any aVal;
+ aVal <<= (sal_Int16)0; // nur wenn es 0 war, habe ich es in _loaded umgesetzt
+ m_xAggregateSet->setPropertyValue(PROPERTY_MAXTEXTLEN, aVal);
+ m_nMaxLen = 0;
+ }
+
+ m_xFormatter = 0;
+ m_nFieldType = starsdbc::DataType::OTHER;
+ m_nFormatKey = 0;
+ m_nKeyType = starutil::NumberFormat::UNDEFINED;
+ m_aNullDate = STANDARD_DB_DATE;
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OEditModel::_commit()
+{
+ ::rtl::OUString aNewValue;
+ m_xAggregateFastSet->getFastPropertyValue(OEditModel::nTextHandle) >>= aNewValue;
+ if (aNewValue != m_aSaveValue)
+ {
+ if (!aNewValue.len() && !m_bRequired && m_bEmptyIsNull)
+ m_xColumnUpdate->updateNull();
+ else
+ {
+ try
+ {
+ DBTypeConversion::setValue(m_xColumnUpdate, m_xFormatter, m_aNullDate, aNewValue,
+ m_nFormatKey, m_nFieldType, m_nKeyType);
+ }
+ catch(...)
+ {
+ return sal_False;
+ }
+ }
+ m_aSaveValue = aNewValue;
+ }
+ return sal_True;
+}
+
+// starbeans::XPropertyChangeListener
+//------------------------------------------------------------------------------
+void OEditModel::_onValueChanged()
+{
+
+ // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
+ // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
+ // our own mutex locked
+ // and in this special case do it before calling DBTypeConversion::getValue, as this uses the number formatter
+ // which's implementation locks the SM, too :(
+ // FS - 72451 - 31.01.00
+ MutexRelease aRelease(m_aMutex);
+ m_aSaveValue = DBTypeConversion::getValue(m_xColumn,
+ m_xFormatter,
+ m_aNullDate,
+ m_nFormatKey,
+ m_nKeyType);
+
+ m_xAggregateFastSet->setFastPropertyValue(OEditModel::nTextHandle, staruno::makeAny(m_aSaveValue));
+}
+
+// starform::XReset
+//------------------------------------------------------------------------------
+void OEditModel::_reset()
+{
+ { // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
+ // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
+ // our own mutex locked
+ // FS - 72451 - 31.01.00
+ MutexRelease aRelease(m_aMutex);
+ m_xAggregateFastSet->setFastPropertyValue(OEditModel::nTextHandle, staruno::makeAny(m_aDefaultText));
+ }
+}
+
+//.........................................................................
+}
+//.........................................................................
+
diff --git a/forms/source/component/Edit.hxx b/forms/source/component/Edit.hxx
new file mode 100644
index 000000000000..b07932e210ad
--- /dev/null
+++ b/forms/source/component/Edit.hxx
@@ -0,0 +1,199 @@
+/*************************************************************************
+ *
+ * $RCSfile: Edit.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_EDIT_HXX_
+#define _FORMS_EDIT_HXX_
+
+#ifndef _FORMS_EDITBASE_HXX_
+#include "EditBase.hxx"
+#endif
+
+//.........................................................................
+namespace frm
+{
+
+//==================================================================
+//= OEditModel
+//==================================================================
+class OEditModel
+ :public OEditBaseModel
+ ,public ::utl::OAggregationArrayUsageHelper< OEditModel >
+{
+ staruno::Reference<starutil::XNumberFormatter> m_xFormatter;
+ ::rtl::OUString m_aSaveValue;
+ sal_Int32 m_nFormatKey;
+ Date m_aNullDate;
+ sal_Int32 m_nFieldType;
+ sal_Int16 m_nKeyType;
+ sal_Int16 m_nMaxLen;
+
+ sal_Bool m_bWritingFormattedFake;
+ // are we writing something which should be interpreted as formatted upon reading
+
+ static sal_Int32 nTextHandle;
+
+protected:
+ virtual void _onValueChanged();
+ virtual staruno::Sequence<staruno::Type> _getTypes();
+
+ OEditModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+ virtual ~OEditModel();
+
+ void enableFormattedWriteFake() { m_bWritingFormattedFake = sal_True; }
+ void disableFormattedWriteFake() { m_bWritingFormattedFake = sal_False; }
+ sal_Bool lastReadWasFormattedFake() const { return (getLastReadVersion() & PF_FAKE_FORMATTED_FIELD) != 0; }
+
+ friend InterfaceRef SAL_CALL OEditModel_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+ friend class OFormattedFieldWrapper;
+ friend class OFormattedModel; // temporary
+
+public:
+ virtual void SAL_CALL disposing();
+
+// starform::XBoundComponent
+ virtual sal_Bool _commit();
+
+// stario::XPersistObject
+ virtual void SAL_CALL write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream);
+ virtual void SAL_CALL read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream);
+ virtual ::rtl::OUString SAL_CALL getServiceName();
+
+// starbeans::XPropertySet
+ virtual staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(staruno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+// starlang::XServiceInfo
+ IMPLEMENTATION_NAME(OEditModel);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
+
+// starform::XLoadListener
+ virtual void _loaded(const starlang::EventObject& rEvent);
+ virtual void _unloaded();
+
+// starform::XReset
+ virtual void _reset();
+
+// OAggregationArrayUsageHelper
+ virtual void fillProperties(
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rProps,
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rAggregateProps
+ ) const;
+ IMPLEMENT_INFO_SERVICE()
+
+protected:
+ virtual sal_Int16 getPersistenceFlags() const;
+};
+
+//==================================================================
+//= OEditControl
+//==================================================================
+class OEditControl : public OBoundControl
+ ,public starawt::XFocusListener
+ ,public starawt::XKeyListener
+ ,public starform::XChangeBroadcaster
+{
+ ::cppu::OInterfaceContainerHelper
+ m_aChangeListeners;
+
+ ::rtl::OUString m_aHtmlChangeValue;
+ sal_uInt32 m_nKeyEvent;
+
+public:
+ OEditControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+ virtual ~OEditControl();
+
+ DECLARE_UNO3_AGG_DEFAULTS(OEditControl, OBoundControl);
+ virtual staruno::Any SAL_CALL queryAggregation(const staruno::Type& _rType) throw(staruno::RuntimeException);
+
+ virtual staruno::Sequence<staruno::Type> _getTypes();
+
+// OComponentHelper
+ virtual void SAL_CALL disposing();
+
+// starlang::XEventListener
+ virtual void SAL_CALL disposing(const starlang::EventObject& _rSource) throw(staruno::RuntimeException);
+
+// starlang::XServiceInfo
+ IMPLEMENTATION_NAME(OEditControl);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
+
+// starform::XChangeBroadcaster
+ virtual void SAL_CALL addChangeListener(const staruno::Reference<starform::XChangeListener>& _rxListener);
+ virtual void SAL_CALL removeChangeListener(const staruno::Reference<starform::XChangeListener>& _rxListener);
+
+// starawt::XFocusListener
+ virtual void SAL_CALL focusGained( const starawt::FocusEvent& e );
+ virtual void SAL_CALL focusLost( const starawt::FocusEvent& e );
+
+// starawt::XKeyListener
+ virtual void SAL_CALL keyPressed(const starawt::KeyEvent& e);
+ virtual void SAL_CALL keyReleased(const starawt::KeyEvent& e);
+
+private:
+ DECL_LINK( OnKeyPressed, void* );
+};
+
+//.........................................................................
+}
+//.........................................................................
+
+#endif // _FORMS_EDIT_HXX_
+
diff --git a/forms/source/component/EditBase.cxx b/forms/source/component/EditBase.cxx
new file mode 100644
index 000000000000..8e8bb5d761b7
--- /dev/null
+++ b/forms/source/component/EditBase.cxx
@@ -0,0 +1,429 @@
+/*************************************************************************
+ *
+ * $RCSfile: EditBase.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_EDITBASE_HXX_
+#include "EditBase.hxx"
+#endif
+#ifndef _FRM_PROPERTY_HXX_
+#include "property.hxx"
+#endif
+#ifndef _FRM_PROPERTY_HRC_
+#include "property.hrc"
+#endif
+#ifndef _FRM_SERVICES_HXX_
+#include "services.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _FRM_RESOURCE_HXX_
+#include "frm_resource.hxx"
+#endif
+#ifndef _FRM_RESOURCE_HRC_
+#include "frm_resource.hrc"
+#endif
+
+//.........................................................................
+namespace frm
+{
+
+const sal_uInt16 DEFAULT_LONG = 0x0001;
+const sal_uInt16 DEFAULT_DOUBLE = 0x0002;
+const sal_uInt16 FILTERPROPOSAL = 0x0004;
+
+//------------------------------------------------------------------
+OEditBaseModel::OEditBaseModel(
+ const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory,
+ const ::rtl::OUString& rUnoControlModelName,
+ const ::rtl::OUString& rDefault )
+ :OBoundControlModel( _rxFactory, rUnoControlModelName, rDefault )
+ ,m_bFilterProposal(sal_False)
+ ,m_bEmptyIsNull(sal_True)
+ ,m_nLastReadVersion(0)
+{
+}
+
+// stario::XPersist
+//------------------------------------------------------------------------------
+void OEditBaseModel::write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream)
+{
+ OBoundControlModel::write(_rxOutStream);
+
+ // Version
+ sal_uInt16 nVersionId = 0x0005;
+ DBG_ASSERT((getPersistenceFlags() & ~(sal_Int16)PF_SPECIAL_FLAGS) == 0,
+ "OEditBaseModel::write : invalid special version flags !");
+ // please don't use other flags, older versions can't interpret them !
+
+ nVersionId |= getPersistenceFlags();
+ _rxOutStream->writeShort(nVersionId);
+
+ // Name
+ _rxOutStream->writeShort(0); // obsolete
+ _rxOutStream << m_aDefaultText;
+
+ // Maskierung fuer any
+ sal_uInt16 nAnyMask = 0;
+ if (m_aDefault.getValueType().getTypeClass() == staruno::TypeClass_LONG)
+ nAnyMask |= DEFAULT_LONG;
+ else if (m_aDefault.getValueType().getTypeClass() == staruno::TypeClass_DOUBLE)
+ nAnyMask |= DEFAULT_DOUBLE;
+
+ if (m_bFilterProposal) // da boolean, kein Wert speichern
+ nAnyMask |= FILTERPROPOSAL;
+
+ _rxOutStream->writeBoolean(m_bEmptyIsNull);
+ _rxOutStream->writeShort(nAnyMask);
+
+ if ((nAnyMask & DEFAULT_LONG) == DEFAULT_LONG)
+ _rxOutStream->writeLong(getINT32(m_aDefault));
+ else if ((nAnyMask & DEFAULT_DOUBLE) == DEFAULT_DOUBLE)
+ _rxOutStream->writeDouble(getDouble(m_aDefault));
+
+ // since version 5 we write the help text
+ _rxOutStream << m_aHelpText;
+ // (that's potentially bad : at the time I added the above line we had two derived classes : OEditModel and
+ // OFormattedModel. The first one does not have an own version handling, so it can't write the help text itself,
+ // the second one does it's own writing (reading) after calling our method, so normally we shouldn't write any
+ // additional members as this is not compatible to older office versions.
+ // We decided to place the writing of the help text here as it seems the less worse alternative. There is no delivered
+ // office version including formatted controls (and thus the OFormattedModel), and the OFormattedModel::read seems
+ // robust against this change (as it will read a wrong and unknown file version and thus set it's members to defaults).
+
+ if ((nVersionId & PF_HANDLE_COMMON_PROPS) != 0)
+ writeCommonEditProperties(_rxOutStream);
+
+ // !!! properties common to all OEditBaseModel derived classes should be written in writeCommonEditProperties !!!
+}
+
+//------------------------------------------------------------------------------
+sal_Int16 OEditBaseModel::getPersistenceFlags() const
+{
+ return PF_HANDLE_COMMON_PROPS;
+}
+
+//------------------------------------------------------------------------------
+void OEditBaseModel::read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream)
+{
+ OBoundControlModel::read(_rxInStream);
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ // Version eigene Versionsnummer
+ sal_uInt16 nVersion = _rxInStream->readShort();
+ m_nLastReadVersion = nVersion;
+
+ sal_Bool bHandleCommonProps = (nVersion & PF_HANDLE_COMMON_PROPS) != 0;
+ nVersion = nVersion & ~PF_SPECIAL_FLAGS;
+
+ sal_uInt16 nOld = _rxInStream->readShort();
+ _rxInStream >> m_aDefaultText;
+
+ if (nVersion >= 0x0003)
+ {
+ m_bEmptyIsNull = _rxInStream->readBoolean();
+
+ sal_uInt16 nAnyMask = _rxInStream->readShort();
+ if ((nAnyMask & DEFAULT_LONG) == DEFAULT_LONG)
+ {
+ sal_Int32 nValue = _rxInStream->readLong();
+ m_aDefault <<= (sal_Int32)nValue;
+ }
+ else if ((nAnyMask & DEFAULT_DOUBLE) == DEFAULT_DOUBLE)
+ {
+ double fValue = _rxInStream->readDouble();
+ m_aDefault <<= (double)fValue;
+ }
+
+ if ((nAnyMask & FILTERPROPOSAL) == FILTERPROPOSAL)
+ m_bFilterProposal = sal_True;
+ }
+
+ if (nVersion > 4)
+ _rxInStream >> m_aHelpText;
+
+ if (bHandleCommonProps)
+ readCommonEditProperties(_rxInStream);
+
+ // Nach dem Lesen die Defaultwerte anzeigen
+ if (m_aControlSource.getLength())
+ // (not if we don't have a control source - the "State" property acts like it is persistent, then)
+ _reset();
+};
+
+//------------------------------------------------------------------------------
+void OEditBaseModel::defaultCommonEditProperties()
+{
+ OBoundControlModel::defaultCommonProperties();
+ // no own common properties at the moment
+}
+
+//------------------------------------------------------------------------------
+void OEditBaseModel::readCommonEditProperties(const staruno::Reference<stario::XObjectInputStream>& _rxInStream)
+{
+ sal_Int32 nLen = _rxInStream->readLong();
+
+ staruno::Reference<stario::XMarkableStream> xMark(_rxInStream, staruno::UNO_QUERY);
+ DBG_ASSERT(xMark.is(), "OBoundControlModel::readCommonProperties : can only work with markable streams !");
+ sal_Int32 nMark = xMark->createMark();
+
+ // read properties common to all OBoundControlModels
+ OBoundControlModel::readCommonProperties(_rxInStream);
+
+ // read properties common to all OEditBaseModels
+
+ // skip the remaining bytes
+ xMark->jumpToMark(nMark);
+ _rxInStream->skipBytes(nLen);
+ xMark->deleteMark(nMark);
+}
+
+//------------------------------------------------------------------------------
+void OEditBaseModel::writeCommonEditProperties(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream)
+{
+ staruno::Reference<stario::XMarkableStream> xMark(_rxOutStream, staruno::UNO_QUERY);
+ DBG_ASSERT(xMark.is(), "OEditBaseModel::writeCommonProperties : can only work with markable streams !");
+ sal_Int32 nMark = xMark->createMark();
+
+ // a placeholder where we will write the overall length (later in this method)
+ sal_Int32 nLen = 0;
+ _rxOutStream->writeLong(nLen);
+
+ // write properties common to all OBoundControlModels
+ OBoundControlModel::writeCommonProperties(_rxOutStream);
+
+ // write properties common to all OEditBaseModels
+
+ // close the block - write the correct length at the beginning
+ nLen = xMark->offsetToMark(nMark) - sizeof(nLen);
+ xMark->jumpToMark(nMark);
+ _rxOutStream->writeLong(nLen);
+ xMark->jumpToFurthest();
+ xMark->deleteMark(nMark);
+}
+
+//------------------------------------------------------------------------------
+void OEditBaseModel::getFastPropertyValue( staruno::Any& rValue, sal_Int32 nHandle ) const
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_EMPTY_IS_NULL:
+ rValue <<= (sal_Bool)m_bEmptyIsNull;
+ break;
+ case PROPERTY_ID_FILTERPROPOSAL:
+ rValue <<= (sal_Bool)m_bFilterProposal;
+ break;
+ case PROPERTY_ID_DEFAULT_TEXT:
+ rValue <<= m_aDefaultText;
+ break;
+ case PROPERTY_ID_DEFAULT_VALUE:
+ case PROPERTY_ID_DEFAULT_DATE:
+ case PROPERTY_ID_DEFAULT_TIME:
+ rValue = m_aDefault;
+ break;
+ default:
+ OBoundControlModel::getFastPropertyValue(rValue, nHandle);
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OEditBaseModel::convertFastPropertyValue( staruno::Any& rConvertedValue, staruno::Any& rOldValue,
+ sal_Int32 nHandle, const staruno::Any& rValue ) throw( starlang::IllegalArgumentException )
+{
+ sal_Bool bModified(sal_False);
+ switch (nHandle)
+ {
+ case PROPERTY_ID_EMPTY_IS_NULL:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bEmptyIsNull);
+ break;
+ case PROPERTY_ID_FILTERPROPOSAL:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bFilterProposal);
+ break;
+ case PROPERTY_ID_DEFAULT_TEXT:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aDefaultText);
+ break;
+ case PROPERTY_ID_DEFAULT_VALUE:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aDefault, ::getCppuType((const double*)0));
+ break;
+ case PROPERTY_ID_DEFAULT_DATE:
+ case PROPERTY_ID_DEFAULT_TIME:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aDefault, ::getCppuType((const sal_Int32*)0));
+ break;
+ default:
+ bModified = OBoundControlModel::convertFastPropertyValue(
+ rConvertedValue,
+ rOldValue,
+ nHandle,
+ rValue);
+ }
+ return bModified;
+}
+
+//------------------------------------------------------------------------------
+void OEditBaseModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const staruno::Any& rValue )
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_EMPTY_IS_NULL:
+ DBG_ASSERT(rValue.getValueType().getTypeClass() == staruno::TypeClass_BOOLEAN, "invalid type" );
+ m_bEmptyIsNull = getBOOL(rValue);
+ break;
+ case PROPERTY_ID_FILTERPROPOSAL:
+ DBG_ASSERT(rValue.getValueType().getTypeClass() == staruno::TypeClass_BOOLEAN, "invalid type" );
+ m_bFilterProposal = getBOOL(rValue);
+ break;
+ // Aenderung der defaultwerte fuehrt zu reset
+ case PROPERTY_ID_DEFAULT_TEXT:
+ DBG_ASSERT(rValue.getValueType().getTypeClass() == staruno::TypeClass_STRING, "invalid type" );
+ rValue >>= m_aDefaultText;
+ _reset();
+ break;
+ case PROPERTY_ID_DEFAULT_VALUE:
+ case PROPERTY_ID_DEFAULT_DATE:
+ case PROPERTY_ID_DEFAULT_TIME:
+ m_aDefault = rValue;
+ _reset();
+ break;
+ default:
+ OBoundControlModel::setFastPropertyValue_NoBroadcast(nHandle, rValue );
+ }
+}
+
+//XPropertyState
+//------------------------------------------------------------------------------
+starbeans::PropertyState OEditBaseModel::getPropertyStateByHandle(sal_Int32 nHandle)
+{
+ starbeans::PropertyState eState;
+ switch (nHandle)
+ {
+ case PROPERTY_ID_DEFAULT_TEXT:
+ if (!m_aDefaultText.len())
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ else
+ eState = starbeans::PropertyState_DIRECT_VALUE;
+ break;
+ case PROPERTY_ID_FILTERPROPOSAL:
+ if (!m_bFilterProposal)
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ else
+ eState = starbeans::PropertyState_DIRECT_VALUE;
+ break;
+ case PROPERTY_ID_DEFAULT_VALUE:
+ case PROPERTY_ID_DEFAULT_DATE:
+ case PROPERTY_ID_DEFAULT_TIME:
+ if (!m_aDefault.hasValue())
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ else
+ eState = starbeans::PropertyState_DIRECT_VALUE;
+ break;
+ default:
+ eState = OBoundControlModel::getPropertyStateByHandle(nHandle);
+ }
+ return eState;
+}
+
+//------------------------------------------------------------------------------
+void OEditBaseModel::setPropertyToDefaultByHandle(sal_Int32 nHandle)
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_DEFAULT_TEXT:
+ setFastPropertyValue(nHandle, staruno::makeAny(::rtl::OUString()));
+ break;
+ case PROPERTY_ID_FILTERPROPOSAL:
+ setFastPropertyValue(nHandle, staruno::makeAny((sal_Bool)sal_False));
+ break;
+ case PROPERTY_ID_DEFAULT_VALUE:
+ case PROPERTY_ID_DEFAULT_DATE:
+ case PROPERTY_ID_DEFAULT_TIME:
+ setFastPropertyValue(nHandle, staruno::Any());
+ break;
+ default:
+ OBoundControlModel::setPropertyToDefaultByHandle(nHandle);
+ }
+}
+
+//------------------------------------------------------------------------------
+staruno::Any OEditBaseModel::getPropertyDefaultByHandle( sal_Int32 nHandle ) const
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_DEFAULT_TEXT:
+ return staruno::makeAny(::rtl::OUString());
+ break;
+ case PROPERTY_ID_FILTERPROPOSAL:
+ return staruno::Any(staruno::makeAny((sal_Bool)sal_False));
+ break;
+ case PROPERTY_ID_DEFAULT_VALUE:
+ case PROPERTY_ID_DEFAULT_DATE:
+ case PROPERTY_ID_DEFAULT_TIME:
+ return staruno::Any();
+ default:
+ return OBoundControlModel::getPropertyDefaultByHandle(nHandle);
+ }
+}
+
+//.........................................................................
+}
+//.........................................................................
+
diff --git a/forms/source/component/EditBase.hxx b/forms/source/component/EditBase.hxx
new file mode 100644
index 000000000000..87e40a3a3523
--- /dev/null
+++ b/forms/source/component/EditBase.hxx
@@ -0,0 +1,158 @@
+/*************************************************************************
+ *
+ * $RCSfile: EditBase.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_EDITBASE_HXX_
+#define _FORMS_EDITBASE_HXX_
+
+#ifndef _FORMS_FORMCOMPONENT_HXX_
+#include "FormComponent.hxx"
+#endif
+#ifndef _DATE_HXX
+#include <tools/date.hxx>
+#endif
+#ifndef _LINK_HXX
+#include <tools/link.hxx>
+#endif
+
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#include <com/sun/star/awt/XFocusListener.hpp>
+#include <com/sun/star/awt/XKeyListener.hpp>
+#include <com/sun/star/form/XChangeBroadcaster.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+
+// persistence flags for use with the version id
+#define PF_HANDLE_COMMON_PROPS 0x8000
+ // Derived classes which use their own persistence methods (read/write) and have an own
+ // version handling therein may want to clear this flag in getPersistenceFlags.
+ // If done so, this class will write an version without a call to writeCommonEditProperties.
+#define PF_FAKE_FORMATTED_FIELD 0x4000
+ // .... hmmm .... a fake, as the name suggests. see OFormattedFieldWrapper
+#define PF_RESERVED_2 0x2000
+#define PF_RESERVED_3 0x1000
+#define PF_RESERVED_4 0x0800
+#define PF_RESERVED_5 0x0400
+#define PF_RESERVED_6 0x0200
+#define PF_RESERVED_7 0x0100
+
+#define PF_SPECIAL_FLAGS 0xFF00
+
+//.........................................................................
+namespace frm
+{
+
+//==================================================================
+//= OEditBaseModel
+//==================================================================
+class OEditBaseModel : public OBoundControlModel
+{
+ sal_Int16 m_nLastReadVersion;
+
+protected:
+// [properties] fuer all Editierfelder
+ staruno::Any m_aDefault;
+ ::rtl::OUString m_aDefaultText; // Defaultwert
+ sal_Bool m_bEmptyIsNull : 1; // LeerString ist NULL
+ sal_Bool m_bFilterProposal : 1; // use a list of possible value in filtermode
+// [properties]
+
+ sal_Int16 getLastReadVersion() const { return m_nLastReadVersion; }
+
+public:
+ OEditBaseModel(
+ const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory,
+ const ::rtl::OUString& rUnoControlModelName,
+ const ::rtl::OUString& rDefault );
+
+// stario::XPersistObject
+ virtual void SAL_CALL write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream);
+ virtual void SAL_CALL read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream);
+
+// starbeans::XPropertySet
+ virtual void SAL_CALL getFastPropertyValue(staruno::Any& rValue, sal_Int32 nHandle ) const;
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(staruno::Any& rConvertedValue, staruno::Any& rOldValue,
+ sal_Int32 nHandle, const staruno::Any& rValue )
+ throw(starlang::IllegalArgumentException);
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const staruno::Any& rValue);
+
+// starbeans::XPropertyState
+ virtual starbeans::PropertyState getPropertyStateByHandle(sal_Int32 nHandle);
+ virtual void setPropertyToDefaultByHandle(sal_Int32 nHandle);
+ virtual staruno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const;
+
+protected:
+ // new properties common to all edit models should be handled with the following two methods
+ void SAL_CALL readCommonEditProperties(const staruno::Reference<stario::XObjectInputStream>& _rxInStream);
+ void SAL_CALL writeCommonEditProperties(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream);
+ void defaultCommonEditProperties();
+
+ virtual sal_Int16 getPersistenceFlags() const;
+ // derived classes may use this if they want this base class to write additinal version flags
+ // (one of the PF_.... constants). After ::read they may ask for that flags with getLastReadVersion
+};
+
+//.........................................................................
+}
+//.........................................................................
+
+#endif // _FORMS_EDITBASE_HXX_
+
diff --git a/forms/source/component/EventThread.cxx b/forms/source/component/EventThread.cxx
new file mode 100644
index 000000000000..e7e538a92e2d
--- /dev/null
+++ b/forms/source/component/EventThread.cxx
@@ -0,0 +1,225 @@
+/*************************************************************************
+ *
+ * $RCSfile: EventThread.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FRM_EVENT_THREAD_HXX_
+#include "EventThread.hxx"
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX //autogen
+#include <tools/debug.hxx>
+#endif
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+OComponentEventThread::OComponentEventThread( ::cppu::OComponentHelper* pCompImpl ) :
+ m_pCompImpl( pCompImpl )
+{
+ increment(m_refCount);
+
+ // Eine Referenz des Controls halten
+ {
+ InterfaceRef xIFace(static_cast<staruno::XWeak*>(pCompImpl));
+ query_interface(xIFace, m_xComp);
+ }
+
+ // und uns an dem Control anmelden
+ {
+ staruno::Reference<starlang::XEventListener> xEvtLstnr = static_cast<starlang::XEventListener*>(this);
+ m_xComp->addEventListener( xEvtLstnr );
+ }
+
+ decrement(m_refCount);
+}
+
+OComponentEventThread::~OComponentEventThread()
+{
+ DBG_ASSERT( m_aEvents.size() == 0,
+ "OComponentEventThread::~OComponentEventThread: Kein dispose gerufen?" );
+ while (m_aEvents.size())
+ delete *m_aEvents.erase(m_aEvents.begin());
+}
+
+staruno::Any SAL_CALL OComponentEventThread::queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException)
+{
+ staruno::Any aReturn;
+
+ aReturn = OWeakObject::queryInterface(_rType);
+
+ if (!aReturn.hasValue())
+ aReturn = ::cppu::queryInterface(_rType,
+ static_cast<starlang::XEventListener*>(this)
+ );
+
+ return aReturn;
+}
+
+void OComponentEventThread::disposing( const starlang::EventObject& evt )
+{
+ if( evt.Source == m_xComp )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ // Event-Listener abmelden
+ staruno::Reference<starlang::XEventListener> xEvtLstnr = static_cast<starlang::XEventListener*>(this);
+ m_xComp->removeEventListener( xEvtLstnr );
+
+ // Event-Queue loeschen
+ while (m_aEvents.size())
+ delete *m_aEvents.erase(m_aEvents.begin());
+ m_aControls.erase(m_aControls.begin(), m_aControls.end());
+ m_aFlags.erase(m_aFlags.begin(), m_aFlags.end());
+
+ // Das Control loslassen und pCompImpl auf 0 setzen, damit der
+ // Thread weiss, dass er sich beenden soll.
+ m_xComp = 0;
+ m_pCompImpl = 0;
+
+ // Den Thread aufwecken und beenden.
+ m_aCond.set();
+ terminate();
+ }
+}
+
+void OComponentEventThread::addEvent( const starlang::EventObject* _pEvt, sal_Bool bFlag )
+{
+ staruno::Reference<starawt::XControl> xTmp;
+ addEvent( _pEvt, xTmp, bFlag );
+}
+
+void OComponentEventThread::addEvent( const starlang::EventObject* _pEvt,
+ const staruno::Reference<starawt::XControl>& rControl,
+ sal_Bool bFlag )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ // Daten in die Queue stellen
+ m_aEvents.push_back( cloneEvent( _pEvt ) );
+
+ staruno::Reference<staruno::XWeak> xWeakControl(rControl, staruno::UNO_QUERY);
+ staruno::Reference<staruno::XAdapter> xControlAdapter = xWeakControl.is() ? xWeakControl->queryAdapter() : staruno::Reference<staruno::XAdapter>();
+ m_aControls.push_back( xControlAdapter );
+
+ m_aFlags.push_back( bFlag );
+
+ // Thread aufwecken
+ m_aCond.set();
+}
+
+void OComponentEventThread::run()
+{
+ // uns selbst festhalten, damit wir nicht geloescht werden,
+ // wenn zwischendrinne mal ein dispose gerufen wird.
+ InterfaceRef xThis(static_cast<staruno::XWeak*>(this));
+
+ do
+ {
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ while( m_aEvents.size() > 0 )
+ {
+ // Das Control holen und festhalten, damit es waehrend des
+ // actionPerformed nicht geloescht werden kann.
+ staruno::Reference<starlang::XComponent> xComp = m_xComp;
+ ::cppu::OComponentHelper *pCompImpl = m_pCompImpl;
+
+ starlang::EventObject* pEvt = *m_aEvents.erase( m_aEvents.begin() );
+ staruno::Reference<staruno::XAdapter> xControlAdapter = *m_aControls.erase( m_aControls.begin() );
+ sal_Bool bFlag = *m_aFlags.erase( m_aFlags.begin() );
+
+ {
+ MutexRelease aReleaseOnce(m_aMutex);
+ // Weil ein queryHardRef eine staruno::Exception schmeissen kann sollte
+ // es nicht bei gelocktem Mutex aufgerufen werden.
+ staruno::Reference<starawt::XControl> xControl;
+ if ( xControlAdapter.is() )
+ query_interface(xControlAdapter->queryAdapted(), xControl);
+
+ if( xComp.is() )
+ processEvent( pCompImpl, pEvt, xControl, bFlag );
+ }
+
+ delete pEvt;
+ };
+
+ // Nach einem dispose kennen wir das Control nicht mehr. Dann darf
+ // auch nicht gewartet werden.
+ if( !m_xComp.is() )
+ return;
+
+ // Warte-Bedingung zuruecksetzen
+ m_aCond.reset();
+ {
+ MutexRelease aReleaseOnce(m_aMutex);
+ // und warten ... falls nicht zwischenzeitlich doch noch ein
+ // Event eingetroffen ist.
+ m_aCond.wait();
+ }
+ }
+ while( sal_True );
+}
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
diff --git a/forms/source/component/EventThread.hxx b/forms/source/component/EventThread.hxx
new file mode 100644
index 000000000000..5bf63e85c539
--- /dev/null
+++ b/forms/source/component/EventThread.hxx
@@ -0,0 +1,165 @@
+/*************************************************************************
+ *
+ * $RCSfile: EventThread.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FRM_EVENT_THREAD_HXX_
+#define _FRM_EVENT_THREAD_HXX_
+
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/lang/EventObject.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/awt/XControl.hpp>
+#include <vos/thread.hxx>
+
+
+#ifndef _OSL_CONDITN_HXX_
+#include <osl/conditn.hxx>
+#endif
+#ifndef _CPPUHELPER_COMPONENT_HXX_
+#include <cppuhelper/component.hxx>
+#endif
+
+#ifndef _UTL_STLTYPES_HXX_
+#include <unotools/stl_types.hxx>
+#endif
+#ifndef _UNOTOOLS_GUARDING_HXX_
+#include <unotools/guarding.hxx>
+#endif
+#ifndef _UTL_UNO3_HXX_
+#include <unotools/uno3.hxx>
+#endif
+using namespace utl;
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+ namespace starlang = ::com::sun::star::lang;
+ namespace staruno = ::com::sun::star::uno;
+
+// ***************************************************************************************************
+// ***************************************************************************************************
+
+class OComponentEventThread
+ :public ::vos::OThread
+ ,public starlang::XEventListener
+ ,public ::cppu::OWeakObject
+{
+ DECLARE_STL_VECTOR(starlang::EventObject*, ThreadEvents);
+ DECLARE_STL_VECTOR(staruno::Reference<staruno::XAdapter> , ThreadObjects);
+ DECLARE_STL_VECTOR(sal_Bool, ThreadBools);
+
+ OCountedMutex m_aMutex;
+ ::osl::Condition m_aCond; // Queue gefuellt?
+ ThreadEvents m_aEvents; // Event-Queue
+ ThreadObjects m_aControls; // Control fuer Submit
+ ThreadBools m_aFlags; // Flags fuer Submit/Reset
+
+ ::cppu::OComponentHelper* m_pCompImpl; // Implementierung des Controls
+ staruno::Reference<starlang::XComponent> m_xComp; // starlang::XComponent des Controls
+
+protected:
+
+ // XThread
+ virtual void SAL_CALL run();
+
+ // Die folgende Methode wird gerufen um das Event unter Beruecksichtigung
+ // seines Typs zu duplizieren.
+ virtual starlang::EventObject* cloneEvent(const starlang::EventObject* _pEvt) const = 0;
+
+ // Ein Event bearbeiten. Der Mutex ist dabei nicht gelockt, pCompImpl
+ // bleibt aber in jedem Fall gueltig. Bei pEvt kann es sich auch um
+ // einen abgeleiteten Typ handeln, naemlich den, den cloneEvent
+ // zurueckgibt. rControl ist nur gesetzt, wenn beim addEvent ein
+ // Control uebergeben wurde. Da das Control nur als WeakRef gehalten
+ // wird kann es auch zwischenzeitlich verschwinden.
+ virtual void processEvent( ::cppu::OComponentHelper* _pCompImpl,
+ const starlang::EventObject* _pEvt,
+ const staruno::Reference<starawt::XControl>& _rControl,
+ sal_Bool _bFlag) = 0;
+
+public:
+
+ // UNO Anbindung
+ DECLARE_UNO3_DEFAULTS(OComponentEventThread, OWeakObject);
+ virtual staruno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException);
+
+ OComponentEventThread(::cppu::OComponentHelper* pCompImpl);
+ virtual ~OComponentEventThread();
+
+ void addEvent( const starlang::EventObject* _pEvt, sal_Bool bFlag = sal_False );
+ void addEvent( const starlang::EventObject* _pEvt, const staruno::Reference<starawt::XControl>& rControl,
+ sal_Bool bFlag = sal_False );
+
+ // starlang::XEventListener
+ virtual void SAL_CALL disposing(const starlang::EventObject& _rSource );
+
+/* resolve ambiguity : both OWeakObject and OObject have these memory operators */
+ void * SAL_CALL operator new( size_t size ) throw() { return OThread::operator new(size); }
+ void SAL_CALL operator delete( void * p ) throw() { OThread::operator delete(p); }
+};
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
+#endif // _FRM_EVENT_THREAD_HXX_
+
diff --git a/forms/source/component/File.cxx b/forms/source/component/File.cxx
new file mode 100644
index 000000000000..13623179f644
--- /dev/null
+++ b/forms/source/component/File.cxx
@@ -0,0 +1,329 @@
+/*************************************************************************
+ *
+ * $RCSfile: File.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#ifndef _FORMS_FILE_HXX_
+#include "File.hxx"
+#endif
+
+#include <com/sun/star/form/FormComponentType.hpp>
+
+#ifndef _FRM_PROPERTY_HRC_
+#include "property.hrc"
+#endif
+#ifndef _FRM_SERVICES_HXX_
+#include "services.hxx"
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _UTL_CONTAINER_HXX_
+#include <unotools/container.hxx>
+#endif
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OFileControlModel_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new OFileControlModel(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> OFileControlModel::_getTypes()
+{
+ static staruno::Sequence<staruno::Type> aTypes;
+ if (!aTypes.getLength())
+ {
+ // my base class
+ staruno::Sequence<staruno::Type> aBaseClassTypes = OControlModel::_getTypes();
+
+ staruno::Sequence<staruno::Type> aOwnTypes(1);
+ staruno::Type* pOwnTypes = aOwnTypes.getArray();
+ pOwnTypes[0] = getCppuType((staruno::Reference<starform::XReset>*)NULL);
+
+ aTypes = concatSequences(aBaseClassTypes, aOwnTypes);
+ }
+ return aTypes;
+}
+
+
+// starlang::XServiceInfo
+//------------------------------------------------------------------------------
+StringSequence OFileControlModel::getSupportedServiceNames() throw(staruno::RuntimeException)
+{
+ StringSequence aSupported = OControlModel::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 1);
+
+ ::rtl::OUString*pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_FILECONTROL;
+ return aSupported;
+}
+
+//------------------------------------------------------------------
+OFileControlModel::OFileControlModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OControlModel(_rxFactory, VCL_CONTROLMODEL_FILECONTROL)
+ ,m_aResetListeners(m_aMutex)
+{
+ m_nClassId = starform::FormComponentType::FILECONTROL;
+}
+
+//------------------------------------------------------------------
+OFileControlModel::~OFileControlModel()
+{
+ if (!OComponentHelper::rBHelper.bDisposed)
+ {
+ acquire();
+ dispose();
+ }
+}
+
+//------------------------------------------------------------------------------
+staruno::Any SAL_CALL OFileControlModel::queryAggregation(const staruno::Type& _rType) throw (staruno::RuntimeException)
+{
+ staruno::Any aReturn;
+
+ aReturn = OControlModel::queryAggregation(_rType);
+ if (!aReturn.hasValue())
+ aReturn = ::cppu::queryInterface(_rType
+ ,static_cast<starform::XReset*>(this)
+ );
+
+ return aReturn;
+}
+
+// OComponentHelper
+//-----------------------------------------------------------------------------
+void OFileControlModel::disposing()
+{
+ OControlModel::disposing();
+
+ starlang::EventObject aEvt(static_cast<staruno::XWeak*>(this));
+ m_aResetListeners.disposeAndClear(aEvt);
+}
+
+//------------------------------------------------------------------------------
+void OFileControlModel::getFastPropertyValue(staruno::Any& rValue, sal_Int32 nHandle) const
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_DEFAULT_TEXT : rValue <<= m_sDefaultValue; break;
+ default:
+ OControlModel::getFastPropertyValue(rValue, nHandle);
+ }
+}
+
+//------------------------------------------------------------------------------
+void OFileControlModel::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const staruno::Any& rValue)
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_DEFAULT_TEXT :
+ DBG_ASSERT(rValue.getValueType().getTypeClass() == staruno::TypeClass_STRING, "OFileControlModel::setFastPropertyValue_NoBroadcast : invalid type !" );
+ rValue >>= m_sDefaultValue;
+ break;
+ default:
+ OControlModel::setFastPropertyValue_NoBroadcast(nHandle, rValue);
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OFileControlModel::convertFastPropertyValue(staruno::Any& rConvertedValue, staruno::Any& rOldValue, sal_Int32 nHandle, const staruno::Any& rValue)
+ throw( starlang::IllegalArgumentException )
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_DEFAULT_TEXT :
+ return tryPropertyValue(rConvertedValue, rOldValue, rValue, m_sDefaultValue);
+ default:
+ return OControlModel::convertFastPropertyValue(rConvertedValue, rOldValue, nHandle, rValue);
+ }
+}
+
+//------------------------------------------------------------------------------
+staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL OFileControlModel::getPropertySetInfo() throw( staruno::RuntimeException )
+{
+ staruno::Reference<starbeans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//------------------------------------------------------------------------------
+void OFileControlModel::fillProperties(
+ staruno::Sequence< starbeans::Property >& _rProps,
+ staruno::Sequence< starbeans::Property >& _rAggregateProps ) const
+{
+ FRM_BEGIN_PROP_HELPER(6)
+ DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT);
+ DECL_PROP1(DEFAULT_TEXT, ::rtl::OUString, BOUND);
+ DECL_PROP1(NAME, ::rtl::OUString, BOUND);
+ DECL_PROP1(TAG, ::rtl::OUString, BOUND);
+ DECL_PROP1(TABINDEX, sal_Int16, BOUND);
+ DECL_PROP1(HELPTEXT, ::rtl::OUString, BOUND);
+
+ // in den agregierten Properties muss ich noch PROPERTY_ID_TEXT auf transient setzen ...
+// ModifyPropertyAttributes(_rAggregateProps, PROPERTY_TEXT, starbeans::PropertyAttribute::TRANSIENT, 0);
+ FRM_END_PROP_HELPER();
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OFileControlModel::getInfoHelper()
+{
+ return *const_cast<OFileControlModel*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OFileControlModel::getServiceName()
+{
+ return FRM_COMPONENT_FILECONTROL; // old (non-sun) name for compatibility !
+}
+
+//------------------------------------------------------------------------------
+void OFileControlModel::write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream)
+{
+ OControlModel::write(_rxOutStream);
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ // Version
+ _rxOutStream->writeShort(0x0002);
+ // Default-Wert
+ _rxOutStream << m_sDefaultValue;
+ _rxOutStream << m_aHelpText;
+}
+
+//------------------------------------------------------------------------------
+void OFileControlModel::read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream)
+{
+ OControlModel::read(_rxInStream);
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ // Version
+ sal_uInt16 nVersion = _rxInStream->readShort();
+ // Default-Wert
+ switch (nVersion)
+ {
+ case 1:
+ _rxInStream >> m_sDefaultValue; break;
+ case 2:
+ _rxInStream >> m_sDefaultValue;
+ _rxInStream >> m_aHelpText;
+ break;
+ default:
+ DBG_ERROR("OFileControlModel::read : unknown version !");
+ m_sDefaultValue = ::rtl::OUString();
+ }
+
+ // Nach dem Lesen die Defaultwerte anzeigen
+// _reset();
+}
+
+//-----------------------------------------------------------------------------
+void SAL_CALL OFileControlModel::reset()
+{
+ ::cppu::OInterfaceIteratorHelper aIter(m_aResetListeners);
+ starlang::EventObject aEvt(static_cast<staruno::XWeak*>(this));
+ sal_Bool bContinue = sal_True;
+ while (aIter.hasMoreElements() && bContinue)
+ bContinue =((starform::XResetListener*)aIter.next())->approveReset(aEvt);
+
+ if (bContinue)
+ {
+ {
+ // Wenn Models threadSave
+ ::osl::MutexGuard aGuard(m_aMutex);
+ _reset();
+ }
+ NOTIFY_LISTENERS(m_aResetListeners, starform::XResetListener, resetted, aEvt);
+ }
+}
+
+//-----------------------------------------------------------------------------
+void OFileControlModel::addResetListener(const staruno::Reference<starform::XResetListener>& _rxListener)
+{
+ m_aResetListeners.addInterface(_rxListener);
+}
+
+//-----------------------------------------------------------------------------
+void OFileControlModel::removeResetListener(const staruno::Reference<starform::XResetListener>& _rxListener)
+{
+ m_aResetListeners.removeInterface(_rxListener);
+}
+
+//------------------------------------------------------------------------------
+void OFileControlModel::_reset()
+{
+ { // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
+ // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
+ // our own mutex locked
+ // FS - 72451 - 31.01.00
+ MutexRelease aRelease(m_aMutex);
+ m_xAggregateSet->setPropertyValue(PROPERTY_TEXT, staruno::makeAny(m_sDefaultValue));
+ }
+}
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
diff --git a/forms/source/component/File.hxx b/forms/source/component/File.hxx
new file mode 100644
index 000000000000..dccaafaf01c0
--- /dev/null
+++ b/forms/source/component/File.hxx
@@ -0,0 +1,138 @@
+/*************************************************************************
+ *
+ * $RCSfile: File.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_FILE_HXX_
+#define _FORMS_FILE_HXX_
+
+#ifndef _FORMS_FORMCOMPONENT_HXX_
+#include "FormComponent.hxx"
+#endif
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+//==================================================================
+// OFileControlModel
+//==================================================================
+class OFileControlModel
+ :public OControlModel
+ ,public starform::XReset
+ ,public ::utl::OAggregationArrayUsageHelper< OFileControlModel >
+{
+ ::cppu::OInterfaceContainerHelper m_aResetListeners;
+ ::rtl::OUString m_sDefaultValue;
+
+protected:
+ virtual staruno::Sequence<staruno::Type> _getTypes();
+
+public:
+ OFileControlModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+ ~OFileControlModel();
+
+ DECLARE_UNO3_AGG_DEFAULTS(OFileControlModel, OControlModel);
+ virtual staruno::Any SAL_CALL queryAggregation(const staruno::Type& _rType) throw(staruno::RuntimeException);
+
+// starlang::XServiceInfo
+ IMPLEMENTATION_NAME(OFileControlModel);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw(staruno::RuntimeException);
+
+// OComponentHelper
+ virtual void SAL_CALL disposing();
+
+ virtual void SAL_CALL getFastPropertyValue(staruno::Any& rValue, sal_Int32 nHandle) const;
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const staruno::Any& rValue);
+
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(staruno::Any& rConvertedValue, staruno::Any& rOldValue, sal_Int32 nHandle, const staruno::Any& rValue )
+ throw(starlang::IllegalArgumentException);
+
+// starbeans::XPropertySet
+ virtual staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(staruno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+// stario::XPersistObject
+ virtual ::rtl::OUString SAL_CALL getServiceName();
+ virtual void SAL_CALL write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream);
+ virtual void SAL_CALL read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream);
+
+// starform::XReset
+ virtual void SAL_CALL reset();
+ virtual void SAL_CALL addResetListener(const staruno::Reference<starform::XResetListener>& _rxListener);
+ virtual void SAL_CALL removeResetListener(const staruno::Reference<starform::XResetListener>& _rxListener);
+
+// OAggregationArrayUsageHelper
+ virtual void fillProperties(
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rProps,
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rAggregateProps
+ ) const;
+ IMPLEMENT_INFO_SERVICE()
+
+protected:
+ void _reset();
+};
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
+#endif // _FORMS_FILE_HXX_
+
diff --git a/forms/source/component/FixedText.cxx b/forms/source/component/FixedText.cxx
new file mode 100644
index 000000000000..edc7567d448b
--- /dev/null
+++ b/forms/source/component/FixedText.cxx
@@ -0,0 +1,174 @@
+/*************************************************************************
+ *
+ * $RCSfile: FixedText.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#ifndef _FORMS_FIXEDTEXT_HXX_
+#include "FixedText.hxx"
+#endif
+#ifndef _FRM_SERVICES_HXX_
+#include "services.hxx"
+#endif
+#ifndef _FRM_PROPERTY_HRC_
+#include "property.hrc"
+#endif
+#ifndef _FRM_PROPERTY_HXX_
+#include "property.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+//.........................................................................
+namespace frm
+{
+
+//------------------------------------------------------------------------------
+InterfaceRef SAL_CALL OFixedTextModel_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory) throw (staruno::RuntimeException)
+{
+ return *(new OFixedTextModel(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> OFixedTextModel::_getTypes()
+{
+ static staruno::Sequence<staruno::Type> aTypes = OControlModel::_getTypes();
+ return aTypes;
+}
+
+//------------------------------------------------------------------
+OFixedTextModel::OFixedTextModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rFactory)
+ :OControlModel(_rFactory, VCL_CONTROLMODEL_FIXEDTEXT)
+
+{
+ m_nClassId = starform::FormComponentType::FIXEDTEXT;
+}
+
+//------------------------------------------------------------------------------
+StringSequence SAL_CALL OFixedTextModel::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException)
+{
+ StringSequence aSupported = OControlModel::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 1);
+
+ ::rtl::OUString* pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_FIXEDTEXT;
+ return aSupported;
+}
+
+//------------------------------------------------------------------------------
+staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL OFixedTextModel::getPropertySetInfo() throw(staruno::RuntimeException)
+{
+ staruno::Reference<starbeans::XPropertySetInfo> xInfo(createPropertySetInfo(getInfoHelper()));
+ return xInfo;
+}
+
+//------------------------------------------------------------------------------
+cppu::IPropertyArrayHelper& OFixedTextModel::getInfoHelper()
+{
+ return *const_cast<OFixedTextModel*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+void OFixedTextModel::fillProperties(
+ staruno::Sequence< starbeans::Property >& _rProps,
+ staruno::Sequence< starbeans::Property >& _rAggregateProps ) const
+{
+ FRM_BEGIN_PROP_HELPER(4)
+ RemoveProperty(_rAggregateProps, PROPERTY_TABSTOP);
+
+ DECL_PROP1(NAME, rtl::OUString, BOUND);
+ DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT);
+ DECL_PROP1(TAG, rtl::OUString, BOUND);
+ DECL_PROP1(HELPTEXT,rtl::OUString, BOUND);
+ FRM_END_PROP_HELPER();
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OFixedTextModel::getServiceName() throw(staruno::RuntimeException)
+{
+ return FRM_COMPONENT_FIXEDTEXT; // old (non-sun) name for compatibility !
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OFixedTextModel::write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream)
+ throw(stario::IOException, staruno::RuntimeException)
+{
+ OControlModel::write(_rxOutStream);
+
+ // Version
+ _rxOutStream->writeShort(0x0002);
+ _rxOutStream << m_aHelpText;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OFixedTextModel::read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream) throw(stario::IOException, staruno::RuntimeException)
+{
+ OControlModel::read(_rxInStream);
+
+ // Version
+ sal_Int16 nVersion = _rxInStream->readShort();
+ if (nVersion > 1)
+ _rxInStream >> m_aHelpText;
+}
+
+//.........................................................................
+}
+//.........................................................................
+
diff --git a/forms/source/component/FixedText.hxx b/forms/source/component/FixedText.hxx
new file mode 100644
index 000000000000..aafd01923750
--- /dev/null
+++ b/forms/source/component/FixedText.hxx
@@ -0,0 +1,117 @@
+/*************************************************************************
+ *
+ * $RCSfile: FixedText.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_FIXEDTEXT_HXX_
+#define _FORMS_FIXEDTEXT_HXX_
+
+#ifndef _FORMS_FORMCOMPONENT_HXX_
+#include "FormComponent.hxx"
+#endif
+
+//.........................................................................
+namespace frm
+{
+
+//==================================================================
+// OFixedTextModel
+//==================================================================
+class OFixedTextModel
+ :public OControlModel
+ ,public ::utl::OAggregationArrayUsageHelper< OFixedTextModel >
+{
+protected:
+ // UNO Anbindung
+ virtual staruno::Sequence<staruno::Type> _getTypes();
+
+public:
+ OFixedTextModel(
+ const staruno::Reference<starlang::XMultiServiceFactory>& _rFactory // factory to create the aggregate with
+ );
+
+// XPropertySetRef
+ virtual staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(staruno::RuntimeException);
+ virtual cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+// XServiceInfo
+ IMPLEMENTATION_NAME(OFixedTextModel);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+// XPersistObject
+ virtual ::rtl::OUString SAL_CALL getServiceName() throw(staruno::RuntimeException);
+ virtual void SAL_CALL
+ write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream) throw(stario::IOException, staruno::RuntimeException);
+ virtual void SAL_CALL
+ read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream) throw(stario::IOException, staruno::RuntimeException);
+
+// OAggregationArrayUsageHelper
+ virtual void fillProperties(
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rProps,
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rAggregateProps
+ ) const;
+ IMPLEMENT_INFO_SERVICE()
+};
+
+//.........................................................................
+}
+//.........................................................................
+
+#endif // _FORMS_FIXEDTEXT_HXX_
+
diff --git a/forms/source/component/FormComponent.cxx b/forms/source/component/FormComponent.cxx
new file mode 100644
index 000000000000..371d3507a86d
--- /dev/null
+++ b/forms/source/component/FormComponent.cxx
@@ -0,0 +1,1458 @@
+/*************************************************************************
+ *
+ * $RCSfile: FormComponent.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_FORMCOMPONENT_HXX_
+#include "FormComponent.hxx"
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_AWT_XTEXTCOMPONENT_HPP_
+#include <com/sun/star/awt/XTextComponent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_
+#include <com/sun/star/awt/XWindow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XMARKABLESTREAM_HPP_
+#include <com/sun/star/io/XMarkableStream.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XLOADABLE_HPP_
+#include <com/sun/star/form/XLoadable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORM_HPP_
+#include <com/sun/star/form/XForm.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#endif
+
+#ifndef _UTL_PROPERTY_HXX_
+#include <unotools/property.hxx>
+#endif
+#ifndef _UTL_UNO3_DB_TOOLS_HXX_
+#include <unotools/dbtools.hxx>
+#endif
+#ifndef _FRM_PROPERTY_HRC_
+#include "property.hrc"
+#endif
+#ifndef _FRM_SERVICES_HXX_
+#include "services.hxx"
+#endif
+
+//... namespace frm .......................................................
+namespace frm
+{
+//.........................................................................
+
+//=========================================================================
+//= base class for form layer controls
+//=========================================================================
+DBG_NAME(frm_OControl)
+//------------------------------------------------------------------------------
+OControl::OControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory, const rtl::OUString& _sService)
+ :OComponentHelper(m_aMutex)
+ ,m_aService(_sService)
+ ,m_xServiceFactory(_rxFactory)
+{
+ DBG_CTOR(frm_OControl, NULL);
+ // VCL-Control aggregieren
+ // bei Aggregation den Refcount um eins erhoehen da im setDelegator
+ // das Aggregat selbst den Refcount erhoeht
+ increment(m_refCount);
+ {
+ m_xAggregate = staruno::Reference<staruno::XAggregation>(
+ _rxFactory->createInstance(_sService), staruno::UNO_QUERY);
+ m_xControl = staruno::Reference<starawt::XControl>(m_xAggregate, staruno::UNO_QUERY);
+ }
+
+ if (m_xAggregate.is())
+ {
+ m_xAggregate->setDelegator(static_cast<staruno::XWeak*>(this));
+ }
+
+ // Refcount wieder bei NULL
+ sal_Int32 n = decrement(m_refCount);
+}
+
+//------------------------------------------------------------------------------
+OControl::~OControl()
+{
+ DBG_DTOR(frm_OControl, NULL);
+ // Freigeben der Aggregation
+ if (m_xAggregate.is())
+ {
+ m_xAggregate->setDelegator(InterfaceRef());
+ }
+}
+
+// UNO Anbindung
+//------------------------------------------------------------------------------
+staruno::Any SAL_CALL OControl::queryAggregation( const staruno::Type& _rType ) throw(staruno::RuntimeException)
+{
+ staruno::Any aReturn;
+
+ // ask the base class
+ aReturn = OComponentHelper::queryAggregation(_rType);
+ // ask our own interfaces
+ if (!aReturn.hasValue())
+ aReturn = cppu::queryInterface(_rType
+ ,static_cast<starawt::XControl*>(this)
+ ,static_cast<starlang::XEventListener*>(this)
+ ,static_cast<starlang::XServiceInfo*>(this)
+ );
+
+ // ask our aggregate
+ if (!aReturn.hasValue() && m_xAggregate.is())
+ aReturn = m_xAggregate->queryAggregation(_rType);
+
+ return aReturn;
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<sal_Int8> SAL_CALL OControl::getImplementationId() throw(staruno::RuntimeException)
+{
+ return OImplementationIds::getImplementationId(getTypes());
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> SAL_CALL OControl::getTypes() throw(staruno::RuntimeException)
+{
+ staruno::Sequence<staruno::Type> aOwnTypes = _getTypes();
+ staruno::Reference<starlang::XTypeProvider> xProv;
+
+ if (query_aggregation(m_xAggregate, xProv))
+ return concatSequences(aOwnTypes, xProv->getTypes());
+ else
+ return aOwnTypes;
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> OControl::_getTypes()
+{
+ static staruno::Sequence<staruno::Type> aTypes;
+ if (!aTypes.getLength())
+ {
+ // my base class types
+ staruno::Sequence<staruno::Type> aBaseTypes = OComponentHelper::getTypes();
+
+ staruno::Sequence<staruno::Type> aOwnTypes(3);
+ staruno::Type* pOwnTypes = aOwnTypes.getArray();
+ pOwnTypes[0] = getCppuType((staruno::Reference<starawt::XControl>*)NULL);
+ pOwnTypes[1] = getCppuType((staruno::Reference<starlang::XEventListener>*)NULL);
+ pOwnTypes[2] = getCppuType((staruno::Reference<starlang::XServiceInfo>*)NULL);
+
+ aTypes = concatSequences(aTypes, aOwnTypes);
+ }
+ return aTypes;
+}
+
+// OComponentHelper
+//------------------------------------------------------------------------------
+void OControl::disposing()
+{
+ OComponentHelper::disposing();
+
+ staruno::Reference<starlang::XComponent> xComp;
+ if (query_aggregation(m_xAggregate, xComp))
+ xComp->dispose();
+}
+
+// XServiceInfo
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL OControl::supportsService(const rtl::OUString& _rsServiceName)
+{
+ staruno::Sequence<rtl::OUString> aSupported = getSupportedServiceNames();
+ const rtl::OUString* pSupported = aSupported.getConstArray();
+ for (sal_Int32 i=0; i<aSupported.getLength(); ++i, ++pSupported)
+ if (pSupported->equals(_rsServiceName))
+ return sal_True;
+ return sal_False;
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<rtl::OUString> SAL_CALL OControl::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException)
+{
+ staruno::Sequence<rtl::OUString> aSupported;
+
+ // ask our aggregate
+ staruno::Reference<starlang::XServiceInfo> xInfo;
+ if (query_aggregation(m_xAggregate, xInfo))
+ aSupported = xInfo->getSupportedServiceNames();
+
+ return aSupported;
+}
+
+// XEventListener
+//------------------------------------------------------------------------------
+void SAL_CALL OControl::disposing(const starlang::EventObject& _rEvent) throw (staruno::RuntimeException)
+{
+ InterfaceRef xAggAsIface;
+ query_aggregation(m_xAggregate, xAggAsIface);
+
+ // does the disposing come from the aggregate ?
+ if (xAggAsIface != InterfaceRef(_rEvent.Source, staruno::UNO_QUERY))
+ { // no -> forward it
+ staruno::Reference<starlang::XEventListener> xListener;
+ if (query_aggregation(m_xAggregate, xListener))
+ xListener->disposing(_rEvent);
+ }
+}
+
+// XControl
+//------------------------------------------------------------------------------
+void SAL_CALL OControl::setContext(const InterfaceRef& Context) throw (staruno::RuntimeException)
+{
+ if (m_xControl.is())
+ m_xControl->setContext(Context);
+}
+
+//------------------------------------------------------------------------------
+InterfaceRef SAL_CALL OControl::getContext() throw (staruno::RuntimeException)
+{
+ return m_xControl.is() ? m_xControl->getContext() : InterfaceRef();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OControl::createPeer(const staruno::Reference<starawt::XToolkit>& Toolkit, const staruno::Reference<starawt::XWindowPeer>& Parent) throw (staruno::RuntimeException)
+{
+ if (m_xControl.is())
+ m_xControl->createPeer(Toolkit, Parent);
+}
+
+//------------------------------------------------------------------------------
+staruno::Reference<starawt::XWindowPeer> SAL_CALL OControl::getPeer()
+{
+ return m_xControl.is() ? m_xControl->getPeer() : staruno::Reference<starawt::XWindowPeer>();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL OControl::setModel(const staruno::Reference<starawt::XControlModel>& Model)
+{
+ return m_xControl.is() ? m_xControl->setModel( Model ) : sal_False;
+}
+
+//------------------------------------------------------------------------------
+staruno::Reference<starawt::XControlModel> SAL_CALL OControl::getModel()
+{
+ return m_xControl.is() ? m_xControl->getModel() : staruno::Reference<starawt::XControlModel>();
+}
+
+//------------------------------------------------------------------------------
+staruno::Reference<starawt::XView> SAL_CALL OControl::getView()
+{
+ return m_xControl.is() ? m_xControl->getView() : staruno::Reference<starawt::XView>();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OControl::setDesignMode(sal_Bool bOn)
+{
+ if (m_xControl.is())
+ m_xControl->setDesignMode(bOn);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL OControl::isDesignMode()
+{
+ return m_xControl.is() ? m_xControl->isDesignMode() : sal_True;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL OControl::isTransparent()
+{
+ return m_xControl.is() ? m_xControl->isTransparent() : sal_True;
+}
+
+//==================================================================
+//= OBoundControl
+//==================================================================
+DBG_NAME(frm_OBoundControl);
+//------------------------------------------------------------------
+OBoundControl::OBoundControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory, const ::rtl::OUString& _sService)
+ :OControl(_rxFactory, _sService)
+ ,m_bLocked(sal_False)
+{
+ DBG_CTOR(frm_OBoundControl, NULL);
+}
+
+//------------------------------------------------------------------
+OBoundControl::~OBoundControl()
+{
+ DBG_DTOR(frm_OBoundControl, NULL);
+}
+
+//------------------------------------------------------------------
+staruno::Any SAL_CALL OBoundControl::queryAggregation(const staruno::Type& _rType) throw(staruno::RuntimeException)
+{
+ staruno::Any aReturn;
+
+ // ask the base class
+ aReturn = OControl::queryAggregation(_rType);
+ // ask our own interfaces
+ if (!aReturn.hasValue())
+ aReturn = cppu::queryInterface(_rType, static_cast<starform::XBoundControl*>(this));
+
+ return aReturn;
+}
+
+//------------------------------------------------------------------
+sal_Bool SAL_CALL OBoundControl::getLock() throw(staruno::RuntimeException)
+{
+ return m_bLocked;
+}
+
+//------------------------------------------------------------------
+void SAL_CALL OBoundControl::setLock(sal_Bool _bLock) throw(staruno::RuntimeException)
+{
+ if (m_bLocked == _bLock)
+ return;
+
+ osl::MutexGuard aGuard(m_aMutex);
+ _setLock(_bLock);
+ m_bLocked = _bLock;
+}
+
+//------------------------------------------------------------------
+void OBoundControl::_setLock(sal_Bool _bLock)
+{
+ // try to set the text component to readonly
+ staruno::Reference<starawt::XWindowPeer> xPeer = getPeer();
+ staruno::Reference<com::sun::star::awt::XTextComponent> xText(xPeer, staruno::UNO_QUERY);
+
+ if (xText.is())
+ xText->setEditable(!_bLock);
+ else
+ {
+ // disable the window
+ staruno::Reference<starawt::XWindow> xComp(xPeer, staruno::UNO_QUERY);
+ if (xComp.is())
+ xComp->setEnable(!_bLock);
+ }
+}
+
+//==================================================================
+//= OControlModel
+//==================================================================
+ConcretInfoService OControlModel::s_aPropInfos;
+DBG_NAME(OControlModel)
+//------------------------------------------------------------------
+staruno::Sequence<sal_Int8> SAL_CALL OControlModel::getImplementationId() throw(staruno::RuntimeException)
+{
+ return OImplementationIds::getImplementationId(getTypes());
+}
+
+//------------------------------------------------------------------
+staruno::Sequence<staruno::Type> SAL_CALL OControlModel::getTypes() throw(staruno::RuntimeException)
+{
+ staruno::Sequence<staruno::Type> aOwnTypes = _getTypes();
+ staruno::Reference<starlang::XTypeProvider> xProv;
+
+ if (query_aggregation(m_xAggregate, xProv))
+ return concatSequences(aOwnTypes, xProv->getTypes());
+ else
+ return aOwnTypes;
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> OControlModel::_getTypes()
+{
+ static staruno::Sequence<staruno::Type> aTypes;
+ if (!aTypes.getLength())
+ {
+ // my two base classes
+ staruno::Sequence<staruno::Type> aComponentTypes = OComponentHelper::getTypes();
+ staruno::Sequence<staruno::Type> aPropertyTypes = OPropertySetAggregationHelper::getTypes();
+
+ staruno::Sequence<staruno::Type> aOwnTypes(4);
+ staruno::Type* pOwnTypes = aOwnTypes.getArray();
+ pOwnTypes[0] = getCppuType((staruno::Reference<starform::XFormComponent>*)NULL);
+ pOwnTypes[1] = getCppuType((staruno::Reference<stario::XPersistObject>*)NULL);
+ pOwnTypes[1] = getCppuType((staruno::Reference<starcontainer::XNamed>*)NULL);
+ pOwnTypes[3] = getCppuType((staruno::Reference<starlang::XServiceInfo>*)NULL);
+
+ aTypes = concatSequences(aComponentTypes, aPropertyTypes, aOwnTypes);
+ }
+ return aTypes;
+}
+
+//------------------------------------------------------------------
+staruno::Any SAL_CALL OControlModel::queryAggregation(const staruno::Type& _rType) throw (staruno::RuntimeException)
+{
+ staruno::Any aReturn;
+
+ // base class 1
+ aReturn = OComponentHelper::queryAggregation(_rType);
+
+ // base class 2
+ if (!aReturn.hasValue())
+ aReturn = OPropertySetAggregationHelper::queryInterface(_rType);
+
+ // our own interfaces
+ if (!aReturn.hasValue())
+ aReturn = ::cppu::queryInterface(_rType
+ ,static_cast<starform::XFormComponent*>(this)
+ ,static_cast<starcontainer::XChild*>(this)
+ ,static_cast<stario::XPersistObject*>(this)
+ ,static_cast<starcontainer::XNamed*>(this)
+ ,static_cast<starlang::XServiceInfo*>(this)
+ );
+
+ // our aggregate
+ if (!aReturn.hasValue() && m_xAggregate.is())
+ aReturn = m_xAggregate->queryAggregation(_rType);
+ return aReturn;
+}
+
+//------------------------------------------------------------------
+OControlModel::OControlModel(
+ const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory,
+ const ::rtl::OUString& _rUnoControlModelTypeName,
+ const ::rtl::OUString& rDefault)
+ :OComponentHelper(m_aMutex)
+ ,OPropertySetAggregationHelper(OComponentHelper::rBHelper)
+ ,m_aUnoControlModelTypeName(_rUnoControlModelTypeName)
+ ,m_nTabIndex(FRM_DEFAULT_TABINDEX)
+ ,m_nClassId(starform::FormComponentType::CONTROL)
+ ,m_xServiceFactory(_rxFactory)
+{
+ DBG_CTOR(OControlModel, NULL);
+ if (_rUnoControlModelTypeName.getLength()) // the is a model we have to aggregate
+ {
+ increment(m_refCount);
+
+ // Muss im eigenen Block,
+ // da xAgg vor dem delegator setzen wieder freigesetzt sein muß!
+ {
+ m_xAggregate = staruno::Reference<staruno::XAggregation>(_rxFactory->createInstance(_rUnoControlModelTypeName), staruno::UNO_QUERY);
+ setAggregation(m_xAggregate);
+
+ if (m_xAggregateSet.is() && rDefault.len())
+ m_xAggregateSet->setPropertyValue(PROPERTY_DEFAULTCONTROL, staruno::makeAny(rDefault));
+ }
+
+ if (m_xAggregate.is())
+ {
+ m_xAggregate->setDelegator(static_cast<staruno::XWeak*>(this));
+ }
+
+ // Refcount wieder bei NULL
+ sal_Int32 n = decrement(m_refCount);
+ }
+}
+
+//------------------------------------------------------------------
+OControlModel::~OControlModel()
+{
+ DBG_DTOR(OControlModel, NULL);
+ // release the aggregate
+ if (m_xAggregate.is())
+ m_xAggregate->setDelegator(InterfaceRef());
+}
+
+// XChild
+//------------------------------------------------------------------------------
+void SAL_CALL OControlModel::setParent(const InterfaceRef& _rxParent) throw(starlang::NoSupportException, staruno::RuntimeException)
+{
+ osl::MutexGuard aGuard(m_aMutex);
+
+ staruno::Reference<starlang::XComponent> xComp(m_xParent, staruno::UNO_QUERY);
+ if (xComp.is())
+ xComp->removeEventListener(static_cast<starbeans::XPropertiesChangeListener*>(this));
+
+ xComp = staruno::Reference<starlang::XComponent>(_rxParent, staruno::UNO_QUERY);
+ if (xComp.is())
+ xComp->addEventListener(static_cast<starbeans::XPropertiesChangeListener*>(this));
+ m_xParent = _rxParent;
+}
+
+// XNamed
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OControlModel::getName() throw(staruno::RuntimeException)
+{
+ ::rtl::OUString aReturn;
+ OPropertySetHelper::getFastPropertyValue(PROPERTY_ID_NAME) >>= aReturn;
+ return aReturn;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OControlModel::setName(const ::rtl::OUString& _rName) throw(staruno::RuntimeException)
+{
+ setFastPropertyValue(PROPERTY_ID_NAME, staruno::makeAny(_rName));
+}
+
+// XServiceInfo
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL OControlModel::supportsService(const rtl::OUString& _rServiceName)
+{
+ staruno::Sequence<rtl::OUString> aSupported = getSupportedServiceNames();
+ const rtl::OUString* pSupported = aSupported.getConstArray();
+ for (sal_Int32 i=0; i<aSupported.getLength(); ++i, ++pSupported)
+ if (pSupported->equals(_rServiceName))
+ return sal_True;
+ return sal_False;
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<rtl::OUString> SAL_CALL OControlModel::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException)
+{
+ staruno::Sequence<rtl::OUString> aSupported;
+
+ // ask our aggregate
+ staruno::Reference<starlang::XServiceInfo> xInfo;
+ if (query_aggregation(m_xAggregate, xInfo))
+ aSupported = xInfo->getSupportedServiceNames();
+
+ aSupported.realloc(aSupported.getLength() + 2);
+ ::rtl::OUString* pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-2] = ::rtl::OUString::createFromAscii("com.sun.star.form.FormComponent");
+ pArray[aSupported.getLength()-1] = ::rtl::OUString::createFromAscii("com.sun.star.form.FormControlModel");
+
+ return aSupported;
+}
+
+// XEventListener
+//------------------------------------------------------------------------------
+void SAL_CALL OControlModel::disposing(const starlang::EventObject& _rSource) throw (staruno::RuntimeException)
+{
+ // release the parent
+ if (_rSource.Source == m_xParent)
+ {
+ osl::MutexGuard aGuard(m_aMutex);
+ m_xParent = NULL;
+ }
+ else
+ {
+ staruno::Reference<starlang::XEventListener> xEvtLst;
+ if (query_aggregation(m_xAggregate, xEvtLst))
+ {
+ osl::MutexGuard aGuard(m_aMutex);
+ xEvtLst->disposing(_rSource);
+ }
+ }
+}
+
+// OComponentHelper
+//-----------------------------------------------------------------------------
+void OControlModel::disposing()
+{
+ OPropertySetAggregationHelper::disposing();
+
+ staruno::Reference<starlang::XComponent> xComp;
+ if (query_aggregation(m_xAggregate, xComp))
+ xComp->dispose();
+
+ setParent(staruno::Reference<starform::XFormComponent>());
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OControlModel::write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream)
+ throw(stario::IOException, staruno::RuntimeException)
+{
+ osl::MutexGuard aGuard(m_aMutex);
+
+ // 1. Schreiben des UnoControls
+ staruno::Reference<stario::XMarkableStream> xMark(_rxOutStream, staruno::UNO_QUERY);
+ sal_Int32 nMark = xMark->createMark();
+ sal_Int32 nLen = 0;
+
+ _rxOutStream->writeLong(nLen);
+
+ staruno::Reference<stario::XPersistObject> xPersist;
+ if (query_aggregation(m_xAggregate, xPersist))
+ xPersist->write(_rxOutStream);
+
+ // feststellen der Laenge
+ nLen = xMark->offsetToMark(nMark) - 4;
+ xMark->jumpToMark(nMark);
+ _rxOutStream->writeLong(nLen);
+ xMark->jumpToFurthest();
+ xMark->deleteMark(nMark);
+
+ // 2. Schreiben einer VersionsNummer
+ _rxOutStream->writeShort(0x0003);
+
+ // 3. Schreiben der allgemeinen Properties
+ _rxOutStream << m_aName;
+ _rxOutStream->writeShort(m_nTabIndex);
+ _rxOutStream << m_aTag; // 3. Version
+
+ // !!! IMPORTANT NOTE !!!
+ // don't write any new members here : this wouldn't be compatible with older versions, as OControlModel
+ // is a base class which is called in derived classes "read" method. So if you increment the version
+ // and write new stuff, older office versions will read this in the _derived_ classes, which may result
+ // in anything from data loss to crash.
+ // !!! EOIN !!!
+}
+
+//------------------------------------------------------------------------------
+void OControlModel::read(const staruno::Reference<stario::XObjectInputStream>& InStream) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
+{
+ osl::MutexGuard aGuard(m_aMutex);
+
+ // 1. Lesen des UnoControls
+ sal_Int32 nLen = InStream->readLong();
+ if (nLen)
+ {
+ staruno::Reference<stario::XMarkableStream> xMark(InStream, staruno::UNO_QUERY);
+ sal_Int32 nMark = xMark->createMark();
+
+ staruno::Reference<stario::XPersistObject> xPersist;
+ if (query_aggregation(m_xAggregate, xPersist))
+ xPersist->read(InStream);
+
+ xMark->jumpToMark(nMark);
+ InStream->skipBytes(nLen);
+ xMark->deleteMark(nMark);
+ }
+
+ // 2. Lesen des Versionsnummer
+ UINT16 nVersion = InStream->readShort();
+
+ // 3. Lesen der allgemeinen Properties
+ InStream >> m_aName;
+ m_nTabIndex = InStream->readShort();
+
+ if (nVersion > 0x0002)
+ InStream >> m_aTag;
+
+ // we had a version where we wrote the help text
+ if (nVersion == 0x0004)
+ InStream >> m_aHelpText;
+
+ DBG_ASSERT(nVersion < 5, "OControlModel::read : suspicious version number !");
+ // 4 was the version where we wrote the help text
+ // later versions shouldn't exist (see write for a detailed comment)
+}
+
+//------------------------------------------------------------------------------
+void OControlModel::getFastPropertyValue( staruno::Any& rValue, sal_Int32 nHandle ) const
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_NAME:
+ rValue <<= m_aName;
+ break;
+ case PROPERTY_ID_TAG:
+ rValue <<= m_aTag;
+ break;
+ case PROPERTY_ID_CLASSID:
+ rValue <<= m_nClassId;
+ break;
+ case PROPERTY_ID_TABINDEX:
+ rValue <<= m_nTabIndex;
+ break;
+ case PROPERTY_ID_HELPTEXT:
+ rValue <<= m_aHelpText;
+ break;
+ default:
+ OPropertySetAggregationHelper::getFastPropertyValue(rValue, nHandle);
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OControlModel::convertFastPropertyValue(
+ staruno::Any& _rConvertedValue, staruno::Any& _rOldValue, sal_Int32 _nHandle, const staruno::Any& _rValue)
+ throw (starlang::IllegalArgumentException)
+{
+ sal_Bool bModified(sal_False);
+ switch (_nHandle)
+ {
+ case PROPERTY_ID_NAME:
+ bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_aName);
+ break;
+ case PROPERTY_ID_TAG:
+ bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_aTag);
+ break;
+ case PROPERTY_ID_HELPTEXT:
+ bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_aHelpText);
+ break;
+ case PROPERTY_ID_TABINDEX:
+ bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_nTabIndex);
+ break;
+ }
+ return bModified;
+}
+
+//------------------------------------------------------------------------------
+void OControlModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const staruno::Any& _rValue)
+ throw (staruno::Exception)
+{
+ switch (_nHandle)
+ {
+ case PROPERTY_ID_NAME:
+ DBG_ASSERT(_rValue.getValueType() == getCppuType((const ::rtl::OUString*)NULL),
+ "OControlModel::setFastPropertyValue_NoBroadcast : invalid type" );
+ _rValue >>= m_aName;
+ break;
+ case PROPERTY_ID_TAG:
+ DBG_ASSERT(_rValue.getValueType() == getCppuType((const ::rtl::OUString*)NULL),
+ "OControlModel::setFastPropertyValue_NoBroadcast : invalid type" );
+ _rValue >>= m_aTag;
+ break;
+ case PROPERTY_ID_TABINDEX:
+ DBG_ASSERT(_rValue.getValueType() == getCppuType((const sal_Int16*)NULL),
+ "OControlModel::setFastPropertyValue_NoBroadcast : invalid type" );
+ _rValue >>= m_nTabIndex;
+ break;
+ case PROPERTY_ID_HELPTEXT:
+ DBG_ASSERT(_rValue.getValueType() == getCppuType((const ::rtl::OUString*)NULL),
+ "OControlModel::setFastPropertyValue_NoBroadcast : invalid type" );
+ _rValue >>= m_aHelpText;
+ break;
+ }
+}
+
+//==================================================================
+//= OBoundControlModel
+//==================================================================
+DBG_NAME(frm_OBoundControlModel);
+//------------------------------------------------------------------
+staruno::Any SAL_CALL OBoundControlModel::queryAggregation( const staruno::Type& _rType ) throw (staruno::RuntimeException)
+{
+ staruno::Any aReturn;
+
+ aReturn = OControlModel::queryAggregation(_rType);
+ if (!aReturn.hasValue())
+ aReturn = cppu::queryInterface(_rType
+ ,static_cast<starbeans::XPropertyChangeListener*>(this)
+ ,static_cast<starform::XReset*>(this)
+ ,static_cast<starform::XLoadListener*>(this)
+ ,static_cast<starlang::XEventListener*>(static_cast<starform::XLoadListener*>(this))
+ );
+
+ if (!aReturn.hasValue() && m_bCommitable)
+ aReturn = cppu::queryInterface(_rType
+ ,static_cast<starform::XBoundComponent*>(this)
+ ,static_cast<starform::XUpdateBroadcaster*>(this)
+ );
+
+ return aReturn;
+}
+
+//------------------------------------------------------------------
+OBoundControlModel::OBoundControlModel(
+ const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory,
+ const ::rtl::OUString& _rUnoControlModelTypeName,
+ const ::rtl::OUString& _rDefault,
+ sal_Bool _bCommitable)
+ :OControlModel(_rxFactory, _rUnoControlModelTypeName, _rDefault)
+ ,m_aUpdateListeners(m_aMutex)
+ ,m_aResetListeners(m_aMutex)
+ ,m_bLoaded(sal_False)
+ ,m_bRequired(sal_False)
+ ,m_bCommitable(_bCommitable)
+ ,m_aLabelServiceName(FRM_SUN_COMPONENT_FIXEDTEXT)
+ ,m_bResetting(sal_False)
+ ,m_bForwardValueChanges(sal_True)
+{
+ DBG_CTOR(frm_OBoundControlModel, NULL);
+}
+
+//------------------------------------------------------------------
+OBoundControlModel::~OBoundControlModel()
+{
+ DBG_DTOR(frm_OBoundControlModel, NULL);
+}
+
+//-----------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> OBoundControlModel::_getTypes()
+{
+ staruno::Sequence<staruno::Type> aReturn = OControlModel::_getTypes();
+
+ sal_Int32 nBaseLen = aReturn.getLength();
+ aReturn.realloc(nBaseLen + (m_bCommitable ? 4 : 3));
+ staruno::Type* pReturn = aReturn.getArray() + nBaseLen;
+ pReturn[0] = ::getCppuType((staruno::Reference<starform::XLoadListener>*)NULL);
+ pReturn[1] = ::getCppuType((staruno::Reference<starform::XReset>*)NULL);
+ pReturn[2] = ::getCppuType((staruno::Reference<starbeans::XPropertyChangeListener>*)NULL);
+ if (m_bCommitable)
+ pReturn[3] = ::getCppuType((staruno::Reference<starform::XBoundComponent>*)NULL);
+
+ return aReturn;
+}
+
+// OComponentHelper
+//-----------------------------------------------------------------------------
+void OBoundControlModel::disposing()
+{
+ OControlModel::disposing();
+
+ osl::MutexGuard aGuard(m_aMutex);
+ starlang::EventObject aEvt(static_cast<staruno::XWeak*>(this));
+ m_aResetListeners.disposeAndClear(aEvt);
+ m_aUpdateListeners.disposeAndClear(aEvt);
+
+ if (m_xField.is())
+ {
+ m_xField->removePropertyChangeListener(PROPERTY_VALUE, this);
+ resetField();
+ }
+ m_xCursor = NULL;
+
+ staruno::Reference<starlang::XComponent> xComp(m_xLabelControl, staruno::UNO_QUERY);
+ if (xComp.is())
+ xComp->removeEventListener(static_cast<starlang::XEventListener*>(static_cast<starbeans::XPropertyChangeListener*>(this)));
+}
+
+// XChild
+//------------------------------------------------------------------------------
+void SAL_CALL OBoundControlModel::setParent(const staruno::Reference<staruno::XInterface>& _rxParent) throw(starlang::NoSupportException, staruno::RuntimeException)
+{
+ osl::MutexGuard aGuard(m_aMutex);
+
+ // log off old listeners
+ staruno::Reference<starform::XLoadable> xLoadable(m_xParent, staruno::UNO_QUERY);
+ if (xLoadable.is())
+ xLoadable->removeLoadListener(this);
+
+ // log on new listeners
+ xLoadable = staruno::Reference<starform::XLoadable>(_rxParent, staruno::UNO_QUERY);
+ if (xLoadable.is())
+ xLoadable->addLoadListener(this);
+
+ OControlModel::setParent(_rxParent);
+}
+
+// XEventListener
+//------------------------------------------------------------------------------
+void SAL_CALL OBoundControlModel::disposing(const starlang::EventObject& _rEvent) throw (staruno::RuntimeException)
+{
+ osl::MutexGuard aGuard(m_aMutex);
+ if (m_xField == _rEvent.Source)
+ {
+ resetField();
+ }
+ else if (m_xLabelControl == _rEvent.Source)
+ {
+ staruno::Reference<starbeans::XPropertySet> xOldValue = m_xLabelControl;
+ m_xLabelControl = NULL;
+
+ // fire a property change event
+ staruno::Any aOldValue; aOldValue <<= xOldValue;
+ staruno::Any aNewValue; aNewValue <<= m_xLabelControl;
+ sal_Int32 nHandle = PROPERTY_ID_CONTROLLABEL;
+ OPropertySetHelper::fire(&nHandle, &aNewValue, &aOldValue, 1, sal_False);
+ }
+ else
+ OControlModel::disposing(_rEvent);
+}
+
+// XServiceInfo
+//------------------------------------------------------------------------------
+StringSequence SAL_CALL OBoundControlModel::getSupportedServiceNames() throw(staruno::RuntimeException)
+{
+ StringSequence aSupported = OControlModel::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 1);
+
+ ::rtl::OUString* pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-1] = ::rtl::OUString::createFromAscii("com.sun.star.form.DataAwareControlModel");
+ return aSupported;
+}
+
+
+// XPersist
+//------------------------------------------------------------------------------
+void SAL_CALL OBoundControlModel::write( const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream ) throw(stario::IOException, staruno::RuntimeException)
+{
+ OControlModel::write(_rxOutStream);
+
+ osl::MutexGuard aGuard(m_aMutex);
+
+ // Version
+ _rxOutStream->writeShort(0x0002);
+
+ // Controlsource
+ _rxOutStream << m_aControlSource;
+
+ // !!! IMPORTANT NOTE !!!
+ // don't write any new members here : this wouldn't be compatible with older versions, as OBoundControlModel
+ // is a base class which is called in derived classes "read" method. So if you increment the version
+ // and write new stuff, older office versions will read this in the _derived_ classes, which may result
+ // in anything from data loss to crash.
+ // (use writeCommonProperties instead, this is called in derived classes write-method)
+ // !!! EOIN !!!
+ // FS - 68876 - 28.09.1999
+}
+
+//------------------------------------------------------------------------------
+void OBoundControlModel::defaultCommonProperties()
+{
+ staruno::Reference<starlang::XComponent> xComp(m_xLabelControl, staruno::UNO_QUERY);
+ if (xComp.is())
+ xComp->removeEventListener(static_cast<starlang::XEventListener*>(static_cast<starbeans::XPropertyChangeListener*>(this)));
+ m_xLabelControl = NULL;
+}
+
+//------------------------------------------------------------------------------
+void OBoundControlModel::readCommonProperties(const staruno::Reference<stario::XObjectInputStream>& _rxInStream)
+{
+ sal_Int32 nLen = _rxInStream->readLong();
+
+ staruno::Reference<stario::XMarkableStream> xMark(_rxInStream, staruno::UNO_QUERY);
+ DBG_ASSERT(xMark.is(), "OBoundControlModel::readCommonProperties : can only work with markable streams !");
+ sal_Int32 nMark = xMark->createMark();
+
+ // read the reference to the label control
+ staruno::Reference<stario::XPersistObject> xPersist;
+ sal_Int32 nUsedFlag;
+ nUsedFlag = _rxInStream->readLong();
+ if (nUsedFlag)
+ xPersist = _rxInStream->readObject();
+ m_xLabelControl = staruno::Reference<starbeans::XPropertySet>(xPersist, staruno::UNO_QUERY);
+ staruno::Reference<starlang::XComponent> xComp(m_xLabelControl, staruno::UNO_QUERY);
+ if (xComp.is())
+ xComp->addEventListener(static_cast<starlang::XEventListener*>(static_cast<starbeans::XPropertyChangeListener*>(this)));
+
+ // read any other new common properties here
+
+ // skip the remaining bytes
+ xMark->jumpToMark(nMark);
+ _rxInStream->skipBytes(nLen);
+ xMark->deleteMark(nMark);
+}
+
+//------------------------------------------------------------------------------
+void OBoundControlModel::writeCommonProperties(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream)
+{
+ staruno::Reference<stario::XMarkableStream> xMark(_rxOutStream, staruno::UNO_QUERY);
+ DBG_ASSERT(xMark.is(), "OBoundControlModel::writeCommonProperties : can only work with markable streams !");
+ sal_Int32 nMark = xMark->createMark();
+
+ // a placeholder where we will write the overall length (later in this method)
+ sal_Int32 nLen = 0;
+ _rxOutStream->writeLong(nLen);
+
+ // write the reference to the label control
+ staruno::Reference<stario::XPersistObject> xPersist(m_xLabelControl, staruno::UNO_QUERY);
+ sal_Int32 nUsedFlag = 0;
+ if (xPersist.is())
+ nUsedFlag = 1;
+ _rxOutStream->writeLong(nUsedFlag);
+ if (xPersist.is())
+ _rxOutStream->writeObject(xPersist);
+
+ // write any other new common properties here
+
+ // write the correct length at the beginning of the block
+ nLen = xMark->offsetToMark(nMark) - sizeof(nLen);
+ xMark->jumpToMark(nMark);
+ _rxOutStream->writeLong(nLen);
+ xMark->jumpToFurthest();
+ xMark->deleteMark(nMark);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OBoundControlModel::read( const staruno::Reference< stario::XObjectInputStream >& _rxInStream ) throw(stario::IOException, staruno::RuntimeException)
+{
+ OControlModel::read(_rxInStream);
+
+ osl::MutexGuard aGuard(m_aMutex);
+ UINT16 nVersion = _rxInStream->readShort();
+ _rxInStream >> m_aControlSource;
+}
+
+//------------------------------------------------------------------------------
+void OBoundControlModel::getFastPropertyValue(staruno::Any& rValue, sal_Int32 nHandle) const
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_CONTROLSOURCEPROPERTY:
+ rValue <<= m_sDataFieldConnectivityProperty;
+ break;
+ case PROPERTY_ID_CONTROLSOURCE:
+ rValue <<= m_aControlSource;
+ break;
+ case PROPERTY_ID_BOUNDFIELD:
+ rValue <<= m_xField;
+ break;
+ case PROPERTY_ID_CONTROLLABEL:
+ if (!m_xLabelControl.is())
+ rValue.clear();
+ else
+ rValue <<= m_xLabelControl;
+ break;
+ default:
+ OControlModel::getFastPropertyValue(rValue, nHandle);
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OBoundControlModel::convertFastPropertyValue(
+ staruno::Any& _rConvertedValue, staruno::Any& _rOldValue,
+ sal_Int32 _nHandle,
+ const staruno::Any& _rValue)
+ throw (starlang::IllegalArgumentException)
+{
+ sal_Bool bModified(sal_False);
+ switch (_nHandle)
+ {
+ case PROPERTY_ID_CONTROLSOURCE:
+ bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_aControlSource);
+ break;
+ case PROPERTY_ID_BOUNDFIELD:
+ bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_xField);
+ break;
+ case PROPERTY_ID_CONTROLLABEL:
+ if (!_rValue.hasValue())
+ { // property set to void
+ _rConvertedValue = staruno::Any();
+ getFastPropertyValue(_rOldValue, _nHandle);
+ bModified = m_xLabelControl.is();
+ }
+ else
+ bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_xLabelControl);
+ break;
+ default:
+ bModified = OControlModel::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
+ }
+ return bModified;
+}
+
+//------------------------------------------------------------------------------
+void OBoundControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const staruno::Any& rValue ) throw (com::sun::star::uno::Exception)
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_CONTROLSOURCE:
+ DBG_ASSERT(rValue.getValueType().getTypeClass() == staruno::TypeClass_STRING, "invalid type" );
+ rValue >>= m_aControlSource;
+ break;
+ case PROPERTY_ID_BOUNDFIELD:
+ DBG_ERROR("OBoundControlModel::setFastPropertyValue_NoBroadcast : BoundField should be a read-only property !");
+ throw starlang::IllegalArgumentException();
+ break;
+ case PROPERTY_ID_CONTROLLABEL:
+ {
+ DBG_ASSERT(!rValue.hasValue() || (rValue.getValueType().getTypeClass() == staruno::TypeClass_INTERFACE),
+ "OBoundControlModel::setFastPropertyValue_NoBroadcast : invalid argument !");
+ if (!rValue.hasValue())
+ { // set property to "void"
+ staruno::Reference<starlang::XComponent> xComp(m_xLabelControl, staruno::UNO_QUERY);
+ if (xComp.is())
+ xComp->removeEventListener(static_cast<starlang::XEventListener*>(static_cast<starbeans::XPropertyChangeListener*>(this)));
+ m_xLabelControl = NULL;
+ break;
+ }
+
+ InterfaceRef xNewValue = *(InterfaceRef*)rValue.getValue();
+
+ staruno::Reference<starawt::XControlModel> xAsModel(xNewValue, staruno::UNO_QUERY);
+ staruno::Reference<starlang::XServiceInfo> xAsServiceInfo(xNewValue, staruno::UNO_QUERY);
+ staruno::Reference<starbeans::XPropertySet> xAsPropSet(xNewValue, staruno::UNO_QUERY);
+ staruno::Reference<starcontainer::XChild> xAsChild(xNewValue, staruno::UNO_QUERY);
+ if (!xAsModel.is() || !xAsServiceInfo.is() || !xAsPropSet.is() || !xAsChild.is())
+ {
+ throw starlang::IllegalArgumentException();
+ }
+
+ if (!xAsServiceInfo->supportsService(m_aLabelServiceName))
+ {
+ throw starlang::IllegalArgumentException();
+ }
+
+ // check if weself and the given model have a common anchestor (up to the forms collection)
+ staruno::Reference<starcontainer::XChild> xCont;
+ query_interface(static_cast<staruno::XWeak*>(this), xCont);
+ InterfaceRef xMyTopLevel = xCont->getParent();
+ while (xMyTopLevel.is())
+ {
+ staruno::Reference<starform::XForm> xAsForm(xMyTopLevel, staruno::UNO_QUERY);
+ if (!xAsForm.is())
+ // found my root
+ break;
+
+ staruno::Reference<starcontainer::XChild> xAsChild(xMyTopLevel, staruno::UNO_QUERY);
+ xMyTopLevel = xAsChild.is() ? xAsChild->getParent() : InterfaceRef();
+ }
+ InterfaceRef xNewTopLevel = xAsChild->getParent();
+ while (xNewTopLevel.is())
+ {
+ staruno::Reference<starform::XForm> xAsForm(xNewTopLevel, staruno::UNO_QUERY);
+ if (!xAsForm.is())
+ break;
+
+ staruno::Reference<starcontainer::XChild> xAsChild(xNewTopLevel, staruno::UNO_QUERY);
+ xNewTopLevel = xAsChild.is() ? xAsChild->getParent() : InterfaceRef();
+ }
+ if (xNewTopLevel != xMyTopLevel)
+ {
+ // the both objects don't belong to the same forms collection -> not acceptable
+ throw starlang::IllegalArgumentException();
+ }
+
+ m_xLabelControl = xAsPropSet;
+ staruno::Reference<starlang::XComponent> xComp(m_xLabelControl, staruno::UNO_QUERY);
+ if (xComp.is())
+ xComp->addEventListener(static_cast<starlang::XEventListener*>(static_cast<starbeans::XPropertyChangeListener*>(this)));
+ }
+ break;
+ default:
+ OControlModel::setFastPropertyValue_NoBroadcast(nHandle, rValue );
+ }
+}
+
+// XPropertyChangeListener
+//------------------------------------------------------------------------------
+void SAL_CALL OBoundControlModel::propertyChange( const starbeans::PropertyChangeEvent& evt ) throw(staruno::RuntimeException)
+{
+ // Bei Wertaenderung neu initialisieren
+ if (evt.PropertyName.equals(PROPERTY_VALUE))
+ {
+ osl::MutexGuard aGuard(m_aMutex);
+ if (m_bForwardValueChanges && m_xColumn.is())
+ _onValueChanged();
+ }
+}
+
+// XBoundComponent
+//------------------------------------------------------------------------------
+void SAL_CALL OBoundControlModel::addUpdateListener(const staruno::Reference<starform::XUpdateListener>& _rxListener) throw(staruno::RuntimeException)
+{
+ m_aUpdateListeners.addInterface(_rxListener);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OBoundControlModel::removeUpdateListener(const staruno::Reference< starform::XUpdateListener>& _rxListener) throw(staruno::RuntimeException)
+{
+ m_aUpdateListeners.removeInterface(_rxListener);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL OBoundControlModel::commit() throw(staruno::RuntimeException)
+{
+ DBG_ASSERT(m_bCommitable, "OBoundControlModel::commit : invalid call (I'm not commitable !) ");
+ {
+ osl::MutexGuard aGuard(m_aMutex);
+ if (!m_xField.is())
+ return sal_True;
+ }
+
+ cppu::OInterfaceIteratorHelper aIter(m_aUpdateListeners);
+ starlang::EventObject aEvt;
+ aEvt.Source = static_cast<staruno::XWeak*>(this);
+ sal_Bool bSucceed = sal_True;
+ while (aIter.hasMoreElements() && bSucceed)
+ bSucceed = ((starform::XUpdateListener*)aIter.next())->approveUpdate(aEvt);
+
+ if (bSucceed)
+ {
+ osl::MutexGuard aGuard(m_aMutex);
+ try
+ {
+ bSucceed = _commit();
+ }
+ catch(...)
+ {
+ bSucceed = sal_False;
+ }
+ }
+
+ if (bSucceed)
+ {
+ cppu::OInterfaceIteratorHelper aIter(m_aUpdateListeners);
+ while (aIter.hasMoreElements())
+ ((starform::XUpdateListener*)aIter.next())->updated(aEvt);
+ }
+
+ return bSucceed;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OBoundControlModel::connectToField(const staruno::Reference<starsdbc::XRowSet>& rForm)
+{
+ // wenn eine Verbindung zur Datenbank existiert
+ if (rForm.is() && getConnection(rForm).is())
+ {
+ // Feld bestimmen und PropertyChangeListener
+ m_xCursor = rForm;
+ staruno::Reference<starbeans::XPropertySet> xFieldCandidate;
+
+ if (m_xCursor.is())
+ {
+ staruno::Reference<starsdbcx::XColumnsSupplier> xColumnsSupplier(m_xCursor, staruno::UNO_QUERY);
+ DBG_ASSERT(xColumnsSupplier.is(), "OBoundControlModel::connectToField : the row set should support the com::sun::star::sdb::ResultSet service !");
+ if (xColumnsSupplier.is())
+ {
+ staruno::Reference<starcontainer::XNameAccess> xColumns(xColumnsSupplier->getColumns(), staruno::UNO_QUERY);
+ if (xColumns.is() && xColumns->hasByName(m_aControlSource))
+ {
+ staruno::Any aElement(xColumns->getByName(m_aControlSource));
+ DBG_ASSERT(xColumns->getElementType().equals(::getCppuType(reinterpret_cast<staruno::Reference<starbeans::XPropertySet>*>(NULL))),
+ "OBoundControlModel::connectToField : the columns container should contain XPropertySets !");
+ // if this assertion fails we probably should do a queryInterface ....
+ aElement >>= xFieldCandidate;
+ }
+ }
+ }
+
+ // darf ich mich ueberhaupt an dieses Feld binden (Typ-Check)
+ if (xFieldCandidate.is())
+ {
+ sal_Int32 nFieldType;
+ xFieldCandidate->getPropertyValue(PROPERTY_FIELDTYPE) >>= nFieldType;
+ if (_approve(nFieldType))
+ m_xField = xFieldCandidate;
+ }
+ else
+ m_xField = NULL;
+
+ if (m_xField.is())
+ {
+ if(m_xField->getPropertySetInfo()->hasPropertyByName(PROPERTY_VALUE))
+ {
+ // an wertaenderungen horchen
+ m_xField->addPropertyChangeListener(PROPERTY_VALUE, this);
+ m_xColumnUpdate = staruno::Reference<starsdb::XColumnUpdate>(m_xField, staruno::UNO_QUERY);
+ m_xColumn = staruno::Reference<starsdb::XColumn>(m_xField, staruno::UNO_QUERY);
+ INT32 nNullableFlag; m_xField->getPropertyValue(PROPERTY_ISNULLABLE) >>= nNullableFlag;
+ m_bRequired = (starsdbc::ColumnValue::NO_NULLS == nNullableFlag);
+ // we're optimistic : in case of ColumnValue_NULLABLE_UNKNOWN we assume nullability ....
+ }
+ else
+ {
+ OSL_ASSERT("OBoundControlModel::connectToField: property NAME not supported!");
+ m_xField = NULL;
+ }
+ }
+ }
+ return m_xField.is();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OBoundControlModel::_approve(sal_Int32 _nColumnType)
+{
+ if ((_nColumnType == starsdbc::DataType::BINARY) || (_nColumnType == starsdbc::DataType::VARBINARY)
+ || (_nColumnType == starsdbc::DataType::LONGVARBINARY) || (_nColumnType == starsdbc::DataType::OTHER)
+ || (_nColumnType == starsdbc::DataType::OBJECT) || (_nColumnType == starsdbc::DataType::DISTINCT)
+ || (_nColumnType == starsdbc::DataType::STRUCT) || (_nColumnType == starsdbc::DataType::ARRAY)
+ || (_nColumnType == starsdbc::DataType::BLOB) || (_nColumnType == starsdbc::DataType::CLOB)
+ || (_nColumnType == starsdbc::DataType::REF) || (_nColumnType == starsdbc::DataType::SQLNULL))
+ return sal_False;
+
+ return sal_True;
+}
+
+// XLoadListener
+//------------------------------------------------------------------------------
+void SAL_CALL OBoundControlModel::loaded(const starlang::EventObject& _rEvent) throw(staruno::RuntimeException)
+{
+ osl::MutexGuard aGuard(m_aMutex);
+ staruno::Reference<starsdbc::XRowSet> xForm(_rEvent.Source, staruno::UNO_QUERY);
+ connectToField(xForm);
+
+ m_bLoaded = sal_True;
+ _loaded(_rEvent);
+
+ if (m_xField.is())
+ _onValueChanged();
+}
+
+
+//------------------------------------------------------------------------------
+void SAL_CALL OBoundControlModel::unloaded( const starlang::EventObject& aEvent ) throw(staruno::RuntimeException)
+{
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OBoundControlModel::reloading( const starlang::EventObject& aEvent ) throw(staruno::RuntimeException)
+{
+ osl::MutexGuard aGuard(m_aMutex);
+ m_bForwardValueChanges = sal_False;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OBoundControlModel::unloading(const starlang::EventObject& aEvent) throw(staruno::RuntimeException)
+{
+ osl::MutexGuard aGuard(m_aMutex);
+ _unloaded();
+
+ if (m_xField.is())
+ {
+ m_xField->removePropertyChangeListener(PROPERTY_VALUE, this);
+ resetField();
+ }
+ m_xCursor = NULL;
+ m_bLoaded = sal_False;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OBoundControlModel::reloaded(const starlang::EventObject& aEvent) throw(staruno::RuntimeException)
+{
+ osl::MutexGuard aGuard(m_aMutex);
+ // did we lost the connection to the field because there was a new created?
+ if (!m_xField.is())
+ {
+ staruno::Reference<starsdbc::XRowSet> xForm(aEvent.Source, staruno::UNO_QUERY);
+ connectToField(xForm);
+ }
+
+ m_bForwardValueChanges = sal_True;
+
+ // do we have a field, than get the new value
+ if (m_xField.is())
+ _onValueChanged();
+}
+
+//------------------------------------------------------------------------------
+void OBoundControlModel::_loaded(const starlang::EventObject& rEvent)
+{
+}
+
+//------------------------------------------------------------------------------
+void OBoundControlModel::_unloaded()
+{
+}
+
+// XReset
+//-----------------------------------------------------------------------------
+void OBoundControlModel::_reset()
+{
+}
+
+//-----------------------------------------------------------------------------
+void OBoundControlModel::addResetListener(const staruno::Reference<starform::XResetListener>& l) throw (com::sun::star::uno::RuntimeException)
+{
+ m_aResetListeners.addInterface(l);
+}
+
+//-----------------------------------------------------------------------------
+void OBoundControlModel::removeResetListener(const staruno::Reference<starform::XResetListener>& l) throw (com::sun::star::uno::RuntimeException)
+{
+ m_aResetListeners.removeInterface(l);
+}
+
+//-----------------------------------------------------------------------------
+void OBoundControlModel::reset() throw (com::sun::star::uno::RuntimeException)
+{
+ cppu::OInterfaceIteratorHelper aIter(m_aResetListeners);
+ starlang::EventObject aResetEvent(static_cast<staruno::XWeak*>(this));
+ sal_Bool bContinue = sal_True;
+ while (aIter.hasMoreElements() && bContinue)
+ bContinue = reinterpret_cast<starform::XResetListener*>(aIter.next())->approveReset(aResetEvent);
+
+ if (!bContinue)
+ return;
+
+ osl::ClearableMutexGuard aGuard(m_aMutex);
+ m_bResetting = sal_True;
+
+ // gesondertes Verhalten bei Datenbankverbindung
+ if (m_xField.is())
+ {
+ // nur wenn der derzeitige Wert des Feldes auf NULL steht
+ // werden die Defaultwerte gesetzt
+ // ansonsten soll der aktuelle Werte nochmals aus dem Feld gesetzt werden
+ // dieses Verhalten ist noch nicht ganz ausgereift, was passiert wenn das Feld einen Defaultwert besitzt
+ // und das Control auch?
+
+ sal_Bool bIsNull = sal_True;
+ // we have to access the field content at least once to get a reliable result by XColumn::wasNull
+ try
+ {
+ m_xColumn->getString();
+ }
+ catch(...)
+ {
+ DBG_ERROR("OBoundControlModel::reset : XColumn::getString is expected to always succeed !");
+ }
+ bIsNull = m_xColumn->wasNull();
+
+ if (bIsNull)
+ {
+ staruno::Reference<starbeans::XPropertySet> xSet(m_xCursor, staruno::UNO_QUERY);
+ sal_Bool bIsNewRecord = sal_False;
+ if (xSet.is())
+ xSet->getPropertyValue(PROPERTY_ISNEW) >>= bIsNewRecord;
+ if (bIsNewRecord)
+ {
+ _reset(); // setzen der Werte,
+ _commit(); // uebertragen der Werte ins Feld
+ // fuer das zuruecksetzen des modifyflags ist das Formular zuständig
+ }
+ else
+ _onValueChanged();
+ }
+ else
+ _onValueChanged();
+ }
+ else
+ _reset();
+
+ m_bResetting = sal_False;
+ aGuard.clear();
+
+ cppu::OInterfaceIteratorHelper aIterDone(m_aResetListeners);
+ while (aIterDone.hasMoreElements())
+ reinterpret_cast<starform::XResetListener*>(aIterDone.next())->resetted(aResetEvent);
+}
+
+//.........................................................................
+}
+//... namespace frm .......................................................
+
diff --git a/forms/source/component/FormattedField.cxx b/forms/source/component/FormattedField.cxx
new file mode 100644
index 000000000000..dc3b1773714f
--- /dev/null
+++ b/forms/source/component/FormattedField.cxx
@@ -0,0 +1,1186 @@
+/*************************************************************************
+ *
+ * $RCSfile: FormattedField.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_FORMATTEDFIELD_HXX_
+#include "FormattedField.hxx"
+#endif
+#ifndef _FRM_SERVICES_HXX_
+#include "services.hxx"
+#endif
+#ifndef _FRM_PROPERTY_HRC_
+#include "property.hrc"
+#endif
+#ifndef _FRM_PROPERTY_HXX_
+#include "property.hxx"
+#endif
+
+#ifndef _UTL_SEQUENCE_HXX_
+#include <unotools/sequence.hxx>
+#endif
+#ifndef _UTL_NUMBERS_HXX_
+#include <unotools/numbers.hxx>
+#endif
+#ifndef _UNOTOOLS_DATETIME_HXX_
+#include <unotools/datetime.hxx>
+#endif
+#ifndef _UTL_UNO3_DB_TOOLS_HXX_
+#include <unotools/dbtools.hxx>
+#endif
+#ifndef _UTL_DB_CONVERSION_HXX_
+#include <unotools/dbconversion.hxx>
+#endif
+
+#ifndef _ZFORLIST_HXX //autogen
+#include <svtools/zforlist.hxx>
+#endif
+#ifndef _NUMUNO_HXX
+#include <svtools/numuno.hxx>
+#endif
+
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _TOOLS_VCLRSC_HXX
+#include <tools/vclrsc.hxx>
+#endif
+#ifndef _ISOLANG_HXX
+#include <tools/isolang.hxx>
+#endif
+#ifndef _RTL_TEXTENC_H
+#include <rtl/textenc.h>
+#endif
+
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_
+#include <com/sun/star/util/NumberFormat.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_MOUSEEVENT_HPP_
+#include <com/sun/star/awt/MouseEvent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XSUBMIT_HPP_
+#include <com/sun/star/form/XSubmit.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_
+#include <com/sun/star/awt/XWindow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XKEYLISTENER_HPP_
+#include <com/sun/star/awt/XKeyListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_FORMCOMPONENTTYPE_HPP_
+#include <com/sun/star/form/FormComponentType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTYPES_HPP_
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORM_HPP_
+#include <com/sun/star/form/XForm.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
+#include <com/sun/star/container/XIndexAccess.hpp>
+#endif
+
+#ifndef _VOS_MUTEX_HXX_
+#include <vos/mutex.hxx>
+#endif
+ // needed as long as we use the SolarMutex
+
+// temporary, 'til the base class of StandardFormatsSupplier is implemented with new UNO
+#if SUPD<583
+#ifndef _USR_SMARTCONV_HXX_
+#include <usr/smartconv.hxx>
+#endif
+#endif
+
+/** implements handling for compatibly reading/writing data from/into an input/output stream.
+ data written in a block secured by this class should be readable by older versions which
+ use the same mechanism.
+*/
+/*************************************************************************/
+
+class OMarkableStreamBlock
+{
+ staruno::Reference< stario::XMarkableStream > m_xMarkStream;
+ staruno::Reference< stario::XDataInputStream > m_xInStream;
+ staruno::Reference< stario::XDataOutputStream > m_xOutStream;
+
+ sal_Int32 m_nBlockStart;
+ sal_Int32 m_nBlockLen;
+
+public:
+ /** starts reading of a "skippable" block of data within the given input stream<BR>
+ The object given by _rxInput must support the XMarkableStream interface.
+ */
+ OMarkableStreamBlock(const staruno::Reference< stario::XDataInputStream >& _rxInput);
+ /** starts writing of a "skippable" block of data into the given output stream
+ The object given by _rxOutput must support the XMarkableStream interface.
+ */
+ OMarkableStreamBlock(const staruno::Reference< stario::XDataOutputStream >& _rxOutput);
+
+ ~OMarkableStreamBlock();
+};
+
+//-------------------------------------------------------------------------
+OMarkableStreamBlock::OMarkableStreamBlock(const staruno::Reference< stario::XDataInputStream >& _rxInput)
+ :m_xInStream(_rxInput)
+ ,m_xMarkStream(_rxInput, ::com::sun::star::uno::UNO_QUERY)
+ ,m_nBlockStart(-1)
+ ,m_nBlockLen(-1)
+{
+ DBG_ASSERT(m_xInStream.is() && m_xMarkStream.is(), "OMarkableStreamBlock::OMarkableStreamBlock : invaid argument !");
+ if (m_xInStream.is() && m_xMarkStream.is())
+ {
+ m_nBlockLen = _rxInput->readLong();
+ m_nBlockStart = m_xMarkStream->createMark();
+ }
+}
+
+//-------------------------------------------------------------------------
+OMarkableStreamBlock::OMarkableStreamBlock(const staruno::Reference< stario::XDataOutputStream >& _rxOutput)
+ :m_xOutStream(_rxOutput)
+ ,m_xMarkStream(_rxOutput, ::com::sun::star::uno::UNO_QUERY)
+ ,m_nBlockStart(-1)
+ ,m_nBlockLen(-1)
+{
+ DBG_ASSERT(m_xOutStream.is() && m_xMarkStream.is(), "OMarkableStreamBlock::OMarkableStreamBlock : invaid argument !");
+ if (m_xOutStream.is() && m_xMarkStream.is())
+ {
+ m_nBlockStart = m_xMarkStream->createMark();
+ // a placeholder where we will write the overall length (within the destructor)
+ m_nBlockLen = 0;
+ m_xOutStream->writeLong(m_nBlockLen);
+ }
+}
+
+//-------------------------------------------------------------------------
+OMarkableStreamBlock::~OMarkableStreamBlock()
+{
+ if (m_xInStream.is() && m_xMarkStream.is())
+ { // we're working on an input stream
+ m_xMarkStream->jumpToMark(m_nBlockStart);
+ m_xInStream->skipBytes(m_nBlockLen);
+ m_xMarkStream->deleteMark(m_nBlockStart);
+ }
+ else if (m_xOutStream.is() && m_xMarkStream.is())
+ {
+ m_nBlockLen = m_xMarkStream->offsetToMark(m_nBlockStart) - sizeof(m_nBlockLen);
+ m_xMarkStream->jumpToMark(m_nBlockStart);
+ m_xOutStream->writeLong(m_nBlockLen);
+ m_xMarkStream->jumpToFurthest();
+ m_xMarkStream->deleteMark(m_nBlockStart);
+ }
+}
+
+//.........................................................................
+namespace frm
+{
+
+/*************************************************************************/
+
+class StandardFormatsSupplier : protected SvNumberFormatsSupplierObj
+{
+protected:
+ SvNumberFormatter* m_pMyPrivateFormatter;
+
+public:
+ StandardFormatsSupplier();
+
+ operator staruno::Reference<starutil::XNumberFormatsSupplier> ();
+ SvNumberFormatsSupplierObj::operator new;
+ SvNumberFormatsSupplierObj::operator delete;
+
+protected:
+ ~StandardFormatsSupplier() { if (m_pMyPrivateFormatter) delete m_pMyPrivateFormatter; }
+};
+
+
+//------------------------------------------------------------------
+StandardFormatsSupplier::StandardFormatsSupplier()
+ :SvNumberFormatsSupplierObj()
+ ,m_pMyPrivateFormatter(new SvNumberFormatter(Application::GetAppInternational().GetLanguage()))
+{
+ SetNumberFormatter(m_pMyPrivateFormatter);
+}
+
+//------------------------------------------------------------------
+StandardFormatsSupplier::operator staruno::Reference<starutil::XNumberFormatsSupplier> ()
+{
+#if SUPD<583
+ // our base class is still implemented with old UNO
+ staruno::Any aOldUno;
+ XNumberFormatsSupplierRef xOldUnoRef = static_cast<XNumberFormatsSupplier*>(static_cast<SvNumberFormatsSupplierObj*>(this));
+ aOldUno.set(&xOldUnoRef, XNumberFormatsSupplier_getReflection());
+
+ staruno::Any aNewUno;
+ ::usr::convertUsr2UnoAny(aNewUno, aOldUno);
+ DBG_ASSERT(isAReference(aNewUno, static_cast<starutil::XNumberFormatsSupplier*>(NULL)),
+ "StandardFormatsSupplier::operator.... : unexpected conversion result !");
+
+ staruno::Reference<starutil::XNumberFormatsSupplier> xNewUnoRef;
+ if (isAReference(aNewUno, static_cast<starutil::XNumberFormatsSupplier*>(NULL)))
+ aNewUno >>= xNewUnoRef;
+
+ return xNewUnoRef;
+#endif
+
+ return static_cast<starutil::XNumberFormatsSupplier*>(static_cast<SvNumberFormatsSupplierObj*>(this));
+}
+
+//------------------------------------------------------------------
+staruno::Reference<starutil::XNumberFormatsSupplier> OFormattedModel::s_xDefaultFormatter;
+sal_Int32 OFormattedModel::nValueHandle = -1;
+
+/*************************************************************************/
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OFormattedControl_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new OFormattedControl(_rxFactory));
+}
+
+//------------------------------------------------------------------
+staruno::Sequence<staruno::Type> OFormattedControl::_getTypes()
+{
+ static staruno::Sequence<staruno::Type> aTypes;
+ if (!aTypes.getLength())
+ {
+ // my two base classes
+ staruno::Sequence<staruno::Type> aBaseClassTypes = OBoundControl::_getTypes();
+
+ staruno::Sequence<staruno::Type> aOwnTypes(1);
+ staruno::Type* pOwnTypes = aOwnTypes.getArray();
+ pOwnTypes[0] = getCppuType((staruno::Reference<starawt::XKeyListener>*)NULL);
+
+ aTypes = concatSequences(aBaseClassTypes, aOwnTypes);
+ }
+ return aTypes;
+}
+
+//------------------------------------------------------------------
+staruno::Any SAL_CALL OFormattedControl::queryAggregation(const staruno::Type& _rType) throw (staruno::RuntimeException)
+{
+ staruno::Any aReturn;
+
+ aReturn = OBoundControl::queryAggregation(_rType);
+ if (!aReturn.hasValue())
+ aReturn = ::cppu::queryInterface(_rType
+ ,static_cast<starawt::XKeyListener*>(this)
+ );
+
+ return aReturn;
+}
+
+
+DBG_NAME(OFormattedControl);
+//------------------------------------------------------------------------------
+OFormattedControl::OFormattedControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OBoundControl(_rxFactory, VCL_CONTROL_FORMATTEDFIELD)
+ ,m_nKeyEvent(0)
+{
+ DBG_CTOR(OFormattedControl,NULL);
+
+ increment(m_refCount);
+ { // als FocusListener anmelden
+ staruno::Reference<starawt::XWindow> xComp;
+ if (query_aggregation(m_xAggregate, xComp))
+ {
+ xComp->addKeyListener(this);
+ }
+ }
+ // Refcount wieder bei 1 fuer den Listener
+ sal_Int32 n = decrement(m_refCount);
+}
+
+//------------------------------------------------------------------------------
+OFormattedControl::~OFormattedControl()
+{
+ if( m_nKeyEvent )
+ Application::RemoveUserEvent( m_nKeyEvent );
+
+ if (!OComponentHelper::rBHelper.bDisposed)
+ {
+ acquire();
+ dispose();
+ }
+
+ DBG_DTOR(OFormattedControl,NULL);
+}
+
+// starawt::XKeyListener
+//------------------------------------------------------------------------------
+void OFormattedControl::disposing(const starlang::EventObject& _rSource) throw(staruno::RuntimeException)
+{
+ OBoundControl::disposing(_rSource);
+}
+
+//------------------------------------------------------------------------------
+void OFormattedControl::keyPressed(const starawt::KeyEvent& e)
+{
+ if( e.KeyCode != KEY_RETURN || e.Modifiers != 0 )
+ return;
+
+ // Steht das Control in einem Formular mit einer Submit-URL?
+ staruno::Reference<starbeans::XPropertySet> xSet(getModel(), staruno::UNO_QUERY);
+ if( !xSet.is() )
+ return;
+
+ staruno::Reference<starform::XFormComponent> xFComp(xSet, staruno::UNO_QUERY);
+ InterfaceRef xParent = xFComp->getParent();
+ if( !xParent.is() )
+ return;
+
+ staruno::Reference<starbeans::XPropertySet> xFormSet(xParent, staruno::UNO_QUERY);
+ if( !xFormSet.is() )
+ return;
+
+ staruno::Any aTmp(xFormSet->getPropertyValue( PROPERTY_TARGET_URL ));
+ if (!isA(aTmp, static_cast< ::rtl::OUString* >(NULL)) ||
+ !getString(aTmp).getLength() )
+ return;
+
+ staruno::Reference<starcontainer::XIndexAccess> xElements(xParent, staruno::UNO_QUERY);
+ sal_Int32 nCount = xElements->getCount();
+ if( nCount > 1 )
+ {
+ for( sal_Int32 nIndex=0; nIndex < nCount; nIndex++ )
+ {
+ // staruno::Any aElement(xElements->getByIndex(nIndex));
+ staruno::Reference<starbeans::XPropertySet> xFCSet(*(InterfaceRef *)xElements->getByIndex(nIndex).getValue(), staruno::UNO_QUERY);
+
+ if (hasProperty(PROPERTY_CLASSID, xFCSet) &&
+ getINT16(xFCSet->getPropertyValue(PROPERTY_CLASSID)) == starform::FormComponentType::TEXTFIELD)
+ {
+ // Noch ein weiteres Edit gefunden ==> dann nicht submitten
+ if (xFCSet != xSet)
+ return;
+ }
+ }
+ }
+
+ // Da wir noch im Haender stehen, submit asynchron ausloesen
+ if( m_nKeyEvent )
+ Application::RemoveUserEvent( m_nKeyEvent );
+ m_nKeyEvent = Application::PostUserEvent( LINK(this, OFormattedControl,
+ OnKeyPressed) );
+}
+
+//------------------------------------------------------------------------------
+void OFormattedControl::keyReleased(const starawt::KeyEvent& e)
+{
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(OFormattedControl, OnKeyPressed, void*, EMPTYARG)
+{
+ m_nKeyEvent = 0;
+
+ staruno::Reference<starform::XFormComponent> xFComp(getModel(), staruno::UNO_QUERY);
+ InterfaceRef xParent = xFComp->getParent();
+ staruno::Reference<starform::XSubmit> xSubmit(xParent, staruno::UNO_QUERY);
+ if (xSubmit.is())
+ xSubmit->submit( staruno::Reference<starawt::XControl> (), starawt::MouseEvent() );
+ return 0L;
+}
+
+//------------------------------------------------------------------------------
+StringSequence OFormattedControl::getSupportedServiceNames() throw()
+{
+ StringSequence aSupported = OBoundControl::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 1);
+
+ ::rtl::OUString*pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_FORMATTEDFIELD;
+ return aSupported;
+}
+
+//------------------------------------------------------------------------------
+void OFormattedControl::setDesignMode(sal_Bool bOn)
+{
+ OBoundControl::setDesignMode(bOn);
+}
+
+/*************************************************************************/
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OFormattedModel_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new OFormattedModel(_rxFactory));
+}
+
+//------------------------------------------------------------------
+OFormattedModel::OFormattedModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OEditBaseModel(_rxFactory, VCL_CONTROLMODEL_FORMATTEDFIELD, FRM_CONTROL_FORMATTEDFIELD )
+ // use the old control name for compytibility reasons
+ ,OPropertyChangeListener(m_aMutex)
+ ,m_bOriginalNumeric(sal_False)
+ ,m_bNumeric(sal_False)
+ ,m_xOriginalFormatter(NULL)
+ ,m_aNullDate(STANDARD_DB_DATE)
+ ,m_nKeyType(starutil::NumberFormat::UNDEFINED)
+{
+ m_nClassId = starform::FormComponentType::TEXTFIELD;
+
+ increment(m_refCount);
+ setPropertyToDefaultByHandle(PROPERTY_ID_FORMATSSUPPLIER);
+ decrement(m_refCount);
+
+ m_sDataFieldConnectivityProperty = PROPERTY_EFFECTIVE_VALUE;
+ if (OFormattedModel::nValueHandle == -1)
+ OFormattedModel::nValueHandle = getOriginalHandle(PROPERTY_ID_EFFECTIVE_VALUE);
+
+ increment(m_refCount);
+ if (m_xAggregateSet.is())
+ {
+ OPropertyChangeMultiplexer* pMultiplexer = new OPropertyChangeMultiplexer(this, m_xAggregateSet);
+ pMultiplexer->addProperty(PROPERTY_FORMATKEY);
+ }
+ decrement(m_refCount);
+}
+
+// starlang::XServiceInfo
+//------------------------------------------------------------------------------
+StringSequence OFormattedModel::getSupportedServiceNames() throw()
+{
+ StringSequence aSupported = OEditBaseModel::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 2);
+
+ ::rtl::OUString*pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-2] = ::rtl::OUString::createFromAscii("com.sun.star.form.component.DatabaseFormattedField");
+ pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_FORMATTEDFIELD;
+ return aSupported;
+}
+
+// stario::XPersistObject
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OFormattedModel::getServiceName()
+{
+ return ::rtl::OUString(FRM_COMPONENT_EDIT);
+// return ::rtl::OUString(FRM_COMPONENT_FORMATTEDFIELD); // old (non-sun) name for compatibility !
+}
+
+// starbeans::XPropertySet
+//------------------------------------------------------------------------------
+staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL OFormattedModel::getPropertySetInfo() throw(staruno::RuntimeException)
+{
+ staruno::Reference<starbeans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OFormattedModel::getInfoHelper()
+{
+ return *const_cast<OFormattedModel*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+void OFormattedModel::fillProperties(
+ staruno::Sequence< starbeans::Property >& _rProps,
+ staruno::Sequence< starbeans::Property >& _rAggregateProps ) const
+{
+ FRM_BEGIN_PROP_HELPER(11)
+
+ DECL_PROP1(NAME, ::rtl::OUString, BOUND);
+ DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT);
+ DECL_BOOL_PROP1(EMPTY_IS_NULL, BOUND);
+ DECL_PROP1(TAG, ::rtl::OUString, BOUND);
+ DECL_PROP1(TABINDEX, sal_Int16, BOUND);
+ DECL_PROP1(CONTROLSOURCE, ::rtl::OUString, BOUND);
+ DECL_PROP1(HELPTEXT, ::rtl::OUString, BOUND);
+ DECL_IFACE_PROP2(BOUNDFIELD, starbeans::XPropertySet,READONLY, TRANSIENT);
+ DECL_BOOL_PROP2(FILTERPROPOSAL, BOUND, MAYBEDEFAULT);
+ DECL_IFACE_PROP2(CONTROLLABEL, starbeans::XPropertySet,BOUND, MAYBEVOID);
+ DECL_PROP2(CONTROLSOURCEPROPERTY, rtl::OUString, READONLY, TRANSIENT);
+
+ // den Value auf transient, damit das Dokument waehrend der Eingabe nicht als modifiziert gilt ....
+ // (und da der selbstverstaendlich nicht gespeichert werden muss)
+// ModifyPropertyAttributes(_rAggregateProps, PROPERTY_EFFECTIVE_VALUE, starbeans::PropertyAttribute::TRANSIENT, 0);
+ // der Supplier ist fuer uns nur read-only
+ ModifyPropertyAttributes(_rAggregateProps, PROPERTY_FORMATSSUPPLIER, starbeans::PropertyAttribute::READONLY, 0);
+ // TreatAsNumeric nicht transient : wir wollen es an der UI anbinden (ist noetig, um dem EffectiveDefault
+ // - der kann Text oder Zahl sein - einen Sinn zu geben)
+ ModifyPropertyAttributes(_rAggregateProps, PROPERTY_TREATASNUMERIC, 0, starbeans::PropertyAttribute::TRANSIENT);
+
+ FRM_END_PROP_HELPER();
+}
+
+//------------------------------------------------------------------------------
+void OFormattedModel::getFastPropertyValue(staruno::Any& rValue, sal_Int32 nHandle) const
+{
+ OEditBaseModel::getFastPropertyValue(rValue, nHandle);
+}
+
+//------------------------------------------------------------------------------
+void OFormattedModel::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const staruno::Any& rValue)
+{
+ OEditBaseModel::setFastPropertyValue_NoBroadcast(nHandle, rValue);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OFormattedModel::convertFastPropertyValue(staruno::Any& rConvertedValue, staruno::Any& rOldValue, sal_Int32 nHandle, const staruno::Any& rValue)
+ throw( starlang::IllegalArgumentException )
+{
+ return OEditBaseModel::convertFastPropertyValue(rConvertedValue, rOldValue, nHandle, rValue);
+}
+
+//------------------------------------------------------------------------------
+void OFormattedModel::setPropertyToDefaultByHandle(sal_Int32 nHandle)
+{
+ if (nHandle == PROPERTY_ID_FORMATSSUPPLIER)
+ { // das aggregierte Model koennte auf die Idee kommen
+ staruno::Reference<starutil::XNumberFormatsSupplier> xSupplier = calcDefaultFormatsSupplier();
+ DBG_ASSERT(m_xAggregateSet.is(), "OFormattedModel::setPropertyToDefaultByHandle(FORMATSSUPPLIER) : have no aggregate !");
+ if (m_xAggregateSet.is())
+ m_xAggregateSet->setPropertyValue(PROPERTY_FORMATSSUPPLIER, staruno::makeAny(xSupplier));
+ }
+ else
+ OEditBaseModel::setPropertyToDefaultByHandle(nHandle);
+}
+
+//------------------------------------------------------------------------------
+void OFormattedModel::setPropertyToDefault(const ::rtl::OUString& aPropertyName) throw( starbeans::UnknownPropertyException, staruno::RuntimeException )
+{
+ OPropertyArrayAggregationHelper& rPH = (OPropertyArrayAggregationHelper&)getInfoHelper();
+ sal_Int32 nHandle = rPH.getHandleByName( aPropertyName );
+
+ if (nHandle == PROPERTY_ID_FORMATSSUPPLIER)
+ setPropertyToDefaultByHandle(PROPERTY_ID_FORMATSSUPPLIER);
+ else
+ OEditBaseModel::setPropertyToDefault(aPropertyName);
+}
+
+//------------------------------------------------------------------------------
+staruno::Any OFormattedModel::getPropertyDefaultByHandle( sal_Int32 nHandle ) const
+{
+ if (nHandle == PROPERTY_ID_FORMATSSUPPLIER)
+ {
+ staruno::Reference<starutil::XNumberFormatsSupplier> xSupplier = calcFormFormatsSupplier();
+ return staruno::makeAny(xSupplier);
+ }
+ else
+ return OEditBaseModel::getPropertyDefaultByHandle(nHandle);
+}
+
+//------------------------------------------------------------------------------
+staruno::Any SAL_CALL OFormattedModel::getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw( starbeans::UnknownPropertyException, staruno::RuntimeException )
+{
+ OPropertyArrayAggregationHelper& rPH = (OPropertyArrayAggregationHelper&)getInfoHelper();
+ sal_Int32 nHandle = rPH.getHandleByName( aPropertyName );
+
+ if (nHandle == PROPERTY_ID_FORMATSSUPPLIER)
+ return getPropertyDefaultByHandle(PROPERTY_ID_FORMATSSUPPLIER);
+ else
+ return OEditBaseModel::getPropertyDefault(aPropertyName);
+}
+
+//------------------------------------------------------------------------------
+void OFormattedModel::_propertyChanged( const starbeans::PropertyChangeEvent& evt ) throw(staruno::RuntimeException)
+{
+ if (evt.Source == m_xAggregate)
+ {
+ if (evt.PropertyName.equals(PROPERTY_FORMATKEY))
+ {
+ if (evt.NewValue.getValueType().getTypeClass() == staruno::TypeClass_LONG)
+ {
+ try
+ {
+ staruno::Reference<starutil::XNumberFormatsSupplier> xSupplier(calcFormatsSupplier());
+ m_nKeyType = getNumberFormatType(xSupplier->getNumberFormats(), getINT32(evt.NewValue));
+ // as m_aSaveValue (which is used by _commit) is format dependent we have
+ // to recalc it, which is done by _onValueChanged
+ if (m_xColumn.is() && m_xAggregateFastSet.is())
+ {
+ ::osl::MutexGuard aGuard(m_aMutex); // _onValueChanged expects that ...
+ _onValueChanged();
+ }
+ }
+ catch(...)
+ {
+ }
+ }
+ }
+ // our base class does not listen at the aggregate at the moment ... and it does not expect
+ // to get events from objects other than the field we're bound to. So do not call the
+ // base class method here.
+ return;
+ }
+}
+
+//------------------------------------------------------------------------------
+staruno::Reference<starutil::XNumberFormatsSupplier> OFormattedModel::calcFormatsSupplier() const
+{
+ staruno::Reference<starutil::XNumberFormatsSupplier> xSupplier;
+
+ DBG_ASSERT(m_xAggregateSet.is(), "OFormattedModel::calcFormatsSupplier : have no aggregate !");
+ // hat mein aggregiertes Model einen FormatSupplier ?
+ staruno::Any aSupplier( m_xAggregateSet.is() ? m_xAggregateSet->getPropertyValue(PROPERTY_FORMATSSUPPLIER) : staruno::Any());
+ if (aSupplier.hasValue())
+ xSupplier = *(staruno::Reference<starutil::XNumberFormatsSupplier> *)aSupplier.getValue();
+
+ if (!xSupplier.is())
+ // testen, ob meine Parent-starform einen Formatter hat
+ xSupplier = calcFormFormatsSupplier();
+
+ if (!xSupplier.is())
+ xSupplier = calcDefaultFormatsSupplier();
+
+ DBG_ASSERT(xSupplier.is(), "OFormattedModel::calcFormatsSupplier : no supplier !");
+ // jetzt sollte aber einer da sein
+ return xSupplier;
+}
+
+//------------------------------------------------------------------------------
+staruno::Reference<starutil::XNumberFormatsSupplier> OFormattedModel::calcFormFormatsSupplier() const
+{
+ staruno::Reference<starcontainer::XChild> xMe;
+ query_interface(static_cast<staruno::XWeak*>(const_cast<OFormattedModel*>(this)), xMe);
+ // damit stellen wir sicher, dass wir auch fuer den Fall der Aggregation das richtige
+ // Objekt bekommen
+ DBG_ASSERT(xMe.is(), "OFormattedModel::calcFormFormatsSupplier : I should have a content interface !");
+
+ // jetzt durchhangeln nach oben, bis wir auf eine starform treffen (angefangen mit meinem eigenen Parent)
+ staruno::Reference<starcontainer::XChild> xParent(xMe->getParent(), staruno::UNO_QUERY);
+ staruno::Reference<starform::XForm> xNextParentForm(xParent, staruno::UNO_QUERY);
+ while (!xNextParentForm.is() && xParent.is())
+ {
+ xParent = staruno::Reference<starcontainer::XChild> (xParent->getParent(), staruno::UNO_QUERY);
+ xNextParentForm = staruno::Reference<starform::XForm> (xParent, staruno::UNO_QUERY);
+ }
+
+ if (!xNextParentForm.is())
+ {
+ DBG_ERROR("OFormattedModel::calcFormFormatsSupplier : have no ancestor which is a form !");
+ return NULL;
+ }
+
+ // den FormatSupplier von meinem Vorfahren (falls der einen hat)
+ staruno::Reference<starsdbc::XRowSet> xRowSet(xNextParentForm, staruno::UNO_QUERY);
+ staruno::Reference<starutil::XNumberFormatsSupplier> xSupplier;
+ if (xRowSet.is())
+ xSupplier = getNumberFormats(getConnection(xRowSet), sal_True, m_xServiceFactory);
+ return xSupplier;
+}
+
+//------------------------------------------------------------------------------
+staruno::Reference<starutil::XNumberFormatsSupplier> OFormattedModel::calcDefaultFormatsSupplier() const
+{
+ if (!s_xDefaultFormatter.is())
+ s_xDefaultFormatter = *new StandardFormatsSupplier;
+ return s_xDefaultFormatter;
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 OFormattedModel::calcFormatKey() const
+{
+ DBG_ASSERT(m_xAggregateSet.is(), "OFormattedModel::calcFormatKey : have no aggregate !");
+ // hat mein aggregiertes Model einen FormatSupplier ?
+ staruno::Any aFormatKey = m_xAggregateSet.is() ? m_xAggregateSet->getPropertyValue(PROPERTY_FORMATKEY): staruno::Any();
+ if (aFormatKey.hasValue())
+ return getINT32(aFormatKey);
+
+ if (m_xField.is())
+ return getINT32(m_xField->getPropertyValue(PROPERTY_FORMATKEY));
+
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+void OFormattedModel::getFormatDescription(::rtl::OUString& sFormat, LanguageType& eLanguage)
+{
+}
+
+// starform::XBoundComponent
+//------------------------------------------------------------------------------
+void OFormattedModel::loaded(const starlang::EventObject& rEvent)
+{
+ // HACK : our _loaded accesses our NumberFormatter which locks the solar mutex (as it doesn't have
+ // an own one). To prevent deadlocks with other threads which may request a property from us in an
+ // UI-triggered action (e.g. an tooltip) we lock the solar mutex _here_ before our base class locks
+ // it's own muext (which is used for property requests)
+ // alternative a): we use two mutexes, one which is passed to the OPropertysetHelper and used for
+ // property requests and one for our own code. This would need a lot of code rewriting
+ // alternative b): The NumberFormatter has to be really threadsafe (with an own mutex), which is
+ // the only "clean" solution for me.
+ // FS - 69603 - 02.11.99
+
+ ::vos::OGuard aGuard(Application::GetSolarMutex());
+ OEditBaseModel::loaded(rEvent);
+}
+
+//------------------------------------------------------------------------------
+void OFormattedModel::_loaded(const starlang::EventObject& rEvent)
+{
+ static const ::rtl::OUString s_aNullDataProp = ::rtl::OUString::createFromAscii("NullDate");
+
+ m_xOriginalFormatter = NULL;
+
+ DBG_ASSERT(m_xAggregateSet.is(), "OFormattedModel::_loaded : have no aggregate !");
+ if (m_xAggregateSet.is())
+ { // all the following doesn't make any sense if we have no aggregate ...
+ staruno::Any aSupplier = m_xAggregateSet->getPropertyValue(PROPERTY_FORMATSSUPPLIER);
+ DBG_ASSERT(((staruno::Reference<starutil::XNumberFormatsSupplier> *)aSupplier.getValue())->is(), "OFormattedModel::_loaded : invalid property value !");
+ // das sollte im Constructor oder im read auf was richtiges gesetzt worden sein
+
+ staruno::Any aFmtKey = m_xAggregateSet->getPropertyValue(PROPERTY_FORMATKEY);
+ if (!aFmtKey.hasValue())
+ { // unser aggregiertes Model hat noch keine Format-Informationen, also geben wir die von dem Feld, an das
+ // wir gebunden sind, weiter
+ sal_Int32 nType = starsdbc::DataType::VARCHAR;
+ if (m_xField.is())
+ {
+ aFmtKey = m_xField->getPropertyValue(PROPERTY_FORMATKEY);
+ m_xField->getPropertyValue(PROPERTY_FIELDTYPE) >>= nType ;
+ }
+
+ staruno::Reference<starutil::XNumberFormatsSupplier> xSupplier = calcFormFormatsSupplier();
+ DBG_ASSERT(xSupplier.is(), "OFormattedModel::_loaded : bound to a field but no parent with a formatter ? how this ?");
+ if (xSupplier.is())
+ {
+ if (!aFmtKey.hasValue())
+ { // we aren't bound to a field (or this field's format is invalid)
+ // -> determine the standard text format of the supplier
+ staruno::Reference<starutil::XNumberFormatTypes> xTypes(xSupplier->getNumberFormats(), staruno::UNO_QUERY);
+ if (xTypes.is())
+ {
+ UniString sLanguage, sCountry;
+ ConvertLanguageToIsoNames(Application::GetAppInternational().GetLanguage(), sLanguage, sCountry);
+ starlang::Locale aNewLanguage(
+ sLanguage,
+ sCountry,
+ ::rtl::OUString());
+ }
+ }
+
+ m_xAggregateSet->setPropertyValue(PROPERTY_FORMATSSUPPLIER, staruno::makeAny(xSupplier));
+ m_xAggregateSet->setPropertyValue(PROPERTY_FORMATKEY, aFmtKey);
+ m_xOriginalFormatter = *(staruno::Reference<starutil::XNumberFormatsSupplier> *)aSupplier.getValue();
+
+ // das Numeric-Flag an mein gebundenes Feld anpassen
+ m_bNumeric = sal_False;
+ switch (nType)
+ {
+ case starsdbc::DataType::BIT:
+ case starsdbc::DataType::TINYINT:
+ case starsdbc::DataType::SMALLINT:
+ case starsdbc::DataType::INTEGER:
+ case starsdbc::DataType::BIGINT:
+ case starsdbc::DataType::FLOAT:
+ case starsdbc::DataType::REAL:
+ case starsdbc::DataType::DOUBLE:
+ case starsdbc::DataType::NUMERIC:
+ case starsdbc::DataType::DECIMAL:
+ case starsdbc::DataType::DATE:
+ case starsdbc::DataType::TIME:
+ case starsdbc::DataType::TIMESTAMP:
+ m_bNumeric = sal_True;
+ break;
+ }
+ m_bOriginalNumeric = getBOOL(getPropertyValue(PROPERTY_TREATASNUMERIC));
+ setPropertyValue(PROPERTY_TREATASNUMERIC, staruno::makeAny((sal_Bool)m_bNumeric));
+
+ m_nKeyType = getNumberFormatType(xSupplier->getNumberFormats(), getINT32(aFmtKey));
+ typeConvert(*(starutil::Date*)xSupplier->getNumberFormatSettings()->getPropertyValue(s_aNullDataProp).getValue(),
+ m_aNullDate);
+ }
+ }
+ else
+ {
+ staruno::Reference<starutil::XNumberFormatsSupplier> xSupplier = calcFormatsSupplier();
+
+ m_bNumeric = getBOOL(getPropertyValue(PROPERTY_TREATASNUMERIC));
+ m_nKeyType = getNumberFormatType(xSupplier->getNumberFormats(), getINT32(aFmtKey));
+ typeConvert(*(starutil::Date*)xSupplier->getNumberFormatSettings()->getPropertyValue(s_aNullDataProp).getValue(),
+ m_aNullDate);
+ }
+ }
+ else
+ { // try to get some defaults ...
+ staruno::Reference<starutil::XNumberFormatsSupplier> xSupplier = calcFormatsSupplier();
+
+ m_bNumeric = getBOOL(getPropertyValue(PROPERTY_TREATASNUMERIC));
+ m_nKeyType = getNumberFormatType(xSupplier->getNumberFormats(), 0);
+ typeConvert(*(starutil::Date*)xSupplier->getNumberFormatSettings()->getPropertyValue(s_aNullDataProp).getValue(),
+ m_aNullDate);
+ }
+
+ OEditBaseModel::_loaded(rEvent);
+}
+
+//------------------------------------------------------------------------------
+void OFormattedModel::_unloaded()
+{
+ OEditBaseModel::_unloaded();
+ if (m_xOriginalFormatter.is())
+ { // unser aggregiertes Model hatte keinerlei Format-Informationen
+ m_xAggregateSet->setPropertyValue(PROPERTY_FORMATSSUPPLIER, staruno::makeAny(m_xOriginalFormatter));
+ m_xAggregateSet->setPropertyValue(PROPERTY_FORMATKEY, staruno::Any());
+ setPropertyValue(PROPERTY_TREATASNUMERIC, staruno::makeAny((sal_Bool)m_bOriginalNumeric));
+ m_xOriginalFormatter = NULL;
+ }
+
+ m_nKeyType = starutil::NumberFormat::UNDEFINED;
+ m_aNullDate = STANDARD_DB_DATE;
+}
+
+//------------------------------------------------------------------------------
+void OFormattedModel::write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream)
+{
+ OEditBaseModel::write(_rxOutStream);
+ _rxOutStream->writeShort(0x0003);
+
+ DBG_ASSERT(m_xAggregateSet.is(), "OFormattedModel::write : have no aggregate !");
+
+ // mein Format (evtl. void) in ein persistentes Format bringen (der Supplier zusammen mit dem Key ist es zwar auch,
+ // aber deswegen muessen wir ja nicht gleich den ganzen Supplier speichern, das waere ein klein wenig Overhead ;)
+
+ staruno::Reference<starutil::XNumberFormatsSupplier> xSupplier;
+ staruno::Any aFmtKey;
+ sal_Bool bVoidKey = sal_True;
+ if (m_xAggregateSet.is())
+ {
+ staruno::Any aSupplier = m_xAggregateSet->getPropertyValue(PROPERTY_FORMATSSUPPLIER);
+ if (aSupplier.getValueType().getTypeClass() != staruno::TypeClass_VOID)
+ {
+ DBG_ASSERT(isAReference(aSupplier, static_cast<starutil::XNumberFormatsSupplier*>(NULL)),
+ "OFormattedModel::write : invalid formats supplier !");
+ xSupplier = *(staruno::Reference<starutil::XNumberFormatsSupplier> *)aSupplier.getValue();
+ }
+
+ aFmtKey = m_xAggregateSet->getPropertyValue(PROPERTY_FORMATKEY);
+ bVoidKey = (!xSupplier.is() || !aFmtKey.hasValue()) || (m_bLoaded && m_xOriginalFormatter.is());
+ // (kein Fomatter und/oder Key) oder (loaded und faked Formatter)
+ }
+
+ _rxOutStream->writeBoolean(!bVoidKey);
+ if (!bVoidKey)
+ {
+ // aus dem FormatKey und dem Formatter persistente Angaben basteln
+
+ staruno::Any aKey = m_xAggregateSet->getPropertyValue(PROPERTY_FORMATKEY);
+ sal_Int32 nKey = aKey.hasValue() ? getINT32(aKey) : 0;
+
+ staruno::Reference<starutil::XNumberFormats> xFormats = xSupplier->getNumberFormats();
+
+ ::rtl::OUString sFormatDescription;
+ LanguageType eFormatLanguage = LANGUAGE_DONTKNOW;
+
+ static const ::rtl::OUString s_aLocaleProp = ::rtl::OUString::createFromAscii("Locale");
+ staruno::Reference<starbeans::XPropertySet> xFormat = xFormats->getByKey(nKey);
+ if (hasProperty(s_aLocaleProp, xFormat))
+ {
+ staruno::Any aLocale = xFormat->getPropertyValue(s_aLocaleProp);
+ DBG_ASSERT(isA(aLocale, static_cast<starlang::Locale*>(NULL)), "OFormattedModel::write : invalid language property !");
+ if (isA(aLocale, static_cast<starlang::Locale*>(NULL)))
+ {
+ starlang::Locale* pLocale = (starlang::Locale*)aLocale.getValue();
+ eFormatLanguage = ConvertIsoNamesToLanguage(
+ ::rtl::OUStringToOString(pLocale->Language, RTL_TEXTENCODING_ASCII_US).getStr(),
+ ::rtl::OUStringToOString(pLocale->Country, RTL_TEXTENCODING_ASCII_US).getStr()
+ );
+ }
+ }
+
+ static const ::rtl::OUString s_aFormatStringProp = ::rtl::OUString::createFromAscii("FormatString");
+ if (hasProperty(s_aFormatStringProp, xFormat))
+ xFormat->getPropertyValue(s_aFormatStringProp) >>= sFormatDescription;
+
+ _rxOutStream->writeUTF(sFormatDescription);
+ _rxOutStream->writeLong((sal_Int32)eFormatLanguage);
+ }
+
+ // version 2 : write the properties common to all OEditBaseModels
+ writeCommonEditProperties(_rxOutStream);
+
+ // version 3 : write the effective value property of the aggregate
+ // Due to a bug within the UnoControlFormattedFieldModel implementation (our default aggregate) this props value isn't correctly read
+ // and this can't be corrected without being incompatible.
+ // so we have our own handling.
+
+ // and to be a little bit more compatible we make the following section skippable
+ {
+ staruno::Reference< stario::XDataOutputStream > xOut(_rxOutStream, staruno::UNO_QUERY);
+ OMarkableStreamBlock aDownCompat(xOut);
+
+ // a sub version within the skippable block
+ _rxOutStream->writeShort(0x0000);
+
+ // version 0: the effective value of the aggregate
+ staruno::Any aEffectiveValue;
+ if (m_xAggregateSet.is())
+ {
+ try { aEffectiveValue = m_xAggregateSet->getPropertyValue(PROPERTY_EFFECTIVE_VALUE); } catch(...) { }
+ }
+
+ {
+ OMarkableStreamBlock aDownCompat2(xOut);
+ switch (aEffectiveValue.getValueType().getTypeClass())
+ {
+ case staruno::TypeClass_STRING:
+ _rxOutStream->writeShort(0x0000);
+ _rxOutStream->writeUTF(::utl::getString(aEffectiveValue));
+ break;
+ case staruno::TypeClass_DOUBLE:
+ _rxOutStream->writeShort(0x0001);
+ _rxOutStream->writeDouble(::utl::getDouble(aEffectiveValue));
+ break;
+ default: // void and all unknown states
+ DBG_ASSERT(!aEffectiveValue.hasValue(), "FmXFormattedModel::write : unknown property value type !");
+ _rxOutStream->writeShort(0x0002);
+ break;
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void OFormattedModel::read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream)
+{
+ OEditBaseModel::read(_rxInStream);
+ sal_uInt16 nVersion = _rxInStream->readShort();
+
+ staruno::Reference<starutil::XNumberFormatsSupplier> xSupplier;
+ sal_Int32 nKey = -1;
+ switch (nVersion)
+ {
+ case 0x0001 :
+ case 0x0002 :
+ case 0x0003 :
+ {
+ sal_Bool bNonVoidKey = _rxInStream->readBoolean();
+ if (bNonVoidKey)
+ {
+ // den String und die starutil::Language lesen ....
+ ::rtl::OUString sFormatDescription = _rxInStream->readUTF();
+ LanguageType eDescriptionLanguage = (LanguageType)_rxInStream->readLong();
+
+ // und daraus von einem Formatter zu einem Key zusammenwuerfeln lassen ...
+ xSupplier = calcFormatsSupplier();
+ // calcFormatsSupplier nimmt erst den vom Model, dann einen von der starform, dann einen ganz neuen ....
+ staruno::Reference<starutil::XNumberFormats> xFormats = xSupplier->getNumberFormats();
+
+ if (xFormats.is())
+ {
+ UniString sLanguage, sCountry;
+ ConvertLanguageToIsoNames(eDescriptionLanguage, sLanguage, sCountry);
+ starlang::Locale aDescriptionLanguage(
+ sLanguage,
+ sCountry,
+ ::rtl::OUString());
+ nKey = xFormats->queryKey(sFormatDescription, aDescriptionLanguage, sal_False);
+ if (nKey == (sal_Int32)-1)
+ { // noch nicht vorhanden in meinem Formatter ...
+ nKey = xFormats->addNew(sFormatDescription, aDescriptionLanguage);
+ }
+ }
+ }
+ if ((nVersion == 0x0002) || (nVersion == 0x0003))
+ readCommonEditProperties(_rxInStream);
+
+ if (nVersion == 0x0003)
+ { // since version 3 there is a "skippable" block at this position
+ staruno::Reference< stario::XDataInputStream > xIn(_rxInStream, staruno::UNO_QUERY);
+ OMarkableStreamBlock aDownCompat(xIn);
+
+ sal_Int16 nSubVersion = _rxInStream->readShort();
+
+ // version 0 and higher : the "effective value" property
+ staruno::Any aEffectiveValue;
+ {
+ OMarkableStreamBlock aDownCompat2(xIn);
+ switch (_rxInStream->readShort())
+ {
+ case 0: // String
+ aEffectiveValue <<= _rxInStream->readUTF();
+ break;
+ case 1: // double
+ aEffectiveValue <<= (double)_rxInStream->readDouble();
+ break;
+ case 2:
+ break;
+ case 3:
+ DBG_ERROR("FmXFormattedModel::read : unknown effective value type !");
+ }
+ }
+
+ // this property is only to be set if we have no control source : in all other cases the base class did a
+ // reset after it's read and this set the effective value to a default value
+ if (m_xAggregateSet.is() && (m_aControlSource.getLength() == 0))
+ {
+ try
+ {
+ m_xAggregateSet->setPropertyValue(PROPERTY_EFFECTIVE_VALUE, aEffectiveValue);
+ }
+ catch(...)
+ {
+ }
+ }
+ }
+ }
+ break;
+ default :
+ DBG_ERROR("OFormattedModel::read : unknown version !");
+ // dann bleibt das Format des aggregierten Sets, wie es bei der Erzeugung ist : void
+ defaultCommonEditProperties();
+ break;
+ }
+
+ if ((nKey != -1) && m_xAggregateSet.is())
+ {
+ m_xAggregateSet->setPropertyValue(PROPERTY_FORMATSSUPPLIER, staruno::makeAny(xSupplier));
+ m_xAggregateSet->setPropertyValue(PROPERTY_FORMATKEY, staruno::makeAny((sal_Int32)nKey));
+ }
+ else
+ {
+ setPropertyToDefault(PROPERTY_FORMATSSUPPLIER);
+ setPropertyToDefault(PROPERTY_FORMATKEY);
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Int16 OFormattedModel::getPersistenceFlags() const
+{
+ return (OEditBaseModel::getPersistenceFlags() & ~PF_HANDLE_COMMON_PROPS);
+ // a) we do our own call to writeCommonEditProperties
+}
+//------------------------------------------------------------------------------
+sal_Bool OFormattedModel::_commit()
+{
+ staruno::Any aNewValue = m_xAggregateFastSet->getFastPropertyValue( OFormattedModel::nValueHandle );
+ if (!compare(aNewValue, m_aSaveValue))
+ {
+ // Leerstring + EmptyIsNull = void
+ if (!aNewValue.hasValue() ||
+ (aNewValue.getValueType().getTypeClass() == staruno::TypeClass_STRING)
+ && (getString(aNewValue).getLength() == 0) && m_bEmptyIsNull)
+ m_xColumnUpdate->updateNull();
+ else
+ {
+ // als Value koennen nur double, string oder void auftreten
+ try
+ {
+ if (aNewValue.getValueType().getTypeClass() == staruno::TypeClass_DOUBLE)
+ {
+ DBTypeConversion::setValue(m_xColumnUpdate, m_aNullDate, getDouble(aNewValue), m_nKeyType);
+ }
+ else
+ {
+ DBG_ASSERT(aNewValue.getValueType().getTypeClass() == staruno::TypeClass_STRING, "OFormattedModel::_commit : invalud value type !");
+ m_xColumnUpdate->updateString(getString(aNewValue));
+ }
+ }
+ catch(...)
+ {
+ return sal_False;
+ }
+ m_aSaveValue = aNewValue;
+ }
+ }
+ return sal_True;
+}
+
+// starbeans::XPropertyChangeListener
+//------------------------------------------------------------------------------
+void OFormattedModel::_onValueChanged()
+{
+ if (m_bNumeric)
+ m_aSaveValue <<= m_xColumn->getDouble();
+ else
+ m_aSaveValue <<= m_xColumn->getString();
+
+ if (m_xColumn->wasNull())
+ m_aSaveValue.clear();
+
+ { // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
+ // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
+ // our own mutex locked
+ // FS - 72451 - 31.01.00
+ MutexRelease aRelease(m_aMutex);
+ m_xAggregateFastSet->setFastPropertyValue(OFormattedModel::nValueHandle, m_aSaveValue);
+ }
+}
+
+// starform::XReset
+//------------------------------------------------------------------------------
+void OFormattedModel::_reset( void )
+{
+ if (!m_xAggregateSet.is())
+ {
+ DBG_ERROR("OFormattedModel::_reset : no aggregate !");
+ return;
+ }
+ staruno::Any aValue = m_xAggregateSet->getPropertyValue(PROPERTY_EFFECTIVE_DEFAULT);
+ { // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
+ // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
+ // our own mutex locked
+ // FS - 72451 - 31.01.00
+ MutexRelease aRelease(m_aMutex);
+ m_xAggregateFastSet->setFastPropertyValue(OFormattedModel::nValueHandle, aValue);
+ }
+}
+
+//.........................................................................
+}
+//.........................................................................
+
diff --git a/forms/source/component/FormattedField.hxx b/forms/source/component/FormattedField.hxx
new file mode 100644
index 000000000000..d19f037d00af
--- /dev/null
+++ b/forms/source/component/FormattedField.hxx
@@ -0,0 +1,212 @@
+/*************************************************************************
+ *
+ * $RCSfile: FormattedField.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_FORMATTEDFIELD_HXX_
+#define _FORMS_FORMATTEDFIELD_HXX_
+
+#ifndef _FORMS_EDITBASE_HXX_
+#include "EditBase.hxx"
+#endif
+
+#ifndef _LANG_HXX
+#include <tools/lang.hxx>
+#endif
+
+#ifndef _UNOTOOLS_PROPERTY_MULTIPLEX_HXX_
+#include <unotools/propmultiplex.hxx>
+#endif
+
+//.........................................................................
+namespace frm
+{
+
+//==================================================================
+//= OFormattedModel
+//==================================================================
+class OFormattedModel
+ :public OEditBaseModel
+ ,public OPropertyChangeListener
+ ,public ::utl::OAggregationArrayUsageHelper< OFormattedModel >
+{
+ // das Original, falls ich die Format-Properties meines aggregierten Models gefaket, d.h. von dem Feld, an das
+ // ich gebunden bin, weitergereicht habe (nur gueltig wenn loaded)
+ staruno::Reference<starutil::XNumberFormatsSupplier> m_xOriginalFormatter;
+ Date m_aNullDate;
+ staruno::Any m_aSaveValue;
+ sal_Int16 m_nKeyType;
+
+ sal_Bool m_bOriginalNumeric : 1,
+ m_bNumeric : 1;
+ // analog fuer TreatAsNumeric-Property
+
+ static staruno::Reference<starutil::XNumberFormatsSupplier> s_xDefaultFormatter;
+ static sal_Int32 nValueHandle;
+ // falls ich wirklich mal einen selber benutzen muss, wird der zwischen allen Instanzen geteilt
+
+protected:
+ virtual void _onValueChanged();
+
+ staruno::Reference<starutil::XNumberFormatsSupplier> calcDefaultFormatsSupplier() const;
+ staruno::Reference<starutil::XNumberFormatsSupplier> calcFormFormatsSupplier() const;
+ staruno::Reference<starutil::XNumberFormatsSupplier> calcFormatsSupplier() const;
+ sal_Int32 calcFormatKey() const;
+ void getFormatDescription(::rtl::OUString& sFormat, LanguageType& eLanguage);
+
+ OFormattedModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+
+ friend InterfaceRef SAL_CALL OFormattedModel_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+ friend class OFormattedFieldWrapper;
+public:
+
+// starlang::XServiceInfo
+ IMPLEMENTATION_NAME(OFormattedModel);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
+
+// starform::XBoundComponent
+ virtual sal_Bool _commit();
+
+// stario::XPersistObject
+ virtual void SAL_CALL write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream);
+ virtual void SAL_CALL read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream);
+ virtual ::rtl::OUString SAL_CALL getServiceName();
+
+// starbeans::XPropertySet
+ virtual staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(staruno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ virtual void SAL_CALL getFastPropertyValue(staruno::Any& rValue, sal_Int32 nHandle ) const;
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(staruno::Any& rConvertedValue, staruno::Any& rOldValue,
+ sal_Int32 nHandle, const staruno::Any& rValue )
+ throw(starlang::IllegalArgumentException);
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const staruno::Any& rValue);
+
+// starform::XLoadListener
+ virtual void SAL_CALL loaded(const starlang::EventObject& rEvent);
+ virtual void _loaded(const starlang::EventObject& rEvent);
+ virtual void _unloaded();
+
+// starform::XReset
+ virtual void _reset( void );
+
+// starbeans::XPropertyState
+ void setPropertyToDefaultByHandle(sal_Int32 nHandle);
+ staruno::Any getPropertyDefaultByHandle(sal_Int32 nHandle) const;
+
+ void SAL_CALL setPropertyToDefault(const ::rtl::OUString& aPropertyName) throw(starbeans::UnknownPropertyException, staruno::RuntimeException);
+ staruno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(starbeans::UnknownPropertyException, staruno::RuntimeException);
+
+ // OAggregationArrayUsageHelper
+ virtual void fillProperties(
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rProps,
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rAggregateProps
+ ) const;
+ IMPLEMENT_INFO_SERVICE()
+
+// OPropertyChangeListener
+ virtual void _propertyChanged(const starbeans::PropertyChangeEvent& evt) throw(staruno::RuntimeException);
+
+protected:
+ virtual sal_Int16 getPersistenceFlags() const;
+ // as we have an own version handling for persistence
+};
+
+//==================================================================
+//= OFormattedControl
+//==================================================================
+class OFormattedControl : public OBoundControl
+ ,public starawt::XKeyListener
+{
+ sal_uInt32 m_nKeyEvent;
+
+public:
+ OFormattedControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+ virtual ~OFormattedControl();
+
+ DECLARE_UNO3_AGG_DEFAULTS(OFormattedControl, OBoundControl);
+ virtual staruno::Any SAL_CALL queryAggregation(const staruno::Type& _rType) throw(staruno::RuntimeException);
+
+ virtual staruno::Sequence<staruno::Type> _getTypes();
+
+// starlang::XServiceInfo
+ IMPLEMENTATION_NAME(OFormattedControl);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
+
+// starlang::XEventListener
+ virtual void SAL_CALL disposing(const starlang::EventObject& _rSource) throw(staruno::RuntimeException);
+
+// starawt::XKeyListener
+ virtual void SAL_CALL keyPressed(const starawt::KeyEvent& e);
+ virtual void SAL_CALL keyReleased(const starawt::KeyEvent& e);
+
+// starawt::XControl
+ virtual void SAL_CALL setDesignMode(sal_Bool bOn);
+
+private:
+ DECL_LINK( OnKeyPressed, void* );
+};
+
+
+//.........................................................................
+}
+//.........................................................................
+
+#endif // _FORMS_FORMATTEDFIELD_HXX_
+
diff --git a/forms/source/component/FormattedFieldWrapper.cxx b/forms/source/component/FormattedFieldWrapper.cxx
new file mode 100644
index 000000000000..0c1ce3b07817
--- /dev/null
+++ b/forms/source/component/FormattedFieldWrapper.cxx
@@ -0,0 +1,350 @@
+/*************************************************************************
+ *
+ * $RCSfile: FormattedFieldWrapper.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FRM_FORMATTED_FIELD_WRAPPER_HXX_
+#include "FormattedFieldWrapper.hxx"
+#endif
+#ifndef _FORMS_EDIT_HXX_
+#include "Edit.hxx"
+#endif
+#ifndef _FORMS_FORMATTEDFIELD_HXX_
+#include "FormattedField.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _FORMS_EDITBASE_HXX_
+#include "EditBase.hxx"
+#endif
+#ifndef _FRM_SERVICES_HXX_
+#include "services.hxx"
+#endif
+#ifndef _UTL_UNO3_DB_TOOLS_HXX_
+#include <unotools/dbtools.hxx>
+#endif
+
+#ifndef _ISOLANG_HXX
+#include <tools/isolang.hxx>
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _TOOLS_INTN_HXX
+#include <tools/intn.hxx>
+#endif
+
+//.........................................................................
+namespace frm
+{
+
+//==================================================================
+// OFormattedFieldWrapper
+//==================================================================
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OFormattedFieldWrapper_CreateInstance_ForceFormatted(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new OFormattedFieldWrapper(_rxFactory, sal_True));
+}
+
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OFormattedFieldWrapper_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new OFormattedFieldWrapper(_rxFactory, sal_False));
+}
+
+//------------------------------------------------------------------
+OFormattedFieldWrapper::OFormattedFieldWrapper(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory, sal_Bool _bActAsFormatted)
+ :m_pEditPart(NULL)
+ ,m_xServiceFactory(_rxFactory)
+{
+ if (_bActAsFormatted)
+ {
+ increment(m_refCount);
+ {
+ // instantiate an FormattedModel
+ InterfaceRef xFormattedModel;
+ // (instantiate it directly ..., as the OFormattedModel isn't registered for any service names anymore)
+ OFormattedModel* pModel = new OFormattedModel(m_xServiceFactory);
+ query_interface(static_cast<staruno::XWeak*>(pModel), xFormattedModel);
+
+ m_xAggregate = staruno::Reference<staruno::XAggregation> (xFormattedModel, staruno::UNO_QUERY);
+ DBG_ASSERT(m_xAggregate.is(), "OFormattedFieldWrapper::OFormattedFieldWrapper : the OFormattedModel didn't have an staruno::XAggregation interface !");
+
+ // _before_ setting the delegator, give it to the member references
+ query_interface(xFormattedModel, m_xFormattedPart);
+ m_pEditPart = new OEditModel(m_xServiceFactory);
+ m_pEditPart->acquire();
+ }
+ if (m_xAggregate.is())
+ { // has to be in it's own block because of the temporary variable created by *this
+ m_xAggregate->setDelegator(static_cast<staruno::XWeak*>(this));
+ }
+ decrement(m_refCount);
+ }
+}
+
+//------------------------------------------------------------------
+OFormattedFieldWrapper::~OFormattedFieldWrapper()
+{
+ // release the aggregated object (if any)
+ if (m_xAggregate.is())
+ m_xAggregate->setDelegator(InterfaceRef ());
+
+ if (m_pEditPart)
+ m_pEditPart->release();
+}
+
+//------------------------------------------------------------------
+staruno::Any SAL_CALL OFormattedFieldWrapper::queryAggregation(const staruno::Type& _rType) throw (staruno::RuntimeException)
+{
+ staruno::Any aReturn;
+
+ if (_rType.equals( ::getCppuType( static_cast< staruno::Reference< starlang::XTypeProvider >* >(NULL) ) ) )
+ { // a XTypeProvider interface needs a working aggregate - we don't want to give the type provider
+ // of our base class (OWeakAggObject) to the caller as it supplies nearly nothing
+ ensureAggregate();
+ if (m_xAggregate.is())
+ aReturn = m_xAggregate->queryAggregation(_rType);
+ }
+
+ if (!aReturn.hasValue())
+ aReturn = OWeakAggObject::queryAggregation(_rType);
+
+ if (!aReturn.hasValue())
+ aReturn = ::cppu::queryInterface(_rType
+ ,static_cast<stario::XPersistObject*>(this)
+ );
+
+ if (!aReturn.hasValue())
+ {
+ // somebody requests an interface other than the basics (staruno::XInterface) and other than
+ // the only one we can supply without an aggregate. So ensure the aggregate exists.
+ ensureAggregate();
+ if (m_xAggregate.is())
+ aReturn = m_xAggregate->queryAggregation(_rType);
+ }
+
+ return aReturn;
+}
+
+//------------------------------------------------------------------
+::rtl::OUString SAL_CALL OFormattedFieldWrapper::getServiceName() throw(staruno::RuntimeException)
+{
+ // return the old compatibility name for an EditModel
+ return FRM_COMPONENT_EDIT;
+}
+
+//------------------------------------------------------------------
+void SAL_CALL OFormattedFieldWrapper::write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream) throw( stario::IOException, staruno::RuntimeException )
+{
+ // can't write myself
+ ensureAggregate();
+
+ // if we act as real edit field, we can simple forward this write request
+ if (!m_xFormattedPart.is())
+ {
+ staruno::Reference<stario::XPersistObject> xAggregatePersistence;
+ query_aggregation(m_xAggregate, xAggregatePersistence);
+ DBG_ASSERT(xAggregatePersistence.is(), "OFormattedFieldWrapper::write : don't know how to handle this : can't write !");
+ // oops ... We gave an stario::XPersistObject interface to the caller but now we aren't an stario::XPersistObject ...
+ if (xAggregatePersistence.is())
+ xAggregatePersistence->write(_rxOutStream);
+ return;
+ }
+
+ // else we have to write an edit part first
+ DBG_ASSERT(m_pEditPart, "OFormattedFieldWrapper::write : formatted part without edit part ?");
+
+ // for this we transfer the current props of the formatted part to the edit part
+ staruno::Reference<starbeans::XPropertySet> xFormatProps(m_xFormattedPart, staruno::UNO_QUERY);
+ staruno::Reference<starbeans::XPropertySet> xEditProps;
+ query_interface(static_cast<staruno::XWeak*>(m_pEditPart), xEditProps);
+
+ UniString sLanguage, sCountry;
+ ConvertLanguageToIsoNames(Application::GetAppInternational().GetLanguage(), sLanguage, sCountry);
+ starlang::Locale aAppLanguage(
+ sLanguage,
+ sCountry,
+ ::rtl::OUString());
+
+ TransferFormComponentProperties(xFormatProps, xEditProps, aAppLanguage);
+
+ // then write the edit part, after switching to "fake mode"
+ m_pEditPart->enableFormattedWriteFake();
+ m_pEditPart->write(_rxOutStream);
+ m_pEditPart->disableFormattedWriteFake();
+
+ // and finally write the formatted part we're really interested in
+ m_xFormattedPart->write(_rxOutStream);
+}
+
+//------------------------------------------------------------------
+void SAL_CALL OFormattedFieldWrapper::read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream) throw( stario::IOException, staruno::RuntimeException )
+{
+ if (m_xAggregate.is())
+ { // we alread did a decision if we're an EditModel or a FormattedModel
+
+ // if we act as formatted, we have to read the edit part first
+ if (m_xFormattedPart.is())
+ {
+ // two possible cases:
+ // a) the stuff was written by a version which didn't work with an Edit header (all intermediate
+ // versions >5.1 && <=568)
+ // b) it was written by a version using edit headers
+ // as we can distinguish a) from b) only after we have read the edit part, we need to remember the
+ // position
+ staruno::Reference<stario::XMarkableStream> xInMarkable(_rxInStream, staruno::UNO_QUERY);
+ DBG_ASSERT(xInMarkable.is(), "OFormattedFieldWrapper::read : can only work with markable streams !");
+ sal_Int32 nBeforeEditPart = xInMarkable->createMark();
+
+ m_pEditPart->read(_rxInStream);
+ // this only works because an edit model can read the stuff written by a formatted model (maybe with
+ // some assertions) , but not vice versa
+ if (!m_pEditPart->lastReadWasFormattedFake())
+ { // case a), written with a version without the edit part fake, so seek to the start position, again
+ xInMarkable->jumpToMark(nBeforeEditPart);
+ }
+ xInMarkable->deleteMark(nBeforeEditPart);
+ }
+
+ staruno::Reference<stario::XPersistObject> xAggregatePersistence;
+ query_aggregation(m_xAggregate, xAggregatePersistence);
+ DBG_ASSERT(xAggregatePersistence.is(), "OFormattedFieldWrapper::read : don't know how to handle this : can't read !");
+ // oops ... We gave an stario::XPersistObject interface to the caller but now we aren't an stario::XPersistObject ...
+
+ if (xAggregatePersistence.is())
+ xAggregatePersistence->read(_rxInStream);
+ return;
+ }
+
+ // we have to decide from the data within the stream whether we should be an EditModel or a FormattedModel
+ OEditBaseModel* pNewAggregate = NULL;
+
+ // let an OEditModel do the reading
+ OEditModel* pBasicReader = new OEditModel(m_xServiceFactory);
+ pBasicReader->read(_rxInStream);
+
+ // was it really an edit model ?
+ if (!pBasicReader->lastReadWasFormattedFake())
+ // yes -> all fine
+ pNewAggregate = pBasicReader;
+ else
+ { // no -> substitute it with a formatted model
+
+ // let the formmatted model do the reading
+ OFormattedModel* pFormattedReader = new OFormattedModel(m_xServiceFactory);
+ pFormattedReader->read(_rxInStream);
+
+ // for the next write (if any) : the FormattedModel and the EditModel parts
+ query_interface(static_cast<staruno::XWeak*>(pFormattedReader), m_xFormattedPart);
+ m_pEditPart = pBasicReader;
+ m_pEditPart->acquire();
+
+ // aggregate the formatted part below
+ pNewAggregate = pFormattedReader;
+ }
+
+ // do the aggregation
+ increment(m_refCount);
+ {
+ query_interface(static_cast<staruno::XWeak*>(pNewAggregate), m_xAggregate);
+ DBG_ASSERT(m_xAggregate.is(), "OFormattedFieldWrapper::read : the OEditModel didn't have an staruno::XAggregation interface !");
+ }
+ if (m_xAggregate.is())
+ { // has to be in it's own block because of the temporary variable created by *this
+ m_xAggregate->setDelegator(static_cast<staruno::XWeak*>(this));
+ }
+ decrement(m_refCount);
+}
+
+//------------------------------------------------------------------
+void OFormattedFieldWrapper::ensureAggregate()
+{
+ if (m_xAggregate.is())
+ return;
+
+ increment(m_refCount);
+ {
+ // instantiate an EditModel (the only place where we are allowed to decide that we're an FormattedModel
+ // is in ::read)
+ InterfaceRef xEditModel = m_xServiceFactory->createInstance(FRM_SUN_COMPONENT_TEXTFIELD);
+ if (!xEditModel.is())
+ {
+ // arghhh ... instantiate it directly ... it's dirty, but we really need this aggregate
+ OEditModel* pModel = new OEditModel(m_xServiceFactory);
+ query_interface(static_cast<staruno::XWeak*>(pModel), xEditModel);
+ }
+
+ m_xAggregate = staruno::Reference<staruno::XAggregation> (xEditModel, staruno::UNO_QUERY);
+ DBG_ASSERT(m_xAggregate.is(), "OFormattedFieldWrapper::ensureAggregate : the OEditModel didn't have an staruno::XAggregation interface !");
+ }
+ if (m_xAggregate.is())
+ { // has to be in it's own block because of the temporary variable created by *this
+ m_xAggregate->setDelegator(static_cast<staruno::XWeak*>(this));
+ }
+ decrement(m_refCount);
+}
+
+//.........................................................................
+}
+//.........................................................................
+
+
diff --git a/forms/source/component/FormattedFieldWrapper.hxx b/forms/source/component/FormattedFieldWrapper.hxx
new file mode 100644
index 000000000000..d050990c85fe
--- /dev/null
+++ b/forms/source/component/FormattedFieldWrapper.hxx
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * $RCSfile: FormattedFieldWrapper.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FRM_FORMATTED_FIELD_WRAPPER_HXX_
+#define _FRM_FORMATTED_FIELD_WRAPPER_HXX_
+
+#ifndef _FORMS_FORMCOMPONENT_HXX_
+#include "FormComponent.hxx"
+#endif
+
+//.........................................................................
+namespace frm
+{
+
+class OEditModel;
+//==================================================================
+//= OFormattedFieldWrapper
+//==================================================================
+class OFormattedFieldWrapper
+ :public stario::XPersistObject
+ ,public ::cppu::OWeakAggObject
+{
+ staruno::Reference<starlang::XMultiServiceFactory> m_xServiceFactory;
+
+protected:
+ staruno::Reference<staruno::XAggregation> m_xAggregate;
+
+ OEditModel* m_pEditPart;
+ // if we act as formatted this is used to write the EditModel part
+ staruno::Reference<stario::XPersistObject> m_xFormattedPart;
+ // if we act as formatted, this is the PersistObject interface of our aggregate, used
+ // to read and write the FormattedModel part
+
+ OFormattedFieldWrapper(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory, sal_Bool _bActAsFormatted);
+ // if _bActAsFormatted is sal_False, the state is undetermined until somebody calls ::read or does
+ // anything which requires a living aggregate
+ virtual ~OFormattedFieldWrapper();
+
+ friend InterfaceRef SAL_CALL OFormattedFieldWrapper_CreateInstance_ForceFormatted(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+ friend InterfaceRef SAL_CALL OFormattedFieldWrapper_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+
+public:
+ // UNO
+ DECLARE_UNO3_AGG_DEFAULTS(OFormattedFieldWrapper, OWeakAggObject);
+ virtual staruno::Any SAL_CALL queryAggregation(const staruno::Type& _rType) throw(staruno::RuntimeException);
+
+ // stario::XPersistObject
+ virtual ::rtl::OUString SAL_CALL getServiceName() throw(staruno::RuntimeException);
+ virtual void SAL_CALL write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream) throw(stario::IOException, staruno::RuntimeException);
+ virtual void SAL_CALL read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream) throw(stario::IOException, staruno::RuntimeException);
+
+protected:
+ /// ensure we're in a defined state, which means a FormattedModel _OR_ an EditModel
+ void ensureAggregate();
+};
+
+//.........................................................................
+}
+//.........................................................................
+
+#endif // _FRM_FORMATTED_FIELD_WRAPPER_HXX_
+
diff --git a/forms/source/component/FormsCollection.cxx b/forms/source/component/FormsCollection.cxx
new file mode 100644
index 000000000000..c7b3acf4f78c
--- /dev/null
+++ b/forms/source/component/FormsCollection.cxx
@@ -0,0 +1,207 @@
+/*************************************************************************
+ *
+ * $RCSfile: FormsCollection.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:04 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "FormsCollection.hxx"
+
+#ifndef _FRM_SERVICES_HXX_
+#include "services.hxx"
+#endif
+
+#ifndef _UTL_SEQUENCE_HXX_
+#include <unotools/sequence.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_FORM_XFORM_HPP_
+#include <com/sun/star/form/XForm.hpp>
+#endif
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+//------------------------------------------------------------------
+DBG_NAME(OFormsCollection)
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OFormsCollection_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new OFormsCollection(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OFormsCollection::getServiceName() throw(staruno::RuntimeException)
+{
+ return FRM_SUN_FORMS_COLLECTION;
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence< sal_Int8 > SAL_CALL OFormsCollection::getImplementationId( ) throw(staruno::RuntimeException)
+{
+ return OImplementationIds::getImplementationId(getTypes());
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> SAL_CALL OFormsCollection::getTypes() throw(staruno::RuntimeException)
+{
+ staruno::Sequence<staruno::Type> aBaseTypes = OInterfaceContainer::getTypes();
+ staruno::Sequence<staruno::Type> aComponentTypes = FormsCollectionComponentBase::getTypes();
+
+ staruno::Sequence<staruno::Type> aOwnTypes(1);
+ aOwnTypes.getArray()[0] = ::getCppuType(static_cast<staruno::Reference<starcontainer::XChild>*>(NULL));
+
+ return concatSequences(aBaseTypes, aComponentTypes, aOwnTypes);
+}
+
+//------------------------------------------------------------------
+OFormsCollection::OFormsCollection(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :FormsCollectionComponentBase(m_aMutex)
+ ,OInterfaceContainer(_rxFactory, m_aMutex, ::getCppuType(static_cast<staruno::Reference<starform::XForm>*>(NULL)))
+{
+ DBG_CTOR(OFormsCollection, NULL);
+}
+
+//------------------------------------------------------------------------------
+OFormsCollection::~OFormsCollection()
+{
+ DBG_DTOR(OFormsCollection, NULL);
+ if (!FormsCollectionComponentBase::rBHelper.bDisposed)
+ {
+ acquire();
+ dispose();
+ }
+}
+
+//------------------------------------------------------------------------------
+staruno::Any SAL_CALL OFormsCollection::queryAggregation(const staruno::Type& _rType) throw(staruno::RuntimeException)
+{
+ staruno::Any aReturn = ::cppu::queryInterface(
+ _rType,
+ static_cast<starcontainer::XChild*>(this),
+ static_cast<starlang::XServiceInfo*>(this)
+ );
+
+ if (!aReturn.hasValue())
+ aReturn = OInterfaceContainer::queryInterface(_rType);
+
+ if (!aReturn.hasValue())
+ aReturn = FormsCollectionComponentBase::queryAggregation(_rType);
+
+ return aReturn;
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OFormsCollection::getImplementationName() throw(staruno::RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.form.OFormsCollection");
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL OFormsCollection::supportsService( const ::rtl::OUString& _rServiceName ) throw(staruno::RuntimeException)
+{
+ staruno::Sequence<rtl::OUString> aSupported = getSupportedServiceNames();
+ const rtl::OUString* pSupported = aSupported.getConstArray();
+ for (sal_Int32 i=0; i<aSupported.getLength(); ++i, ++pSupported)
+ if (pSupported->equals(_rServiceName))
+ return sal_True;
+ return sal_False;
+}
+
+//------------------------------------------------------------------------------
+StringSequence SAL_CALL OFormsCollection::getSupportedServiceNames() throw(staruno::RuntimeException)
+{
+ StringSequence aReturn(2);
+
+ aReturn.getArray()[0] = FRM_SUN_FORMS_COLLECTION;
+ aReturn.getArray()[1] = ::rtl::OUString::createFromAscii("com.sun.star.form.FormComponents");
+
+ return aReturn;
+}
+
+// OComponentHelper
+//------------------------------------------------------------------------------
+void OFormsCollection::disposing()
+{
+ OInterfaceContainer::disposing();
+ FormsCollectionComponentBase::disposing();
+ m_xParent = NULL;
+}
+
+//XChild
+//------------------------------------------------------------------------------
+void OFormsCollection::setParent(const InterfaceRef& Parent) throw( starlang::NoSupportException, staruno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_xParent = Parent;
+}
+
+//------------------------------------------------------------------------------
+InterfaceRef OFormsCollection::getParent() throw( staruno::RuntimeException )
+{
+ return m_xParent;
+}
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
diff --git a/forms/source/component/FormsCollection.hxx b/forms/source/component/FormsCollection.hxx
new file mode 100644
index 000000000000..cfb82543d651
--- /dev/null
+++ b/forms/source/component/FormsCollection.hxx
@@ -0,0 +1,138 @@
+/*************************************************************************
+ *
+ * $RCSfile: FormsCollection.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FRM_INTERFACE_CONTAINER_HXX_
+#include "InterfaceContainer.hxx"
+#endif
+
+#ifndef _CPPUHELPER_COMPONENT_HXX_
+#include <cppuhelper/component.hxx>
+#endif
+
+#ifndef _UTL_UNO3_HXX_
+#include <unotools/uno3.hxx>
+#endif
+#ifndef _FRM_IDS_HXX_
+#include "ids.hxx"
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+//==================================================================
+// OFormsCollection
+// Implementiert den UNO-Container fuer Formulare
+// enthaelt alle zugeordneten Forms
+// dieses Container kann selbst den Context fuer Formulare darstellen
+// oder außen einen Context uebergeben bekommen
+//==================================================================
+typedef ::cppu::OComponentHelper FormsCollectionComponentBase;
+ // else MSVC kills itself on some statements
+class OFormsCollection
+ :public FormsCollectionComponentBase
+ ,public OInterfaceContainer
+ ,public starcontainer::XChild
+ ,public starlang::XServiceInfo
+
+{
+ ::osl::Mutex m_aMutex;
+ OImplementationIdsRef m_aHoldIdHelper;
+ ::utl::InterfaceRef m_xParent; // Parent
+
+public:
+ OFormsCollection(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+ virtual ~OFormsCollection();
+
+public:
+ DECLARE_UNO3_AGG_DEFAULTS(OFormsCollection, FormsCollectionComponentBase);
+
+ virtual staruno::Any SAL_CALL queryAggregation(const staruno::Type& _rType) throw(staruno::RuntimeException);
+
+// XTypeProvider
+ virtual staruno::Sequence< staruno::Type > SAL_CALL getTypes( ) throw(staruno::RuntimeException);
+ virtual staruno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(staruno::RuntimeException);
+
+// XPersistObject
+ virtual ::rtl::OUString SAL_CALL getServiceName() throw(staruno::RuntimeException);
+
+// XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(staruno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(staruno::RuntimeException);
+ virtual StringSequence SAL_CALL getSupportedServiceNames( ) throw(staruno::RuntimeException);
+
+// OComponentHelper
+ virtual void SAL_CALL disposing();
+
+// starcontainer::XChild
+ virtual ::utl::InterfaceRef SAL_CALL getParent() throw(staruno::RuntimeException);
+ virtual void SAL_CALL setParent(const ::utl::InterfaceRef& Parent) throw(starlang::NoSupportException, staruno::RuntimeException);
+};
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
diff --git a/forms/source/component/Grid.cxx b/forms/source/component/Grid.cxx
new file mode 100644
index 000000000000..bf412134e93e
--- /dev/null
+++ b/forms/source/component/Grid.cxx
@@ -0,0 +1,1302 @@
+/*************************************************************************
+ *
+ * $RCSfile: Grid.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "Grid.hxx"
+#ifndef _FRM_COLUMNS_HXX
+#include "Columns.hxx"
+#endif
+
+#ifndef _COM_SUN_STAR_FORM_FORMCOMPONENTTYPE_HPP_
+#include <com/sun/star/form/FormComponentType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORM_HPP_
+#include <com/sun/star/form/XForm.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XLOADABLE_HPP_
+#include <com/sun/star/form/XLoadable.hpp>
+#endif
+
+#ifndef _FRM_SERVICES_HXX_
+#include "services.hxx"
+#endif
+#ifndef _FRM_PROPERTY_HRC_
+#include "property.hrc"
+#endif
+#ifndef _FRM_PROPERTY_HXX_
+#include "property.hxx"
+#endif
+
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _CPPUHELPER_EXTRACT_HXX_
+#include <cppuhelper/extract.hxx>
+#endif
+#ifndef _UTL_CONTAINER_HXX_
+#include <unotools/container.hxx>
+#endif
+
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+
+#ifndef _TOOLKIT_UNOHLP_HXX
+#include <toolkit/helper/vclunohelper.hxx>
+#endif
+
+// TODO : find a place for this !
+namespace internal
+{
+//------------------------------------------------------------------
+// Vergleichen von Strings
+static int
+#if defined( WNT )
+ __cdecl
+#endif
+#if defined( ICC ) && defined( OS2 )
+_Optlink
+#endif
+ NameCompare(const void* pFirst, const void* pSecond)
+{
+ return ((::rtl::OUString*)pFirst)->compareTo(*(::rtl::OUString*)pSecond);
+}
+
+//------------------------------------------------------------------
+sal_Int32 findPos(const ::rtl::OUString& aStr, const StringSequence& rList)
+{
+ const ::rtl::OUString* pStrList = rList.getConstArray();
+ ::rtl::OUString* pResult = (::rtl::OUString*) bsearch(&aStr, (void*)pStrList, rList.getLength(), sizeof(::rtl::OUString),
+ &NameCompare);
+
+ if (pResult)
+ return (pResult - pStrList);
+ else
+ return -1;
+}
+
+} // namespace internal
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+const sal_uInt16 ROWHEIGHT = 0x0001;
+const sal_uInt16 FONTTYPE = 0x0002;
+const sal_uInt16 FONTSIZE = 0x0004;
+const sal_uInt16 FONTATTRIBS = 0x0008;
+const sal_uInt16 TABSTOP = 0x0010;
+const sal_uInt16 TEXTCOLOR = 0x0020;
+const sal_uInt16 FONTDESCRIPTOR = 0x0040;
+const sal_uInt16 RECORDMARKER = 0x0080;
+const sal_uInt16 BACKGROUNDCOLOR = 0x0100;
+
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OGridControlModel_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new OGridControlModel(_rxFactory));
+}
+
+//------------------------------------------------------------------
+staruno::Sequence<staruno::Type> OGridControlModel::_getTypes()
+{
+ static staruno::Sequence<staruno::Type> aTypes;
+ if (!aTypes.getLength())
+ {
+ staruno::Sequence<staruno::Type> aOwnTypes(5);
+ staruno::Type* pOwnTypes = aOwnTypes.getArray();
+ pOwnTypes[0] = getCppuType((staruno::Reference<starform::XGridColumnFactory>*)NULL);
+ pOwnTypes[1] = getCppuType((staruno::Reference<starview::XSelectionSupplier>*)NULL);
+ pOwnTypes[2] = getCppuType((staruno::Reference<starawt::XControlModel>*)NULL);
+ pOwnTypes[3] = getCppuType((staruno::Reference<starform::XReset>*)NULL);
+ pOwnTypes[4] = getCppuType((staruno::Reference<starform::XLoadListener>*)NULL);
+
+ aTypes = concatSequences(OControlModel::_getTypes(), OInterfaceContainer::getTypes(), aOwnTypes);
+ }
+ return aTypes;
+}
+
+DBG_NAME(OGridControlModel);
+//------------------------------------------------------------------
+OGridControlModel::OGridControlModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OControlModel(_rxFactory, ::rtl::OUString())
+ ,OInterfaceContainer(_rxFactory, m_aMutex, ::getCppuType(static_cast<staruno::Reference<starbeans::XPropertySet>*>(NULL)))
+ ,m_aSelectListeners(m_aMutex)
+ ,m_aResetListeners(m_aMutex)
+ ,m_aDefaultControl(FRM_CONTROL_GRID) // use the old control name for compytibility reasons
+ ,m_nFontEvent(0)
+ ,m_bEnable(sal_True)
+ ,m_bNavigation(sal_True)
+ ,m_nBorder(1)
+ ,m_bRecordMarker(sal_True)
+ ,m_bPrintable(sal_True)
+ ,m_bAlwaysShowCursor(sal_False)
+ ,m_bDisplaySynchron(sal_True)
+{
+ DBG_CTOR(OGridControlModel,NULL);
+
+ m_nClassId = starform::FormComponentType::GRIDCONTROL;
+}
+
+//------------------------------------------------------------------
+OGridControlModel::~OGridControlModel()
+{
+ DBG_DTOR(OGridControlModel,NULL);
+ if (m_nFontEvent)
+ Application::RemoveUserEvent(m_nFontEvent);
+
+ if (!OComponentHelper::rBHelper.bDisposed)
+ {
+ acquire();
+ dispose();
+ }
+
+}
+
+// starlang::XServiceInfo
+//------------------------------------------------------------------------------
+StringSequence OGridControlModel::getSupportedServiceNames() throw(staruno::RuntimeException)
+{
+ StringSequence aSupported = OControlModel::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 1);
+
+ ::rtl::OUString*pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_GRIDCONTROL;
+ return aSupported;
+}
+
+//------------------------------------------------------------------------------
+staruno::Any SAL_CALL OGridControlModel::queryAggregation( const staruno::Type& _rType ) throw (staruno::RuntimeException)
+{
+ staruno::Any aReturn =
+ ::cppu::queryInterface(_rType,
+ static_cast<starform::XGridColumnFactory*>(this),
+ static_cast<starawt::XControlModel*>(this),
+ static_cast<starview::XSelectionSupplier*>(this),
+ static_cast<starform::XReset*>(this),
+ static_cast<starform::XLoadListener*>(this),
+ static_cast<starlang::XEventListener*>(static_cast<starform::XLoadListener*>(this))
+ );
+
+ if (!aReturn.hasValue())
+ aReturn = OControlModel::queryAggregation(_rType);
+
+ if (!aReturn.hasValue())
+ aReturn = OInterfaceContainer::queryInterface(_rType);
+
+ return aReturn;
+}
+
+// starcontainer::XChild
+//------------------------------------------------------------------------------
+void SAL_CALL OGridControlModel::setParent(const InterfaceRef& Parent) throw(starlang::NoSupportException, staruno::RuntimeException)
+{
+ staruno::Reference<starform::XForm> xForm(m_xParent, staruno::UNO_QUERY);
+ staruno::Reference<starform::XLoadable> xLoadable(xForm, staruno::UNO_QUERY);
+ if (xLoadable.is())
+ xLoadable->removeLoadListener(this);
+
+ OControlModel::setParent(Parent);
+
+ xForm = staruno::Reference<starform::XForm> (m_xParent, staruno::UNO_QUERY);
+ xLoadable = staruno::Reference<starform::XLoadable> (xForm, staruno::UNO_QUERY);
+ if (xLoadable.is())
+ xLoadable->addLoadListener(this);
+}
+
+// OComponentHelper
+//------------------------------------------------------------------------------
+void OGridControlModel::disposing()
+{
+ OControlModel::disposing();
+ OInterfaceContainer::disposing();
+
+ starlang::EventObject aEvt(static_cast<staruno::XWeak*>(this));
+ m_aSelectListeners.disposeAndClear(aEvt);
+ m_aResetListeners.disposeAndClear(aEvt);
+}
+
+// starlang::XEventListener
+//------------------------------------------------------------------------------
+void OGridControlModel::disposing(const starlang::EventObject& e) throw( staruno::RuntimeException )
+{
+ OControlModel::disposing(e);
+}
+
+// starview::XSelectionSupplier
+//-----------------------------------------------------------------------------
+sal_Bool SAL_CALL OGridControlModel::select(const staruno::Any& rElement) throw(starlang::IllegalArgumentException, staruno::RuntimeException)
+{
+ staruno::Reference<starbeans::XPropertySet> xSel;
+ if (rElement.hasValue() && !::cppu::extractInterface(xSel, rElement))
+ {
+ throw starlang::IllegalArgumentException();
+ }
+ InterfaceRef xMe = static_cast<staruno::XWeak*>(this);
+
+ if (xSel.is())
+ {
+ staruno::Reference<starcontainer::XChild> xAsChild(xSel, staruno::UNO_QUERY);
+ if (!xAsChild.is() || (xAsChild->getParent() != xMe))
+ {
+ throw starlang::IllegalArgumentException();
+ }
+ }
+
+ if (xSel != m_xSelection)
+ {
+ m_xSelection = xSel;
+ starlang::EventObject aEvt(xMe);
+ NOTIFY_LISTENERS(m_aSelectListeners, starview::XSelectionChangeListener, selectionChanged, aEvt);
+ return sal_True;
+ }
+ else
+ return sal_False;
+}
+
+//-----------------------------------------------------------------------------
+staruno::Any SAL_CALL OGridControlModel::getSelection() throw(staruno::RuntimeException)
+{
+ return staruno::makeAny(m_xSelection);
+}
+
+//-----------------------------------------------------------------------------
+void OGridControlModel::addSelectionChangeListener(const staruno::Reference< starview::XSelectionChangeListener >& _rxListener) throw( staruno::RuntimeException )
+{
+ m_aSelectListeners.addInterface(_rxListener);
+}
+
+//-----------------------------------------------------------------------------
+void OGridControlModel::removeSelectionChangeListener(const staruno::Reference< starview::XSelectionChangeListener >& _rxListener) throw( staruno::RuntimeException )
+{
+ m_aSelectListeners.removeInterface(_rxListener);
+}
+
+// starform::XGridColumnFactory
+//------------------------------------------------------------------------------
+staruno::Reference<starbeans::XPropertySet> SAL_CALL OGridControlModel::createColumn(const ::rtl::OUString& ColumnType)
+{
+ const staruno::Sequence< ::rtl::OUString >& rColumnTypes = frm::getColumnTypes();
+ return createColumn(::internal::findPos(ColumnType, rColumnTypes));
+}
+
+//------------------------------------------------------------------------------
+staruno::Reference<starbeans::XPropertySet> OGridControlModel::createColumn(sal_Int32 nTypeId) const
+{
+ staruno::Reference<starbeans::XPropertySet> xReturn;
+ switch (nTypeId)
+ {
+ case TYPE_CHECKBOX: xReturn = new CheckBoxColumn(OControlModel::m_xServiceFactory); break;
+ case TYPE_COMBOBOX: xReturn = new ComboBoxColumn(OControlModel::m_xServiceFactory); break;
+ case TYPE_CURRENCYFIELD: xReturn = new CurrencyFieldColumn(OControlModel::m_xServiceFactory); break;
+ case TYPE_DATEFIELD: xReturn = new DateFieldColumn(OControlModel::m_xServiceFactory); break;
+ case TYPE_LISTBOX: xReturn = new ListBoxColumn(OControlModel::m_xServiceFactory); break;
+ case TYPE_NUMERICFIELD: xReturn = new NumericFieldColumn(OControlModel::m_xServiceFactory); break;
+ case TYPE_PATTERNFIELD: xReturn = new PatternFieldColumn(OControlModel::m_xServiceFactory); break;
+ case TYPE_TEXTFIELD: xReturn = new TextFieldColumn(OControlModel::m_xServiceFactory); break;
+ case TYPE_TIMEFIELD: xReturn = new TimeFieldColumn(OControlModel::m_xServiceFactory); break;
+ case TYPE_FORMATTEDFIELD: xReturn = new FormattedFieldColumn(OControlModel::m_xServiceFactory); break;
+ default:
+ DBG_ERROR("OGridControlModel::createColumn: Unknown Column");
+ break;
+ }
+ return xReturn;
+}
+
+//------------------------------------------------------------------------------
+StringSequence SAL_CALL OGridControlModel::getColumnTypes()
+{
+ return frm::getColumnTypes();
+}
+
+// starform::XReset
+//-----------------------------------------------------------------------------
+void SAL_CALL OGridControlModel::reset()
+{
+ ::cppu::OInterfaceIteratorHelper aIter(m_aResetListeners);
+ starlang::EventObject aEvt(static_cast<staruno::XWeak*>(this));
+ sal_Bool bContinue = sal_True;
+ while (aIter.hasMoreElements() && bContinue)
+ bContinue =((starform::XResetListener*)aIter.next())->approveReset(aEvt);
+
+ if (bContinue)
+ {
+ _reset();
+ NOTIFY_LISTENERS(m_aResetListeners, starform::XResetListener, resetted, aEvt);
+ }
+}
+
+//-----------------------------------------------------------------------------
+void SAL_CALL OGridControlModel::addResetListener(const staruno::Reference<starform::XResetListener>& _rxListener)
+{
+ m_aResetListeners.addInterface(_rxListener);
+}
+
+//-----------------------------------------------------------------------------
+void SAL_CALL OGridControlModel::removeResetListener(const staruno::Reference<starform::XResetListener>& _rxListener)
+{
+ m_aResetListeners.removeInterface(_rxListener);
+}
+
+//-----------------------------------------------------------------------------
+void OGridControlModel::_reset()
+{
+ sal_Int32 nCount = getCount();
+ for (sal_Int32 nIndex=0; nIndex < nCount; nIndex++)
+ {
+ staruno::Reference<starform::XReset> xReset;
+ ::cppu::extractInterface(xReset, getByIndex( nIndex ));
+ if (xReset.is())
+ xReset->reset();
+ }
+}
+
+// starbeans::XPropertySet
+//------------------------------------------------------------------------------
+staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL OGridControlModel::getPropertySetInfo() throw(staruno::RuntimeException)
+{
+ staruno::Reference<starbeans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OGridControlModel::getInfoHelper()
+{
+ return *const_cast<OGridControlModel*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+void OGridControlModel::fillProperties(
+ staruno::Sequence< starbeans::Property >& _rProps,
+ staruno::Sequence< starbeans::Property >& _rAggregateProps ) const
+{
+ BEGIN_AGGREGATION_PROPERTY_HELPER(29, m_xAggregateSet)
+ DECL_PROP1(NAME, ::rtl::OUString, BOUND);
+ DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT);
+ DECL_PROP1(TAG, ::rtl::OUString, BOUND);
+ DECL_PROP1(TABINDEX, sal_Int16, BOUND);
+ DECL_PROP3(TABSTOP, sal_Bool, BOUND, MAYBEDEFAULT, MAYBEVOID);
+ DECL_PROP2(HASNAVIGATION, sal_Bool, BOUND, MAYBEDEFAULT);
+ DECL_PROP1(ENABLED, sal_Bool, BOUND);
+ DECL_PROP1(BORDER, sal_Int16, BOUND);
+ DECL_PROP1(DEFAULTCONTROL, ::rtl::OUString, BOUND);
+ DECL_PROP3(TEXTCOLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID);
+ DECL_PROP3(BACKGROUNDCOLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID);
+ DECL_PROP2(FONT, starawt::FontDescriptor, BOUND, MAYBEDEFAULT);
+ DECL_PROP3(ROWHEIGHT, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID);
+ DECL_PROP1(HELPTEXT, ::rtl::OUString, BOUND);
+ DECL_PROP1(FONT_NAME, ::rtl::OUString, MAYBEDEFAULT);
+ DECL_PROP1(FONT_STYLENAME, ::rtl::OUString, MAYBEDEFAULT);
+ DECL_PROP1(FONT_FAMILY, sal_Int16, MAYBEDEFAULT);
+ DECL_PROP1(FONT_CHARSET, sal_Int16, MAYBEDEFAULT);
+ DECL_PROP1(FONT_HEIGHT, Float, MAYBEDEFAULT);
+ DECL_PROP1(FONT_WEIGHT, Float, MAYBEDEFAULT);
+ DECL_PROP1(FONT_SLANT, sal_Int16, MAYBEDEFAULT);
+ DECL_PROP1(FONT_UNDERLINE, sal_Int16, MAYBEDEFAULT);
+ DECL_PROP1(FONT_STRIKEOUT, sal_Int16, MAYBEDEFAULT);
+ DECL_PROP2(RECORDMARKER, sal_Bool, BOUND, MAYBEDEFAULT );
+ DECL_PROP2(PRINTABLE, sal_Bool, BOUND, MAYBEDEFAULT );
+ DECL_PROP4(CURSORCOLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID , TRANSIENT);
+ DECL_PROP3(ALWAYSSHOWCURSOR, sal_Bool, BOUND, MAYBEDEFAULT, TRANSIENT);
+ DECL_PROP3(DISPLAYSYNCHRON, sal_Bool, BOUND, MAYBEDEFAULT, TRANSIENT);
+ DECL_PROP2(HELPURL, ::rtl::OUString, BOUND, MAYBEDEFAULT);
+ END_AGGREGATION_PROPERTY_HELPER();
+}
+
+//------------------------------------------------------------------------------
+void OGridControlModel::getFastPropertyValue(staruno::Any& rValue, sal_Int32 nHandle ) const
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_HELPURL:
+ rValue <<= m_sHelpURL;
+ break;
+ case PROPERTY_ID_DISPLAYSYNCHRON:
+ setBOOL(rValue, m_bDisplaySynchron);
+ break;
+ case PROPERTY_ID_ALWAYSSHOWCURSOR:
+ setBOOL(rValue, m_bAlwaysShowCursor);
+ break;
+ case PROPERTY_ID_CURSORCOLOR:
+ rValue = m_aCursorColor;
+ break;
+ case PROPERTY_ID_PRINTABLE:
+ setBOOL(rValue, m_bPrintable);
+ break;
+ case PROPERTY_ID_TABSTOP:
+ rValue = m_aTabStop;
+ break;
+ case PROPERTY_ID_HASNAVIGATION:
+ setBOOL(rValue, m_bNavigation);
+ break;
+ case PROPERTY_ID_RECORDMARKER:
+ setBOOL(rValue, m_bRecordMarker);
+ break;
+ case PROPERTY_ID_ENABLED:
+ setBOOL(rValue, m_bEnable);
+ break;
+ case PROPERTY_ID_BORDER:
+ rValue <<= (sal_Int16)m_nBorder;
+ break;
+ case PROPERTY_ID_DEFAULTCONTROL:
+ rValue <<= m_aDefaultControl;
+ break;
+ case PROPERTY_ID_TEXTCOLOR:
+ rValue = m_aTextColor;
+ break;
+ case PROPERTY_ID_BACKGROUNDCOLOR:
+ rValue = m_aBackgroundColor;
+ break;
+ case PROPERTY_ID_FONT:
+ rValue = staruno::makeAny(m_aFont);
+ break;
+ case PROPERTY_ID_ROWHEIGHT:
+ rValue = m_aRowHeight;
+ break;
+ case PROPERTY_ID_FONT_NAME:
+ rValue <<= m_aFont.Name;
+ break;
+ case PROPERTY_ID_FONT_STYLENAME:
+ rValue <<= m_aFont.StyleName;
+ break;
+ case PROPERTY_ID_FONT_FAMILY:
+ rValue <<= (sal_Int16)m_aFont.Family;
+ break;
+ case PROPERTY_ID_FONT_CHARSET:
+ rValue <<= (sal_Int16)m_aFont.CharSet;
+ break;
+ case PROPERTY_ID_FONT_HEIGHT:
+ rValue <<= (float)(m_aFont.Height);
+ break;
+ case PROPERTY_ID_FONT_WEIGHT:
+ rValue <<= (float)m_aFont.Weight;
+ break;
+ case PROPERTY_ID_FONT_SLANT:
+ rValue = staruno::makeAny(m_aFont.Slant);
+ break;
+ case PROPERTY_ID_FONT_UNDERLINE:
+ rValue <<= (sal_Int16)m_aFont.Underline;
+ break;
+ case PROPERTY_ID_FONT_STRIKEOUT:
+ rValue <<= (sal_Int16)m_aFont.Strikeout;
+ break;
+ default:
+ OControlModel::getFastPropertyValue(rValue, nHandle);
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OGridControlModel::convertFastPropertyValue( staruno::Any& rConvertedValue, staruno::Any& rOldValue,
+ sal_Int32 nHandle, const staruno::Any& rValue )throw( starlang::IllegalArgumentException )
+{
+ sal_Bool bModified(sal_False);
+ switch (nHandle)
+ {
+ case PROPERTY_ID_HELPURL:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_sHelpURL);
+ break;
+ case PROPERTY_ID_DISPLAYSYNCHRON:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bDisplaySynchron);
+ break;
+ case PROPERTY_ID_ALWAYSSHOWCURSOR:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAlwaysShowCursor);
+ break;
+ case PROPERTY_ID_CURSORCOLOR:
+ if (!rValue.hasValue() || !m_aCursorColor.hasValue())
+ {
+ if (rValue.hasValue() && (staruno::TypeClass_LONG != rValue.getValueType().getTypeClass()))
+ {
+ throw starlang::IllegalArgumentException();
+ }
+ rOldValue = m_aCursorColor;
+ rConvertedValue = rValue;
+ bModified = (rOldValue.getValue() != rConvertedValue.getValue());
+ }
+ else
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, getINT32(m_aCursorColor));
+ break;
+ case PROPERTY_ID_PRINTABLE:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bPrintable);
+ break;
+ case PROPERTY_ID_TABSTOP:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aTabStop, ::getBooleanCppuType());
+ break;
+ case PROPERTY_ID_HASNAVIGATION:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bNavigation);
+ break;
+ case PROPERTY_ID_RECORDMARKER:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bRecordMarker);
+ break;
+ case PROPERTY_ID_ENABLED:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bEnable);
+ break;
+ case PROPERTY_ID_BORDER:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_nBorder);
+ break;
+ case PROPERTY_ID_DEFAULTCONTROL:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aDefaultControl);
+ break;
+ case PROPERTY_ID_TEXTCOLOR:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aTextColor, ::getCppuType((const sal_Int32*)NULL));
+ break;
+ case PROPERTY_ID_BACKGROUNDCOLOR:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aBackgroundColor, ::getCppuType((const sal_Int32*)NULL));
+ break;
+ case PROPERTY_ID_FONT:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, staruno::makeAny(m_aFont), ::getCppuType((const starawt::FontDescriptor*)NULL));
+ break;
+ case PROPERTY_ID_ROWHEIGHT:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aRowHeight, ::getCppuType((const sal_Int32*)NULL));
+ break;
+ case PROPERTY_ID_FONT_NAME:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aFont.Name);
+ break;
+ case PROPERTY_ID_FONT_STYLENAME:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aFont.StyleName);
+ break;
+ case PROPERTY_ID_FONT_FAMILY:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, (sal_Int16)m_aFont.Family);
+ break;
+ case PROPERTY_ID_FONT_CHARSET:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, (sal_Int16)m_aFont.CharSet);
+ break;
+ case PROPERTY_ID_FONT_HEIGHT:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, float(m_aFont.Height));
+ break;
+ case PROPERTY_ID_FONT_WEIGHT:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aFont.Weight);
+ break;
+ case PROPERTY_ID_FONT_SLANT:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aFont.Slant);
+ break;
+ case PROPERTY_ID_FONT_UNDERLINE:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, (sal_Int16)m_aFont.Underline);
+ break;
+ case PROPERTY_ID_FONT_STRIKEOUT:
+ bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, (sal_Int16)m_aFont.Strikeout);
+ break;
+ default:
+ bModified = OControlModel::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue);
+ }
+ return bModified;
+}
+
+//------------------------------------------------------------------------------
+void OGridControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const staruno::Any& rValue )
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_HELPURL:
+ rValue >>= m_sHelpURL;
+ break;
+ case PROPERTY_ID_DISPLAYSYNCHRON:
+ m_bDisplaySynchron = getBOOL(rValue);
+ break;
+ case PROPERTY_ID_ALWAYSSHOWCURSOR:
+ m_bAlwaysShowCursor = getBOOL(rValue);
+ break;
+ case PROPERTY_ID_CURSORCOLOR:
+ m_aCursorColor = rValue;
+ break;
+ case PROPERTY_ID_PRINTABLE:
+ m_bPrintable = getBOOL(rValue);
+ break;
+ case PROPERTY_ID_TABSTOP:
+ m_aTabStop = rValue;
+ break;
+ case PROPERTY_ID_HASNAVIGATION:
+ m_bNavigation = getBOOL(rValue);
+ break;
+ case PROPERTY_ID_ENABLED:
+ m_bEnable = getBOOL(rValue);
+ break;
+ case PROPERTY_ID_RECORDMARKER:
+ m_bRecordMarker = getBOOL(rValue);
+ break;
+ case PROPERTY_ID_BORDER:
+ rValue >>= m_nBorder;
+ break;
+ case PROPERTY_ID_DEFAULTCONTROL:
+ rValue >>= m_aDefaultControl;
+ break;
+ case PROPERTY_ID_TEXTCOLOR:
+ m_aTextColor = rValue;
+ break;
+ case PROPERTY_ID_BACKGROUNDCOLOR:
+ m_aBackgroundColor = rValue;
+ break;
+ case PROPERTY_ID_FONT:
+ rValue >>= m_aFont;
+ break;
+ case PROPERTY_ID_FONT_NAME:
+ rValue >>= m_aFont.Name;
+ break;
+ case PROPERTY_ID_FONT_STYLENAME:
+ rValue >>= m_aFont.StyleName;
+ break;
+ case PROPERTY_ID_FONT_FAMILY:
+ m_aFont.Family = getINT16(rValue);
+ break;
+ case PROPERTY_ID_FONT_CHARSET:
+ m_aFont.CharSet = getINT16(rValue);
+ break;
+ case PROPERTY_ID_FONT_HEIGHT:
+ m_aFont.Height = sal_Int16(getFloat(rValue));
+ break;
+ case PROPERTY_ID_FONT_WEIGHT:
+ rValue >>= m_aFont.Weight;
+ break;
+ case PROPERTY_ID_FONT_SLANT:
+ rValue >>= m_aFont.Slant;
+ break;
+ case PROPERTY_ID_FONT_UNDERLINE:
+ m_aFont.Underline = getINT16(rValue);
+ break;
+ case PROPERTY_ID_FONT_STRIKEOUT:
+ m_aFont.Strikeout = getINT16(rValue);
+ break;
+ case PROPERTY_ID_ROWHEIGHT:
+ m_aRowHeight = rValue;
+ break;
+ default:
+ OControlModel::setFastPropertyValue_NoBroadcast(nHandle, rValue );
+ }
+
+ switch (nHandle)
+ {
+ case PROPERTY_ID_FONT:
+ if (m_nFontEvent)
+ {
+ Application::RemoveUserEvent(m_nFontEvent);
+ m_nFontEvent = 0;
+ }
+ break;
+ case PROPERTY_ID_FONT_NAME:
+ case PROPERTY_ID_FONT_STYLENAME:
+ case PROPERTY_ID_FONT_FAMILY:
+ case PROPERTY_ID_FONT_CHARSET:
+ case PROPERTY_ID_FONT_HEIGHT:
+ case PROPERTY_ID_FONT_WEIGHT:
+ case PROPERTY_ID_FONT_SLANT:
+ case PROPERTY_ID_FONT_UNDERLINE:
+ case PROPERTY_ID_FONT_STRIKEOUT:
+ if (m_nFontEvent)
+ Application::RemoveUserEvent(m_nFontEvent);
+ m_nFontEvent = Application::PostUserEvent( LINK(this, OGridControlModel, OnFontChanged) );
+ break;
+ }
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OGridControlModel, OnFontChanged, void*, EMPTYARG )
+{
+ staruno::Any aOldVal;
+ aOldVal >>= m_aOldFont;
+ staruno::Any aNewVal;
+ aNewVal >>= m_aFont;
+ {
+ ::osl::MutexGuard aGuard(m_aMutex);
+ m_nFontEvent = 0;
+ m_aOldFont = m_aFont;
+ }
+ firePropertyChange(PROPERTY_ID_FONT, aNewVal, aOldVal);
+ return 1;
+}
+
+//XPropertyState
+//------------------------------------------------------------------------------
+starbeans::PropertyState OGridControlModel::getPropertyStateByHandle(sal_Int32 nHandle)
+{
+ starbeans::PropertyState eState(starbeans::PropertyState_DIRECT_VALUE);
+ switch (nHandle)
+ {
+ case PROPERTY_ID_HELPURL:
+ if (m_sHelpURL.getLength() == 0)
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ break;
+ case PROPERTY_ID_DISPLAYSYNCHRON:
+ if (m_bDisplaySynchron)
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ break;
+ case PROPERTY_ID_ALWAYSSHOWCURSOR:
+ if (!m_bAlwaysShowCursor)
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ break;
+ case PROPERTY_ID_CURSORCOLOR:
+ if (!m_aCursorColor.hasValue())
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ break;
+ case PROPERTY_ID_PRINTABLE:
+ if (m_bPrintable)
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ break;
+ case PROPERTY_ID_HASNAVIGATION:
+ if (m_bNavigation)
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ break;
+ case PROPERTY_ID_RECORDMARKER:
+ if (m_bRecordMarker)
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ break;
+ case PROPERTY_ID_TABSTOP:
+ if (!m_aTabStop.hasValue())
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ break;
+ case PROPERTY_ID_TEXTCOLOR:
+ if (!m_aTextColor.hasValue())
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ break;
+ case PROPERTY_ID_BACKGROUNDCOLOR:
+ if (!m_aBackgroundColor.hasValue())
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ break;
+ case PROPERTY_ID_FONT_NAME:
+ if (!m_aFont.Name.len())
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ break;
+ case PROPERTY_ID_FONT_STYLENAME:
+ if (!m_aFont.StyleName.len())
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ break;
+ case PROPERTY_ID_FONT_FAMILY:
+ if (!m_aFont.Family)
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ break;
+ case PROPERTY_ID_FONT_CHARSET:
+ if (!m_aFont.CharSet)
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ break;
+ case PROPERTY_ID_FONT_HEIGHT:
+ if (!m_aFont.Height)
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ break;
+ case PROPERTY_ID_FONT_WEIGHT:
+ if (!m_aFont.Weight)
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ break;
+ case PROPERTY_ID_FONT_SLANT:
+ if (m_aFont.Slant == starawt::FontSlant_NONE)
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ break;
+ case PROPERTY_ID_FONT_UNDERLINE:
+ if (!m_aFont.Underline)
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ break;
+ case PROPERTY_ID_FONT_STRIKEOUT:
+ if (!m_aFont.Strikeout)
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ break;
+ case PROPERTY_ID_ROWHEIGHT:
+ if (!m_aRowHeight.hasValue())
+ eState = starbeans::PropertyState_DEFAULT_VALUE;
+ break;
+ default:
+ eState = OControlModel::getPropertyStateByHandle(nHandle);
+ }
+ return eState;
+}
+
+//------------------------------------------------------------------------------
+void OGridControlModel::setPropertyToDefaultByHandle(sal_Int32 nHandle)
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_ALWAYSSHOWCURSOR:
+ setFastPropertyValue(nHandle, makeBoolAny(sal_False));
+ break;
+ break;
+ case PROPERTY_ID_PRINTABLE:
+ case PROPERTY_ID_HASNAVIGATION:
+ case PROPERTY_ID_RECORDMARKER:
+ case PROPERTY_ID_DISPLAYSYNCHRON:
+ setFastPropertyValue(nHandle, makeBoolAny(sal_True));
+ break;
+ case PROPERTY_ID_TABSTOP:
+ case PROPERTY_ID_TEXTCOLOR:
+ case PROPERTY_ID_BACKGROUNDCOLOR:
+ case PROPERTY_ID_ROWHEIGHT:
+ case PROPERTY_ID_CURSORCOLOR:
+ setFastPropertyValue(nHandle, staruno::Any());
+ break;
+ case PROPERTY_ID_HELPURL:
+ case PROPERTY_ID_FONT_NAME:
+ case PROPERTY_ID_FONT_STYLENAME:
+ setFastPropertyValue(nHandle, staruno::makeAny(::rtl::OUString()));
+ break;
+ case PROPERTY_ID_FONT_FAMILY:
+ case PROPERTY_ID_FONT_CHARSET:
+ case PROPERTY_ID_FONT_SLANT:
+ case PROPERTY_ID_FONT_UNDERLINE:
+ case PROPERTY_ID_FONT_STRIKEOUT:
+ {
+ staruno::Any aVal;
+ aVal <<= (sal_Int16)0;
+ setFastPropertyValue(nHandle, aVal);
+ } break;
+ case PROPERTY_ID_FONT_HEIGHT:
+ setFastPropertyValue(nHandle, staruno::makeAny((float)0));
+ break;
+ case PROPERTY_ID_FONT_WEIGHT:
+ setFastPropertyValue(nHandle, staruno::makeAny((float)0));
+ break;
+ default:
+ OControlModel::setPropertyToDefaultByHandle(nHandle);
+ }
+}
+
+//------------------------------------------------------------------------------
+staruno::Any OGridControlModel::getPropertyDefaultByHandle( sal_Int32 nHandle )
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_PRINTABLE:
+ case PROPERTY_ID_HASNAVIGATION:
+ case PROPERTY_ID_RECORDMARKER:
+ return makeBoolAny(sal_True);
+ case PROPERTY_ID_TABSTOP:
+ case PROPERTY_ID_TEXTCOLOR:
+ case PROPERTY_ID_BACKGROUNDCOLOR:
+ case PROPERTY_ID_ROWHEIGHT:
+ return staruno::Any();
+ case PROPERTY_ID_FONT_NAME:
+ case PROPERTY_ID_FONT_STYLENAME:
+ return staruno::makeAny(::rtl::OUString());
+ case PROPERTY_ID_FONT_FAMILY:
+ case PROPERTY_ID_FONT_CHARSET:
+ case PROPERTY_ID_FONT_SLANT:
+ case PROPERTY_ID_FONT_UNDERLINE:
+ case PROPERTY_ID_FONT_STRIKEOUT:
+ return staruno::makeAny((sal_Int16)0);
+ case PROPERTY_ID_FONT_HEIGHT:
+ return staruno::makeAny((float)0);
+ case PROPERTY_ID_FONT_WEIGHT:
+ return staruno::makeAny((float)0);
+ default:
+ return OControlModel::getPropertyDefaultByHandle(nHandle);
+ }
+}
+
+// starform::XLoadListener
+//------------------------------------------------------------------------------
+void SAL_CALL OGridControlModel::loaded(const starlang::EventObject& rEvent) throw(staruno::RuntimeException)
+{
+ sal_Int32 nCount = getCount();
+ for (sal_Int32 nIndex=0; nIndex < nCount; ++nIndex)
+ {
+ // staruno::Any aElement(getByIndex( nIndex ));
+ staruno::Reference<starform::XLoadListener> xListener;
+ ::cppu::extractInterface(xListener, getByIndex(nIndex));
+ if (xListener.is())
+ xListener->loaded(rEvent);
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OGridControlModel::unloaded(const starlang::EventObject& rEvent) throw(staruno::RuntimeException)
+{
+ sal_Int32 nCount = getCount();
+ for (sal_Int32 nIndex=0; nIndex < nCount; nIndex++)
+ {
+ staruno::Reference<starform::XLoadListener> xListener;
+ ::cppu::extractInterface(xListener, getByIndex(nIndex));
+ if (xListener.is())
+ xListener->unloaded(rEvent);
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OGridControlModel::reloading(const starlang::EventObject& rEvent) throw(staruno::RuntimeException)
+{
+ sal_Int32 nCount = getCount();
+ for (sal_Int32 nIndex=0; nIndex < nCount; nIndex++)
+ {
+ staruno::Reference<starform::XLoadListener> xListener;
+ ::cppu::extractInterface(xListener, getByIndex(nIndex));
+ if (xListener.is())
+ xListener->reloading(rEvent);
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OGridControlModel::unloading(const starlang::EventObject& rEvent) throw(staruno::RuntimeException)
+{
+ sal_Int32 nCount = getCount();
+ for (sal_Int32 nIndex=0; nIndex < nCount; nIndex++)
+ {
+ staruno::Reference<starform::XLoadListener> xListener;
+ ::cppu::extractInterface(xListener, getByIndex(nIndex));
+ if (xListener.is())
+ xListener->unloading(rEvent);
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OGridControlModel::reloaded(const starlang::EventObject& rEvent) throw(staruno::RuntimeException)
+{
+ sal_Int32 nCount = getCount();
+ for (sal_Int32 nIndex=0; nIndex < nCount; nIndex++)
+ {
+ staruno::Reference<starform::XLoadListener> xListener;
+ ::cppu::extractInterface(xListener, getByIndex(nIndex));
+ if (xListener.is())
+ xListener->reloaded(rEvent);
+ }
+}
+
+//------------------------------------------------------------------------------
+OGridColumn* OGridControlModel::getColumnImplementation(const InterfaceRef& _rxIFace) const
+{
+ OGridColumn* pImplementation = NULL;
+ staruno::Reference<starlang::XUnoTunnel> xUnoTunnel(_rxIFace, staruno::UNO_QUERY);
+ if (xUnoTunnel.is())
+ pImplementation = reinterpret_cast<OGridColumn*>(xUnoTunnel->getSomething(OGridColumn::getUnoTunnelImplementationId()));
+
+ return pImplementation;
+}
+
+//------------------------------------------------------------------------------
+void OGridControlModel::insert(sal_Int32 _nIndex, const InterfaceRef& xElement, sal_Bool bEvents) throw( starlang::IllegalArgumentException )
+{
+ OGridColumn* pCol = getColumnImplementation(xElement);
+ if (!pCol)
+ {
+ throw starlang::IllegalArgumentException();
+ }
+ OInterfaceContainer::insert(_nIndex, xElement, bEvents);
+}
+
+// stario::XPersistObject
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OGridControlModel::getServiceName()
+{
+ return FRM_COMPONENT_GRID; // old (non-sun) name for compatibility !
+}
+
+//------------------------------------------------------------------------------
+void OGridControlModel::write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream)
+{
+ OControlModel::write(_rxOutStream);
+
+ staruno::Reference<stario::XMarkableStream> xMark(_rxOutStream, staruno::UNO_QUERY);
+
+ // 1. Version
+ _rxOutStream->writeShort(0x0008);
+
+ // 2. Columns
+ sal_Int32 nLen = getCount();
+ _rxOutStream->writeLong(nLen);
+ OGridColumn* pCol;
+ for (sal_Int32 i = 0; i < nLen; i++)
+ {
+ // zuerst den Servicenamen fuer das darunterliegende Model
+ pCol = getColumnImplementation(m_aItems[i]);
+ DBG_ASSERT(pCol != NULL, "OGridControlModel::write : such items should never reach it into my container !");
+
+ _rxOutStream << pCol->getModelName();
+
+ // dann das Object selbst
+ sal_Int32 nMark = xMark->createMark();
+ sal_Int32 nObjLen = 0;
+ _rxOutStream->writeLong(nObjLen);
+
+ // schreiben der Col
+ pCol->write(_rxOutStream);
+
+ // feststellen der Laenge
+ nObjLen = xMark->offsetToMark(nMark) - 4;
+ xMark->jumpToMark(nMark);
+ _rxOutStream->writeLong(nObjLen);
+ xMark->jumpToFurthest();
+ xMark->deleteMark(nMark);
+ }
+
+ // 3. Events
+ writeEvents(_rxOutStream);
+
+ // 4. Attribute
+ // Maskierung fuer alle any Typen
+ sal_uInt16 nAnyMask = 0;
+ if (m_aRowHeight.getValueType().getTypeClass() == staruno::TypeClass_LONG)
+ nAnyMask |= ROWHEIGHT;
+ if (!(m_aFont == getDefaultFont())) // have no !=, only a ==
+ nAnyMask |= FONTATTRIBS | FONTSIZE | FONTTYPE | FONTDESCRIPTOR;
+ if (m_aTabStop.getValueType().getTypeClass() == staruno::TypeClass_BOOLEAN)
+ nAnyMask |= TABSTOP;
+ if (m_aTextColor.getValueType().getTypeClass() == staruno::TypeClass_LONG)
+ nAnyMask |= TEXTCOLOR;
+ if (m_aBackgroundColor.getValueType().getTypeClass() == staruno::TypeClass_LONG)
+ nAnyMask |= BACKGROUNDCOLOR;
+ if (!m_bRecordMarker)
+ nAnyMask |= RECORDMARKER;
+
+ _rxOutStream->writeShort(nAnyMask);
+
+ if (nAnyMask & ROWHEIGHT)
+ _rxOutStream->writeLong(getINT32(m_aRowHeight));
+
+ // alte Structuren
+ if (nAnyMask & FONTDESCRIPTOR)
+ {
+ // Attrib
+ _rxOutStream->writeShort( VCLUnoHelper::ConvertFontWeight( m_aFont.Weight ) );
+ _rxOutStream->writeShort( m_aFont.Slant );
+ _rxOutStream->writeShort( m_aFont.Underline );
+ _rxOutStream->writeShort( m_aFont.Strikeout );
+ _rxOutStream->writeShort( m_aFont.Orientation * 10 );
+ _rxOutStream->writeBoolean( m_aFont.Kerning );
+ _rxOutStream->writeBoolean( m_aFont.WordLineMode );
+
+ // starawt::Size
+ _rxOutStream->writeLong( m_aFont.Width );
+ _rxOutStream->writeLong( m_aFont.Height );
+ _rxOutStream->writeShort( VCLUnoHelper::ConvertFontWidth( m_aFont.CharacterWidth ) );
+
+ // Type
+ _rxOutStream->writeUTF( m_aFont.Name );
+ _rxOutStream->writeUTF( m_aFont.StyleName );
+ _rxOutStream->writeShort( m_aFont.Family );
+ _rxOutStream->writeShort( m_aFont.CharSet );
+ _rxOutStream->writeShort( m_aFont.Pitch );
+ }
+
+ _rxOutStream << m_aDefaultControl;
+ _rxOutStream->writeShort(m_nBorder);
+ _rxOutStream->writeBoolean(m_bEnable);
+
+ if (nAnyMask & TABSTOP)
+ _rxOutStream->writeBoolean(getBOOL(m_aTabStop));
+
+ _rxOutStream->writeBoolean(m_bNavigation);
+
+ if (nAnyMask & TEXTCOLOR)
+ _rxOutStream->writeLong(getINT32(m_aTextColor));
+
+ // neu ab Version 6
+ _rxOutStream << m_aHelpText;
+
+ if (nAnyMask & FONTDESCRIPTOR)
+ _rxOutStream << m_aFont;
+
+ if (nAnyMask & RECORDMARKER)
+ _rxOutStream->writeBoolean(m_bRecordMarker);
+
+ // neu ab Version 7
+ _rxOutStream->writeBoolean(m_bPrintable);
+
+ // new since 8
+ if (nAnyMask & BACKGROUNDCOLOR)
+ _rxOutStream->writeLong(getINT32(m_aBackgroundColor));
+}
+
+//------------------------------------------------------------------------------
+void OGridControlModel::read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream)
+{
+ OControlModel::read(_rxInStream);
+
+ staruno::Reference<stario::XMarkableStream> xMark(_rxInStream, staruno::UNO_QUERY);
+
+ // 1. Version
+ sal_Int16 nVersion = _rxInStream->readShort();
+
+ // 2. Einlesen der Spalten
+ sal_Int32 nLen = _rxInStream->readLong();
+ if (nLen)
+ {
+ for (sal_Int32 i = 0; i < nLen; i++)
+ {
+ // Lesen des Modelnamen
+
+ ::rtl::OUString sModelName;
+ _rxInStream >> sModelName;
+
+ staruno::Reference<starbeans::XPropertySet> xCol(createColumn(getColumnTypeByModelName(sModelName)));
+ DBG_ASSERT(xCol.is(), "OGridControlModel::read : unknown column type !");
+ sal_Int32 nObjLen = _rxInStream->readLong();
+ if (nObjLen)
+ {
+ sal_Int32 nMark = xMark->createMark();
+ if (xCol.is())
+ {
+ OGridColumn* pCol = getColumnImplementation(xCol);
+ pCol->read(_rxInStream);
+ }
+ xMark->jumpToMark(nMark);
+ _rxInStream->skipBytes(nObjLen);
+ xMark->deleteMark(nMark);
+ }
+
+ if (xCol.is())
+ insert(i, xCol, sal_False);
+ }
+ }
+
+ // In der Basisimplementierung werden die Events nur gelesen, Elemente im Container existieren
+ // da aber vor TF_ONE fuer das GridControl immer Events geschrieben wurden, muessen sie auch immer
+ // mit gelesen werden
+ sal_Int32 nObjLen = _rxInStream->readLong();
+ if (nObjLen)
+ {
+ sal_Int32 nMark = xMark->createMark();
+ staruno::Reference<stario::XPersistObject> xObj(m_xEventAttacher, staruno::UNO_QUERY);
+ if (xObj.is())
+ xObj->read(_rxInStream);
+ xMark->jumpToMark(nMark);
+ _rxInStream->skipBytes(nObjLen);
+ xMark->deleteMark(nMark);
+ }
+
+ // Attachement lesen
+ for (sal_Int32 i = 0; i < nLen; i++)
+ {
+ InterfaceRef xIfc(m_aItems[i], staruno::UNO_QUERY);
+ staruno::Reference<starbeans::XPropertySet> xSet(xIfc, staruno::UNO_QUERY);
+ staruno::Any aHelper;
+ aHelper <<= xSet;
+ m_xEventAttacher->attach( i, xIfc, aHelper );
+ }
+
+ // 4. Einlesen der Attribute
+ if (nVersion == 1)
+ return;
+
+ // Maskierung fuer any
+ sal_uInt16 nAnyMask = _rxInStream->readShort();
+
+ if (nAnyMask & ROWHEIGHT)
+ {
+ sal_Int32 nValue = _rxInStream->readLong();
+ m_aRowHeight <<= (sal_Int32)nValue;
+ }
+
+ if (nAnyMask & FONTATTRIBS)
+ {
+ m_aFont.Weight = VCLUnoHelper::ConvertFontWeight( _rxInStream->readShort() );
+
+ m_aFont.Slant = (starawt::FontSlant)_rxInStream->readShort();
+ m_aFont.Underline = _rxInStream->readShort();
+ m_aFont.Strikeout = _rxInStream->readShort();
+ m_aFont.Orientation = ( (double)_rxInStream->readShort() ) / 10;
+ m_aFont.Kerning = _rxInStream->readBoolean();
+ m_aFont.WordLineMode = _rxInStream->readBoolean();
+ }
+ if (nAnyMask & FONTSIZE)
+ {
+ m_aFont.Width = _rxInStream->readLong();
+ m_aFont.Height = _rxInStream->readLong();
+ m_aFont.CharacterWidth = VCLUnoHelper::ConvertFontWidth( _rxInStream->readShort() );
+ }
+ if (nAnyMask & FONTTYPE)
+ {
+ m_aFont.Name = _rxInStream->readUTF();
+ m_aFont.StyleName = _rxInStream->readUTF();
+ m_aFont.Family = _rxInStream->readShort();
+ m_aFont.CharSet = _rxInStream->readShort();
+ m_aFont.Pitch = _rxInStream->readShort();
+ }
+
+ // Name
+ _rxInStream >> m_aDefaultControl;
+ m_nBorder = _rxInStream->readShort();
+ m_bEnable = _rxInStream->readBoolean();
+
+ if (nAnyMask & TABSTOP)
+ {
+ m_aTabStop = makeBoolAny(_rxInStream->readBoolean());
+ }
+
+ if (nVersion > 3)
+ m_bNavigation = _rxInStream->readBoolean();
+
+ if (nAnyMask & TEXTCOLOR)
+ {
+ sal_Int32 nValue = _rxInStream->readLong();
+ m_aTextColor <<= (sal_Int32)nValue;
+ }
+
+ // neu ab Version 6
+ if (nVersion > 5)
+ _rxInStream >> m_aHelpText;
+
+ if (nAnyMask & FONTDESCRIPTOR)
+ {
+ _rxInStream >> m_aFont;
+ }
+
+ m_aOldFont = m_aFont;
+
+ if (nAnyMask & RECORDMARKER)
+ m_bRecordMarker = _rxInStream->readBoolean();
+
+ // neu ab Version 7
+ if (nVersion > 6)
+ m_bPrintable = _rxInStream->readBoolean();
+
+ if (nAnyMask & BACKGROUNDCOLOR)
+ {
+ sal_Int32 nValue = _rxInStream->readLong();
+ m_aBackgroundColor <<= (sal_Int32)nValue;
+ }
+}
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
diff --git a/forms/source/component/Grid.hxx b/forms/source/component/Grid.hxx
new file mode 100644
index 000000000000..9296506c1151
--- /dev/null
+++ b/forms/source/component/Grid.hxx
@@ -0,0 +1,228 @@
+/*************************************************************************
+ *
+ * $RCSfile: Grid.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_FORMCOMPONENT_HXX_
+#include "FormComponent.hxx"
+#endif
+
+#ifndef _COM_SUN_STAR_FORM_XLOADLISTENER_HPP_
+#include <com/sun/star/form/XLoadListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XGRIDCOLUMNFACTORY_HPP_
+#include <com/sun/star/form/XGridColumnFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_VIEW_XSELECTIONSUPPLIER_HPP_
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#endif
+
+#ifndef _LINK_HXX
+#include <tools/link.hxx>
+#endif
+
+#ifndef _FRM_INTERFACE_CONTAINER_HXX_
+#include "InterfaceContainer.hxx"
+#endif
+
+#ifndef _UNOTOOLS_PROPERTY_ARRAY_HELPER_HXX_
+#include <unotools/proparrhlp.hxx>
+#endif
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+ namespace starview = ::com::sun::star::view;
+
+//==================================================================
+// OGridControlModel
+//==================================================================
+class OGridColumn;
+class OGridControlModel :public OControlModel
+ ,public OInterfaceContainer
+ ,public OAggregationArrayUsageHelper<OGridControlModel>
+ // though we don't use aggregation, we're derived from an OPropertySetAggregationHelper,
+ // which expects that we use an OPropertyArrayAggregationHelper, which we ensure
+ // with deriving from OAggregationArrayUsageHelper
+ ,public starawt::XControlModel
+ ,public starform::XGridColumnFactory
+ ,public starform::XLoadListener
+ ,public starform::XReset
+ ,public starview::XSelectionSupplier
+{
+ ::cppu::OInterfaceContainerHelper
+ m_aSelectListeners,
+ m_aResetListeners;
+
+ staruno::Reference<starbeans::XPropertySet> m_xSelection;
+
+ sal_uInt32 m_nFontEvent;
+
+// [properties]
+ ::rtl::OUString m_aDefaultControl;
+ staruno::Any m_aRowHeight; // Zeilenhoehe
+ staruno::Any m_aTabStop;
+ staruno::Any m_aTextColor;
+ staruno::Any m_aBackgroundColor;
+ starawt::FontDescriptor m_aFont;
+ starawt::FontDescriptor m_aOldFont;
+ sal_Int16 m_nBorder;
+ sal_Bool m_bEnable : 1;
+ sal_Bool m_bNavigation : 1;
+ sal_Bool m_bRecordMarker : 1;
+ sal_Bool m_bPrintable : 1;
+ sal_Bool m_bAlwaysShowCursor : 1; // transient
+ sal_Bool m_bDisplaySynchron : 1; // transient
+ staruno::Any m_aCursorColor; // transient
+ ::rtl::OUString m_sHelpURL; // URL
+// [properties]
+
+protected:
+ virtual staruno::Sequence<staruno::Type> _getTypes();
+ void _reset();
+
+public:
+ OGridControlModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+
+ virtual ~OGridControlModel();
+
+// UNO Anbindung
+ DECLARE_UNO3_AGG_DEFAULTS(OGridControlModel, OControlModel);
+ virtual staruno::Any SAL_CALL queryAggregation( const staruno::Type& _rType ) throw (staruno::RuntimeException);
+
+// starcontainer::XChild
+ virtual void SAL_CALL setParent(const InterfaceRef& Parent) throw(starlang::NoSupportException, staruno::RuntimeException);
+
+// starlang::XServiceInfo
+ IMPLEMENTATION_NAME(OGridControlModel);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw(staruno::RuntimeException);
+
+// OComponentHelper
+ virtual void SAL_CALL disposing();
+
+// starlang::XEventListener
+ virtual void SAL_CALL disposing(const starlang::EventObject& _rSource) throw(staruno::RuntimeException);
+
+// starform::XLoadListener
+ virtual void SAL_CALL loaded(const starlang::EventObject& aEvent) throw(staruno::RuntimeException);
+ virtual void SAL_CALL unloaded(const starlang::EventObject& aEvent) throw(staruno::RuntimeException);
+ virtual void SAL_CALL unloading(const starlang::EventObject& aEvent) throw(staruno::RuntimeException);
+ virtual void SAL_CALL reloading(const starlang::EventObject& aEvent) throw(staruno::RuntimeException);
+ virtual void SAL_CALL reloaded(const starlang::EventObject& aEvent) throw(staruno::RuntimeException);
+
+// starform::XReset
+ virtual void SAL_CALL reset();
+ virtual void SAL_CALL addResetListener(const staruno::Reference<starform::XResetListener>& _rxListener);
+ virtual void SAL_CALL removeResetListener(const staruno::Reference<starform::XResetListener>& _rxListener);
+
+// ::com::sun::star::view::XSelectionSupplier
+ virtual sal_Bool SAL_CALL select(const staruno::Any& aElement) throw(starlang::IllegalArgumentException, staruno::RuntimeException);
+ virtual staruno::Any SAL_CALL getSelection() throw(staruno::RuntimeException);
+ virtual void SAL_CALL addSelectionChangeListener(const staruno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener) throw(staruno::RuntimeException);
+ virtual void SAL_CALL removeSelectionChangeListener(const staruno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener) throw(staruno::RuntimeException);
+
+// starform::XGridColumnFactory
+ virtual staruno::Reference<starbeans::XPropertySet> SAL_CALL createColumn(const ::rtl::OUString& ColumnType);
+ virtual StringSequence SAL_CALL getColumnTypes();
+
+// stario::XPersistObject
+ virtual ::rtl::OUString SAL_CALL getServiceName();
+ virtual void SAL_CALL write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream);
+ virtual void SAL_CALL read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream);
+
+// starbeans::XPropertySet
+ virtual staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(staruno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+ virtual void SAL_CALL getFastPropertyValue(staruno::Any& rValue, sal_Int32 nHandle ) const;
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(staruno::Any& rConvertedValue, staruno::Any& rOldValue,
+ sal_Int32 nHandle, const staruno::Any& rValue )
+ throw(starlang::IllegalArgumentException);
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const staruno::Any& rValue);
+
+// starbeans::XPropertyState
+ virtual starbeans::PropertyState getPropertyStateByHandle(sal_Int32 nHandle);
+ virtual void setPropertyToDefaultByHandle(sal_Int32 nHandle);
+ virtual staruno::Any getPropertyDefaultByHandle( sal_Int32 nHandle );
+
+// OAggregationArrayUsageHelper
+ virtual void fillProperties(
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rProps,
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rAggregateProps
+ ) const;
+ IMPLEMENT_INFO_SERVICE()
+
+protected:
+ virtual void insert(sal_Int32 _nIndex, const InterfaceRef& _Object, sal_Bool bEvents)
+ throw(starlang::IllegalArgumentException);
+
+ staruno::Reference<starbeans::XPropertySet> createColumn(sal_Int32 nTypeId) const;
+
+ OGridColumn* getColumnImplementation(const InterfaceRef& _rxIFace) const;
+
+private:
+ DECL_LINK( OnFontChanged, void* );
+};
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
+
diff --git a/forms/source/component/GroupBox.cxx b/forms/source/component/GroupBox.cxx
new file mode 100644
index 000000000000..2b2f452b87fd
--- /dev/null
+++ b/forms/source/component/GroupBox.cxx
@@ -0,0 +1,211 @@
+/*************************************************************************
+ *
+ * $RCSfile: GroupBox.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_GROUPBOX_HXX_
+#include "GroupBox.hxx"
+#endif
+#ifndef _FRM_PROPERTY_HXX_
+#include "property.hxx"
+#endif
+#ifndef _FRM_PROPERTY_HRC_
+#include "property.hrc"
+#endif
+#ifndef _FRM_SERVICES_HXX_
+#include "services.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+//.........................................................................
+namespace frm
+{
+
+//==================================================================
+// OGroupBoxModel
+//==================================================================
+
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OGroupBoxModel_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory) throw (staruno::RuntimeException)
+{
+ return *(new OGroupBoxModel(_rxFactory));
+}
+
+//------------------------------------------------------------------
+OGroupBoxModel::OGroupBoxModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OControlModel(_rxFactory, VCL_CONTROLMODEL_GROUPBOX, VCL_CONTROL_GROUPBOX)
+{
+ m_nClassId = starform::FormComponentType::GROUPBOX;
+}
+
+// XServiceInfo
+//------------------------------------------------------------------------------
+StringSequence SAL_CALL OGroupBoxModel::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException)
+{
+ StringSequence aSupported = OControlModel::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 1);
+
+ ::rtl::OUString* pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_GROUPBOX;
+ return aSupported;
+}
+
+//------------------------------------------------------------------
+OGroupBoxModel::~OGroupBoxModel()
+{
+}
+
+//------------------------------------------------------------------------------
+staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL OGroupBoxModel::getPropertySetInfo() throw(staruno::RuntimeException)
+{
+ staruno::Reference<starbeans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//------------------------------------------------------------------------------
+cppu::IPropertyArrayHelper& OGroupBoxModel::getInfoHelper()
+{
+ return *const_cast<OGroupBoxModel*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+void OGroupBoxModel::fillProperties(
+ staruno::Sequence< starbeans::Property >& _rProps,
+ staruno::Sequence< starbeans::Property >& _rAggregateProps ) const
+{
+ FRM_BEGIN_PROP_HELPER(4)
+ // don't want to have the TabStop property
+ RemoveProperty(_rAggregateProps, PROPERTY_TABSTOP);
+
+ DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT);
+ DECL_PROP1(NAME, ::rtl::OUString, BOUND);
+ DECL_PROP1(TAG, ::rtl::OUString, BOUND);
+ DECL_PROP1(HELPTEXT, ::rtl::OUString, BOUND);
+ FRM_END_PROP_HELPER();
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OGroupBoxModel::getServiceName() throw(staruno::RuntimeException)
+{
+ return FRM_COMPONENT_GROUPBOX; // old (non-sun) name for compatibility !
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OGroupBoxModel::write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream)
+ throw(stario::IOException, staruno::RuntimeException)
+{
+ OControlModel::write(_rxOutStream);
+
+ // Version
+ _rxOutStream->writeShort(0x0002);
+ _rxOutStream << m_aHelpText;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OGroupBoxModel::read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream) throw(stario::IOException, staruno::RuntimeException)
+{
+ OControlModel::read( _rxInStream );
+
+ // Version
+ sal_uInt16 nVersion = _rxInStream->readShort();
+ DBG_ASSERT(nVersion > 0, "OGroupBoxModel::read : version 0 ? this should never have been written !");
+ // ups, ist das Englisch richtig ? ;)
+
+ if (nVersion == 2)
+ _rxInStream >> m_aHelpText;
+
+ if (nVersion > 0x0002)
+ {
+ DBG_ERROR("OGroupBoxModel::read : unknown version !");
+ }
+};
+
+//==================================================================
+// OGroupBoxControl
+//==================================================================
+
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OGroupBoxControl_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory) throw (staruno::RuntimeException)
+{
+ return *(new OGroupBoxControl(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+OGroupBoxControl::OGroupBoxControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OControl(_rxFactory, VCL_CONTROL_GROUPBOX)
+{
+}
+
+//------------------------------------------------------------------------------
+StringSequence SAL_CALL OGroupBoxControl::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException)
+{
+ StringSequence aSupported = OControl::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 1);
+
+ ::rtl::OUString* pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_GROUPBOX;
+ return aSupported;
+}
+
+//.........................................................................
+}
+//.........................................................................
+
diff --git a/forms/source/component/GroupBox.hxx b/forms/source/component/GroupBox.hxx
new file mode 100644
index 000000000000..62ec04576797
--- /dev/null
+++ b/forms/source/component/GroupBox.hxx
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * $RCSfile: GroupBox.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_GROUPBOX_HXX_
+#define _FORMS_GROUPBOX_HXX_
+
+#ifndef _FORMS_FORMCOMPONENT_HXX_
+#include "FormComponent.hxx"
+#endif
+
+//.........................................................................
+namespace frm
+{
+
+//==================================================================
+// OGroupBoxModel
+//==================================================================
+class OGroupBoxModel
+ :public OControlModel
+ ,public ::utl::OAggregationArrayUsageHelper< OGroupBoxModel >
+{
+public:
+ OGroupBoxModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+ virtual ~OGroupBoxModel();
+
+ // XServiceInfo
+ IMPLEMENTATION_NAME(OGroupBoxModel);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XPropertySetRef
+ virtual staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(staruno::RuntimeException);
+ virtual cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // XPersistObject
+ virtual ::rtl::OUString SAL_CALL getServiceName() throw(staruno::RuntimeException);
+ virtual void SAL_CALL
+ write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream) throw(stario::IOException, staruno::RuntimeException);
+ virtual void SAL_CALL
+ read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream) throw(stario::IOException, staruno::RuntimeException);
+
+ // OAggregationArrayUsageHelper
+ virtual void fillProperties(
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rProps,
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rAggregateProps
+ ) const;
+ IMPLEMENT_INFO_SERVICE()
+};
+
+//==================================================================
+// OGroupBoxControl (nur aus Kompatibilität zur 5.0)
+//==================================================================
+class OGroupBoxControl : public OControl
+{
+public:
+ OGroupBoxControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+
+ // XServiceInfo
+ IMPLEMENTATION_NAME(OGroupBoxControl);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+};
+
+//.........................................................................
+}
+//.........................................................................
+
+#endif // _FORMS_GROUPBOX_HXX_
+
diff --git a/forms/source/component/GroupManager.cxx b/forms/source/component/GroupManager.cxx
new file mode 100644
index 000000000000..b656e9254148
--- /dev/null
+++ b/forms/source/component/GroupManager.cxx
@@ -0,0 +1,532 @@
+/*************************************************************************
+ *
+ * $RCSfile: GroupManager.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FRM_GROUPMANAGER_HXX_
+#include "GroupManager.hxx"
+#endif
+#ifndef _FRM_DATABASEFORM_HXX_
+#include "DatabaseForm.hxx"
+#endif
+
+#include <com/sun/star/beans/XFastPropertySet.hpp>
+
+#ifndef _UTL_PROPERTY_HXX_
+#include <unotools/property.hxx>
+#endif
+#ifndef _UTL_TYPES_HXX_
+#include <unotools/types.hxx>
+#endif
+
+#ifndef _SOLAR_H
+#include <tools/solar.h>
+#endif
+#include <tools/debug.hxx>
+
+#include "property.hrc"
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+//========================================================================
+// class OGroupCompAcc
+//========================================================================
+//------------------------------------------------------------------
+OGroupCompAcc::OGroupCompAcc(const staruno::Reference<starbeans::XPropertySet>& rxElement, const OGroupComp& _rGroupComp )
+ :m_xComponent( rxElement )
+ ,m_aGroupComp( _rGroupComp )
+{
+}
+
+//------------------------------------------------------------------
+sal_Bool OGroupCompAcc::operator==( const OGroupCompAcc& rCompAcc ) const
+{
+ return (m_xComponent == rCompAcc.GetComponent());
+}
+
+//------------------------------------------------------------------
+class OGroupCompAccLess : public ::std::binary_function<OGroupCompAcc, OGroupCompAcc, sal_Bool>
+{
+public:
+ sal_Bool operator() (const OGroupCompAcc& lhs, const OGroupCompAcc& rhs) const
+ {
+ return
+ reinterpret_cast<sal_Int64>(lhs.m_xComponent.get())
+ < reinterpret_cast<sal_Int64>(rhs.m_xComponent.get());
+ }
+};
+
+//========================================================================
+// class OGroupComp
+//========================================================================
+
+//------------------------------------------------------------------
+OGroupComp::OGroupComp()
+ :m_nTabIndex( 0 )
+ ,m_nPos( -1 )
+{
+}
+
+//------------------------------------------------------------------
+OGroupComp::OGroupComp(const OGroupComp& _rSource)
+ :m_aName( _rSource.m_aName )
+ ,m_xComponent( _rSource.m_xComponent )
+ ,m_nTabIndex( _rSource.m_nTabIndex )
+ ,m_nPos( _rSource.m_nPos )
+{
+}
+
+//------------------------------------------------------------------
+OGroupComp::OGroupComp(const staruno::Reference<starbeans::XPropertySet>& rxSet, sal_Int32 nInsertPos )
+ :m_xComponent( rxSet )
+ ,m_nTabIndex(0)
+ ,m_nPos( nInsertPos )
+{
+ if (m_xComponent.is())
+ {
+ if (hasProperty( PROPERTY_TABINDEX, m_xComponent ) )
+ // Indices kleiner 0 werden wie 0 behandelt
+ m_nTabIndex = Max(getINT16(m_xComponent->getPropertyValue( PROPERTY_TABINDEX )) , sal_Int16(0));
+
+ m_xComponent->getPropertyValue( PROPERTY_NAME ) >>= m_aName;
+ }
+}
+
+//------------------------------------------------------------------
+sal_Bool OGroupComp::operator==( const OGroupComp& rComp ) const
+{
+ return m_nTabIndex == rComp.GetTabIndex() && m_nPos == rComp.GetPos();
+}
+
+//------------------------------------------------------------------
+class OGroupCompLess : public ::std::binary_function<OGroupComp, OGroupComp, sal_Bool>
+{
+public:
+ sal_Bool operator() (const OGroupComp& lhs, const OGroupComp& rhs) const
+ {
+ sal_Bool bResult;
+ // TabIndex von 0 wird hinten einsortiert
+ if (lhs.m_nTabIndex == rhs.GetTabIndex())
+ bResult = lhs.m_nPos < rhs.GetPos();
+ else if (lhs.m_nTabIndex && rhs.GetTabIndex())
+ bResult = lhs.m_nTabIndex < rhs.GetTabIndex();
+ else
+ bResult = lhs.m_nTabIndex != 0;
+ return bResult;
+ }
+};
+
+//========================================================================
+// class OGroup
+//========================================================================
+
+DBG_NAME(OGroup)
+//------------------------------------------------------------------
+OGroup::OGroup( const ::rtl::OUString& rGroupName )
+ :m_aGroupName( rGroupName )
+ ,m_nInsertPos(0)
+{
+ DBG_CTOR(OGroup,NULL);
+}
+
+//------------------------------------------------------------------
+OGroup::~OGroup()
+{
+ DBG_DTOR(OGroup,NULL);
+}
+
+//------------------------------------------------------------------
+void OGroup::InsertComponent( const staruno::Reference<starbeans::XPropertySet>& xSet )
+{
+ OGroupComp aNewGroupComp( xSet, m_nInsertPos );
+ sal_Int32 nPosInserted = insert_sorted(m_aCompArray, aNewGroupComp, OGroupCompLess());
+
+ OGroupCompAcc aNewGroupCompAcc( xSet, m_aCompArray[nPosInserted] );
+ insert_sorted(m_aCompAccArray, aNewGroupCompAcc, OGroupCompAccLess());
+ m_nInsertPos++;
+}
+
+//------------------------------------------------------------------
+void OGroup::RemoveComponent( const staruno::Reference<starbeans::XPropertySet>& rxElement )
+{
+ sal_Int32 nGroupCompAccPos;
+ OGroupCompAcc aSearchCompAcc( rxElement, OGroupComp() );
+ if ( seek_entry(m_aCompAccArray, aSearchCompAcc, nGroupCompAccPos, OGroupCompAccLess()) )
+ {
+ OGroupCompAcc& aGroupCompAcc = m_aCompAccArray[nGroupCompAccPos];
+ const OGroupComp& aGroupComp = aGroupCompAcc.GetGroupComponent();
+
+ sal_Int32 nGroupCompPos;
+ if ( seek_entry(m_aCompArray, aGroupComp, nGroupCompPos, OGroupCompLess()) )
+ {
+ m_aCompAccArray.erase( m_aCompAccArray.begin() + nGroupCompAccPos );
+ m_aCompArray.erase( m_aCompArray.begin() + nGroupCompPos );
+
+ /*============================================================
+ Durch das Entfernen der GroupComp ist die Einfuegeposition
+ ungueltig geworden. Sie braucht hier aber nicht angepasst werden,
+ da sie fortlaufend vergeben wird und damit immer
+ aufsteigend eindeutig ist.
+ ============================================================*/
+ }
+ else
+ {
+ DBG_ERROR( "OGroup::RemoveComponent: Component nicht in Gruppe" );
+ }
+ }
+ else
+ {
+ DBG_ERROR( "OGroup::RemoveComponent: Component nicht in Gruppe" );
+ }
+}
+
+//------------------------------------------------------------------
+sal_Bool OGroup::operator==( const OGroup& rGroup ) const
+{
+ return m_aGroupName.equals(rGroup.GetGroupName());
+}
+
+//------------------------------------------------------------------
+class OGroupLess : public ::std::binary_function<OGroup, OGroup, sal_Bool>
+{
+public:
+ sal_Bool operator() (const OGroup& lhs, const OGroup& rhs) const
+ {
+ return lhs.m_aGroupName < rhs.m_aGroupName;
+ }
+};
+
+//------------------------------------------------------------------
+staruno::Sequence< staruno::Reference<starawt::XControlModel> > OGroup::GetControlModels() const
+{
+ sal_Int32 nLen = m_aCompArray.size();
+ staruno::Sequence<staruno::Reference<starawt::XControlModel> > aControlModelSeq( nLen );
+ staruno::Reference<starawt::XControlModel>* pModels = aControlModelSeq.getArray();
+
+ ConstOGroupCompArrIterator aGroupComps = m_aCompArray.begin();
+ for (sal_Int32 i = 0; i < nLen; ++i, ++pModels, ++aGroupComps)
+ {
+ *pModels = staruno::Reference<starawt::XControlModel> ((*aGroupComps).GetComponent(), staruno::UNO_QUERY);
+ }
+ return aControlModelSeq;
+}
+
+DBG_NAME(OGroupManager);
+//------------------------------------------------------------------
+OGroupManager::OGroupManager()
+ :m_pCompGroup(new OGroup(ALL_COMPONENTS_GROUP_NAME))
+{
+ DBG_CTOR(OGroupManager,NULL);
+
+}
+
+//------------------------------------------------------------------
+OGroupManager::~OGroupManager()
+{
+ DBG_DTOR(OGroupManager,NULL);
+ // Alle Components und CompGroup loeschen
+ delete m_pCompGroup;
+}
+
+// starbeans::XPropertyChangeListener
+//------------------------------------------------------------------
+void OGroupManager::disposing(const starlang::EventObject& evt) throw( staruno::RuntimeException )
+{
+ staruno::Reference<starcontainer::XContainer> xContainer(evt.Source, staruno::UNO_QUERY);
+ if (xContainer.is())
+ {
+ DELETEZ(m_pCompGroup);
+
+ ////////////////////////////////////////////////////////////////
+ // Gruppen loeschen
+ m_aGroupArr.erase(m_aGroupArr.begin(), m_aGroupArr.end());
+ }
+}
+
+//------------------------------------------------------------------
+void SAL_CALL OGroupManager::propertyChange(const starbeans::PropertyChangeEvent& evt)
+{
+ staruno::Reference<starbeans::XPropertySet> xSet(evt.Source, staruno::UNO_QUERY);
+
+ // Component aus CompGroup entfernen
+ m_pCompGroup->RemoveComponent( xSet );
+
+ // Component aus Gruppe entfernen
+ sal_Int32 nGroupPos;
+ ::rtl::OUString sGroupName;
+ if (evt.PropertyName == PROPERTY_NAME)
+ evt.OldValue >>= sGroupName;
+ else
+ xSet->getPropertyValue( PROPERTY_NAME ) >>= sGroupName;
+
+ OGroup aSearchGroup( sGroupName );
+
+ if (seek_entry(m_aGroupArr, aSearchGroup, nGroupPos, OGroupLess()))
+ {
+ // Gruppe vorhanden
+ OGroup& rFoundGroup = m_aGroupArr[nGroupPos];
+ rFoundGroup.RemoveComponent( xSet );
+
+ // Wenn Anzahl der Gruppenelemente == 1 ist, Gruppe deaktivieren
+ if( rFoundGroup.Count() == 1 )
+ {
+ for ( OUInt32ArrIterator aMapSearch = m_aActiveGroupMap.begin();
+ aMapSearch < m_aActiveGroupMap.end();
+ ++aMapSearch
+ )
+ {
+ if( *aMapSearch == nGroupPos )
+ {
+ m_aActiveGroupMap.erase(aMapSearch);
+ break;
+ }
+ }
+ }
+ }
+
+
+ // Bei Component als PropertyChangeListener abmelden
+ xSet->removePropertyChangeListener( PROPERTY_NAME, this );
+ if (hasProperty(PROPERTY_TABINDEX, xSet))
+ xSet->removePropertyChangeListener( PROPERTY_TABINDEX, this );
+
+ // Component neu einordnen
+ InsertElement( xSet );
+}
+
+// starcontainer::XContainerListener
+//------------------------------------------------------------------
+void SAL_CALL OGroupManager::elementInserted(const starcontainer::ContainerEvent& Event)
+{
+ staruno::Reference<starbeans::XPropertySet> xSet(*(InterfaceRef *)Event.Element.getValue(), staruno::UNO_QUERY);
+ if (xSet.is())
+ InsertElement( xSet );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL OGroupManager::elementRemoved(const starcontainer::ContainerEvent& Event)
+{
+ staruno::Reference<starbeans::XPropertySet> xSet(*(InterfaceRef *)Event.Element.getValue(), staruno::UNO_QUERY);
+ if (xSet.is())
+ RemoveElement( xSet );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL OGroupManager::elementReplaced(const starcontainer::ContainerEvent& Event)
+{
+ staruno::Reference<starbeans::XPropertySet> xSet(*(InterfaceRef *)Event.ReplacedElement.getValue(), staruno::UNO_QUERY);
+ if (xSet.is())
+ RemoveElement( xSet );
+
+ xSet = staruno::Reference<starbeans::XPropertySet> (*(InterfaceRef *)Event.Element.getValue(), staruno::UNO_QUERY);
+ if (xSet.is())
+ InsertElement( xSet );
+}
+
+// Other functions
+//------------------------------------------------------------------
+staruno::Sequence<staruno::Reference<starawt::XControlModel> > OGroupManager::getControlModels()
+{
+ return m_pCompGroup->GetControlModels();
+}
+
+//------------------------------------------------------------------
+sal_Int32 OGroupManager::getGroupCount()
+{
+ return m_aActiveGroupMap.size();
+}
+
+//------------------------------------------------------------------
+void OGroupManager::getGroup(sal_Int32 nGroup, staruno::Sequence< staruno::Reference<starawt::XControlModel> >& _rGroup, ::rtl::OUString& _rName)
+{
+ sal_uInt16 nGroupPos= m_aActiveGroupMap[nGroup];
+ OGroup& rGroup = m_aGroupArr[nGroupPos];
+ _rName = rGroup.GetGroupName();
+ _rGroup = rGroup.GetControlModels();
+}
+
+//------------------------------------------------------------------
+void OGroupManager::getGroupByName(const ::rtl::OUString& _rName, staruno::Sequence< staruno::Reference<starawt::XControlModel> >& _rGroup)
+{
+ sal_Int32 nGroupPos;
+ OGroup aSearchGroup( _rName );
+
+ if (seek_entry(m_aGroupArr, aSearchGroup, nGroupPos, OGroupLess()))
+ {
+ OGroup& rGroup = m_aGroupArr[nGroupPos];
+ _rGroup = rGroup.GetControlModels();
+ }
+}
+
+//------------------------------------------------------------------
+void OGroupManager::InsertElement( const staruno::Reference<starbeans::XPropertySet>& xSet )
+{
+ // Nur ControlModels
+ staruno::Reference<starawt::XControlModel> xControl(xSet, staruno::UNO_QUERY);
+ if (!xControl.is() )
+ return;
+
+ // Component in CompGroup aufnehmen
+ m_pCompGroup->InsertComponent( xSet );
+
+ // Component in Gruppe aufnehmen
+ sal_Int32 nPos;
+ ::rtl::OUString sGroupName;
+ xSet->getPropertyValue( PROPERTY_NAME ) >>= sGroupName;
+
+ OGroup aNewGroup( sGroupName );
+ if (seek_entry(m_aGroupArr, aNewGroup, nPos, OGroupLess()))
+ {
+ // Gruppe existiert schon ...
+ }
+ else
+ {
+ // Gruppe muss neu angelegt werden
+ nPos = insert_sorted(m_aGroupArr, aNewGroup, OGroupLess());
+
+ // Indizes der ActiveGroupMap anpassen
+ if (seek_entry(m_aGroupArr, aNewGroup, nPos, OGroupLess()))
+ {
+ for ( OUInt32ArrIterator aMapSearch = m_aActiveGroupMap.begin();
+ aMapSearch < m_aActiveGroupMap.end();
+ ++aMapSearch
+ )
+ {
+ if( (*aMapSearch) >= nPos )
+ ++(*aMapSearch);
+ }
+ }
+ else
+ DBG_ERROR("OGroupManager::InsertElement : inserted the element but did not find it afterwards !");
+ }
+
+ OGroup& rNewGroup = m_aGroupArr[nPos];
+ rNewGroup.InsertComponent( xSet );
+
+
+ // Wenn Anzahl der Gruppenelemente == 2 ist, Gruppe aktivieren
+ if( rNewGroup.Count() == 2 )
+ {
+ m_aActiveGroupMap.insert( m_aActiveGroupMap.end(), nPos );
+ }
+
+
+ // Bei Component als PropertyChangeListener anmelden
+ xSet->addPropertyChangeListener( PROPERTY_NAME, this );
+
+ // Tabindex muß nicht jeder unterstuetzen
+ if (hasProperty(PROPERTY_TABINDEX, xSet))
+ xSet->addPropertyChangeListener( PROPERTY_TABINDEX, this );
+
+}
+
+//------------------------------------------------------------------
+void OGroupManager::RemoveElement( const staruno::Reference<starbeans::XPropertySet>& xSet )
+{
+ // Nur ControlModels
+ staruno::Reference<starawt::XControlModel> xControl(xSet, staruno::UNO_QUERY);
+ if (!xControl.is() )
+ return;
+
+ // Component aus CompGroup entfernen
+ m_pCompGroup->RemoveComponent( xSet );
+
+ // Component aus Gruppe entfernen
+ sal_Int32 nGroupPos;
+ ::rtl::OUString sGroupName;
+ xSet->getPropertyValue( PROPERTY_NAME ) >>= sGroupName;
+ OGroup aSearchGroup( sGroupName );
+
+ if (seek_entry(m_aGroupArr, aSearchGroup, nGroupPos, OGroupLess()))
+ {
+ // Gruppe vorhanden
+ OGroup& rGroup = m_aGroupArr[nGroupPos];
+ rGroup.RemoveComponent( xSet );
+
+
+ // Wenn Anzahl der Gruppenelemente == 1 ist, Gruppe deaktivieren
+ if( rGroup.Count() == 1 )
+ {
+ for ( OUInt32ArrIterator aMapSearch = m_aActiveGroupMap.begin();
+ aMapSearch < m_aActiveGroupMap.end();
+ ++aMapSearch
+ )
+ {
+ if( *aMapSearch == nGroupPos )
+ {
+ m_aActiveGroupMap.erase(aMapSearch);
+ break;
+ }
+ }
+ }
+ }
+
+ // Bei Component als PropertyChangeListener abmelden
+ xSet->removePropertyChangeListener( PROPERTY_NAME, this );
+ if (hasProperty(PROPERTY_TABINDEX, xSet))
+ xSet->removePropertyChangeListener( PROPERTY_TABINDEX, this );
+}
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
diff --git a/forms/source/component/GroupManager.hxx b/forms/source/component/GroupManager.hxx
new file mode 100644
index 000000000000..8ef74c7e9352
--- /dev/null
+++ b/forms/source/component/GroupManager.hxx
@@ -0,0 +1,264 @@
+/*************************************************************************
+ *
+ * $RCSfile: GroupManager.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FRM_GROUPMANAGER_HXX_
+#define _FRM_GROUPMANAGER_HXX_
+
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/container/XContainerListener.hpp>
+
+#ifndef _UTL_STLTYPES_HXX_
+#include <unotools/stl_types.hxx>
+#endif
+
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx>
+#endif
+
+#ifndef _UTL_STLTYPES_HXX_
+#include <unotools/stl_types.hxx>
+#endif
+#ifndef _UTL_TYPES_HXX_
+#include <unotools/types.hxx>
+#endif
+using namespace utl;
+
+/*========================================================================
+Funktionsweise GroupManager:
+
+Der GroupManager horcht an der starform, ob FormComponents eingefuegt oder entfernt
+werden. Zusaetzlich horcht er bei den FormComponents an den Properties
+"Name" und "TabIndex". Mit diesen Infos aktualisiert er seine Gruppen.
+
+Der GroupManager verwaltet eine Gruppe, in der alle Controls nach TabIndex
+geordnet sind, und ein Array von Gruppen, in dem jede FormComponent noch
+einmal einer Gruppe dem Namen nach zugeordnet wird.
+Die einzelnen Gruppen werden ueber eine Map aktiviert, wenn sie mehr als
+ein Element besitzen.
+
+Die Gruppen verwalten intern die FormComponents in zwei Arrays. In dem
+GroupCompArray werden die Components nach TabIndex und Einfuegepostion
+sortiert. Da auf dieses Array ueber die FormComponent zugegriffen
+wird, gibt es noch das GroupCompAccessArray, in dem die FormComponents
+nach ihrer Speicheradresse sortiert sind. Jedes Element des
+GroupCompAccessArrays ist mit einem Element des GroupCompArrays verpointert.
+
+========================================================================*/
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+ namespace starbeans = ::com::sun::star::beans;
+ namespace starcontainer = ::com::sun::star::container;
+
+//========================================================================
+ template <class ELEMENT, class LESS_COMPARE>
+ sal_Int32 insert_sorted(::std::vector<ELEMENT>& _rArray, const ELEMENT& _rNewElement, const LESS_COMPARE& _rCompareOp)
+ {
+ ::std::vector<ELEMENT>::iterator aInsertPos = lower_bound(
+ _rArray.begin(),
+ _rArray.end(),
+ _rNewElement,
+ _rCompareOp
+ );
+ aInsertPos = _rArray.insert(aInsertPos, _rNewElement);
+ return aInsertPos - _rArray.begin();
+ }
+
+ template <class ELEMENT, class LESS_COMPARE>
+ sal_Bool seek_entry(const ::std::vector<ELEMENT>& _rArray, const ELEMENT& _rNewElement, sal_Int32& nPos, const LESS_COMPARE& _rCompareOp)
+ {
+ ::std::vector<ELEMENT>::const_iterator aExistentPos = ::std::lower_bound(
+ _rArray.begin(),
+ _rArray.end(),
+ _rNewElement,
+ _rCompareOp
+ );
+ if ((aExistentPos != _rArray.end()) && (*aExistentPos == _rNewElement))
+ { // we have a valid "lower or equal" element and it's really "equal"
+ nPos = aExistentPos - _rArray.begin();
+ return sal_True;
+ }
+ nPos = -1;
+ return sal_False;
+ }
+
+//========================================================================
+class OGroupComp
+{
+ ::rtl::OUString m_aName;
+ staruno::Reference<starbeans::XPropertySet> m_xComponent;
+ sal_Int32 m_nPos;
+ sal_Int16 m_nTabIndex;
+
+ friend class OGroupCompLess;
+
+public:
+ OGroupComp(const staruno::Reference<starbeans::XPropertySet>& rxElement, sal_Int32 nInsertPos );
+ OGroupComp(const OGroupComp& _rSource);
+ OGroupComp();
+
+ sal_Bool operator==( const OGroupComp& rComp ) const;
+
+ const staruno::Reference<starbeans::XPropertySet>& GetComponent() const { return m_xComponent; }
+ sal_Int32 GetPos() const { return m_nPos; }
+ sal_Int16 GetTabIndex() const { return m_nTabIndex; }
+ ::rtl::OUString GetName() const { return m_aName; }
+};
+
+DECLARE_STL_VECTOR(OGroupComp, OGroupCompArr);
+
+//========================================================================
+class OGroupComp;
+class OGroupCompAcc
+{
+ staruno::Reference<starbeans::XPropertySet> m_xComponent;
+ OGroupComp m_aGroupComp;
+
+ friend class OGroupCompAccLess;
+
+public:
+ OGroupCompAcc(const staruno::Reference<starbeans::XPropertySet>& rxElement, const OGroupComp& _rGroupComp );
+
+ sal_Bool operator==( const OGroupCompAcc& rCompAcc ) const;
+
+ const staruno::Reference<starbeans::XPropertySet>& GetComponent() const { return m_xComponent; }
+ const OGroupComp& GetGroupComponent() const { return m_aGroupComp; }
+};
+
+DECLARE_STL_VECTOR(OGroupCompAcc, OGroupCompAccArr);
+
+//========================================================================
+class OGroup
+{
+ OGroupCompArr m_aCompArray;
+ OGroupCompAccArr m_aCompAccArray;
+
+ ::rtl::OUString m_aGroupName;
+ sal_uInt16 m_nInsertPos; // Die Einfugeposition der GroupComps wird von der Gruppe bestimmt.
+
+ friend class OGroupLess;
+
+public:
+ OGroup( const ::rtl::OUString& rGroupName );
+ virtual ~OGroup();
+
+ sal_Bool operator==( const OGroup& rGroup ) const;
+
+ ::rtl::OUString GetGroupName() const { return m_aGroupName; }
+ staruno::Sequence< staruno::Reference<starawt::XControlModel> > GetControlModels() const;
+
+ void InsertComponent( const staruno::Reference<starbeans::XPropertySet>& rxElement );
+ void RemoveComponent( const staruno::Reference<starbeans::XPropertySet>& rxElement );
+ sal_uInt16 Count() const { return m_aCompArray.size(); }
+ const staruno::Reference<starbeans::XPropertySet>& GetObject( sal_uInt16 nP ) const
+ { return m_aCompArray[nP].GetComponent(); }
+};
+
+DECLARE_STL_VECTOR(OGroup, OGroupArr);
+DECLARE_STL_VECTOR(sal_uInt32, OUInt32Arr);
+
+//========================================================================
+class OGroupManager : public ::cppu::WeakImplHelper2<starbeans::XPropertyChangeListener, starcontainer::XContainerListener>
+{
+ OGroup* m_pCompGroup; // Alle Components nach TabIndizes sortiert
+ OGroupArr m_aGroupArr; // Alle Components nach Gruppen sortiert
+ OUInt32Arr m_aActiveGroupMap; // In dieser Map werden die Indizes aller Gruppen gehalten,
+ // die mehr als 1 Element haben
+
+ // Helper functions
+ void InsertElement( const staruno::Reference<starbeans::XPropertySet>& rxElement );
+ void RemoveElement( const staruno::Reference<starbeans::XPropertySet>& rxElement );
+
+public:
+ OGroupManager();
+ virtual ~OGroupManager();
+
+// starlang::XEventListener
+ virtual void SAL_CALL disposing(const starlang::EventObject& _rSource) throw(staruno::RuntimeException);
+
+// starbeans::XPropertyChangeListener
+ virtual void SAL_CALL propertyChange(const starbeans::PropertyChangeEvent& evt);
+
+// starcontainer::XContainerListener
+ virtual void SAL_CALL elementInserted(const starcontainer::ContainerEvent& _rEvent);
+ virtual void SAL_CALL elementRemoved(const starcontainer::ContainerEvent& _rEvent);
+ virtual void SAL_CALL elementReplaced(const starcontainer::ContainerEvent& _rEvent);
+
+// Other functions
+ sal_Int32 getGroupCount();
+ void getGroup(sal_Int32 nGroup, staruno::Sequence< staruno::Reference<starawt::XControlModel> >& _rGroup, ::rtl::OUString& Name);
+ void getGroupByName(const ::rtl::OUString& Name, staruno::Sequence< staruno::Reference<starawt::XControlModel> >& _rGroup);
+ staruno::Sequence< staruno::Reference<starawt::XControlModel> > getControlModels();
+};
+
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
+#endif // _FRM_GROUPMANAGER_HXX_
+
diff --git a/forms/source/component/Hidden.cxx b/forms/source/component/Hidden.cxx
new file mode 100644
index 000000000000..38806eba2c14
--- /dev/null
+++ b/forms/source/component/Hidden.cxx
@@ -0,0 +1,216 @@
+/*************************************************************************
+ *
+ * $RCSfile: Hidden.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_HIDDEN_HXX_
+#include "Hidden.hxx"
+#endif
+#ifndef _FRM_PROPERTY_HXX_
+#include "property.hxx"
+#endif
+#ifndef _FRM_PROPERTY_HRC_
+#include "property.hrc"
+#endif
+#ifndef _FRM_SERVICES_HXX_
+#include "services.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+//.........................................................................
+namespace frm
+{
+
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OHiddenModel_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory) throw (staruno::RuntimeException)
+{
+ return *(new OHiddenModel(_rxFactory));
+}
+
+//------------------------------------------------------------------
+OHiddenModel::OHiddenModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OControlModel(_rxFactory, ::rtl::OUString())
+{
+ m_nClassId = starform::FormComponentType::HIDDENCONTROL;
+}
+
+//------------------------------------------------------------------------------
+void OHiddenModel::getFastPropertyValue(staruno::Any& _rValue, sal_Int32 _nHandle) const
+{
+ switch (_nHandle)
+ {
+ case PROPERTY_ID_HIDDEN_VALUE : _rValue <<= m_sHiddenValue; break;
+ default:
+ OControlModel::getFastPropertyValue(_rValue, _nHandle);
+ }
+}
+
+//------------------------------------------------------------------------------
+void OHiddenModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const staruno::Any& _rValue) throw (com::sun::star::uno::Exception)
+{
+ switch (_nHandle)
+ {
+ case PROPERTY_ID_HIDDEN_VALUE :
+ DBG_ASSERT(_rValue.getValueType().getTypeClass() == staruno::TypeClass_STRING, "OHiddenModel::setFastPropertyValue_NoBroadcast : invalid type !" );
+ _rValue >>= m_sHiddenValue;
+ break;
+ default:
+ OControlModel::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OHiddenModel::convertFastPropertyValue(
+ staruno::Any& _rConvertedValue, staruno::Any& _rOldValue, sal_Int32 _nHandle, const staruno::Any& _rValue)
+ throw (starlang::IllegalArgumentException)
+{
+ sal_Bool bModified(sal_False);
+ switch (_nHandle)
+ {
+ case PROPERTY_ID_HIDDEN_VALUE :
+ bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_sHiddenValue);
+ break;
+ default:
+ bModified = OControlModel::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
+ break;
+ }
+ return bModified;
+}
+
+//------------------------------------------------------------------------------
+staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL OHiddenModel::getPropertySetInfo() throw(staruno::RuntimeException)
+{
+ staruno::Reference<starbeans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//------------------------------------------------------------------------------
+cppu::IPropertyArrayHelper& OHiddenModel::getInfoHelper()
+{
+ return *const_cast<OHiddenModel*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+void OHiddenModel::fillProperties(
+ staruno::Sequence< starbeans::Property >& _rProps,
+ staruno::Sequence< starbeans::Property >& _rAggregateProps ) const
+{
+ BEGIN_AGGREGATION_PROPERTY_HELPER(4, m_xAggregateSet)
+ DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT);
+ DECL_PROP1(HIDDEN_VALUE, ::rtl::OUString, BOUND);
+ DECL_PROP1(NAME, ::rtl::OUString, BOUND);
+ DECL_PROP1(TAG, ::rtl::OUString, BOUND);
+ END_AGGREGATION_PROPERTY_HELPER();
+}
+
+// XServiceInfo
+//------------------------------------------------------------------------------
+StringSequence SAL_CALL OHiddenModel::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException)
+{
+ StringSequence aSupported = OControlModel::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 2);
+
+ ::rtl::OUString* pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-2] = ::rtl::OUString::createFromAscii("com.sun.star.form.FormComponent");
+ pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_HIDDENCONTROL;
+ return aSupported;
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OHiddenModel::getServiceName() throw(staruno::RuntimeException)
+{
+ return FRM_COMPONENT_HIDDEN; // old (non-sun) name for compatibility !
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OHiddenModel::write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream)
+ throw(stario::IOException, staruno::RuntimeException)
+{
+ // Version
+ _rxOutStream->writeShort(0x0002);
+
+ // Wert
+ _rxOutStream << m_sHiddenValue;
+
+ OControlModel::write(_rxOutStream);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OHiddenModel::read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream) throw(stario::IOException, staruno::RuntimeException)
+{
+ // Version
+ UINT16 nVersion = _rxInStream->readShort();
+
+ // Name
+ DBG_ASSERT(nVersion != 1, "OHiddenModel::read : this version is obsolete !");
+ switch (nVersion)
+ {
+ case 1 : { ::rtl::OUString sDummy; _rxInStream >> sDummy; _rxInStream >> m_sHiddenValue; } break;
+ case 2 : _rxInStream >> m_sHiddenValue; break;
+ default : DBG_ERROR("OHiddenModel::read : unknown version !"); m_sHiddenValue = ::rtl::OUString();
+ }
+ OControlModel::read(_rxInStream);
+}
+
+//.........................................................................
+}
+//.........................................................................
+
diff --git a/forms/source/component/Hidden.hxx b/forms/source/component/Hidden.hxx
new file mode 100644
index 000000000000..095903e1c4ad
--- /dev/null
+++ b/forms/source/component/Hidden.hxx
@@ -0,0 +1,121 @@
+/*************************************************************************
+ *
+ * $RCSfile: Hidden.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_HIDDEN_HXX_
+#define _FORMS_HIDDEN_HXX_
+
+#ifndef _FORMS_FORMCOMPONENT_HXX_
+#include "FormComponent.hxx"
+#endif
+
+//.........................................................................
+namespace frm
+{
+
+//==================================================================
+// OHiddenModel
+//==================================================================
+class OHiddenModel
+ :public OControlModel
+ ,public ::utl::OAggregationArrayUsageHelper< OHiddenModel >
+{
+ ::rtl::OUString m_sHiddenValue;
+
+public:
+ OHiddenModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+
+ // OPropertySetHelper
+ virtual void SAL_CALL getFastPropertyValue(staruno::Any& rValue, sal_Int32 nHandle) const;
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const staruno::Any& rValue )
+ throw (staruno::Exception);
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(
+ staruno::Any& _rConvertedValue, staruno::Any& _rOldValue, sal_Int32 _nHandle, const staruno::Any& _rValue )
+ throw (starlang::IllegalArgumentException);
+
+ // XPropertySetRef
+ virtual staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(staruno::RuntimeException);
+ virtual cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // XServiceInfo
+ IMPLEMENTATION_NAME(OHiddenModel);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XPersistObject
+ virtual ::rtl::OUString SAL_CALL getServiceName() throw(staruno::RuntimeException);
+ virtual void SAL_CALL
+ write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream) throw(stario::IOException, staruno::RuntimeException);
+ virtual void SAL_CALL
+ read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream) throw(stario::IOException, staruno::RuntimeException);
+
+// OAggregationArrayUsageHelper
+ virtual void fillProperties(
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rProps,
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rAggregateProps
+ ) const;
+ IMPLEMENT_INFO_SERVICE()
+};
+
+#endif // _FORMS_HIDDEN_HXX_
+
+//.........................................................................
+}
+//.........................................................................
+
diff --git a/forms/source/component/ImageButton.cxx b/forms/source/component/ImageButton.cxx
new file mode 100644
index 000000000000..8923d05f76f5
--- /dev/null
+++ b/forms/source/component/ImageButton.cxx
@@ -0,0 +1,316 @@
+/*************************************************************************
+ *
+ * $RCSfile: ImageButton.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FRM_IMAGE_BUTTON_HXX_
+#include "ImageButton.hxx"
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_AWT_MOUSEBUTTON_HPP_
+#include <com/sun/star/awt/MouseButton.hpp>
+#endif
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+//==================================================================
+//= OImageButtonModel
+//==================================================================
+DBG_NAME(OImageButtonModel)
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OImageButtonModel_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new OImageButtonModel(_rxFactory));
+}
+
+//------------------------------------------------------------------
+OImageButtonModel::OImageButtonModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OImageModel(_rxFactory, VCL_CONTROLMODEL_IMAGEBUTTON, FRM_CONTROL_IMAGEBUTTON)
+ // use the old control name for compytibility reasons
+{
+ DBG_CTOR(OImageButtonModel, NULL);
+ m_nClassId = starform::FormComponentType::IMAGEBUTTON;
+}
+
+//------------------------------------------------------------------------------
+OImageButtonModel::~OImageButtonModel()
+{
+ DBG_DTOR(OImageButtonModel, NULL);
+}
+
+//------------------------------------------------------------------------------
+staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL OImageButtonModel::getPropertySetInfo() throw( staruno::RuntimeException )
+{
+ staruno::Reference<starbeans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+// starlang::XServiceInfo
+//------------------------------------------------------------------------------
+StringSequence OImageButtonModel::getSupportedServiceNames() throw()
+{
+ StringSequence aSupported = OControlModel::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 1);
+
+ ::rtl::OUString*pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_IMAGEBUTTON;
+ return aSupported;
+}
+
+//------------------------------------------------------------------------------
+void OImageButtonModel::fillProperties(
+ staruno::Sequence< starbeans::Property >& _rProps,
+ staruno::Sequence< starbeans::Property >& _rAggregateProps ) const
+{
+ FRM_BEGIN_PROP_HELPER(8)
+ DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT);
+ DECL_PROP1(BUTTONTYPE, starform::FormButtonType, BOUND);
+ DECL_PROP1(TARGET_URL, ::rtl::OUString, BOUND);
+ DECL_PROP1(TARGET_FRAME, ::rtl::OUString, BOUND);
+ DECL_PROP1(NAME, ::rtl::OUString, BOUND);
+ DECL_PROP1(TAG, ::rtl::OUString, BOUND);
+ DECL_PROP1(TABINDEX, sal_Int16, BOUND);
+ DECL_PROP1(HELPTEXT, ::rtl::OUString, BOUND);
+ FRM_END_PROP_HELPER();
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OImageButtonModel::getInfoHelper()
+{
+ return *const_cast<OImageButtonModel*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString OImageButtonModel::getServiceName()
+{
+ return FRM_COMPONENT_IMAGEBUTTON; // old (non-sun) name for compatibility !
+}
+
+//------------------------------------------------------------------------------
+void OImageButtonModel::write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream)
+{
+ OControlModel::write(_rxOutStream);
+
+ // Version
+ _rxOutStream->writeShort(0x0003);
+ _rxOutStream->writeShort((sal_uInt16)m_eButtonType);
+
+ ::rtl::OUString sTmp(INetURLObject::decode(INetURLObject::AbsToRel(m_sTargetURL), '%', INetURLObject::DECODE_UNAMBIGUOUS));
+ _rxOutStream << sTmp;
+ _rxOutStream << m_sTargetFrame;
+ _rxOutStream << m_aHelpText;
+}
+
+//------------------------------------------------------------------------------
+void OImageButtonModel::read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream)
+{
+ OControlModel::read(_rxInStream);
+
+ // Version
+ sal_uInt16 nVersion = _rxInStream->readShort();
+
+ switch (nVersion)
+ {
+ case 0x0001:
+ {
+ m_eButtonType = (starform::FormButtonType)_rxInStream->readShort();
+ }
+ break;
+ case 0x0002:
+ {
+ m_eButtonType = (starform::FormButtonType)_rxInStream->readShort();
+ ::rtl::OUString sTmp;
+ _rxInStream >> sTmp;
+ m_sTargetURL = INetURLObject::RelToAbs( sTmp );
+ _rxInStream >> m_sTargetFrame;
+ }
+ break;
+ case 0x0003:
+ {
+ m_eButtonType = (starform::FormButtonType)_rxInStream->readShort();
+ ::rtl::OUString sTmp;
+ _rxInStream >> sTmp;
+ m_sTargetURL = INetURLObject::RelToAbs( sTmp );
+ _rxInStream >> m_sTargetFrame;
+ _rxInStream >> m_aHelpText;
+ }
+ break;
+
+ default :
+ DBG_ERROR("OImageButtonModel::read : unknown version !");
+ m_eButtonType = starform::FormButtonType_PUSH;
+ m_sTargetURL = ::rtl::OUString();
+ m_sTargetFrame = ::rtl::OUString();
+ break;
+ }
+}
+
+//==================================================================
+// OImageButtonControl
+//==================================================================
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OImageButtonControl_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new OImageButtonControl(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> OImageButtonControl::_getTypes()
+{
+ static staruno::Sequence<staruno::Type> aTypes;
+ if (!aTypes.getLength())
+ {
+ // my base class
+ staruno::Sequence<staruno::Type> aBaseClassTypes = OImageControl::_getTypes();
+
+ staruno::Sequence<staruno::Type> aOwnTypes(1);
+ staruno::Type* pOwnTypes = aOwnTypes.getArray();
+ pOwnTypes[0] = getCppuType((staruno::Reference<starawt::XMouseListener>*)NULL);
+
+ aTypes = concatSequences(aBaseClassTypes, aOwnTypes);
+ }
+ return aTypes;
+}
+
+//------------------------------------------------------------------------------
+StringSequence OImageButtonControl::getSupportedServiceNames() throw()
+{
+ StringSequence aSupported = OControl::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 1);
+
+ ::rtl::OUString*pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_IMAGEBUTTON;
+ return aSupported;
+}
+
+//------------------------------------------------------------------------------
+OImageButtonControl::OImageButtonControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OImageControl(_rxFactory, VCL_CONTROL_IMAGEBUTTON)
+{
+ increment(m_refCount);
+ {
+ // als MouseListener anmelden
+ staruno::Reference<starawt::XWindow> xComp;
+ query_aggregation( m_xAggregate, xComp);
+ if (xComp.is())
+ xComp->addMouseListener((starawt::XMouseListener*)this);
+ }
+ // Refcount bei 1 fuer angemeldeten Listener
+ sal_Int32 n = decrement(m_refCount);
+}
+
+// UNO Anbindung
+//------------------------------------------------------------------------------
+staruno::Any SAL_CALL OImageButtonControl::queryAggregation(const staruno::Type& _rType) throw (staruno::RuntimeException)
+{
+ staruno::Any aReturn;
+
+ aReturn = OImageControl::queryAggregation(_rType);
+ if (!aReturn.hasValue())
+ aReturn = ::cppu::queryInterface(_rType
+ ,static_cast<starawt::XMouseListener*>(this)
+ );
+
+ return aReturn;
+}
+
+//------------------------------------------------------------------------------
+void OImageButtonControl::mousePressed(const starawt::MouseEvent& e)
+{
+ //////////////////////////////////////////////////////////////////////
+ // Nur linke Maustaste
+ if (e.Buttons != starawt::MouseButton::LEFT)
+ return;
+
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+ if( m_aApproveActionListeners.getLength() )
+ {
+ // Wenn es ApproveAction-Lisener gibt, muss ein eigener Thread
+ // aufgemacht werden.
+ if( !m_pThread )
+ {
+ m_pThread = new OImageControlThread_Impl( this );
+ m_pThread->acquire();
+ m_pThread->create();
+ }
+ m_pThread->OComponentEventThread::addEvent( &e );
+ }
+ else
+ {
+ // Sonst nicht. Dann darf man aber auf keinen Fal die Listener
+ // benachrichtigen, auch dann nicht, wenn er spaeter hinzukommt.
+ aGuard.clear();
+ actionPerformed_Impl( sal_False, e );
+ }
+}
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
diff --git a/forms/source/component/ImageButton.hxx b/forms/source/component/ImageButton.hxx
new file mode 100644
index 000000000000..fab7633e4efe
--- /dev/null
+++ b/forms/source/component/ImageButton.hxx
@@ -0,0 +1,147 @@
+/*************************************************************************
+ *
+ * $RCSfile: ImageButton.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FRM_IMAGE_BUTTON_HXX_
+#define _FRM_IMAGE_BUTTON_HXX_
+
+#ifndef _FRM_IMAGE_HXX_
+#include "Image.hxx"
+#endif
+
+#ifndef _COM_SUN_STAR_AWT_XMOUSELISTENER_HPP_
+#include <com/sun/star/awt/XMouseListener.hpp>
+#endif
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+//==================================================================
+// OImageButtonModel
+//==================================================================
+class OImageButtonModel
+ :public OImageModel
+ ,public ::utl::OAggregationArrayUsageHelper< OImageButtonModel >
+{
+public:
+ OImageButtonModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+ ~OImageButtonModel();
+
+// starlang::XServiceInfo
+ IMPLEMENTATION_NAME(OImageButtonModel);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
+
+// staruno::Reference<starbeans::XPropertySet>
+ virtual staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(staruno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+// stario::XPersistObject
+ virtual ::rtl::OUString SAL_CALL getServiceName();
+ virtual void SAL_CALL write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream);
+ virtual void SAL_CALL read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream);
+
+// OAggregationArrayUsageHelper
+ virtual void fillProperties(
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rProps,
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rAggregateProps
+ ) const;
+ IMPLEMENT_INFO_SERVICE()
+};
+
+//==================================================================
+// OImageButtonControl
+//==================================================================
+class OImageButtonControl : public OImageControl,
+ public starawt::XMouseListener
+{
+protected:
+ // UNO Anbindung
+ virtual staruno::Sequence<staruno::Type> _getTypes();
+
+public:
+ OImageButtonControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+
+// starlang::XServiceInfo
+ IMPLEMENTATION_NAME(OImageButtonControl);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
+
+ // UNO Anbindung
+ DECLARE_UNO3_AGG_DEFAULTS(OImageButtonControl, OImageControl);
+ virtual staruno::Any SAL_CALL queryAggregation(const staruno::Type& _rType) throw(staruno::RuntimeException);
+
+// starlang::XEventListener
+ virtual void SAL_CALL disposing(const starlang::EventObject& _rSource) throw(staruno::RuntimeException)
+ { OControl::disposing(_rSource); }
+
+// starawt::XMouseListener
+ virtual void SAL_CALL mousePressed(const starawt::MouseEvent& e);
+ virtual void SAL_CALL mouseReleased(const starawt::MouseEvent& e) { }
+ virtual void SAL_CALL mouseEntered(const starawt::MouseEvent& e) { }
+ virtual void SAL_CALL mouseExited(const starawt::MouseEvent& e) { }
+};
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
+#endif // _FRM_IMAGE_BUTTON_HXX_
+
diff --git a/forms/source/component/ImageControl.cxx b/forms/source/component/ImageControl.cxx
new file mode 100644
index 000000000000..eb3da3ce913a
--- /dev/null
+++ b/forms/source/component/ImageControl.cxx
@@ -0,0 +1,673 @@
+/*************************************************************************
+ *
+ * $RCSfile: ImageControl.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FRM_IMAGE_CONTROL_HXX_
+#include "ImageControl.hxx"
+#endif
+
+#ifndef _FRM_PROPERTY_HRC_
+#include "property.hrc"
+#endif
+#ifndef _FRM_RESOURCE_HRC_
+#include "frm_resource.hrc"
+#endif
+#ifndef _FRM_RESOURCE_HXX_
+#include "frm_resource.hxx"
+#endif
+#include "conversion.hxx"
+
+#ifndef _FRM_SERVICES_HXX_
+#include "services.hxx"
+#endif
+
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_MOUSEBUTTON_HPP_
+#include <com/sun/star/awt/MouseButton.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_
+#include <com/sun/star/awt/XWindow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XDIALOG_HPP_
+#include <com/sun/star/awt/XDialog.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HPP_
+#include <com/sun/star/io/XActiveDataSink.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_NOTCONNECTEDEXCEPTION_HPP_
+#include <com/sun/star/io/NotConnectedException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+
+#ifndef _SVX_IMPGRF_HXX
+#include <svx/impgrf.hxx>
+#endif
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+#ifndef _STREAM_HXX
+#include <tools/stream.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#ifndef _UNOTOOLS_STREAMHELPER_HXX_
+#include <unotools/streamhelper.hxx>
+#endif
+#ifndef _CPPUHELPER_EXTRACT_HXX_
+#include <cppuhelper/extract.hxx>
+#endif
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+//==================================================================
+// OImageControlModel
+//==================================================================
+
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OImageControlModel_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new OImageControlModel(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> OImageControlModel::_getTypes()
+{
+ static staruno::Sequence<staruno::Type> aTypes;
+ if (!aTypes.getLength())
+ {
+ // my base class
+ staruno::Sequence<staruno::Type> aBaseClassTypes = OBoundControlModel::_getTypes();
+
+ staruno::Sequence<staruno::Type> aOwnTypes(1);
+ staruno::Type* pOwnTypes = aOwnTypes.getArray();
+ pOwnTypes[0] = getCppuType((staruno::Reference<starform::XImageProducerSupplier>*)NULL);
+
+ aTypes = concatSequences(aBaseClassTypes, aOwnTypes);
+ }
+ return aTypes;
+}
+
+DBG_NAME(OImageControlModel)
+//------------------------------------------------------------------
+OImageControlModel::OImageControlModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OBoundControlModel(_rxFactory, VCL_CONTROLMODEL_IMAGECONTROL, FRM_CONTROL_IMAGECONTROL, sal_False)
+ // use the old control name for compytibility reasons
+ ,OPropertyChangeListener(m_aMutex)
+ ,m_pImageProducer(new ImageProducer)
+ ,m_bReadOnly(sal_False)
+{
+ DBG_CTOR(OImageControlModel,NULL);
+
+ m_xImageProducer = m_pImageProducer;
+
+ m_sDataFieldConnectivityProperty = PROPERTY_IMAGE_URL;
+ increment(m_refCount);
+ if (m_xAggregateSet.is())
+ {
+ OPropertyChangeMultiplexer* pMultiplexer = new OPropertyChangeMultiplexer(this, m_xAggregateSet);
+ pMultiplexer->addProperty(PROPERTY_IMAGE_URL);
+ }
+ decrement(m_refCount);
+}
+
+//------------------------------------------------------------------
+OImageControlModel::~OImageControlModel()
+{
+ if (!OComponentHelper::rBHelper.bDisposed)
+ {
+ acquire();
+ dispose();
+ }
+
+ DBG_DTOR(OImageControlModel,NULL);
+}
+
+// starlang::XServiceInfo
+//------------------------------------------------------------------------------
+StringSequence OImageControlModel::getSupportedServiceNames() throw()
+{
+ StringSequence aSupported = OBoundControlModel::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 2);
+
+ ::rtl::OUString*pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-2] = ::rtl::OUString::createFromAscii("com.sun.star.form.component.starform");
+ pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_IMAGECONTROL;
+ return aSupported;
+}
+
+//------------------------------------------------------------------------------
+staruno::Any SAL_CALL OImageControlModel::queryAggregation(const staruno::Type& _rType) throw (staruno::RuntimeException)
+{
+ staruno::Any aReturn;
+
+ aReturn = OBoundControlModel::queryAggregation(_rType);
+ if (!aReturn.hasValue())
+ aReturn = ::cppu::queryInterface(_rType
+ ,static_cast<starform::XImageProducerSupplier*>(this)
+ );
+
+ return aReturn;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OImageControlModel::_approve(sal_Int32 _nColumnType)
+{
+ // zulaessing sind die binary Typen, OTHER- und LONGVARCHAR-Felder
+ if ((_nColumnType == starsdbc::DataType::BINARY) || (_nColumnType == starsdbc::DataType::VARBINARY)
+ || (_nColumnType == starsdbc::DataType::LONGVARBINARY) || (_nColumnType == starsdbc::DataType::OTHER)
+ || (_nColumnType == starsdbc::DataType::LONGVARCHAR))
+ return sal_True;
+
+ return sal_False;
+}
+
+
+//------------------------------------------------------------------------------
+void OImageControlModel::_propertyChanged( const starbeans::PropertyChangeEvent& rEvt )
+ throw( staruno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ // Wenn eine starutil::URL gesetzt worden ist, muss die noch an den ImageProducer
+ // weitergereicht werden.
+ // xInStream erzeugen
+
+ staruno::Reference<stario::XActiveDataSink> xSink(
+ m_xServiceFactory->createInstance(
+ ::rtl::OUString::createFromAscii("com.sun.star.io.ObjectInputStream")), staruno::UNO_QUERY);
+ if (!xSink.is())
+ return;
+
+ // SvStream am xInStream setzen
+ INetURLObject aURLObj(getString(rEvt.NewValue));
+ String aPath = INetURLObject::decode(aURLObj.PathToFileName(), '%', INetURLObject::DECODE_UNAMBIGUOUS);
+
+ SvFileStream* pFileStream = new SvFileStream();
+ pFileStream->Open(aPath, STREAM_READ);
+ sal_Bool bSetNull = !pFileStream->IsOpen();
+
+ if (!bSetNull)
+ {
+ // get the size of the stream
+ pFileStream->Seek(STREAM_SEEK_TO_END);
+ sal_Int32 nSize = (sal_Int32)pFileStream->Tell();
+ if (pFileStream->GetBufferSize() < 8192)
+ pFileStream->SetBufferSize(8192);
+
+ staruno::Reference<stario::XInputStream> xInput
+ (new ::utl::OInputStreamHelper(new SvLockBytes(pFileStream, sal_True),
+ pFileStream->GetBufferSize()));
+ xSink->setInputStream(xInput);
+ staruno::Reference<stario::XInputStream> xInStream(xSink, staruno::UNO_QUERY);
+ if (m_xColumnUpdate.is())
+ m_xColumnUpdate->updateBinaryStream(xInStream, xInput->available());
+ else
+ {
+ GetImageProducer()->setImage( xInStream );
+ m_xImageProducer->startProduction();
+ }
+
+ // usually the setBinaryStream should close the input, but just in case ....
+ try { xInStream->closeInput(); } catch (stario::NotConnectedException& e) { e; }
+ }
+ else
+ {
+ if (m_xColumnUpdate.is())
+ m_xColumnUpdate->updateNull();
+ else
+ {
+ staruno::Reference<stario::XInputStream> xInStream;
+ GetImageProducer()->setImage( xInStream );
+ m_xImageProducer->startProduction();
+ }
+ delete pFileStream;
+ }
+}
+
+//------------------------------------------------------------------------------
+void OImageControlModel::getFastPropertyValue(staruno::Any& rValue, sal_Int32 nHandle) const
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_READONLY : rValue <<= (sal_Bool)m_bReadOnly; break;
+ default:
+ OBoundControlModel::getFastPropertyValue(rValue, nHandle);
+ }
+}
+
+//------------------------------------------------------------------------------
+void OImageControlModel::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const staruno::Any& rValue)
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_READONLY :
+ DBG_ASSERT(rValue.getValueType().getTypeClass() == staruno::TypeClass_BOOLEAN, "OImageControlModel::setFastPropertyValue_NoBroadcast : invalid type !" );
+ m_bReadOnly = getBOOL(rValue);
+ break;
+
+ default:
+ OBoundControlModel::setFastPropertyValue_NoBroadcast(nHandle, rValue);
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OImageControlModel::convertFastPropertyValue(staruno::Any& rConvertedValue, staruno::Any& rOldValue, sal_Int32 nHandle, const staruno::Any& rValue)
+ throw( starlang::IllegalArgumentException )
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_READONLY :
+ return tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bReadOnly);
+
+ default:
+ return OBoundControlModel::convertFastPropertyValue(rConvertedValue, rOldValue, nHandle, rValue);
+ }
+}
+
+//------------------------------------------------------------------------------
+staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL OImageControlModel::getPropertySetInfo() throw( staruno::RuntimeException )
+{
+ staruno::Reference<starbeans::XPropertySetInfo> xInfo(createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//------------------------------------------------------------------------------
+void OImageControlModel::fillProperties(
+ staruno::Sequence< starbeans::Property >& _rProps,
+ staruno::Sequence< starbeans::Property >& _rAggregateProps ) const
+{
+ FRM_BEGIN_PROP_HELPER(9)
+// ModifyPropertyAttributes(_rAggregateProps, PROPERTY_IMAGE_URL, starbeans::PropertyAttribute::TRANSIENT, 0);
+
+ DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT);
+ DECL_BOOL_PROP1(READONLY, BOUND);
+ DECL_PROP1(NAME, ::rtl::OUString, BOUND);
+ DECL_PROP1(TAG, ::rtl::OUString, BOUND);
+ DECL_PROP1(CONTROLSOURCE, ::rtl::OUString, BOUND);
+ DECL_PROP1(HELPTEXT, ::rtl::OUString, BOUND);
+ DECL_IFACE_PROP2(BOUNDFIELD, starbeans::XPropertySet, READONLY, TRANSIENT);
+ DECL_IFACE_PROP2(CONTROLLABEL, starbeans::XPropertySet, BOUND, MAYBEVOID);
+ DECL_PROP2(CONTROLSOURCEPROPERTY, rtl::OUString, READONLY, TRANSIENT);
+ FRM_END_PROP_HELPER();
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OImageControlModel::getInfoHelper()
+{
+ return *const_cast<OImageControlModel*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString OImageControlModel::getServiceName()
+{
+ return FRM_COMPONENT_IMAGECONTROL; // old (non-sun) name for compatibility !
+}
+
+//------------------------------------------------------------------------------
+void OImageControlModel::write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream)
+{
+ // Basisklasse
+ OBoundControlModel::write(_rxOutStream);
+ // Version
+ _rxOutStream->writeShort(0x0003);
+ // Name
+ _rxOutStream->writeBoolean(m_bReadOnly);
+ _rxOutStream << m_aHelpText;
+ // from version 0x0003 : common properties
+ writeCommonProperties(_rxOutStream);
+}
+
+//------------------------------------------------------------------------------
+void OImageControlModel::read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream)
+{
+ OBoundControlModel::read(_rxInStream);
+
+ // Version
+ sal_uInt16 nVersion = _rxInStream->readShort();
+ switch (nVersion)
+ {
+ case 0x0001:
+ m_bReadOnly = _rxInStream->readBoolean();
+ break;
+ case 0x0002:
+ m_bReadOnly = _rxInStream->readBoolean();
+ _rxInStream >> m_aHelpText;
+ break;
+ case 0x0003:
+ m_bReadOnly = _rxInStream->readBoolean();
+ _rxInStream >> m_aHelpText;
+ readCommonProperties(_rxInStream);
+ break;
+ default :
+ DBG_ERROR("OImageControlModel::read : unknown version !");
+ m_bReadOnly = sal_False;
+ defaultCommonProperties();
+ break;
+ }
+ // Nach dem Lesen die Defaultwerte anzeigen
+ if (m_aControlSource.getLength())
+ { // (not if we don't have a control source - the "State" property acts like it is persistent, then
+ ::osl::MutexGuard aGuard(m_aMutex); // _reset expects this mutex guarding
+ _reset();
+ }
+}
+
+// starbeans::XPropertyChangeListener
+//------------------------------------------------------------------------------
+void OImageControlModel::_onValueChanged()
+{
+ UpdateFromField();
+}
+
+//------------------------------------------------------------------------------
+staruno::Any OImageControlModel::_getControlValue() const
+{
+ // hier macht ein Vergleich keinen Sinn, daher void siehe OBoundControlModel
+ return staruno::Any();
+}
+
+// OComponentHelper
+//------------------------------------------------------------------
+void OImageControlModel::disposing()
+{
+ OBoundControlModel::disposing();
+
+#if SUPD<583
+ XInputStreamRef xInStream;
+#else
+ staruno::Reference<stario::XInputStream> xInStream;
+#endif
+ GetImageProducer()->setImage( xInStream );
+ m_xImageProducer->startProduction();
+}
+
+//------------------------------------------------------------------------------
+void OImageControlModel::_reset()
+{
+#if SUPD<583
+ XInputStreamRef xDummy;
+#else
+ staruno::Reference<stario::XInputStream> xDummy;
+#endif
+ GetImageProducer()->setImage(xDummy);
+ staruno::Reference<starawt::XImageProducer> xProducer = m_xImageProducer;
+ { // release our mutex once (it's acquired in the calling method !), as starting the image production may
+ // result in the locking of the solar mutex (unfortunally the default implementation of our aggregate,
+ // VCLXImageControl, does this locking)
+ // FS - 74438 - 30.03.00
+ MutexRelease aRelease(m_aMutex);
+ xProducer->startProduction();
+ }
+}
+
+// Helper functions
+//------------------------------------------------------------------------------
+void OImageControlModel::UpdateFromField()
+{
+ staruno::Reference<stario::XInputStream> xInStream;
+ xInStream = m_xColumn->getBinaryStream();
+
+#if SUPD<583
+ //------------------------------------------------------------
+ // temporary as long as the ImageProducer is a Smart-UNO-Class
+ XInputStreamRef xUsrIFace;
+ convertIFace(xInStream, xUsrIFace);
+ GetImageProducer()->setImage(xUsrIFace);
+ //------------------------------------------------------------
+#else
+ GetImageProducer()->setImage(xInStream);
+#endif
+
+ m_xImageProducer->startProduction();
+}
+
+//==================================================================
+// OImageControlControl
+//==================================================================
+
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OImageControlControl_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new OImageControlControl(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> OImageControlControl::_getTypes()
+{
+ static staruno::Sequence<staruno::Type> aTypes;
+ if (!aTypes.getLength())
+ {
+ // my base class
+ staruno::Sequence<staruno::Type> aBaseClassTypes = OBoundControl::_getTypes();
+
+ staruno::Sequence<staruno::Type> aOwnTypes(1);
+ staruno::Type* pOwnTypes = aOwnTypes.getArray();
+ pOwnTypes[0] = getCppuType((staruno::Reference<starawt::XMouseListener>*)NULL);
+
+ aTypes = concatSequences(aBaseClassTypes, aOwnTypes);
+ }
+ return aTypes;
+}
+
+//------------------------------------------------------------------------------
+OImageControlControl::OImageControlControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OBoundControl(_rxFactory, VCL_CONTROL_IMAGECONTROL)
+{
+ increment(m_refCount);
+ {
+ // als Focus- und MouseListener anmelden
+ staruno::Reference<starawt::XWindow> xComp;
+ query_aggregation( m_xAggregate, xComp);
+ if (xComp.is())
+ xComp->addMouseListener(this);
+ }
+ // Refcount bei 1 fuer den Listener
+ sal_Int32 n = decrement(m_refCount);
+}
+
+// UNO Anbindung
+//------------------------------------------------------------------------------
+staruno::Any SAL_CALL OImageControlControl::queryAggregation(const staruno::Type& _rType) throw (staruno::RuntimeException)
+{
+ staruno::Any aReturn;
+
+ aReturn = OBoundControl::queryAggregation(_rType);
+ if (!aReturn.hasValue())
+ aReturn = ::cppu::queryInterface(_rType
+ ,static_cast<starawt::XMouseListener*>(this)
+ );
+
+ return aReturn;
+}
+
+//------------------------------------------------------------------------------
+StringSequence OImageControlControl::getSupportedServiceNames() throw()
+{
+ StringSequence aSupported = OBoundControl::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 1);
+
+ ::rtl::OUString*pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_IMAGECONTROL;
+ return aSupported;
+}
+
+// starawt::XControl
+//------------------------------------------------------------------------------
+void SAL_CALL OImageControlControl::createPeer(const staruno::Reference<starawt::XToolkit>& _rxToolkit, const staruno::Reference<starawt::XWindowPeer>& Parent) throw( staruno::RuntimeException )
+{
+ OBoundControl::createPeer(_rxToolkit, Parent);
+ if (!m_xControl.is())
+ return;
+
+ // ImageConsumer vom Control holen
+ staruno::Reference<starawt::XWindowPeer> xPeer = m_xControl->getPeer();
+ staruno::Reference<starawt::XImageConsumer> xImageConsumer(xPeer, staruno::UNO_QUERY);
+ if (!xImageConsumer.is())
+ return;
+
+ // ImageConsumer am Imageproducer setzen
+ staruno::Reference<starform::XImageProducerSupplier> xImageSource(m_xControl->getModel(), staruno::UNO_QUERY);
+ if (!xImageSource.is())
+ return;
+ staruno::Reference<starawt::XImageProducer> xImageProducer = xImageSource->getImageProducer();
+
+ xImageProducer->addConsumer(xImageConsumer);
+ xImageProducer->startProduction();
+}
+
+// MouseListener
+//------------------------------------------------------------------------------
+void OImageControlControl::mousePressed(const starawt::MouseEvent& e)
+{
+ //////////////////////////////////////////////////////////////////////
+ // Nur linke Maustaste
+ if (e.Buttons != starawt::MouseButton::LEFT)
+ return;
+
+ //////////////////////////////////////////////////////////////////////
+ // Doppelclick
+ if (e.ClickCount == 2)
+ {
+
+ staruno::Reference<starbeans::XPropertySet> xSet(getModel(), staruno::UNO_QUERY);
+ if (!xSet.is())
+ return;
+
+ // wenn Control nicht gebunden ist, kein Dialog (da die zu schickende URL hinterher sowieso
+ // versanden wuerde)
+ // FS - #64946# - 19.04.99
+ staruno::Reference<starbeans::XPropertySet> xBoundField;
+ if (hasProperty(PROPERTY_BOUNDFIELD, xSet))
+ ::cppu::extractInterface(xBoundField, xSet->getPropertyValue(PROPERTY_BOUNDFIELD));
+ if (!xBoundField.is())
+ {
+ // but only if our IMAGE_URL property is handled as if it is transient, which is equivalent to
+ // an empty control source
+ if (!hasProperty(PROPERTY_CONTROLSOURCE, xSet) || (::utl::getString(xSet->getPropertyValue(PROPERTY_CONTROLSOURCE)).getLength() != 0))
+ return;
+ }
+
+ sal_Bool bReadOnly;
+ xSet->getPropertyValue(PROPERTY_READONLY) >>= bReadOnly;
+ if (bReadOnly)
+ return;
+
+ ::rtl::OUString sTitle = FRM_RES_STRING(RID_STR_IMPORT_GRAPHIC);
+ // build some arguments for the upcoming dialog
+ staruno::Sequence<staruno::Any> aParams(4);
+ aParams.getArray()[0] = staruno::makeAny(starbeans::PropertyValue(
+ ::rtl::OUString::createFromAscii("Title"), -1,
+ staruno::makeAny(sTitle), starbeans::PropertyState_DIRECT_VALUE
+ ));
+ aParams.getArray()[1] = staruno::makeAny(starbeans::PropertyValue(
+ ::rtl::OUString::createFromAscii("PreviewActive"), -1,
+ staruno::makeAny((sal_Bool)sal_True), starbeans::PropertyState_DIRECT_VALUE
+ ));
+ aParams.getArray()[2] = staruno::makeAny(starbeans::PropertyValue(
+ ::rtl::OUString::createFromAscii("AllowEmptyFileNames"), -1,
+ staruno::makeAny((sal_Bool)sal_True), starbeans::PropertyState_DIRECT_VALUE
+ ));
+ staruno::Reference<starawt::XWindow> xWindow(getPeer(), staruno::UNO_QUERY);
+ aParams.getArray()[3] = staruno::makeAny(starbeans::PropertyValue(
+ ::rtl::OUString::createFromAscii("ParentWindow"), -1,
+ staruno::makeAny(xWindow), starbeans::PropertyState_DIRECT_VALUE
+ ));
+
+ try
+ {
+ staruno::Reference<starawt::XDialog> xDialog(
+ m_xServiceFactory->createInstanceWithArguments(
+ ::rtl::OUString::createFromAscii("com.sun.star.dialogs.ImportGraphicsDialog"),
+ aParams),
+ staruno::UNO_QUERY
+ );
+
+ staruno::Reference<starbeans::XPropertySet> xDialogProps(xDialog, staruno::UNO_QUERY);
+ if (xDialog.is() && xDialogProps.is() && xDialog->execute())
+ {
+ staruno::Any aSelectedPath = xDialogProps->getPropertyValue(::rtl::OUString::createFromAscii("SelectedPath"));
+ if (aSelectedPath.getValueType().getTypeClass() == staruno::TypeClass_STRING)
+ {
+ xSet->setPropertyValue(PROPERTY_IMAGE_URL, ::com::sun::star::uno::makeAny(::rtl::OUString()));
+ // reset the url property in case it already has the value we're about to set - in this case
+ // our propertyChanged would not get called without this.
+ xSet->setPropertyValue(PROPERTY_IMAGE_URL, aSelectedPath);
+ }
+ }
+ }
+ catch(...)
+ {
+ }
+ }
+}
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
diff --git a/forms/source/component/ImageControl.hxx b/forms/source/component/ImageControl.hxx
new file mode 100644
index 000000000000..1d4a4eae4705
--- /dev/null
+++ b/forms/source/component/ImageControl.hxx
@@ -0,0 +1,201 @@
+/*************************************************************************
+ *
+ * $RCSfile: ImageControl.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FRM_IMAGE_CONTROL_HXX_
+#define _FRM_IMAGE_CONTROL_HXX_
+
+#include "FormComponent.hxx"
+
+#ifndef _PRODUCE_HXX //autogen
+#include <svtools/imgprod.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_FORM_XIMAGEPRODUCERSUPPLIER_HPP_
+#include <com/sun/star/form/XImageProducerSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XMOUSELISTENER_HPP_
+#include <com/sun/star/awt/XMouseListener.hpp>
+#endif
+
+#ifndef _UNOTOOLS_PROPERTY_MULTIPLEX_HXX_
+#include <unotools/propmultiplex.hxx>
+#endif
+using namespace utl;
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+//==================================================================
+// OImageControlModel
+//==================================================================
+class OImageControlModel
+ :public starform::XImageProducerSupplier
+ ,public ::utl::OAggregationArrayUsageHelper<OImageControlModel>
+ ,public OBoundControlModel
+ ,public OPropertyChangeListener
+{
+ staruno::Reference<starawt::XImageProducer> m_xImageProducer;
+ ImageProducer* m_pImageProducer;
+ sal_Bool m_bReadOnly;
+
+ // Helper functions
+ void UpdateFromField();
+
+protected:
+ // UNO Anbindung
+ virtual staruno::Sequence<staruno::Type> _getTypes();
+ virtual void _onValueChanged();
+
+ virtual sal_Bool _approve(sal_Int32 _nColumnType);
+
+ inline ImageProducer* GetImageProducer() { return m_pImageProducer; }
+
+public:
+ OImageControlModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+ virtual ~OImageControlModel();
+
+ virtual void SAL_CALL getFastPropertyValue(staruno::Any& rValue, sal_Int32 nHandle ) const;
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const staruno::Any& rValue);
+
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(staruno::Any& rConvertedValue, staruno::Any& rOldValue, sal_Int32 nHandle, const staruno::Any& rValue )
+ throw(starlang::IllegalArgumentException);
+
+ // UNO Anbindung
+ DECLARE_UNO3_AGG_DEFAULTS(OImageControlModel, OBoundControlModel);
+ virtual staruno::Any SAL_CALL queryAggregation(const staruno::Type& _rType) throw(staruno::RuntimeException);
+
+// starform::XBoundComponent
+ virtual staruno::Any _getControlValue() const;
+ virtual void _reset();
+
+// starlang::XServiceInfo
+ IMPLEMENTATION_NAME(OImageControlModel);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
+
+// OComponentHelper
+ virtual void SAL_CALL disposing();
+
+// OPropertyChangeListener
+ virtual void _propertyChanged( const starbeans::PropertyChangeEvent& ) throw(staruno::RuntimeException);
+
+// staruno::Reference<starbeans::XPropertySet>
+ virtual staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(staruno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+// stario::XPersistObject
+ virtual ::rtl::OUString SAL_CALL getServiceName();
+ virtual void SAL_CALL write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream);
+ virtual void SAL_CALL read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream);
+
+// starform::XImageProducerSupplier
+ virtual staruno::Reference<starawt::XImageProducer> SAL_CALL getImageProducer() { return m_xImageProducer; }
+
+// ::utl::OAggregationArrayUsageHelper
+ virtual void fillProperties(
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rProps,
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rAggregateProps
+ ) const;
+ IMPLEMENT_INFO_SERVICE()
+};
+
+//==================================================================
+// OImageControlControl
+//==================================================================
+class OImageControlControl : public starawt::XMouseListener,
+ public OBoundControl
+{
+protected:
+ // UNO Anbindung
+ virtual staruno::Sequence<staruno::Type> _getTypes();
+
+public:
+ OImageControlControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+
+// UNO Anbindung
+ DECLARE_UNO3_AGG_DEFAULTS(OImageControlControl, OBoundControl);
+ virtual staruno::Any SAL_CALL queryAggregation(const staruno::Type& _rType) throw(staruno::RuntimeException);
+
+// starlang::XEventListener
+ virtual void SAL_CALL disposing(const starlang::EventObject& _rSource) throw(staruno::RuntimeException)
+ { OBoundControl::disposing(_rSource); }
+
+// starlang::XServiceInfo
+ IMPLEMENTATION_NAME(OImageControlControl);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
+
+// starawt::XMouseListener
+ virtual void SAL_CALL mousePressed(const starawt::MouseEvent& e);
+ virtual void SAL_CALL mouseReleased(const starawt::MouseEvent& e) { }
+ virtual void SAL_CALL mouseEntered(const starawt::MouseEvent& e) { }
+ virtual void SAL_CALL mouseExited(const starawt::MouseEvent& e) { }
+
+// starawt::XControl
+ virtual void SAL_CALL createPeer(const staruno::Reference<starawt::XToolkit>& _rToolkit, const staruno::Reference<starawt::XWindowPeer>& _rParent) throw(staruno::RuntimeException);
+};
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
+#endif // _FRM_IMAGE_CONTROL_HXX_
+
diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx
new file mode 100644
index 000000000000..fa097dfe5261
--- /dev/null
+++ b/forms/source/component/ListBox.cxx
@@ -0,0 +1,1330 @@
+/*************************************************************************
+ *
+ * $RCSfile: ListBox.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:05 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_LISTBOX_HXX_
+#include "ListBox.hxx"
+#endif
+#ifndef _FRM_PROPERTY_HXX_
+#include "property.hxx"
+#endif
+#ifndef _FRM_PROPERTY_HRC_
+#include "property.hrc"
+#endif
+#ifndef _FRM_SERVICES_HXX_
+#include "services.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _FRM_RESOURCE_HXX_
+#include "frm_resource.hxx"
+#endif
+#ifndef _FRM_RESOURCE_HRC_
+#include "frm_resource.hrc"
+#endif
+#ifndef _FORMS_BASELISTBOX_HXX_
+#include "BaseListBox.hxx"
+#endif
+#ifndef _UTL_CONTAINER_HXX_
+#include <unotools/container.hxx>
+#endif
+#ifndef _UNOTOOLS_DATETIME_HXX_
+#include <unotools/datetime.hxx>
+#endif
+#ifndef _UTL_NUMBERS_HXX_
+#include <unotools/numbers.hxx>
+#endif
+#ifndef _UTL_UNO3_DB_TOOLS_HXX_
+#include <unotools/dbtools.hxx>
+#endif
+#ifndef _UTL_DB_CONVERSION_HXX_
+#include <unotools/dbconversion.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_SDB_SQLERROREVENT_HPP_
+#include <com/sun/star/sdb/SQLErrorEvent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROWSET_HPP_
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
+#include <com/sun/star/container/XIndexAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_
+#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_
+#include <com/sun/star/util/NumberFormat.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XLISTBOX_HPP_
+#include <com/sun/star/awt/XListBox.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_
+#include <com/sun/star/awt/XWindow.hpp>
+#endif
+
+//.........................................................................
+namespace frm
+{
+
+//==================================================================
+//= OListBoxModel
+//==================================================================
+sal_Int32 OListBoxModel::nSelectHandle = -1;
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OListBoxModel_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory) throw (staruno::RuntimeException)
+{
+ return *(new OListBoxModel(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> OListBoxModel::_getTypes()
+{
+ static staruno::Sequence<staruno::Type> aTypes;
+ if (!aTypes.getLength())
+ {
+ // my two base classes
+ staruno::Sequence<staruno::Type> aBaseClassTypes = OBoundControlModel::_getTypes();
+
+ staruno::Sequence<staruno::Type> aOwnTypes(2);
+ staruno::Type* pOwnTypes = aOwnTypes.getArray();
+ pOwnTypes[0] = getCppuType((staruno::Reference<starsdb::XSQLErrorBroadcaster>*)NULL);
+ pOwnTypes[1] = getCppuType((staruno::Reference<starutil::XRefreshable>*)NULL);
+
+ aTypes = concatSequences(aBaseClassTypes, aOwnTypes);
+ }
+ return aTypes;
+}
+
+
+DBG_NAME(OListBoxModel);
+//------------------------------------------------------------------
+OListBoxModel::OListBoxModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OBoundControlModel(_rxFactory, VCL_CONTROLMODEL_LISTBOX, FRM_CONTROL_LISTBOX)
+ // use the old control name for compytibility reasons
+ ,m_aRefreshListeners(m_aMutex)
+ ,m_bBoundComponent(sal_False)
+ ,m_nNULLPos(-1)
+ ,m_aErrorListeners(m_aMutex)
+{
+ DBG_CTOR(OListBoxModel,NULL);
+
+ m_nClassId = starform::FormComponentType::LISTBOX;
+ m_eListSourceType = starform::ListSourceType_VALUELIST;
+ m_aBoundColumn <<= (sal_Int16)1;
+ m_sDataFieldConnectivityProperty = PROPERTY_SELECT_SEQ;
+ if (OListBoxModel::nSelectHandle == -1)
+ OListBoxModel::nSelectHandle = getOriginalHandle(PROPERTY_ID_SELECT_SEQ);
+}
+
+//------------------------------------------------------------------
+OListBoxModel::~OListBoxModel()
+{
+ if (!OComponentHelper::rBHelper.bDisposed)
+ {
+ acquire();
+ dispose();
+ }
+
+ DBG_DTOR(OListBoxModel,NULL);
+}
+
+// XServiceInfo
+//------------------------------------------------------------------------------
+StringSequence SAL_CALL OListBoxModel::getSupportedServiceNames() throw(staruno::RuntimeException)
+{
+ StringSequence aSupported = OBoundControlModel::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 2);
+
+ ::rtl::OUString* pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-2] = ::rtl::OUString::createFromAscii("com.sun.star.form.component.DatabaseListBox");
+ pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_LISTBOX;
+ return aSupported;
+}
+
+//------------------------------------------------------------------------------
+staruno::Any SAL_CALL OListBoxModel::queryAggregation(const staruno::Type& _rType) throw (staruno::RuntimeException)
+{
+ staruno::Any aReturn;
+
+ aReturn = OBoundControlModel::queryAggregation(_rType);
+ if (!aReturn.hasValue())
+ aReturn = ::cppu::queryInterface(_rType
+ ,static_cast<starutil::XRefreshable*>(this)
+ ,static_cast<starsdb::XSQLErrorBroadcaster*>(this)
+ );
+
+ return aReturn;
+}
+
+// OComponentHelper
+//------------------------------------------------------------------------------
+void OListBoxModel::disposing()
+{
+ starlang::EventObject aEvt(static_cast<staruno::XWeak*>(this));
+ m_aRefreshListeners.disposeAndClear(aEvt);
+ OBoundControlModel::disposing();
+}
+
+// XRefreshable
+//------------------------------------------------------------------------------
+void SAL_CALL OListBoxModel::addRefreshListener(const staruno::Reference<starutil::XRefreshListener>& _rxListener) throw(staruno::RuntimeException)
+{
+ m_aRefreshListeners.addInterface(_rxListener);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OListBoxModel::removeRefreshListener(const staruno::Reference<starutil::XRefreshListener>& _rxListener) throw(staruno::RuntimeException)
+{
+ m_aRefreshListeners.removeInterface(_rxListener);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OListBoxModel::refresh() throw(staruno::RuntimeException)
+{
+ {
+ ::osl::MutexGuard aGuard(m_aMutex);
+ if (m_eListSourceType != starform::ListSourceType_VALUELIST)
+ {
+ if (m_xField.is())
+ m_aValueSeq = StringSequence();
+
+ if (m_xCursor.is())
+ loadData();
+ }
+ }
+
+ starlang::EventObject aEvt(static_cast<staruno::XWeak*>(this));
+ NOTIFY_LISTENERS(m_aRefreshListeners, starutil::XRefreshListener, refreshed, aEvt);
+}
+
+//------------------------------------------------------------------------------
+void OListBoxModel::getFastPropertyValue(staruno::Any& _rValue, sal_Int32 _nHandle) const
+{
+ switch (_nHandle)
+ {
+ case PROPERTY_ID_BOUNDCOLUMN:
+ _rValue <<= m_aBoundColumn;
+ break;
+
+ case PROPERTY_ID_LISTSOURCETYPE:
+ _rValue <<= m_eListSourceType;
+ break;
+
+ case PROPERTY_ID_LISTSOURCE:
+ _rValue <<= m_aListSourceSeq;
+ break;
+
+ case PROPERTY_ID_VALUE_SEQ:
+ _rValue <<= m_aValueSeq;
+ break;
+
+ case PROPERTY_ID_DEFAULT_SELECT_SEQ:
+ _rValue <<= m_aDefaultSelectSeq;
+ break;
+
+ default:
+ OBoundControlModel::getFastPropertyValue(_rValue, _nHandle);
+ }
+}
+
+//------------------------------------------------------------------------------
+void OListBoxModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const staruno::Any& _rValue) throw (com::sun::star::uno::Exception)
+{
+ switch (_nHandle)
+ {
+ case PROPERTY_ID_BOUNDCOLUMN :
+ DBG_ASSERT((_rValue.getValueType().getTypeClass() == staruno::TypeClass_SHORT) || (_rValue.getValueType().getTypeClass() == staruno::TypeClass_VOID),
+ "OListBoxModel::setFastPropertyValue_NoBroadcast : invalid type !" );
+ m_aBoundColumn = _rValue;
+ break;
+
+ case PROPERTY_ID_LISTSOURCETYPE :
+ DBG_ASSERT(_rValue.getValueType().equals(::getCppuType(reinterpret_cast<starform::ListSourceType*>(NULL))),
+ "OComboBoxModel::setFastPropertyValue_NoBroadcast : invalid type !" );
+ _rValue >>= m_eListSourceType;
+ break;
+
+ case PROPERTY_ID_LISTSOURCE :
+ DBG_ASSERT(_rValue.getValueType().equals(::getCppuType(reinterpret_cast<StringSequence*>(NULL))),
+ "OListBoxModel::setFastPropertyValue_NoBroadcast : invalid type !" );
+ _rValue >>= m_aListSourceSeq;
+
+ if (m_eListSourceType == starform::ListSourceType_VALUELIST)
+ m_aValueSeq = m_aListSourceSeq;
+ else if (m_xCursor.is() && !m_xField.is()) // Listbox bereits mit Datenbank verbunden
+ // Aenderung der Datenquelle -> neu laden
+ loadData();
+
+ break;
+
+ case PROPERTY_ID_VALUE_SEQ :
+ DBG_ASSERT(_rValue.getValueType().equals(::getCppuType(reinterpret_cast<StringSequence*>(NULL))),
+ "OListBoxModel::setFastPropertyValue_NoBroadcast : invalid type !" );
+ _rValue >>= m_aValueSeq;
+ break;
+
+ case PROPERTY_ID_DEFAULT_SELECT_SEQ :
+ DBG_ASSERT(_rValue.getValueType().equals(::getCppuType(reinterpret_cast<staruno::Sequence<sal_Int16>*>(NULL))),
+ "OListBoxModel::setFastPropertyValue_NoBroadcast : invalid type !" );
+ _rValue >>= m_aDefaultSelectSeq;
+
+ DBG_ASSERT(m_xAggregateFastSet.is(), "OListBoxModel::setFastPropertyValue_NoBroadcast(DEFAULT_SELECT_SEQ) : invalid aggregate !");
+ if (m_xAggregateFastSet.is())
+ { // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
+ // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
+ // our own mutex locked
+ // FS - 72451 - 31.01.00
+ MutexRelease aRelease(m_aMutex);
+ m_xAggregateFastSet->setFastPropertyValue(OListBoxModel::nSelectHandle, _rValue);
+ }
+ break;
+
+ default:
+ OBoundControlModel::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
+ }
+
+ if (PROPERTY_ID_STRINGITEMLIST == _nHandle)
+ _reset();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OListBoxModel::convertFastPropertyValue(
+ staruno::Any& _rConvertedValue, staruno::Any& _rOldValue, sal_Int32 _nHandle, const staruno::Any& _rValue)
+ throw (starlang::IllegalArgumentException)
+{
+ sal_Bool bModified(sal_False);
+ switch (_nHandle)
+ {
+ case PROPERTY_ID_BOUNDCOLUMN :
+ bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_aBoundColumn, ::getCppuType(reinterpret_cast<sal_Int16*>(NULL)));
+ break;
+
+ case PROPERTY_ID_LISTSOURCETYPE:
+ bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_eListSourceType);
+ break;
+
+ case PROPERTY_ID_LISTSOURCE:
+ bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_aListSourceSeq);
+ break;
+
+ case PROPERTY_ID_VALUE_SEQ :
+ bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_aValueSeq);
+ break;
+
+ case PROPERTY_ID_DEFAULT_SELECT_SEQ :
+ bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_aDefaultSelectSeq);
+ break;
+
+ default:
+ return OBoundControlModel::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
+ }
+ return bModified;
+}
+
+//------------------------------------------------------------------------------
+staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL OListBoxModel::getPropertySetInfo() throw(staruno::RuntimeException)
+{
+ staruno::Reference<starbeans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//------------------------------------------------------------------------------
+cppu::IPropertyArrayHelper& OListBoxModel::getInfoHelper()
+{
+ return *const_cast<OListBoxModel*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+void OListBoxModel::fillProperties(
+ staruno::Sequence< starbeans::Property >& _rProps,
+ staruno::Sequence< starbeans::Property >& _rAggregateProps ) const
+{
+ FRM_BEGIN_PROP_HELPER(14)
+ // die SelectSequence-Property soll transient sein ....
+ ModifyPropertyAttributes(_rAggregateProps, PROPERTY_SELECT_SEQ, starbeans::PropertyAttribute::TRANSIENT, 0);
+
+ DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT);
+ DECL_PROP1(NAME, ::rtl::OUString, BOUND);
+ DECL_PROP1(TAG, ::rtl::OUString, BOUND);
+ DECL_PROP1(TABINDEX, sal_Int16, BOUND);
+ DECL_PROP2(BOUNDCOLUMN, sal_Int16, BOUND, MAYBEVOID);
+ DECL_PROP1(LISTSOURCETYPE, starform::ListSourceType, BOUND);
+ DECL_PROP1(LISTSOURCE, StringSequence, BOUND);
+ DECL_PROP3(VALUE_SEQ, StringSequence, BOUND, READONLY, TRANSIENT);
+ DECL_PROP1(DEFAULT_SELECT_SEQ, staruno::Sequence<sal_Int16>, BOUND);
+ DECL_PROP1(CONTROLSOURCE, ::rtl::OUString, BOUND);
+ DECL_PROP1(HELPTEXT, ::rtl::OUString, BOUND);
+ DECL_IFACE_PROP2(BOUNDFIELD, starbeans::XPropertySet, READONLY, TRANSIENT);
+ DECL_IFACE_PROP2(CONTROLLABEL, starbeans::XPropertySet, BOUND, MAYBEVOID);
+ DECL_PROP2(CONTROLSOURCEPROPERTY, rtl::OUString, READONLY, TRANSIENT);
+ FRM_END_PROP_HELPER();
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OListBoxModel::getServiceName() throw(staruno::RuntimeException)
+{
+ return FRM_COMPONENT_LISTBOX; // old (non-sun) name for compatibility !
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OListBoxModel::write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream)
+ throw(stario::IOException, staruno::RuntimeException)
+{
+ OBoundControlModel::write(_rxOutStream);
+
+ // Dummy-Seq, um Kompatible zu bleiben, wenn SelectSeq nicht mehr gespeichert wird
+ staruno::Sequence<sal_Int16> aDummySeq;
+
+ // Version
+ // Version 0x0002: ListSource wird StringSeq
+ _rxOutStream->writeShort(0x0004);
+
+ // Maskierung fuer any
+ sal_uInt16 nAnyMask = 0;
+ if (m_aBoundColumn.getValueType().getTypeClass() != staruno::TypeClass_VOID)
+ nAnyMask |= BOUNDCOLUMN;
+
+ _rxOutStream << nAnyMask;
+
+ _rxOutStream << m_aListSourceSeq;
+ _rxOutStream << (sal_Int16)m_eListSourceType;
+ _rxOutStream << aDummySeq;
+ _rxOutStream << m_aDefaultSelectSeq;
+
+ if ((nAnyMask & BOUNDCOLUMN) == BOUNDCOLUMN)
+ {
+ sal_Int16 nBoundColumn;
+ m_aBoundColumn >>= nBoundColumn;
+ _rxOutStream << nBoundColumn;
+ }
+ _rxOutStream << m_aHelpText;
+
+ // from version 0x0004 : common properties
+ writeCommonProperties(_rxOutStream);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OListBoxModel::read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream) throw(stario::IOException, staruno::RuntimeException)
+{
+ // Bei manchen Variblen muessen Abhaengigkeiten beruecksichtigt werden.
+ // Deshalb muessen sie explizit ueber setPropertyValue() gesetzt werden.
+
+ OBoundControlModel::read(_rxInStream);
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ // Version
+ sal_uInt16 nVersion = _rxInStream->readShort();
+ DBG_ASSERT(nVersion > 0, "OListBoxModel::read : version 0 ? this should never have been written !");
+
+ if (nVersion > 0x0004)
+ {
+ DBG_ERROR("OListBoxModel::read : invalid (means unknown) version !");
+ m_aListSourceSeq.realloc(0);
+ m_aBoundColumn <<= (sal_Int16)0;
+ m_aValueSeq.realloc(0);
+ m_eListSourceType = starform::ListSourceType_VALUELIST;
+ m_aDefaultSelectSeq.realloc(0);
+ defaultCommonProperties();
+ return;
+ }
+
+ // Maskierung fuer any
+ sal_uInt16 nAnyMask;
+ _rxInStream >> nAnyMask;
+
+ // ListSourceSeq
+ StringSequence aListSourceSeq;
+ if (nVersion == 0x0001)
+ {
+ // ListSourceSeq aus String zusammenstellen;
+ ::rtl::OUString sListSource;
+ _rxInStream >> sListSource;
+
+ aListSourceSeq.realloc( sListSource.getTokenCount() );
+ for (sal_uInt16 i=0; i<sListSource.getTokenCount(); ++i)
+ aListSourceSeq.getArray()[i] = sListSource.getToken(i);
+ }
+ else
+ _rxInStream >> aListSourceSeq;
+
+ sal_Int16 nListSourceType;
+ _rxInStream >> nListSourceType;
+ m_eListSourceType = (starform::ListSourceType)nListSourceType;
+ staruno::Any aListSourceSeqAny;
+ aListSourceSeqAny <<= aListSourceSeq;
+
+ setFastPropertyValue(PROPERTY_ID_LISTSOURCE, aListSourceSeqAny );
+
+ // Dummy-Seq, um Kompatible zu bleiben, wenn SelectSeq nicht mehr gespeichert wird
+ staruno::Sequence<sal_Int16> aDummySeq;
+ _rxInStream >> aDummySeq;
+
+ // DefaultSelectSeq
+ staruno::Sequence<sal_Int16> aDefaultSelectSeq;
+ _rxInStream >> aDefaultSelectSeq;
+ staruno::Any aDefaultSelectSeqAny;
+ aDefaultSelectSeqAny <<= aDefaultSelectSeq;
+ setFastPropertyValue(PROPERTY_ID_DEFAULT_SELECT_SEQ, aDefaultSelectSeqAny);
+
+ // BoundColumn
+ if ((nAnyMask & BOUNDCOLUMN) == BOUNDCOLUMN)
+ {
+ sal_Int16 nValue;
+ _rxInStream >> nValue;
+ m_aBoundColumn <<= nValue;
+ }
+
+ if (nVersion > 2)
+ _rxInStream >> m_aHelpText;
+
+ // Stringliste muß gelehrt werden, wenn nicht ueber WerteListe gefuellt wird
+ // dieses kann der Fall sein wenn im alive modus gespeichert wird
+ if (m_eListSourceType != starform::ListSourceType_VALUELIST && m_xAggregateSet.is())
+ {
+ StringSequence aSequence;
+ setFastPropertyValue(PROPERTY_ID_STRINGITEMLIST, staruno::makeAny(aSequence));
+ }
+
+ if (nVersion > 3)
+ readCommonProperties(_rxInStream);
+
+ // Nach dem Lesen die Defaultwerte anzeigen
+ if (m_aControlSource.getLength())
+ // (not if we don't have a control source - the "State" property acts like it is persistent, then
+ _reset();
+}
+
+//------------------------------------------------------------------------------
+void OListBoxModel::loadData()
+{
+ DBG_ASSERT(m_eListSourceType != starform::ListSourceType_VALUELIST, "fuer Werteliste kein Laden aus der Datenbank")
+
+ m_nNULLPos = -1;
+ m_bBoundComponent = sal_False;
+
+ // Connection holen
+ staruno::Reference<starsdbc::XRowSet> xForm(m_xCursor, staruno::UNO_QUERY);
+ if (!xForm.is())
+ return;
+ staruno::Reference<starsdbc::XConnection> xConnection = getConnection(xForm);
+ if (!xConnection.is())
+ return;
+
+ // we need a com::sun::star::sdb::Connection for some of the code below ...
+ staruno::Reference<starlang::XServiceInfo> xServiceInfo(xConnection, staruno::UNO_QUERY);
+ if (!xServiceInfo.is() || !xServiceInfo->supportsService(SRV_SDB_CONNECTION))
+ {
+ DBG_ERROR("OListBoxModel::loadData : invalid connection !");
+ return;
+ }
+
+ staruno::Reference<starsdbc::XResultSet> xListCursor;
+
+ // Wenn der ListSourceType keine Werteliste ist,
+ // muss die String-Seq zu einem String zusammengefasst werden
+ ::rtl::OUString sListSource;
+ const ::rtl::OUString* pustrListSouceStrings = m_aListSourceSeq.getConstArray();
+ sal_Int32 i;
+ for (i=0; i<m_aListSourceSeq.getLength(); ++i)
+ sListSource = sListSource + pustrListSouceStrings[i];
+ if (!sListSource.len())
+ return;
+
+ sal_Int16 nBoundColumn = 0;
+ if (m_aBoundColumn.getValueType().getTypeClass() == staruno::TypeClass_SHORT)
+ m_aBoundColumn >>= nBoundColumn;
+
+ try
+ {
+ switch (m_eListSourceType)
+ {
+ case starform::ListSourceType_TABLEFIELDS:
+ // don't work with a statement here, the fields will be collected below
+ break;
+ case starform::ListSourceType_TABLE:
+ {
+ staruno::Reference<starcontainer::XNameAccess> xFieldsByName = getTableFields(xConnection, sListSource);
+ staruno::Reference<starcontainer::XIndexAccess> xFieldsByIndex(xFieldsByName, staruno::UNO_QUERY);
+
+ // do we have a bound column if yes we have to select it
+ // and the displayed column is the first column othwhise we act as a combobox
+ ::rtl::OUString aFieldName;
+ ::rtl::OUString aBoundFieldName;
+
+ if ((nBoundColumn > 0) && xFieldsByIndex.is())
+ {
+ if (xFieldsByIndex->getCount() <= nBoundColumn)
+ break;
+
+ staruno::Reference<starbeans::XPropertySet> xFieldAsSet;
+ xFieldsByIndex->getByIndex(nBoundColumn) >>= xFieldAsSet;
+ xFieldAsSet->getPropertyValue(PROPERTY_NAME) >>= aBoundFieldName;
+ nBoundColumn = 1;
+
+ xFieldsByIndex->getByIndex(0) >>= xFieldAsSet;
+ xFieldAsSet->getPropertyValue(PROPERTY_NAME) >>= aFieldName;
+ }
+ else if (xFieldsByName.is())
+ {
+ if (xFieldsByName->hasByName(m_aControlSource))
+ aFieldName = m_aControlSource;
+ else
+ {
+ // otherwise look for the alias
+ staruno::Reference<starsdb::XSQLQueryComposerFactory> xFactory(xConnection, staruno::UNO_QUERY);
+ if (!xFactory.is())
+ break;
+
+ staruno::Reference<starsdb::XSQLQueryComposer> xComposer = xFactory->createQueryComposer();
+ try
+ {
+ staruno::Reference<starbeans::XPropertySet> xFormAsSet(xForm, staruno::UNO_QUERY);
+ ::rtl::OUString aStatement;
+ xFormAsSet->getPropertyValue(PROPERTY_ACTIVECOMMAND) >>= aStatement;
+ xComposer->setQuery(aStatement);
+ }
+ catch(...)
+ {
+ disposeComponent(xComposer);
+ break;
+ }
+
+ // search the field
+ staruno::Reference<starsdbcx::XColumnsSupplier> xSupplyFields(xComposer, staruno::UNO_QUERY);
+ DBG_ASSERT(xSupplyFields.is(), "OListBoxModel::loadData : invalid query composer !");
+
+ staruno::Reference<starcontainer::XNameAccess> xFieldNames = xSupplyFields->getColumns();
+ if (xFieldNames->hasByName(m_aControlSource))
+ {
+ staruno::Reference<starbeans::XPropertySet> xComposerFieldAsSet;
+ xFieldNames->getByName(m_aControlSource) >>= xComposerFieldAsSet;
+ if (hasProperty(PROPERTY_FIELDSOURCE, xComposerFieldAsSet))
+ xComposerFieldAsSet->getPropertyValue(PROPERTY_FIELDSOURCE) >>= aFieldName;
+ }
+ disposeComponent(xComposer);
+ }
+ }
+ if (!aFieldName.len())
+ break;
+
+ staruno::Reference<starsdbc::XDatabaseMetaData> xMeta = xConnection->getMetaData();
+ ::rtl::OUString aQuote = xMeta->getIdentifierQuoteString();
+ ::rtl::OUString aStatement = ::rtl::OUString::createFromAscii("SELECT ");
+ if (!aBoundFieldName.getLength()) // act like a combobox
+ aStatement += ::rtl::OUString::createFromAscii("DISTINCT ");
+
+ aStatement += quoteName(aQuote,aFieldName);
+ if (aBoundFieldName.len())
+ {
+ aStatement += ::rtl::OUString::createFromAscii(", ");
+ aStatement += quoteName(aQuote, aBoundFieldName);
+ }
+ aStatement += ::rtl::OUString::createFromAscii(" FROM ");
+ aStatement += quoteTableName(xMeta, sListSource);
+
+ staruno::Reference<starsdbc::XStatement> xStmt = xConnection->createStatement();
+ xListCursor = xStmt->executeQuery(aStatement);
+ } break;
+ case starform::ListSourceType_QUERY:
+ {
+ staruno::Reference<starsdb::XQueriesSupplier> xSupplyQueries(xConnection, staruno::UNO_QUERY);
+ staruno::Reference<starbeans::XPropertySet> xQuery(*(InterfaceRef*)xSupplyQueries->getQueries()->getByName(sListSource).getValue(), staruno::UNO_QUERY);
+ staruno::Reference<starsdbc::XStatement> xStmt = xConnection->createStatement();
+ staruno::Reference<starbeans::XPropertySet>(xStmt, staruno::UNO_QUERY)->setPropertyValue(PROPERTY_ESCAPE_PROCESSING, xQuery->getPropertyValue(PROPERTY_ESCAPE_PROCESSING));
+
+ ::rtl::OUString sCommand;
+ xQuery->getPropertyValue(PROPERTY_COMMAND) >>= sCommand;
+ xListCursor = xStmt->executeQuery(sCommand);
+ } break;
+ default:
+ {
+ staruno::Reference<starsdbc::XStatement> xStmt = xConnection->createStatement();
+ if (starform::ListSourceType_SQLPASSTHROUGH == m_eListSourceType)
+ {
+ staruno::Reference<starbeans::XPropertySet> xStatementProps(xStmt, staruno::UNO_QUERY);
+ xStatementProps->setPropertyValue(PROPERTY_ESCAPE_PROCESSING, staruno::makeAny(sal_Bool(sal_False)));
+ }
+ xListCursor = xStmt->executeQuery(sListSource);
+ }
+ }
+ }
+ catch(starsdbc::SQLException& eSQL)
+ {
+ onError(eSQL, FRM_RES_STRING(RID_BASELISTBOX_ERROR_FILLLIST));
+ disposeComponent(xListCursor);
+ return;
+ }
+ catch(staruno::Exception& eUnknown)
+ {
+ eUnknown;
+ disposeComponent(xListCursor);
+ return;
+ }
+
+ if (starform::ListSourceType_TABLEFIELDS != m_eListSourceType && !xListCursor.is())
+ // something went wrong ...
+ return;
+
+ // Anzeige- und Werteliste fuellen
+ vector< ::rtl::OUString > aValueList, aStringList;
+ aValueList.reserve(16);
+ aStringList.reserve(16);
+ sal_Bool bUseNULL = m_xField.is() && !m_bRequired;
+ try
+ {
+ switch (m_eListSourceType)
+ {
+ case starform::ListSourceType_SQL:
+ case starform::ListSourceType_SQLPASSTHROUGH:
+ case starform::ListSourceType_TABLE:
+ case starform::ListSourceType_QUERY:
+ {
+ // Feld der 1. Column des ResultSets holen
+ staruno::Reference<starsdbcx::XColumnsSupplier> xSupplyCols(xListCursor, staruno::UNO_QUERY);
+ DBG_ASSERT(xSupplyCols.is(), "OListBoxModel::loadData : cursor supports the row set service but is no column supplier ??!");
+ staruno::Reference<starcontainer::XIndexAccess> xColumns;
+ if (xSupplyCols.is())
+ {
+ xColumns = staruno::Reference<starcontainer::XIndexAccess>(xSupplyCols->getColumns(), staruno::UNO_QUERY);
+ DBG_ASSERT(xColumns.is(), "OListBoxModel::loadData : no columns supplied by the row set !");
+ }
+ staruno::Reference<starsdb::XColumn> xDataField;
+ if (xColumns.is())
+ xDataField = staruno::Reference<starsdb::XColumn>(*(InterfaceRef*)xColumns->getByIndex(0).getValue(), staruno::UNO_QUERY);
+ if (!xDataField.is())
+ {
+ disposeComponent(xListCursor);
+ return;
+ }
+
+ Date aNullDate(STANDARD_DB_DATE);
+ sal_Int32 nFormatKey = 0;
+ sal_Int32 nFieldType = starsdbc::DataType::OTHER;
+ sal_Int16 nKeyType = starutil::NumberFormat::UNDEFINED;
+ try
+ {
+ staruno::Reference<starbeans::XPropertySet> xFieldAsSet(xDataField, staruno::UNO_QUERY);
+ xFieldAsSet->getPropertyValue(PROPERTY_FIELDTYPE) >>= nFieldType;
+ xFieldAsSet->getPropertyValue(PROPERTY_FORMATKEY) >>= nFormatKey;
+ }
+ catch(...)
+ {
+ }
+
+ staruno::Reference<starutil::XNumberFormatter> xFormatter;
+ staruno::Reference<starutil::XNumberFormatsSupplier> xSupplier = getNumberFormats(xConnection, sal_False, m_xServiceFactory);
+ if (xSupplier.is())
+ {
+ xFormatter = staruno::Reference<starutil::XNumberFormatter>(
+ m_xServiceFactory->createInstance(FRM_NUMBER_FORMATTER),
+ staruno::UNO_QUERY
+ );
+ if (xFormatter.is())
+ {
+ xFormatter->attachNumberFormatsSupplier(xSupplier);
+ typeConvert(*(starutil::Date*)xFormatter->getNumberFormatsSupplier()->getNumberFormatSettings()->getPropertyValue(
+ ::rtl::OUString::createFromAscii("NullDate")).getValue(),
+ aNullDate);
+ nKeyType = getNumberFormatType(xFormatter->getNumberFormatsSupplier()->getNumberFormats(), nFormatKey);
+ }
+ }
+
+ // Feld der BoundColumn des ResultSets holen
+ staruno::Reference<starsdb::XColumn> xBoundField;
+ if ((nBoundColumn > 0) && m_xColumn.is())
+ // don't look for a bound column if we're not connected to a field
+ xBoundField = staruno::Reference<starsdb::XColumn>(*(InterfaceRef*)xColumns->getByIndex(nBoundColumn).getValue(), staruno::UNO_QUERY);
+ m_bBoundComponent = xBoundField.is();
+
+ // Ist die LB an ein Feld gebunden und sind Leereinträge zulaessig
+ // dann wird die Position fuer einen Leereintrag gemerkt
+
+ ::rtl::OUString aStr;
+ sal_Int16 i = 0;
+ // per definitionem the list cursor is positioned _before_ the first row at the moment
+ while (xListCursor->next() && (i++<SHRT_MAX)) // max anzahl eintraege
+ {
+ aStr = DBTypeConversion::getValue(xDataField,
+ xFormatter,
+ aNullDate,
+ nFormatKey,
+ nKeyType);
+
+ aStringList.push_back(aStr);
+
+ if (m_bBoundComponent)
+ {
+ aStr = xBoundField->getString();
+ aValueList.push_back(aStr);
+ }
+
+ if (bUseNULL && (m_nNULLPos == -1) && !aStr.len())
+ m_nNULLPos = (sal_Int16)aStringList.size() - 1;
+ }
+ }
+ break;
+
+ case starform::ListSourceType_TABLEFIELDS:
+ {
+ staruno::Reference<starcontainer::XNameAccess> xFieldNames = getTableFields(xConnection, sListSource);
+ if (xFieldNames.is())
+ {
+ StringSequence seqNames = xFieldNames->getElementNames();
+ sal_Int32 nFieldsCount = seqNames.getLength();
+ const ::rtl::OUString* pustrNames = seqNames.getConstArray();
+
+ for (sal_Int32 k=0; k<nFieldsCount; ++k)
+ aStringList.push_back(pustrNames[k]);
+ }
+ }
+ break;
+ }
+ }
+ catch(starsdbc::SQLException& eSQL)
+ {
+ onError(eSQL, FRM_RES_STRING(RID_BASELISTBOX_ERROR_FILLLIST));
+ disposeComponent(xListCursor);
+ return;
+ }
+ catch(staruno::Exception& eUnknown)
+ {
+ eUnknown;
+ disposeComponent(xListCursor);
+ return;
+ }
+
+
+ // Value-staruno::Sequence erzeugen
+ // NULL eintrag hinzufuegen
+ if (bUseNULL && m_nNULLPos == -1)
+ {
+ if (m_bBoundComponent)
+ aValueList.insert(aValueList.begin());
+
+ aStringList.insert(aStringList.begin());
+ m_nNULLPos = 0;
+ }
+
+ m_aValueSeq.realloc(aValueList.size());
+ ::rtl::OUString* pustrValues = m_aValueSeq.getArray();
+ for (i = 0; i < aValueList.size(); ++i)
+ pustrValues[i] = aValueList[i];
+
+ // String-staruno::Sequence fuer ListBox erzeugen
+ StringSequence aStringSeq(aStringList.size());
+ ::rtl::OUString* pustrStrings = aStringSeq.getArray();
+ for (i = 0; i < aStringList.size(); ++i)
+ pustrStrings[i] = aStringList[i];
+
+ setFastPropertyValue(PROPERTY_ID_STRINGITEMLIST, staruno::makeAny(aStringSeq));
+
+
+ // Statement + Cursor zerstoeren
+ disposeComponent(xListCursor);
+}
+
+//------------------------------------------------------------------------------
+void OListBoxModel::_loaded(const starlang::EventObject& rEvent)
+{
+ // an Felder gebundene Listboxen haben keine Multiselektion
+ if (m_xField.is())
+ {
+ setFastPropertyValue(PROPERTY_ID_MULTISELECTION, staruno::makeAny(sal_Bool(sal_False)));
+ }
+
+ if (m_eListSourceType != starform::ListSourceType_VALUELIST)
+ {
+ if (m_xField.is())
+ m_aValueSeq = StringSequence();
+
+ if (m_xCursor.is())
+ loadData();
+ }
+}
+
+//------------------------------------------------------------------------------
+void OListBoxModel::_unloaded()
+{
+ if (m_eListSourceType != starform::ListSourceType_VALUELIST)
+ {
+ m_aValueSeq = StringSequence();
+ m_nNULLPos = -1;
+ m_bBoundComponent = sal_False;
+
+ StringSequence aSequence;
+ setFastPropertyValue(PROPERTY_ID_STRINGITEMLIST, staruno::makeAny(aSequence));
+ }
+}
+
+//------------------------------------------------------------------------------
+StringSequence OListBoxModel::GetCurValueSeq() const
+{
+ StringSequence aCurValues;
+
+ // Aus den selektierten Indizes Werte-staruno::Sequence aufbauen
+ DBG_ASSERT(m_xAggregateFastSet.is(), "OListBoxModel::GetCurValueSeq : invalid aggregate !");
+ if (!m_xAggregateFastSet.is())
+ return aCurValues;
+ staruno::Any aTmp = m_xAggregateFastSet->getFastPropertyValue(OListBoxModel::nSelectHandle);
+
+ staruno::Sequence<sal_Int16> aSelectSeq = *(staruno::Sequence<sal_Int16>*)aTmp.getValue();
+ const sal_Int16 *pSels = aSelectSeq.getConstArray();
+ sal_uInt32 nSelCount = aSelectSeq.getLength();
+
+ if (nSelCount)
+ {
+ const ::rtl::OUString *pVals = NULL;
+ sal_uInt16 nValCnt = 0;
+ if (m_aValueSeq.getLength())
+ {
+ pVals = m_aValueSeq.getConstArray();
+ nValCnt = m_aValueSeq.getLength();
+ }
+ else
+ {
+ aTmp = const_cast<OListBoxModel*>(this)->OPropertySetAggregationHelper::getFastPropertyValue(PROPERTY_ID_STRINGITEMLIST);
+ pVals = (*(StringSequence*)aTmp.getValue()).getConstArray();
+ nValCnt = (*(StringSequence*)aTmp.getValue()).getLength();
+ }
+
+ if (nSelCount > 1)
+ {
+ // Einfach- oder Mehrfach-Selektion
+ sal_Bool bMultiSel;
+ const_cast<OListBoxModel*>(this)->OPropertySetAggregationHelper::getFastPropertyValue(PROPERTY_ID_MULTISELECTION) >>= bMultiSel;
+ if (bMultiSel)
+ nSelCount = 1;
+ }
+
+ // ist der Eintrag fuer NULL selektiert ?
+ // dann leere Selektion liefern
+ if (m_nNULLPos != -1 && nSelCount == 1 && pSels[0] == m_nNULLPos)
+ nSelCount = 0;
+
+ aCurValues.realloc(nSelCount);
+ ::rtl::OUString *pCurVals = aCurValues.getArray();
+
+ for (sal_uInt16 i = 0; i < nSelCount; i++)
+ {
+ if (pSels[i] < nValCnt)
+ pCurVals[i] = pVals[pSels[i]];
+ }
+ }
+ return aCurValues;
+}
+
+// XBoundComponent
+//------------------------------------------------------------------------------
+sal_Bool OListBoxModel::_commit()
+{
+ // derzeitige Selectionsliste
+ staruno::Any aNewValue;
+ StringSequence aCurValueSeq = GetCurValueSeq();
+ if (aCurValueSeq.getLength())
+ aNewValue <<= aCurValueSeq.getConstArray()[0];
+
+ if (!compare(aNewValue, m_aSaveValue))
+ {
+ if (!aNewValue.hasValue())
+ m_xColumnUpdate->updateNull();
+ else
+ {
+ try
+ {
+ ::rtl::OUString sNewValue;
+ aNewValue >>= sNewValue;
+ m_xColumnUpdate->updateString(sNewValue);
+ }
+ catch(...)
+ {
+ return sal_False;
+ }
+ }
+ m_aSaveValue = aNewValue;
+ }
+ return sal_True;
+}
+
+// XPropertiesChangeListener
+//------------------------------------------------------------------------------
+void OListBoxModel::_onValueChanged()
+{
+ DBG_ASSERT(m_xAggregateFastSet.is() && m_xAggregateSet.is(), "OListBoxModel::_onValueChanged : invalid aggregate !");
+ if (!m_xAggregateFastSet.is() || !m_xAggregateSet.is())
+ return;
+
+ staruno::Sequence<sal_Int16> aSelSeq;
+
+ // Bei NULL-Eintraegen Selektion aufheben!
+ ::rtl::OUString sValue = m_xColumn->getString();
+ if (m_xColumn->wasNull())
+ {
+ m_aSaveValue.clear();
+ if (m_nNULLPos != -1)
+ {
+ aSelSeq.realloc(1);
+ aSelSeq.getArray()[0] = m_nNULLPos;
+ }
+ }
+ else
+ {
+ m_aSaveValue <<= sValue;
+
+ // In der Werteliste nur einzelne Werte suchen, wenn das Control mit einem Datenbankfeld verbunden ist
+ if (m_aValueSeq.getLength()) // WerteListe
+ aSelSeq = findValue(m_aValueSeq, sValue, m_bBoundComponent);
+ else
+ {
+ StringSequence aStringSeq = *(StringSequence*)m_xAggregateSet->getPropertyValue(PROPERTY_STRINGITEMLIST).getValue();
+ aSelSeq = findValue(aStringSeq, sValue, m_bBoundComponent);
+ }
+ }
+ staruno::Any aSelectAny;
+ aSelectAny <<= aSelSeq;
+ { // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
+ // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
+ // our own mutex locked
+ // FS - 72451 - 31.01.00
+ MutexRelease aRelease(m_aMutex);
+ m_xAggregateFastSet->setFastPropertyValue(OListBoxModel::nSelectHandle, aSelectAny );
+ }
+}
+
+// XReset
+//------------------------------------------------------------------------------
+void OListBoxModel::_reset( void )
+{
+ DBG_ASSERT(m_xAggregateFastSet.is() && m_xAggregateSet.is(), "OListBoxModel::reset : invalid aggregate !");
+ if (!m_xAggregateFastSet.is() || !m_xAggregateSet.is())
+ return;
+
+ staruno::Any aValue;
+ if (m_aDefaultSelectSeq.getLength())
+ aValue <<= m_aDefaultSelectSeq;
+ else if (m_nNULLPos != -1) // gebundene Listbox
+ {
+ staruno::Sequence<sal_Int16> aSeq(1);
+ aSeq.getArray()[0] = m_nNULLPos;
+ aValue <<= aSeq;
+ }
+ else
+ {
+ staruno::Sequence<sal_Int16> aSeq;
+ aValue <<= aSeq;
+ }
+ { // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
+ // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
+ // our own mutex locked
+ // FS - 72451 - 31.01.00
+ MutexRelease aRelease(m_aMutex);
+ m_xAggregateFastSet->setFastPropertyValue(OListBoxModel::nSelectHandle, aValue);
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OListBoxModel::addSQLErrorListener(const staruno::Reference<starsdb::XSQLErrorListener>& _rxListener) throw(staruno::RuntimeException)
+{
+ m_aErrorListeners.addInterface(_rxListener);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OListBoxModel::removeSQLErrorListener(const staruno::Reference<starsdb::XSQLErrorListener>& _rxListener) throw(staruno::RuntimeException)
+{
+ m_aErrorListeners.removeInterface(_rxListener);
+}
+
+//------------------------------------------------------------------------------
+void OListBoxModel::onError(starsdbc::SQLException& _rException, const ::rtl::OUString& _rContextDescription)
+{
+ starsdb::SQLContext aError = prependContextInfo(_rException, static_cast<staruno::XWeak*>(this), _rContextDescription);
+ if (m_aErrorListeners.getLength())
+ {
+ starsdb::SQLErrorEvent aEvent(static_cast<staruno::XWeak*>(this), staruno::makeAny(aError));
+
+ ::cppu::OInterfaceIteratorHelper aIter(m_aErrorListeners);
+ while (aIter.hasMoreElements())
+ static_cast<starsdb::XSQLErrorListener*>(aIter.next())->errorOccured(aEvent);
+ }
+}
+
+//==================================================================
+// OListBoxControl
+//==================================================================
+
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OListBoxControl_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory) throw (staruno::RuntimeException)
+{
+ return *(new OListBoxControl(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> OListBoxControl::_getTypes()
+{
+ static staruno::Sequence<staruno::Type> aTypes;
+ if (!aTypes.getLength())
+ {
+ // my two base classes
+ staruno::Sequence<staruno::Type> aBaseClassTypes = OBoundControl::_getTypes();
+
+ staruno::Sequence<staruno::Type> aOwnTypes(2);
+ staruno::Type* pOwnTypes = aOwnTypes.getArray();
+ pOwnTypes[0] = ::getCppuType((staruno::Reference<starawt::XFocusListener>*)NULL);
+ pOwnTypes[1] = ::getCppuType((staruno::Reference<starform::XChangeBroadcaster>*)NULL);
+
+ aTypes = concatSequences(aBaseClassTypes, aOwnTypes);
+ }
+ return aTypes;
+}
+
+//------------------------------------------------------------------
+staruno::Any SAL_CALL OListBoxControl::queryAggregation(const staruno::Type& _rType) throw (staruno::RuntimeException)
+{
+ staruno::Any aReturn;
+
+ aReturn = ::cppu::queryInterface(_rType
+ ,static_cast<starawt::XFocusListener*>(this)
+ ,static_cast<starform::XChangeBroadcaster*>(this)
+ );
+ if (!aReturn.hasValue())
+ aReturn = OBoundControl::queryAggregation(_rType);
+
+ return aReturn;
+}
+
+DBG_NAME(OListBoxControl);
+//------------------------------------------------------------------------------
+OListBoxControl::OListBoxControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OBoundControl(_rxFactory, VCL_CONTROL_LISTBOX)
+ ,m_aChangeListeners(m_aMutex)
+{
+ DBG_CTOR(OListBoxControl,NULL);
+
+ increment(m_refCount);
+ {
+ // als FocusListener anmelden
+ staruno::Reference<starawt::XWindow> xComp;
+ if (query_aggregation(m_xAggregate, xComp))
+ xComp->addFocusListener(this);
+
+ // als ItemListener anmelden
+ staruno::Reference<starawt::XListBox> xListbox;
+ if (query_aggregation(m_xAggregate, xListbox))
+ xListbox->addItemListener(this);
+ }
+ // Refcount bei 2 fuer angemeldete Listener
+ sal_Int32 n = decrement(m_refCount);
+
+ m_aChangeTimer.SetTimeout(500);
+ m_aChangeTimer.SetTimeoutHdl(LINK(this,OListBoxControl,OnTimeout));
+}
+
+//------------------------------------------------------------------------------
+OListBoxControl::~OListBoxControl()
+{
+ if (!OComponentHelper::rBHelper.bDisposed)
+ {
+ acquire();
+ dispose();
+ }
+
+ DBG_DTOR(OListBoxControl,NULL);
+}
+
+//------------------------------------------------------------------------------
+StringSequence SAL_CALL OListBoxControl::getSupportedServiceNames() throw(staruno::RuntimeException)
+{
+ StringSequence aSupported = OBoundControl::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 1);
+
+ ::rtl::OUString* pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_LISTBOX;
+ return aSupported;
+}
+
+
+// XFocusListener
+//------------------------------------------------------------------------------
+void SAL_CALL OListBoxControl::focusGained(const starawt::FocusEvent& _rEvent) throw(staruno::RuntimeException)
+{
+ ::osl::ClearableMutexGuard aGuard(m_aMutex);
+ if (m_aChangeListeners.getLength()) // only if there are listeners
+ {
+ staruno::Reference<starbeans::XPropertySet> xSet(getModel(), staruno::UNO_QUERY);
+ if (xSet.is())
+ {
+ // memorize the current selection for posting the change event
+ m_aCurrentSelection = xSet->getPropertyValue(PROPERTY_SELECT_SEQ);
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OListBoxControl::focusLost(const starawt::FocusEvent& _rEvent) throw(staruno::RuntimeException)
+{
+ m_aCurrentSelection.clear();
+}
+
+// XItemListener
+//------------------------------------------------------------------------------
+void SAL_CALL OListBoxControl::itemStateChanged(const starawt::ItemEvent& _rEvent) throw(staruno::RuntimeException)
+{
+ // call the changelistener delayed
+ ::osl::ClearableMutexGuard aGuard(m_aMutex);
+ if (m_aChangeTimer.IsActive())
+ {
+ staruno::Reference<starbeans::XPropertySet> xSet(getModel(), staruno::UNO_QUERY);
+ m_aCurrentSelection = xSet->getPropertyValue(PROPERTY_SELECT_SEQ);
+
+ m_aChangeTimer.Stop();
+ m_aChangeTimer.Start();
+ }
+ else
+ {
+ if (m_aChangeListeners.getLength() && m_aCurrentSelection.hasValue())
+ {
+ staruno::Reference<starbeans::XPropertySet> xSet(getModel(), staruno::UNO_QUERY);
+ if (xSet.is())
+ {
+ // Has the selection been changed?
+ sal_Bool bModified(sal_False);
+ staruno::Any aValue = xSet->getPropertyValue(PROPERTY_SELECT_SEQ);
+
+ staruno::Sequence<sal_Int16>& rSelection = *(staruno::Sequence<sal_Int16> *)aValue.getValue();
+ staruno::Sequence<sal_Int16>& rOldSelection = *(staruno::Sequence<sal_Int16> *)m_aCurrentSelection.getValue();
+ sal_Int32 nLen = rSelection.getLength();
+ if (nLen != rOldSelection.getLength())
+ bModified = sal_True;
+ else
+ {
+ const sal_Int16* pVal = rSelection.getConstArray();
+ const sal_Int16* pCompVal = rOldSelection.getConstArray();
+
+ while (nLen-- && !bModified)
+ bModified = pVal[nLen] != pCompVal[nLen];
+ }
+
+ if (bModified)
+ {
+ m_aCurrentSelection = aValue;
+ m_aChangeTimer.Start();
+ }
+ }
+ }
+ else if (m_aCurrentSelection.hasValue())
+ m_aCurrentSelection.clear();
+ }
+}
+
+// XEventListener
+//------------------------------------------------------------------------------
+void SAL_CALL OListBoxControl::disposing(const starlang::EventObject& _rSource) throw (staruno::RuntimeException)
+{
+ OBoundControl::disposing(_rSource);
+}
+
+// XChangeBroadcaster
+//------------------------------------------------------------------------------
+void SAL_CALL OListBoxControl::addChangeListener(const staruno::Reference<starform::XChangeListener>& _rxListener) throw(staruno::RuntimeException)
+{
+ m_aChangeListeners.addInterface(_rxListener);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OListBoxControl::removeChangeListener(const staruno::Reference<starform::XChangeListener>& _rxListener) throw(staruno::RuntimeException)
+{
+ m_aChangeListeners.removeInterface(_rxListener);
+}
+
+// OComponentHelper
+//------------------------------------------------------------------------------
+void OListBoxControl::disposing()
+{
+ if (m_aChangeTimer.IsActive())
+ m_aChangeTimer.Stop();
+
+ starlang::EventObject aEvt(static_cast<staruno::XWeak*>(this));
+ m_aChangeListeners.disposeAndClear(aEvt);
+
+ OBoundControl::disposing();
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(OListBoxControl, OnTimeout, void*, EMPTYTAG)
+{
+ starlang::EventObject aEvt(static_cast<staruno::XWeak*>(this));
+ NOTIFY_LISTENERS(m_aChangeListeners, starform::XChangeListener, changed, aEvt);
+ return 1;
+}
+
+//.........................................................................
+}
+//.........................................................................
+
diff --git a/forms/source/component/ListBox.hxx b/forms/source/component/ListBox.hxx
new file mode 100644
index 000000000000..26e3b4964c74
--- /dev/null
+++ b/forms/source/component/ListBox.hxx
@@ -0,0 +1,254 @@
+/*************************************************************************
+ *
+ * $RCSfile: ListBox.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:06 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_LISTBOX_HXX_
+#define _FORMS_LISTBOX_HXX_
+
+#ifndef _FORMS_FORMCOMPONENT_HXX_
+#include "FormComponent.hxx"
+#endif
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+#ifndef _DATE_HXX
+#include <tools/date.hxx>
+#endif
+#ifndef _SV_TIMER_HXX
+#include <vcl/timer.hxx>
+#endif
+
+#include <com/sun/star/util/XRefreshable.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#include <com/sun/star/sdb/XSQLErrorBroadcaster.hpp>
+#include <com/sun/star/form/ListSourceType.hpp>
+#include <com/sun/star/awt/XItemListener.hpp>
+#include <com/sun/star/awt/XFocusListener.hpp>
+#include <com/sun/star/form/XChangeBroadcaster.hpp>
+
+//.........................................................................
+namespace frm
+{
+
+const ::rtl::OUString LISTBOX_EMPTY_VALUE = ::rtl::OUString::createFromAscii("$$$empty$$$");
+
+//==================================================================
+//= OListBoxModel
+//==================================================================
+class OListBoxModel
+ :public OBoundControlModel
+ ,public starsdb::XSQLErrorBroadcaster
+ ,public starutil::XRefreshable
+ ,public ::utl::OAggregationArrayUsageHelper< OListBoxModel >
+{
+ staruno::Any m_aSaveValue;
+
+ // <properties>
+ starform::ListSourceType m_eListSourceType; // type der list source
+ staruno::Any m_aBoundColumn;
+ StringSequence m_aListSourceSeq; //
+ StringSequence m_aValueSeq; // alle Werte, readonly
+ staruno::Sequence<sal_Int16> m_aDefaultSelectSeq; // DefaultSelected
+ // </properties>
+
+ ::cppu::OInterfaceContainerHelper m_aRefreshListeners;
+ ::cppu::OInterfaceContainerHelper m_aErrorListeners;
+
+ static sal_Int32 nSelectHandle;
+ // [properties]
+
+ sal_Int16 m_nNULLPos; // Position an der der NULLwert abgelegt wird
+ sal_Bool m_bBoundComponent : 1;
+
+ // Helper functions
+ StringSequence GetCurValueSeq() const;
+
+ virtual staruno::Sequence<staruno::Type> _getTypes();
+
+protected:
+ // UNO Anbindung
+ virtual void _onValueChanged();
+
+public:
+ OListBoxModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+ virtual ~OListBoxModel();
+
+// XServiceInfo
+ IMPLEMENTATION_NAME(OListBoxModel);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw(staruno::RuntimeException);
+
+// UNO Anbindung
+ DECLARE_UNO3_AGG_DEFAULTS(OListBoxModel, OBoundControlModel);
+ virtual staruno::Any SAL_CALL queryAggregation( const staruno::Type& _rType ) throw (staruno::RuntimeException);
+
+// OComponentHelper
+ virtual void SAL_CALL disposing();
+
+// OPropertySetHelper
+ virtual void SAL_CALL getFastPropertyValue(staruno::Any& rValue, sal_Int32 nHandle) const;
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const staruno::Any& rValue )
+ throw (staruno::Exception);
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(
+ staruno::Any& _rConvertedValue, staruno::Any& _rOldValue, sal_Int32 _nHandle, const staruno::Any& _rValue )
+ throw (starlang::IllegalArgumentException);
+
+// XLoadListener
+ virtual void _loaded(const starlang::EventObject& rEvent);
+ virtual void _unloaded();
+
+// XBoundComponent
+ virtual sal_Bool _commit();
+
+// XPropertySet
+ virtual staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(staruno::RuntimeException);
+ virtual cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+// XPersistObject
+ virtual ::rtl::OUString SAL_CALL getServiceName() throw(staruno::RuntimeException);
+ virtual void SAL_CALL
+ write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream) throw(stario::IOException, staruno::RuntimeException);
+ virtual void SAL_CALL
+ read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream) throw(stario::IOException, staruno::RuntimeException);
+
+// XReset
+ virtual void _reset();
+
+// XRefreshable
+ virtual void SAL_CALL refresh() throw(staruno::RuntimeException);
+ virtual void SAL_CALL addRefreshListener(const staruno::Reference<starutil::XRefreshListener>& _rxListener) throw(staruno::RuntimeException);
+ virtual void SAL_CALL removeRefreshListener(const staruno::Reference<starutil::XRefreshListener>& _rxListener) throw(staruno::RuntimeException);
+
+// XSQLErrorBroadcaster
+ virtual void SAL_CALL addSQLErrorListener(const staruno::Reference<starsdb::XSQLErrorListener>& _rxListener) throw(staruno::RuntimeException);
+ virtual void SAL_CALL removeSQLErrorListener(const staruno::Reference<starsdb::XSQLErrorListener>& _rxListener) throw(staruno::RuntimeException);
+
+ // OAggregationArrayUsageHelper
+ virtual void fillProperties(
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rProps,
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rAggregateProps
+ ) const;
+ IMPLEMENT_INFO_SERVICE()
+
+protected:
+ void loadData();
+
+ void onError(starsdbc::SQLException& _rException, const ::rtl::OUString& _rContextDescription);
+};
+
+//==================================================================
+//= OListBoxControl
+//==================================================================
+
+class OListBoxControl :public OBoundControl
+ ,public starawt::XFocusListener
+ ,public starawt::XItemListener
+ ,public starform::XChangeBroadcaster
+{
+ ::cppu::OInterfaceContainerHelper m_aChangeListeners;
+
+ staruno::Any m_aCurrentSelection;
+ Timer m_aChangeTimer;
+
+protected:
+ // UNO Anbindung
+ virtual staruno::Sequence<staruno::Type> _getTypes();
+
+public:
+ OListBoxControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+ virtual ~OListBoxControl();
+
+ // UNO Anbindung
+ DECLARE_UNO3_AGG_DEFAULTS(OListBoxControl, OBoundControl);
+ virtual staruno::Any SAL_CALL queryAggregation( const staruno::Type& _rType ) throw (staruno::RuntimeException);
+
+// XServiceInfo
+ IMPLEMENTATION_NAME(OListBoxControl);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw(staruno::RuntimeException);
+
+// XChangeBroadcaster
+ virtual void SAL_CALL addChangeListener(const staruno::Reference<starform::XChangeListener>& _rxListener) throw(staruno::RuntimeException);
+ virtual void SAL_CALL removeChangeListener(const staruno::Reference<starform::XChangeListener>& _rxListener) throw(staruno::RuntimeException);
+
+// XFocusListener
+ virtual void SAL_CALL focusGained(const starawt::FocusEvent& _rEvent) throw(staruno::RuntimeException);
+ virtual void SAL_CALL focusLost(const starawt::FocusEvent& _rEvent) throw(staruno::RuntimeException);
+
+// XItemListener
+ virtual void SAL_CALL itemStateChanged(const starawt::ItemEvent& _rEvent) throw(staruno::RuntimeException);
+
+// XEventListener
+ virtual void SAL_CALL disposing(const starlang::EventObject& Source) throw (staruno::RuntimeException);
+
+// OComponentHelper
+ virtual void SAL_CALL disposing();
+
+private:
+ DECL_LINK( OnTimeout, void* );
+};
+
+//.........................................................................
+}
+//.........................................................................
+
+#endif // _FORMS_LISTBOX_HXX_
+
diff --git a/forms/source/component/Numeric.cxx b/forms/source/component/Numeric.cxx
new file mode 100644
index 000000000000..25d3eb19f75e
--- /dev/null
+++ b/forms/source/component/Numeric.cxx
@@ -0,0 +1,256 @@
+/*************************************************************************
+ *
+ * $RCSfile: Numeric.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:06 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_NUMERIC_HXX_
+#include "Numeric.hxx"
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+//==================================================================
+// ONumericControl
+//==================================================================
+
+//------------------------------------------------------------------
+ONumericControl::ONumericControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OBoundControl(_rxFactory, VCL_CONTROL_NUMERICFIELD)
+{
+}
+
+//------------------------------------------------------------------------------
+StringSequence ONumericControl::getSupportedServiceNames() throw()
+{
+ StringSequence aSupported = OBoundControl::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 1);
+
+ ::rtl::OUString*pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_NUMERICFIELD;
+ return aSupported;
+}
+
+
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL ONumericControl_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new ONumericControl(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> ONumericControl::_getTypes()
+{
+ return OBoundControl::_getTypes();
+}
+
+//==================================================================
+// ONumericModel
+//==================================================================
+sal_Int32 ONumericModel::nValueHandle = -1;
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL ONumericModel_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new ONumericModel(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> ONumericModel::_getTypes()
+{
+ return OEditBaseModel::_getTypes();
+}
+
+//------------------------------------------------------------------
+ONumericModel::ONumericModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OEditBaseModel(_rxFactory, VCL_CONTROLMODEL_NUMERICFIELD, FRM_CONTROL_NUMERICFIELD)
+ // use the old control name for compytibility reasons
+{
+ m_nClassId = starform::FormComponentType::NUMERICFIELD;
+ m_sDataFieldConnectivityProperty = PROPERTY_VALUE;
+ if (ONumericModel::nValueHandle == -1)
+ ONumericModel::nValueHandle = getOriginalHandle(PROPERTY_ID_VALUE);
+}
+
+//------------------------------------------------------------------
+ONumericModel::~ONumericModel()
+{
+}
+
+// starlang::XServiceInfo
+//------------------------------------------------------------------------------
+StringSequence ONumericModel::getSupportedServiceNames() throw()
+{
+ StringSequence aSupported = OBoundControlModel::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 2);
+
+ ::rtl::OUString*pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-2] = ::rtl::OUString::createFromAscii("com.sun.star.form.component.starform");
+ pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_NUMERICFIELD;
+ return aSupported;
+}
+
+//------------------------------------------------------------------------------
+staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL ONumericModel::getPropertySetInfo() throw( staruno::RuntimeException )
+{
+ staruno::Reference<starbeans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//------------------------------------------------------------------------------
+void ONumericModel::fillProperties(
+ staruno::Sequence< starbeans::Property >& _rProps,
+ staruno::Sequence< starbeans::Property >& _rAggregateProps ) const
+{
+ FRM_BEGIN_PROP_HELPER(10)
+ // Value auf transient setzen
+// ModifyPropertyAttributes(_rAggregateProps, PROPERTY_VALUE, starbeans::PropertyAttribute::TRANSIENT, 0);
+
+ DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT);
+ DECL_PROP3(DEFAULT_VALUE, double, BOUND, MAYBEDEFAULT, MAYBEVOID);
+ DECL_PROP1(NAME, ::rtl::OUString, BOUND);
+ DECL_PROP1(TAG, ::rtl::OUString, BOUND);
+ DECL_PROP1(TABINDEX, sal_Int16, BOUND);
+ DECL_PROP1(CONTROLSOURCE, ::rtl::OUString, BOUND);
+ DECL_PROP1(HELPTEXT, ::rtl::OUString, BOUND);
+ DECL_IFACE_PROP2(BOUNDFIELD, starbeans::XPropertySet,READONLY, TRANSIENT);
+ DECL_IFACE_PROP2(CONTROLLABEL, starbeans::XPropertySet, BOUND, MAYBEVOID);
+ DECL_PROP2(CONTROLSOURCEPROPERTY, rtl::OUString, READONLY, TRANSIENT);
+ FRM_END_PROP_HELPER();
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& ONumericModel::getInfoHelper()
+{
+ return *const_cast<ONumericModel*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ONumericModel::getServiceName()
+{
+ return FRM_COMPONENT_NUMERICFIELD; // old (non-sun) name for compatibility !
+}
+
+// starform::XBoundComponent
+//------------------------------------------------------------------------------
+sal_Bool ONumericModel::_commit()
+{
+ staruno::Any aNewValue = m_xAggregateFastSet->getFastPropertyValue( ONumericModel::nValueHandle );
+ if (!compare(aNewValue, m_aSaveValue))
+ {
+ if (!aNewValue.hasValue())
+ m_xColumnUpdate->updateNull();
+ else
+ {
+ try
+ {
+ m_xColumnUpdate->updateDouble(getDouble(aNewValue));
+ }
+ catch(...)
+ {
+ return sal_False;
+ }
+ }
+ m_aSaveValue = aNewValue;
+ }
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+void ONumericModel::_onValueChanged()
+{
+ m_aSaveValue <<= (double)m_xColumn->getDouble();
+ if (m_xColumn->wasNull())
+ m_aSaveValue.clear();
+
+ { // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
+ // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
+ // our own mutex locked
+ // FS - 72451 - 31.01.00
+ MutexRelease aRelease(m_aMutex);
+ m_xAggregateFastSet->setFastPropertyValue(ONumericModel::nValueHandle, m_aSaveValue);
+ }
+}
+
+// starform::XReset
+//------------------------------------------------------------------------------
+void ONumericModel::_reset()
+{
+ staruno::Any aValue;
+ if (m_aDefault.getValueType().getTypeClass() == staruno::TypeClass_DOUBLE)
+ aValue = m_aDefault;
+
+ { // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
+ // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
+ // our own mutex locked
+ // FS - 72451 - 31.01.00
+ MutexRelease aRelease(m_aMutex);
+ m_xAggregateFastSet->setFastPropertyValue(ONumericModel::nValueHandle, aValue);
+ }
+}
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
diff --git a/forms/source/component/Numeric.hxx b/forms/source/component/Numeric.hxx
new file mode 100644
index 000000000000..ab02748f1f93
--- /dev/null
+++ b/forms/source/component/Numeric.hxx
@@ -0,0 +1,138 @@
+/*************************************************************************
+ *
+ * $RCSfile: Numeric.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:06 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_NUMERIC_HXX_
+#define _FORMS_NUMERIC_HXX_
+
+#ifndef _FORMS_EDITBASE_HXX_
+#include "EditBase.hxx"
+#endif
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+//==================================================================
+//= ONumericModel
+//==================================================================
+class ONumericModel
+ :public OEditBaseModel
+ ,public ::utl::OAggregationArrayUsageHelper< ONumericModel >
+{
+ staruno::Any m_aSaveValue;
+ static sal_Int32 nValueHandle;
+
+protected:
+ virtual void _onValueChanged();
+ virtual staruno::Sequence<staruno::Type> _getTypes();
+
+public:
+ ONumericModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+ virtual ~ONumericModel();
+
+ // starform::XBoundComponent
+ virtual sal_Bool _commit();
+
+ // starlang::XServiceInfo
+ IMPLEMENTATION_NAME(ONumericModel);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
+
+ // staruno::Reference<starbeans::XPropertySet>
+ virtual staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(staruno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // stario::XPersistObject
+ virtual ::rtl::OUString SAL_CALL getServiceName();
+
+ // starform::XReset
+ virtual void _reset();
+
+ // OAggregationArrayUsageHelper
+ virtual void fillProperties(
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rProps,
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rAggregateProps
+ ) const;
+ IMPLEMENT_INFO_SERVICE()
+};
+
+//==================================================================
+//= ONumericControl
+//==================================================================
+class ONumericControl: public OBoundControl
+{
+protected:
+ virtual staruno::Sequence<staruno::Type> _getTypes();
+
+public:
+ ONumericControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+
+ // starlang::XServiceInfo
+ IMPLEMENTATION_NAME(ONumericControl);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
+};
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
+#endif // _FORMS_NUMERIC_HXX_
+
diff --git a/forms/source/component/Pattern.cxx b/forms/source/component/Pattern.cxx
new file mode 100644
index 000000000000..cec218fe4dec
--- /dev/null
+++ b/forms/source/component/Pattern.cxx
@@ -0,0 +1,251 @@
+/*************************************************************************
+ *
+ * $RCSfile: Pattern.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:06 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_PATTERN_HXX_
+#include "Pattern.hxx"
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+//==================================================================
+// OPatternControl
+//==================================================================
+//------------------------------------------------------------------
+OPatternControl::OPatternControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OBoundControl(_rxFactory, VCL_CONTROL_PATTERNFIELD)
+{
+}
+
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OPatternControl_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new OPatternControl(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> OPatternControl::_getTypes()
+{
+ return OBoundControl::_getTypes();
+}
+
+//------------------------------------------------------------------------------
+StringSequence OPatternControl::getSupportedServiceNames() throw()
+{
+ StringSequence aSupported = OBoundControl::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 1);
+
+ ::rtl::OUString*pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_PATTERNFIELD;
+ return aSupported;
+}
+
+//==================================================================
+// OPatternModel
+//==================================================================
+sal_Int32 OPatternModel::nTextHandle = -1;
+
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OPatternModel_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new OPatternModel(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> OPatternModel::_getTypes()
+{
+ return OEditBaseModel::_getTypes();
+}
+
+//------------------------------------------------------------------
+OPatternModel::OPatternModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OEditBaseModel(_rxFactory, VCL_CONTROLMODEL_PATTERNFIELD, FRM_CONTROL_PATTERNFIELD)
+ // use the old control name for compytibility reasons
+{
+ m_nClassId = starform::FormComponentType::PATTERNFIELD;
+ m_sDataFieldConnectivityProperty = PROPERTY_TEXT;
+ if (OPatternModel::nTextHandle == -1)
+ OPatternModel::nTextHandle = getOriginalHandle(PROPERTY_ID_TEXT);
+}
+
+//------------------------------------------------------------------
+OPatternModel::~OPatternModel()
+{
+}
+
+// starlang::XServiceInfo
+//------------------------------------------------------------------------------
+StringSequence SAL_CALL OPatternModel::getSupportedServiceNames() throw()
+{
+ StringSequence aSupported = OBoundControlModel::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 2);
+
+ ::rtl::OUString*pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-2] = ::rtl::OUString::createFromAscii("com.sun.star.form.component.DatabasePatternField");
+ pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_PATTERNFIELD;
+ return aSupported;
+}
+
+
+//------------------------------------------------------------------------------
+staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL OPatternModel::getPropertySetInfo() throw( staruno::RuntimeException )
+{
+ staruno::Reference<starbeans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//------------------------------------------------------------------------------
+void OPatternModel::fillProperties(
+ staruno::Sequence< starbeans::Property >& _rProps,
+ staruno::Sequence< starbeans::Property >& _rAggregateProps ) const
+{
+ FRM_BEGIN_PROP_HELPER(12)
+ // Text auf transient setzen
+// ModifyPropertyAttributes(_rAggregateProps, PROPERTY_TEXT, starbeans::PropertyAttribute::TRANSIENT, 0);
+ DECL_PROP1(NAME, ::rtl::OUString, BOUND);
+ DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT);
+ DECL_PROP2(DEFAULT_TEXT, ::rtl::OUString, BOUND, MAYBEDEFAULT);
+ DECL_BOOL_PROP1(EMPTY_IS_NULL, BOUND);
+ DECL_PROP1(TAG, ::rtl::OUString, BOUND);
+ DECL_PROP1(TABINDEX, sal_Int16, BOUND);
+ DECL_PROP1(CONTROLSOURCE, ::rtl::OUString, BOUND);
+ DECL_PROP1(HELPTEXT, ::rtl::OUString, BOUND);
+ DECL_IFACE_PROP2(BOUNDFIELD, starbeans::XPropertySet, READONLY, TRANSIENT);
+ DECL_PROP2(FILTERPROPOSAL, sal_Bool, BOUND, MAYBEDEFAULT);
+ DECL_IFACE_PROP2(CONTROLLABEL, starbeans::XPropertySet, BOUND, MAYBEVOID);
+ DECL_PROP2(CONTROLSOURCEPROPERTY, rtl::OUString, READONLY, TRANSIENT);
+ FRM_END_PROP_HELPER();
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OPatternModel::getInfoHelper()
+{
+ return *const_cast<OPatternModel*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OPatternModel::getServiceName()
+{
+ return FRM_COMPONENT_PATTERNFIELD; // old (non-sun) name for compatibility !
+}
+
+// starform::XBoundComponent
+//------------------------------------------------------------------------------
+sal_Bool OPatternModel::_commit()
+{
+ ::rtl::OUString aNewValue = getString(m_xAggregateFastSet->getFastPropertyValue( OPatternModel::nTextHandle ));
+ if (aNewValue != m_aSaveValue)
+ {
+ if (!aNewValue.len() && !m_bRequired && m_bEmptyIsNull)
+ m_xColumnUpdate->updateNull();
+ else
+ {
+ try
+ {
+ m_xColumnUpdate->updateString(aNewValue);
+ }
+ catch(...)
+ {
+ return sal_False;
+ }
+ }
+ m_aSaveValue = aNewValue;
+ }
+ return sal_True;
+}
+
+// starbeans::XPropertyChangeListener
+//------------------------------------------------------------------------------
+void OPatternModel::_onValueChanged()
+{
+ m_aSaveValue = m_xColumn->getString();
+ { // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
+ // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
+ // our own mutex locked
+ // FS - 72451 - 31.01.00
+ MutexRelease aRelease(m_aMutex);
+ m_xAggregateFastSet->setFastPropertyValue(OPatternModel::nTextHandle, staruno::makeAny(m_aSaveValue));
+ }
+}
+
+// starform::XReset
+//------------------------------------------------------------------------------
+void OPatternModel::_reset( void )
+{
+ { // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
+ // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
+ // our own mutex locked
+ // FS - 72451 - 31.01.00
+ MutexRelease aRelease(m_aMutex);
+ m_xAggregateFastSet->setFastPropertyValue(OPatternModel::nTextHandle, staruno::makeAny(m_aDefaultText));
+ }
+}
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
diff --git a/forms/source/component/Pattern.hxx b/forms/source/component/Pattern.hxx
new file mode 100644
index 000000000000..4276e2fc2fa7
--- /dev/null
+++ b/forms/source/component/Pattern.hxx
@@ -0,0 +1,139 @@
+/*************************************************************************
+ *
+ * $RCSfile: Pattern.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:06 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_PATTERN_HXX_
+#define _FORMS_PATTERN_HXX_
+
+#ifndef _FORMS_EDITBASE_HXX_
+#include "EditBase.hxx"
+#endif
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+//==================================================================
+//= OPatternModel
+//==================================================================
+class OPatternModel
+ :public OEditBaseModel
+ ,public ::utl::OAggregationArrayUsageHelper< OPatternModel >
+{
+ ::rtl::OUString m_aSaveValue;
+
+ static sal_Int32 nTextHandle;
+
+protected:
+ virtual void _onValueChanged();
+ virtual staruno::Sequence<staruno::Type> _getTypes();
+
+public:
+ OPatternModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+ virtual ~OPatternModel();
+
+ // starform::XBoundComponent
+ virtual sal_Bool _commit();
+
+ // staruno::Reference<starbeans::XPropertySet>
+ virtual staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(staruno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // starlang::XServiceInfo
+ IMPLEMENTATION_NAME(OPatternModel);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
+
+ // stario::XPersistObject
+ virtual ::rtl::OUString SAL_CALL getServiceName();
+
+ // starform::XReset
+ virtual void _reset();
+
+ // OAggregationArrayUsageHelper
+ virtual void fillProperties(
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rProps,
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rAggregateProps
+ ) const;
+ IMPLEMENT_INFO_SERVICE()
+};
+
+//==================================================================
+//= OPatternControl
+//==================================================================
+class OPatternControl: public OBoundControl
+{
+protected:
+ virtual staruno::Sequence<staruno::Type> _getTypes();
+
+public:
+ OPatternControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+
+ // starlang::XServiceInfo
+ IMPLEMENTATION_NAME(OPatternControl);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
+};
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
+#endif // _FORMS_PATTERN_HXX_
+
diff --git a/forms/source/component/RadioButton.cxx b/forms/source/component/RadioButton.cxx
new file mode 100644
index 000000000000..b8542a0fe8f0
--- /dev/null
+++ b/forms/source/component/RadioButton.cxx
@@ -0,0 +1,510 @@
+/*************************************************************************
+ *
+ * $RCSfile: RadioButton.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:06 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_RADIOBUTTON_HXX_
+#include "RadioButton.hxx"
+#endif
+#ifndef _FRM_PROPERTY_HXX_
+#include "property.hxx"
+#endif
+#ifndef _FRM_PROPERTY_HRC_
+#include "property.hrc"
+#endif
+#ifndef _FRM_SERVICES_HXX_
+#include "services.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
+#include <com/sun/star/container/XIndexAccess.hpp>
+#endif
+
+//.........................................................................
+namespace frm
+{
+
+//==================================================================
+//------------------------------------------------------------------------------
+InterfaceRef SAL_CALL ORadioButtonControl_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory) throw (staruno::RuntimeException)
+{
+ return *(new ORadioButtonControl(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+StringSequence SAL_CALL ORadioButtonControl::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException)
+{
+ StringSequence aSupported = OBoundControl::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 1);
+
+ ::rtl::OUString* pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_RADIOBUTTON;
+ return aSupported;
+}
+
+
+//------------------------------------------------------------------
+ORadioButtonControl::ORadioButtonControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OBoundControl(_rxFactory, VCL_CONTROL_RADIOBUTTON)
+{
+}
+
+//==================================================================
+InterfaceRef SAL_CALL ORadioButtonModel_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory) throw (staruno::RuntimeException)
+{
+ return *(new ORadioButtonModel(_rxFactory));
+}
+
+//------------------------------------------------------------------
+ORadioButtonModel::ORadioButtonModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OBoundControlModel(_rxFactory, VCL_CONTROLMODEL_RADIOBUTTON, FRM_CONTROL_RADIOBUTTON, sal_False)
+ // use the old control name for compytibility reasons
+ ,OPropertyChangeListener(m_aMutex)
+ ,m_bInReset(sal_False)
+{
+ m_nClassId = starform::FormComponentType::RADIOBUTTON;
+ m_nDefaultChecked = RB_NOCHECK;
+ m_aLabelServiceName = FRM_SUN_COMPONENT_GROUPBOX;
+ m_sDataFieldConnectivityProperty = PROPERTY_STATE;
+
+
+ increment(m_refCount);
+ if (m_xAggregateSet.is())
+ {
+ OPropertyChangeMultiplexer* pMultiplexer = new OPropertyChangeMultiplexer(this, m_xAggregateSet);
+ pMultiplexer->addProperty(PROPERTY_STATE);
+ }
+ decrement(m_refCount);
+}
+
+// XServiceInfo
+//------------------------------------------------------------------------------
+StringSequence SAL_CALL ORadioButtonModel::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException)
+{
+ StringSequence aSupported = OBoundControlModel::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 2);
+
+ ::rtl::OUString* pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-2] = ::rtl::OUString::createFromAscii("com.sun.star.form.component.DatabaseRadioButton");
+ pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_RADIOBUTTON;
+ return aSupported;
+}
+
+//------------------------------------------------------------------------------
+void ORadioButtonModel::getFastPropertyValue(staruno::Any& rValue, sal_Int32 nHandle) const
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_REFVALUE : rValue <<= m_sReferenceValue; break;
+ case PROPERTY_ID_DEFAULTCHECKED : rValue <<= m_nDefaultChecked; break;
+ default:
+ OBoundControlModel::getFastPropertyValue(rValue, nHandle);
+ }
+}
+
+//------------------------------------------------------------------------------
+void ORadioButtonModel::SetSiblingPropsTo(const ::rtl::OUString& rPropName, const staruno::Any& rValue)
+{
+ // mein Name
+ ::rtl::OUString sMyName(m_aName);
+
+ // meine Siblings durchiterieren
+ staruno::Reference<starcontainer::XIndexAccess> xIndexAccess(getParent(), staruno::UNO_QUERY);
+ if (xIndexAccess.is())
+ {
+ staruno::Reference<starbeans::XPropertySet> xMyProps;
+ query_interface(static_cast<staruno::XWeak*>(this), xMyProps);
+ ::rtl::OUString sCurrentName;
+ for (sal_Int32 i=0; i<xIndexAccess->getCount(); ++i)
+ {
+ staruno::Reference<starbeans::XPropertySet> xSiblingProperties(*(InterfaceRef*)xIndexAccess->getByIndex(i).getValue(), staruno::UNO_QUERY);
+ if (!xSiblingProperties.is())
+ continue;
+ if (xMyProps == xSiblingProperties)
+ continue; // mich selber nicht umsetzen
+
+ // nur wenn es ein Radio-Button ist
+ if (!hasProperty(PROPERTY_CLASSID, xSiblingProperties))
+ continue;
+ sal_Int16 nType;
+ xSiblingProperties->getPropertyValue(PROPERTY_CLASSID) >>= nType;
+ if (nType != starform::FormComponentType::RADIOBUTTON)
+ continue;
+
+ // das 'zur selben Gruppe gehoeren' wird am Namen festgemacht
+ xSiblingProperties->getPropertyValue(PROPERTY_NAME) >>= sCurrentName;
+ if (sCurrentName == sMyName)
+ xSiblingProperties->setPropertyValue(rPropName, rValue);
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void ORadioButtonModel::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const staruno::Any& rValue) throw (::com::sun::star::uno::Exception)
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_REFVALUE :
+ DBG_ASSERT(rValue.getValueType().getTypeClass() == staruno::TypeClass_STRING, "ORadioButtonModel::setFastPropertyValue_NoBroadcast : invalid type !" );
+ rValue >>= m_sReferenceValue;
+ break;
+
+ case PROPERTY_ID_DEFAULTCHECKED :
+ DBG_ASSERT(rValue.getValueType().getTypeClass() == staruno::TypeClass_SHORT, "ORadioButtonModel::setFastPropertyValue_NoBroadcast : invalid type !" );
+ rValue >>= (sal_Int16)m_nDefaultChecked;
+ _reset();
+ break;
+
+ default:
+ OBoundControlModel::setFastPropertyValue_NoBroadcast(nHandle, rValue);
+ }
+
+ // if the label control changed ...
+ if (nHandle == PROPERTY_ID_CONTROLLABEL)
+ { // ... forward this to our siblings
+ SetSiblingPropsTo(PROPERTY_CONTROLLABEL, rValue);
+ }
+
+ // wenn sich die ControlSource-Eigenschaft geaendert hat ...
+ if (nHandle == PROPERTY_ID_CONTROLSOURCE)
+ { // ... muss ich allen meinen Siblings, die in der selben RadioButton-Gruppe sind wie ich, auch die
+ // neue ControlSource mitgeben
+ SetSiblingPropsTo(PROPERTY_CONTROLSOURCE, rValue);
+ }
+
+ // die andere Richtung : wenn sich mein Name aendert ...
+ if (nHandle == PROPERTY_ID_NAME)
+ {
+ // ... muss ich testen, ob ich Siblings mit dem selben Namen habe, damit ich deren ControlSource uebernehmen kann
+ staruno::Reference<starcontainer::XIndexAccess> xIndexAccess(getParent(), staruno::UNO_QUERY);
+ if (xIndexAccess.is())
+ {
+ ::rtl::OUString sName;
+ ::rtl::OUString sControlSource;
+
+ staruno::Reference<starbeans::XPropertySet> xMyProps;
+ query_interface(static_cast<staruno::XWeak*>(this), xMyProps);
+ for (sal_Int32 i=0; i<xIndexAccess->getCount(); ++i)
+ {
+ staruno::Reference<starbeans::XPropertySet> xSiblingProperties(*(InterfaceRef*)xIndexAccess->getByIndex(i).getValue(), staruno::UNO_QUERY);
+ if (!xSiblingProperties.is())
+ continue;
+
+ if (xMyProps == xSiblingProperties)
+ // nur wenn ich nicht mich selber gefunden habe
+ continue;
+
+ sal_Int16 nType;
+ xSiblingProperties->getPropertyValue(PROPERTY_CLASSID) >>= nType;
+ if (nType != starform::FormComponentType::RADIOBUTTON)
+ // nur Radio-Buttons
+ continue;
+
+ xSiblingProperties->getPropertyValue(PROPERTY_NAME) >>= sName;
+ // Control, das zur gleichen Gruppe gehoert ?
+ if (rValue == sName)
+ {
+ setPropertyValue(PROPERTY_CONTROLSOURCE, xSiblingProperties->getPropertyValue(PROPERTY_CONTROLSOURCE));
+ break;
+ }
+ }
+ }
+ }
+
+ if (nHandle == PROPERTY_ID_DEFAULTCHECKED)
+ {
+ sal_Int16 nValue;
+ rValue >>= nValue;
+ if (1 == nValue)
+ { // bei allen Radios der selben Gruppe das 'default checked' ruecksetzen, denn wie schon der highlander wusste :
+ // es kann nur einen geben.
+ staruno::Any aZero;
+ nValue = 0;
+ aZero <<= nValue;
+ SetSiblingPropsTo(PROPERTY_DEFAULTCHECKED, aZero);
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool ORadioButtonModel::convertFastPropertyValue(
+ staruno::Any& _rConvertedValue, staruno::Any& _rOldValue, sal_Int32 _nHandle, const staruno::Any& _rValue)
+ throw (starlang::IllegalArgumentException)
+{
+ sal_Bool bModified(sal_False);
+ switch (_nHandle)
+ {
+ case PROPERTY_ID_REFVALUE :
+ bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_sReferenceValue);
+ break;
+ case PROPERTY_ID_DEFAULTCHECKED :
+ bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_nDefaultChecked);
+ break;
+ default:
+ bModified = OBoundControlModel::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
+ break;
+ }
+ return bModified;
+}
+
+//------------------------------------------------------------------------------
+staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL ORadioButtonModel::getPropertySetInfo() throw(staruno::RuntimeException)
+{
+ staruno::Reference<starbeans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//------------------------------------------------------------------------------
+cppu::IPropertyArrayHelper& ORadioButtonModel::getInfoHelper()
+{
+ return *const_cast<ORadioButtonModel*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+void ORadioButtonModel::fillProperties(
+ staruno::Sequence< starbeans::Property >& _rProps,
+ staruno::Sequence< starbeans::Property >& _rAggregateProps ) const
+{
+ FRM_BEGIN_PROP_HELPER(11)
+ // the "State" property is transient, so change this
+ // ModifyPropertyAttributes(_rAggregateProps, PROPERTY_STATE, starbeans::PropertyAttribute::TRANSIENT, 0);
+
+ DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT);
+ DECL_PROP1(REFVALUE, ::rtl::OUString, BOUND);
+ DECL_PROP1(DEFAULTCHECKED, sal_Int16, BOUND);
+ DECL_PROP1(NAME, ::rtl::OUString, BOUND);
+ DECL_PROP1(TAG, ::rtl::OUString, BOUND);
+ DECL_PROP1(TABINDEX, sal_Int16, BOUND);
+ DECL_PROP1(CONTROLSOURCE, rtl::OUString, BOUND);
+ DECL_PROP1(HELPTEXT, rtl::OUString, BOUND);
+ DECL_IFACE_PROP2(BOUNDFIELD, starbeans::XPropertySet, READONLY, TRANSIENT);
+ DECL_IFACE_PROP2(CONTROLLABEL, starbeans::XPropertySet, BOUND, MAYBEVOID);
+ DECL_PROP2(CONTROLSOURCEPROPERTY, rtl::OUString, READONLY, TRANSIENT);
+ FRM_END_PROP_HELPER();
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ORadioButtonModel::getServiceName() throw(staruno::RuntimeException)
+{
+ return FRM_COMPONENT_RADIOBUTTON; // old (non-sun) name for compatibility !
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ORadioButtonModel::write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream)
+ throw(stario::IOException, staruno::RuntimeException)
+{
+ OBoundControlModel::write(_rxOutStream);
+
+ // Version
+ _rxOutStream->writeShort(0x0003);
+
+ // Properties
+ _rxOutStream << m_sReferenceValue;
+ _rxOutStream << (sal_Int16)m_nDefaultChecked;
+ _rxOutStream << m_aHelpText;
+
+ // from version 0x0003 : common properties
+ writeCommonProperties(_rxOutStream);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ORadioButtonModel::read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream) throw(stario::IOException, staruno::RuntimeException)
+{
+ OBoundControlModel::read(_rxInStream);
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ // Version
+ UINT16 nVersion = _rxInStream->readShort();
+
+ switch (nVersion)
+ {
+ case 0x0001 : _rxInStream >> m_sReferenceValue; _rxInStream >> (sal_Int16)m_nDefaultChecked; break;
+ case 0x0002 :
+ _rxInStream >> m_sReferenceValue;
+ _rxInStream >> (sal_Int16)m_nDefaultChecked;
+ _rxInStream >> m_aHelpText;
+ break;
+ case 0x0003 :
+ _rxInStream >> m_sReferenceValue;
+ _rxInStream >> (sal_Int16)m_nDefaultChecked;
+ _rxInStream >> m_aHelpText;
+ readCommonProperties(_rxInStream);
+ break;
+ default :
+ DBG_ERROR("ORadioButtonModel::read : unknown version !");
+ m_sReferenceValue = ::rtl::OUString();
+ m_nDefaultChecked = 0;
+ defaultCommonProperties();
+ break;
+ }
+ // Nach dem Lesen die Defaultwerte anzeigen
+ if (m_aControlSource.getLength())
+ // (not if we don't have a control source - the "State" property acts like it is persistent, then
+ _reset();
+}
+
+//------------------------------------------------------------------------------
+void ORadioButtonModel::_propertyChanged(const starbeans::PropertyChangeEvent& _rEvent) throw(staruno::RuntimeException)
+{
+ if (_rEvent.PropertyName.equals(PROPERTY_STATE))
+ {
+ if (_rEvent.NewValue == (sal_Int16)1)
+ {
+ // wenn sich mein Status auf 'checked' geaendert hat, muss ich alle meine Siblings, die in der selben Gruppe
+ // sind wie ich, entsprechend zuruecksetzen
+ staruno::Any aZero;
+ aZero <<= (sal_Int16)0;
+
+ SetSiblingPropsTo(PROPERTY_STATE, aZero);
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ // as we aren't commitable we have to take care of the field we are bound to ourself
+ if (m_xField.is() && !m_bInReset)
+ {
+ m_xField->setPropertyValue(PROPERTY_VALUE, staruno::makeAny(m_sReferenceValue));
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void ORadioButtonModel::_onValueChanged()
+{
+ staruno::Any aValue;
+ aValue <<= (sal_Int16)((m_xColumn->getString() == m_sReferenceValue) ? RB_CHECK : RB_NOCHECK);
+ m_bInReset = sal_True;
+ { // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
+ // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
+ // our own mutex locked
+ // FS - 72451 - 31.01.00
+ MutexRelease aRelease(m_aMutex);
+ m_xAggregateSet->setPropertyValue(PROPERTY_STATE, aValue);
+ }
+ m_bInReset = sal_False;
+}
+
+//------------------------------------------------------------------------------
+staruno::Any ORadioButtonModel::_getControlValue() const
+{
+ return m_xAggregateSet->getPropertyValue(PROPERTY_STATE);
+}
+
+//------------------------------------------------------------------------------
+sal_Int16 ORadioButtonModel::getState( const staruno::Any& rValue )
+{
+ //::rtl::OUString aStrValue = DBTypeConversion::toString( rValue );
+ return RB_NOCHECK;
+}
+
+//------------------------------------------------------------------------------
+void ORadioButtonModel::_reset( void )
+{
+ staruno::Any aValue;
+ aValue <<= (sal_Int16)m_nDefaultChecked;
+ { // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
+ // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
+ // our own mutex locked
+ // FS - 72451 - 31.01.00
+ MutexRelease aRelease(m_aMutex);
+ m_xAggregateSet->setPropertyValue(PROPERTY_STATE, aValue);
+ }
+}
+
+//-----------------------------------------------------------------------------
+sal_Bool ORadioButtonModel::_commit()
+{
+ if (!m_bInReset)
+ // normally we don't have a commit as we forward all state changes immediately to our field we're bound to
+ return sal_True;
+
+ // we're in reset, so this commit means "put the value into the field you're bound to"
+ // 72769 - 08.02.00 - FS
+ DBG_ASSERT(m_xField.is(), "ORadioButtonModel::_commit : committing while resetting, but not bound ?");
+ if (m_xField.is())
+ {
+ try
+ {
+ sal_Int16 nValue;
+ m_xAggregateSet->getPropertyValue(PROPERTY_STATE) >>= nValue;
+ if (nValue == 1)
+ m_xField->setPropertyValue(PROPERTY_VALUE, staruno::makeAny(m_sReferenceValue));
+ }
+ catch(...)
+ {
+ DBG_ERROR("ORadioButtonModel::_commit : could not commit !");
+ }
+ }
+ return sal_True;
+}
+
+//-----------------------------------------------------------------------------
+void ORadioButtonModel::reset(void) throw (::com::sun::star::uno::RuntimeException)
+{
+ m_bInReset = sal_True;
+ OBoundControlModel::reset();
+ m_bInReset = sal_False;
+}
+
+//.........................................................................
+}
+//.........................................................................
+
diff --git a/forms/source/component/RadioButton.hxx b/forms/source/component/RadioButton.hxx
new file mode 100644
index 000000000000..9df628f846e9
--- /dev/null
+++ b/forms/source/component/RadioButton.hxx
@@ -0,0 +1,162 @@
+/*************************************************************************
+ *
+ * $RCSfile: RadioButton.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:06 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_RADIOBUTTON_HXX_
+#define _FORMS_RADIOBUTTON_HXX_
+
+#ifndef _FORMS_FORMCOMPONENT_HXX_
+#include "FormComponent.hxx"
+#endif
+
+#ifndef _UNOTOOLS_PROPERTY_MULTIPLEX_HXX_
+#include <unotools/propmultiplex.hxx>
+#endif
+
+//.........................................................................
+namespace frm
+{
+
+enum { RB_NOCHECK, RB_CHECK, RB_DONTKNOW };
+
+//==================================================================
+// ORadioButtonModel
+//==================================================================
+class ORadioButtonModel :public OBoundControlModel
+ ,public OPropertyChangeListener
+ ,public ::utl::OAggregationArrayUsageHelper< ORadioButtonModel >
+{
+ ::rtl::OUString m_sReferenceValue; // Referenzwert zum Checken des Buttons
+ sal_Int16 m_nDefaultChecked; // Soll beim Reset gecheckt werden ?
+
+ sal_Bool m_bInReset : 1;
+
+protected:
+ sal_Int16 getState(const staruno::Any& rValue);
+
+ virtual void _onValueChanged();
+ virtual staruno::Any _getControlValue() const;
+
+public:
+ ORadioButtonModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+
+ // XServiceInfo
+ IMPLEMENTATION_NAME(ORadioButtonModel);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // OPropertySetHelper
+ virtual void SAL_CALL getFastPropertyValue(staruno::Any& rValue, sal_Int32 nHandle) const;
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const staruno::Any& rValue )
+ throw (staruno::Exception);
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(
+ staruno::Any& _rConvertedValue, staruno::Any& _rOldValue, sal_Int32 _nHandle, const staruno::Any& _rValue )
+ throw (starlang::IllegalArgumentException);
+
+ // XPropertySet
+ virtual staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(staruno::RuntimeException);
+ virtual cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // XPersistObject
+ virtual ::rtl::OUString SAL_CALL getServiceName() throw(staruno::RuntimeException);
+ virtual void SAL_CALL
+ write(const staruno::Reference<stario::XObjectOutputStream>& _rxOutStream) throw(stario::IOException, staruno::RuntimeException);
+ virtual void SAL_CALL
+ read(const staruno::Reference<stario::XObjectInputStream>& _rxInStream) throw(stario::IOException, staruno::RuntimeException);
+
+ // OPropertyChangeListener
+ virtual void _propertyChanged(const starbeans::PropertyChangeEvent& evt) throw(staruno::RuntimeException);
+
+ // XReset
+ virtual void SAL_CALL reset() throw(staruno::RuntimeException);
+
+ // OAggregationArrayUsageHelper
+ virtual void fillProperties(
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rProps,
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rAggregateProps
+ ) const;
+ IMPLEMENT_INFO_SERVICE()
+
+protected:
+ virtual void _reset();
+ virtual sal_Bool _commit();
+
+protected:
+ void SetSiblingPropsTo(const ::rtl::OUString& rPropName, const staruno::Any& rValue);
+};
+
+//==================================================================
+// ORadioButtonControl
+//==================================================================
+class ORadioButtonControl: public OBoundControl
+{
+public:
+ ORadioButtonControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+
+ // XServiceInfo
+ IMPLEMENTATION_NAME(ORadioButtonControl);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+};
+
+//.........................................................................
+}
+//.........................................................................
+
+#endif // _FORMS_RADIOBUTTON_HXX_
+
diff --git a/forms/source/component/Time.cxx b/forms/source/component/Time.cxx
new file mode 100644
index 000000000000..83e3c173cae4
--- /dev/null
+++ b/forms/source/component/Time.cxx
@@ -0,0 +1,310 @@
+/*************************************************************************
+ *
+ * $RCSfile: Time.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:06 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_TIME_HXX_
+#include "Time.hxx"
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _TOOLS_TIME_HXX
+#include <tools/time.hxx>
+#endif
+#ifndef _UNOTOOLS_DATETIME_HXX_
+#include <unotools/datetime.hxx>
+#endif
+#ifndef _UTL_DB_CONVERSION_HXX_
+#include <unotools/dbconversion.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+//==================================================================
+//= OTimeControl
+//==================================================================
+//------------------------------------------------------------------
+OTimeControl::OTimeControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OBoundControl(_rxFactory, VCL_CONTROL_TIMEFIELD)
+{
+}
+
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OTimeControl_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new OTimeControl(_rxFactory));
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> OTimeControl::_getTypes()
+{
+ return OBoundControl::_getTypes();
+}
+
+//------------------------------------------------------------------------------
+StringSequence SAL_CALL OTimeControl::getSupportedServiceNames() throw()
+{
+ StringSequence aSupported = OBoundControl::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 1);
+
+ ::rtl::OUString*pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_TIMEFIELD;
+ return aSupported;
+}
+
+//==================================================================
+//= OTimeModel
+//==================================================================
+sal_Int32 OTimeModel::nTimeHandle = -1;
+
+//------------------------------------------------------------------
+InterfaceRef SAL_CALL OTimeModel_CreateInstance(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+{
+ return *(new OTimeModel(_rxFactory));
+}
+
+// starlang::XServiceInfo
+//------------------------------------------------------------------------------
+StringSequence SAL_CALL OTimeModel::getSupportedServiceNames() throw()
+{
+ StringSequence aSupported = OBoundControlModel::getSupportedServiceNames();
+ aSupported.realloc(aSupported.getLength() + 2);
+
+ ::rtl::OUString*pArray = aSupported.getArray();
+ pArray[aSupported.getLength()-2] = ::rtl::OUString::createFromAscii("com.sun.star.form.component.starform");
+ pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_TIMEFIELD;
+ return aSupported;
+}
+
+//------------------------------------------------------------------------------
+staruno::Sequence<staruno::Type> OTimeModel::_getTypes()
+{
+ return OBoundControlModel::_getTypes();
+}
+
+//------------------------------------------------------------------
+OTimeModel::OTimeModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory)
+ :OEditBaseModel(_rxFactory, VCL_CONTROLMODEL_TIMEFIELD, FRM_CONTROL_TIMEFIELD )
+ // use the old control name for compytibility reasons
+{
+ m_nClassId = starform::FormComponentType::TIMEFIELD;
+ m_sDataFieldConnectivityProperty = PROPERTY_TIME;
+ if (OTimeModel::nTimeHandle == -1)
+ OTimeModel::nTimeHandle = getOriginalHandle(PROPERTY_ID_TIME);
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OTimeModel::getServiceName()
+{
+ return FRM_COMPONENT_TIMEFIELD; // old (non-sun) name for compatibility !
+}
+
+// starbeans::XPropertySet
+//------------------------------------------------------------------------------
+staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL OTimeModel::getPropertySetInfo() throw( staruno::RuntimeException )
+{
+ staruno::Reference<starbeans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//------------------------------------------------------------------------------
+void OTimeModel::fillProperties(
+ staruno::Sequence< starbeans::Property >& _rProps,
+ staruno::Sequence< starbeans::Property >& _rAggregateProps ) const
+{
+ FRM_BEGIN_PROP_HELPER(10)
+ // starutil::Time auf transient setzen
+// ModifyPropertyAttributes(_rAggregateProps, PROPERTY_TIME, starbeans::PropertyAttribute::TRANSIENT, 0);
+
+ DECL_PROP1(NAME, ::rtl::OUString, BOUND);
+ DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT);
+ DECL_PROP3(DEFAULT_TIME, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID);
+ DECL_PROP1(TAG, ::rtl::OUString, BOUND);
+ DECL_PROP1(TABINDEX, sal_Int16, BOUND);
+ DECL_PROP1(CONTROLSOURCE, ::rtl::OUString, BOUND);
+ DECL_PROP1(HELPTEXT, ::rtl::OUString, BOUND);
+ DECL_IFACE_PROP2(BOUNDFIELD, starbeans::XPropertySet, READONLY, TRANSIENT);
+ DECL_IFACE_PROP2(CONTROLLABEL, starbeans::XPropertySet, BOUND, MAYBEVOID);
+ DECL_PROP2(CONTROLSOURCEPROPERTY, rtl::OUString, READONLY, TRANSIENT);
+ FRM_END_PROP_HELPER();
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OTimeModel::getInfoHelper()
+{
+ return *const_cast<OTimeModel*>(this)->getArrayHelper();
+}
+
+// starform::XLoadListener
+//------------------------------------------------------------------------------
+void OTimeModel::_loaded(const starlang::EventObject& rEvent)
+{
+ OBoundControlModel::_loaded(rEvent);
+ if (m_xField.is())
+ {
+ m_bDateTimeField = sal_False;
+ try
+ {
+ sal_Int32 nFieldType;
+ m_xField->getPropertyValue(PROPERTY_FIELDTYPE) >>= nFieldType;
+ m_bDateTimeField = (nFieldType == starsdbc::DataType::TIMESTAMP);
+ }
+ catch(...)
+ {
+ }
+ }
+}
+
+// starform::XBoundComponent
+//------------------------------------------------------------------------------
+sal_Bool OTimeModel::_commit()
+{
+ staruno::Any aNewValue = m_xAggregateFastSet->getFastPropertyValue( OTimeModel::nTimeHandle );
+ if (!compare(aNewValue, m_aSaveValue))
+ {
+ if (!aNewValue.hasValue())
+ m_xColumnUpdate->updateNull();
+ else
+ {
+ try
+ {
+ starutil::Time aTime;
+ if (!(aNewValue >>= aTime))
+ {
+ sal_Int32 nAsInt(0);
+ aNewValue >>= nAsInt;
+ Time aToolsValue(nAsInt);
+ typeConvert(aToolsValue, aTime);
+ }
+
+ if (!m_bDateTimeField)
+ m_xColumnUpdate->updateTime(aTime);
+ else
+ {
+ starutil::DateTime aDateTime = m_xColumn->getTimestamp();
+ aDateTime.HundredthSeconds = aTime.HundredthSeconds;
+ aDateTime.Seconds = aTime.Seconds;
+ aDateTime.Minutes = aTime.Minutes;
+ aDateTime.Hours = aTime.Hours;
+ m_xColumnUpdate->updateTimestamp(aDateTime);
+ }
+ }
+ catch(...)
+ {
+ return sal_False;
+ }
+ }
+ m_aSaveValue = aNewValue;
+ }
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+void OTimeModel::_onValueChanged()
+{
+ starutil::Time aTime = m_xColumn->getTime();
+ if (m_xColumn->wasNull())
+ m_aSaveValue.clear();
+ else
+ // the aggregated set expects an Int32 as value ...
+ m_aSaveValue <<= DBTypeConversion::toINT32(aTime);
+
+ { // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
+ // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
+ // our own mutex locked
+ // FS - 72451 - 31.01.00
+ MutexRelease aRelease(m_aMutex);
+ m_xAggregateFastSet->setFastPropertyValue(OTimeModel::nTimeHandle, m_aSaveValue);
+ }
+}
+
+//------------------------------------------------------------------------------
+void OTimeModel::_reset()
+{
+ staruno::Any aValue;
+ if (m_aDefault.getValueType().getTypeClass() == staruno::TypeClass_LONG)
+ aValue = m_aDefault;
+ else
+ { // aktuelles Datum einstellen
+ Time aCurrentTime;
+ aValue <<= DBTypeConversion::toINT32(aCurrentTime);
+ }
+
+ { // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
+ // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
+ // our own mutex locked
+ // FS - 72451 - 31.01.00
+ MutexRelease aRelease(m_aMutex);
+ m_xAggregateFastSet->setFastPropertyValue(OTimeModel::nTimeHandle, aValue);
+ }
+}
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
diff --git a/forms/source/component/Time.hxx b/forms/source/component/Time.hxx
new file mode 100644
index 000000000000..eca2c0cec526
--- /dev/null
+++ b/forms/source/component/Time.hxx
@@ -0,0 +1,142 @@
+/*************************************************************************
+ *
+ * $RCSfile: Time.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:29:06 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _FORMS_TIME_HXX_
+#define _FORMS_TIME_HXX_
+
+#ifndef _FORMS_EDITBASE_HXX_
+#include "EditBase.hxx"
+#endif
+
+//.........................................................................
+namespace frm
+{
+//.........................................................................
+
+//==================================================================
+//= OTimeModel
+//==================================================================
+class OTimeModel
+ :public OEditBaseModel
+ ,public ::utl::OAggregationArrayUsageHelper< OTimeModel >
+{
+ staruno::Any m_aSaveValue;
+ sal_Bool m_bDateTimeField;
+ static sal_Int32 nTimeHandle;
+
+protected:
+ virtual void _onValueChanged();
+ virtual staruno::Sequence<staruno::Type> _getTypes();
+
+public:
+ OTimeModel(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+
+ // starform::XBoundComponent
+ virtual sal_Bool _commit();
+
+ // stario::XPersistObject
+ virtual ::rtl::OUString SAL_CALL getServiceName();
+
+ // starlang::XServiceInfo
+ IMPLEMENTATION_NAME(OTimeModel);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
+
+ // starbeans::XPropertySet
+ virtual staruno::Reference<starbeans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(staruno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // starform::XReset
+ virtual void _reset( void );
+
+ // starform::XLoadListener
+ virtual void _loaded(const starlang::EventObject& rEvent);
+
+ // OAggregationArrayUsageHelper
+ virtual void fillProperties(
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rProps,
+ staruno::Sequence< starbeans::Property >& /* [out] */ _rAggregateProps
+ ) const;
+ IMPLEMENT_INFO_SERVICE()
+};
+
+//==================================================================
+//= OTimeControl
+//==================================================================
+class OTimeControl: public OBoundControl
+{
+protected:
+ virtual staruno::Sequence<staruno::Type> _getTypes();
+
+public:
+ OTimeControl(const staruno::Reference<starlang::XMultiServiceFactory>& _rxFactory);
+ DECLARE_UNO3_AGG_DEFAULTS(OTimeControl, OBoundControl);
+
+ // starlang::XServiceInfo
+ IMPLEMENTATION_NAME(OTimeControl);
+ virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
+};
+
+//.........................................................................
+} // namespace frm
+//.........................................................................
+
+#endif // _FORMS_TIME_HXX_
+
diff --git a/forms/source/component/makefile.mk b/forms/source/component/makefile.mk
new file mode 100644
index 000000000000..afe3e003118c
--- /dev/null
+++ b/forms/source/component/makefile.mk
@@ -0,0 +1,145 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:29:06 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (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.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJINC=..
+PRJNAME=forms
+TARGET=component
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Types -------------------------------------
+
+INCPRE+=$(SOLARINCDIR)$/offuh
+
+# --- Files -------------------------------------
+
+CXXFILES= Grid.cxx \
+ Columns.cxx\
+ DatabaseForm.cxx \
+ GroupManager.cxx \
+ FormsCollection.cxx \
+ EventThread.cxx \
+ File.cxx \
+ Edit.cxx \
+ EditBase.cxx \
+ Numeric.cxx \
+ Pattern.cxx \
+ Currency.cxx \
+ Date.cxx \
+ Time.cxx \
+ FormattedField.cxx \
+ FormattedFieldWrapper.cxx \
+ ListBox.cxx \
+ ComboBox.cxx \
+ GroupBox.cxx \
+ Hidden.cxx \
+ CheckBox.cxx \
+ RadioButton.cxx \
+ FixedText.cxx \
+ FormComponent.cxx \
+ Image.cxx \
+ Button.cxx \
+ ImageButton.cxx \
+ ImageControl.cxx \
+
+.IF "$(COM)"=="GCC"
+NOOPTFILES= $(SLO)$/EventThread.obj
+.ENDIF
+
+SLOFILES= $(SLO)$/Grid.obj \
+ $(SLO)$/Columns.obj \
+ $(SLO)$/DatabaseForm.obj \
+ $(SLO)$/GroupManager.obj \
+ $(SLO)$/FormsCollection.obj \
+ $(SLO)$/EventThread.obj \
+ $(SLO)$/File.obj \
+ $(SLO)$/Edit.obj \
+ $(SLO)$/EditBase.obj \
+ $(SLO)$/Numeric.obj \
+ $(SLO)$/Pattern.obj \
+ $(SLO)$/Currency.obj \
+ $(SLO)$/Date.obj \
+ $(SLO)$/Time.obj \
+ $(SLO)$/FormattedField.obj \
+ $(SLO)$/FormattedFieldWrapper.obj \
+ $(SLO)$/ListBox.obj \
+ $(SLO)$/ComboBox.obj \
+ $(SLO)$/GroupBox.obj \
+ $(SLO)$/Hidden.obj \
+ $(SLO)$/CheckBox.obj \
+ $(SLO)$/RadioButton.obj \
+ $(SLO)$/FixedText.obj \
+ $(SLO)$/FormComponent.obj \
+ $(SLO)$/Image.obj \
+ $(SLO)$/Button.obj \
+ $(SLO)$/ImageButton.obj \
+ $(SLO)$/ImageControl.obj \
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+