summaryrefslogtreecommitdiff
path: root/extensions/source/propctrlr
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/source/propctrlr')
-rw-r--r--extensions/source/propctrlr/MasterDetailLinkDialog.cxx157
-rw-r--r--extensions/source/propctrlr/MasterDetailLinkDialog.hxx84
-rw-r--r--extensions/source/propctrlr/browserline.cxx548
-rw-r--r--extensions/source/propctrlr/browserline.hxx143
-rw-r--r--extensions/source/propctrlr/browserlistbox.cxx1312
-rw-r--r--extensions/source/propctrlr/browserlistbox.hxx250
-rw-r--r--extensions/source/propctrlr/browserpage.cxx105
-rw-r--r--extensions/source/propctrlr/browserpage.hxx68
-rw-r--r--extensions/source/propctrlr/browserview.cxx144
-rw-r--r--extensions/source/propctrlr/browserview.hxx89
-rw-r--r--extensions/source/propctrlr/buttonnavigationhandler.cxx295
-rw-r--r--extensions/source/propctrlr/buttonnavigationhandler.hxx90
-rw-r--r--extensions/source/propctrlr/cellbindinghandler.cxx504
-rw-r--r--extensions/source/propctrlr/cellbindinghandler.hxx109
-rw-r--r--extensions/source/propctrlr/cellbindinghelper.cxx565
-rw-r--r--extensions/source/propctrlr/cellbindinghelper.hxx290
-rw-r--r--extensions/source/propctrlr/commoncontrol.cxx206
-rw-r--r--extensions/source/propctrlr/commoncontrol.hxx337
-rw-r--r--extensions/source/propctrlr/composeduiupdate.cxx859
-rw-r--r--extensions/source/propctrlr/composeduiupdate.hxx231
-rw-r--r--extensions/source/propctrlr/controlfontdialog.cxx177
-rw-r--r--extensions/source/propctrlr/controlfontdialog.hxx100
-rw-r--r--extensions/source/propctrlr/controltype.hxx54
-rw-r--r--extensions/source/propctrlr/defaultforminspection.cxx270
-rw-r--r--extensions/source/propctrlr/defaultforminspection.hxx91
-rw-r--r--extensions/source/propctrlr/defaulthelpprovider.cxx206
-rw-r--r--extensions/source/propctrlr/defaulthelpprovider.hxx93
-rw-r--r--extensions/source/propctrlr/editpropertyhandler.cxx323
-rw-r--r--extensions/source/propctrlr/editpropertyhandler.hxx82
-rw-r--r--extensions/source/propctrlr/eformshelper.cxx790
-rw-r--r--extensions/source/propctrlr/eformshelper.hxx269
-rw-r--r--extensions/source/propctrlr/eformspropertyhandler.cxx616
-rw-r--r--extensions/source/propctrlr/eformspropertyhandler.hxx108
-rw-r--r--extensions/source/propctrlr/enumrepresentation.hxx76
-rw-r--r--extensions/source/propctrlr/eventhandler.cxx1285
-rw-r--r--extensions/source/propctrlr/eventhandler.hxx265
-rw-r--r--extensions/source/propctrlr/fontdialog.cxx631
-rw-r--r--extensions/source/propctrlr/fontdialog.hxx83
-rw-r--r--extensions/source/propctrlr/fontdialog.src60
-rw-r--r--extensions/source/propctrlr/fontitemids.hxx66
-rw-r--r--extensions/source/propctrlr/formbrowsertools.cxx148
-rw-r--r--extensions/source/propctrlr/formbrowsertools.hxx108
-rw-r--r--extensions/source/propctrlr/formcomponenthandler.cxx3341
-rw-r--r--extensions/source/propctrlr/formcomponenthandler.hxx479
-rw-r--r--extensions/source/propctrlr/formcontroller.cxx299
-rw-r--r--extensions/source/propctrlr/formcontroller.hxx140
-rw-r--r--extensions/source/propctrlr/formgeometryhandler.cxx826
-rw-r--r--extensions/source/propctrlr/formlinkdialog.cxx676
-rw-r--r--extensions/source/propctrlr/formlinkdialog.hrc44
-rw-r--r--extensions/source/propctrlr/formlinkdialog.hxx150
-rw-r--r--extensions/source/propctrlr/formlinkdialog.src162
-rw-r--r--extensions/source/propctrlr/formlocalid.hrc39
-rw-r--r--extensions/source/propctrlr/formmetadata.cxx706
-rw-r--r--extensions/source/propctrlr/formmetadata.hxx350
-rw-r--r--extensions/source/propctrlr/formres.src1523
-rw-r--r--extensions/source/propctrlr/formresid.hrc389
-rw-r--r--extensions/source/propctrlr/formstrings.cxx36
-rw-r--r--extensions/source/propctrlr/formstrings.hxx307
-rw-r--r--extensions/source/propctrlr/genericpropertyhandler.cxx726
-rw-r--r--extensions/source/propctrlr/genericpropertyhandler.hxx161
-rw-r--r--extensions/source/propctrlr/handlerhelper.cxx291
-rw-r--r--extensions/source/propctrlr/handlerhelper.hxx217
-rw-r--r--extensions/source/propctrlr/inspectorhelpwindow.cxx153
-rw-r--r--extensions/source/propctrlr/inspectorhelpwindow.hxx78
-rw-r--r--extensions/source/propctrlr/inspectormodelbase.cxx272
-rw-r--r--extensions/source/propctrlr/inspectormodelbase.hxx108
-rw-r--r--extensions/source/propctrlr/linedescriptor.hxx70
-rw-r--r--extensions/source/propctrlr/listselectiondlg.cxx173
-rw-r--r--extensions/source/propctrlr/listselectiondlg.hrc39
-rw-r--r--extensions/source/propctrlr/listselectiondlg.hxx89
-rw-r--r--extensions/source/propctrlr/listselectiondlg.src82
-rw-r--r--extensions/source/propctrlr/makefile.mk154
-rw-r--r--extensions/source/propctrlr/modulepcr.cxx48
-rw-r--r--extensions/source/propctrlr/modulepcr.hxx45
-rw-r--r--extensions/source/propctrlr/newdatatype.cxx109
-rw-r--r--extensions/source/propctrlr/newdatatype.hrc38
-rw-r--r--extensions/source/propctrlr/newdatatype.hxx77
-rw-r--r--extensions/source/propctrlr/newdatatype.src79
-rw-r--r--extensions/source/propctrlr/objectinspectormodel.cxx242
-rw-r--r--extensions/source/propctrlr/pcr.component91
-rw-r--r--extensions/source/propctrlr/pcr.xml146
-rw-r--r--extensions/source/propctrlr/pcrcommon.cxx78
-rw-r--r--extensions/source/propctrlr/pcrcommon.hxx152
-rw-r--r--extensions/source/propctrlr/pcrcommontypes.hxx51
-rw-r--r--extensions/source/propctrlr/pcrcomponentcontext.cxx106
-rw-r--r--extensions/source/propctrlr/pcrcomponentcontext.hxx168
-rw-r--r--extensions/source/propctrlr/pcrmiscres.src189
-rw-r--r--extensions/source/propctrlr/pcrservices.cxx124
-rw-r--r--extensions/source/propctrlr/pcrstrings.cxx36
-rw-r--r--extensions/source/propctrlr/pcrstrings.hxx46
-rw-r--r--extensions/source/propctrlr/pcrunodialogs.cxx146
-rw-r--r--extensions/source/propctrlr/pcrunodialogs.hxx94
-rw-r--r--extensions/source/propctrlr/propcontroller.cxx1778
-rw-r--r--extensions/source/propctrlr/propcontroller.hxx430
-rw-r--r--extensions/source/propctrlr/propcontrolobserver.hxx56
-rw-r--r--extensions/source/propctrlr/propertycomposer.cxx516
-rw-r--r--extensions/source/propctrlr/propertycomposer.hxx157
-rw-r--r--extensions/source/propctrlr/propertycontrolextender.cxx145
-rw-r--r--extensions/source/propctrlr/propertycontrolextender.hxx74
-rw-r--r--extensions/source/propctrlr/propertyeditor.cxx542
-rw-r--r--extensions/source/propctrlr/propertyeditor.hxx163
-rw-r--r--extensions/source/propctrlr/propertyhandler.cxx464
-rw-r--r--extensions/source/propctrlr/propertyhandler.hxx457
-rw-r--r--extensions/source/propctrlr/propertyinfo.hxx66
-rw-r--r--extensions/source/propctrlr/propeventtranslation.cxx105
-rw-r--r--extensions/source/propctrlr/propeventtranslation.hxx84
-rw-r--r--extensions/source/propctrlr/proplinelistener.hxx51
-rw-r--r--extensions/source/propctrlr/propres.src68
-rw-r--r--extensions/source/propctrlr/propresid.hrc48
-rw-r--r--extensions/source/propctrlr/pushbuttonnavigation.cxx306
-rw-r--r--extensions/source/propctrlr/pushbuttonnavigation.hxx108
-rw-r--r--extensions/source/propctrlr/selectlabeldialog.cxx313
-rw-r--r--extensions/source/propctrlr/selectlabeldialog.hxx91
-rw-r--r--extensions/source/propctrlr/selectlabeldialog.src85
-rw-r--r--extensions/source/propctrlr/sqlcommanddesign.cxx393
-rw-r--r--extensions/source/propctrlr/sqlcommanddesign.hxx223
-rw-r--r--extensions/source/propctrlr/standardcontrol.cxx1442
-rw-r--r--extensions/source/propctrlr/standardcontrol.hxx445
-rw-r--r--extensions/source/propctrlr/stlops.hxx70
-rw-r--r--extensions/source/propctrlr/stringdefine.hxx99
-rw-r--r--extensions/source/propctrlr/stringrepresentation.cxx650
-rw-r--r--extensions/source/propctrlr/submissionhandler.cxx448
-rw-r--r--extensions/source/propctrlr/submissionhandler.hxx125
-rw-r--r--extensions/source/propctrlr/taborder.cxx424
-rw-r--r--extensions/source/propctrlr/taborder.hrc45
-rw-r--r--extensions/source/propctrlr/taborder.hxx132
-rw-r--r--extensions/source/propctrlr/taborder.src107
-rw-r--r--extensions/source/propctrlr/unourl.cxx70
-rw-r--r--extensions/source/propctrlr/unourl.hxx65
-rw-r--r--extensions/source/propctrlr/usercontrol.cxx370
-rw-r--r--extensions/source/propctrlr/usercontrol.hxx172
-rw-r--r--extensions/source/propctrlr/xsddatatypes.cxx250
-rw-r--r--extensions/source/propctrlr/xsddatatypes.hxx114
-rw-r--r--extensions/source/propctrlr/xsdvalidationhelper.cxx412
-rw-r--r--extensions/source/propctrlr/xsdvalidationhelper.hxx150
-rw-r--r--extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx692
-rw-r--r--extensions/source/propctrlr/xsdvalidationpropertyhandler.hxx103
137 files changed, 39540 insertions, 0 deletions
diff --git a/extensions/source/propctrlr/MasterDetailLinkDialog.cxx b/extensions/source/propctrlr/MasterDetailLinkDialog.cxx
new file mode 100644
index 000000000000..dfd695999048
--- /dev/null
+++ b/extensions/source/propctrlr/MasterDetailLinkDialog.cxx
@@ -0,0 +1,157 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+ #include "precompiled_extensions.hxx"
+ #include "MasterDetailLinkDialog.hxx"
+ #include "formlinkdialog.hxx"
+
+ extern "C" void SAL_CALL createRegistryInfo_MasterDetailLinkDialog()
+{
+ ::pcr::OAutoRegistration< ::pcr::MasterDetailLinkDialog > aAutoRegistration;
+}
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+
+ //====================================================================
+ //= MasterDetailLinkDialog
+ //====================================================================
+ //---------------------------------------------------------------------
+ MasterDetailLinkDialog::MasterDetailLinkDialog(const Reference< XComponentContext >& _rxContext )
+ :OGenericUnoDialog( _rxContext )
+ {
+ }
+//---------------------------------------------------------------------
+ Sequence<sal_Int8> SAL_CALL MasterDetailLinkDialog::getImplementationId( ) throw(RuntimeException)
+ {
+ static ::cppu::OImplementationId aId;
+ return aId.getImplementationId();
+ }
+
+ //---------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL MasterDetailLinkDialog::Create( const Reference< XComponentContext >& _rxContext )
+ {
+ return *( new MasterDetailLinkDialog( _rxContext ) );
+ }
+
+ //---------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL MasterDetailLinkDialog::getImplementationName() throw(RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //---------------------------------------------------------------------
+ ::rtl::OUString MasterDetailLinkDialog::getImplementationName_static() throw(RuntimeException)
+ {
+ return ::rtl::OUString::createFromAscii("org.openoffice.comp.form.ui.MasterDetailLinkDialog");
+ }
+
+ //---------------------------------------------------------------------
+ ::comphelper::StringSequence SAL_CALL MasterDetailLinkDialog::getSupportedServiceNames() throw(RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //---------------------------------------------------------------------
+ ::comphelper::StringSequence MasterDetailLinkDialog::getSupportedServiceNames_static() throw(RuntimeException)
+ {
+ ::comphelper::StringSequence aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.form.MasterDetailLinkDialog");
+ return aSupported;
+ }
+
+ //---------------------------------------------------------------------
+ Reference<XPropertySetInfo> SAL_CALL MasterDetailLinkDialog::getPropertySetInfo() throw(RuntimeException)
+ {
+ Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+ }
+
+ //---------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper& MasterDetailLinkDialog::getInfoHelper()
+ {
+ return *const_cast<MasterDetailLinkDialog*>(this)->getArrayHelper();
+ }
+
+ //--------------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper* MasterDetailLinkDialog::createArrayHelper( ) const
+ {
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+ }
+
+ //--------------------------------------------------------------------------
+ Dialog* MasterDetailLinkDialog::createDialog(Window* _pParent)
+ {
+ return new FormLinkDialog(_pParent,m_xDetail,m_xMaster,m_aContext.getLegacyServiceFactory()
+ ,m_sExplanation,m_sDetailLabel,m_sMasterLabel);
+ }
+ //---------------------------------------------------------------------
+ void MasterDetailLinkDialog::implInitialize(const Any& _rValue)
+ {
+ PropertyValue aProperty;
+ if (_rValue >>= aProperty)
+ {
+ if (0 == aProperty.Name.compareToAscii("Detail"))
+ {
+ OSL_VERIFY( aProperty.Value >>= m_xDetail );
+ return;
+ }
+ else if (0 == aProperty.Name.compareToAscii("Master"))
+ {
+ OSL_VERIFY( aProperty.Value >>= m_xMaster );
+ return;
+ }
+ else if (0 == aProperty.Name.compareToAscii("Explanation"))
+ {
+ OSL_VERIFY( aProperty.Value >>= m_sExplanation );
+ return;
+ }
+ else if (0 == aProperty.Name.compareToAscii("DetailLabel"))
+ {
+ OSL_VERIFY( aProperty.Value >>= m_sDetailLabel );
+ return;
+ }
+ else if (0 == aProperty.Name.compareToAscii("MasterLabel"))
+ {
+ OSL_VERIFY( aProperty.Value >>= m_sMasterLabel );
+ return;
+ }
+ }
+ MasterDetailLinkDialog_DBase::implInitialize(_rValue);
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
diff --git a/extensions/source/propctrlr/MasterDetailLinkDialog.hxx b/extensions/source/propctrlr/MasterDetailLinkDialog.hxx
new file mode 100644
index 000000000000..4fa32628ef66
--- /dev/null
+++ b/extensions/source/propctrlr/MasterDetailLinkDialog.hxx
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef PROPCTRLR_MASTERDETAILLINKDIALOG_HXX
+#define PROPCTRLR_MASTERDETAILLINKDIALOG_HXX
+#include <svtools/genericunodialog.hxx>
+#include "modulepcr.hxx"
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ class MasterDetailLinkDialog;
+ typedef ::svt::OGenericUnoDialog MasterDetailLinkDialog_DBase;
+ typedef ::comphelper::OPropertyArrayUsageHelper< MasterDetailLinkDialog > MasterDetailLinkDialog_PBase;
+
+ //========================================================================
+ //= MasterDetailLinkDialog
+ //========================================================================
+ class MasterDetailLinkDialog : public MasterDetailLinkDialog_DBase
+ ,public MasterDetailLinkDialog_PBase
+ ,public PcrClient
+ {
+ public:
+ MasterDetailLinkDialog(const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& _rxContext);
+
+ // XServiceInfo - static methods
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::rtl::OUString getImplementationName_static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >&);
+ private:
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ // OGenericUnoDialog overridables
+ virtual Dialog* createDialog(Window* _pParent);
+ virtual void implInitialize(const com::sun::star::uno::Any& _rValue);
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xDetail;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xMaster;
+ ::rtl::OUString m_sExplanation;
+ ::rtl::OUString m_sDetailLabel;
+ ::rtl::OUString m_sMasterLabel;
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+#endif // PROPCTRLR_MASTERDETAILLINKDIALOG_HXX
diff --git a/extensions/source/propctrlr/browserline.cxx b/extensions/source/propctrlr/browserline.cxx
new file mode 100644
index 000000000000..e67e466c5d24
--- /dev/null
+++ b/extensions/source/propctrlr/browserline.cxx
@@ -0,0 +1,548 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "browserline.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/PropertyLineElement.hpp>
+#include <com/sun/star/graphic/XGraphicProvider.hpp>
+/** === end UNO includes === **/
+
+#include <vcl/svapp.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/urlobj.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/componentcontext.hxx>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::inspection::XPropertyControl;
+ using ::com::sun::star::inspection::XPropertyControlContext;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::graphic::XGraphicProvider;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::graphic::XGraphic;
+ /** === end UNO using === **/
+
+ namespace PropertyLineElement = ::com::sun::star::inspection::PropertyLineElement;
+
+ //==================================================================
+ //= OBrowserLine
+ //==================================================================
+ DBG_NAME(OBrowserLine)
+ //------------------------------------------------------------------
+
+ OBrowserLine::OBrowserLine( const ::rtl::OUString& _rEntryName, Window* pParent )
+ :m_sEntryName( _rEntryName )
+ ,m_aFtTitle(pParent)
+ ,m_pControlWindow( NULL )
+ ,m_pBrowseButton(NULL)
+ ,m_pAdditionalBrowseButton( NULL )
+ ,m_pClickListener( NULL )
+ ,m_pTheParent(pParent)
+ ,m_nNameWidth(0)
+ ,m_nEnableFlags( 0xFFFF )
+ ,m_bIndentTitle( false )
+ ,m_bReadOnly( false )
+ {
+ DBG_CTOR(OBrowserLine,NULL);
+ m_aFtTitle.Show();
+ }
+
+ //------------------------------------------------------------------
+ OBrowserLine::~OBrowserLine()
+ {
+ implHideBrowseButton( true, false );
+ implHideBrowseButton( false, false );
+
+ DBG_DTOR(OBrowserLine,NULL);
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::IndentTitle( bool _bIndent )
+ {
+ if ( m_bIndentTitle != _bIndent )
+ {
+ m_bIndentTitle = _bIndent;
+ impl_layoutComponents();
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::SetComponentHelpIds( const rtl::OString& _rHelpId, const rtl::OString& _sPrimaryButtonId, const rtl::OString& _sSecondaryButtonId )
+ {
+ if ( m_pControlWindow )
+ m_pControlWindow->SetHelpId( _rHelpId );
+
+ if ( m_pBrowseButton )
+ {
+ m_pBrowseButton->SetHelpId( _rHelpId );
+ m_pBrowseButton->SetUniqueId( _sPrimaryButtonId );
+
+ if ( m_pAdditionalBrowseButton )
+ {
+ m_pAdditionalBrowseButton->SetHelpId( _rHelpId );
+ m_pAdditionalBrowseButton->SetUniqueId( _sSecondaryButtonId );
+ }
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::setControl( const Reference< XPropertyControl >& _rxControl )
+ {
+ m_xControl = _rxControl;
+ m_pControlWindow = m_xControl.is() ? VCLUnoHelper::GetWindow( _rxControl->getControlWindow() ) : NULL;
+ DBG_ASSERT( m_pControlWindow, "OBrowserLine::setControl: setting NULL controls/windows is not allowed!" );
+
+ if ( m_pControlWindow )
+ {
+ m_pControlWindow->SetParent( m_pTheParent );
+ m_pControlWindow->Show();
+ }
+ impl_layoutComponents();
+ }
+
+ //------------------------------------------------------------------
+ Window* OBrowserLine::GetRefWindow()
+ {
+ Window* pRefWindow=&m_aFtTitle;
+
+ if(m_pBrowseButton)
+ {
+ pRefWindow=(Window*)m_pBrowseButton;
+ }
+ else if ( m_pControlWindow )
+ {
+ pRefWindow = m_pControlWindow;
+ }
+ return pRefWindow;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::SetTabOrder(Window* pRefWindow, sal_uInt16 nFlags )
+ {
+ m_aFtTitle.SetZOrder(pRefWindow,nFlags);
+ if ( m_pControlWindow )
+ m_pControlWindow->SetZOrder( (Window*)&m_aFtTitle, WINDOW_ZORDER_BEHIND );
+
+ if ( m_pBrowseButton )
+ m_pBrowseButton->SetZOrder( m_pControlWindow, WINDOW_ZORDER_BEHIND );
+
+ if ( m_pAdditionalBrowseButton )
+ m_pAdditionalBrowseButton->SetZOrder( m_pBrowseButton, WINDOW_ZORDER_BEHIND );
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool OBrowserLine::GrabFocus()
+ {
+ sal_Bool bRes=sal_False;
+
+ if ( m_pControlWindow && m_pControlWindow->IsEnabled() )
+ {
+ m_pControlWindow->GrabFocus();
+ bRes = sal_True;
+ }
+ else if ( m_pAdditionalBrowseButton && m_pAdditionalBrowseButton->IsEnabled() )
+ {
+ m_pAdditionalBrowseButton->GrabFocus();
+ bRes = sal_True;
+ }
+ else if ( m_pBrowseButton && m_pBrowseButton->IsEnabled() )
+ {
+ m_pBrowseButton->GrabFocus();
+ bRes = sal_True;
+ }
+ return bRes;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::SetPosSizePixel( Point _rPos, Size _rSize )
+ {
+ m_aLinePos = _rPos;
+ m_aOutputSize = _rSize;
+
+ impl_layoutComponents();
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::Show(sal_Bool bFlag)
+ {
+ m_aFtTitle.Show(bFlag);
+ if ( m_pControlWindow )
+ m_pControlWindow->Show( bFlag );
+ if ( m_pBrowseButton )
+ m_pBrowseButton->Show( bFlag );
+ if ( m_pAdditionalBrowseButton )
+ m_pAdditionalBrowseButton->Show( bFlag );
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::Hide()
+ {
+ Show(sal_False);
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool OBrowserLine::IsVisible()
+ {
+ return m_aFtTitle.IsVisible();
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::impl_layoutComponents()
+ {
+ {
+ Point aTitlePos( m_aLinePos.X(), m_aLinePos.Y() + 8 );
+ Size aTitleSize( m_nNameWidth - 3, m_aOutputSize.Height() );
+
+ if ( m_bIndentTitle )
+ {
+ Size aIndent( m_pTheParent->LogicToPixel( Size( 8, 0 ), MAP_APPFONT ) );
+ aTitlePos.X() += aIndent.Width();
+ aTitleSize.Width() -= aIndent.Width();
+ }
+ m_aFtTitle.SetPosSizePixel( aTitlePos, aTitleSize );
+ }
+
+ sal_Int32 nBrowseButtonSize = m_aOutputSize.Height() - 4;
+
+ if ( m_pControlWindow )
+ {
+ Point aControlPos( m_aLinePos.X() + m_nNameWidth, m_aLinePos.Y() + 2 );
+ m_pControlWindow->SetPosPixel( aControlPos );
+
+ Size aControlSize( m_aOutputSize.Width() - 4 - m_nNameWidth - nBrowseButtonSize - 4, m_pControlWindow->GetSizePixel().Height() );
+ if ( m_pAdditionalBrowseButton )
+ aControlSize.Width() -= nBrowseButtonSize + 4;
+ m_pControlWindow->SetSizePixel( aControlSize );
+ }
+
+ if ( m_pBrowseButton )
+ {
+ Point aButtonPos( m_aOutputSize.Width() - 4 - nBrowseButtonSize, m_aLinePos.Y() + 2 );
+ Size aButtonSize( nBrowseButtonSize, nBrowseButtonSize );
+ m_pBrowseButton->SetPosSizePixel( aButtonPos, aButtonSize );
+
+ if ( m_pAdditionalBrowseButton )
+ {
+ aButtonPos.X() -= nBrowseButtonSize + 4;
+ m_pAdditionalBrowseButton->SetPosSizePixel( aButtonPos, aButtonSize );
+ }
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::SetTitle(const XubString& _rNewTtile )
+ {
+ if ( GetTitle() == _rNewTtile )
+ return;
+ // #99102# --------------
+ m_aFtTitle.SetText( _rNewTtile );
+ if ( m_pControlWindow )
+ m_pControlWindow->SetAccessibleName( _rNewTtile );
+ if ( m_pBrowseButton )
+ m_pBrowseButton->SetAccessibleName( _rNewTtile );
+ FullFillTitleString();
+ }
+
+ // #99102# ---------------------------------------------------------
+ void OBrowserLine::FullFillTitleString()
+ {
+ if( m_pTheParent )
+ {
+ String aText = m_aFtTitle.GetText();
+
+ while( m_pTheParent->GetTextWidth( aText ) < m_nNameWidth )
+ aText.AppendAscii("...........");
+
+ // for Issue 69452
+ if (Application::GetSettings().GetLayoutRTL())
+ {
+ sal_Unicode cRTL_mark = 0x200F;
+ aText.Append(cRTL_mark);
+ }
+
+ m_aFtTitle.SetText(aText);
+ }
+ }
+
+ //------------------------------------------------------------------
+ XubString OBrowserLine::GetTitle() const
+ {
+ String sDisplayName = m_aFtTitle.GetText();
+
+ // for Issue 69452
+ if (Application::GetSettings().GetLayoutRTL())
+ {
+ sal_Unicode cRTL_mark = 0x200F;
+ sDisplayName.EraseTrailingChars(cRTL_mark);
+ }
+
+ sDisplayName.EraseTrailingChars( '.' );
+
+ return sDisplayName;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::SetReadOnly( bool _bReadOnly )
+ {
+ if ( m_bReadOnly != _bReadOnly )
+ {
+ m_bReadOnly = _bReadOnly;
+ implUpdateEnabledDisabled();
+ }
+ }
+
+ //------------------------------------------------------------------
+ namespace
+ {
+ void implSetBitIfAffected( sal_uInt16& _nEnabledBits, sal_Int16 _nAffectedMask, sal_Int16 _nTestBit, bool _bSet )
+ {
+ if ( _nAffectedMask & _nTestBit )
+ {
+ if ( _bSet )
+ _nEnabledBits |= _nTestBit;
+ else
+ _nEnabledBits &= ~_nTestBit;
+ }
+ }
+
+ void implEnable( Window* _pWindow, sal_uInt16 _nEnabledBits, sal_uInt16 _nMatchBits )
+ {
+ if ( _pWindow )
+ _pWindow->Enable( ( _nEnabledBits & _nMatchBits ) == _nMatchBits );
+ }
+
+ void implEnable( Window* _pWindow, bool _bEnable )
+ {
+ if ( _pWindow )
+ _pWindow->Enable( _bEnable );
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::implUpdateEnabledDisabled()
+ {
+ implEnable( &m_aFtTitle, m_nEnableFlags, PropertyLineElement::CompleteLine );
+ if ( m_pControlWindow )
+ implEnable( m_pControlWindow, m_nEnableFlags, PropertyLineElement::CompleteLine | PropertyLineElement::InputControl );
+
+ if ( m_bReadOnly )
+ {
+ implEnable( m_pBrowseButton, false );
+ implEnable( m_pAdditionalBrowseButton, false );
+ }
+ else
+ {
+ implEnable( m_pBrowseButton, m_nEnableFlags, PropertyLineElement::CompleteLine | PropertyLineElement::PrimaryButton );
+ implEnable( m_pAdditionalBrowseButton, m_nEnableFlags, PropertyLineElement::CompleteLine | PropertyLineElement::SecondaryButton );
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::EnablePropertyLine( bool _bEnable )
+ {
+ implSetBitIfAffected( m_nEnableFlags, PropertyLineElement::CompleteLine, PropertyLineElement::CompleteLine, _bEnable );
+ implUpdateEnabledDisabled();
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::EnablePropertyControls( sal_Int16 _nControls, bool _bEnable )
+ {
+ implSetBitIfAffected( m_nEnableFlags, _nControls, PropertyLineElement::InputControl, _bEnable );
+ implSetBitIfAffected( m_nEnableFlags, _nControls, PropertyLineElement::PrimaryButton, _bEnable );
+ implSetBitIfAffected( m_nEnableFlags, _nControls, PropertyLineElement::SecondaryButton, _bEnable );
+ implUpdateEnabledDisabled();
+ }
+
+ //------------------------------------------------------------------
+ PushButton& OBrowserLine::impl_ensureButton( bool _bPrimary )
+ {
+ PushButton*& rpButton = _bPrimary ? m_pBrowseButton : m_pAdditionalBrowseButton;
+
+ if ( !rpButton )
+ {
+ rpButton = new PushButton( m_pTheParent, WB_NOPOINTERFOCUS );
+ rpButton->SetGetFocusHdl( LINK( this, OBrowserLine, OnButtonFocus ) );
+ rpButton->SetClickHdl( LINK( this, OBrowserLine, OnButtonClicked ) );
+ rpButton->SetText( String::CreateFromAscii( "..." ) );
+ }
+
+ rpButton->Show();
+
+ impl_layoutComponents();
+
+ return *rpButton;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::impl_getImagesFromURL_nothrow( const ::rtl::OUString& _rImageURL, Image& _out_rImage, Image& _out_rHCImage )
+ {
+ try
+ {
+ ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+ Reference< XGraphicProvider > xGraphicProvider( aContext.createComponent( "com.sun.star.graphic.GraphicProvider" ), UNO_QUERY_THROW );
+
+ Sequence< PropertyValue > aMediaProperties(1);
+ aMediaProperties[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
+ aMediaProperties[0].Value <<= _rImageURL;
+
+ Reference< XGraphic > xGraphic( xGraphicProvider->queryGraphic( aMediaProperties ), UNO_QUERY_THROW );
+ _out_rImage = _out_rHCImage = Image( xGraphic );
+
+ // see if we find an HC version beside the normal graphic
+ INetURLObject aURL( _rImageURL );
+ ::rtl::OUString sBaseName( aURL.getBase() );
+ aURL.setBase( sBaseName + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_hc" ) ) );
+ ::rtl::OUString sHCImageURL( aURL.GetMainURL( INetURLObject::NO_DECODE ) );
+
+ Reference< XGraphic > xHCGraphic;
+ try
+ {
+ aMediaProperties[0].Value <<= sHCImageURL;
+ xHCGraphic = xGraphicProvider->queryGraphic( aMediaProperties );
+ }
+ catch( const Exception& ) { }
+
+ if ( xHCGraphic.is() )
+ _out_rHCImage = Image( xHCGraphic );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::ShowBrowseButton( const ::rtl::OUString& _rImageURL, sal_Bool _bPrimary )
+ {
+ PushButton& rButton( impl_ensureButton( _bPrimary ) );
+
+ OSL_PRECOND( _rImageURL.getLength(), "OBrowserLine::ShowBrowseButton: use the other version if you don't have an image!" );
+ Image aImage, aHCImage;
+ impl_getImagesFromURL_nothrow( _rImageURL, aImage, aHCImage );
+
+ rButton.SetModeImage( aImage, BMP_COLOR_NORMAL );
+ rButton.SetModeImage( aHCImage, BMP_COLOR_HIGHCONTRAST );
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::ShowBrowseButton( const Image& _rImage, sal_Bool _bPrimary )
+ {
+ PushButton& rButton( impl_ensureButton( _bPrimary ) );
+ if ( !!_rImage )
+ rButton.SetModeImage( _rImage );
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::ShowBrowseButton( sal_Bool _bPrimary )
+ {
+ impl_ensureButton( _bPrimary );
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::implHideBrowseButton( sal_Bool _bPrimary, bool _bReLayout )
+ {
+ PushButton*& rpButton = _bPrimary ? m_pBrowseButton : m_pAdditionalBrowseButton;
+
+ if ( rpButton )
+ {
+ rpButton->Hide();
+ delete rpButton;
+ rpButton = NULL;
+ }
+
+ if ( _bReLayout )
+ impl_layoutComponents();
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::HideBrowseButton( sal_Bool _bPrimary )
+ {
+ implHideBrowseButton( _bPrimary, true );
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::SetTitleWidth(sal_uInt16 nWidth)
+ {
+ if (m_nNameWidth != nWidth+10)
+ {
+ m_nNameWidth = nWidth+10;
+ impl_layoutComponents();
+ }
+ // #99102# ---------
+ FullFillTitleString();
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::SetClickListener( IButtonClickListener* _pListener )
+ {
+ m_pClickListener = _pListener;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( OBrowserLine, OnButtonClicked, PushButton*, _pButton )
+ {
+ if ( m_pClickListener )
+ m_pClickListener->buttonClicked( this, _pButton == m_pBrowseButton );
+
+ return 0L;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( OBrowserLine, OnButtonFocus, PushButton*, /*pPB*/ )
+ {
+ if ( m_xControl.is() )
+ {
+ try
+ {
+ Reference< XPropertyControlContext > xContext( m_xControl->getControlContext(), UNO_QUERY_THROW );
+ xContext->focusGained( m_xControl );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ return 0;
+ }
+//............................................................................
+} // namespace pcr
+//............................................................................
+
diff --git a/extensions/source/propctrlr/browserline.hxx b/extensions/source/propctrlr/browserline.hxx
new file mode 100644
index 000000000000..ac65993c0e12
--- /dev/null
+++ b/extensions/source/propctrlr/browserline.hxx
@@ -0,0 +1,143 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_BROWSERLINE_HXX_
+#define _EXTENSIONS_PROPCTRLR_BROWSERLINE_HXX_
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/XPropertyControl.hpp>
+/** === end UNO includes === **/
+#include <vcl/fixed.hxx>
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+
+namespace com { namespace sun { namespace star { namespace inspection { namespace PropertyLineElement
+{
+ const sal_Int16 CompleteLine = 0x4000;
+} } } } }
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ class OBrowserLine;
+
+ //========================================================================
+ class IButtonClickListener
+ {
+ public:
+ virtual void buttonClicked( OBrowserLine* _pLine, sal_Bool _bPrimary ) = 0;
+ };
+
+ //========================================================================
+ class OBrowserLine
+ {
+ private:
+ ::rtl::OUString m_sEntryName;
+ FixedText m_aFtTitle;
+ Size m_aOutputSize;
+ Point m_aLinePos;
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
+ m_xControl;
+ Window* m_pControlWindow;
+ PushButton* m_pBrowseButton;
+ PushButton* m_pAdditionalBrowseButton;
+ IButtonClickListener* m_pClickListener;
+ Window* m_pTheParent;
+ sal_uInt16 m_nNameWidth;
+ sal_uInt16 m_nEnableFlags;
+ bool m_bIndentTitle;
+ bool m_bReadOnly;
+
+ public:
+ OBrowserLine( const ::rtl::OUString& _rEntryName, Window* pParent);
+ ~OBrowserLine();
+
+ void setControl( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& _rxControl );
+ const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& getControl()
+ {
+ return m_xControl;
+ }
+ inline Window* getControlWindow() const
+ {
+ return m_pControlWindow;
+ }
+
+ const ::rtl::OUString&
+ GetEntryName() const { return m_sEntryName; }
+
+ void SetComponentHelpIds( const rtl::OString& _rHelpId, const rtl::OString& _sPrimaryButtonId, const rtl::OString& _sSecondaryButtonId );
+
+ void SetTitle(const String& rString );
+ void FullFillTitleString();
+ String GetTitle() const;
+ void SetTitleWidth(sal_uInt16);
+
+ void SetPosSizePixel(Point aPos,Size aSize);
+ void Show(sal_Bool bFlag=sal_True);
+ void Hide();
+ sal_Bool IsVisible();
+
+ Window* GetRefWindow();
+ void SetTabOrder(Window* pRefWindow, sal_uInt16 nFlags );
+
+ sal_Bool GrabFocus();
+ void ShowBrowseButton( const ::rtl::OUString& _rImageURL, sal_Bool _bPrimary );
+ void ShowBrowseButton( const Image& _rImage, sal_Bool _bPrimary );
+ void ShowBrowseButton( sal_Bool _bPrimary );
+ void HideBrowseButton( sal_Bool _bPrimary );
+
+ void EnablePropertyControls( sal_Int16 _nControls, bool _bEnable );
+ void EnablePropertyLine( bool _bEnable );
+
+ void SetReadOnly( bool _bReadOnly );
+
+ void SetClickListener( IButtonClickListener* _pListener );
+
+ void IndentTitle( bool _bIndent );
+
+ private:
+ DECL_LINK( OnButtonClicked, PushButton* );
+ DECL_LINK( OnButtonFocus, PushButton* );
+
+ void implHideBrowseButton( sal_Bool _bPrimary, bool _bReLayout );
+ void implUpdateEnabledDisabled();
+
+ void impl_layoutComponents();
+
+ PushButton& impl_ensureButton( bool _bPrimary );
+ void impl_getImagesFromURL_nothrow( const ::rtl::OUString& _rImageURL, Image& _out_rImage, Image& _out_rHCImage );
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_BROWSERLINE_HXX_
+
diff --git a/extensions/source/propctrlr/browserlistbox.cxx b/extensions/source/propctrlr/browserlistbox.cxx
new file mode 100644
index 000000000000..8682d9e701bb
--- /dev/null
+++ b/extensions/source/propctrlr/browserlistbox.cxx
@@ -0,0 +1,1312 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "browserlistbox.hxx"
+#ifndef EXTENSIONS_PROPRESID_HRC
+#include "propresid.hrc"
+#endif
+#include "proplinelistener.hxx"
+#include "propcontrolobserver.hxx"
+#include "linedescriptor.hxx"
+#include "inspectorhelpwindow.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/inspection/PropertyControlType.hpp>
+/** === end UNO includes === **/
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <comphelper/asyncnotification.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <vcl/svapp.hxx>
+#include <vos/mutex.hxx>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ #define FRAME_OFFSET 4
+ // TODO: find out what this is really for ... and check if it does make sense in the new
+ // browser environment
+ #define LAYOUT_HELP_WINDOW_DISTANCE_APPFONT 3
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::inspection::XPropertyControlContext;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::inspection::XPropertyControl;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::lang::DisposedException;
+ using ::com::sun::star::lang::XComponent;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::graphic::XGraphic;
+ /** === end UNO using === **/
+ namespace PropertyControlType = ::com::sun::star::inspection::PropertyControlType;
+
+ //==================================================================
+ //= ControlEvent
+ //==================================================================
+ enum ControlEventType
+ {
+ FOCUS_GAINED,
+ VALUE_CHANGED,
+ ACTIVATE_NEXT
+ };
+
+ struct ControlEvent : public ::comphelper::AnyEvent
+ {
+ Reference< XPropertyControl > xControl;
+ ControlEventType eType;
+
+ ControlEvent( const Reference< XPropertyControl >& _rxControl, ControlEventType _eType )
+ :xControl( _rxControl )
+ ,eType( _eType )
+ {
+ }
+ };
+
+ //==================================================================
+ //= SharedNotifier
+ //==================================================================
+ class SharedNotifier
+ {
+ private:
+ static ::osl::Mutex& getMutex();
+ static ::rtl::Reference< ::comphelper::AsyncEventNotifier > s_pNotifier;
+
+ public:
+ static const ::rtl::Reference< ::comphelper::AsyncEventNotifier >&
+ getNotifier();
+
+ private:
+ SharedNotifier(); // never implemented
+ SharedNotifier( const SharedNotifier& ); // never implemented
+ SharedNotifier& operator=( const SharedNotifier& ); // never implemented
+ };
+
+ //------------------------------------------------------------------
+ ::rtl::Reference< ::comphelper::AsyncEventNotifier > SharedNotifier::s_pNotifier;
+
+ //------------------------------------------------------------------
+ ::osl::Mutex& SharedNotifier::getMutex()
+ {
+ static ::osl::Mutex s_aMutex;
+ return s_aMutex;
+ }
+
+ //------------------------------------------------------------------
+ const ::rtl::Reference< ::comphelper::AsyncEventNotifier >& SharedNotifier::getNotifier()
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ if ( !s_pNotifier.is() )
+ {
+ s_pNotifier.set( new ::comphelper::AsyncEventNotifier );
+ s_pNotifier->create();
+ }
+ return s_pNotifier;
+ }
+
+ //==================================================================
+ //= PropertyControlContext_Impl
+ //==================================================================
+ /** implementation for of <type scope="com::sun::star::inspection">XPropertyControlContext</type>
+ which forwards all events to a non-UNO version of this interface
+ */
+ typedef ::cppu::WeakImplHelper1< XPropertyControlContext > PropertyControlContext_Impl_Base;
+ class PropertyControlContext_Impl :public PropertyControlContext_Impl_Base
+ ,public ::comphelper::IEventProcessor
+ {
+ public:
+ enum NotifcationMode
+ {
+ eSynchronously,
+ eAsynchronously
+ };
+
+ private:
+ IControlContext* m_pContext;
+ NotifcationMode m_eMode;
+
+ public:
+ /** creates an instance
+ @param _rContextImpl
+ the instance to delegate events to
+ */
+ PropertyControlContext_Impl( IControlContext& _rContextImpl );
+
+ /** disposes the context.
+
+ When you call this method, all subsequent callbacks to the
+ <type scope="com::sun::star::inspection">XPropertyControlContext</type> methods
+ will throw a <type scope="com::sun::star::lang">DisposedException</type>.
+ */
+ void SAL_CALL dispose();
+
+ /** sets the notification mode, so that notifications recieved from the controls are
+ forwarded to our IControlContext either synchronously or asynchronously
+ @param _eMode
+ the new notification mode
+ */
+ void setNotificationMode( NotifcationMode _eMode );
+
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ protected:
+ ~PropertyControlContext_Impl();
+
+ // XPropertyControlObserver
+ virtual void SAL_CALL focusGained( const Reference< XPropertyControl >& Control ) throw (RuntimeException);
+ virtual void SAL_CALL valueChanged( const Reference< XPropertyControl >& Control ) throw (RuntimeException);
+ // XPropertyControlContext
+ virtual void SAL_CALL activateNextControl( const Reference< XPropertyControl >& CurrentControl ) throw (RuntimeException);
+
+ // IEventProcessor
+ virtual void processEvent( const ::comphelper::AnyEvent& _rEvent );
+
+ private:
+ /** processes the given event, i.e. notifies it to our IControlContext
+ @param _rEvent
+ the event no notify
+ @precond
+ our mutex (well, the SolarMutex) is locked
+ */
+ void impl_processEvent_throw( const ::comphelper::AnyEvent& _rEvent );
+
+ /** checks whether we're alive
+
+ @throws DisposedException
+ if the instance is already disposed
+ */
+ void impl_checkAlive_throw() const;
+
+ /** checks whether the instance is already disposed
+ */
+ bool impl_isDisposed_nothrow() const { return m_pContext == NULL; }
+
+ /** notifies the given event originating from the given control
+ @throws DisposedException
+ @param _rxControl
+ @param _eType
+ */
+ void impl_notify_throw( const Reference< XPropertyControl >& _rxControl, ControlEventType _eType );
+ };
+
+ //--------------------------------------------------------------------
+ PropertyControlContext_Impl::PropertyControlContext_Impl( IControlContext& _rContextImpl )
+ :m_pContext( &_rContextImpl )
+ ,m_eMode( eAsynchronously )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ PropertyControlContext_Impl::~PropertyControlContext_Impl()
+ {
+ if ( !impl_isDisposed_nothrow() )
+ dispose();
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyControlContext_Impl::impl_checkAlive_throw() const
+ {
+ if ( impl_isDisposed_nothrow() )
+ throw DisposedException( ::rtl::OUString(), *const_cast< PropertyControlContext_Impl* >( this ) );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyControlContext_Impl::dispose()
+ {
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ if ( impl_isDisposed_nothrow() )
+ return;
+
+ SharedNotifier::getNotifier()->removeEventsForProcessor( this );
+ m_pContext = NULL;
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyControlContext_Impl::setNotificationMode( NotifcationMode _eMode )
+ {
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ m_eMode = _eMode;
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyControlContext_Impl::impl_notify_throw( const Reference< XPropertyControl >& _rxControl, ControlEventType _eType )
+ {
+ ::comphelper::AnyEventRef pEvent;
+
+ {
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ impl_checkAlive_throw();
+ pEvent = new ControlEvent( _rxControl, _eType );
+
+ if ( m_eMode == eSynchronously )
+ {
+ impl_processEvent_throw( *pEvent );
+ return;
+ }
+ }
+
+ SharedNotifier::getNotifier()->addEvent( pEvent, this );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyControlContext_Impl::focusGained( const Reference< XPropertyControl >& Control ) throw (RuntimeException)
+ {
+ DBG_TRACE( "PropertyControlContext_Impl: FOCUS_GAINED" );
+ impl_notify_throw( Control, FOCUS_GAINED );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyControlContext_Impl::valueChanged( const Reference< XPropertyControl >& Control ) throw (RuntimeException)
+ {
+ DBG_TRACE( "PropertyControlContext_Impl: VALUE_CHANGED" );
+ impl_notify_throw( Control, VALUE_CHANGED );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyControlContext_Impl::activateNextControl( const Reference< XPropertyControl >& CurrentControl ) throw (RuntimeException)
+ {
+ DBG_TRACE( "PropertyControlContext_Impl: ACTIVATE_NEXT" );
+ impl_notify_throw( CurrentControl, ACTIVATE_NEXT );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyControlContext_Impl::acquire() throw()
+ {
+ PropertyControlContext_Impl_Base::acquire();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyControlContext_Impl::release() throw()
+ {
+ PropertyControlContext_Impl_Base::release();
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyControlContext_Impl::processEvent( const ::comphelper::AnyEvent& _rEvent )
+ {
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ if ( impl_isDisposed_nothrow() )
+ return;
+
+ try
+ {
+ impl_processEvent_throw( _rEvent );
+ }
+ catch( const Exception& )
+ {
+ // can't handle otherwise, since our caller (the notification thread) does not allow
+ // for exceptions (it could itself abort only)
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyControlContext_Impl::impl_processEvent_throw( const ::comphelper::AnyEvent& _rEvent )
+ {
+ const ControlEvent& rControlEvent = static_cast< const ControlEvent& >( _rEvent );
+ switch ( rControlEvent.eType )
+ {
+ case FOCUS_GAINED:
+ DBG_TRACE( "PropertyControlContext_Impl::processEvent: FOCUS_GAINED" );
+ m_pContext->focusGained( rControlEvent.xControl );
+ break;
+ case VALUE_CHANGED:
+ DBG_TRACE( "PropertyControlContext_Impl::processEvent: VALUE_CHANGED" );
+ m_pContext->valueChanged( rControlEvent.xControl );
+ break;
+ case ACTIVATE_NEXT:
+ DBG_TRACE( "PropertyControlContext_Impl::processEvent: ACTIVATE_NEXT" );
+ m_pContext->activateNextControl( rControlEvent.xControl );
+ break;
+ }
+ }
+
+ //==================================================================
+ //= OBrowserListBox
+ //==================================================================
+ DBG_NAME(OBrowserListBox)
+ //------------------------------------------------------------------
+ OBrowserListBox::OBrowserListBox( Window* pParent, WinBits nWinStyle)
+ :Control(pParent, nWinStyle| WB_CLIPCHILDREN)
+ ,m_aLinesPlayground(this,WB_DIALOGCONTROL | WB_CLIPCHILDREN)
+ ,m_aVScroll(this,WB_VSCROLL|WB_REPEAT|WB_DRAG)
+ ,m_pHelpWindow( new InspectorHelpWindow( this ) )
+ ,m_pLineListener(NULL)
+ ,m_pControlObserver( NULL )
+ ,m_nYOffset(0)
+ ,m_nCurrentPreferredHelpHeight(0)
+ ,m_nTheNameSize(0)
+ ,m_bIsActive(sal_False)
+ ,m_bUpdate(sal_True)
+ ,m_pControlContextImpl( new PropertyControlContext_Impl( *this ) )
+ {
+ DBG_CTOR(OBrowserListBox,NULL);
+
+ ListBox aListBox(this,WB_DROPDOWN);
+ aListBox.SetPosSizePixel(Point(0,0),Size(100,100));
+ m_nRowHeight = (sal_uInt16)aListBox.GetSizePixel().Height()+2;
+ SetBackground( pParent->GetBackground() );
+ m_aLinesPlayground.SetBackground( GetBackground() );
+
+ m_aLinesPlayground.SetPosPixel(Point(0,0));
+ m_aLinesPlayground.SetPaintTransparent(sal_True);
+ m_aLinesPlayground.Show();
+ m_aVScroll.Hide();
+ m_aVScroll.SetScrollHdl(LINK(this, OBrowserListBox, ScrollHdl));
+ }
+
+ //------------------------------------------------------------------
+ OBrowserListBox::~OBrowserListBox()
+ {
+ OSL_ENSURE( !IsModified(), "OBrowserListBox::~OBrowserListBox: still modified - should have been committed before!" );
+ // doing the commit here, while we, as well as our owner, as well as some other components,
+ // are already "half dead" (means within their dtor) is potentially dangerous.
+ // By definition, CommitModified has to be called (if necessary) before destruction
+ // #105868# - 2002-12-13 - fs@openoffice.org
+
+ m_pControlContextImpl->dispose();
+ m_pControlContextImpl.clear();
+
+ Hide();
+ Clear();
+
+ DBG_DTOR(OBrowserListBox,NULL);
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool OBrowserListBox::IsModified( ) const
+ {
+ sal_Bool bModified = sal_False;
+
+ if ( m_bIsActive && m_xActiveControl.is() )
+ bModified = m_xActiveControl->isModified();
+
+ return bModified;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::CommitModified( )
+ {
+ if ( IsModified() && m_xActiveControl.is() )
+ {
+ // for the time of this commit, notify all events synchronously
+ // #i63814# / 2006-03-31 / frank.schoenheit@sun.com
+ m_pControlContextImpl->setNotificationMode( PropertyControlContext_Impl::eSynchronously );
+ try
+ {
+ m_xActiveControl->notifyModifiedValue();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ m_pControlContextImpl->setNotificationMode( PropertyControlContext_Impl::eAsynchronously );
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::ActivateListBox(sal_Bool _bActive)
+ {
+ m_bIsActive = _bActive;
+ if (m_bIsActive)
+ {
+ // TODO: what's the sense of this?
+ m_aVScroll.SetThumbPos(100);
+ MoveThumbTo(0);
+ Resize();
+ }
+ }
+
+ //------------------------------------------------------------------
+ long OBrowserListBox::impl_getPrefererredHelpHeight()
+ {
+ return HasHelpSection() ? m_pHelpWindow->GetOptimalHeightPixel() : 0;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::Resize()
+ {
+ Rectangle aPlayground( Point( 0, 0 ), GetOutputSizePixel() );
+ Size aHelpWindowDistance( LogicToPixel( Size( 0, LAYOUT_HELP_WINDOW_DISTANCE_APPFONT ), MAP_APPFONT ) );
+
+ long nHelpWindowHeight = m_nCurrentPreferredHelpHeight = impl_getPrefererredHelpHeight();
+ bool bPositionHelpWindow = ( nHelpWindowHeight != 0 );
+
+ Rectangle aLinesArea( aPlayground );
+ if ( bPositionHelpWindow )
+ {
+ aLinesArea.Bottom() -= nHelpWindowHeight;
+ aLinesArea.Bottom() -= aHelpWindowDistance.Height();
+ }
+ m_aLinesPlayground.SetPosSizePixel( aLinesArea.TopLeft(), aLinesArea.GetSize() );
+
+ UpdateVScroll();
+
+ sal_Bool bNeedScrollbar = m_aOrderedLines.size() > (sal_uInt32)CalcVisibleLines();
+ if ( !bNeedScrollbar )
+ {
+ if ( m_aVScroll.IsVisible() )
+ m_aVScroll.Hide();
+ // scroll to top
+ m_nYOffset = 0;
+ m_aVScroll.SetThumbPos( 0 );
+ }
+ else
+ {
+ Size aVScrollSize( m_aVScroll.GetSizePixel() );
+
+ // adjust the playground's width
+ aLinesArea.Right() -= aVScrollSize.Width();
+ m_aLinesPlayground.SetPosSizePixel( aLinesArea.TopLeft(), aLinesArea.GetSize() );
+
+ // position the scrollbar
+ aVScrollSize.Height() = aLinesArea.GetHeight();
+ Point aVScrollPos( aLinesArea.GetWidth(), 0 );
+ m_aVScroll.SetPosSizePixel( aVScrollPos, aVScrollSize );
+ }
+
+ for ( sal_uInt16 i = 0; i < m_aOrderedLines.size(); ++i )
+ m_aOutOfDateLines.insert( i );
+
+ // repaint
+ EnablePaint(sal_False);
+ UpdatePlayGround();
+ EnablePaint(sal_True);
+
+ // show the scrollbar
+ if ( bNeedScrollbar )
+ m_aVScroll.Show();
+
+ // position the help window
+ if ( bPositionHelpWindow )
+ {
+ Rectangle aHelpArea( aPlayground );
+ aHelpArea.Top() = aLinesArea.Bottom() + aHelpWindowDistance.Height();
+ m_pHelpWindow->SetPosSizePixel( aHelpArea.TopLeft(), aHelpArea.GetSize() );
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::SetListener( IPropertyLineListener* _pListener )
+ {
+ m_pLineListener = _pListener;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::SetObserver( IPropertyControlObserver* _pObserver )
+ {
+ m_pControlObserver = _pObserver;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::EnableHelpSection( bool _bEnable )
+ {
+ m_pHelpWindow->Show( _bEnable );
+ Resize();
+ }
+
+ //------------------------------------------------------------------
+ bool OBrowserListBox::HasHelpSection() const
+ {
+ return m_pHelpWindow->IsVisible();
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::SetHelpText( const ::rtl::OUString& _rHelpText )
+ {
+ OSL_ENSURE( HasHelpSection(), "OBrowserListBox::SetHelpText: help section not visible!" );
+ m_pHelpWindow->SetText( _rHelpText );
+ if ( m_nCurrentPreferredHelpHeight != impl_getPrefererredHelpHeight() )
+ Resize();
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::SetHelpLineLimites( sal_Int32 _nMinLines, sal_Int32 _nMaxLines )
+ {
+ m_pHelpWindow->SetLimits( _nMinLines, _nMaxLines );
+ }
+
+ //------------------------------------------------------------------
+ sal_uInt16 OBrowserListBox::CalcVisibleLines()
+ {
+ Size aSize(m_aLinesPlayground.GetOutputSizePixel());
+ sal_uInt16 nResult = 0;
+ if (0 != m_nRowHeight)
+ nResult = (sal_uInt16) aSize.Height()/m_nRowHeight;
+
+ return nResult;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::UpdateVScroll()
+ {
+ sal_uInt16 nLines = CalcVisibleLines();
+ m_aVScroll.SetPageSize(nLines-1);
+ m_aVScroll.SetVisibleSize(nLines-1);
+
+ size_t nCount = m_aLines.size();
+ if (nCount>0)
+ {
+ m_aVScroll.SetRange(Range(0,nCount-1));
+ m_nYOffset = -m_aVScroll.GetThumbPos()*m_nRowHeight;
+ }
+ else
+ {
+ m_aVScroll.SetRange(Range(0,0));
+ m_nYOffset = 0;
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::PositionLine( sal_uInt16 _nIndex )
+ {
+ Size aSize(m_aLinesPlayground.GetOutputSizePixel());
+ Point aPos(0, m_nYOffset);
+
+ aSize.Height() = m_nRowHeight;
+
+ aPos.Y() += _nIndex * m_nRowHeight;
+
+ if ( _nIndex < m_aOrderedLines.size() )
+ {
+ m_aOrderedLines[ _nIndex ]->second.pLine->SetPosSizePixel( aPos, aSize );
+
+ m_aOrderedLines[ _nIndex ]->second.pLine->SetTitleWidth( m_nTheNameSize + 2 * FRAME_OFFSET );
+
+ // show the line if necessary
+ if ( !m_aOrderedLines[ _nIndex ]->second.pLine->IsVisible() )
+ m_aOrderedLines[ _nIndex ]->second.pLine->Show();
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::UpdatePosNSize()
+ {
+ for ( ::std::set< sal_uInt16 >::const_iterator aLoop = m_aOutOfDateLines.begin();
+ aLoop != m_aOutOfDateLines.end();
+ ++aLoop
+ )
+ {
+ DBG_ASSERT( *aLoop < m_aOrderedLines.size(), "OBrowserListBox::UpdatePosNSize: invalid line index!" );
+ if ( *aLoop < m_aOrderedLines.size() )
+ PositionLine( *aLoop );
+ }
+ m_aOutOfDateLines.clear();
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::UpdatePlayGround()
+ {
+ sal_Int32 nThumbPos = m_aVScroll.GetThumbPos();
+ sal_Int32 nLines = CalcVisibleLines();
+
+ sal_uInt16 nEnd = (sal_uInt16)(nThumbPos + nLines);
+ if (nEnd >= m_aOrderedLines.size())
+ nEnd = (sal_uInt16)m_aOrderedLines.size()-1;
+
+ if ( !m_aOrderedLines.empty() )
+ {
+ for ( sal_uInt16 i = (sal_uInt16)nThumbPos; i <= nEnd; ++i )
+ m_aOutOfDateLines.insert( i );
+ UpdatePosNSize();
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::UpdateAll()
+ {
+ Resize();
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::DisableUpdate()
+ {
+ m_bUpdate = sal_False;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::EnableUpdate()
+ {
+ m_bUpdate = sal_True;
+ UpdateAll();
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::SetPropertyValue(const ::rtl::OUString& _rEntryName, const Any& _rValue, bool _bUnknownValue )
+ {
+ ListBoxLines::iterator line = m_aLines.find( _rEntryName );
+ if ( line != m_aLines.end() )
+ {
+ if ( _bUnknownValue )
+ {
+ Reference< XPropertyControl > xControl( line->second.pLine->getControl() );
+ OSL_ENSURE( xControl.is(), "OBrowserListBox::SetPropertyValue: illegal control!" );
+ if ( xControl.is() )
+ xControl->setValue( Any() );
+ }
+ else
+ impl_setControlAsPropertyValue( line->second, _rValue );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ sal_uInt16 OBrowserListBox::GetPropertyPos( const ::rtl::OUString& _rEntryName ) const
+ {
+ sal_uInt16 nRet = LISTBOX_ENTRY_NOTFOUND;
+ for ( OrderedListBoxLines::const_iterator linePos = m_aOrderedLines.begin();
+ linePos != m_aOrderedLines.end();
+ ++linePos
+ )
+ {
+ if ( (*linePos)->first == _rEntryName )
+ {
+ nRet = (sal_uInt16)( linePos - m_aOrderedLines.begin() );
+ break;
+ }
+ }
+
+ return nRet;
+ }
+
+ //------------------------------------------------------------------------
+ bool OBrowserListBox::impl_getBrowserLineForName( const ::rtl::OUString& _rEntryName, BrowserLinePointer& _out_rpLine ) const
+ {
+ ListBoxLines::const_iterator line = m_aLines.find( _rEntryName );
+ if ( line != m_aLines.end() )
+ _out_rpLine = line->second.pLine;
+ else
+ _out_rpLine.reset();
+ return ( NULL != _out_rpLine.get() );
+ }
+
+ //------------------------------------------------------------------------
+ void OBrowserListBox::EnablePropertyControls( const ::rtl::OUString& _rEntryName, sal_Int16 _nControls, bool _bEnable )
+ {
+ BrowserLinePointer pLine;
+ if ( impl_getBrowserLineForName( _rEntryName, pLine ) )
+ pLine->EnablePropertyControls( _nControls, _bEnable );
+ }
+
+ //------------------------------------------------------------------------
+ void OBrowserListBox::EnablePropertyLine( const ::rtl::OUString& _rEntryName, bool _bEnable )
+ {
+ BrowserLinePointer pLine;
+ if ( impl_getBrowserLineForName( _rEntryName, pLine ) )
+ pLine->EnablePropertyLine( _bEnable );
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XPropertyControl > OBrowserListBox::GetPropertyControl( const ::rtl::OUString& _rEntryName )
+ {
+ BrowserLinePointer pLine;
+ if ( impl_getBrowserLineForName( _rEntryName, pLine ) )
+ return pLine->getControl();
+ return NULL;
+ }
+
+ //------------------------------------------------------------------
+ sal_uInt16 OBrowserListBox::InsertEntry(const OLineDescriptor& _rPropertyData, sal_uInt16 _nPos)
+ {
+ // create a new line
+ BrowserLinePointer pBrowserLine( new OBrowserLine( _rPropertyData.sName, &m_aLinesPlayground ) );
+
+ ListBoxLine aNewLine( pBrowserLine, _rPropertyData.xPropertyHandler );
+ ::std::pair< ListBoxLines::iterator, bool > insertPoint =
+ m_aLines.insert( ListBoxLines::value_type( _rPropertyData.sName, aNewLine ) );
+ OSL_ENSURE( insertPoint.second, "OBrowserListBox::InsertEntry: already have another line for this name!" );
+
+ sal_uInt16 nInsertPos = _nPos;
+ if ( nInsertPos > m_aOrderedLines.size() )
+ nInsertPos = EDITOR_LIST_APPEND;
+ if ( EDITOR_LIST_APPEND == nInsertPos )
+ {
+ nInsertPos = (sal_uInt16)m_aOrderedLines.size();
+ m_aOrderedLines.push_back( insertPoint.first );
+ }
+ else
+ m_aOrderedLines.insert( m_aOrderedLines.begin() + nInsertPos, insertPoint.first );
+
+ pBrowserLine->SetTitleWidth(m_nTheNameSize);
+ if (m_bUpdate)
+ {
+ UpdateVScroll();
+ Invalidate();
+ }
+
+ // initialize the entry
+ ChangeEntry(_rPropertyData, nInsertPos);
+
+ // update the positions of possibly affected lines
+ sal_uInt16 nUpdatePos = nInsertPos;
+ while ( nUpdatePos < m_aOrderedLines.size() )
+ m_aOutOfDateLines.insert( nUpdatePos++ );
+ UpdatePosNSize( );
+
+ return nInsertPos;
+ }
+
+ //------------------------------------------------------------------
+ sal_Int32 OBrowserListBox::GetMinimumWidth()
+ {
+ return m_nTheNameSize + 2 * FRAME_OFFSET + (m_nRowHeight - 4) * 8;
+ }
+
+ //------------------------------------------------------------------
+ sal_Int32 OBrowserListBox::GetMinimumHeight()
+ {
+ // assume that we want to display 5 rows, at least
+ sal_Int32 nMinHeight = m_nRowHeight * 5;
+
+ if ( HasHelpSection() )
+ {
+ Size aHelpWindowDistance( LogicToPixel( Size( 0, LAYOUT_HELP_WINDOW_DISTANCE_APPFONT ), MAP_APPFONT ) );
+ nMinHeight += aHelpWindowDistance.Height();
+
+ nMinHeight += m_pHelpWindow->GetMinimalHeightPixel();
+ }
+
+ return nMinHeight;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::ShowEntry(sal_uInt16 _nPos)
+ {
+ if ( _nPos < m_aOrderedLines.size() )
+ {
+ sal_Int32 nThumbPos = m_aVScroll.GetThumbPos();
+
+ if (_nPos < nThumbPos)
+ MoveThumbTo(_nPos);
+ else
+ {
+ sal_Int32 nLines = CalcVisibleLines();
+ if (_nPos >= nThumbPos + nLines)
+ MoveThumbTo(_nPos - nLines + 1);
+ }
+ }
+
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::MoveThumbTo(sal_Int32 _nNewThumbPos)
+ {
+ // disable painting to prevent flicker
+ m_aLinesPlayground.EnablePaint(sal_False);
+
+ sal_Int32 nDelta = _nNewThumbPos - m_aVScroll.GetThumbPos();
+ // adjust the scrollbar
+ m_aVScroll.SetThumbPos(_nNewThumbPos);
+ sal_Int32 nThumbPos = _nNewThumbPos;
+
+ m_nYOffset = -m_aVScroll.GetThumbPos() * m_nRowHeight;
+
+ sal_Int32 nLines = CalcVisibleLines();
+ sal_uInt16 nEnd = (sal_uInt16)(nThumbPos + nLines);
+
+ m_aLinesPlayground.Scroll(0, -nDelta * m_nRowHeight, SCROLL_CHILDREN);
+
+ if (1 == nDelta)
+ {
+ // TODO: what's the sense of this two PositionLines? Why not just one call?
+ PositionLine(nEnd-1);
+ PositionLine(nEnd);
+ }
+ else if (-1 == nDelta)
+ {
+ PositionLine((sal_uInt16)nThumbPos);
+ }
+ else if (0 != nDelta)
+ {
+ UpdatePlayGround();
+ }
+
+ m_aLinesPlayground.EnablePaint(sal_True);
+ m_aLinesPlayground.Invalidate(INVALIDATE_CHILDREN);
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK(OBrowserListBox, ScrollHdl, ScrollBar*, _pScrollBar )
+ {
+ DBG_ASSERT(_pScrollBar == &m_aVScroll, "OBrowserListBox::ScrollHdl: where does this come from?");
+ (void)_pScrollBar;
+
+ // disable painting to prevent flicker
+ m_aLinesPlayground.EnablePaint(sal_False);
+
+ sal_Int32 nThumbPos = m_aVScroll.GetThumbPos();
+
+ sal_Int32 nDelta = m_aVScroll.GetDelta();
+ m_nYOffset = -nThumbPos * m_nRowHeight;
+
+ sal_uInt16 nEnd = (sal_uInt16)(nThumbPos + CalcVisibleLines());
+
+ m_aLinesPlayground.Scroll(0, -nDelta * m_nRowHeight, SCROLL_CHILDREN);
+
+ if (1 == nDelta)
+ {
+ PositionLine(nEnd-1);
+ PositionLine(nEnd);
+ }
+ else if (nDelta==-1)
+ {
+ PositionLine((sal_uInt16)nThumbPos);
+ }
+ else if (nDelta!=0 || m_aVScroll.GetType() == SCROLL_DONTKNOW)
+ {
+ UpdatePlayGround();
+ }
+
+ m_aLinesPlayground.EnablePaint(sal_True);
+ return 0;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::buttonClicked( OBrowserLine* _pLine, sal_Bool _bPrimary )
+ {
+ DBG_ASSERT( _pLine, "OBrowserListBox::buttonClicked: invalid browser line!" );
+ if ( _pLine && m_pLineListener )
+ {
+ m_pLineListener->Clicked( _pLine->GetEntryName(), _bPrimary );
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::impl_setControlAsPropertyValue( const ListBoxLine& _rLine, const Any& _rPropertyValue )
+ {
+ Reference< XPropertyControl > xControl( _rLine.pLine->getControl() );
+ try
+ {
+ if ( _rPropertyValue.getValueType().equals( _rLine.pLine->getControl()->getValueType() ) )
+ {
+ xControl->setValue( _rPropertyValue );
+ }
+ else
+ {
+ #ifdef DBG_UTIL
+ if ( !_rLine.xHandler.is() )
+ {
+ ::rtl::OString sMessage( "OBrowserListBox::impl_setControlAsPropertyValue: no handler -> no conversion (property: '" );
+ ::rtl::OUString sPropertyName( _rLine.pLine->GetEntryName() );
+ sMessage += ::rtl::OString( sPropertyName.getStr(), sPropertyName.getLength(), RTL_TEXTENCODING_ASCII_US );
+ sMessage += ::rtl::OString( "')!" );
+ DBG_ERROR( sMessage );
+ }
+ #endif
+ if ( _rLine.xHandler.is() )
+ {
+ Any aControlValue = _rLine.xHandler->convertToControlValue(
+ _rLine.pLine->GetEntryName(), _rPropertyValue, xControl->getValueType() );
+ xControl->setValue( aControlValue );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------
+ Any OBrowserListBox::impl_getControlAsPropertyValue( const ListBoxLine& _rLine ) const
+ {
+ Reference< XPropertyControl > xControl( _rLine.pLine->getControl() );
+ Any aPropertyValue;
+ try
+ {
+ #ifdef DBG_UTIL
+ if ( !_rLine.xHandler.is() )
+ {
+ ::rtl::OString sMessage( "OBrowserListBox::impl_getControlAsPropertyValue: no handler -> no conversion (property: '" );
+ ::rtl::OUString sPropertyName( _rLine.pLine->GetEntryName() );
+ sMessage += ::rtl::OString( sPropertyName.getStr(), sPropertyName.getLength(), RTL_TEXTENCODING_ASCII_US );
+ sMessage += ::rtl::OString( "')!" );
+ DBG_ERROR( sMessage );
+ }
+ #endif
+ if ( _rLine.xHandler.is() )
+ aPropertyValue = _rLine.xHandler->convertToPropertyValue( _rLine.pLine->GetEntryName(), xControl->getValue() );
+ else
+ aPropertyValue = xControl->getValue();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return aPropertyValue;
+ }
+
+ //------------------------------------------------------------------
+ sal_uInt16 OBrowserListBox::impl_getControlPos( const Reference< XPropertyControl >& _rxControl ) const
+ {
+ for ( OrderedListBoxLines::const_iterator search = m_aOrderedLines.begin();
+ search != m_aOrderedLines.end();
+ ++search
+ )
+ if ( (*search)->second.pLine->getControl().get() == _rxControl.get() )
+ return sal_uInt16( search - m_aOrderedLines.begin() );
+ DBG_ERROR( "OBrowserListBox::impl_getControlPos: invalid control - not part of any of our lines!" );
+ return (sal_uInt16)-1;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OBrowserListBox::focusGained( const Reference< XPropertyControl >& _rxControl ) throw (RuntimeException)
+ {
+ DBG_TESTSOLARMUTEX();
+
+ DBG_ASSERT( _rxControl.is(), "OBrowserListBox::focusGained: invalid event source!" );
+ if ( !_rxControl.is() )
+ return;
+
+ if ( m_pControlObserver )
+ m_pControlObserver->focusGained( _rxControl );
+
+ m_xActiveControl = _rxControl;
+ ShowEntry( impl_getControlPos( m_xActiveControl ) );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OBrowserListBox::valueChanged( const Reference< XPropertyControl >& _rxControl ) throw (RuntimeException)
+ {
+ DBG_TESTSOLARMUTEX();
+
+ DBG_ASSERT( _rxControl.is(), "OBrowserListBox::valueChanged: invalid event source!" );
+ if ( !_rxControl.is() )
+ return;
+
+ if ( m_pControlObserver )
+ m_pControlObserver->valueChanged( _rxControl );
+
+ if ( m_pLineListener )
+ {
+ const ListBoxLine& rLine = impl_getControlLine( _rxControl );
+ m_pLineListener->Commit(
+ rLine.pLine->GetEntryName(),
+ impl_getControlAsPropertyValue( rLine )
+ );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OBrowserListBox::activateNextControl( const Reference< XPropertyControl >& _rxCurrentControl ) throw (RuntimeException)
+ {
+ DBG_TESTSOLARMUTEX();
+
+ sal_uInt16 nLine = impl_getControlPos( _rxCurrentControl );
+
+ // cycle forwards, 'til we've the next control which can grab the focus
+ ++nLine;
+ while ( (size_t)nLine < m_aOrderedLines.size() )
+ {
+ if ( m_aOrderedLines[nLine]->second.pLine->GrabFocus() )
+ break;
+ ++nLine;
+ }
+
+ if ( ( (size_t)nLine >= m_aOrderedLines.size() )
+ && ( m_aOrderedLines.size() > 0 )
+ )
+ // wrap around
+ m_aOrderedLines[0]->second.pLine->GrabFocus();
+ }
+
+ //------------------------------------------------------------------
+ namespace
+ {
+ //..............................................................
+ void lcl_implDisposeControl_nothrow( const Reference< XPropertyControl >& _rxControl )
+ {
+ if ( !_rxControl.is() )
+ return;
+ try
+ {
+ _rxControl->setControlContext( NULL );
+ Reference< XComponent > xControlComponent( _rxControl, UNO_QUERY );
+ if ( xControlComponent.is() )
+ xControlComponent->dispose();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::Clear()
+ {
+ for ( ListBoxLines::iterator loop = m_aLines.begin();
+ loop != m_aLines.end();
+ ++loop
+ )
+ {
+ // hide the line
+ loop->second.pLine->Hide();
+ // reset the listener
+ lcl_implDisposeControl_nothrow( loop->second.pLine->getControl() );
+ }
+
+ clearContainer( m_aLines );
+ clearContainer( m_aOrderedLines );
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool OBrowserListBox::RemoveEntry( const ::rtl::OUString& _rName )
+ {
+ sal_uInt16 nPos = GetPropertyPos( _rName );
+ if ( nPos == LISTBOX_ENTRY_NOTFOUND )
+ return sal_False;
+
+ OrderedListBoxLines::iterator orderedPos = m_aOrderedLines.begin() + nPos;
+ BrowserLinePointer pLine = (*orderedPos)->second.pLine;
+ pLine->Hide();
+ lcl_implDisposeControl_nothrow( pLine->getControl() );
+
+ m_aLines.erase( *orderedPos );
+ m_aOrderedLines.erase( orderedPos );
+ m_aOutOfDateLines.erase( (sal_uInt16)m_aOrderedLines.size() );
+ // this index *may* have been out of date, which is obsoleted now by m_aOrderedLines shrinking
+
+ // update the positions of possibly affected lines
+ while ( nPos < m_aOrderedLines.size() )
+ m_aOutOfDateLines.insert( nPos++ );
+ UpdatePosNSize( );
+
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::ChangeEntry( const OLineDescriptor& _rPropertyData, sal_uInt16 nPos )
+ {
+ OSL_PRECOND( _rPropertyData.Control.is(), "OBrowserListBox::ChangeEntry: invalid control!" );
+ if ( !_rPropertyData.Control.is() )
+ return;
+
+ if ( nPos == EDITOR_LIST_REPLACE_EXISTING )
+ nPos = GetPropertyPos( _rPropertyData.sName );
+
+ if ( nPos < m_aOrderedLines.size() )
+ {
+ Window* pRefWindow = NULL;
+ if ( nPos > 0 )
+ pRefWindow = m_aOrderedLines[nPos-1]->second.pLine->GetRefWindow();
+
+ // the current line and control
+ ListBoxLine& rLine = m_aOrderedLines[nPos]->second;
+
+ // the old control and some data about it
+ Reference< XPropertyControl > xControl = rLine.pLine->getControl();
+ Window* pControlWindow = rLine.pLine->getControlWindow();
+ Point aControlPos;
+ if ( pControlWindow )
+ aControlPos = pControlWindow->GetPosPixel();
+
+ // clean up the old control
+ lcl_implDisposeControl_nothrow( xControl );
+
+ // set the new control at the line
+ rLine.pLine->setControl( _rPropertyData.Control );
+ xControl = rLine.pLine->getControl();
+
+ if ( xControl.is() )
+ xControl->setControlContext( m_pControlContextImpl.get() );
+
+ // the initial property value
+ if ( _rPropertyData.bUnknownValue )
+ xControl->setValue( Any() );
+ else
+ impl_setControlAsPropertyValue( rLine, _rPropertyData.aValue );
+
+ rLine.pLine->SetTitle(_rPropertyData.DisplayName);
+ rLine.xHandler = _rPropertyData.xPropertyHandler;
+
+ sal_uInt16 nTextWidth = (sal_uInt16)m_aLinesPlayground.GetTextWidth(_rPropertyData.DisplayName);
+ if (m_nTheNameSize< nTextWidth)
+ m_nTheNameSize = nTextWidth;
+
+ if ( _rPropertyData.HasPrimaryButton )
+ {
+ if ( _rPropertyData.PrimaryButtonImageURL.getLength() )
+ rLine.pLine->ShowBrowseButton( _rPropertyData.PrimaryButtonImageURL, true );
+ else if ( _rPropertyData.PrimaryButtonImage.is() )
+ rLine.pLine->ShowBrowseButton( Image( _rPropertyData.PrimaryButtonImage ), true );
+ else
+ rLine.pLine->ShowBrowseButton( true );
+
+ if ( _rPropertyData.HasSecondaryButton )
+ {
+ if ( _rPropertyData.SecondaryButtonImageURL.getLength() )
+ rLine.pLine->ShowBrowseButton( _rPropertyData.SecondaryButtonImageURL, false );
+ else if ( _rPropertyData.SecondaryButtonImage.is() )
+ rLine.pLine->ShowBrowseButton( Image( _rPropertyData.SecondaryButtonImage ), false );
+ else
+ rLine.pLine->ShowBrowseButton( false );
+ }
+ else
+ rLine.pLine->HideBrowseButton( false );
+
+ rLine.pLine->SetClickListener( this );
+ }
+ else
+ {
+ rLine.pLine->HideBrowseButton( true );
+ rLine.pLine->HideBrowseButton( false );
+ }
+
+ DBG_ASSERT( ( _rPropertyData.IndentLevel == 0 ) || ( _rPropertyData.IndentLevel == 1 ),
+ "OBrowserListBox::ChangeEntry: unsupported indent level!" );
+ rLine.pLine->IndentTitle( _rPropertyData.IndentLevel > 0 );
+
+ if ( nPos > 0 )
+ rLine.pLine->SetTabOrder( pRefWindow, WINDOW_ZORDER_BEHIND );
+ else
+ rLine.pLine->SetTabOrder( pRefWindow, WINDOW_ZORDER_FIRST );
+
+ m_aOutOfDateLines.insert( nPos );
+ rLine.pLine->SetComponentHelpIds(
+ HelpIdUrl::getHelpId( _rPropertyData.HelpURL ),
+ rtl::OUStringToOString( _rPropertyData.PrimaryButtonId, RTL_TEXTENCODING_UTF8 ),
+ rtl::OUStringToOString( _rPropertyData.SecondaryButtonId, RTL_TEXTENCODING_UTF8 )
+ );
+
+ if ( _rPropertyData.bReadOnly )
+ {
+ rLine.pLine->SetReadOnly( true );
+
+ // user controls (i.e. the ones not provided by the usual
+ // XPropertyControlFactory) have no chance to know that they should be read-only,
+ // since XPropertyHandler::describePropertyLine does not transport this
+ // information.
+ // So, we manually switch this to read-only.
+ if ( xControl.is() && ( xControl->getControlType() == PropertyControlType::Unknown ) )
+ {
+ Edit* pControlWindowAsEdit = dynamic_cast< Edit* >( rLine.pLine->getControlWindow() );
+ if ( pControlWindowAsEdit )
+ pControlWindowAsEdit->SetReadOnly( sal_True );
+ else
+ pControlWindowAsEdit->Enable( sal_False );
+ }
+ }
+ }
+ }
+
+ //------------------------------------------------------------------
+ long OBrowserListBox::PreNotify( NotifyEvent& _rNEvt )
+ {
+ switch ( _rNEvt.GetType() )
+ {
+ case EVENT_KEYINPUT:
+ {
+ const KeyEvent* pKeyEvent = _rNEvt.GetKeyEvent();
+ if ( ( pKeyEvent->GetKeyCode().GetModifier() != 0 )
+ || ( ( pKeyEvent->GetKeyCode().GetCode() != KEY_PAGEUP )
+ && ( pKeyEvent->GetKeyCode().GetCode() != KEY_PAGEDOWN )
+ )
+ )
+ break;
+
+ long nScrollOffset = 0;
+ if ( m_aVScroll.IsVisible() )
+ {
+ if ( pKeyEvent->GetKeyCode().GetCode() == KEY_PAGEUP )
+ nScrollOffset = -m_aVScroll.GetPageSize();
+ else if ( pKeyEvent->GetKeyCode().GetCode() == KEY_PAGEDOWN )
+ nScrollOffset = m_aVScroll.GetPageSize();
+ }
+
+ if ( nScrollOffset )
+ {
+ long nNewThumbPos = m_aVScroll.GetThumbPos() + nScrollOffset;
+ nNewThumbPos = ::std::max( nNewThumbPos, m_aVScroll.GetRangeMin() );
+ nNewThumbPos = ::std::min( nNewThumbPos, m_aVScroll.GetRangeMax() );
+ m_aVScroll.DoScroll( nNewThumbPos );
+ nNewThumbPos = m_aVScroll.GetThumbPos();
+
+ sal_uInt16 nFocusControlPos = 0;
+ sal_uInt16 nActiveControlPos = impl_getControlPos( m_xActiveControl );
+ if ( nActiveControlPos < nNewThumbPos )
+ nFocusControlPos = (sal_uInt16)nNewThumbPos;
+ else if ( nActiveControlPos >= nNewThumbPos + CalcVisibleLines() )
+ nFocusControlPos = (sal_uInt16)nNewThumbPos + CalcVisibleLines() - 1;
+ if ( nFocusControlPos )
+ {
+ if ( nFocusControlPos < m_aOrderedLines.size() )
+ {
+ m_aOrderedLines[ nFocusControlPos ]->second.pLine->GrabFocus();
+ }
+ else
+ OSL_ENSURE( false, "OBrowserListBox::PreNotify: internal error, invalid focus control position!" );
+ }
+ }
+
+ return 1L;
+ // handled this. In particular, we also consume PageUp/Down events if we do not use them for scrolling,
+ // otherwise they would be used to scroll the document view, which does not sound like it is desired by
+ // the user.
+ }
+ }
+ return Control::PreNotify( _rNEvt );
+ }
+
+ //------------------------------------------------------------------
+ long OBrowserListBox::Notify( NotifyEvent& _rNEvt )
+ {
+ switch ( _rNEvt.GetType() )
+ {
+ case EVENT_COMMAND:
+ {
+ const CommandEvent* pCommand = _rNEvt.GetCommandEvent();
+ if ( ( COMMAND_WHEEL == pCommand->GetCommand() )
+ || ( COMMAND_STARTAUTOSCROLL == pCommand->GetCommand() )
+ || ( COMMAND_AUTOSCROLL == pCommand->GetCommand() )
+ )
+ {
+ // interested in scroll events if we have a scrollbar
+ if ( m_aVScroll.IsVisible() )
+ {
+ HandleScrollCommand( *pCommand, NULL, &m_aVScroll );
+ }
+ }
+ }
+ break;
+ }
+
+ return Control::Notify( _rNEvt );
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+
diff --git a/extensions/source/propctrlr/browserlistbox.hxx b/extensions/source/propctrlr/browserlistbox.hxx
new file mode 100644
index 000000000000..edd9d9bd40eb
--- /dev/null
+++ b/extensions/source/propctrlr/browserlistbox.hxx
@@ -0,0 +1,250 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_BROWSERLISTBOX_HXX_
+#define _EXTENSIONS_PROPCTRLR_BROWSERLISTBOX_HXX_
+
+#include "browserline.hxx"
+#ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
+#include "modulepcr.hxx"
+#endif
+#include "pcrcommon.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/XPropertyControl.hpp>
+#include <com/sun/star/inspection/XPropertyHandler.hpp>
+/** === end UNO includes === **/
+#include <vcl/scrbar.hxx>
+#include <vcl/lstbox.hxx>
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#include <tools/link.hxx>
+#include <rtl/ref.hxx>
+
+#include <set>
+#include <vector>
+#include <hash_map>
+#include <boost/shared_ptr.hpp>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ class IPropertyLineListener;
+ class IPropertyControlObserver;
+ struct OLineDescriptor;
+ class InspectorHelpWindow;
+ class PropertyControlContext_Impl;
+
+ //========================================================================
+ //= administrative structures for OBrowserListBox
+ //========================================================================
+ typedef ::boost::shared_ptr< OBrowserLine > BrowserLinePointer;
+ struct ListBoxLine
+ {
+ BrowserLinePointer pLine;
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler >
+ xHandler;
+
+ ListBoxLine() { }
+ ListBoxLine( BrowserLinePointer _pLine, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler >& _rxHandler )
+ :pLine( _pLine )
+ ,xHandler( _rxHandler )
+ {
+ }
+ };
+ typedef ::std::hash_map< ::rtl::OUString, ListBoxLine, ::rtl::OUStringHash > ListBoxLines;
+ typedef ::std::vector< ListBoxLines::iterator > OrderedListBoxLines;
+
+ //========================================================================
+ //= IControlContext
+ //========================================================================
+ /** non-UNO version of XPropertyControlContext
+ */
+ class SAL_NO_VTABLE IControlContext
+ {
+ public:
+ virtual void SAL_CALL focusGained( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& Control ) throw (::com::sun::star::uno::RuntimeException) = 0;
+ virtual void SAL_CALL valueChanged( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& Control ) throw (::com::sun::star::uno::RuntimeException) = 0;
+ virtual void SAL_CALL activateNextControl( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& CurrentControl ) throw (::com::sun::star::uno::RuntimeException) = 0;
+ };
+
+ //========================================================================
+ //= OBrowserListBox
+ //========================================================================
+ class OBrowserListBox :public Control
+ ,public IButtonClickListener
+ ,public IControlContext
+ ,public PcrClient
+ {
+ protected:
+ Window m_aLinesPlayground;
+ ScrollBar m_aVScroll;
+ ::std::auto_ptr< InspectorHelpWindow >
+ m_pHelpWindow;
+ ListBoxLines m_aLines;
+ OrderedListBoxLines m_aOrderedLines;
+ IPropertyLineListener* m_pLineListener;
+ IPropertyControlObserver* m_pControlObserver;
+ long m_nYOffset;
+ long m_nCurrentPreferredHelpHeight;
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
+ m_xActiveControl;
+ sal_uInt16 m_nTheNameSize;
+ sal_uInt16 m_nRowHeight;
+ ::std::set< sal_uInt16 > m_aOutOfDateLines;
+ sal_Bool m_bIsActive : 1;
+ sal_Bool m_bUpdate : 1;
+ ::rtl::Reference< PropertyControlContext_Impl >
+ m_pControlContextImpl;
+
+ protected:
+ void PositionLine( sal_uInt16 _nIndex );
+ void UpdatePosNSize();
+ void UpdatePlayGround();
+ void UpdateVScroll();
+ void ShowEntry(sal_uInt16 nPos);
+ void MoveThumbTo(sal_Int32 nNewThumbPos);
+ void Resize();
+
+ public:
+ OBrowserListBox( Window* pParent, WinBits nWinStyle = WB_DIALOGCONTROL );
+
+ ~OBrowserListBox();
+
+ void UpdateAll();
+
+ void ActivateListBox( sal_Bool _bActive );
+
+ sal_uInt16 CalcVisibleLines();
+ void EnableUpdate();
+ void DisableUpdate();
+ long Notify( NotifyEvent& _rNEvt );
+ long PreNotify( NotifyEvent& _rNEvt );
+
+ void SetListener( IPropertyLineListener* _pListener );
+ void SetObserver( IPropertyControlObserver* _pObserver );
+
+ void EnableHelpSection( bool _bEnable );
+ bool HasHelpSection() const;
+ void SetHelpText( const ::rtl::OUString& _rHelpText );
+ void SetHelpLineLimites( sal_Int32 _nMinLines, sal_Int32 _nMaxLines );
+
+ void Clear();
+
+ sal_uInt16 InsertEntry( const OLineDescriptor&, sal_uInt16 nPos = EDITOR_LIST_APPEND );
+ sal_Bool RemoveEntry( const ::rtl::OUString& _rName );
+ void ChangeEntry( const OLineDescriptor&, sal_uInt16 nPos );
+
+ void SetPropertyValue( const ::rtl::OUString& rEntryName, const ::com::sun::star::uno::Any& rValue, bool _bUnknownValue );
+ sal_uInt16 GetPropertyPos( const ::rtl::OUString& rEntryName ) const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
+ GetPropertyControl( const ::rtl::OUString& rEntryName );
+ void EnablePropertyControls( const ::rtl::OUString& _rEntryName, sal_Int16 _nControls, bool _bEnable );
+ void EnablePropertyLine( const ::rtl::OUString& _rEntryName, bool _bEnable );
+
+ sal_Int32 GetMinimumWidth();
+ sal_Int32 GetMinimumHeight();
+
+
+ sal_Bool IsModified( ) const;
+ void CommitModified( );
+
+ protected:
+ // IControlContext
+ virtual void SAL_CALL focusGained( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& Control ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL valueChanged( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& Control ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL activateNextControl( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& CurrentControl ) throw (::com::sun::star::uno::RuntimeException);
+
+ // IButtonClickListener
+ void buttonClicked( OBrowserLine* _pLine, sal_Bool _bPrimary );
+
+ using Window::SetHelpText;
+ private:
+ DECL_LINK( ScrollHdl, ScrollBar* );
+
+ /** retrieves the index of a given control in our line list
+ @param _rxControl
+ The control to lookup. Must denote a control of one of the lines in ->m_aLines
+ */
+ sal_uInt16 impl_getControlPos( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& _rxControl ) const;
+
+ /** retrieves (a reference to) the ->ListBoxLine for a given control
+ @param _rxControl
+ The control to lookup. Must denote a control of one of the lines in ->m_aLines
+ */
+ inline const ListBoxLine&
+ impl_getControlLine( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& _rxControl ) const
+ {
+ return m_aOrderedLines[ impl_getControlPos( _rxControl ) ]->second;
+ }
+
+ /** sets the given property value at the given control, after converting it as necessary
+ @param _rLine
+ The line whose at which the value is to be set.
+ @param _rPropertyValue
+ the property value to set. If it's not compatible with the control value,
+ it will be converted, using <member>XPropertyHandler::convertToControlValue</member>
+ */
+ void impl_setControlAsPropertyValue( const ListBoxLine& _rLine, const ::com::sun::star::uno::Any& _rPropertyValue );
+
+ /** retrieves the value for the given control, as a property value, after converting it as necessary
+ @param _rLine
+ The line whose at which the value is to be set.
+ */
+ ::com::sun::star::uno::Any
+ impl_getControlAsPropertyValue( const ListBoxLine& _rLine ) const;
+
+ /** retrieves the ->BrowserLinePointer for a given entry name
+ @param _rEntryName
+ the name whose line is to be looked up
+ @param _out_rpLine
+ contains, upon return, the found browser line, if any
+ @return
+ <TRUE/> if and only if a non-<NULL/> line for the given entry name could be
+ found.
+ */
+ bool impl_getBrowserLineForName( const ::rtl::OUString& _rEntryName, BrowserLinePointer& _out_rpLine ) const;
+
+ /** returns the preferred height (in pixels) of the help section, or 0 if we
+ currently don't have a help section
+ */
+ long impl_getPrefererredHelpHeight();
+
+ private:
+ using Window::Activate;
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_BROWSERLISTBOX_HXX_
+
+
diff --git a/extensions/source/propctrlr/browserpage.cxx b/extensions/source/propctrlr/browserpage.cxx
new file mode 100644
index 000000000000..131a3587a038
--- /dev/null
+++ b/extensions/source/propctrlr/browserpage.cxx
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "browserpage.hxx"
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ #define LAYOUT_BORDER_LEFT 3
+ #define LAYOUT_BORDER_TOP 3
+ #define LAYOUT_BORDER_RIGHT 3
+ #define LAYOUT_BORDER_BOTTOM 3
+
+ //==================================================================
+ // class OBrowserPage
+ //==================================================================
+ //------------------------------------------------------------------
+ OBrowserPage::OBrowserPage(Window* pParent,WinBits nWinStyle)
+ :TabPage(pParent,nWinStyle)
+ ,m_aListBox(this)
+ {
+ m_aListBox.SetBackground(GetBackground());
+ m_aListBox.SetPaintTransparent( sal_True );
+ m_aListBox.Show();
+ }
+
+ //------------------------------------------------------------------
+ OBrowserPage::~OBrowserPage()
+ {
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserPage::Resize()
+ {
+ Size aSize( GetOutputSizePixel() );
+ aSize.Width() -= LAYOUT_BORDER_LEFT + LAYOUT_BORDER_RIGHT;
+ aSize.Height() -= LAYOUT_BORDER_TOP + LAYOUT_BORDER_BOTTOM;
+ m_aListBox.SetPosSizePixel( Point( LAYOUT_BORDER_LEFT, LAYOUT_BORDER_TOP ), aSize );
+ }
+
+ //------------------------------------------------------------------
+ OBrowserListBox& OBrowserPage::getListBox()
+ {
+ return m_aListBox;
+ }
+
+ //------------------------------------------------------------------
+ const OBrowserListBox& OBrowserPage::getListBox() const
+ {
+ return m_aListBox;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserPage::StateChanged(StateChangedType nType)
+ {
+ Window::StateChanged( nType);
+ if (STATE_CHANGE_VISIBLE == nType)
+ m_aListBox.ActivateListBox(IsVisible());
+ }
+
+ //------------------------------------------------------------------
+ sal_Int32 OBrowserPage::getMinimumWidth()
+ {
+ return m_aListBox.GetMinimumWidth() + LAYOUT_BORDER_LEFT + LAYOUT_BORDER_RIGHT;
+ }
+
+ //------------------------------------------------------------------
+ sal_Int32 OBrowserPage::getMinimumHeight()
+ {
+ return m_aListBox.GetMinimumHeight() + LAYOUT_BORDER_TOP + LAYOUT_BORDER_BOTTOM;
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+
diff --git a/extensions/source/propctrlr/browserpage.hxx b/extensions/source/propctrlr/browserpage.hxx
new file mode 100644
index 000000000000..e8c2ee81692e
--- /dev/null
+++ b/extensions/source/propctrlr/browserpage.hxx
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_BROWSERPAGE_HXX_
+#define _EXTENSIONS_PROPCTRLR_BROWSERPAGE_HXX_
+
+#include <vcl/tabpage.hxx>
+#include "browserlistbox.hxx"
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ //========================================================================
+ //= OBrowserPage
+ //========================================================================
+ class OBrowserPage : public TabPage
+ {
+ private:
+ OBrowserListBox m_aListBox;
+
+ protected:
+ virtual void Resize();
+ virtual void StateChanged(StateChangedType nType);
+
+ public:
+ OBrowserPage(Window* pParent, WinBits nWinStyle = 0);
+ ~OBrowserPage();
+
+ sal_Int32 getMinimumWidth();
+ sal_Int32 getMinimumHeight();
+
+ OBrowserListBox& getListBox();
+ const OBrowserListBox& getListBox() const;
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_BROWSERPAGE_HXX_
+
+
diff --git a/extensions/source/propctrlr/browserview.cxx b/extensions/source/propctrlr/browserview.cxx
new file mode 100644
index 000000000000..a023c5ef6b01
--- /dev/null
+++ b/extensions/source/propctrlr/browserview.cxx
@@ -0,0 +1,144 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "browserview.hxx"
+#include "propertyeditor.hxx"
+#include "propctrlr.hrc"
+#include <tools/debug.hxx>
+#include <memory>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+
+
+ //========================================================================
+ //= class OPropertyBrowserView
+ //========================================================================
+ DBG_NAME(OPropertyBrowserView)
+ //------------------------------------------------------------------------
+ OPropertyBrowserView::OPropertyBrowserView( const Reference< XMultiServiceFactory >& _rxORB,
+ Window* _pParent, WinBits nBits)
+ :Window(_pParent, nBits | WB_3DLOOK)
+ ,m_xORB(_rxORB)
+ ,m_nActivePage(0)
+ {
+ DBG_CTOR(OPropertyBrowserView,NULL);
+
+ m_pPropBox = new OPropertyEditor( this );
+ m_pPropBox->SetHelpId(HID_FM_PROPDLG_TABCTR);
+ m_pPropBox->setPageActivationHandler(LINK(this, OPropertyBrowserView, OnPageActivation));
+
+ m_pPropBox->Show();
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK(OPropertyBrowserView, OnPageActivation, void*, EMPTYARG)
+ {
+ m_nActivePage = m_pPropBox->GetCurPage();
+ if (m_aPageActivationHandler.IsSet())
+ m_aPageActivationHandler.Call(NULL);
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------
+ OPropertyBrowserView::~OPropertyBrowserView()
+ {
+ if(m_pPropBox)
+ {
+ sal_uInt16 nTmpPage = m_pPropBox->GetCurPage();
+ if (nTmpPage)
+ m_nActivePage = nTmpPage;
+ ::std::auto_ptr<Window> aTemp(m_pPropBox);
+ m_pPropBox = NULL;
+ }
+ m_xORB = NULL;
+
+ DBG_DTOR(OPropertyBrowserView, NULL);
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserView::activatePage(sal_uInt16 _nPage)
+ {
+ m_nActivePage = _nPage;
+ getPropertyBox().SetPage(m_nActivePage);
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserView::GetFocus()
+ {
+ if (m_pPropBox)
+ m_pPropBox->GrabFocus();
+ else
+ Window::GetFocus();
+ }
+
+ //------------------------------------------------------------------------
+ long OPropertyBrowserView::Notify( NotifyEvent& _rNEvt )
+ {
+ if ( EVENT_KEYINPUT == _rNEvt.GetType() )
+ {
+ sal_uInt16 nKey = _rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
+
+ if ( ( KEY_DELETE == nKey ) || ( KEY_BACKSPACE == nKey ) )
+ // silence this, we don't want to propagate this outside the property
+ // browser, as it will probably do harm there
+ // #i63285# / 2006-12-06 / frank.schoenheit@sun.com
+ return 1;
+ }
+ return Window::Notify( _rNEvt );
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserView::Resize()
+ {
+ Size aSize = GetOutputSizePixel();
+ m_pPropBox->SetSizePixel(aSize);
+ }
+
+ // #95343# ---------------------------------------------------------------
+ ::com::sun::star::awt::Size OPropertyBrowserView::getMinimumSize()
+ {
+ Size aSize = GetOutputSizePixel();
+ if( m_pPropBox )
+ {
+ aSize.setHeight( m_pPropBox->getMinimumHeight() );
+ aSize.setWidth( m_pPropBox->getMinimumWidth() );
+ }
+ return ::com::sun::star::awt::Size( aSize.Width(), aSize.Height() );
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
diff --git a/extensions/source/propctrlr/browserview.hxx b/extensions/source/propctrlr/browserview.hxx
new file mode 100644
index 000000000000..8b0ecda6a28f
--- /dev/null
+++ b/extensions/source/propctrlr/browserview.hxx
@@ -0,0 +1,89 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_BROWSERVIEW_HXX_
+#define _EXTENSIONS_PROPCTRLR_BROWSERVIEW_HXX_
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <vcl/window.hxx>
+#include <tools/resid.hxx>
+// #95343# --------------------
+#include <com/sun/star/awt/Size.hpp>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ class OPropertyEditor;
+
+ //========================================================================
+ //=
+ //========================================================================
+ class OPropertyBrowserView : public Window
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB;
+
+ OPropertyEditor* m_pPropBox;
+ sal_uInt16 m_nActivePage;
+ Link m_aPageActivationHandler;
+
+ protected:
+ virtual void Resize();
+ virtual void GetFocus();
+ virtual long Notify( NotifyEvent& _rNEvt );
+
+ public:
+ OPropertyBrowserView(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB,
+ Window* pParent, WinBits nBits = 0);
+
+ virtual ~OPropertyBrowserView();
+
+ OPropertyEditor& getPropertyBox() { return *m_pPropBox; }
+
+ // page handling
+ sal_uInt16 getActivaPage() const { return m_nActivePage; }
+ void activatePage(sal_uInt16 _nPage);
+
+ void setPageActivationHandler(const Link& _rHdl) { m_aPageActivationHandler = _rHdl; }
+ Link getPageActivationHandler() const { return m_aPageActivationHandler; }
+
+ // #95343# ------------------
+ ::com::sun::star::awt::Size getMinimumSize();
+
+ protected:
+ DECL_LINK(OnPageActivation, void*);
+ };
+
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_BROWSERVIEW_HXX_
+
diff --git a/extensions/source/propctrlr/buttonnavigationhandler.cxx b/extensions/source/propctrlr/buttonnavigationhandler.cxx
new file mode 100644
index 000000000000..7dfcecc76f44
--- /dev/null
+++ b/extensions/source/propctrlr/buttonnavigationhandler.cxx
@@ -0,0 +1,295 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "buttonnavigationhandler.hxx"
+#include "formstrings.hxx"
+#include "formmetadata.hxx"
+#include "pushbuttonnavigation.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+#include <tools/debug.hxx>
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_ButtonNavigationHandler()
+{
+ ::pcr::ButtonNavigationHandler::registerImplementation();
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::script;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::inspection;
+
+ //====================================================================
+ //= ButtonNavigationHandler
+ //====================================================================
+ DBG_NAME( ButtonNavigationHandler )
+ //--------------------------------------------------------------------
+ ButtonNavigationHandler::ButtonNavigationHandler( const Reference< XComponentContext >& _rxContext )
+ :ButtonNavigationHandler_Base( _rxContext )
+ {
+ DBG_CTOR( ButtonNavigationHandler, NULL );
+
+ m_aContext.createComponent(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.FormComponentPropertyHandler" ) ),
+ m_xSlaveHandler );
+ if ( !m_xSlaveHandler.is() )
+ throw RuntimeException();
+ }
+
+ //--------------------------------------------------------------------
+ ButtonNavigationHandler::~ButtonNavigationHandler( )
+ {
+ DBG_DTOR( ButtonNavigationHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ButtonNavigationHandler::getImplementationName_static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.ButtonNavigationHandler" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL ButtonNavigationHandler::getSupportedServiceNames_static( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported( 1 );
+ aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.ButtonNavigationHandler" ) );
+ return aSupported;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ButtonNavigationHandler::inspect( const Reference< XInterface >& _rxIntrospectee ) throw (RuntimeException, NullPointerException)
+ {
+ ButtonNavigationHandler_Base::inspect( _rxIntrospectee );
+ m_xSlaveHandler->inspect( _rxIntrospectee );
+ }
+
+ //--------------------------------------------------------------------
+ PropertyState SAL_CALL ButtonNavigationHandler::getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+ PropertyState eState = PropertyState_DIRECT_VALUE;
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_BUTTONTYPE:
+ {
+ PushButtonNavigation aHelper( m_xComponent );
+ eState = aHelper.getCurrentButtonTypeState();
+ }
+ break;
+ case PROPERTY_ID_TARGET_URL:
+ {
+ PushButtonNavigation aHelper( m_xComponent );
+ eState = aHelper.getCurrentTargetURLState();
+ }
+ break;
+
+ default:
+ DBG_ERROR( "ButtonNavigationHandler::getPropertyState: cannot handle this property!" );
+ break;
+ }
+
+ return eState;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL ButtonNavigationHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ Any aReturn;
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_BUTTONTYPE:
+ {
+ PushButtonNavigation aHelper( m_xComponent );
+ aReturn = aHelper.getCurrentButtonType();
+ }
+ break;
+
+ case PROPERTY_ID_TARGET_URL:
+ {
+ PushButtonNavigation aHelper( m_xComponent );
+ aReturn = aHelper.getCurrentTargetURL();
+ }
+ break;
+
+ default:
+ DBG_ERROR( "ButtonNavigationHandler::getPropertyValue: cannot handle this property!" );
+ break;
+ }
+
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ButtonNavigationHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_BUTTONTYPE:
+ {
+ PushButtonNavigation aHelper( m_xComponent );
+ aHelper.setCurrentButtonType( _rValue );
+ }
+ break;
+
+ case PROPERTY_ID_TARGET_URL:
+ {
+ PushButtonNavigation aHelper( m_xComponent );
+ aHelper.setCurrentTargetURL( _rValue );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( sal_False, "ButtonNavigationHandler::setPropertyValue: cannot handle this id!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool ButtonNavigationHandler::isNavigationCapableButton( const Reference< XPropertySet >& _rxComponent )
+ {
+ Reference< XPropertySetInfo > xPSI;
+ if ( _rxComponent.is() )
+ xPSI = _rxComponent->getPropertySetInfo();
+
+ return xPSI.is()
+ && xPSI->hasPropertyByName( PROPERTY_TARGET_URL )
+ && xPSI->hasPropertyByName( PROPERTY_BUTTONTYPE );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Property > SAL_CALL ButtonNavigationHandler::doDescribeSupportedProperties() const
+ {
+ ::std::vector< Property > aProperties;
+
+ if ( isNavigationCapableButton( m_xComponent ) )
+ {
+ addStringPropertyDescription( aProperties, PROPERTY_TARGET_URL );
+ implAddPropertyDescription( aProperties, PROPERTY_BUTTONTYPE, ::getCppuType( static_cast< sal_Int32* >( NULL ) ) );
+ }
+
+ if ( aProperties.empty() )
+ return Sequence< Property >();
+ return Sequence< Property >( &(*aProperties.begin()), aProperties.size() );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL ButtonNavigationHandler::getActuatingProperties( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aActuating( 2 );
+ aActuating[0] = PROPERTY_BUTTONTYPE;
+ aActuating[1] = PROPERTY_TARGET_URL;
+ return aActuating;
+ }
+
+ //--------------------------------------------------------------------
+ InteractiveSelectionResult SAL_CALL ButtonNavigationHandler::onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, Any& _rData, const Reference< XObjectInspectorUI >& _rxInspectorUI ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ InteractiveSelectionResult eReturn( InteractiveSelectionResult_Cancelled );
+
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_TARGET_URL:
+ eReturn = m_xSlaveHandler->onInteractivePropertySelection( _rPropertyName, _bPrimary, _rData, _rxInspectorUI );
+ break;
+ default:
+ eReturn = ButtonNavigationHandler_Base::onInteractivePropertySelection( _rPropertyName, _bPrimary, _rData, _rxInspectorUI );
+ break;
+ }
+
+ return eReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ButtonNavigationHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& /*_rNewValue*/, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool /*_bFirstTimeInit*/ ) throw (NullPointerException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) );
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_BUTTONTYPE:
+ {
+ PushButtonNavigation aHelper( m_xComponent );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_TARGET_URL, aHelper.currentButtonTypeIsOpenURL() );
+ }
+ break;
+
+ case PROPERTY_ID_TARGET_URL:
+ {
+ PushButtonNavigation aHelper( m_xComponent );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_TARGET_FRAME, aHelper.hasNonEmptyCurrentTargetURL() );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( sal_False, "ButtonNavigationHandler::actuatingPropertyChanged: cannot handle this id!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ LineDescriptor SAL_CALL ButtonNavigationHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName, const Reference< XPropertyControlFactory >& _rxControlFactory ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ LineDescriptor aReturn;
+
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_TARGET_URL:
+ aReturn = m_xSlaveHandler->describePropertyLine( _rPropertyName, _rxControlFactory );
+ break;
+ default:
+ aReturn = ButtonNavigationHandler_Base::describePropertyLine( _rPropertyName, _rxControlFactory );
+ break;
+ }
+
+ return aReturn;
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
diff --git a/extensions/source/propctrlr/buttonnavigationhandler.hxx b/extensions/source/propctrlr/buttonnavigationhandler.hxx
new file mode 100644
index 000000000000..63ad3e4cafef
--- /dev/null
+++ b/extensions/source/propctrlr/buttonnavigationhandler.hxx
@@ -0,0 +1,90 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_BUTTONNAVIGATIONHANDLER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_BUTTONNAVIGATIONHANDLER_HXX
+
+#include "propertyhandler.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= ButtonNavigationHandler
+ //====================================================================
+ class ButtonNavigationHandler;
+ typedef HandlerComponentBase< ButtonNavigationHandler > ButtonNavigationHandler_Base;
+ /** a property handler for any virtual string properties
+ */
+ class ButtonNavigationHandler : public ButtonNavigationHandler_Base
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler >
+ m_xSlaveHandler;
+
+ public:
+ ButtonNavigationHandler(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
+ );
+ static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ ~ButtonNavigationHandler();
+
+ static bool isNavigationCapableButton( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxComponent );
+
+ protected:
+ // XPropertyHandler overriables
+ virtual void SAL_CALL inspect( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxIntrospectee ) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::NullPointerException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::InteractiveSelectionResult
+ SAL_CALL onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, ::com::sun::star::uno::Any& _rData, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::LineDescriptor
+ SAL_CALL describePropertyLine( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+
+ // PropertyHandler overridables
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
+ SAL_CALL doDescribeSupportedProperties() const;
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_BUTTONNAVIGATIONHANDLER_HXX
+
diff --git a/extensions/source/propctrlr/cellbindinghandler.cxx b/extensions/source/propctrlr/cellbindinghandler.cxx
new file mode 100644
index 000000000000..c9630871ce3e
--- /dev/null
+++ b/extensions/source/propctrlr/cellbindinghandler.cxx
@@ -0,0 +1,504 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "cellbindinghandler.hxx"
+#include "formstrings.hxx"
+#include "formmetadata.hxx"
+#include "cellbindinghelper.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/form/binding/XValueBinding.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+/** === end UNO includes === **/
+#include <tools/debug.hxx>
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_CellBindingPropertyHandler()
+{
+ ::pcr::CellBindingPropertyHandler::registerImplementation();
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::table;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::script;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::inspection;
+ using namespace ::com::sun::star::form::binding;
+ using namespace ::comphelper;
+
+ //====================================================================
+ //= CellBindingPropertyHandler
+ //====================================================================
+ DBG_NAME( CellBindingPropertyHandler )
+ //--------------------------------------------------------------------
+ CellBindingPropertyHandler::CellBindingPropertyHandler( const Reference< XComponentContext >& _rxContext )
+ :CellBindingPropertyHandler_Base( _rxContext )
+ ,m_pCellExchangeConverter( new DefaultEnumRepresentation( *m_pInfoService, ::getCppuType( static_cast< sal_Int16* >( NULL ) ), PROPERTY_ID_CELL_EXCHANGE_TYPE ) )
+ {
+ DBG_CTOR( CellBindingPropertyHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL CellBindingPropertyHandler::getImplementationName_static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.CellBindingPropertyHandler" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL CellBindingPropertyHandler::getSupportedServiceNames_static( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported( 1 );
+ aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.CellBindingPropertyHandler" ) );
+ return aSupported;
+ }
+
+ //--------------------------------------------------------------------
+ void CellBindingPropertyHandler::onNewComponent()
+ {
+ PropertyHandlerComponent::onNewComponent();
+
+ Reference< XModel > xDocument( impl_getContextDocument_nothrow() );
+ DBG_ASSERT( xDocument.is(), "CellBindingPropertyHandler::onNewComponent: no document!" );
+ if ( CellBindingHelper::isSpreadsheetDocument( xDocument ) )
+ m_pHelper.reset( new CellBindingHelper( m_xComponent, xDocument ) );
+ }
+
+ //--------------------------------------------------------------------
+ CellBindingPropertyHandler::~CellBindingPropertyHandler( )
+ {
+ DBG_DTOR( CellBindingPropertyHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL CellBindingPropertyHandler::getActuatingProperties( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aInterestingProperties( 3 );
+ aInterestingProperties[0] = PROPERTY_LIST_CELL_RANGE;
+ aInterestingProperties[1] = PROPERTY_BOUND_CELL;
+ aInterestingProperties[2] = PROPERTY_CONTROLSOURCE;
+ return aInterestingProperties;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL CellBindingPropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (NullPointerException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nActuatingPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) );
+ OSL_PRECOND( m_pHelper.get(), "CellBindingPropertyHandler::actuatingPropertyChanged: inconsistentcy!" );
+ // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
+
+ OSL_PRECOND( _rxInspectorUI.is(), "FormComponentPropertyHandler::actuatingPropertyChanged: no access to the UI!" );
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ ::std::vector< PropertyId > aDependentProperties;
+
+ switch ( nActuatingPropId )
+ {
+ // ----- BoundCell -----
+ case PROPERTY_ID_BOUND_CELL:
+ {
+ // the SQL-data-binding related properties need to be enabled if and only if
+ // there is *no* valid cell binding
+ Reference< XValueBinding > xBinding;
+ _rNewValue >>= xBinding;
+
+ if ( impl_isSupportedProperty_nothrow( PROPERTY_ID_CELL_EXCHANGE_TYPE ) )
+ _rxInspectorUI->enablePropertyUI( PROPERTY_CELL_EXCHANGE_TYPE, xBinding.is() );
+ if ( impl_componentHasProperty_throw( PROPERTY_CONTROLSOURCE ) )
+ _rxInspectorUI->enablePropertyUI( PROPERTY_CONTROLSOURCE, !xBinding.is() );
+
+ if ( impl_isSupportedProperty_nothrow( PROPERTY_ID_FILTERPROPOSAL ) )
+ _rxInspectorUI->enablePropertyUI( PROPERTY_FILTERPROPOSAL, !xBinding.is() );
+ if ( impl_isSupportedProperty_nothrow( PROPERTY_ID_EMPTY_IS_NULL ) )
+ _rxInspectorUI->enablePropertyUI( PROPERTY_EMPTY_IS_NULL, !xBinding.is() );
+
+ aDependentProperties.push_back( PROPERTY_ID_BOUNDCOLUMN );
+
+ if ( !xBinding.is() && m_pHelper->getCurrentBinding().is() )
+ {
+ // ensure that the "transfer selection as" property is reset. Since we can't remember
+ // it at the object itself, but derive it from the binding only, we have to normalize
+ // it now that there *is* no binding anymore.
+ setPropertyValue( PROPERTY_CELL_EXCHANGE_TYPE, makeAny( (sal_Int16) 0 ) );
+ }
+ }
+ break;
+
+ // ----- CellRange -----
+ case PROPERTY_ID_LIST_CELL_RANGE:
+ {
+ // the list source related properties need to be enabled if and only if
+ // there is *no* valid external list source for the control
+ Reference< XListEntrySource > xSource;
+ _rNewValue >>= xSource;
+
+ _rxInspectorUI->enablePropertyUI( PROPERTY_STRINGITEMLIST, !xSource.is() );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_LISTSOURCE, !xSource.is() );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_LISTSOURCETYPE, !xSource.is() );
+
+ aDependentProperties.push_back( PROPERTY_ID_BOUNDCOLUMN );
+
+ // also reset the list entries if the cell range is reset
+ // #i28319# - 2004-04-27 - fs@openoffice.org
+ if ( !_bFirstTimeInit )
+ {
+ try
+ {
+ if ( !xSource.is() )
+ setPropertyValue( PROPERTY_STRINGITEMLIST, makeAny( Sequence< ::rtl::OUString >() ) );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "OPropertyBrowserController::actuatingPropertyChanged( ListCellRange ): caught an exception while resetting the string items!" );
+ }
+ }
+ }
+ break; // case PROPERTY_ID_LIST_CELL_RANGE
+
+ // ----- DataField -----
+ case PROPERTY_ID_CONTROLSOURCE:
+ {
+ ::rtl::OUString sControlSource;
+ _rNewValue >>= sControlSource;
+ if ( impl_isSupportedProperty_nothrow( PROPERTY_ID_BOUND_CELL ) )
+ _rxInspectorUI->enablePropertyUI( PROPERTY_BOUND_CELL, sControlSource.getLength() == 0 );
+ }
+ break; // case PROPERTY_ID_CONTROLSOURCE
+
+ default:
+ DBG_ERROR( "CellBindingPropertyHandler::actuatingPropertyChanged: did not register for this property!" );
+ }
+
+ for ( ::std::vector< PropertyId >::const_iterator loopAffected = aDependentProperties.begin();
+ loopAffected != aDependentProperties.end();
+ ++loopAffected
+ )
+ {
+ impl_updateDependentProperty_nothrow( *loopAffected, _rxInspectorUI );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void CellBindingPropertyHandler::impl_updateDependentProperty_nothrow( PropertyId _nPropId, const Reference< XObjectInspectorUI >& _rxInspectorUI ) const
+ {
+ try
+ {
+ switch ( _nPropId )
+ {
+ // ----- BoundColumn -----
+ case PROPERTY_ID_BOUNDCOLUMN:
+ {
+ CellBindingPropertyHandler* pNonConstThis = const_cast< CellBindingPropertyHandler* >( this );
+ Reference< XValueBinding > xBinding( pNonConstThis->getPropertyValue( PROPERTY_BOUND_CELL ), UNO_QUERY );
+ Reference< XListEntrySource > xListSource( pNonConstThis->getPropertyValue( PROPERTY_LIST_CELL_RANGE ), UNO_QUERY );
+
+ if ( impl_isSupportedProperty_nothrow( PROPERTY_ID_BOUNDCOLUMN ) )
+ _rxInspectorUI->enablePropertyUI( PROPERTY_BOUNDCOLUMN, !xBinding.is() && !xListSource.is() );
+ }
+ break; // case PROPERTY_ID_BOUNDCOLUMN
+
+ } // switch
+
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "CellBindingPropertyHandler::impl_updateDependentProperty_nothrow: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL CellBindingPropertyHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ OSL_ENSURE( m_pHelper.get(), "CellBindingPropertyHandler::getPropertyValue: inconsistency!" );
+ // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
+
+ Any aReturn;
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_BOUND_CELL:
+ {
+ Reference< XValueBinding > xBinding( m_pHelper->getCurrentBinding() );
+ if ( !m_pHelper->isCellBinding( xBinding ) )
+ xBinding.clear();
+
+ aReturn <<= xBinding;
+ }
+ break;
+
+ case PROPERTY_ID_LIST_CELL_RANGE:
+ {
+ Reference< XListEntrySource > xSource( m_pHelper->getCurrentListSource() );
+ if ( !m_pHelper->isCellRangeListSource( xSource ) )
+ xSource.clear();
+
+ aReturn <<= xSource;
+ }
+ break;
+
+ case PROPERTY_ID_CELL_EXCHANGE_TYPE:
+ {
+ Reference< XValueBinding > xBinding( m_pHelper->getCurrentBinding() );
+ aReturn <<= (sal_Int16)( m_pHelper->isCellIntegerBinding( xBinding ) ? 1 : 0 );
+ }
+ break;
+
+ default:
+ DBG_ERROR( "CellBindingPropertyHandler::getPropertyValue: cannot handle this!" );
+ break;
+ }
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL CellBindingPropertyHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ OSL_ENSURE( m_pHelper.get(), "CellBindingPropertyHandler::setPropertyValue: inconsistency!" );
+ // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
+
+ try
+ {
+ Any aOldValue = getPropertyValue( _rPropertyName );
+
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_BOUND_CELL:
+ {
+ Reference< XValueBinding > xBinding;
+ _rValue >>= xBinding;
+ m_pHelper->setBinding( xBinding );
+ }
+ break;
+
+ case PROPERTY_ID_LIST_CELL_RANGE:
+ {
+ Reference< XListEntrySource > xSource;
+ _rValue >>= xSource;
+ m_pHelper->setListSource( xSource );
+ }
+ break;
+
+ case PROPERTY_ID_CELL_EXCHANGE_TYPE:
+ {
+ sal_Int16 nExchangeType = 0;
+ OSL_VERIFY( _rValue >>= nExchangeType );
+
+ Reference< XValueBinding > xBinding = m_pHelper->getCurrentBinding( );
+ if ( xBinding.is() )
+ {
+ sal_Bool bNeedIntegerBinding = ( nExchangeType == 1 );
+ if ( (bool)bNeedIntegerBinding != m_pHelper->isCellIntegerBinding( xBinding ) )
+ {
+ CellAddress aAddress;
+ if ( m_pHelper->getAddressFromCellBinding( xBinding, aAddress ) )
+ {
+ xBinding = m_pHelper->createCellBindingFromAddress( aAddress, bNeedIntegerBinding );
+ m_pHelper->setBinding( xBinding );
+ }
+ }
+ }
+ }
+ break;
+
+ default:
+ DBG_ERROR( "CellBindingPropertyHandler::setPropertyValue: cannot handle this!" );
+ break;
+ }
+
+ impl_setContextDocumentModified_nothrow();
+
+ Any aNewValue( getPropertyValue( _rPropertyName ) );
+ firePropertyChange( _rPropertyName, nPropId, aOldValue, aNewValue );
+ // TODO/UNOize: can't we make this a part of the base class, for all those "virtual"
+ // properties? Base class'es |setPropertyValue| could call some |doSetPropertyValue|,
+ // and handle the listener notification itself
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "CellBindingPropertyHandler::setPropertyValue: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL CellBindingPropertyHandler::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Any aPropertyValue;
+
+ OSL_ENSURE( m_pHelper.get(), "CellBindingPropertyHandler::convertToPropertyValue: we have no SupportedProperties!" );
+ if ( !m_pHelper.get() )
+ return aPropertyValue;
+
+ PropertyId nPropId( m_pInfoService->getPropertyId( _rPropertyName ) );
+
+ ::rtl::OUString sControlValue;
+ OSL_VERIFY( _rControlValue >>= sControlValue );
+ switch( nPropId )
+ {
+ case PROPERTY_ID_LIST_CELL_RANGE:
+ aPropertyValue <<= m_pHelper->createCellListSourceFromStringAddress( sControlValue );
+ break;
+
+ case PROPERTY_ID_BOUND_CELL:
+ {
+ // if we have the possibility of an integer binding, then we must preserve
+ // this property's value (e.g. if the current binding is an integer binding, then
+ // the newly created one must be, too)
+ bool bIntegerBinding = false;
+ if ( m_pHelper->isCellIntegerBindingAllowed() )
+ {
+ sal_Int16 nCurrentBindingType = 0;
+ getPropertyValue( PROPERTY_CELL_EXCHANGE_TYPE ) >>= nCurrentBindingType;
+ bIntegerBinding = ( nCurrentBindingType != 0 );
+ }
+ aPropertyValue <<= m_pHelper->createCellBindingFromStringAddress( sControlValue, bIntegerBinding );
+ }
+ break;
+
+ case PROPERTY_ID_CELL_EXCHANGE_TYPE:
+ m_pCellExchangeConverter->getValueFromDescription( sControlValue, aPropertyValue );
+ break;
+
+ default:
+ DBG_ERROR( "CellBindingPropertyHandler::convertToPropertyValue: cannot handle this!" );
+ break;
+ }
+
+ return aPropertyValue;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL CellBindingPropertyHandler::convertToControlValue( const ::rtl::OUString& _rPropertyName,
+ const Any& _rPropertyValue, const Type& /*_rControlValueType*/ ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Any aControlValue;
+
+ OSL_ENSURE( m_pHelper.get(), "CellBindingPropertyHandler::convertToControlValue: we have no SupportedProperties!" );
+ if ( !m_pHelper.get() )
+ return aControlValue;
+
+ PropertyId nPropId( m_pInfoService->getPropertyId( _rPropertyName ) );
+
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_BOUND_CELL:
+ {
+ Reference< XValueBinding > xBinding;
+#if OSL_DEBUG_LEVEL > 0
+ sal_Bool bSuccess =
+#endif
+ _rPropertyValue >>= xBinding;
+ OSL_ENSURE( bSuccess, "CellBindingPropertyHandler::convertToControlValue: invalid value (1)!" );
+
+ // the only value binding we support so far is linking to spreadsheet cells
+ aControlValue <<= m_pHelper->getStringAddressFromCellBinding( xBinding );
+ }
+ break;
+
+ case PROPERTY_ID_LIST_CELL_RANGE:
+ {
+ Reference< XListEntrySource > xSource;
+#if OSL_DEBUG_LEVEL > 0
+ sal_Bool bSuccess =
+#endif
+ _rPropertyValue >>= xSource;
+ OSL_ENSURE( bSuccess, "CellBindingPropertyHandler::convertToControlValue: invalid value (2)!" );
+
+ // the only value binding we support so far is linking to spreadsheet cells
+ aControlValue <<= m_pHelper->getStringAddressFromCellListSource( xSource );
+ }
+ break;
+
+ case PROPERTY_ID_CELL_EXCHANGE_TYPE:
+ aControlValue <<= m_pCellExchangeConverter->getDescriptionForValue( _rPropertyValue );
+ break;
+
+ default:
+ DBG_ERROR( "CellBindingPropertyHandler::convertToControlValue: cannot handle this!" );
+ break;
+ }
+
+ return aControlValue;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Property > SAL_CALL CellBindingPropertyHandler::doDescribeSupportedProperties() const
+ {
+ ::std::vector< Property > aProperties;
+
+ bool bAllowCellLinking = m_pHelper.get() && m_pHelper->isCellBindingAllowed();
+ bool bAllowCellIntLinking = m_pHelper.get() && m_pHelper->isCellIntegerBindingAllowed();
+ bool bAllowListCellRange = m_pHelper.get() && m_pHelper->isListCellRangeAllowed();
+ if ( bAllowCellLinking || bAllowListCellRange || bAllowCellIntLinking )
+ {
+ sal_Int32 nPos = ( bAllowCellLinking ? 1 : 0 )
+ + ( bAllowListCellRange ? 1 : 0 )
+ + ( bAllowCellIntLinking ? 1 : 0 );
+ aProperties.resize( nPos );
+
+ if ( bAllowCellLinking )
+ {
+ aProperties[ --nPos ] = Property( PROPERTY_BOUND_CELL, PROPERTY_ID_BOUND_CELL,
+ ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ), 0 );
+ }
+ if ( bAllowCellIntLinking )
+ {
+ aProperties[ --nPos ] = Property( PROPERTY_CELL_EXCHANGE_TYPE, PROPERTY_ID_CELL_EXCHANGE_TYPE,
+ ::getCppuType( static_cast< sal_Int16* >( NULL ) ), 0 );
+ }
+ if ( bAllowListCellRange )
+ {
+ aProperties[ --nPos ] = Property( PROPERTY_LIST_CELL_RANGE, PROPERTY_ID_LIST_CELL_RANGE,
+ ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ), 0 );
+ }
+ }
+
+ if ( aProperties.empty() )
+ return Sequence< Property >();
+ return Sequence< Property >( &(*aProperties.begin()), aProperties.size() );
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
diff --git a/extensions/source/propctrlr/cellbindinghandler.hxx b/extensions/source/propctrlr/cellbindinghandler.hxx
new file mode 100644
index 000000000000..608ed5f426b6
--- /dev/null
+++ b/extensions/source/propctrlr/cellbindinghandler.hxx
@@ -0,0 +1,109 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_CELLBINDINGHANDLER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_CELLBINDINGHANDLER_HXX
+
+#include "propertyhandler.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+/** === end UNO includes === **/
+#include <rtl/ref.hxx>
+
+#include <memory>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ class CellBindingHelper;
+ class IPropertyEnumRepresentation;
+ //====================================================================
+ //= CellBindingPropertyHandler
+ //====================================================================
+ class CellBindingPropertyHandler;
+ typedef HandlerComponentBase< CellBindingPropertyHandler > CellBindingPropertyHandler_Base;
+ class CellBindingPropertyHandler : public CellBindingPropertyHandler_Base
+ {
+ private:
+ ::std::auto_ptr< CellBindingHelper > m_pHelper;
+ ::rtl::Reference< IPropertyEnumRepresentation > m_pCellExchangeConverter;
+
+ public:
+ CellBindingPropertyHandler(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
+ );
+
+ static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ ~CellBindingPropertyHandler();
+
+ protected:
+ // XPropertyHandler overriables
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rControlValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToControlValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rPropertyValue, const ::com::sun::star::uno::Type& _rControlValueType ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+
+ // PropertyHandler overridables
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
+ SAL_CALL doDescribeSupportedProperties() const;
+ virtual void onNewComponent();
+
+ private:
+ /** updates a property (UI) whose state depends on more than one other property
+
+ ->actuatingPropertyChanged is called for certain properties in whose changes
+ we expressed interes (->getActuatingProperty). Now such a property change can
+ result in simple UI updates, for instance another property being enabled or disabled.
+
+ However, it can also result in a more complex change: The current (UI) state might
+ depend on the value of more than one other property. Those dependent properties (their
+ UI, more precisly) are updated in this method.
+
+ @param _nPropid
+ the ->PropertyId of the dependent property whose UI state is to be updated
+
+ @param _rxInspectorUI
+ provides access to the property browser UI. Must not be <NULL/>.
+ */
+ void impl_updateDependentProperty_nothrow( PropertyId _nPropId, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ) const;
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_CELLBINDINGHANDLER_HXX
+
diff --git a/extensions/source/propctrlr/cellbindinghelper.cxx b/extensions/source/propctrlr/cellbindinghelper.cxx
new file mode 100644
index 000000000000..cf71793f2745
--- /dev/null
+++ b/extensions/source/propctrlr/cellbindinghelper.cxx
@@ -0,0 +1,565 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "cellbindinghelper.hxx"
+#include <com/sun/star/form/binding/XBindableValue.hpp>
+#include <com/sun/star/form/binding/XListEntrySink.hpp>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/form/XGridColumnFactory.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/form/XFormsSupplier.hpp>
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <unotools/transliterationwrapper.hxx>
+#include <osl/diagnose.h>
+#include <tools/diagnose_ex.h>
+#include "formstrings.hxx"
+
+#include <functional>
+#include <algorithm>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::sheet;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::drawing;
+ using namespace ::com::sun::star::table;
+ using namespace ::com::sun::star::form;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::i18n;
+ using namespace ::com::sun::star::form::binding;
+
+ namespace
+ {
+ //....................................................................
+ struct StringCompare : public ::std::unary_function< ::rtl::OUString, bool >
+ {
+ private:
+ ::rtl::OUString m_sReference;
+
+ public:
+ StringCompare( const ::rtl::OUString& _rReference ) : m_sReference( _rReference ) { }
+
+ inline bool operator()( const ::rtl::OUString& _rCompare )
+ {
+ return ( _rCompare == m_sReference ) ? true : false;
+ }
+ };
+ }
+
+ //========================================================================
+ //= CellBindingHelper
+ //========================================================================
+ //------------------------------------------------------------------------
+ CellBindingHelper::CellBindingHelper( const Reference< XPropertySet >& _rxControlModel, const Reference< XModel >& _rxContextDocument )
+ :m_xControlModel( _rxControlModel )
+ {
+ OSL_ENSURE( m_xControlModel.is(), "CellBindingHelper::CellBindingHelper: invalid control model!" );
+
+ m_xDocument = m_xDocument.query( _rxContextDocument );
+ OSL_ENSURE( m_xDocument.is(), "CellBindingHelper::CellBindingHelper: This is no spreadsheet document!" );
+
+ OSL_ENSURE( isSpreadsheetDocumentWhichSupplies( SERVICE_ADDRESS_CONVERSION ),
+ "CellBindingHelper::CellBindingHelper: the document cannot convert address representations!" );
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool CellBindingHelper::isSpreadsheetDocument( const Reference< XModel >& _rxContextDocument )
+ {
+ return Reference< XSpreadsheetDocument >::query( _rxContextDocument ).is();
+ }
+
+ //------------------------------------------------------------------------
+ sal_Int16 CellBindingHelper::getControlSheetIndex( Reference< XSpreadsheet >& _out_rxSheet ) const
+ {
+ sal_Int16 nSheetIndex = -1;
+ // every sheet has a draw page, and every draw page has a forms collection.
+ // Our control, OTOH, belongs to a forms collection. Match these ...
+ try
+ {
+ // for determining the draw page, we need the forms collection which
+ // the object belongs to. This is the first object up the hierarchy which is
+ // *no* XForm (and, well, no XGridColumnFactory)
+ Reference< XChild > xCheck( m_xControlModel, UNO_QUERY );
+ Reference< XForm > xParentAsForm; if ( xCheck.is() ) xParentAsForm = xParentAsForm.query( xCheck->getParent() );
+ Reference< XGridColumnFactory > xParentAsGrid; if ( xCheck.is() ) xParentAsGrid = xParentAsGrid.query( xCheck->getParent() );
+
+ while ( ( xParentAsForm.is() || xParentAsGrid.is() ) && xCheck.is() )
+ {
+ xCheck = xCheck.query( xCheck->getParent() );
+ xParentAsForm = xParentAsForm.query( xCheck.is() ? xCheck->getParent() : (Reference< XInterface >) Reference< XForm >() );
+ xParentAsGrid = xParentAsGrid.query( xCheck.is() ? xCheck->getParent() : (Reference< XInterface >) Reference< XGridColumnFactory >() );
+ }
+ Reference< XInterface > xFormsCollection( xCheck.is() ? xCheck->getParent() : Reference< XInterface >() );
+
+ // now iterate through the sheets
+ Reference< XIndexAccess > xSheets( m_xDocument->getSheets(), UNO_QUERY );
+ if ( xSheets.is() && xFormsCollection.is() )
+ {
+ for ( sal_Int32 i = 0; i < xSheets->getCount(); ++i )
+ {
+ Reference< XDrawPageSupplier > xSuppPage( xSheets->getByIndex( i ), UNO_QUERY_THROW );
+ Reference< XFormsSupplier > xSuppForms( xSuppPage->getDrawPage(), UNO_QUERY_THROW );
+
+ if ( xSuppForms->getForms() == xFormsCollection )
+ { // found it
+ nSheetIndex = (sal_Int16)i;
+ _out_rxSheet.set( xSuppPage, UNO_QUERY_THROW );
+ break;
+ }
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return nSheetIndex;
+ }
+
+ //------------------------------------------------------------------------
+ bool CellBindingHelper::convertStringAddress( const ::rtl::OUString& _rAddressDescription, CellAddress& /* [out] */ _rAddress ) const
+ {
+ Any aAddress;
+ return doConvertAddressRepresentations(
+ PROPERTY_UI_REPRESENTATION,
+ makeAny( _rAddressDescription ),
+ PROPERTY_ADDRESS,
+ aAddress,
+ false
+ )
+ && ( aAddress >>= _rAddress );
+ }
+
+ //------------------------------------------------------------------------
+ bool CellBindingHelper::doConvertAddressRepresentations( const ::rtl::OUString& _rInputProperty, const Any& _rInputValue,
+ const ::rtl::OUString& _rOutputProperty, Any& _rOutputValue, bool _bIsRange ) const SAL_THROW(())
+ {
+ bool bSuccess = false;
+
+ Reference< XPropertySet > xConverter(
+ createDocumentDependentInstance(
+ _bIsRange ? SERVICE_RANGEADDRESS_CONVERSION : SERVICE_ADDRESS_CONVERSION,
+ ::rtl::OUString(),
+ Any()
+ ),
+ UNO_QUERY
+ );
+ OSL_ENSURE( xConverter.is(), "CellBindingHelper::doConvertAddressRepresentations: could not get a converter service!" );
+ if ( xConverter.is() )
+ {
+ try
+ {
+ Reference< XSpreadsheet > xSheet;
+ xConverter->setPropertyValue( PROPERTY_REFERENCE_SHEET, makeAny( (sal_Int32)getControlSheetIndex( xSheet ) ) );
+ xConverter->setPropertyValue( _rInputProperty, _rInputValue );
+ _rOutputValue = xConverter->getPropertyValue( _rOutputProperty );
+ bSuccess = true;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "CellBindingHelper::doConvertAddressRepresentations: caught an exception!" );
+ }
+ }
+
+ return bSuccess;
+ }
+
+ //------------------------------------------------------------------------
+ bool CellBindingHelper::convertStringAddress( const ::rtl::OUString& _rAddressDescription,
+ CellRangeAddress& /* [out] */ _rAddress ) const
+ {
+ Any aAddress;
+ return doConvertAddressRepresentations(
+ PROPERTY_UI_REPRESENTATION,
+ makeAny( _rAddressDescription ),
+ PROPERTY_ADDRESS,
+ aAddress,
+ true
+ )
+ && ( aAddress >>= _rAddress );
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XValueBinding > CellBindingHelper::createCellBindingFromAddress( const CellAddress& _rAddress, bool _bSupportIntegerExchange ) const
+ {
+ Reference< XValueBinding > xBinding( createDocumentDependentInstance(
+ _bSupportIntegerExchange ? SERVICE_SHEET_CELL_INT_BINDING : SERVICE_SHEET_CELL_BINDING,
+ PROPERTY_BOUND_CELL,
+ makeAny( _rAddress )
+ ), UNO_QUERY );
+
+ return xBinding;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XValueBinding > CellBindingHelper::createCellBindingFromStringAddress( const ::rtl::OUString& _rAddress, bool _bSupportIntegerExchange ) const
+ {
+ Reference< XValueBinding > xBinding;
+ if ( !m_xDocument.is() )
+ // very bad ...
+ return xBinding;
+
+ // get the UNO representation of the address
+ CellAddress aAddress;
+ if ( !_rAddress.getLength() || !convertStringAddress( _rAddress, aAddress ) )
+ return xBinding;
+
+ return createCellBindingFromAddress( aAddress, _bSupportIntegerExchange );
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XListEntrySource > CellBindingHelper::createCellListSourceFromStringAddress( const ::rtl::OUString& _rAddress ) const
+ {
+ Reference< XListEntrySource > xSource;
+
+ CellRangeAddress aRangeAddress;
+ if ( !_rAddress.getLength() || !convertStringAddress( _rAddress, aRangeAddress ) )
+ return xSource;
+
+ // create a range object for this address
+ xSource = xSource.query( createDocumentDependentInstance(
+ SERVICE_SHEET_CELLRANGE_LISTSOURCE,
+ PROPERTY_LIST_CELL_RANGE,
+ makeAny( aRangeAddress )
+ ) );
+
+ return xSource;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XInterface > CellBindingHelper::createDocumentDependentInstance( const ::rtl::OUString& _rService, const ::rtl::OUString& _rArgumentName,
+ const Any& _rArgumentValue ) const
+ {
+ Reference< XInterface > xReturn;
+
+ Reference< XMultiServiceFactory > xDocumentFactory( m_xDocument, UNO_QUERY );
+ OSL_ENSURE( xDocumentFactory.is(), "CellBindingHelper::createDocumentDependentInstance: no document service factory!" );
+ if ( xDocumentFactory.is() )
+ {
+ try
+ {
+ if ( _rArgumentName.getLength() )
+ {
+ NamedValue aArg;
+ aArg.Name = _rArgumentName;
+ aArg.Value = _rArgumentValue;
+
+ Sequence< Any > aArgs( 1 );
+ aArgs[ 0 ] <<= aArg;
+
+ xReturn = xDocumentFactory->createInstanceWithArguments( _rService, aArgs );
+ }
+ else
+ {
+ xReturn = xDocumentFactory->createInstance( _rService );
+ }
+ }
+ catch ( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "CellBindingHelper::createDocumentDependentInstance: could not create the binding at the document!" );
+ }
+ }
+ return xReturn;
+ }
+
+ //------------------------------------------------------------------------
+ bool CellBindingHelper::getAddressFromCellBinding(
+ const Reference< XValueBinding >& _rxBinding, CellAddress& _rAddress ) const
+ {
+ OSL_PRECOND( !_rxBinding.is() || isCellBinding( _rxBinding ), "CellBindingHelper::getAddressFromCellBinding: this is no cell binding!" );
+
+ bool bReturn = false;
+ if ( !m_xDocument.is() )
+ // very bad ...
+ return bReturn;
+
+ try
+ {
+ Reference< XPropertySet > xBindingProps( _rxBinding, UNO_QUERY );
+ OSL_ENSURE( xBindingProps.is() || !_rxBinding.is(), "CellBindingHelper::getAddressFromCellBinding: no property set for the binding!" );
+ if ( xBindingProps.is() )
+ {
+ CellAddress aAddress;
+ bReturn = (bool)( xBindingProps->getPropertyValue( PROPERTY_BOUND_CELL ) >>= _rAddress );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "CellBindingHelper::getAddressFromCellBinding: caught an exception!" );
+ }
+
+ return bReturn;
+ }
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString CellBindingHelper::getStringAddressFromCellBinding( const Reference< XValueBinding >& _rxBinding ) const
+ {
+ CellAddress aAddress;
+ ::rtl::OUString sAddress;
+ if ( getAddressFromCellBinding( _rxBinding, aAddress ) )
+ {
+ Any aStringAddress;
+ doConvertAddressRepresentations( PROPERTY_ADDRESS, makeAny( aAddress ),
+ PROPERTY_UI_REPRESENTATION, aStringAddress, false );
+
+ aStringAddress >>= sAddress;
+ }
+
+ return sAddress;
+ }
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString CellBindingHelper::getStringAddressFromCellListSource( const Reference< XListEntrySource >& _rxSource ) const
+ {
+ OSL_PRECOND( !_rxSource.is() || isCellRangeListSource( _rxSource ), "CellBindingHelper::getStringAddressFromCellListSource: this is no cell list source!" );
+
+ ::rtl::OUString sAddress;
+ if ( !m_xDocument.is() )
+ // very bad ...
+ return sAddress;
+
+ try
+ {
+ Reference< XPropertySet > xSourceProps( _rxSource, UNO_QUERY );
+ OSL_ENSURE( xSourceProps.is() || !_rxSource.is(), "CellBindingHelper::getStringAddressFromCellListSource: no property set for the list source!" );
+ if ( xSourceProps.is() )
+ {
+ CellRangeAddress aRangeAddress;
+ xSourceProps->getPropertyValue( PROPERTY_LIST_CELL_RANGE ) >>= aRangeAddress;
+
+ Any aStringAddress;
+ doConvertAddressRepresentations( PROPERTY_ADDRESS, makeAny( aRangeAddress ),
+ PROPERTY_UI_REPRESENTATION, aStringAddress, true );
+ aStringAddress >>= sAddress;
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "CellBindingHelper::getStringAddressFromCellListSource: caught an exception!" );
+ }
+
+ return sAddress;
+ }
+
+ //------------------------------------------------------------------------
+ bool CellBindingHelper::isSpreadsheetDocumentWhichSupplies( const ::rtl::OUString& _rService ) const
+ {
+ bool bYesItIs = false;
+
+ Reference< XServiceInfo > xSI( m_xDocument, UNO_QUERY );
+ if ( xSI.is() && xSI->supportsService( SERVICE_SPREADSHEET_DOCUMENT ) )
+ {
+ Reference< XMultiServiceFactory > xDocumentFactory( m_xDocument, UNO_QUERY );
+ OSL_ENSURE( xDocumentFactory.is(), "CellBindingHelper::isSpreadsheetDocumentWhichSupplies: spreadsheet document, but no factory?" );
+
+ Sequence< ::rtl::OUString > aAvailableServices;
+ if ( xDocumentFactory.is() )
+ aAvailableServices = xDocumentFactory->getAvailableServiceNames( );
+
+ const ::rtl::OUString* pFound = ::std::find_if(
+ aAvailableServices.getConstArray(),
+ aAvailableServices.getConstArray() + aAvailableServices.getLength(),
+ StringCompare( _rService )
+ );
+ if ( pFound - aAvailableServices.getConstArray() < aAvailableServices.getLength() )
+ {
+ bYesItIs = true;
+ }
+ }
+
+ return bYesItIs;
+ }
+
+ //------------------------------------------------------------------------
+ bool CellBindingHelper::isListCellRangeAllowed( ) const
+ {
+ bool bAllow( false );
+
+ Reference< XListEntrySink > xSink( m_xControlModel, UNO_QUERY );
+ if ( xSink.is() )
+ {
+ bAllow = isSpreadsheetDocumentWhichSupplies( SERVICE_SHEET_CELLRANGE_LISTSOURCE );
+ }
+
+ return bAllow;
+ }
+
+ //------------------------------------------------------------------------
+ bool CellBindingHelper::isCellIntegerBindingAllowed( ) const
+ {
+ bool bAllow( true );
+
+ // first, we only offer this for controls which allow bindings in general
+ Reference< XBindableValue > xBindable( m_xControlModel, UNO_QUERY );
+ if ( !xBindable.is() )
+ bAllow = false;
+
+ // then, we must live in a spreadsheet document which can provide the special
+ // service needed for exchanging integer values
+ if ( bAllow )
+ bAllow = isSpreadsheetDocumentWhichSupplies( SERVICE_SHEET_CELL_INT_BINDING );
+
+ // then, we only offer this for list boxes
+ if ( bAllow )
+ {
+ try
+ {
+ sal_Int16 nClassId = FormComponentType::CONTROL;
+ m_xControlModel->getPropertyValue( PROPERTY_CLASSID ) >>= nClassId;
+ if ( FormComponentType::LISTBOX != nClassId )
+ bAllow = false;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "CellBindingHelper::isCellIntegerBindingAllowed: caught an exception!" );
+ // are there really control models which survive isCellBindingAllowed, but don't have a ClassId
+ // property?
+ bAllow = false;
+ }
+ }
+
+ return bAllow;
+ }
+
+ //------------------------------------------------------------------------
+ bool CellBindingHelper::isCellBindingAllowed( ) const
+ {
+ bool bAllow( false );
+
+ Reference< XBindableValue > xBindable( m_xControlModel, UNO_QUERY );
+ if ( xBindable.is() )
+ {
+ // the control can potentially be bound to an external value
+ // Does it live within a Calc document, and is able to supply CellBindings?
+ bAllow = isSpreadsheetDocumentWhichSupplies( SERVICE_SHEET_CELL_BINDING );
+ }
+
+ // disallow for some types
+ // TODO: shouldn't the XBindableValue supply a list of supported types, and we can distingusih
+ // using this list? The current behavior below is somewhat hackish ...
+ if ( bAllow )
+ {
+ try
+ {
+ sal_Int16 nClassId = FormComponentType::CONTROL;
+ m_xControlModel->getPropertyValue( PROPERTY_CLASSID ) >>= nClassId;
+ if ( ( FormComponentType::DATEFIELD == nClassId ) || ( FormComponentType::TIMEFIELD == nClassId ) )
+ bAllow = false;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "CellBindingHelper::isCellBindingAllowed: caught an exception!" );
+ bAllow = false;
+ }
+ }
+ return bAllow;
+ }
+
+ //------------------------------------------------------------------------
+ bool CellBindingHelper::isCellBinding( const Reference< XValueBinding >& _rxBinding ) const
+ {
+ return doesComponentSupport( _rxBinding.get(), SERVICE_SHEET_CELL_BINDING );
+ }
+
+ //------------------------------------------------------------------------
+ bool CellBindingHelper::isCellIntegerBinding( const Reference< XValueBinding >& _rxBinding ) const
+ {
+ return doesComponentSupport( _rxBinding.get(), SERVICE_SHEET_CELL_INT_BINDING );
+ }
+
+ //------------------------------------------------------------------------
+ bool CellBindingHelper::isCellRangeListSource( const Reference< XListEntrySource >& _rxSource ) const
+ {
+ return doesComponentSupport( _rxSource.get(), SERVICE_SHEET_CELLRANGE_LISTSOURCE );
+ }
+
+ //------------------------------------------------------------------------
+ bool CellBindingHelper::doesComponentSupport( const Reference< XInterface >& _rxComponent, const ::rtl::OUString& _rService ) const
+ {
+ bool bDoes = false;
+ Reference< XServiceInfo > xSI( _rxComponent, UNO_QUERY );
+ bDoes = xSI.is() && xSI->supportsService( _rService );
+ return bDoes;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XValueBinding > CellBindingHelper::getCurrentBinding( ) const
+ {
+ Reference< XValueBinding > xBinding;
+ Reference< XBindableValue > xBindable( m_xControlModel, UNO_QUERY );
+ if ( xBindable.is() )
+ xBinding = xBindable->getValueBinding();
+ return xBinding;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XListEntrySource > CellBindingHelper::getCurrentListSource( ) const
+ {
+ Reference< XListEntrySource > xSource;
+ Reference< XListEntrySink > xSink( m_xControlModel, UNO_QUERY );
+ if ( xSink.is() )
+ xSource = xSink->getListEntrySource();
+ return xSource;
+ }
+
+ //------------------------------------------------------------------------
+ void CellBindingHelper::setBinding( const Reference< XValueBinding >& _rxBinding )
+ {
+ Reference< XBindableValue > xBindable( m_xControlModel, UNO_QUERY );
+ OSL_PRECOND( xBindable.is(), "CellBindingHelper::setBinding: the object is not bindable!" );
+ if ( xBindable.is() )
+ xBindable->setValueBinding( _rxBinding );
+ }
+
+ //------------------------------------------------------------------------
+ void CellBindingHelper::setListSource( const Reference< XListEntrySource >& _rxSource )
+ {
+ Reference< XListEntrySink > xSink( m_xControlModel, UNO_QUERY );
+ OSL_PRECOND( xSink.is(), "CellBindingHelper::setListSource: the object is no list entry sink!" );
+ if ( xSink.is() )
+ xSink->setListEntrySource( _rxSource );
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
diff --git a/extensions/source/propctrlr/cellbindinghelper.hxx b/extensions/source/propctrlr/cellbindinghelper.hxx
new file mode 100644
index 000000000000..30bc94c106f0
--- /dev/null
+++ b/extensions/source/propctrlr/cellbindinghelper.hxx
@@ -0,0 +1,290 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_PROPCTRLR_CELLBINDINGHELPER_HXX
+#define EXTENSIONS_PROPCTRLR_CELLBINDINGHELPER_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/form/binding/XValueBinding.hpp>
+#include <com/sun/star/form/binding/XListEntrySource.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+/** === end UNO includes === **/
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ //========================================================================
+ //= CellBindingHelper
+ //========================================================================
+ /** encapsulates functionality related to binding a form control to a spreadsheet cell
+ */
+ class CellBindingHelper
+ {
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xControlModel; // the model we work for
+ ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >
+ m_xDocument; // the document where the model lives
+
+ public:
+ /** ctor
+ @param _rxControlModel
+ the control model which is or will be bound
+ */
+ CellBindingHelper(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxContextDocument
+ );
+
+ public:
+ /** determines whether the given model is a spreadsheet document model
+
+ <p>If this method returns <FALSE/>, you cannot instantiate a CellBindingHelper with
+ the document, since then no of it's functionality will be available.</p>
+ */
+ static sal_Bool isSpreadsheetDocument(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxContextDocument
+ );
+
+ /** gets a cell binding for the given address
+ @precond
+ isCellBindingAllowed returns <TRUE/>
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >
+ createCellBindingFromStringAddress(
+ const ::rtl::OUString& _rAddress,
+ bool _bSupportIntegerExchange = false
+ ) const;
+
+ /** creates a cell binding (supporting integer exchange, if requested) for
+ the given address object
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >
+ createCellBindingFromAddress(
+ const ::com::sun::star::table::CellAddress& _rAddress,
+ bool _bSupportIntegerExchange = false
+ ) const;
+
+ /** gets a cell range list source binding for the given address
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >
+ createCellListSourceFromStringAddress( const ::rtl::OUString& _rAddress ) const;
+
+ /** creates a string representation for the given value binding's address
+
+ <p>If the sheet of the bound cell is the same as the sheet which our control belongs
+ to, then the sheet name is omitted in the resulting string representation.</p>
+
+ @precond
+ The binding is a valid cell binding, or <NULL/>
+ @see isCellBinding
+ */
+ ::rtl::OUString getStringAddressFromCellBinding(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding
+ ) const;
+
+ /** creates an address object for the given value binding's address
+
+ @precond
+ The binding is a valid cell binding, or <NULL/>
+ @return
+ <FALSE/> if and only if an error occured and no valid address could be obtained
+ @see isCellBinding
+ */
+ bool getAddressFromCellBinding(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding,
+ ::com::sun::star::table::CellAddress& _rAddress
+ ) const;
+
+ /** creates a string representation for the given list source's range address
+
+ <p>If the sheet of the cell range which acts as list source is the same as the
+ sheet which our control belongs to, then the sheet name is omitted in the
+ resulting string representation.</p>
+
+ @precond
+ The object is a valid cell range list source, or <NULL/>
+ @see isCellRangeListSource
+ */
+ ::rtl::OUString getStringAddressFromCellListSource(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource
+ ) const;
+
+ /** returns the current binding of our control model, if any.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >
+ getCurrentBinding( ) const;
+
+ /** returns the current external list source of the control model, if any
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >
+ getCurrentListSource( ) const;
+
+ /** sets a new binding for our control model
+ @precond
+ the control model is bindable (which is implied by <member>isCellBindingAllowed</member>
+ returning <TRUE/>)
+ */
+ void setBinding(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding
+ );
+
+ /** sets a list source for our control model
+ @precond
+ the control model is a list sink (which is implied by <member>isListCellRangeAllowed</member>
+ returning <TRUE/>)
+ */
+ void setListSource(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource
+ );
+
+ /** checks whether it's possible to bind the control model to a spreadsheet cell
+ */
+ bool isCellBindingAllowed( ) const;
+
+ /** checks whether it's possible to bind the control model to a spreadsheet cell,
+ with exchanging integer values
+ */
+ bool isCellIntegerBindingAllowed( ) const;
+
+ /** checks whether it's possible to bind the control model to range of spreadsheet cells
+ supplying the list entries
+ */
+ bool isListCellRangeAllowed( ) const;
+
+ /** checks whether a given binding is a spreadsheet cell binding
+ */
+ bool isCellBinding(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding
+ ) const;
+
+ /** checks whether a given binding is a spreadsheet cell binding, exchanging
+ integer values
+ */
+ bool isCellIntegerBinding(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding
+ ) const;
+
+ /** checks whether a given list source is a spreadsheet cell list source
+ */
+ bool isCellRangeListSource(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource
+ ) const;
+
+ /** retrieves the index of the sheet which our control belongs to
+ @return the index of the sheet which our control belongs to or -1, if an error occured
+ */
+ sal_Int16 getControlSheetIndex(
+ ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet >& _out_rxSheet
+ ) const;
+
+ protected:
+ /** creates an address object from a string representation of a cell address
+ */
+ bool convertStringAddress(
+ const ::rtl::OUString& _rAddressDescription,
+ ::com::sun::star::table::CellAddress& /* [out] */ _rAddress
+ ) const;
+
+ /** creates an address range object from a string representation of a cell range address
+ */
+ bool convertStringAddress(
+ const ::rtl::OUString& _rAddressDescription,
+ ::com::sun::star::table::CellRangeAddress& /* [out] */ _rAddress
+ ) const;
+
+ /** determines if our document is a spreadsheet document, *and* can supply
+ the given service
+ */
+ bool isSpreadsheetDocumentWhichSupplies( const ::rtl::OUString& _rService ) const;
+
+ /** checkes whether a given component supports a given servive
+ */
+ bool doesComponentSupport(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent,
+ const ::rtl::OUString& _rService
+ ) const;
+
+ /** uses the document (it's factory interface, respectively) to create a component instance
+ @param _rService
+ the service name
+ @param _rArgumentName
+ the name of the single argument to pass during creation. May be empty, in this case
+ no arguments are passed
+ @param _rArgumentValue
+ the value of the instantiation argument. Not evaluated if <arg>_rArgumentName</arg>
+ is empty.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ createDocumentDependentInstance(
+ const ::rtl::OUString& _rService,
+ const ::rtl::OUString& _rArgumentName,
+ const ::com::sun::star::uno::Any& _rArgumentValue
+ ) const;
+
+ /** converts an address representation into another one
+
+ @param _rInputProperty
+ the input property name for the conversion service
+ @param _rInputValue
+ the input property value for the conversion service
+ @param _rOutputProperty
+ the output property name for the conversion service
+ @param _rOutputValue
+ the output property value for the conversion service
+ @param _bIsRange
+ if <TRUE/>, the RangeAddressConversion service will be used, else
+ the AddressConversion service
+
+ @return
+ <TRUE/> if any only if the conversion was successfull
+
+ @see com::sun::star::table::CellAddressConversion
+ @see com::sun::star::table::CellRangeAddressConversion
+ */
+ bool doConvertAddressRepresentations(
+ const ::rtl::OUString& _rInputProperty,
+ const ::com::sun::star::uno::Any& _rInputValue,
+ const ::rtl::OUString& _rOutputProperty,
+ ::com::sun::star::uno::Any& _rOutputValue,
+ bool _bIsRange
+ ) const SAL_THROW(());
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // EXTENSIONS_PROPCTRLR_CELLBINDINGHELPER_HXX
diff --git a/extensions/source/propctrlr/commoncontrol.cxx b/extensions/source/propctrlr/commoncontrol.cxx
new file mode 100644
index 000000000000..647b8b92c480
--- /dev/null
+++ b/extensions/source/propctrlr/commoncontrol.cxx
@@ -0,0 +1,206 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "commoncontrol.hxx"
+#include "pcrcommon.hxx"
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/combobox.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::inspection::XPropertyControlContext;
+ using ::com::sun::star::awt::XWindow;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::inspection::XPropertyControl;
+ /** === end UNO using === **/
+
+ //==================================================================
+ //= ControlHelper
+ //==================================================================
+ //------------------------------------------------------------------
+ ControlHelper::ControlHelper( Window* _pControlWindow, sal_Int16 _nControlType, XPropertyControl& _rAntiImpl, IModifyListener* _pModifyListener )
+ :m_pControlWindow( _pControlWindow )
+ ,m_nControlType( _nControlType )
+ ,m_rAntiImpl( _rAntiImpl )
+ ,m_pModifyListener( _pModifyListener )
+ ,m_bModified( sal_False )
+ {
+ DBG_ASSERT( m_pControlWindow != NULL, "ControlHelper::ControlHelper: invalid window!" );
+ }
+
+ //------------------------------------------------------------------
+ ControlHelper::~ControlHelper()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Int16 SAL_CALL ControlHelper::getControlType() throw (RuntimeException)
+ {
+ return m_nControlType;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertyControlContext > SAL_CALL ControlHelper::getControlContext() throw (RuntimeException)
+ {
+ return m_xContext;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ControlHelper::setControlContext( const Reference< XPropertyControlContext >& _controlcontext ) throw (RuntimeException)
+ {
+ m_xContext = _controlcontext;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XWindow > SAL_CALL ControlHelper::getControlWindow() throw (RuntimeException)
+ {
+ return VCLUnoHelper::GetInterface( m_pControlWindow );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL ControlHelper::isModified( ) throw (RuntimeException)
+ {
+ return m_bModified;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ControlHelper::notifyModifiedValue( ) throw (RuntimeException)
+ {
+ if ( isModified() && m_xContext.is() )
+ {
+ try
+ {
+ m_xContext->valueChanged( &m_rAntiImpl );
+ m_bModified = sal_False;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL ControlHelper::dispose()
+ {
+ DELETEZ( m_pControlWindow );
+ }
+
+ //------------------------------------------------------------------
+ void ControlHelper::autoSizeWindow()
+ {
+ OSL_PRECOND( m_pControlWindow, "ControlHelper::autoSizeWindow: no window!" );
+ if ( !m_pControlWindow )
+ return;
+
+ ComboBox aComboBox(m_pControlWindow, WB_DROPDOWN);
+ aComboBox.SetPosSizePixel(Point(0,0), Size(100,100));
+ m_pControlWindow->SetSizePixel(aComboBox.GetSizePixel());
+
+ // TODO/UNOize: why do the controls this themselves? Shouldn't this be the task
+ // of the the browser listbox/line?
+ }
+
+ //------------------------------------------------------------------
+ void ControlHelper::impl_activateNextControl_nothrow() const
+ {
+ try
+ {
+ if ( m_xContext.is() )
+ m_xContext->activateNextControl( const_cast< XPropertyControl* >( &m_rAntiImpl ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------
+ bool ControlHelper::handlePreNotify(NotifyEvent& rNEvt)
+ {
+ if (EVENT_KEYINPUT == rNEvt.GetType())
+ {
+ const KeyCode& aKeyCode = rNEvt.GetKeyEvent()->GetKeyCode();
+ sal_uInt16 nKey = aKeyCode.GetCode();
+
+ if (nKey == KEY_RETURN && !aKeyCode.IsShift())
+ {
+ LoseFocusHdl(m_pControlWindow);
+ impl_activateNextControl_nothrow();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( ControlHelper, ModifiedHdl, Window*, /*_pWin*/ )
+ {
+ if ( m_pModifyListener )
+ m_pModifyListener->modified();
+ return 0;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( ControlHelper, GetFocusHdl, Window*, /*_pWin*/ )
+ {
+ try
+ {
+ if ( m_xContext.is() )
+ m_xContext->focusGained( &m_rAntiImpl );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return 0;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( ControlHelper, LoseFocusHdl, Window*, /*_pWin*/ )
+ {
+ // TODO/UNOize: should this be outside the default control's implementations? If somebody
+ // has an own control implementation, which does *not* do this - would this be allowed?
+ // If not, then we must move this logic out of here.
+ notifyModifiedValue();
+ return 0;
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
diff --git a/extensions/source/propctrlr/commoncontrol.hxx b/extensions/source/propctrlr/commoncontrol.hxx
new file mode 100644
index 000000000000..dd586661990b
--- /dev/null
+++ b/extensions/source/propctrlr/commoncontrol.hxx
@@ -0,0 +1,337 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_COMMONCONTROL_HXX_
+#define _EXTENSIONS_PROPCTRLR_COMMONCONTROL_HXX_
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/XPropertyControl.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+/** === end UNO includes === **/
+#include <cppuhelper/compbase1.hxx>
+#include <comphelper/broadcasthelper.hxx>
+#include <tools/link.hxx>
+#include <vcl/window.hxx>
+
+class NotifyEvent;
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ class ControlHelper;
+ //========================================================================
+ //= ControlWindow
+ //========================================================================
+ template< class WINDOW >
+ class ControlWindow : public WINDOW
+ {
+ protected:
+ typedef WINDOW WindowType;
+
+ protected:
+ ControlHelper* m_pHelper;
+
+ public:
+ ControlWindow( Window* _pParent, WinBits _nStyle )
+ :WindowType( _pParent, _nStyle )
+ ,m_pHelper( NULL )
+ {
+ }
+
+ /// sets a ControlHelper instance which some functionality is delegated to
+ inline virtual void setControlHelper( ControlHelper& _rControlHelper );
+
+ protected:
+ // Window overridables
+ inline virtual long PreNotify( NotifyEvent& rNEvt );
+ };
+
+ //========================================================================
+ //= IModifyListener
+ //========================================================================
+ class SAL_NO_VTABLE IModifyListener
+ {
+ public:
+ virtual void modified() = 0;
+ };
+
+ //========================================================================
+ //= ControlHelper
+ //========================================================================
+ /** A helper class for implementing the <type scope="com::sun::star::inspection">XPropertyControl</type>
+ or one of its derived interfaces.
+
+ This class is intended to be held as member of another class which implements the
+ <type scope="com::sun::star::inspection">XPropertyControl</type> interface. The pointer
+ to this interface is to be passed to the ctor.
+ */
+ class ControlHelper
+ {
+ private:
+ Window* m_pControlWindow;
+ sal_Int16 m_nControlType;
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlContext >
+ m_xContext;
+ ::com::sun::star::inspection::XPropertyControl&
+ m_rAntiImpl;
+ IModifyListener* m_pModifyListener;
+ sal_Bool m_bModified;
+
+ public:
+ /** creates the instance
+ @param _rControlWindow
+ the window which is associated with the <type scope="com::sun::star::inspection">XPropertyControl</type>.
+ Must not be <NULL/>.<br/>
+ Ownership for this window is taken by the ControlHelper - it will be deleted in <member>disposing</member>.
+ @param _nControlType
+ the type of the control - one of the <type scope="com::sun::star::inspection">PropertyControlType</type>
+ constants
+ @param _pAntiImpl
+ Reference to the instance as whose "impl-class" we act. This reference is held during lifetime
+ of the <type>ControlHelper</type> class, within acquiring it. Thus, the owner of the
+ <type>ControlHelper</type> is responsible for assuring the lifetime of the instance
+ pointed to by <arg>_pAntiImpl</arg>.
+ @param _pModifyListener
+ a listener to be modfied when the user modified the control's value. the
+ <member>IModifyListener::modified</member> of this listener is called from within our
+ ModifiedHdl. A default implementation of <member>IModifyListener::modified</member>
+ would just call our <member>setModified</member>.
+ */
+ ControlHelper(
+ Window* _pControlWindow,
+ sal_Int16 _nControlType,
+ ::com::sun::star::inspection::XPropertyControl& _rAntiImpl,
+ IModifyListener* _pModifyListener );
+
+ virtual ~ControlHelper();
+
+ /** sets our "modified" flag to <TRUE/>
+ */
+ inline void setModified() { m_bModified = sal_True; }
+ inline Window* getVclControlWindow() { return m_pControlWindow; }
+ inline const Window* getVclControlWindow() const { return m_pControlWindow; }
+
+ public:
+ // XPropertyControl
+ ::sal_Int16 SAL_CALL getControlType() throw (::com::sun::star::uno::RuntimeException);
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlContext > SAL_CALL getControlContext() throw (::com::sun::star::uno::RuntimeException);
+ void SAL_CALL setControlContext( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlContext >& _controlcontext ) throw (::com::sun::star::uno::RuntimeException);
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL getControlWindow() throw (::com::sun::star::uno::RuntimeException);
+ ::sal_Bool SAL_CALL isModified( ) throw (::com::sun::star::uno::RuntimeException);
+ void SAL_CALL notifyModifiedValue( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XComponent
+ virtual void SAL_CALL dispose();
+
+ /** (fail-safe) wrapper around calling our context's activateNextControl
+ */
+ inline void activateNextControl() const { impl_activateNextControl_nothrow(); }
+
+ public:
+ /// may be used to implement the default handling in PreNotify; returns sal_True if handled
+ bool handlePreNotify(NotifyEvent& _rNEvt);
+
+ /// automatically size the window given in the ctor
+ void autoSizeWindow();
+
+ /// may be used by derived classes, they forward the event to the PropCtrListener
+ DECL_LINK( ModifiedHdl, Window* );
+ DECL_LINK( GetFocusHdl, Window* );
+ DECL_LINK( LoseFocusHdl, Window* );
+
+ private:
+ /** fail-safe wrapper around calling our context's activateNextControl
+ */
+ void impl_activateNextControl_nothrow() const;
+ };
+
+ //========================================================================
+ //= CommonBehaviourControl
+ //========================================================================
+ /** implements a base class for <type scope="com::sun::star::inspection">XPropertyControl</type>
+ implementations, which delegates the generic functionality of this interface to a
+ <type>ControlHelper</type> member.
+
+ @param CONTROL_INTERFACE
+ an interface class which is derived from (or identical to) <type scope="com::sun::star::inspection">XPropertyControl</type>
+ @param CONTROL_WINDOW
+ a class which is derived from ControlWindow
+ */
+ template < class CONTROL_INTERFACE, class CONTROL_WINDOW >
+ class CommonBehaviourControl :public ::comphelper::OBaseMutex
+ ,public ::cppu::WeakComponentImplHelper1< CONTROL_INTERFACE >
+ ,public IModifyListener
+ {
+ protected:
+ typedef CONTROL_INTERFACE InterfaceType;
+ typedef CONTROL_WINDOW WindowType;
+
+ typedef ::comphelper::OBaseMutex MutexBaseClass;
+ typedef ::cppu::WeakComponentImplHelper1< CONTROL_INTERFACE > ComponentBaseClass;
+
+ protected:
+ ControlHelper m_aImplControl;
+
+ protected:
+ inline CommonBehaviourControl( sal_Int16 _nControlType, Window* _pParentWindow, WinBits _nWindowStyle, bool _bDoSetHandlers = true );
+
+ // XPropertyControl - delegated to ->m_aImplControl
+ inline ::sal_Int16 SAL_CALL getControlType() throw (::com::sun::star::uno::RuntimeException);
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlContext > SAL_CALL getControlContext() throw (::com::sun::star::uno::RuntimeException);
+ inline void SAL_CALL setControlContext( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlContext >& _controlcontext ) throw (::com::sun::star::uno::RuntimeException);
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL getControlWindow() throw (::com::sun::star::uno::RuntimeException);
+ inline ::sal_Bool SAL_CALL isModified( ) throw (::com::sun::star::uno::RuntimeException);
+ inline void SAL_CALL notifyModifiedValue( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XComponent
+ inline virtual void SAL_CALL disposing();
+
+ // IModifyListener
+ inline virtual void modified();
+
+ /// returns a typed pointer to our control window
+ WindowType* getTypedControlWindow() { return static_cast< WindowType* > ( m_aImplControl.getVclControlWindow() ); }
+ const WindowType* getTypedControlWindow() const { return static_cast< const WindowType* >( m_aImplControl.getVclControlWindow() ); }
+
+ protected:
+ /** checks whether the instance is already disposed
+ @throws DisposedException
+ if the instance is already disposed
+ */
+ inline void impl_checkDisposed_throw();
+ };
+
+ //========================================================================
+ //= ControlWindow - implementation
+ //========================================================================
+ //------------------------------------------------------------------------
+ template< class WINDOW >
+ inline void ControlWindow< WINDOW >::setControlHelper( ControlHelper& _rControlHelper )
+ {
+ m_pHelper = &_rControlHelper;
+ }
+
+ //------------------------------------------------------------------------
+ template< class WINDOW >
+ inline long ControlWindow< WINDOW >::PreNotify( NotifyEvent& rNEvt )
+ {
+ if ( m_pHelper && m_pHelper->handlePreNotify( rNEvt ) )
+ return 1;
+ return WindowType::PreNotify( rNEvt );
+ }
+
+ //========================================================================
+ //= CommonBehaviourControl - implementation
+ //========================================================================
+ //------------------------------------------------------------------------
+ template< class CONTROL_INTERFACE, class CONTROL_WINDOW >
+ inline CommonBehaviourControl< CONTROL_INTERFACE, CONTROL_WINDOW >::CommonBehaviourControl ( sal_Int16 _nControlType, Window* _pParentWindow, WinBits _nWindowStyle, bool _bDoSetHandlers )
+ :ComponentBaseClass( m_aMutex )
+ ,m_aImplControl( new WindowType( _pParentWindow, _nWindowStyle ), _nControlType, *this, this )
+ {
+ WindowType* pControlWindow( getTypedControlWindow() );
+ pControlWindow->setControlHelper( m_aImplControl );
+ if ( _bDoSetHandlers )
+ {
+ pControlWindow->SetModifyHdl( LINK( &m_aImplControl, ControlHelper, ModifiedHdl ) );
+ pControlWindow->SetGetFocusHdl( LINK( &m_aImplControl, ControlHelper, GetFocusHdl ) );
+ pControlWindow->SetLoseFocusHdl( LINK( &m_aImplControl, ControlHelper, LoseFocusHdl ) );
+ }
+ m_aImplControl.autoSizeWindow();
+ }
+
+ //--------------------------------------------------------------------
+ template< class CONTROL_INTERFACE, class CONTROL_WINDOW >
+ inline ::sal_Int16 SAL_CALL CommonBehaviourControl< CONTROL_INTERFACE, CONTROL_WINDOW >::getControlType() throw (::com::sun::star::uno::RuntimeException)
+ {
+ return m_aImplControl.getControlType();
+ }
+
+ //--------------------------------------------------------------------
+ template< class CONTROL_INTERFACE, class CONTROL_WINDOW >
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlContext > SAL_CALL CommonBehaviourControl< CONTROL_INTERFACE, CONTROL_WINDOW >::getControlContext() throw (::com::sun::star::uno::RuntimeException)
+ {
+ return m_aImplControl.getControlContext();
+ }
+
+ //--------------------------------------------------------------------
+ template< class CONTROL_INTERFACE, class CONTROL_WINDOW >
+ inline void SAL_CALL CommonBehaviourControl< CONTROL_INTERFACE, CONTROL_WINDOW >::setControlContext( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlContext >& _controlcontext ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ m_aImplControl.setControlContext( _controlcontext );
+ }
+
+ //--------------------------------------------------------------------
+ template< class CONTROL_INTERFACE, class CONTROL_WINDOW >
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL CommonBehaviourControl< CONTROL_INTERFACE, CONTROL_WINDOW >::getControlWindow() throw (::com::sun::star::uno::RuntimeException)
+ {
+ return m_aImplControl.getControlWindow();
+ }
+
+ //--------------------------------------------------------------------
+ template< class CONTROL_INTERFACE, class CONTROL_WINDOW >
+ inline ::sal_Bool SAL_CALL CommonBehaviourControl< CONTROL_INTERFACE, CONTROL_WINDOW >::isModified( ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ return m_aImplControl.isModified();
+ }
+
+ //--------------------------------------------------------------------
+ template< class CONTROL_INTERFACE, class CONTROL_WINDOW >
+ inline void SAL_CALL CommonBehaviourControl< CONTROL_INTERFACE, CONTROL_WINDOW >::notifyModifiedValue( ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ m_aImplControl.notifyModifiedValue();
+ }
+
+ //--------------------------------------------------------------------
+ template< class CONTROL_INTERFACE, class CONTROL_WINDOW >
+ inline void SAL_CALL CommonBehaviourControl< CONTROL_INTERFACE, CONTROL_WINDOW >::disposing()
+ {
+ m_aImplControl.dispose();
+ }
+
+ //--------------------------------------------------------------------
+ template< class CONTROL_INTERFACE, class CONTROL_WINDOW >
+ inline void CommonBehaviourControl< CONTROL_INTERFACE, CONTROL_WINDOW >::modified()
+ {
+ m_aImplControl.setModified();
+ }
+
+ //--------------------------------------------------------------------
+ template< class CONTROL_INTERFACE, class CONTROL_WINDOW >
+ inline void CommonBehaviourControl< CONTROL_INTERFACE, CONTROL_WINDOW >::impl_checkDisposed_throw()
+ {
+ if ( ComponentBaseClass::rBHelper.bDisposed )
+ throw ::com::sun::star::lang::DisposedException( ::rtl::OUString(), *this );
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_COMMONCONTROL_HXX_
+
diff --git a/extensions/source/propctrlr/composeduiupdate.cxx b/extensions/source/propctrlr/composeduiupdate.cxx
new file mode 100644
index 000000000000..c9659d076de5
--- /dev/null
+++ b/extensions/source/propctrlr/composeduiupdate.cxx
@@ -0,0 +1,859 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "composeduiupdate.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/inspection/PropertyLineElement.hpp>
+/** === end UNO includes === **/
+#include <osl/mutex.hxx>
+#include <rtl/ref.hxx>
+
+#include <algorithm>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::lang::DisposedException;
+ using ::com::sun::star::lang::NullPointerException;
+ using ::com::sun::star::inspection::XPropertyHandler;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::inspection::XObjectInspectorUI;
+ using ::com::sun::star::inspection::XPropertyControl;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::lang::NoSupportException;
+ using ::com::sun::star::inspection::XPropertyControlObserver;
+ /** === end UNO using === **/
+
+ namespace PropertyLineElement = ::com::sun::star::inspection::PropertyLineElement;
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ namespace
+ {
+ struct HandlerLess : public ::std::binary_function < Reference< XPropertyHandler >
+ , Reference< XPropertyHandler >
+ , bool
+ >
+ {
+ bool operator()( const Reference< XPropertyHandler >& lhs, const Reference< XPropertyHandler >& rhs) const
+ {
+ return lhs.get() < rhs.get();
+ }
+ };
+
+ //================================================================
+ typedef ::std::set< ::rtl::OUString > StringBag;
+ typedef ::std::map< sal_Int16, StringBag > MapIntToStringBag;
+ }
+
+ //====================================================================
+ //= callbacks for CachedInspectorUI
+ //====================================================================
+ typedef void (ComposedPropertyUIUpdate::*FNotifySingleUIChange)();
+
+ //====================================================================
+ //= CachedInspectorUI
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::inspection::XObjectInspectorUI
+ > CachedInspectorUI_Base;
+ struct CachedInspectorUI : public CachedInspectorUI_Base
+ {
+ private:
+ ::osl::Mutex m_aMutex;
+ oslInterlockedCount m_refCount;
+ bool m_bDisposed;
+ ComposedPropertyUIUpdate&
+ m_rMaster;
+ FNotifySingleUIChange m_pUIChangeNotification;
+
+ // enablePropertyUI cache
+ StringBag aEnabledProperties;
+ StringBag aDisabledProperties;
+
+ // show/hidePropertyUI cache
+ StringBag aShownProperties;
+ StringBag aHiddenProperties;
+
+ // rebuildPropertyUI cache
+ StringBag aRebuiltProperties;
+
+ // showCategory cache
+ StringBag aShownCategories;
+ StringBag aHiddenCategories;
+
+ // enablePropertyUIElements cache
+ MapIntToStringBag aEnabledElements;
+ MapIntToStringBag aDisabledElements;
+
+ public:
+ typedef StringBag& (CachedInspectorUI::*FGetStringBag)();
+
+ // enablePropertyUI cache
+ StringBag& getEnabledProperties() { return aEnabledProperties; }
+ StringBag& getDisabledProperties() { return aDisabledProperties; }
+
+ // show/hidePropertyUI cache
+ StringBag& getShownProperties() { return aShownProperties; }
+ StringBag& getHiddenProperties() { return aHiddenProperties; }
+
+ // rebuildPropertyUI cache
+ StringBag& getRebuiltProperties() { return aRebuiltProperties; }
+
+ // showCategory cache
+ StringBag& getShownCategories() { return aShownCategories; }
+ StringBag& getHiddenCategories() { return aHiddenCategories; }
+
+ // enablePropertyUIElements
+ StringBag& getEnabledInputControls() { return aEnabledElements[ PropertyLineElement::InputControl ]; }
+ StringBag& getDisabledInputControls() { return aDisabledElements[ PropertyLineElement::InputControl ]; }
+ StringBag& getEnabledPrimaryButtons() { return aEnabledElements[ PropertyLineElement::PrimaryButton ]; }
+ StringBag& getDisabledPrimaryButtons() { return aDisabledElements[ PropertyLineElement::PrimaryButton ]; }
+ StringBag& getEnabledSecondaryButtons() { return aEnabledElements[ PropertyLineElement::SecondaryButton ]; }
+ StringBag& getDisabledSecondaryButtons() { return aDisabledElements[ PropertyLineElement::SecondaryButton ]; }
+
+ public:
+ CachedInspectorUI( ComposedPropertyUIUpdate& _rMaster, FNotifySingleUIChange _pUIChangeNotification );
+
+ /// disposes the instance
+ void dispose();
+
+ // XObjectInspectorUI overridables
+ virtual void SAL_CALL enablePropertyUI( const ::rtl::OUString& _rPropertyName, ::sal_Bool _bEnable ) throw (RuntimeException);
+ virtual void SAL_CALL enablePropertyUIElements( const ::rtl::OUString& _rPropertyName, ::sal_Int16 _nElements, ::sal_Bool _bEnable ) throw (RuntimeException);
+ virtual void SAL_CALL rebuildPropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException);
+ virtual void SAL_CALL showPropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException);
+ virtual void SAL_CALL hidePropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException);
+ virtual void SAL_CALL showCategory( const ::rtl::OUString& _rCategory, ::sal_Bool _bShow ) throw (RuntimeException);
+ virtual Reference< XPropertyControl > SAL_CALL getPropertyControl( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException);
+ virtual void SAL_CALL registerControlObserver( const Reference< XPropertyControlObserver >& Observer ) throw (RuntimeException);
+ virtual void SAL_CALL revokeControlObserver( const Reference< XPropertyControlObserver >& Observer ) throw (RuntimeException);
+ virtual void SAL_CALL setHelpSectionText( const ::rtl::OUString& _HelpText ) throw (NoSupportException, RuntimeException);
+
+ // UNOCompatibleNonUNOReference overridables
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ protected:
+ ~CachedInspectorUI();
+
+ /// determines whether the instance is already disposed
+ inline bool isDisposed() const { return m_bDisposed; }
+
+ /// throws an exception if the component is already disposed
+ void checkDisposed() const;
+
+ private:
+ void impl_markElementEnabledOrDisabled( const ::rtl::OUString& _rPropertyName, sal_Int16 _nElementIdOrZero, sal_Bool _bEnable );
+
+ /** calls <member>m_pUIChangeNotification</member> at <member>m_rMaster</member>
+ */
+ void impl_notifySingleUIChange() const;
+
+ private:
+ CachedInspectorUI( const CachedInspectorUI& ); // never implemented
+ CachedInspectorUI& operator=( const CachedInspectorUI& ); // never implemented
+
+ private:
+ class MethodGuard;
+ friend class MethodGuard;
+ class MethodGuard : public ::osl::MutexGuard
+ {
+ public:
+ MethodGuard( CachedInspectorUI& rInstance )
+ : ::osl::MutexGuard( rInstance.m_aMutex )
+ {
+ rInstance.checkDisposed();
+ }
+ };
+ };
+
+ //----------------------------------------------------------------
+ CachedInspectorUI::CachedInspectorUI( ComposedPropertyUIUpdate& _rMaster, FNotifySingleUIChange _pUIChangeNotification )
+ :m_refCount( 0 )
+ ,m_bDisposed( false )
+ ,m_rMaster( _rMaster )
+ ,m_pUIChangeNotification( _pUIChangeNotification )
+ {
+ }
+
+ //----------------------------------------------------------------
+ CachedInspectorUI::~CachedInspectorUI()
+ {
+ }
+
+ //----------------------------------------------------------------
+ void CachedInspectorUI::dispose()
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_bDisposed = true;
+
+ clearContainer( aEnabledProperties );
+ clearContainer( aDisabledProperties );
+ clearContainer( aRebuiltProperties );
+ clearContainer( aShownProperties );
+ clearContainer( aHiddenProperties );
+ clearContainer( aShownCategories );
+ clearContainer( aHiddenCategories );
+ clearContainer( aEnabledElements );
+ clearContainer( aDisabledElements );
+ }
+
+ //----------------------------------------------------------------
+ void SAL_CALL CachedInspectorUI::acquire() throw()
+ {
+ osl_incrementInterlockedCount( &m_refCount );
+ }
+
+ //----------------------------------------------------------------
+ void SAL_CALL CachedInspectorUI::release() throw()
+ {
+ if ( 0 == osl_decrementInterlockedCount( &m_refCount ) )
+ delete this;
+ }
+
+
+ //----------------------------------------------------------------
+ void CachedInspectorUI::checkDisposed() const
+ {
+ if ( isDisposed() )
+ throw DisposedException();
+ }
+
+ //----------------------------------------------------------------
+ namespace
+ {
+ void lcl_markStringKeyPositiveOrNegative( const ::rtl::OUString& _rKeyName, StringBag& _rPositives, StringBag& _rNegatives, sal_Bool _bMarkPositive )
+ {
+ if ( _bMarkPositive )
+ {
+ _rPositives.insert( _rKeyName );
+ // if the same key has been remember as in the "negative" list before, clear this information, since it's overruled
+ _rNegatives.erase( _rKeyName );
+ }
+ else
+ _rNegatives.insert( _rKeyName );
+ }
+ }
+
+ //----------------------------------------------------------------
+ void CachedInspectorUI::enablePropertyUI( const ::rtl::OUString& _rPropertyName, sal_Bool _bEnable ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ if ( !m_rMaster.shouldContinuePropertyHandling( _rPropertyName ) )
+ return;
+
+ lcl_markStringKeyPositiveOrNegative( _rPropertyName, aEnabledProperties, aDisabledProperties, _bEnable );
+ impl_notifySingleUIChange();
+ }
+
+ //----------------------------------------------------------------
+ void CachedInspectorUI::impl_markElementEnabledOrDisabled( const ::rtl::OUString& _rPropertyName, sal_Int16 _nElementIdOrZero, sal_Bool _bEnable )
+ {
+ if ( _nElementIdOrZero == 0 )
+ return;
+
+ lcl_markStringKeyPositiveOrNegative(
+ _rPropertyName,
+ aEnabledElements[ _nElementIdOrZero ],
+ aDisabledElements[ _nElementIdOrZero ],
+ _bEnable
+ );
+ }
+
+ //----------------------------------------------------------------
+ void CachedInspectorUI::impl_notifySingleUIChange() const
+ {
+ (m_rMaster.*m_pUIChangeNotification)();
+ }
+
+ //----------------------------------------------------------------
+ void CachedInspectorUI::enablePropertyUIElements( const ::rtl::OUString& _rPropertyName, sal_Int16 _nElements, sal_Bool _bEnable ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ if ( !m_rMaster.shouldContinuePropertyHandling( _rPropertyName ) )
+ return;
+
+ impl_markElementEnabledOrDisabled( _rPropertyName, _nElements & PropertyLineElement::InputControl, _bEnable );
+ impl_markElementEnabledOrDisabled( _rPropertyName, _nElements & PropertyLineElement::PrimaryButton, _bEnable );
+ impl_markElementEnabledOrDisabled( _rPropertyName, _nElements & PropertyLineElement::SecondaryButton, _bEnable );
+
+ impl_notifySingleUIChange();
+ }
+
+ //----------------------------------------------------------------
+ void CachedInspectorUI::rebuildPropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ if ( !m_rMaster.shouldContinuePropertyHandling( _rPropertyName ) )
+ return;
+
+ aRebuiltProperties.insert( _rPropertyName );
+
+ impl_notifySingleUIChange();
+ }
+
+ //----------------------------------------------------------------
+ void CachedInspectorUI::showPropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ if ( !m_rMaster.shouldContinuePropertyHandling( _rPropertyName ) )
+ return;
+
+ aShownProperties.insert( _rPropertyName );
+ // if the same category has been hidden before, clear this information, since it's overruled
+ aHiddenProperties.erase( _rPropertyName );
+
+ impl_notifySingleUIChange();
+ }
+
+ //----------------------------------------------------------------
+ void CachedInspectorUI::hidePropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ if ( !m_rMaster.shouldContinuePropertyHandling( _rPropertyName ) )
+ return;
+
+ aHiddenProperties.insert( _rPropertyName );
+ impl_notifySingleUIChange();
+ }
+
+ //----------------------------------------------------------------
+ void CachedInspectorUI::showCategory( const ::rtl::OUString& _rCategory, sal_Bool _bShow ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+
+ lcl_markStringKeyPositiveOrNegative( _rCategory, aShownCategories, aHiddenCategories, _bShow );
+ impl_notifySingleUIChange();
+ }
+
+ //----------------------------------------------------------------
+ Reference< XPropertyControl > SAL_CALL CachedInspectorUI::getPropertyControl( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ if ( !m_rMaster.shouldContinuePropertyHandling( _rPropertyName ) )
+ return Reference< XPropertyControl >();
+
+ return m_rMaster.getDelegatorUI()->getPropertyControl( _rPropertyName );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL CachedInspectorUI::registerControlObserver( const Reference< XPropertyControlObserver >& _Observer ) throw (RuntimeException)
+ {
+ OSL_ENSURE( false, "CachedInspectorUI::registerControlObserver: not expected to be called!" );
+ // CachedInspectorUI is used as context for the controls, and we don't expect them to
+ // register listeners themself
+ m_rMaster.getDelegatorUI()->registerControlObserver( _Observer );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL CachedInspectorUI::revokeControlObserver( const Reference< XPropertyControlObserver >& _Observer ) throw (RuntimeException)
+ {
+ OSL_ENSURE( false, "CachedInspectorUI::revokeControlObserver: not expected to be called!" );
+ // CachedInspectorUI is used as context for the controls, and we don't expect them to
+ // register listeners themself
+ m_rMaster.getDelegatorUI()->revokeControlObserver( _Observer );
+ }
+
+ //----------------------------------------------------------------
+ void SAL_CALL CachedInspectorUI::setHelpSectionText( const ::rtl::OUString& _HelpText ) throw (NoSupportException, RuntimeException)
+ {
+ m_rMaster.getDelegatorUI()->setHelpSectionText( _HelpText );
+ }
+
+ //====================================================================
+ //= HandlerMap
+ //====================================================================
+ typedef ::std::map < Reference< XPropertyHandler >
+ , ::rtl::Reference< CachedInspectorUI >
+ , HandlerLess
+ > ImplMapHandlerToUI;
+ struct MapHandlerToUI
+ {
+ ImplMapHandlerToUI aHandlers;
+ };
+
+ //====================================================================
+ //= ComposedPropertyUIUpdate
+ //====================================================================
+ //----------------------------------------------------------------
+ ComposedPropertyUIUpdate::ComposedPropertyUIUpdate( const Reference< XObjectInspectorUI >& _rxDelegatorUI,
+ IPropertyExistenceCheck* _pPropertyCheck )
+ :m_pCollectedUIs( new MapHandlerToUI )
+ ,m_xDelegatorUI( _rxDelegatorUI )
+ ,m_nSuspendCounter( 0 )
+ ,m_pPropertyCheck( _pPropertyCheck )
+ {
+ if ( !m_xDelegatorUI.is() )
+ throw NullPointerException();
+ }
+
+ //----------------------------------------------------------------
+ ComposedPropertyUIUpdate::~ComposedPropertyUIUpdate( )
+ {
+ }
+
+ //----------------------------------------------------------------
+ Reference< XObjectInspectorUI > ComposedPropertyUIUpdate::getUIForPropertyHandler( const Reference< XPropertyHandler >& _rxHandler )
+ {
+ impl_checkDisposed();
+
+ ::rtl::Reference< CachedInspectorUI >& rUI = m_pCollectedUIs->aHandlers[ _rxHandler ];
+ if ( !rUI.is() )
+ rUI = new CachedInspectorUI( *this, &ComposedPropertyUIUpdate::callback_inspectorUIChanged_throw );
+ return rUI.get();
+ }
+
+ //----------------------------------------------------------------
+ namespace
+ {
+ //============================================================
+ //= StringBagCollector
+ //============================================================
+ /** an STL-compatible structure which collects strings from a CachedInspectorUI instances
+ */
+ struct StringBagCollector : public ::std::unary_function< ImplMapHandlerToUI::value_type, void >
+ {
+ private:
+ StringBag& m_rBag;
+ CachedInspectorUI::FGetStringBag m_pGetter;
+
+ public:
+ StringBagCollector( StringBag& _rBag, CachedInspectorUI::FGetStringBag _pGetter ) :m_rBag( _rBag ), m_pGetter( _pGetter ) { }
+
+ void operator()( const ImplMapHandlerToUI::value_type& _rUI )
+ {
+ StringBag& rBag( ((_rUI.second.get())->*m_pGetter)() );
+ m_rBag.insert( rBag.begin(), rBag.end() );
+ }
+
+ static void collectAll( StringBag& _rAll, const ImplMapHandlerToUI& _rMap, CachedInspectorUI::FGetStringBag _pGetter )
+ {
+ ::std::for_each( _rMap.begin(), _rMap.end(), StringBagCollector( _rAll, _pGetter ) );
+ }
+ };
+
+ //============================================================
+ //= StringBagClearer
+ //============================================================
+ /** an STL-compatible structure which cleans a certain string bag in a CachedInspectorUI instances
+ */
+ struct StringBagClearer : public ::std::unary_function< ImplMapHandlerToUI::value_type, void >
+ {
+ private:
+ CachedInspectorUI::FGetStringBag m_pGetter;
+
+ public:
+ StringBagClearer( CachedInspectorUI::FGetStringBag _pGetter ) :m_pGetter( _pGetter ) { }
+
+ void operator()( const ImplMapHandlerToUI::value_type& _rUI )
+ {
+ clearContainer( ((_rUI.second.get())->*m_pGetter)() );
+ }
+
+ static void clearAll( const ImplMapHandlerToUI& _rMap, CachedInspectorUI::FGetStringBag _pGetter )
+ {
+ ::std::for_each( _rMap.begin(), _rMap.end(), StringBagClearer( _pGetter ) );
+ }
+ };
+
+ //============================================================
+ //= FPropertyUISetter
+ //============================================================
+ /** a typedef for a ->XObjectInspectorUI member function taking a string
+ */
+ typedef void ( SAL_CALL XObjectInspectorUI::*FPropertyUISetter )( const ::rtl::OUString& );
+
+ //============================================================
+ //= PropertyUIOperator
+ //============================================================
+ /** an STL-compatible struct which calls a certain member method (taking a string) at a
+ given ->XObjectInspectorUI instance
+ */
+ struct PropertyUIOperator : public ::std::unary_function< ::rtl::OUString, void >
+ {
+ private:
+ Reference< XObjectInspectorUI > m_xUpdater;
+ FPropertyUISetter m_pSetter;
+
+ public:
+ PropertyUIOperator( const Reference< XObjectInspectorUI >& _rxInspectorUI, FPropertyUISetter _pSetter )
+ :m_xUpdater( _rxInspectorUI )
+ ,m_pSetter( _pSetter )
+ {
+ }
+
+ void operator()( const ::rtl::OUString& _rPropertyName )
+ {
+ ((m_xUpdater.get())->*m_pSetter)( _rPropertyName );
+ }
+
+ static void forEach( const StringBag& _rProperties, const Reference< XObjectInspectorUI >& _rxDelegatorUI, FPropertyUISetter _pSetter )
+ {
+ ::std::for_each( _rProperties.begin(), _rProperties.end(), PropertyUIOperator( _rxDelegatorUI, _pSetter ) );
+ }
+ };
+
+ //============================================================
+ //= IStringKeyBooleanUIUpdate
+ //============================================================
+ /** an interface which encapsulates access to a single aspect of the ->XObjectInspectorUI,
+ where this aspect is given by a string key, and has a boolean value.
+ */
+ class IStringKeyBooleanUIUpdate
+ {
+ public:
+ virtual void updateUIForKey( const ::rtl::OUString& _rKey, sal_Bool _bFlag ) const = 0;
+
+ virtual ~IStringKeyBooleanUIUpdate() { }
+ };
+
+ //============================================================
+ //= FPropertyUIFlagSetter
+ //============================================================
+ /** an implementation of the ->IStringKeyBooleanUIUpdate interface which,
+ for a fixed ->XObjectInspectorUI instance and a fixed UI element (->PropertyLineElement),
+ updates this element for a given property with a given boolean flag
+ (->XObjectInspectorUI::enablePropertyUIElements)
+ */
+ class EnablePropertyUIElement : public IStringKeyBooleanUIUpdate
+ {
+ private:
+ Reference< XObjectInspectorUI > m_xUIUpdate;
+ sal_Int16 m_nElement;
+
+ public:
+ EnablePropertyUIElement( const Reference< XObjectInspectorUI >& _rxUIUpdate, sal_Int16 _nElement )
+ :m_xUIUpdate( _rxUIUpdate )
+ ,m_nElement( _nElement )
+ {
+ }
+ // IStringKeyBooleanUIUpdate
+ virtual void updateUIForKey( const ::rtl::OUString& _rKey, sal_Bool _bFlag ) const;
+ };
+
+ //............................................................
+ void EnablePropertyUIElement::updateUIForKey( const ::rtl::OUString& _rKey, sal_Bool _bFlag ) const
+ {
+ m_xUIUpdate->enablePropertyUIElements( _rKey, m_nElement, _bFlag );
+ }
+
+ //============================================================
+ //= FPropertyUIFlagSetter
+ //============================================================
+ /** a ->XObjectInspectorUI method taking a string and a boolean
+ */
+ typedef void ( SAL_CALL XObjectInspectorUI::*FPropertyUIFlagSetter )( const ::rtl::OUString&, sal_Bool );
+
+ //============================================================
+ //= DefaultStringKeyBooleanUIUpdate
+ //============================================================
+ /** an implementaiton of the ->IStringKeyBooleanUIUpdate interface which calls
+ am arbitrary ->XObjectInspectorUI method taking a string and a boolean flag
+ */
+ class DefaultStringKeyBooleanUIUpdate : public IStringKeyBooleanUIUpdate
+ {
+ private:
+ Reference< XObjectInspectorUI > m_xUIUpdate;
+ FPropertyUIFlagSetter m_pSetter;
+
+ public:
+ DefaultStringKeyBooleanUIUpdate( const Reference< XObjectInspectorUI >& _rxUIUpdate, FPropertyUIFlagSetter _pSetter );
+ // IStringKeyBooleanUIUpdate
+ virtual void updateUIForKey( const ::rtl::OUString& _rKey, sal_Bool _bFlag ) const;
+ };
+
+ //............................................................
+ DefaultStringKeyBooleanUIUpdate::DefaultStringKeyBooleanUIUpdate( const Reference< XObjectInspectorUI >& _rxUIUpdate, FPropertyUIFlagSetter _pSetter )
+ :m_xUIUpdate( _rxUIUpdate )
+ ,m_pSetter( _pSetter )
+ {
+ }
+
+ //............................................................
+ void DefaultStringKeyBooleanUIUpdate::updateUIForKey( const ::rtl::OUString& _rKey, sal_Bool _bFlag ) const
+ {
+ ((m_xUIUpdate.get())->*m_pSetter)( _rKey, _bFlag );
+ }
+
+ //============================================================
+ //= BooleanUIAspectUpdate
+ //============================================================
+ /** an STL-compatible structure which applies a ->IStringKeyBooleanUIUpdate::updateUIForKey
+ operation with a fixed boolean value, for a given string value
+ */
+ struct BooleanUIAspectUpdate : public ::std::unary_function< ::rtl::OUString, void >
+ {
+ private:
+ const IStringKeyBooleanUIUpdate& m_rUpdater;
+ sal_Bool m_bFlag;
+
+ public:
+ BooleanUIAspectUpdate( const IStringKeyBooleanUIUpdate& _rUpdater, sal_Bool _bFlag )
+ :m_rUpdater( _rUpdater )
+ ,m_bFlag( _bFlag )
+ {
+ }
+
+ void operator()( const ::rtl::OUString& _rPropertyName )
+ {
+ m_rUpdater.updateUIForKey( _rPropertyName, m_bFlag );
+ }
+
+ static void forEach( const StringBag& _rProperties, const IStringKeyBooleanUIUpdate& _rUpdater, sal_Bool _bFlag )
+ {
+ ::std::for_each( _rProperties.begin(), _rProperties.end(), BooleanUIAspectUpdate( _rUpdater, _bFlag ) );
+ }
+ };
+
+ //============================================================
+ //= BooleanUIAspectUpdate
+ //============================================================
+ /** an STL-compatible structure subtracting a given string from a fixed ->StringBag
+ */
+ struct StringBagComplement : public ::std::unary_function< ::rtl::OUString, void >
+ {
+ private:
+ StringBag& m_rMinuend;
+
+ public:
+ StringBagComplement( StringBag& _rMinuend ) :m_rMinuend( _rMinuend ) { }
+
+ void operator()( const ::rtl::OUString& _rPropertyToSubtract )
+ {
+ m_rMinuend.erase( _rPropertyToSubtract );
+ }
+
+ static void subtract( StringBag& _rMinuend, const StringBag& _rSubtrahend )
+ {
+ ::std::for_each( _rSubtrahend.begin(), _rSubtrahend.end(), StringBagComplement( _rMinuend ) );
+ }
+ };
+
+ //============================================================
+ //= BooleanUIAspectUpdate
+ //============================================================
+ void lcl_fireUIStateFlag(
+ const IStringKeyBooleanUIUpdate& _rUIUpdate,
+ const ImplMapHandlerToUI& _rHandlerUIs,
+ CachedInspectorUI::FGetStringBag _pGetPositives,
+ CachedInspectorUI::FGetStringBag _pGetNegatives
+ )
+ {
+ // all strings which are in the "positive" list of one handler
+ StringBag aAllPositives;
+ StringBagCollector::collectAll( aAllPositives, _rHandlerUIs, _pGetPositives );
+
+ // all strings which are in the "negative" list of one handler
+ StringBag aAllNegatives;
+ StringBagCollector::collectAll( aAllNegatives, _rHandlerUIs, _pGetNegatives );
+
+ // propagate the "negative" flags to the delegator UI
+ BooleanUIAspectUpdate::forEach( aAllNegatives, _rUIUpdate, sal_False );
+
+ // propagate the "positive" flags to the delegator UI, for all elements where _no_
+ // "negative" flag exists
+ StringBagComplement::subtract( aAllPositives, aAllNegatives );
+ BooleanUIAspectUpdate::forEach( aAllPositives, _rUIUpdate, sal_True );
+
+ // the "positive" request can be cleared no, only negative requests
+ // (such as "disable a property" or "hide a category") need to be preserved for the next round
+ StringBagClearer::clearAll( _rHandlerUIs, _pGetPositives );
+ }
+ }
+
+ //----------------------------------------------------------------
+ void ComposedPropertyUIUpdate::impl_fireEnablePropertyUI_throw()
+ {
+ lcl_fireUIStateFlag(
+ DefaultStringKeyBooleanUIUpdate( m_xDelegatorUI, &XObjectInspectorUI::enablePropertyUI ),
+ m_pCollectedUIs->aHandlers,
+ &CachedInspectorUI::getEnabledProperties,
+ &CachedInspectorUI::getDisabledProperties
+ );
+ }
+
+ //----------------------------------------------------------------
+ void ComposedPropertyUIUpdate::impl_fireRebuildPropertyUI_throw()
+ {
+ // collect all properties for which a rebuild request has been made
+ StringBag aAllRebuilt;
+ StringBagCollector::collectAll( aAllRebuilt, m_pCollectedUIs->aHandlers, &CachedInspectorUI::getRebuiltProperties );
+
+ // rebuild all those properties
+ PropertyUIOperator::forEach( aAllRebuilt, m_xDelegatorUI, &XObjectInspectorUI::rebuildPropertyUI );
+
+ // clear the "properties to rebuild" at all handlers, since the request has been fulfilled now.
+ StringBagClearer::clearAll( m_pCollectedUIs->aHandlers, &CachedInspectorUI::getRebuiltProperties );
+ }
+
+ //----------------------------------------------------------------
+ void ComposedPropertyUIUpdate::impl_fireShowHidePropertyUI_throw()
+ {
+ // all properties which have been shown by at least one handler
+ StringBag aAllShown;
+ StringBagCollector::collectAll( aAllShown, m_pCollectedUIs->aHandlers, &CachedInspectorUI::getShownProperties );
+ // all properties which have been hidden by at least one handler
+ StringBag aAllHidden;
+ StringBagCollector::collectAll( aAllHidden, m_pCollectedUIs->aHandlers, &CachedInspectorUI::getHiddenProperties );
+
+ // hide properties as necessary
+ PropertyUIOperator::forEach( aAllHidden, m_xDelegatorUI, &XObjectInspectorUI::hidePropertyUI );
+
+ // for those properties which are hidden, ignore all "show" requests which other handlers might have had
+ StringBagComplement::subtract( aAllShown, aAllHidden );
+
+ // show properties
+ PropertyUIOperator::forEach( aAllShown, m_xDelegatorUI, &XObjectInspectorUI::showPropertyUI );
+ }
+
+ //----------------------------------------------------------------
+ void ComposedPropertyUIUpdate::impl_fireShowCategory_throw()
+ {
+ lcl_fireUIStateFlag(
+ DefaultStringKeyBooleanUIUpdate( m_xDelegatorUI, &XObjectInspectorUI::showCategory ),
+ m_pCollectedUIs->aHandlers,
+ &CachedInspectorUI::getShownCategories,
+ &CachedInspectorUI::getHiddenCategories
+ );
+ }
+
+ //----------------------------------------------------------------
+ void ComposedPropertyUIUpdate::impl_fireEnablePropertyUIElements_throw()
+ {
+ lcl_fireUIStateFlag(
+ EnablePropertyUIElement( m_xDelegatorUI, PropertyLineElement::InputControl ),
+ m_pCollectedUIs->aHandlers,
+ &CachedInspectorUI::getEnabledInputControls,
+ &CachedInspectorUI::getDisabledInputControls
+ );
+
+ lcl_fireUIStateFlag(
+ EnablePropertyUIElement( m_xDelegatorUI, PropertyLineElement::PrimaryButton ),
+ m_pCollectedUIs->aHandlers,
+ &CachedInspectorUI::getEnabledPrimaryButtons,
+ &CachedInspectorUI::getDisabledPrimaryButtons
+ );
+
+ lcl_fireUIStateFlag(
+ EnablePropertyUIElement( m_xDelegatorUI, PropertyLineElement::SecondaryButton ),
+ m_pCollectedUIs->aHandlers,
+ &CachedInspectorUI::getEnabledSecondaryButtons,
+ &CachedInspectorUI::getDisabledSecondaryButtons
+ );
+ }
+
+ //--------------------------------------------------------------------
+ void ComposedPropertyUIUpdate::impl_fireAll_throw()
+ {
+ OSL_PRECOND( !impl_isDisposed(), "ComposedPropertyUIUpdate::impl_fireAll_throw: already disposed, this will crash!" );
+
+ impl_fireEnablePropertyUI_throw();
+ impl_fireShowHidePropertyUI_throw();
+ impl_fireRebuildPropertyUI_throw();
+ impl_fireShowCategory_throw();
+ impl_fireEnablePropertyUIElements_throw();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ComposedPropertyUIUpdate::suspendAutoFire()
+ {
+ impl_checkDisposed();
+ osl_incrementInterlockedCount( &m_nSuspendCounter );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ComposedPropertyUIUpdate::resumeAutoFire()
+ {
+ impl_checkDisposed();
+ if ( 0 == osl_decrementInterlockedCount( &m_nSuspendCounter ) )
+ impl_fireAll_throw();
+ }
+
+ //----------------------------------------------------------------
+ void ComposedPropertyUIUpdate::impl_checkDisposed() const
+ {
+ if ( impl_isDisposed() )
+ throw DisposedException();
+ }
+
+ //----------------------------------------------------------------
+ void ComposedPropertyUIUpdate::callback_inspectorUIChanged_throw()
+ {
+ if ( 0 == m_nSuspendCounter )
+ impl_fireAll_throw();
+ }
+
+ //----------------------------------------------------------------
+ Reference< XObjectInspectorUI > ComposedPropertyUIUpdate::getDelegatorUI() const
+ {
+ impl_checkDisposed();
+ return m_xDelegatorUI;
+ }
+
+ //----------------------------------------------------------------
+ void SAL_CALL ComposedPropertyUIUpdate::dispose()
+ {
+ if ( impl_isDisposed() )
+ return;
+
+ OSL_ENSURE( m_nSuspendCounter == 0, "ComposedPropertyUIUpdate::dispose: still suspended, the changes will be lost!" );
+
+ for ( ImplMapHandlerToUI::const_iterator singleUI = m_pCollectedUIs->aHandlers.begin();
+ singleUI != m_pCollectedUIs->aHandlers.end();
+ ++singleUI
+ )
+ {
+ singleUI->second->dispose();
+ }
+ m_pCollectedUIs.reset( NULL );
+ m_xDelegatorUI.set( NULL );
+ }
+
+ //----------------------------------------------------------------
+ bool ComposedPropertyUIUpdate::shouldContinuePropertyHandling( const ::rtl::OUString& _rName ) const
+ {
+ if ( !m_pPropertyCheck )
+ return true;
+ if ( m_pPropertyCheck->hasPropertyByName( _rName ) )
+ return true;
+ return false;
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
diff --git a/extensions/source/propctrlr/composeduiupdate.hxx b/extensions/source/propctrlr/composeduiupdate.hxx
new file mode 100644
index 000000000000..d9ae3e0aa76e
--- /dev/null
+++ b/extensions/source/propctrlr/composeduiupdate.hxx
@@ -0,0 +1,231 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_COMPOSEDUIUPDATE_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_COMPOSEDUIUPDATE_HXX
+
+#include "propertyhandler.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+/** === end UNO includes === **/
+
+#include <map>
+#include <set>
+#include <memory>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= some helper types
+ //====================================================================
+
+ struct MapHandlerToUI;
+
+ /** callback for an ComposedPropertyUIUpdate checking a given property for existence
+ */
+ class SAL_NO_VTABLE IPropertyExistenceCheck
+ {
+ public:
+ virtual ::sal_Bool SAL_CALL hasPropertyByName( const ::rtl::OUString& _rName ) throw (::com::sun::star::uno::RuntimeException) = 0;
+ };
+
+ //====================================================================
+ //= ComposedPropertyUIUpdate
+ //====================================================================
+ /** helper class composing requests to a ->XObjectInspectorUI interface, coming
+ from multiple sources
+
+ Usually, a handler tells the browser UI to enable to disable, or show or hide, certain
+ elements. Now when multiple handlers do this, their instructions must be combined:
+ If one handler disables a certain element, but others enable it, it must in the
+ result still be disabled. Similar for showing/hiding elements.
+
+ ->ComposedPropertyUIUpdate implements this combination. It does so by providing a dedicated
+ ->XObjectInspectorUI instance for every participating handler, and remembering the UI
+ state on a per-handler basis. Upon request (->fire), the combined UI state is
+ forwarded to another ->XObjectInspectorUI instance, the so-called delegator UI.
+ */
+ class ComposedPropertyUIUpdate
+ {
+ private:
+ ::std::auto_ptr< MapHandlerToUI > m_pCollectedUIs;
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >
+ m_xDelegatorUI;
+ oslInterlockedCount m_nSuspendCounter;
+ IPropertyExistenceCheck* m_pPropertyCheck;
+
+ public:
+ /** constructs a ->ComposedPropertyUIUpdate instance
+ @param _rxDelegatorUI
+ a ->XObjectInspectorUI instance to which composed UI requests should be forwarded. Must
+ not be <NULL/>.
+ @param _pPropertyCheck
+ an instance checking properties for existence. If this is not <NULL/>, it will be invoked
+ whenever one of the ->XObjectInspectorUI methods is called, to check the passed property
+ name.<br/>
+ Beware of lifetime issues. The instance pointed to by <arg>_pPropertyCheck</arg> must
+ live at least as long as the ->ComposedPropertyUIUpdate instance you're going to create.
+ @throws ::com::sun::star::lang::NullPointerException
+ if ->_rxDelegatorUI is <NULL/>
+ */
+ ComposedPropertyUIUpdate(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxDelegatorUI,
+ IPropertyExistenceCheck* _pPropertyCheck );
+ ~ComposedPropertyUIUpdate();
+
+ /** returns the delegator UI
+ @throw ::com::sun::star::lang::DisposedException
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI > getDelegatorUI() const;
+
+ /** returns a ->XObjectInspectorUI instance belonging to a given property handler
+
+ In every call to an ->XPropertyHandler method which requires a ->XObjectInspectorUI,
+ the same UI instance should be used. The instance here will cache all requests passed
+ to it, and ->ComposedPropertyUIUpdate::fire will use the combination of all
+ cached UI states of all handlers to update the delegator UI.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >
+ getUIForPropertyHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler >& _rxHandler );
+
+ /** Suspends automatic firing of UI changes
+
+ normally, as soon as any of the property handlers does a request for an
+ arbitrary UI change, the set of collected UI changes is evaluated, and the combined
+ UI state is fired to the delegator UI.
+
+ You can disable this automatic firing by calling ->suspendAutoFire. As longs as auto
+ firing is suspended, only explicit ->fire calls trigger the notification to the
+ delegator UI.
+
+ Note that calls to ->suspendAutoFire are culmulative, that is, if you make multiple calls
+ they must be accompanied by an equal number of calls to ->resumeAutoFire, to enable
+ auto-firing again.
+
+ @seealso resumeAutoFire
+ */
+ void SAL_CALL suspendAutoFire();
+
+ /** Suspends automatic firing of UI changes
+
+ @seealso suspendAutoFire
+ */
+ void SAL_CALL resumeAutoFire();
+
+ /** disposes the instance, so it becomes non-functional.
+
+ All cached handlers and cached ->XObjectInspectorUI instances will be released,
+ the latter will also be disposed, so that if anybody still holds a reference to them
+ and tries to operate them will get a DisposedException.
+ */
+ void SAL_CALL dispose();
+
+ /** invokes m_pPropertyCheck to check whether a given property should be handled
+ */
+ bool shouldContinuePropertyHandling( const ::rtl::OUString& _rName ) const;
+
+ private:
+ /// determines whether the instance is already disposed
+ inline bool impl_isDisposed() const { return m_pCollectedUIs.get() == NULL; }
+
+ /// throws an exception if the component is already disposed
+ void impl_checkDisposed() const;
+
+ /** fires the collected UI changes to our delegator UI
+
+ All operations for any elements are forwarded:
+ <ul><li>If an element has been hidden at least once, it's also hidden at the delegator UI.</li>
+ <li>If an element has been shown at least once, and never been hidden, it's also
+ shown at the delegator UI.</li>
+ <li>If an element has never been shown or hidden, it's also not touched at the delegator UI.</li>
+ <li>The same holds if you replace "hidden" in the last three items with "disabled",
+ and "shown" with "enabled".</li>
+ <li>If an element should have been rebuilt (->XObjectInspectorUI::rebuiltPropertyUI)
+ at least once, it's rebuilt at the delegator UI, too.<br/>
+ After that, the request to rebuild the UI for this property is cleared, so subsequent
+ calls to ->fire will not trigger an new rebuilt request.
+ </ul>
+
+ @precond
+ instance is not disposed
+ */
+ void impl_fireAll_throw();
+
+ /// fires the combination of ->XObjectInspectorUI::enablePropertyUI calls
+ void impl_fireEnablePropertyUI_throw();
+
+ /// fires the combination of ->XObjectInspectorUI::enablePropertyUIElements calls
+ void impl_fireEnablePropertyUIElements_throw();
+
+ /// fires the combination of ->XObjectInspectorUI::rebuildPropertyUI calls
+ void impl_fireRebuildPropertyUI_throw();
+
+ /// fires the combination of ->XObjectInspectorUI::showPropertyUI and ->XObjectInspectorUI::hidePropertyUI calls
+ void impl_fireShowHidePropertyUI_throw();
+
+ /// fires the combination of ->XObjectInspectorUI::showCategory calls
+ void impl_fireShowCategory_throw();
+
+ /** callback for when a single property handler requested any change in the inspector UI
+ */
+ void callback_inspectorUIChanged_throw();
+
+ private:
+ ComposedPropertyUIUpdate(); // never implemented
+ ComposedPropertyUIUpdate( const ComposedPropertyUIUpdate& ); // never implemented
+ ComposedPropertyUIUpdate& operator=( const ComposedPropertyUIUpdate& ); // never implemented
+ };
+
+ //====================================================================
+ //= ComposedUIAutoFireGuard
+ //====================================================================
+ class ComposedUIAutoFireGuard
+ {
+ private:
+ ComposedPropertyUIUpdate& m_rUIUpdate;
+ public:
+ ComposedUIAutoFireGuard( ComposedPropertyUIUpdate& _rUIUpdate )
+ :m_rUIUpdate( _rUIUpdate )
+ {
+ m_rUIUpdate.suspendAutoFire();
+ }
+ ~ComposedUIAutoFireGuard()
+ {
+ m_rUIUpdate.resumeAutoFire();
+ }
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_COMPOSEDUIUPDATE_HXX
+
diff --git a/extensions/source/propctrlr/controlfontdialog.cxx b/extensions/source/propctrlr/controlfontdialog.cxx
new file mode 100644
index 000000000000..856e27dc4bc9
--- /dev/null
+++ b/extensions/source/propctrlr/controlfontdialog.cxx
@@ -0,0 +1,177 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#ifndef _EXTENSIONS_PROPCTRLR_FONTITEMIDS_HXX_
+#include "controlfontdialog.hxx"
+#endif
+#include <cppuhelper/typeprovider.hxx>
+#include "fontdialog.hxx"
+#include "formstrings.hxx"
+#include "pcrcommon.hxx"
+
+extern "C" void SAL_CALL createRegistryInfo_OControlFontDialog()
+{
+ ::pcr::OAutoRegistration< ::pcr::OControlFontDialog > aAutoRegistration;
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+
+ //====================================================================
+ //= OControlFontDialog
+ //====================================================================
+ //---------------------------------------------------------------------
+ OControlFontDialog::OControlFontDialog(const Reference< XComponentContext >& _rxContext )
+ :OGenericUnoDialog( _rxContext )
+ ,m_pFontItems(NULL)
+ ,m_pItemPool(NULL)
+ ,m_pItemPoolDefaults(NULL)
+ {
+ registerProperty(PROPERTY_INTROSPECTEDOBJECT, OWN_PROPERTY_ID_INTROSPECTEDOBJECT,
+ PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT,
+ &m_xControlModel, ::getCppuType(&m_xControlModel));
+ }
+
+ //---------------------------------------------------------------------
+ OControlFontDialog::~OControlFontDialog()
+ {
+ if (m_pDialog)
+ {
+ ::osl::MutexGuard aGuard(m_aMutex);
+ if (m_pDialog)
+ destroyDialog();
+ }
+ }
+
+ //---------------------------------------------------------------------
+ Sequence<sal_Int8> SAL_CALL OControlFontDialog::getImplementationId( ) throw(RuntimeException)
+ {
+ static ::cppu::OImplementationId aId;
+ return aId.getImplementationId();
+ }
+
+ //---------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL OControlFontDialog::Create( const Reference< XComponentContext >& _rxContext )
+ {
+ return *( new OControlFontDialog( _rxContext ) );
+ }
+
+ //---------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL OControlFontDialog::getImplementationName() throw(RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //---------------------------------------------------------------------
+ ::rtl::OUString OControlFontDialog::getImplementationName_static() throw(RuntimeException)
+ {
+ return ::rtl::OUString::createFromAscii("org.openoffice.comp.form.ui.OControlFontDialog");
+ }
+
+ //---------------------------------------------------------------------
+ ::comphelper::StringSequence SAL_CALL OControlFontDialog::getSupportedServiceNames() throw(RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //---------------------------------------------------------------------
+ ::comphelper::StringSequence OControlFontDialog::getSupportedServiceNames_static() throw(RuntimeException)
+ {
+ ::comphelper::StringSequence aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.form.ControlFontDialog");
+ return aSupported;
+ }
+
+ //---------------------------------------------------------------------
+ Reference<XPropertySetInfo> SAL_CALL OControlFontDialog::getPropertySetInfo() throw(RuntimeException)
+ {
+ Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+ }
+
+ //---------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper& OControlFontDialog::getInfoHelper()
+ {
+ return *const_cast<OControlFontDialog*>(this)->getArrayHelper();
+ }
+
+ //--------------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper* OControlFontDialog::createArrayHelper( ) const
+ {
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+ }
+
+ //--------------------------------------------------------------------------
+ Dialog* OControlFontDialog::createDialog(Window* _pParent)
+ {
+ ControlCharacterDialog::createItemSet(m_pFontItems, m_pItemPool, m_pItemPoolDefaults);
+
+ OSL_ENSURE(m_xControlModel.is(), "OControlFontDialog::createDialog: no introspectee set!");
+ if (m_xControlModel.is())
+ ControlCharacterDialog::translatePropertiesToItems(m_xControlModel, m_pFontItems);
+ // TODO: we need a mechanism to prevent that somebody creates us, sets an introspectee, executes us,
+ // sets a new introspectee and re-executes us. In this case, the dialog returned here (upon the first
+ // execute) will be re-used upon the second execute, and thus it won't be initialized correctly.
+
+ ControlCharacterDialog* pDialog = new ControlCharacterDialog(_pParent, *m_pFontItems);
+ return pDialog;
+ }
+
+ //-------------------------------------------------------------------------
+ void OControlFontDialog::destroyDialog()
+ {
+ OGenericUnoDialog::destroyDialog();
+ ControlCharacterDialog::destroyItemSet(m_pFontItems, m_pItemPool, m_pItemPoolDefaults);
+ }
+
+ //-------------------------------------------------------------------------
+ void OControlFontDialog::executedDialog(sal_Int16 _nExecutionResult)
+ {
+ OSL_ENSURE(m_pDialog, "OControlFontDialog::executedDialog: no dialog anymore?!!");
+ if (m_pDialog && (sal_True == _nExecutionResult) && m_xControlModel.is())
+ {
+ const SfxItemSet* pOutput = static_cast<ControlCharacterDialog*>(m_pDialog)->GetOutputItemSet();
+ if (pOutput)
+ ControlCharacterDialog::translateItemsToProperties( *pOutput, m_xControlModel );
+ }
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
diff --git a/extensions/source/propctrlr/controlfontdialog.hxx b/extensions/source/propctrlr/controlfontdialog.hxx
new file mode 100644
index 000000000000..a681870e134b
--- /dev/null
+++ b/extensions/source/propctrlr/controlfontdialog.hxx
@@ -0,0 +1,100 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_CONTROLFONTDIALOG_HXX_
+#define _EXTENSIONS_PROPCTRLR_CONTROLFONTDIALOG_HXX_
+
+#include <svtools/genericunodialog.hxx>
+#include "modulepcr.hxx"
+
+class SfxItemSet;
+class SfxItemPool;
+class SfxPoolItem;
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= OControlFontDialog
+ //====================================================================
+ class OControlFontDialog;
+ typedef ::svt::OGenericUnoDialog OControlFontDialog_DBase;
+ typedef ::comphelper::OPropertyArrayUsageHelper< OControlFontDialog > OControlFontDialog_PBase;
+
+ class OControlFontDialog
+ :public OControlFontDialog_DBase
+ ,public OControlFontDialog_PBase
+ ,public PcrClient
+ {
+ protected:
+ // <properties>
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xControlModel;
+ // </properties>
+
+ SfxItemSet* m_pFontItems; // item set for the dialog
+ SfxItemPool* m_pItemPool; // item pool for the item set for the dialog
+ SfxPoolItem** m_pItemPoolDefaults; // pool defaults
+
+ public:
+ OControlFontDialog(const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& _rxContext);
+ ~OControlFontDialog();
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo - static methods
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::rtl::OUString getImplementationName_static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >&);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ protected:
+ // OGenericUnoDialog overridables
+ virtual Dialog* createDialog(Window* _pParent);
+ virtual void destroyDialog();
+ virtual void executedDialog(sal_Int16 _nExecutionResult);
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_CONTROLFONTDIALOG_HXX_
+
diff --git a/extensions/source/propctrlr/controltype.hxx b/extensions/source/propctrlr/controltype.hxx
new file mode 100644
index 000000000000..03dc5455c2ce
--- /dev/null
+++ b/extensions/source/propctrlr/controltype.hxx
@@ -0,0 +1,54 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_CONTROLTYPE_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_CONTROLTYPE_HXX
+
+#include <sal/types.h>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= control types, analogous to FormComponentType
+ //====================================================================
+ namespace ControlType
+ {
+ static const sal_Int16 FIXEDLINE = (sal_Int16)100;
+ static const sal_Int16 FORMATTEDFIELD = (sal_Int16)101;
+ static const sal_Int16 PROGRESSBAR = (sal_Int16)102;
+
+ // need only those which are not already covered as FormComponentType
+ }
+
+//........................................................................
+} // namespacepcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_CONTROLTYPE_HXX
+
diff --git a/extensions/source/propctrlr/defaultforminspection.cxx b/extensions/source/propctrlr/defaultforminspection.cxx
new file mode 100644
index 000000000000..f3014d7d2e57
--- /dev/null
+++ b/extensions/source/propctrlr/defaultforminspection.cxx
@@ -0,0 +1,270 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "defaultforminspection.hxx"
+#include "pcrcommon.hxx"
+#ifndef EXTENSIONS_PROPRESID_HRC
+#include "propresid.hrc"
+#endif
+#ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
+#include "formresid.hrc"
+#endif
+#ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
+#include "modulepcr.hxx"
+#endif
+#include "propctrlr.hrc"
+#include "formmetadata.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/ucb/AlreadyInitializedException.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+/** === end UNO includes === **/
+#include <cppuhelper/implbase1.hxx>
+#include <osl/diagnose.h>
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_DefaultFormComponentInspectorModel()
+{
+ ::pcr::OAutoRegistration< ::pcr::DefaultFormComponentInspectorModel > aAutoRegistration;
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::inspection::PropertyCategoryDescriptor;
+ using ::com::sun::star::beans::UnknownPropertyException;
+ using ::com::sun::star::ucb::AlreadyInitializedException;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= DefaultFormComponentInspectorModel
+ //====================================================================
+ //--------------------------------------------------------------------
+ DefaultFormComponentInspectorModel::DefaultFormComponentInspectorModel( const Reference< XComponentContext >& _rxContext, bool _bUseFormFormComponentHandlers )
+ :ImplInspectorModel( _rxContext )
+ ,m_bUseFormComponentHandlers( _bUseFormFormComponentHandlers )
+ ,m_bConstructed( false )
+ ,m_pInfoService( new OPropertyInfoService )
+ {
+ }
+
+ //------------------------------------------------------------------------
+ DefaultFormComponentInspectorModel::~DefaultFormComponentInspectorModel()
+ {
+ }
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL DefaultFormComponentInspectorModel::getImplementationName( ) throw(RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL DefaultFormComponentInspectorModel::getSupportedServiceNames( ) throw(RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString DefaultFormComponentInspectorModel::getImplementationName_static( ) throw(RuntimeException)
+ {
+ return ::rtl::OUString::createFromAscii( "org.openoffice.comp.extensions.DefaultFormComponentInspectorModel");
+ }
+
+ //------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > DefaultFormComponentInspectorModel::getSupportedServiceNames_static( ) throw(RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported(1);
+ aSupported[0] = ::rtl::OUString::createFromAscii( "com.sun.star.form.inspection.DefaultFormComponentInspectorModel" );
+ return aSupported;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL DefaultFormComponentInspectorModel::Create( const Reference< XComponentContext >& _rxContext )
+ {
+ return *new DefaultFormComponentInspectorModel( _rxContext );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Any > SAL_CALL DefaultFormComponentInspectorModel::getHandlerFactories() throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ // service names for all our handlers
+ struct
+ {
+ const sal_Char* serviceName;
+ bool isFormOnly;
+ } aFactories[] = {
+
+ // a generic handler for form component properties (must precede the ButtonNavigationHandler)
+ { "com.sun.star.form.inspection.FormComponentPropertyHandler", false },
+
+ // generic virtual edit properties
+ { "com.sun.star.form.inspection.EditPropertyHandler", false },
+
+ // a handler which virtualizes the ButtonType property, to provide additional types like
+ // "move to next record"
+ { "com.sun.star.form.inspection.ButtonNavigationHandler", false },
+
+ // a handler for script events bound to form components or dialog elements
+ { "com.sun.star.form.inspection.EventHandler", false },
+
+ // a handler which introduces virtual properties for binding controls to spreadsheet cells
+ { "com.sun.star.form.inspection.CellBindingPropertyHandler", true },
+
+ // properties related to binding to an XForms DOM node
+ { "com.sun.star.form.inspection.XMLFormsPropertyHandler", true },
+
+ // properties related to the XSD data against which a control content is validated
+ { "com.sun.star.form.inspection.XSDValidationPropertyHandler", true },
+
+ // a handler which cares for XForms submissions
+ { "com.sun.star.form.inspection.SubmissionPropertyHandler", true },
+
+ // a handler which cares for geometry properties of form controls
+ { "com.sun.star.form.inspection.FormGeometryHandler", true }
+ };
+
+ sal_Int32 nFactories = sizeof( aFactories ) / sizeof( aFactories[ 0 ] );
+ Sequence< Any > aReturn( nFactories );
+ Any* pReturn = aReturn.getArray();
+ for ( sal_Int32 i = 0; i < nFactories; ++i )
+ {
+ if ( aFactories[i].isFormOnly && !m_bUseFormComponentHandlers )
+ continue;
+ *pReturn++ <<= ::rtl::OUString::createFromAscii( aFactories[i].serviceName );
+ }
+ aReturn.realloc( pReturn - aReturn.getArray() );
+
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< PropertyCategoryDescriptor > SAL_CALL DefaultFormComponentInspectorModel::describeCategories( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ struct
+ {
+ const sal_Char* programmaticName;
+ sal_uInt16 uiNameResId;
+ const sal_Char* helpId;
+ } aCategories[] = {
+ { "General", RID_STR_PROPPAGE_DEFAULT, HID_FM_PROPDLG_TAB_GENERAL },
+ { "Data", RID_STR_PROPPAGE_DATA, HID_FM_PROPDLG_TAB_DATA },
+ { "Events", RID_STR_EVENTS, HID_FM_PROPDLG_TAB_EVT }
+ };
+
+ sal_Int32 nCategories = sizeof( aCategories ) / sizeof( aCategories[0] );
+ Sequence< PropertyCategoryDescriptor > aReturn( nCategories );
+ PropertyCategoryDescriptor* pReturn = aReturn.getArray();
+ for ( sal_Int32 i=0; i<nCategories; ++i, ++pReturn )
+ {
+ pReturn->ProgrammaticName = ::rtl::OUString::createFromAscii( aCategories[i].programmaticName );
+ pReturn->UIName = String( PcrRes( aCategories[i].uiNameResId ) );
+ pReturn->HelpURL = HelpIdUrl::getHelpURL( aCategories[i].helpId );
+ }
+
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Int32 SAL_CALL DefaultFormComponentInspectorModel::getPropertyOrderIndex( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException)
+ {
+ sal_Int32 nPropertyId( m_pInfoService->getPropertyId( _rPropertyName ) );
+ if ( nPropertyId == -1 )
+ {
+ if ( _rPropertyName.indexOf( ';' ) != -1 )
+ // it's an event. Just give it an arbitrary number - events will be on a separate
+ // page, and by definition, if two properties have the same OrderIndex, then
+ // they will be ordered as they appear in the handler's getSupportedProperties.
+ return 1000;
+ return 0;
+ }
+ return m_pInfoService->getPropertyPos( nPropertyId );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DefaultFormComponentInspectorModel::initialize( const Sequence< Any >& _arguments ) throw (Exception, RuntimeException)
+ {
+ if ( m_bConstructed )
+ throw AlreadyInitializedException();
+
+ StlSyntaxSequence< Any > arguments( _arguments );
+ if ( arguments.empty() )
+ { // constructor: "createDefault()"
+ createDefault();
+ return;
+ }
+
+ sal_Int32 nMinHelpTextLines( 0 ), nMaxHelpTextLines( 0 );
+ if ( arguments.size() == 2 )
+ { // constructor: "createWithHelpSection( long, long )"
+ if ( !( arguments[0] >>= nMinHelpTextLines ) || !( arguments[1] >>= nMaxHelpTextLines ) )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
+ createWithHelpSection( nMinHelpTextLines, nMaxHelpTextLines );
+ return;
+ }
+
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
+ }
+
+ //--------------------------------------------------------------------
+ void DefaultFormComponentInspectorModel::createDefault()
+ {
+ m_bConstructed = true;
+ }
+
+ //--------------------------------------------------------------------
+ void DefaultFormComponentInspectorModel::createWithHelpSection( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines )
+ {
+ if ( ( _nMinHelpTextLines <= 0 ) || ( _nMaxHelpTextLines <= 0 ) || ( _nMinHelpTextLines > _nMaxHelpTextLines ) )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
+
+ enableHelpSectionProperties( _nMinHelpTextLines, _nMaxHelpTextLines );
+ m_bConstructed = true;
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
diff --git a/extensions/source/propctrlr/defaultforminspection.hxx b/extensions/source/propctrlr/defaultforminspection.hxx
new file mode 100644
index 000000000000..53d06e6b5579
--- /dev/null
+++ b/extensions/source/propctrlr/defaultforminspection.hxx
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_DEFAULTFORMINSPECTION_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_DEFAULTFORMINSPECTION_HXX
+
+#include "inspectormodelbase.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <memory>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ class OPropertyInfoService;
+ //====================================================================
+ //= DefaultFormComponentInspectorModel
+ //====================================================================
+ class DefaultFormComponentInspectorModel : public ImplInspectorModel
+ {
+ private:
+ bool m_bUseFormComponentHandlers;
+ bool m_bConstructed;
+
+ /// access to property meta data
+ ::std::auto_ptr< OPropertyInfoService > m_pInfoService;
+
+ protected:
+ ~DefaultFormComponentInspectorModel();
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XObjectInspectorModel
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getHandlerFactories() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::inspection::PropertyCategoryDescriptor > SAL_CALL describeCategories( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getPropertyOrderIndex( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ public:
+ // XServiceInfo - static versions
+ static ::rtl::OUString getImplementationName_static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+ Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
+
+ public:
+ DefaultFormComponentInspectorModel( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext, bool _bUseFormFormComponentHandlers = true );
+
+ protected:
+ // Service constructors
+ void createDefault();
+ void createWithHelpSection( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines );
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_DEFAULTFORMINSPECTION_HXX
+
diff --git a/extensions/source/propctrlr/defaulthelpprovider.cxx b/extensions/source/propctrlr/defaulthelpprovider.cxx
new file mode 100644
index 000000000000..30df724728bc
--- /dev/null
+++ b/extensions/source/propctrlr/defaulthelpprovider.cxx
@@ -0,0 +1,206 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "defaulthelpprovider.hxx"
+#include "pcrcommon.hxx"
+#include "modulepcr.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/ucb/AlreadyInitializedException.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/awt/XVclWindowPeer.hpp>
+/** === end UNO includes === **/
+
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/window.hxx>
+#include <tools/diagnose_ex.h>
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_DefaultHelpProvider()
+{
+ ::pcr::OAutoRegistration< ::pcr::DefaultHelpProvider > aAutoRegistration;
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::inspection::XPropertyControl;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::inspection::XObjectInspectorUI;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::ucb::AlreadyInitializedException;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::awt::XWindow;
+ using ::com::sun::star::awt::XVclWindowPeer;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= DefaultHelpProvider
+ //====================================================================
+ //--------------------------------------------------------------------
+ DefaultHelpProvider::DefaultHelpProvider( const Reference< XComponentContext >& _rxContext )
+ :m_aContext( _rxContext )
+ ,m_bConstructed( false )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ DefaultHelpProvider::~DefaultHelpProvider()
+ {
+ }
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString DefaultHelpProvider::getImplementationName_static( ) throw(RuntimeException)
+ {
+ return ::rtl::OUString::createFromAscii( "org.openoffice.comp.extensions.DefaultHelpProvider");
+ }
+
+ //------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > DefaultHelpProvider::getSupportedServiceNames_static( ) throw(RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported(1);
+ aSupported[0] = ::rtl::OUString::createFromAscii( "com.sun.star.inspection.DefaultHelpProvider" );
+ return aSupported;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL DefaultHelpProvider::Create( const Reference< XComponentContext >& _rxContext )
+ {
+ return *new DefaultHelpProvider( _rxContext );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DefaultHelpProvider::focusGained( const Reference< XPropertyControl >& _Control ) throw (RuntimeException)
+ {
+ if ( !m_xInspectorUI.is() )
+ throw RuntimeException( ::rtl::OUString(), *this );
+
+ try
+ {
+ m_xInspectorUI->setHelpSectionText( impl_getHelpText_nothrow( _Control ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DefaultHelpProvider::valueChanged( const Reference< XPropertyControl >& /*_Control*/ ) throw (RuntimeException)
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DefaultHelpProvider::initialize( const Sequence< Any >& _arguments ) throw (Exception, RuntimeException)
+ {
+ if ( m_bConstructed )
+ throw AlreadyInitializedException();
+
+ StlSyntaxSequence< Any > arguments( _arguments );
+ if ( arguments.size() == 1 )
+ { // constructor: "create( XObjectInspectorUI )"
+ Reference< XObjectInspectorUI > xUI( arguments[0], UNO_QUERY );
+ create( xUI );
+ return;
+ }
+
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
+ }
+
+ //--------------------------------------------------------------------
+ void DefaultHelpProvider::create( const Reference< XObjectInspectorUI >& _rxUI )
+ {
+ if ( !_rxUI.is() )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
+
+ try
+ {
+ m_xInspectorUI = _rxUI;
+ m_xInspectorUI->registerControlObserver( this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ m_bConstructed = true;
+ }
+
+ //--------------------------------------------------------------------
+ Window* DefaultHelpProvider::impl_getVclControlWindow_nothrow( const Reference< XPropertyControl >& _rxControl )
+ {
+ Window* pControlWindow = NULL;
+ OSL_PRECOND( _rxControl.is(), "DefaultHelpProvider::impl_getVclControlWindow_nothrow: illegal control!" );
+ if ( !_rxControl.is() )
+ return pControlWindow;
+
+ try
+ {
+ Reference< XWindow > xControlWindow( _rxControl->getControlWindow(), UNO_QUERY_THROW );
+ pControlWindow = VCLUnoHelper::GetWindow( xControlWindow );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return pControlWindow;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString DefaultHelpProvider::impl_getHelpText_nothrow( const Reference< XPropertyControl >& _rxControl )
+ {
+ ::rtl::OUString sHelpText;
+ OSL_PRECOND( _rxControl.is(), "DefaultHelpProvider::impl_getHelpText_nothrow: illegal control!" );
+ if ( !_rxControl.is() )
+ return sHelpText;
+
+ Window* pControlWindow( impl_getVclControlWindow_nothrow( _rxControl ) );
+ OSL_ENSURE( pControlWindow, "DefaultHelpProvider::impl_getHelpText_nothrow: could not determine the VCL window!" );
+ if ( !pControlWindow )
+ return sHelpText;
+
+ sHelpText = pControlWindow->GetHelpText();
+ return sHelpText;
+ }
+//........................................................................
+} // namespace pcr
+//........................................................................
diff --git a/extensions/source/propctrlr/defaulthelpprovider.hxx b/extensions/source/propctrlr/defaulthelpprovider.hxx
new file mode 100644
index 000000000000..151fcc872099
--- /dev/null
+++ b/extensions/source/propctrlr/defaulthelpprovider.hxx
@@ -0,0 +1,93 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_DEFAULTHELPPROVIDER_HXX
+#define EXTENSIONS_DEFAULTHELPPROVIDER_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/XPropertyControlObserver.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/implbase2.hxx>
+#include <comphelper/componentcontext.hxx>
+
+class Window;
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= DefaultHelpProvider
+ //====================================================================
+ typedef ::cppu::WeakImplHelper2 < ::com::sun::star::inspection::XPropertyControlObserver
+ , ::com::sun::star::lang::XInitialization
+ > DefaultHelpProvider_Base;
+ class DefaultHelpProvider : public DefaultHelpProvider_Base
+ {
+ private:
+ ::comphelper::ComponentContext m_aContext;
+ bool m_bConstructed;
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >
+ m_xInspectorUI;
+
+ public:
+ DefaultHelpProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
+
+ // XServiceInfo - static versions
+ static ::rtl::OUString getImplementationName_static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+ Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
+
+ protected:
+ ~DefaultHelpProvider();
+
+ // XPropertyControlObserver
+ virtual void SAL_CALL focusGained( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& Control ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL valueChanged( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& Control ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ protected:
+ // Service constructors
+ void create( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxUI );
+
+ private:
+ Window* impl_getVclControlWindow_nothrow( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& _rxControl );
+ ::rtl::OUString impl_getHelpText_nothrow( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& _rxControl );
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_DEFAULTHELPPROVIDER_HXX
diff --git a/extensions/source/propctrlr/editpropertyhandler.cxx b/extensions/source/propctrlr/editpropertyhandler.cxx
new file mode 100644
index 000000000000..8ea6342943d2
--- /dev/null
+++ b/extensions/source/propctrlr/editpropertyhandler.cxx
@@ -0,0 +1,323 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "editpropertyhandler.hxx"
+#include "formstrings.hxx"
+#include "formmetadata.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+/** === end UNO includes === **/
+#include <tools/debug.hxx>
+
+#define TEXTTYPE_SINGLELINE 0
+#define TEXTTYPE_MULTILINE 1
+#define TEXTTYPE_RICHTEXT 2
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_EditPropertyHandler()
+{
+ ::pcr::EditPropertyHandler::registerImplementation();
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::script;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::inspection;
+
+ //====================================================================
+ //= EditPropertyHandler
+ //====================================================================
+ DBG_NAME( EditPropertyHandler )
+ //--------------------------------------------------------------------
+ EditPropertyHandler::EditPropertyHandler( const Reference< XComponentContext >& _rxContext )
+ :EditPropertyHandler_Base( _rxContext )
+ {
+ DBG_CTOR( EditPropertyHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ EditPropertyHandler::~EditPropertyHandler( )
+ {
+ DBG_DTOR( EditPropertyHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL EditPropertyHandler::getImplementationName_static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.EditPropertyHandler" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL EditPropertyHandler::getSupportedServiceNames_static( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported( 1 );
+ aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.EditPropertyHandler" ) );
+ return aSupported;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL EditPropertyHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ Any aReturn;
+ try
+ {
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_SHOW_SCROLLBARS:
+ {
+ sal_Bool bHasVScroll = sal_False;
+ m_xComponent->getPropertyValue( PROPERTY_VSCROLL ) >>= bHasVScroll;
+ sal_Bool bHasHScroll = sal_False;
+ m_xComponent->getPropertyValue( PROPERTY_HSCROLL ) >>= bHasHScroll;
+
+ aReturn <<= (sal_Int32)( ( bHasVScroll ? 2 : 0 ) + ( bHasHScroll ? 1 : 0 ) );
+ }
+ break;
+
+ case PROPERTY_ID_TEXTTYPE:
+ {
+ sal_Int32 nTextType = TEXTTYPE_SINGLELINE;
+ sal_Bool bRichText = sal_False;
+ OSL_VERIFY( m_xComponent->getPropertyValue( PROPERTY_RICHTEXT ) >>= bRichText );
+ if ( bRichText )
+ nTextType = TEXTTYPE_RICHTEXT;
+ else
+ {
+ sal_Bool bMultiLine = sal_False;
+ OSL_VERIFY( m_xComponent->getPropertyValue( PROPERTY_MULTILINE ) >>= bMultiLine );
+ if ( bMultiLine )
+ nTextType = TEXTTYPE_MULTILINE;
+ else
+ nTextType = TEXTTYPE_SINGLELINE;
+ }
+ aReturn <<= nTextType;
+ }
+ break;
+
+
+ default:
+ DBG_ERROR( "EditPropertyHandler::getPropertyValue: cannot handle this property!" );
+ break;
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EditPropertyHandler::getPropertyValue: caught an exception!" );
+ }
+
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EditPropertyHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ try
+ {
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_SHOW_SCROLLBARS:
+ {
+ sal_Int32 nScrollbars = 0;
+ _rValue >>= nScrollbars;
+
+ sal_Bool bHasVScroll = 0 != ( nScrollbars & 2 );
+ sal_Bool bHasHScroll = 0 != ( nScrollbars & 1 );
+
+ m_xComponent->setPropertyValue( PROPERTY_VSCROLL, makeAny( (sal_Bool)bHasVScroll ) );
+ m_xComponent->setPropertyValue( PROPERTY_HSCROLL, makeAny( (sal_Bool)bHasHScroll ) );
+ }
+ break;
+
+ case PROPERTY_ID_TEXTTYPE:
+ {
+ sal_Bool bMultiLine = sal_False;
+ sal_Bool bRichText = sal_False;
+ sal_Int32 nTextType = TEXTTYPE_SINGLELINE;
+ OSL_VERIFY( _rValue >>= nTextType );
+ switch ( nTextType )
+ {
+ case TEXTTYPE_SINGLELINE: bMultiLine = bRichText = sal_False; break;
+ case TEXTTYPE_MULTILINE: bMultiLine = sal_True; bRichText = sal_False; break;
+ case TEXTTYPE_RICHTEXT: bMultiLine = sal_True; bRichText = sal_True; break;
+ default:
+ OSL_ENSURE( sal_False, "EditPropertyHandler::setPropertyValue: invalid text type!" );
+ }
+
+ m_xComponent->setPropertyValue( PROPERTY_MULTILINE, makeAny( bMultiLine ) );
+ m_xComponent->setPropertyValue( PROPERTY_RICHTEXT, makeAny( bRichText ) );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( sal_False, "EditPropertyHandler::setPropertyValue: cannot handle this id!" );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EditPropertyHandler::setPropertyValue: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool EditPropertyHandler::implHaveBothScrollBarProperties() const
+ {
+ // have a "Scrollbars" property if the object supports both "HScroll" and "VScroll"
+ Reference< XPropertySetInfo > xPSI;
+ if ( m_xComponent.is() )
+ xPSI = m_xComponent->getPropertySetInfo();
+
+ return xPSI.is()
+ && xPSI->hasPropertyByName( PROPERTY_HSCROLL )
+ && xPSI->hasPropertyByName( PROPERTY_VSCROLL );
+ }
+
+ //--------------------------------------------------------------------
+ bool EditPropertyHandler::implHaveTextTypeProperty() const
+ {
+ // have a "Scrollbars" property if the object supports both "HScroll" and "VScroll"
+ Reference< XPropertySetInfo > xPSI;
+ if ( m_xComponent.is() )
+ xPSI = m_xComponent->getPropertySetInfo();
+
+ return xPSI.is()
+ && xPSI->hasPropertyByName( PROPERTY_RICHTEXT )
+ && xPSI->hasPropertyByName( PROPERTY_MULTILINE );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Property > SAL_CALL EditPropertyHandler::doDescribeSupportedProperties() const
+ {
+ ::std::vector< Property > aProperties;
+
+ if ( implHaveBothScrollBarProperties() )
+ addInt32PropertyDescription( aProperties, PROPERTY_SHOW_SCROLLBARS );
+
+ if ( implHaveTextTypeProperty() )
+ addInt32PropertyDescription( aProperties, PROPERTY_TEXTTYPE );
+
+ if ( aProperties.empty() )
+ return Sequence< Property >();
+ return Sequence< Property >( &(*aProperties.begin()), aProperties.size() );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL EditPropertyHandler::getSupersededProperties( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ ::std::vector< ::rtl::OUString > aSuperseded;
+ if ( implHaveBothScrollBarProperties() )
+ {
+ aSuperseded.push_back( PROPERTY_HSCROLL );
+ aSuperseded.push_back( PROPERTY_VSCROLL );
+ }
+ if ( implHaveTextTypeProperty() )
+ {
+ aSuperseded.push_back( PROPERTY_RICHTEXT );
+ aSuperseded.push_back( PROPERTY_MULTILINE );
+ }
+ if ( aSuperseded.empty() )
+ return Sequence< ::rtl::OUString >();
+ return Sequence< ::rtl::OUString >( &(*aSuperseded.begin()), aSuperseded.size() );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL EditPropertyHandler::getActuatingProperties( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ ::std::vector< ::rtl::OUString > aInterestingActuatingProps;
+ if ( implHaveTextTypeProperty() )
+ aInterestingActuatingProps.push_back( PROPERTY_TEXTTYPE );
+ aInterestingActuatingProps.push_back( PROPERTY_MULTILINE );
+ return Sequence< ::rtl::OUString >( &(*aInterestingActuatingProps.begin()), aInterestingActuatingProps.size() );;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EditPropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool ) throw (NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nActuatingPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) );
+ switch ( nActuatingPropId )
+ {
+ case PROPERTY_ID_TEXTTYPE:
+ {
+ sal_Int32 nTextType = TEXTTYPE_SINGLELINE;
+ getPropertyValue( PROPERTY_TEXTTYPE ) >>= nTextType;
+
+ if ( impl_isSupportedProperty_nothrow( PROPERTY_ID_WORDBREAK ) )
+ _rxInspectorUI->enablePropertyUI( PROPERTY_WORDBREAK, nTextType == TEXTTYPE_RICHTEXT );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_MAXTEXTLEN, nTextType != TEXTTYPE_RICHTEXT );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_ECHO_CHAR, nTextType == TEXTTYPE_SINGLELINE );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_FONT, nTextType != TEXTTYPE_RICHTEXT );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_ALIGN, nTextType != TEXTTYPE_RICHTEXT );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_DEFAULT_TEXT, nTextType != TEXTTYPE_RICHTEXT );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_SHOW_SCROLLBARS, nTextType != TEXTTYPE_SINGLELINE );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_LINEEND_FORMAT, nTextType != TEXTTYPE_SINGLELINE );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_VERTICAL_ALIGN, nTextType == TEXTTYPE_SINGLELINE );
+
+ _rxInspectorUI->showCategory( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Data" ) ), nTextType != TEXTTYPE_RICHTEXT );
+ }
+ break;
+
+ case PROPERTY_ID_MULTILINE:
+ {
+ sal_Bool bIsMultiline = sal_False;
+ _rNewValue >>= bIsMultiline;
+
+ _rxInspectorUI->enablePropertyUI( PROPERTY_SHOW_SCROLLBARS, bIsMultiline );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_ECHO_CHAR, !bIsMultiline );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_LINEEND_FORMAT, bIsMultiline );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( sal_False, "EditPropertyHandler::actuatingPropertyChanged: cannot handle this id!" );
+ }
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
diff --git a/extensions/source/propctrlr/editpropertyhandler.hxx b/extensions/source/propctrlr/editpropertyhandler.hxx
new file mode 100644
index 000000000000..d3429f635d26
--- /dev/null
+++ b/extensions/source/propctrlr/editpropertyhandler.hxx
@@ -0,0 +1,82 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_EDITPROPERTYHANDLER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_EDITPROPERTYHANDLER_HXX
+
+#include "propertyhandler.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= EditPropertyHandler
+ //====================================================================
+ class EditPropertyHandler;
+ typedef HandlerComponentBase< EditPropertyHandler > EditPropertyHandler_Base;
+ /** a property handler for any virtual string properties
+ */
+ class EditPropertyHandler : public EditPropertyHandler_Base
+ {
+ public:
+ EditPropertyHandler(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
+ );
+
+ static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ ~EditPropertyHandler();
+
+ protected:
+ // XPropertyHandler overriables
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupersededProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+
+ // PropertyHandler overridables
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
+ SAL_CALL doDescribeSupportedProperties() const;
+ private:
+ bool implHaveBothScrollBarProperties() const;
+ bool implHaveTextTypeProperty() const;
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_EDITPROPERTYHANDLER_HXX
+
diff --git a/extensions/source/propctrlr/eformshelper.cxx b/extensions/source/propctrlr/eformshelper.cxx
new file mode 100644
index 000000000000..d4adaf3281f1
--- /dev/null
+++ b/extensions/source/propctrlr/eformshelper.cxx
@@ -0,0 +1,790 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "eformshelper.hxx"
+#include "formstrings.hxx"
+#ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
+#include "formresid.hrc"
+#endif
+#ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
+#include "modulepcr.hxx"
+#endif
+#include "propeventtranslation.hxx"
+#include "formbrowsertools.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/xforms/XFormsUIHelper1.hpp>
+#include <com/sun/star/xsd/DataTypeClass.hpp>
+#include <com/sun/star/form/binding/XListEntrySink.hpp>
+/** === end UNO includes === **/
+#include <tools/diagnose_ex.h>
+#include <rtl/ustrbuf.hxx>
+
+#include <functional>
+#include <algorithm>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::form::binding;
+ using namespace ::com::sun::star::xsd;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::form;
+
+ //====================================================================
+ //= file-local helpers
+ //====================================================================
+ namespace
+ {
+ //--------------------------------------------------------------------
+ ::rtl::OUString composeModelElementUIName( const ::rtl::OUString& _rModelName, const ::rtl::OUString& _rElementName )
+ {
+ ::rtl::OUStringBuffer aBuffer;
+ aBuffer.appendAscii( "[" );
+ aBuffer.append( _rModelName );
+ aBuffer.appendAscii( "] " );
+ aBuffer.append( _rElementName );
+ return aBuffer.makeStringAndClear();
+ }
+ }
+
+ //====================================================================
+ //= EFormsHelper
+ //====================================================================
+ //--------------------------------------------------------------------
+ EFormsHelper::EFormsHelper( ::osl::Mutex& _rMutex, const Reference< XPropertySet >& _rxControlModel, const Reference< frame::XModel >& _rxContextDocument )
+ :m_xControlModel( _rxControlModel )
+ ,m_aPropertyListeners( _rMutex )
+ {
+ OSL_ENSURE( _rxControlModel.is(), "EFormsHelper::EFormsHelper: invalid control model!" );
+ m_xBindableControl = m_xBindableControl.query( _rxControlModel );
+
+ m_xDocument = m_xDocument.query( _rxContextDocument );
+ OSL_ENSURE( m_xDocument.is(), "EFormsHelper::EFormsHelper: invalid document!" );
+
+ }
+
+ //--------------------------------------------------------------------
+ bool EFormsHelper::isEForm( const Reference< frame::XModel >& _rxContextDocument )
+ {
+ try
+ {
+ Reference< xforms::XFormsSupplier > xDocument( _rxContextDocument, UNO_QUERY );
+ if ( !xDocument.is() )
+ return false;
+
+ return xDocument->getXForms().is();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::isEForm: caught an exception!" );
+ }
+ return false;
+ }
+
+ //--------------------------------------------------------------------
+ bool EFormsHelper::canBindToDataType( sal_Int32 _nDataType ) const SAL_THROW(())
+ {
+ if ( !m_xBindableControl.is() )
+ // cannot bind at all
+ return false;
+
+ // some types cannot be bound, independent from the control type
+ if ( ( DataTypeClass::hexBinary == _nDataType )
+ || ( DataTypeClass::base64Binary == _nDataType )
+ || ( DataTypeClass::QName == _nDataType )
+ || ( DataTypeClass::NOTATION == _nDataType )
+ )
+ return false;
+
+ bool bCan = false;
+ try
+ {
+ // classify the control model
+ sal_Int16 nControlType = FormComponentType::CONTROL;
+ OSL_VERIFY( m_xControlModel->getPropertyValue( PROPERTY_CLASSID ) >>= nControlType );
+
+ // some lists
+ sal_Int16 nNumericCompatibleTypes[] = { DataTypeClass::DECIMAL, DataTypeClass::FLOAT, DataTypeClass::DOUBLE, 0 };
+ sal_Int16 nDateCompatibleTypes[] = { DataTypeClass::DATE, 0 };
+ sal_Int16 nTimeCompatibleTypes[] = { DataTypeClass::TIME, 0 };
+ sal_Int16 nCheckboxCompatibleTypes[] = { DataTypeClass::BOOLEAN, DataTypeClass::STRING, DataTypeClass::anyURI, 0 };
+ sal_Int16 nRadiobuttonCompatibleTypes[] = { DataTypeClass::STRING, DataTypeClass::anyURI, 0 };
+ sal_Int16 nFormattedCompatibleTypes[] = { DataTypeClass::DECIMAL, DataTypeClass::FLOAT, DataTypeClass::DOUBLE, DataTypeClass::DATETIME, DataTypeClass::DATE, DataTypeClass::TIME, 0 };
+
+ sal_Int16* pCompatibleTypes = NULL;
+ switch ( nControlType )
+ {
+ case FormComponentType::SPINBUTTON:
+ case FormComponentType::NUMERICFIELD:
+ pCompatibleTypes = nNumericCompatibleTypes;
+ break;
+ case FormComponentType::DATEFIELD:
+ pCompatibleTypes = nDateCompatibleTypes;
+ break;
+ case FormComponentType::TIMEFIELD:
+ pCompatibleTypes = nTimeCompatibleTypes;
+ break;
+ case FormComponentType::CHECKBOX:
+ pCompatibleTypes = nCheckboxCompatibleTypes;
+ break;
+ case FormComponentType::RADIOBUTTON:
+ pCompatibleTypes = nRadiobuttonCompatibleTypes;
+ break;
+
+ case FormComponentType::TEXTFIELD:
+ {
+ // both the normal text field, and the formatted field, claim to be a TEXTFIELD
+ // need to distinguish by service name
+ Reference< XServiceInfo > xSI( m_xControlModel, UNO_QUERY );
+ OSL_ENSURE( xSI.is(), "EFormsHelper::canBindToDataType: a control model which has no service info?" );
+ if ( xSI.is() )
+ {
+ if ( xSI->supportsService( SERVICE_COMPONENT_FORMATTEDFIELD ) )
+ {
+ pCompatibleTypes = nFormattedCompatibleTypes;
+ break;
+ }
+ }
+ // NO break here!
+ }
+ case FormComponentType::LISTBOX:
+ case FormComponentType::COMBOBOX:
+ // edit fields and list/combo boxes can be bound to anything
+ bCan = true;
+ }
+
+ if ( !bCan && pCompatibleTypes )
+ {
+ if ( _nDataType == -1 )
+ {
+ // the control can be bound to at least one type, and exactly this is being asked for
+ bCan = true;
+ }
+ else
+ {
+ while ( *pCompatibleTypes && !bCan )
+ bCan = ( *pCompatibleTypes++ == _nDataType );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::canBindToDataType: caught an exception!" );
+ }
+
+ return bCan;
+ }
+
+ //--------------------------------------------------------------------
+ bool EFormsHelper::isListEntrySink() const SAL_THROW(())
+ {
+ bool bIs = false;
+ try
+ {
+ Reference< XListEntrySink > xAsSink( m_xControlModel, UNO_QUERY );
+ bIs = xAsSink.is();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::isListEntrySink: caught an exception!" );
+ }
+ return bIs;
+ }
+
+ //--------------------------------------------------------------------
+ void EFormsHelper::impl_switchBindingListening_throw( bool _bDoListening, const Reference< XPropertyChangeListener >& _rxListener )
+ {
+ Reference< XPropertySet > xBindingProps;
+ if ( m_xBindableControl.is() )
+ xBindingProps = xBindingProps.query( m_xBindableControl->getValueBinding() );
+ if ( !xBindingProps.is() )
+ return;
+
+ if ( _bDoListening )
+ {
+ xBindingProps->addPropertyChangeListener( ::rtl::OUString(), _rxListener );
+ }
+ else
+ {
+ xBindingProps->removePropertyChangeListener( ::rtl::OUString(), _rxListener );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void EFormsHelper::registerBindingListener( const Reference< XPropertyChangeListener >& _rxBindingListener )
+ {
+ if ( !_rxBindingListener.is() )
+ return;
+ impl_toggleBindingPropertyListening_throw( true, _rxBindingListener );
+ }
+
+ //--------------------------------------------------------------------
+ void EFormsHelper::impl_toggleBindingPropertyListening_throw( bool _bDoListen, const Reference< XPropertyChangeListener >& _rxConcreteListenerOrNull )
+ {
+ if ( !_bDoListen )
+ {
+ ::std::auto_ptr< ::cppu::OInterfaceIteratorHelper > pListenerIterator = m_aPropertyListeners.createIterator();
+ while ( pListenerIterator->hasMoreElements() )
+ {
+ PropertyEventTranslation* pTranslator = dynamic_cast< PropertyEventTranslation* >( pListenerIterator->next() );
+ OSL_ENSURE( pTranslator, "EFormsHelper::impl_toggleBindingPropertyListening_throw: invalid listener element in my container!" );
+ if ( !pTranslator )
+ continue;
+
+ Reference< XPropertyChangeListener > xEventSourceTranslator( pTranslator );
+ if ( _rxConcreteListenerOrNull.is() )
+ {
+ if ( pTranslator->getDelegator() == _rxConcreteListenerOrNull )
+ {
+ impl_switchBindingListening_throw( false, xEventSourceTranslator );
+ m_aPropertyListeners.removeListener( xEventSourceTranslator );
+ break;
+ }
+ }
+ else
+ {
+ impl_switchBindingListening_throw( false, xEventSourceTranslator );
+ }
+ }
+ }
+ else
+ {
+ if ( _rxConcreteListenerOrNull.is() )
+ {
+ Reference< XPropertyChangeListener > xEventSourceTranslator( new PropertyEventTranslation( _rxConcreteListenerOrNull, m_xBindableControl ) );
+ m_aPropertyListeners.addListener( xEventSourceTranslator );
+ impl_switchBindingListening_throw( true, xEventSourceTranslator );
+ }
+ else
+ {
+ ::std::auto_ptr< ::cppu::OInterfaceIteratorHelper > pListenerIterator = m_aPropertyListeners.createIterator();
+ while ( pListenerIterator->hasMoreElements() )
+ {
+ Reference< XPropertyChangeListener > xListener( pListenerIterator->next(), UNO_QUERY );
+ impl_switchBindingListening_throw( true, xListener );
+ }
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void EFormsHelper::revokeBindingListener( const Reference< XPropertyChangeListener >& _rxBindingListener )
+ {
+ impl_toggleBindingPropertyListening_throw( false, _rxBindingListener );
+ }
+
+ //--------------------------------------------------------------------
+ void EFormsHelper::getFormModelNames( ::std::vector< ::rtl::OUString >& /* [out] */ _rModelNames ) const SAL_THROW(())
+ {
+ if ( m_xDocument.is() )
+ {
+ try
+ {
+ _rModelNames.resize( 0 );
+
+ Reference< XNameContainer > xForms( m_xDocument->getXForms() );
+ OSL_ENSURE( xForms.is(), "EFormsHelper::getFormModelNames: invalid forms container!" );
+ if ( xForms.is() )
+ {
+ Sequence< ::rtl::OUString > aModelNames = xForms->getElementNames();
+ _rModelNames.resize( aModelNames.getLength() );
+ ::std::copy( aModelNames.getConstArray(), aModelNames.getConstArray() + aModelNames.getLength(),
+ _rModelNames.begin()
+ );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::getFormModelNames: caught an exception!" );
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void EFormsHelper::getBindingNames( const ::rtl::OUString& _rModelName, ::std::vector< ::rtl::OUString >& /* [out] */ _rBindingNames ) const SAL_THROW(())
+ {
+ _rBindingNames.resize( 0 );
+ try
+ {
+ Reference< xforms::XModel > xModel( getFormModelByName( _rModelName ) );
+ if ( xModel.is() )
+ {
+ Reference< XNameAccess > xBindings( xModel->getBindings(), UNO_QUERY );
+ OSL_ENSURE( xBindings.is(), "EFormsHelper::getBindingNames: invalid bindings container obtained from the model!" );
+ if ( xBindings.is() )
+ {
+ Sequence< ::rtl::OUString > aNames = xBindings->getElementNames();
+ _rBindingNames.resize( aNames.getLength() );
+ ::std::copy( aNames.getConstArray(), aNames.getConstArray() + aNames.getLength(), _rBindingNames.begin() );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::getBindingNames: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Reference< xforms::XModel > EFormsHelper::getFormModelByName( const ::rtl::OUString& _rModelName ) const SAL_THROW(())
+ {
+ Reference< xforms::XModel > xReturn;
+ try
+ {
+ Reference< XNameContainer > xForms( m_xDocument->getXForms() );
+ OSL_ENSURE( xForms.is(), "EFormsHelper::getFormModelByName: invalid forms container!" );
+ if ( xForms.is() )
+ OSL_VERIFY( xForms->getByName( _rModelName ) >>= xReturn );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::getFormModelByName: caught an exception!" );
+ }
+ return xReturn;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< xforms::XModel > EFormsHelper::getCurrentFormModel() const SAL_THROW(())
+ {
+ Reference< xforms::XModel > xModel;
+ try
+ {
+ Reference< XPropertySet > xBinding( getCurrentBinding() );
+ if ( xBinding.is() )
+ {
+ OSL_VERIFY( xBinding->getPropertyValue( PROPERTY_MODEL ) >>= xModel );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::getCurrentFormModel: caught an exception!" );
+ }
+ return xModel;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString EFormsHelper::getCurrentFormModelName() const SAL_THROW(())
+ {
+ ::rtl::OUString sModelName;
+ try
+ {
+ Reference< xforms::XModel > xFormsModel( getCurrentFormModel() );
+ if ( xFormsModel.is() )
+ sModelName = xFormsModel->getID();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::getCurrentFormModel: caught an exception!" );
+ }
+ return sModelName;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertySet > EFormsHelper::getCurrentBinding() const SAL_THROW(())
+ {
+ Reference< XPropertySet > xBinding;
+
+ try
+ {
+ if ( m_xBindableControl.is() )
+ xBinding = xBinding.query( m_xBindableControl->getValueBinding() );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::getCurrentBinding: caught an exception!" );
+ }
+
+ return xBinding;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString EFormsHelper::getCurrentBindingName() const SAL_THROW(())
+ {
+ ::rtl::OUString sBindingName;
+ try
+ {
+ Reference< XPropertySet > xBinding( getCurrentBinding() );
+ if ( xBinding.is() )
+ xBinding->getPropertyValue( PROPERTY_BINDING_ID ) >>= sBindingName;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::getCurrentBindingName: caught an exception!" );
+ }
+ return sBindingName;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XListEntrySource > EFormsHelper::getCurrentListSourceBinding() const SAL_THROW(())
+ {
+ Reference< XListEntrySource > xReturn;
+ try
+ {
+ Reference< XListEntrySink > xAsSink( m_xControlModel, UNO_QUERY );
+ OSL_ENSURE( xAsSink.is(), "EFormsHelper::getCurrentListSourceBinding: you should have used isListEntrySink before!" );
+ if ( xAsSink.is() )
+ xReturn = xAsSink->getListEntrySource();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::getCurrentListSourceBinding: caught an exception!" );
+ }
+ return xReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void EFormsHelper::setListSourceBinding( const Reference< XListEntrySource >& _rxListSource ) SAL_THROW(())
+ {
+ try
+ {
+ Reference< XListEntrySink > xAsSink( m_xControlModel, UNO_QUERY );
+ OSL_ENSURE( xAsSink.is(), "EFormsHelper::setListSourceBinding: you should have used isListEntrySink before!" );
+ if ( xAsSink.is() )
+ xAsSink->setListEntrySource( _rxListSource );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::setListSourceBinding: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void EFormsHelper::setBinding( const Reference< ::com::sun::star::beans::XPropertySet >& _rxBinding ) SAL_THROW(())
+ {
+ if ( !m_xBindableControl.is() )
+ return;
+
+ try
+ {
+ Reference< XPropertySet > xOldBinding( m_xBindableControl->getValueBinding(), UNO_QUERY );
+
+ Reference< XValueBinding > xBinding( _rxBinding, UNO_QUERY );
+ OSL_ENSURE( xBinding.is() || !_rxBinding.is(), "EFormsHelper::setBinding: invalid binding!" );
+
+ impl_toggleBindingPropertyListening_throw( false, NULL );
+ m_xBindableControl->setValueBinding( xBinding );
+ impl_toggleBindingPropertyListening_throw( true, NULL );
+
+ ::std::set< ::rtl::OUString > aSet;
+ firePropertyChanges( xOldBinding, _rxBinding, aSet );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::setBinding: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertySet > EFormsHelper::getOrCreateBindingForModel( const ::rtl::OUString& _rTargetModel, const ::rtl::OUString& _rBindingName ) const SAL_THROW(())
+ {
+ OSL_ENSURE( _rBindingName.getLength(), "EFormsHelper::getOrCreateBindingForModel: invalid binding name!" );
+ return implGetOrCreateBinding( _rTargetModel, _rBindingName );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertySet > EFormsHelper::implGetOrCreateBinding( const ::rtl::OUString& _rTargetModel, const ::rtl::OUString& _rBindingName ) const SAL_THROW(())
+ {
+ OSL_ENSURE( !( !_rTargetModel.getLength() && _rBindingName .getLength() ), "EFormsHelper::implGetOrCreateBinding: no model, but a binding name?" );
+
+ Reference< XPropertySet > xBinding;
+ try
+ {
+ ::rtl::OUString sTargetModel( _rTargetModel );
+ // determine the model which the binding should belong to
+ if ( !sTargetModel.getLength() )
+ {
+ ::std::vector< ::rtl::OUString > aModelNames;
+ getFormModelNames( aModelNames );
+ if ( !aModelNames.empty() )
+ sTargetModel = *aModelNames.begin();
+ OSL_ENSURE( sTargetModel.getLength(), "EFormsHelper::implGetOrCreateBinding: unable to obtain a default model!" );
+ }
+ Reference< xforms::XModel > xModel( getFormModelByName( sTargetModel ) );
+ Reference< XNameAccess > xBindingNames( xModel.is() ? xModel->getBindings() : Reference< XSet >(), UNO_QUERY );
+ if ( xBindingNames.is() )
+ {
+ // get or create the binding instance
+ if ( _rBindingName.getLength() )
+ {
+ if ( xBindingNames->hasByName( _rBindingName ) )
+ OSL_VERIFY( xBindingNames->getByName( _rBindingName ) >>= xBinding );
+ else
+ {
+ xBinding = xModel->createBinding( );
+ if ( xBinding.is() )
+ {
+ xBinding->setPropertyValue( PROPERTY_BINDING_ID, makeAny( _rBindingName ) );
+ xModel->getBindings()->insert( makeAny( xBinding ) );
+ }
+ }
+ }
+ else
+ {
+ xBinding = xModel->createBinding( );
+ if ( xBinding.is() )
+ {
+ // find a nice name for it
+ String sBaseName( PcrRes( RID_STR_BINDING_UI_NAME ) );
+ sBaseName += String::CreateFromAscii( " " );
+ String sNewName;
+ sal_Int32 nNumber = 1;
+ do
+ {
+ sNewName = sBaseName + ::rtl::OUString::valueOf( nNumber++ );
+ }
+ while ( xBindingNames->hasByName( sNewName ) );
+ Reference< XNamed > xName( xBinding, UNO_QUERY_THROW );
+ xName->setName( sNewName );
+ // and insert into the model
+ xModel->getBindings()->insert( makeAny( xBinding ) );
+ }
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return xBinding;
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ //................................................................
+ struct PropertyBagInserter : public ::std::unary_function< Property, void >
+ {
+ private:
+ PropertyBag& m_rProperties;
+
+ public:
+ PropertyBagInserter( PropertyBag& rProperties ) : m_rProperties( rProperties ) { }
+
+ void operator()( const Property& _rProp )
+ {
+ m_rProperties.insert( _rProp );
+ }
+ };
+
+ //................................................................
+ Reference< XPropertySetInfo > collectPropertiesGetInfo( const Reference< XPropertySet >& _rxProps, PropertyBag& _rBag )
+ {
+ Reference< XPropertySetInfo > xInfo;
+ if ( _rxProps.is() )
+ xInfo = _rxProps->getPropertySetInfo();
+ if ( xInfo.is() )
+ {
+ Sequence< Property > aProperties = xInfo->getProperties();
+ ::std::for_each( aProperties.getConstArray(), aProperties.getConstArray() + aProperties.getLength(),
+ PropertyBagInserter( _rBag )
+ );
+ }
+ return xInfo;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString EFormsHelper::getModelElementUIName( const EFormsHelper::ModelElementType _eType, const Reference< XPropertySet >& _rxElement ) const SAL_THROW(())
+ {
+ ::rtl::OUString sUIName;
+ try
+ {
+ // determine the model which the element belongs to
+ Reference< xforms::XFormsUIHelper1 > xHelper;
+ if ( _rxElement.is() )
+ _rxElement->getPropertyValue( PROPERTY_MODEL ) >>= xHelper;
+ OSL_ENSURE( xHelper.is(), "EFormsHelper::getModelElementUIName: invalid element or model!" );
+ if ( xHelper.is() )
+ {
+ ::rtl::OUString sElementName = ( _eType == Submission ) ? xHelper->getSubmissionName( _rxElement, sal_True ) : xHelper->getBindingName( _rxElement, sal_True );
+ Reference< xforms::XModel > xModel( xHelper, UNO_QUERY_THROW );
+ sUIName = composeModelElementUIName( xModel->getID(), sElementName );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::getModelElementUIName: caught an exception!" );
+ }
+
+ return sUIName;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertySet > EFormsHelper::getModelElementFromUIName( const EFormsHelper::ModelElementType _eType, const ::rtl::OUString& _rUIName ) const SAL_THROW(())
+ {
+ const MapStringToPropertySet& rMapUINameToElement( ( _eType == Submission ) ? m_aSubmissionUINames : m_aBindingUINames );
+ MapStringToPropertySet::const_iterator pos = rMapUINameToElement.find( _rUIName );
+ OSL_ENSURE( pos != rMapUINameToElement.end(), "EFormsHelper::getModelElementFromUIName: didn't find it!" );
+
+ return ( pos != rMapUINameToElement.end() ) ? pos->second : Reference< XPropertySet >();
+ }
+
+ //--------------------------------------------------------------------
+ void EFormsHelper::getAllElementUINames( const ModelElementType _eType, ::std::vector< ::rtl::OUString >& /* [out] */ _rElementNames, bool _bPrepentEmptyEntry )
+ {
+ MapStringToPropertySet& rMapUINameToElement( ( _eType == Submission ) ? m_aSubmissionUINames : m_aBindingUINames );
+ rMapUINameToElement.clear();
+ _rElementNames.resize( 0 );
+
+ if ( _bPrepentEmptyEntry )
+ rMapUINameToElement[ ::rtl::OUString() ] = Reference< XPropertySet >();
+
+ try
+ {
+ // obtain the model names
+ ::std::vector< ::rtl::OUString > aModels;
+ getFormModelNames( aModels );
+ _rElementNames.reserve( aModels.size() * 2 ); // heuristics
+
+ // for every model, obtain the element
+ for ( ::std::vector< ::rtl::OUString >::const_iterator pModelName = aModels.begin();
+ pModelName != aModels.end();
+ ++pModelName
+ )
+ {
+ Reference< xforms::XModel > xModel = getFormModelByName( *pModelName );
+ OSL_ENSURE( xModel.is(), "EFormsHelper::getAllElementUINames: inconsistency in the models!" );
+ Reference< xforms::XFormsUIHelper1 > xHelper( xModel, UNO_QUERY );
+
+ Reference< XIndexAccess > xElements;
+ if ( xModel.is() )
+ xElements = xElements.query( ( _eType == Submission ) ? xModel->getSubmissions() : xModel->getBindings() );
+ if ( !xElements.is() )
+ break;
+
+ sal_Int32 nElementCount = xElements->getCount();
+ for ( sal_Int32 i = 0; i < nElementCount; ++i )
+ {
+ Reference< XPropertySet > xElement( xElements->getByIndex( i ), UNO_QUERY );
+ OSL_ENSURE( xElement.is(), "EFormsHelper::getAllElementUINames: empty element!" );
+ if ( !xElement.is() )
+ continue;
+#if OSL_DEBUG_LEVEL > 0
+ {
+ Reference< xforms::XModel > xElementsModel;
+ xElement->getPropertyValue( PROPERTY_MODEL ) >>= xElementsModel;
+ OSL_ENSURE( xElementsModel == xModel, "EFormsHelper::getAllElementUINames: inconsistency in the model-element relationship!" );
+ if ( !( xElementsModel == xModel ) )
+ xElement->setPropertyValue( PROPERTY_MODEL, makeAny( xModel ) );
+ }
+#endif
+ ::rtl::OUString sElementName = ( _eType == Submission ) ? xHelper->getSubmissionName( xElement, sal_True ) : xHelper->getBindingName( xElement, sal_True );
+ ::rtl::OUString sUIName = composeModelElementUIName( *pModelName, sElementName );
+
+ OSL_ENSURE( rMapUINameToElement.find( sUIName ) == rMapUINameToElement.end(), "EFormsHelper::getAllElementUINames: duplicate name!" );
+ rMapUINameToElement.insert( MapStringToPropertySet::value_type( sUIName, xElement ) );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::getAllElementUINames: caught an exception!" );
+ }
+
+ _rElementNames.resize( rMapUINameToElement.size() );
+ ::std::transform( rMapUINameToElement.begin(), rMapUINameToElement.end(), _rElementNames.begin(), ::std::select1st< MapStringToPropertySet::value_type >() );
+ }
+
+ //--------------------------------------------------------------------
+ void EFormsHelper::firePropertyChange( const ::rtl::OUString& _rName, const Any& _rOldValue, const Any& _rNewValue ) const
+ {
+ if ( m_aPropertyListeners.empty() )
+ return;
+
+ if ( _rOldValue == _rNewValue )
+ return;
+
+ try
+ {
+ PropertyChangeEvent aEvent;
+
+ aEvent.Source = m_xBindableControl.get();
+ aEvent.PropertyName = _rName;
+ aEvent.OldValue = _rOldValue;
+ aEvent.NewValue = _rNewValue;
+
+ const_cast< EFormsHelper* >( this )->m_aPropertyListeners.notify( aEvent, &XPropertyChangeListener::propertyChange );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::firePropertyChange: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void EFormsHelper::firePropertyChanges( const Reference< XPropertySet >& _rxOldProps, const Reference< XPropertySet >& _rxNewProps, ::std::set< ::rtl::OUString >& _rFilter ) const
+ {
+ if ( m_aPropertyListeners.empty() )
+ return;
+
+ try
+ {
+ PropertyBag aProperties;
+ Reference< XPropertySetInfo > xOldInfo = collectPropertiesGetInfo( _rxOldProps, aProperties );
+ Reference< XPropertySetInfo > xNewInfo = collectPropertiesGetInfo( _rxNewProps, aProperties );
+
+ for ( PropertyBag::const_iterator aProp = aProperties.begin();
+ aProp != aProperties.end();
+ ++aProp
+ )
+ {
+ if ( _rFilter.find( aProp->Name ) != _rFilter.end() )
+ continue;
+
+ Any aOldValue( NULL, aProp->Type );
+ if ( xOldInfo.is() && xOldInfo->hasPropertyByName( aProp->Name ) )
+ aOldValue = _rxOldProps->getPropertyValue( aProp->Name );
+
+ Any aNewValue( NULL, aProp->Type );
+ if ( xNewInfo.is() && xNewInfo->hasPropertyByName( aProp->Name ) )
+ aNewValue = _rxNewProps->getPropertyValue( aProp->Name );
+
+ firePropertyChange( aProp->Name, aOldValue, aNewValue );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::firePropertyChanges: caught an exception!" );
+ }
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
diff --git a/extensions/source/propctrlr/eformshelper.hxx b/extensions/source/propctrlr/eformshelper.hxx
new file mode 100644
index 000000000000..408ae2a2cabd
--- /dev/null
+++ b/extensions/source/propctrlr/eformshelper.hxx
@@ -0,0 +1,269 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_EFORMSHELPER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_EFORMSHELPER_HXX
+
+#include "pcrcommon.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/xforms/XModel.hpp>
+#include <com/sun/star/xforms/XFormsSupplier.hpp>
+#include <com/sun/star/form/binding/XBindableValue.hpp>
+#include <com/sun/star/form/binding/XListEntrySource.hpp>
+/** === end UNO includes === **/
+#include <osl/mutex.hxx>
+#include <tools/string.hxx>
+#include <comphelper/listenernotification.hxx>
+
+#include <vector>
+#include <set>
+#include <map>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ typedef ::std::map< ::rtl::OUString, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >, ::std::less< ::rtl::OUString > >
+ MapStringToPropertySet;
+
+ //====================================================================
+ //= EFormsHelper
+ //====================================================================
+ class EFormsHelper
+ {
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xControlModel;
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XBindableValue >
+ m_xBindableControl;
+ ::com::sun::star::uno::Reference< ::com::sun::star::xforms::XFormsSupplier >
+ m_xDocument;
+ PropertyChangeListeners
+ m_aPropertyListeners;
+ MapStringToPropertySet
+ m_aSubmissionUINames; // only filled upon request
+ MapStringToPropertySet
+ m_aBindingUINames; // only filled upon request
+
+ public:
+ EFormsHelper(
+ ::osl::Mutex& _rMutex,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxContextDocument
+ );
+
+ /** determines whether the given document is an eForm
+
+ If this method returns <FALSE/>, you cannot instantiate a EFormsHelper with
+ this document, since then no of it's functionality will be available.
+ */
+ static bool
+ isEForm(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxContextDocument
+ ) SAL_THROW(());
+
+ /** registers a listener to be notified when any aspect of the binding changes.
+
+ The listener will be registered at the current binding of the control model. If the binding
+ changes (see <method>setBinding</method>), the listener will be revoked from the old binding,
+ registered at the new binding, and for all properties which differ between both bindings,
+ the listener will be notified.
+ @see revokeBindingListener
+ */
+ void registerBindingListener(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxBindingListener
+ );
+
+ /** revokes the binding listener which has previously been registered
+ @see registerBindingListener
+ */
+ void revokeBindingListener(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxBindingListener
+ );
+
+ /** checks whether it's possible to bind the control model to a given XSD data type
+
+ @param _nDataType
+ the data type which should be bound. If this is -1, <TRUE/> is returned if the control model
+ can be bound to <em>any</em> data type.
+ */
+ bool canBindToDataType( sal_Int32 _nDataType = -1 ) const SAL_THROW(());
+
+ /** checks whether the control model cna be bound to any XSD data type
+ */
+ bool canBindToAnyDataType() const SAL_THROW(()) { return canBindToDataType( -1 ); }
+
+ /** checks whether the control model is a source for list entries, as supplied by XML data bindings
+ */
+ bool isListEntrySink() const SAL_THROW(());
+
+ /** retrieves the names of all XForms models in the document the control lives in
+ */
+ void getFormModelNames( ::std::vector< ::rtl::OUString >& /* [out] */ _rModelNames ) const SAL_THROW(());
+
+ /** retrieves the names of all bindings for a given model
+ @see getFormModelNames
+ */
+ void getBindingNames( const ::rtl::OUString& _rModelName, ::std::vector< ::rtl::OUString >& /* [out] */ _rBindingNames ) const SAL_THROW(());
+
+ /// retrieves the XForms model (within the control model's document) with the given name
+ ::com::sun::star::uno::Reference< ::com::sun::star::xforms::XModel >
+ getFormModelByName( const ::rtl::OUString& _rModelName ) const SAL_THROW(());
+
+ /** retrieves the model which the active binding of the control model belongs to
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::xforms::XModel >
+ getCurrentFormModel() const SAL_THROW(());
+
+ /** retrieves the name of the model which the active binding of the control model belongs to
+ */
+ ::rtl::OUString
+ getCurrentFormModelName() const SAL_THROW(());
+
+ /** retrieves the binding instance which is currently attached to the control model
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ getCurrentBinding() const SAL_THROW(());
+
+ /** retrieves the name of the binding instance which is currently attached to the control model
+ */
+ ::rtl::OUString
+ getCurrentBindingName() const SAL_THROW(());
+
+ /** sets a new binding at the control model
+ */
+ void setBinding( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxBinding ) SAL_THROW(());
+
+ /** retrieves the binding instance which is currently used as list source for the control model
+ @see isListEntrySink
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >
+ getCurrentListSourceBinding() const SAL_THROW(());
+
+ /** sets a new list source at the control model
+ @see isListEntrySink
+ */
+ void setListSourceBinding( const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxListSource ) SAL_THROW(());
+
+ /** retrieves a given binding for a given model, or creates a new one
+
+ @param _rTargetModel
+ the name of the model to create a binding for. Must not be empty
+ @param _rBindingName
+ the name of the binding to retrieve. If the model denoted by <arg>_rTargetModel</arg> does not
+ have a binding with this name, a new binding is created and returned.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ getOrCreateBindingForModel( const ::rtl::OUString& _rTargetModel, const ::rtl::OUString& _rBindingName ) const SAL_THROW(());
+
+ /** types of sub-elements of a model
+ */
+ enum ModelElementType
+ {
+ Submission,
+ Binding
+ };
+
+ /** retrieves the name of a model's sub-element, as to be shown in the UI
+ @see getModelElementFromUIName
+ @see getAllElementUINames
+ */
+ ::rtl::OUString
+ getModelElementUIName(
+ const ModelElementType _eType,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxElement
+ ) const SAL_THROW(());
+
+ /** retrieves the submission object for an UI name
+
+ Note that <member>getAllElementUINames</member> must have been called before, for the given element type
+
+ @see getModelElementUIName
+ @see getAllElementUINames
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ getModelElementFromUIName(
+ const ModelElementType _eType,
+ const ::rtl::OUString& _rUIName
+ ) const SAL_THROW(());
+
+ /** retrieves the UI names of all elements of all models in our document
+ @param _eType
+ the type of elements for which the names should be retrieved
+ @param _rElementNames
+ the array of element names
+ @see getModelElementUIName
+ @see getModelElementFromUIName
+ */
+ void getAllElementUINames(
+ const ModelElementType _eType,
+ ::std::vector< ::rtl::OUString >& /* [out] */ _rElementNames,
+ bool _bPrepentEmptyEntry
+ );
+
+ protected:
+ void firePropertyChanges(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxOldProps,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxNewProps,
+ ::std::set< ::rtl::OUString >& _rFilter
+ ) const;
+
+ /** fires a change in a single property, if the property value changed, and if we have a listener
+ interested in property changes
+ */
+ void firePropertyChange(
+ const ::rtl::OUString& _rName,
+ const ::com::sun::star::uno::Any& _rOldValue,
+ const ::com::sun::star::uno::Any& _rNewValue
+ ) const;
+
+ private:
+ void impl_switchBindingListening_throw( bool _bDoListening, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener );
+
+ /// implementation for both <member>getOrCreateBindingForModel</member>
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ implGetOrCreateBinding( const ::rtl::OUString& _rTargetModel, const ::rtl::OUString& _rBindingName ) const SAL_THROW(());
+
+ void
+ impl_toggleBindingPropertyListening_throw( bool _bDoListen, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxConcreteListenerOrNull );
+
+ private:
+ EFormsHelper(); // never implemented
+ EFormsHelper( const EFormsHelper& ); // never implemented
+ EFormsHelper& operator=( const EFormsHelper& ); // never implemented
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_EFORMSHELPER_HXX
+
diff --git a/extensions/source/propctrlr/eformspropertyhandler.cxx b/extensions/source/propctrlr/eformspropertyhandler.cxx
new file mode 100644
index 000000000000..e2d57aaee57e
--- /dev/null
+++ b/extensions/source/propctrlr/eformspropertyhandler.cxx
@@ -0,0 +1,616 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "eformspropertyhandler.hxx"
+#include "formstrings.hxx"
+#include "formmetadata.hxx"
+#include "propctrlr.hrc"
+#include "formbrowsertools.hxx"
+#include "eformshelper.hxx"
+#include "handlerhelper.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/inspection/PropertyControlType.hpp>
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+/** === end UNO includes === **/
+#include <tools/debug.hxx>
+
+#include <functional>
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_EFormsPropertyHandler()
+{
+ ::pcr::EFormsPropertyHandler::registerImplementation();
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::xforms;
+ using namespace ::com::sun::star::script;
+ using namespace ::com::sun::star::ui::dialogs;
+ using namespace ::com::sun::star::form::binding;
+ using namespace ::com::sun::star::inspection;
+
+ //====================================================================
+ //= EFormsPropertyHandler
+ //====================================================================
+ DBG_NAME( EFormsPropertyHandler )
+ //--------------------------------------------------------------------
+ EFormsPropertyHandler::EFormsPropertyHandler( const Reference< XComponentContext >& _rxContext )
+ :EFormsPropertyHandler_Base( _rxContext )
+ ,m_bSimulatingModelChange( false )
+ {
+ DBG_CTOR( EFormsPropertyHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ EFormsPropertyHandler::~EFormsPropertyHandler( )
+ {
+ DBG_DTOR( EFormsPropertyHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL EFormsPropertyHandler::getImplementationName_static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.EFormsPropertyHandler" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL EFormsPropertyHandler::getSupportedServiceNames_static( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported( 1 );
+ aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.XMLFormsPropertyHandler" ) );
+ return aSupported;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString EFormsPropertyHandler::getModelNamePropertyValue() const
+ {
+ ::rtl::OUString sModelName = m_pHelper->getCurrentFormModelName();
+ if ( !sModelName.getLength() )
+ sModelName = m_sBindingLessModelName;
+ return sModelName;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL EFormsPropertyHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::getPropertyValue: we don't have any SupportedProperties!" );
+ // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
+
+ Any aReturn;
+ try
+ {
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_LIST_BINDING:
+ aReturn <<= m_pHelper->getCurrentListSourceBinding();
+ break;
+
+ case PROPERTY_ID_XML_DATA_MODEL:
+ aReturn <<= getModelNamePropertyValue();
+ break;
+
+ case PROPERTY_ID_BINDING_NAME:
+ aReturn <<= m_pHelper->getCurrentBindingName();
+ break;
+
+ case PROPERTY_ID_BIND_EXPRESSION:
+ case PROPERTY_ID_XSD_CONSTRAINT:
+ case PROPERTY_ID_XSD_CALCULATION:
+ case PROPERTY_ID_XSD_REQUIRED:
+ case PROPERTY_ID_XSD_RELEVANT:
+ case PROPERTY_ID_XSD_READONLY:
+ {
+ Reference< XPropertySet > xBindingProps( m_pHelper->getCurrentBinding() );
+ if ( xBindingProps.is() )
+ {
+ aReturn = xBindingProps->getPropertyValue( _rPropertyName );
+ DBG_ASSERT( aReturn.getValueType().equals( ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ) ),
+ "EFormsPropertyHandler::getPropertyValue: invalid BindingExpression value type!" );
+ }
+ else
+ aReturn <<= ::rtl::OUString();
+ }
+ break;
+
+ default:
+ DBG_ERROR( "EFormsPropertyHandler::getPropertyValue: cannot handle this property!" );
+ break;
+ }
+ }
+ catch( const Exception& )
+ {
+#if OSL_DEBUG_LEVEL > 0
+ ::rtl::OString sMessage( "EFormsPropertyHandler::getPropertyValue: caught an exception!" );
+ sMessage += "\n(have been asked for the \"";
+ sMessage += ::rtl::OString( _rPropertyName.getStr(), _rPropertyName.getLength(), RTL_TEXTENCODING_ASCII_US );
+ sMessage += "\" property.)";
+ OSL_ENSURE( sal_False, sMessage.getStr() );
+#endif
+ }
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EFormsPropertyHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::setPropertyValue: we don't have any SupportedProperties!" );
+ // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
+
+ try
+ {
+ Any aOldValue = getPropertyValue( _rPropertyName );
+
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_LIST_BINDING:
+ {
+ Reference< XListEntrySource > xSource;
+ OSL_VERIFY( _rValue >>= xSource );
+ m_pHelper->setListSourceBinding( xSource );
+ }
+ break;
+
+ case PROPERTY_ID_XML_DATA_MODEL:
+ {
+ OSL_VERIFY( _rValue >>= m_sBindingLessModelName );
+
+ // if the model changed, reset the binding to NULL
+ if ( m_pHelper->getCurrentFormModelName() != m_sBindingLessModelName )
+ {
+ ::rtl::OUString sOldBindingName = m_pHelper->getCurrentBindingName();
+ m_pHelper->setBinding( NULL );
+ firePropertyChange( PROPERTY_BINDING_NAME, PROPERTY_ID_BINDING_NAME,
+ makeAny( sOldBindingName ), makeAny( ::rtl::OUString() ) );
+ }
+ }
+ break;
+
+ case PROPERTY_ID_BINDING_NAME:
+ {
+ ::rtl::OUString sNewBindingName;
+ OSL_VERIFY( _rValue >>= sNewBindingName );
+
+ bool bPreviouslyEmptyModel = !m_pHelper->getCurrentFormModel().is();
+
+ Reference< XPropertySet > xNewBinding;
+ if ( sNewBindingName.getLength() )
+ // obtain the binding with this name, for the current model
+ xNewBinding = m_pHelper->getOrCreateBindingForModel( getModelNamePropertyValue(), sNewBindingName );
+
+ m_pHelper->setBinding( xNewBinding );
+
+ if ( bPreviouslyEmptyModel )
+ { // simulate a property change for the model property
+ // This is because we "simulate" the Model property by remembering the
+ // value ourself. Other instances might, however, not know this value,
+ // but prefer to retrieve it somewhere else - e.g. from the EFormsHelper
+ //
+ // The really correct solution would be if *all* property handlers
+ // obtain a "current property value" for *all* properties from a central
+ // instance. Then, handler A could ask it for the value of property
+ // X, and this request would be re-routed to handler B, which ultimately
+ // knows the current value.
+ // However, there's no such mechanism in place currently.
+ m_bSimulatingModelChange = true;
+ firePropertyChange( PROPERTY_XML_DATA_MODEL, PROPERTY_ID_XML_DATA_MODEL,
+ makeAny( ::rtl::OUString() ), makeAny( getModelNamePropertyValue() ) );
+ m_bSimulatingModelChange = false;
+ }
+ }
+ break;
+
+ case PROPERTY_ID_BIND_EXPRESSION:
+ {
+ Reference< XPropertySet > xBinding( m_pHelper->getCurrentBinding() );
+ OSL_ENSURE( xBinding.is(), "You should not reach this without an active binding!" );
+ if ( xBinding.is() )
+ xBinding->setPropertyValue( PROPERTY_BIND_EXPRESSION, _rValue );
+ }
+ break;
+
+ case PROPERTY_ID_XSD_REQUIRED:
+ case PROPERTY_ID_XSD_RELEVANT:
+ case PROPERTY_ID_XSD_READONLY:
+ case PROPERTY_ID_XSD_CONSTRAINT:
+ case PROPERTY_ID_XSD_CALCULATION:
+ {
+ Reference< XPropertySet > xBindingProps( m_pHelper->getCurrentBinding() );
+ DBG_ASSERT( xBindingProps.is(), "EFormsPropertyHandler::setPropertyValue: how can I set a property if there's no binding?" );
+ if ( xBindingProps.is() )
+ {
+ DBG_ASSERT( _rValue.getValueType().equals( ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ) ),
+ "EFormsPropertyHandler::setPropertyValue: invalid value type!" );
+ xBindingProps->setPropertyValue( _rPropertyName, _rValue );
+ }
+ }
+ break;
+
+ default:
+ DBG_ERROR( "EFormsPropertyHandler::setPropertyValue: cannot handle this property!" );
+ break;
+ }
+
+ impl_setContextDocumentModified_nothrow();
+
+ Any aNewValue( getPropertyValue( _rPropertyName ) );
+ firePropertyChange( _rPropertyName, nPropId, aOldValue, aNewValue );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsPropertyHandler::setPropertyValue: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void EFormsPropertyHandler::onNewComponent()
+ {
+ EFormsPropertyHandler_Base::onNewComponent();
+
+ Reference< frame::XModel > xDocument( impl_getContextDocument_nothrow() );
+ DBG_ASSERT( xDocument.is(), "EFormsPropertyHandler::onNewComponent: no document!" );
+ if ( EFormsHelper::isEForm( xDocument ) )
+ m_pHelper.reset( new EFormsHelper( m_aMutex, m_xComponent, xDocument ) );
+ else
+ m_pHelper.reset( NULL );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Property > SAL_CALL EFormsPropertyHandler::doDescribeSupportedProperties() const
+ {
+ ::std::vector< Property > aProperties;
+
+ if ( m_pHelper.get() )
+ {
+ if ( m_pHelper->canBindToAnyDataType() )
+ {
+ aProperties.reserve( 7 );
+ addStringPropertyDescription( aProperties, PROPERTY_XML_DATA_MODEL );
+ addStringPropertyDescription( aProperties, PROPERTY_BINDING_NAME );
+ addStringPropertyDescription( aProperties, PROPERTY_BIND_EXPRESSION );
+ addStringPropertyDescription( aProperties, PROPERTY_XSD_REQUIRED );
+ addStringPropertyDescription( aProperties, PROPERTY_XSD_RELEVANT );
+ addStringPropertyDescription( aProperties, PROPERTY_XSD_READONLY );
+ addStringPropertyDescription( aProperties, PROPERTY_XSD_CONSTRAINT );
+ addStringPropertyDescription( aProperties, PROPERTY_XSD_CALCULATION );
+ }
+ if ( m_pHelper->isListEntrySink() )
+ {
+ implAddPropertyDescription( aProperties, PROPERTY_LIST_BINDING,
+ ::getCppuType( static_cast< Reference< XListEntrySource > * >( NULL ) ) );
+ }
+ }
+
+ if ( aProperties.empty() )
+ return Sequence< Property >();
+ return Sequence< Property >( &(*aProperties.begin()), aProperties.size() );
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL EFormsPropertyHandler::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Any aReturn;
+
+ OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::convertToPropertyValue: we have no SupportedProperties!" );
+ if ( !m_pHelper.get() )
+ return aReturn;
+
+ PropertyId nPropId( m_pInfoService->getPropertyId( _rPropertyName ) );
+
+ ::rtl::OUString sControlValue;
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_LIST_BINDING:
+ {
+ OSL_VERIFY( _rControlValue >>= sControlValue );
+ Reference< XListEntrySource > xListSource( m_pHelper->getModelElementFromUIName( EFormsHelper::Binding, sControlValue ), UNO_QUERY );
+ OSL_ENSURE( xListSource.is() || !m_pHelper->getModelElementFromUIName( EFormsHelper::Binding, sControlValue ).is(),
+ "EFormsPropertyHandler::convertToPropertyValue: there's a binding which is no ListEntrySource!" );
+ aReturn <<= xListSource;
+ }
+ break;
+
+ default:
+ aReturn = EFormsPropertyHandler_Base::convertToPropertyValue( _rPropertyName, _rControlValue );
+ break;
+ }
+
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL EFormsPropertyHandler::convertToControlValue( const ::rtl::OUString& _rPropertyName, const Any& _rPropertyValue, const Type& _rControlValueType ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Any aReturn;
+
+ OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::convertToControlValue: we have no SupportedProperties!" );
+ if ( !m_pHelper.get() )
+ return aReturn;
+
+ PropertyId nPropId( m_pInfoService->getPropertyId( _rPropertyName ) );
+
+ OSL_ENSURE( _rControlValueType.getTypeClass() == TypeClass_STRING,
+ "EFormsPropertyHandler::convertToControlValue: all our controls should use strings for value exchange!" );
+
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_LIST_BINDING:
+ {
+ Reference< XPropertySet > xListSourceBinding( _rPropertyValue, UNO_QUERY );
+ if ( xListSourceBinding.is() )
+ aReturn <<= m_pHelper->getModelElementUIName( EFormsHelper::Binding, xListSourceBinding );
+ }
+ break;
+
+ default:
+ aReturn = EFormsPropertyHandler_Base::convertToControlValue( _rPropertyName, _rPropertyValue, _rControlValueType );
+ break;
+ }
+
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL EFormsPropertyHandler::getActuatingProperties( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_pHelper.get() )
+ return Sequence< ::rtl::OUString >();
+
+ ::std::vector< ::rtl::OUString > aInterestedInActuations( 2 );
+ aInterestedInActuations[ 0 ] = PROPERTY_XML_DATA_MODEL;
+ aInterestedInActuations[ 1 ] = PROPERTY_BINDING_NAME;
+ return Sequence< ::rtl::OUString >( &(*aInterestedInActuations.begin()), aInterestedInActuations.size() );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL EFormsPropertyHandler::getSupersededProperties( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_pHelper.get() )
+ return Sequence< ::rtl::OUString >();
+
+ Sequence< ::rtl::OUString > aReturn( 1 );
+ aReturn[ 0 ] = PROPERTY_INPUT_REQUIRED;
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ LineDescriptor SAL_CALL EFormsPropertyHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName,
+ const Reference< XPropertyControlFactory >& _rxControlFactory )
+ throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !_rxControlFactory.is() )
+ throw NullPointerException();
+ if ( !m_pHelper.get() )
+ throw RuntimeException();
+
+ LineDescriptor aDescriptor;
+ sal_Int16 nControlType = PropertyControlType::TextField;
+ ::std::vector< ::rtl::OUString > aListEntries;
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_LIST_BINDING:
+ nControlType = PropertyControlType::ListBox;
+ const_cast< EFormsHelper* >( m_pHelper.get() )->getAllElementUINames( EFormsHelper::Binding, aListEntries, true );
+ break;
+
+ case PROPERTY_ID_XML_DATA_MODEL:
+ nControlType = PropertyControlType::ListBox;
+ m_pHelper->getFormModelNames( aListEntries );
+ break;
+
+ case PROPERTY_ID_BINDING_NAME:
+ {
+ nControlType = PropertyControlType::ComboBox;
+ ::rtl::OUString sCurrentModel( getModelNamePropertyValue() );
+ if ( sCurrentModel.getLength() )
+ m_pHelper->getBindingNames( sCurrentModel, aListEntries );
+ }
+ break;
+
+ case PROPERTY_ID_BIND_EXPRESSION: aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_BIND_EXPRESSION); break;
+ case PROPERTY_ID_XSD_REQUIRED: aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_REQUIRED); break;
+ case PROPERTY_ID_XSD_RELEVANT: aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_RELEVANT); break;
+ case PROPERTY_ID_XSD_READONLY: aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_READONLY); break;
+ case PROPERTY_ID_XSD_CONSTRAINT: aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_CONSTRAINT); break;
+ case PROPERTY_ID_XSD_CALCULATION: aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_CALCULATION); break;
+
+ default:
+ DBG_ERROR( "EFormsPropertyHandler::describePropertyLine: cannot handle this property!" );
+ break;
+ }
+
+ switch ( nControlType )
+ {
+ case PropertyControlType::ListBox:
+ aDescriptor.Control = PropertyHandlerHelper::createListBoxControl( _rxControlFactory, aListEntries, sal_False, sal_True );
+ break;
+ case PropertyControlType::ComboBox:
+ aDescriptor.Control = PropertyHandlerHelper::createComboBoxControl( _rxControlFactory, aListEntries, sal_False, sal_True );
+ break;
+ default:
+ aDescriptor.Control = _rxControlFactory->createPropertyControl( nControlType, sal_False );
+ break;
+ }
+
+ aDescriptor.DisplayName = m_pInfoService->getPropertyTranslation( nPropId );
+ aDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Data" ) );
+ aDescriptor.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( nPropId ) );
+ return aDescriptor;
+ }
+
+ //--------------------------------------------------------------------
+ InteractiveSelectionResult SAL_CALL EFormsPropertyHandler::onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool /*_bPrimary*/, Any& _rData, const Reference< XObjectInspectorUI >& _rxInspectorUI ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::onInteractivePropertySelection: we do not have any SupportedProperties!" );
+ if ( !m_pHelper.get() )
+ return InteractiveSelectionResult_Cancelled;
+
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+ (void)nPropId;
+ OSL_ENSURE( ( PROPERTY_ID_BINDING_NAME == nPropId )
+ || ( PROPERTY_ID_BIND_EXPRESSION == nPropId )
+ || ( PROPERTY_ID_XSD_REQUIRED == nPropId )
+ || ( PROPERTY_ID_XSD_RELEVANT == nPropId )
+ || ( PROPERTY_ID_XSD_READONLY == nPropId )
+ || ( PROPERTY_ID_XSD_CONSTRAINT == nPropId )
+ || ( PROPERTY_ID_XSD_CALCULATION == nPropId ), "EFormsPropertyHandler::onInteractivePropertySelection: unexpected!" );
+
+ try
+ {
+ Reference< XExecutableDialog > xDialog;
+ m_aContext.createComponent( "com.sun.star.xforms.ui.dialogs.AddCondition", xDialog );
+ Reference< XPropertySet > xDialogProps( xDialog, UNO_QUERY_THROW );
+
+ // the model for the dialog to work with
+ Reference< xforms::XModel > xModel( m_pHelper->getCurrentFormModel() );
+ // the binding for the dialog to work with
+ Reference< XPropertySet > xBinding( m_pHelper->getCurrentBinding() );
+ // the aspect of the binding which the dialog should modify
+ ::rtl::OUString sFacetName( _rPropertyName );
+
+ OSL_ENSURE( xModel.is() && xBinding.is() && sFacetName.getLength(),
+ "EFormsPropertyHandler::onInteractivePropertySelection: something is missing for the dialog initialization!" );
+ if ( !( xModel.is() && xBinding.is() && sFacetName.getLength() ) )
+ return InteractiveSelectionResult_Cancelled;
+
+ xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FormModel" ) ), makeAny( xModel ) );
+ xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Binding" ) ), makeAny( xBinding ) );
+ xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FacetName" ) ), makeAny( sFacetName ) );
+
+ if ( !xDialog->execute() )
+ // cancelled
+ return InteractiveSelectionResult_Cancelled;
+
+ _rData = xDialogProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ConditionValue" ) ) );
+ return InteractiveSelectionResult_ObtainedValue;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsPropertyHandler::onInteractivePropertySelection: caught an exception!" );
+ }
+
+ // something went wrong here ...(but has been asserted already)
+ return InteractiveSelectionResult_Cancelled;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EFormsPropertyHandler::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ EFormsPropertyHandler_Base::addPropertyChangeListener( _rxListener );
+ if ( m_pHelper.get() )
+ m_pHelper->registerBindingListener( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EFormsPropertyHandler::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_pHelper.get() )
+ m_pHelper->revokeBindingListener( _rxListener );
+ EFormsPropertyHandler_Base::removePropertyChangeListener( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EFormsPropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool ) throw (NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nActuatingPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) );
+ OSL_PRECOND( m_pHelper.get(), "EFormsPropertyHandler::actuatingPropertyChanged: inconsistentcy!" );
+ // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
+
+ DBG_ASSERT( _rxInspectorUI.is(), "EFormsPropertyHandler::actuatingPropertyChanged: invalid callback!" );
+ if ( !_rxInspectorUI.is() )
+ return;
+
+ switch ( nActuatingPropId )
+ {
+ case PROPERTY_ID_XML_DATA_MODEL:
+ {
+ if ( m_bSimulatingModelChange )
+ break;
+ ::rtl::OUString sDataModelName;
+ OSL_VERIFY( _rNewValue >>= sDataModelName );
+ sal_Bool bBoundToSomeModel = 0 != sDataModelName.getLength();
+ _rxInspectorUI->rebuildPropertyUI( PROPERTY_BINDING_NAME );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_BINDING_NAME, bBoundToSomeModel );
+ }
+ // NO break
+
+ case PROPERTY_ID_BINDING_NAME:
+ {
+ sal_Bool bHaveABinding = ( m_pHelper->getCurrentBindingName().getLength() > 0 );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_BIND_EXPRESSION, bHaveABinding );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_REQUIRED, bHaveABinding );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_RELEVANT, bHaveABinding );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_READONLY, bHaveABinding );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_CONSTRAINT, bHaveABinding );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_CALCULATION, bHaveABinding );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_DATA_TYPE, bHaveABinding );
+ }
+ break;
+
+ default:
+ DBG_ERROR( "EFormsPropertyHandler::actuatingPropertyChanged: cannot handle this property!" );
+ break;
+ }
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
diff --git a/extensions/source/propctrlr/eformspropertyhandler.hxx b/extensions/source/propctrlr/eformspropertyhandler.hxx
new file mode 100644
index 000000000000..222ff1ce94f8
--- /dev/null
+++ b/extensions/source/propctrlr/eformspropertyhandler.hxx
@@ -0,0 +1,108 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_EFORMSPROPERTYHANDLER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_EFORMSPROPERTYHANDLER_HXX
+
+#include "propertyhandler.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <memory>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ class EFormsHelper;
+ //====================================================================
+ //= EFormsPropertyHandler
+ //====================================================================
+ class EFormsPropertyHandler;
+ typedef HandlerComponentBase< EFormsPropertyHandler > EFormsPropertyHandler_Base;
+ class EFormsPropertyHandler : public EFormsPropertyHandler_Base
+ {
+ private:
+ ::std::auto_ptr< EFormsHelper > m_pHelper;
+ /** current value of the Model property, if there is no binding, yet
+ */
+ ::rtl::OUString m_sBindingLessModelName;
+ /** are we currently simulating a propertyChange event of the Model property?
+ */
+ bool m_bSimulatingModelChange;
+
+ public:
+ EFormsPropertyHandler(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
+ );
+
+ static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ ~EFormsPropertyHandler();
+
+ protected:
+ // XPropertyHandler overriables
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getSupersededProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::LineDescriptor
+ SAL_CALL describePropertyLine( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::InteractiveSelectionResult
+ SAL_CALL onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, ::com::sun::star::uno::Any& _rData, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rControlValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToControlValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rPropertyValue, const ::com::sun::star::uno::Type& _rControlValueType ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // PropertyHandler overridables
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
+ SAL_CALL doDescribeSupportedProperties() const;
+ virtual void onNewComponent();
+
+ protected:
+ /** returns the value of the PROPERTY_XML_DATA_MODEL property.
+
+ An extra method is necessary here, which respects both the value set at our helper,
+ and <member>m_sBindingLessModelName</member>
+ */
+ ::rtl::OUString getModelNamePropertyValue() const;
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_EFORMSPROPERTYHANDLER_HXX
+
diff --git a/extensions/source/propctrlr/enumrepresentation.hxx b/extensions/source/propctrlr/enumrepresentation.hxx
new file mode 100644
index 000000000000..05872d2d80d1
--- /dev/null
+++ b/extensions/source/propctrlr/enumrepresentation.hxx
@@ -0,0 +1,76 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_ENUMREPRESENTATION_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_ENUMREPRESENTATION_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/uno/Any.hxx>
+/** === end UNO includes === **/
+#include <rtl/ref.hxx>
+#include <rtl/ustring.hxx>
+
+#include <vector>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= IPropertyEnumRepresentation
+ //====================================================================
+ class SAL_NO_VTABLE IPropertyEnumRepresentation : public ::rtl::IReference
+ {
+ public:
+ /** retrieves all descriptions of all possible values of the enumeration property
+ */
+ virtual ::std::vector< ::rtl::OUString > SAL_CALL getDescriptions(
+ ) const = 0;
+
+ /** converts a given description into a property value
+ */
+ virtual void SAL_CALL getValueFromDescription(
+ const ::rtl::OUString& _rDescription,
+ ::com::sun::star::uno::Any& _out_rValue
+ ) const = 0;
+
+ /** converts a given property value into a description
+ */
+ virtual ::rtl::OUString SAL_CALL getDescriptionForValue(
+ const ::com::sun::star::uno::Any& _rEnumValue
+ ) const = 0;
+
+ virtual ~IPropertyEnumRepresentation() { };
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_ENUMREPRESENTATION_HXX
+
diff --git a/extensions/source/propctrlr/eventhandler.cxx b/extensions/source/propctrlr/eventhandler.cxx
new file mode 100644
index 000000000000..24fb4e8b88db
--- /dev/null
+++ b/extensions/source/propctrlr/eventhandler.cxx
@@ -0,0 +1,1285 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "eventhandler.hxx"
+#include "propctrlr.hrc"
+#include "formbrowsertools.hxx"
+#include "formresid.hrc"
+#include "formstrings.hxx"
+#include "handlerhelper.hxx"
+#include "modulepcr.hxx"
+#include "pcrcommon.hxx"
+#include "pcrstrings.hxx"
+#include "propertycontrolextender.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/XTabControllerModel.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/UnknownPropertyException.hpp>
+#include <com/sun/star/beans/XIntrospection.hpp>
+#include <com/sun/star/beans/XIntrospectionAccess.hpp>
+#include <com/sun/star/container/NoSuchElementException.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/container/XNameReplace.hpp>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/form/runtime/XFormController.hpp>
+#include <com/sun/star/inspection/PropertyControlType.hpp>
+#include <com/sun/star/lang/NullPointerException.hpp>
+#include <com/sun/star/script/XEventAttacherManager.hpp>
+#include <com/sun/star/script/XScriptEventsSupplier.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/uri/UriReferenceFactory.hpp>
+#include <com/sun/star/uri/XVndSunStarScriptUrlReference.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/evtmethodhelper.hxx>
+#include <comphelper/types.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <rtl/ref.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <sfx2/app.hxx>
+#include <svl/eitem.hxx>
+#include <svl/itemset.hxx>
+#include <svx/svxdlg.hxx>
+#include <svx/svxids.hrc>
+#include <tools/diagnose_ex.h>
+
+#include <map>
+#include <algorithm>
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_EventHandler()
+{
+ ::pcr::OAutoRegistration< ::pcr::EventHandler > aAutoRegistration;
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::TypeClass_STRING;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::beans::XPropertyChangeListener;
+ using ::com::sun::star::beans::Property;
+ using ::com::sun::star::beans::PropertyState;
+ using ::com::sun::star::beans::PropertyState_DIRECT_VALUE;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::script::ScriptEventDescriptor;
+ using ::com::sun::star::script::XScriptEventsSupplier;
+ using ::com::sun::star::lang::NullPointerException;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::container::XChild;
+ using ::com::sun::star::container::XIndexAccess;
+ using ::com::sun::star::script::XEventAttacherManager;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::beans::XIntrospection;
+ using ::com::sun::star::beans::XIntrospectionAccess;
+ using ::com::sun::star::container::XNameContainer;
+ using ::com::sun::star::awt::XTabControllerModel;
+ using ::com::sun::star::form::XForm;
+ using ::com::sun::star::form::runtime::XFormController;
+ using ::com::sun::star::beans::UnknownPropertyException;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::container::NoSuchElementException;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::container::XNameReplace;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::lang::WrappedTargetException;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::inspection::LineDescriptor;
+ using ::com::sun::star::inspection::XPropertyControlFactory;
+ using ::com::sun::star::inspection::InteractiveSelectionResult;
+ using ::com::sun::star::inspection::InteractiveSelectionResult_Cancelled;
+ using ::com::sun::star::inspection::InteractiveSelectionResult_Success;
+ using ::com::sun::star::inspection::XObjectInspectorUI;
+ using ::com::sun::star::util::XModifiable;
+ using ::com::sun::star::beans::PropertyChangeEvent;
+ using ::com::sun::star::frame::XFrame;
+ using ::com::sun::star::frame::XModel;
+ using ::com::sun::star::frame::XController;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using com::sun::star::uri::UriReferenceFactory;
+ using com::sun::star::uri::XUriReferenceFactory;
+ using com::sun::star::uri::XVndSunStarScriptUrlReference;
+ using ::com::sun::star::lang::XEventListener;
+ /** === end UNO using === **/
+ namespace PropertyControlType = ::com::sun::star::inspection::PropertyControlType;
+ namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
+ namespace FormComponentType = ::com::sun::star::form::FormComponentType;
+
+ //====================================================================
+ //= EventDescription
+ //====================================================================
+ EventDescription::EventDescription( EventId _nId, const sal_Char* _pListenerNamespaceAscii, const sal_Char* _pListenerClassAsciiName,
+ const sal_Char* _pListenerMethodAsciiName, sal_uInt16 _nDisplayNameResId, const rtl::OString& _sHelpId, const rtl::OString& _sUniqueBrowseId )
+ :sDisplayName( String( PcrRes( _nDisplayNameResId ) ) )
+ ,sListenerMethodName( ::rtl::OUString::createFromAscii( _pListenerMethodAsciiName ) )
+ ,sHelpId( _sHelpId )
+ ,sUniqueBrowseId( _sUniqueBrowseId )
+ ,nId( _nId )
+ {
+ ::rtl::OUStringBuffer aQualifiedListenerClass;
+ aQualifiedListenerClass.appendAscii( "com.sun.star." );
+ aQualifiedListenerClass.appendAscii( _pListenerNamespaceAscii );
+ aQualifiedListenerClass.appendAscii( "." );
+ aQualifiedListenerClass.appendAscii( _pListenerClassAsciiName );
+ sListenerClassName = aQualifiedListenerClass.makeStringAndClear();
+ }
+
+ //========================================================================
+ //= helper
+ //========================================================================
+ namespace
+ {
+ //....................................................................
+ #define DESCRIBE_EVENT( asciinamespace, asciilistener, asciimethod, id_postfix ) \
+ s_aKnownEvents.insert( EventMap::value_type( \
+ ::rtl::OUString::createFromAscii( asciimethod ), \
+ EventDescription( ++nEventId, asciinamespace, asciilistener, asciimethod, RID_STR_EVT_##id_postfix, HID_EVT_##id_postfix, UID_BRWEVT_##id_postfix ) ) )
+
+ //....................................................................
+ bool lcl_getEventDescriptionForMethod( const ::rtl::OUString& _rMethodName, EventDescription& _out_rDescription )
+ {
+ static EventMap s_aKnownEvents;
+ if ( s_aKnownEvents.empty() )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if ( s_aKnownEvents.empty() )
+ {
+ static sal_Int32 nEventId = 0;
+
+ DESCRIBE_EVENT( "form", "XApproveActionListener", "approveAction", APPROVEACTIONPERFORMED );
+ DESCRIBE_EVENT( "awt", "XActionListener", "actionPerformed", ACTIONPERFORMED );
+ DESCRIBE_EVENT( "form", "XChangeListener", "changed", CHANGED );
+ DESCRIBE_EVENT( "awt", "XTextListener", "textChanged", TEXTCHANGED );
+ DESCRIBE_EVENT( "awt", "XItemListener", "itemStateChanged", ITEMSTATECHANGED );
+ DESCRIBE_EVENT( "awt", "XFocusListener", "focusGained", FOCUSGAINED );
+ DESCRIBE_EVENT( "awt", "XFocusListener", "focusLost", FOCUSLOST );
+ DESCRIBE_EVENT( "awt", "XKeyListener", "keyPressed", KEYTYPED );
+ DESCRIBE_EVENT( "awt", "XKeyListener", "keyReleased", KEYUP );
+ DESCRIBE_EVENT( "awt", "XMouseListener", "mouseEntered", MOUSEENTERED );
+ DESCRIBE_EVENT( "awt", "XMouseMotionListener", "mouseDragged", MOUSEDRAGGED );
+ DESCRIBE_EVENT( "awt", "XMouseMotionListener", "mouseMoved", MOUSEMOVED );
+ DESCRIBE_EVENT( "awt", "XMouseListener", "mousePressed", MOUSEPRESSED );
+ DESCRIBE_EVENT( "awt", "XMouseListener", "mouseReleased", MOUSERELEASED );
+ DESCRIBE_EVENT( "awt", "XMouseListener", "mouseExited", MOUSEEXITED );
+ DESCRIBE_EVENT( "form", "XResetListener", "approveReset", APPROVERESETTED );
+ DESCRIBE_EVENT( "form", "XResetListener", "resetted", RESETTED );
+ DESCRIBE_EVENT( "form", "XSubmitListener", "approveSubmit", SUBMITTED );
+ DESCRIBE_EVENT( "form", "XUpdateListener", "approveUpdate", BEFOREUPDATE );
+ DESCRIBE_EVENT( "form", "XUpdateListener", "updated", AFTERUPDATE );
+ DESCRIBE_EVENT( "form", "XLoadListener", "loaded", LOADED );
+ DESCRIBE_EVENT( "form", "XLoadListener", "reloading", RELOADING );
+ DESCRIBE_EVENT( "form", "XLoadListener", "reloaded", RELOADED );
+ DESCRIBE_EVENT( "form", "XLoadListener", "unloading", UNLOADING );
+ DESCRIBE_EVENT( "form", "XLoadListener", "unloaded", UNLOADED );
+ DESCRIBE_EVENT( "form", "XConfirmDeleteListener", "confirmDelete", CONFIRMDELETE );
+ DESCRIBE_EVENT( "sdb", "XRowSetApproveListener", "approveRowChange", APPROVEROWCHANGE );
+ DESCRIBE_EVENT( "sdbc", "XRowSetListener", "rowChanged", ROWCHANGE );
+ DESCRIBE_EVENT( "sdb", "XRowSetApproveListener", "approveCursorMove", POSITIONING );
+ DESCRIBE_EVENT( "sdbc", "XRowSetListener", "cursorMoved", POSITIONED );
+ DESCRIBE_EVENT( "form", "XDatabaseParameterListener", "approveParameter", APPROVEPARAMETER );
+ DESCRIBE_EVENT( "sdb", "XSQLErrorListener", "errorOccured", ERROROCCURED );
+ DESCRIBE_EVENT( "awt", "XAdjustmentListener", "adjustmentValueChanged", ADJUSTMENTVALUECHANGED );
+ }
+ }
+
+ EventMap::const_iterator pos = s_aKnownEvents.find( _rMethodName );
+ if ( pos == s_aKnownEvents.end() )
+ return false;
+
+ _out_rDescription = pos->second;
+ return true;
+ }
+
+ //....................................................................
+ ::rtl::OUString lcl_getEventPropertyName( const ::rtl::OUString& _rListenerClassName, const ::rtl::OUString& _rMethodName )
+ {
+ ::rtl::OUStringBuffer aPropertyName;
+ aPropertyName.append( _rListenerClassName );
+ aPropertyName.append( (sal_Unicode)';' );
+ aPropertyName.append( _rMethodName.getStr() );
+ return aPropertyName.makeStringAndClear();
+ }
+
+ //................................................................
+ ScriptEventDescriptor lcl_getAssignedScriptEvent( const EventDescription& _rEvent, const Sequence< ScriptEventDescriptor >& _rAllAssignedMacros )
+ {
+ ScriptEventDescriptor aScriptEvent;
+ // for the case there is actually no event assigned, initialize at least ListenerType and MethodName,
+ // so this ScriptEventDescriptor properly describes the given event
+ aScriptEvent.ListenerType = _rEvent.sListenerClassName;
+ aScriptEvent.EventMethod = _rEvent.sListenerMethodName;
+
+ const ScriptEventDescriptor* pAssignedEvent = _rAllAssignedMacros.getConstArray();
+ sal_Int32 assignedEventCount( _rAllAssignedMacros.getLength() );
+ for ( sal_Int32 assignedEvent = 0; assignedEvent < assignedEventCount; ++assignedEvent, ++pAssignedEvent )
+ {
+ if ( ( pAssignedEvent->ListenerType != _rEvent.sListenerClassName )
+ || ( pAssignedEvent->EventMethod != _rEvent.sListenerMethodName )
+ )
+ continue;
+
+ if ( ( pAssignedEvent->ScriptCode.getLength() == 0 )
+ || ( pAssignedEvent->ScriptType.getLength() == 0 )
+ )
+ {
+ DBG_ERROR( "lcl_getAssignedScriptEvent: me thinks this should not happen!" );
+ continue;
+ }
+
+ aScriptEvent = *pAssignedEvent;
+
+ if ( !aScriptEvent.ScriptType.equalsAscii( "StarBasic" ) )
+ continue;
+
+ // this is an old-style macro specification:
+ // [document|application]:Library.Module.Function
+ // we need to translate this to the new-style macro specification
+ // vnd.sun.star.script:Library.Module.Function?language=Basic&location=[document|application]
+
+ sal_Int32 nPrefixLen = aScriptEvent.ScriptCode.indexOf( ':' );
+ OSL_ENSURE( nPrefixLen > 0, "lcl_getAssignedScriptEvent: illegal location!" );
+ ::rtl::OUString sLocation = aScriptEvent.ScriptCode.copy( 0, nPrefixLen );
+ ::rtl::OUString sMacroPath = aScriptEvent.ScriptCode.copy( nPrefixLen + 1 );
+
+ ::rtl::OUStringBuffer aNewStyleSpec;
+ aNewStyleSpec.appendAscii( "vnd.sun.star.script:" );
+ aNewStyleSpec.append ( sMacroPath );
+ aNewStyleSpec.appendAscii( "?language=Basic&location=" );
+ aNewStyleSpec.append ( sLocation );
+
+ aScriptEvent.ScriptCode = aNewStyleSpec.makeStringAndClear();
+
+ // also, this new-style spec requires the script code to be "Script" instead of "StarBasic"
+ aScriptEvent.ScriptType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Script" ) );
+ }
+ return aScriptEvent;
+ }
+
+ //................................................................
+ ::rtl::OUString lcl_getQualifiedKnownListenerName( const ScriptEventDescriptor& _rFormComponentEventDescriptor )
+ {
+ EventDescription aKnownEvent;
+ if ( lcl_getEventDescriptionForMethod( _rFormComponentEventDescriptor.EventMethod, aKnownEvent ) )
+ return aKnownEvent.sListenerClassName;
+ DBG_ERROR( "lcl_getQualifiedKnownListenerName: unknown method name!" );
+ // somebody assigned an script to a form component event which we don't know
+ // Speaking strictly, this is not really an error - it is possible to do
+ // this programmatically -, but it should rarely happen, since it's not possible
+ // via UI
+ return _rFormComponentEventDescriptor.ListenerType;
+ }
+
+ //................................................................
+ typedef ::std::set< Type, TypeLessByName > TypeBag;
+
+ //................................................................
+ void lcl_addListenerTypesFor_throw( const Reference< XInterface >& _rxComponent,
+ const Reference< XIntrospection >& _rxIntrospection, TypeBag& _out_rTypes )
+ {
+ if ( !_rxComponent.is() )
+ return;
+ OSL_PRECOND( _rxIntrospection.is(), "lcl_addListenerTypesFor_throw: this will crash!" );
+
+ Reference< XIntrospectionAccess > xIntrospectionAccess(
+ _rxIntrospection->inspect( makeAny( _rxComponent ) ), UNO_QUERY_THROW );
+
+ Sequence< Type > aListeners( xIntrospectionAccess->getSupportedListeners() );
+
+ ::std::copy( aListeners.getConstArray(), aListeners.getConstArray() + aListeners.getLength(),
+ ::std::insert_iterator< TypeBag >( _out_rTypes, _out_rTypes.begin() ) );
+ }
+
+ //................................................................
+ bool operator ==( const ScriptEventDescriptor _lhs, const ScriptEventDescriptor _rhs )
+ {
+ return ( ( _lhs.ListenerType == _rhs.ListenerType )
+ && ( _lhs.EventMethod == _rhs.EventMethod )
+ && ( _lhs.AddListenerParam == _rhs.AddListenerParam )
+ && ( _lhs.ScriptType == _rhs.ScriptType )
+ && ( _lhs.ScriptCode == _rhs.ScriptCode )
+ );
+ }
+ }
+
+ //====================================================================
+ //= EventHandler
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::container::XNameReplace
+ > EventHolder_Base;
+ /** a UNO component holding assigned event descriptions, for use with a SvxMacroAssignDlg
+ */
+ class EventHolder : public EventHolder_Base
+ {
+ private:
+ typedef ::std::hash_map< ::rtl::OUString, ScriptEventDescriptor, ::rtl::OUStringHash > EventMap;
+ typedef ::std::map< EventId, EventMap::iterator > EventMapIndexAccess;
+
+ EventMap m_aEventNameAccess;
+ EventMapIndexAccess m_aEventIndexAccess;
+
+ public:
+ EventHolder( );
+
+ void addEvent( EventId _nId, const ::rtl::OUString& _rEventName, const ScriptEventDescriptor& _rScriptEvent );
+
+ /** effectively the same as getByName, but instead of converting the ScriptEventDescriptor to the weird
+ format used by the macro assignment dialog, it is returned directly
+ */
+ ScriptEventDescriptor getNormalizedDescriptorByName( const ::rtl::OUString& _rEventName ) const;
+
+ // XNameReplace
+ virtual void SAL_CALL replaceByName( const ::rtl::OUString& _rName, const Any& aElement ) throw (IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException);
+ virtual Any SAL_CALL getByName( const ::rtl::OUString& _rName ) throw (NoSuchElementException, WrappedTargetException, RuntimeException);
+ virtual Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (RuntimeException);
+ virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& _rName ) throw (RuntimeException);
+ virtual Type SAL_CALL getElementType( ) throw (RuntimeException);
+ virtual ::sal_Bool SAL_CALL hasElements( ) throw (RuntimeException);
+
+ protected:
+ ~EventHolder( );
+
+ private:
+ ScriptEventDescriptor impl_getDescriptor_throw( const ::rtl::OUString& _rEventName ) const;
+ };
+
+ DBG_NAME( EventHolder )
+ //------------------------------------------------------------------------
+ EventHolder::EventHolder()
+ {
+ DBG_CTOR( EventHolder, NULL );
+ }
+
+ //------------------------------------------------------------------------
+ EventHolder::~EventHolder()
+ {
+ m_aEventNameAccess.clear();
+ m_aEventIndexAccess.clear();
+ DBG_DTOR( EventHolder, NULL );
+ }
+
+ //------------------------------------------------------------------------
+ void EventHolder::addEvent( EventId _nId, const ::rtl::OUString& _rEventName, const ScriptEventDescriptor& _rScriptEvent )
+ {
+ ::std::pair< EventMap::iterator, bool > insertionResult =
+ m_aEventNameAccess.insert( EventMap::value_type( _rEventName, _rScriptEvent ) );
+ OSL_ENSURE( insertionResult.second, "EventHolder::addEvent: there already was a MacroURL for this event!" );
+ m_aEventIndexAccess[ _nId ] = insertionResult.first;
+ }
+
+ //------------------------------------------------------------------------
+ ScriptEventDescriptor EventHolder::getNormalizedDescriptorByName( const ::rtl::OUString& _rEventName ) const
+ {
+ return impl_getDescriptor_throw( _rEventName );
+ }
+
+ //------------------------------------------------------------------------
+ ScriptEventDescriptor EventHolder::impl_getDescriptor_throw( const ::rtl::OUString& _rEventName ) const
+ {
+ EventMap::const_iterator pos = m_aEventNameAccess.find( _rEventName );
+ if ( pos == m_aEventNameAccess.end() )
+ throw NoSuchElementException( ::rtl::OUString(), *const_cast< EventHolder* >( this ) );
+ return pos->second;
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL EventHolder::replaceByName( const ::rtl::OUString& _rName, const Any& _rElement ) throw (IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException)
+ {
+ EventMap::iterator pos = m_aEventNameAccess.find( _rName );
+ if ( pos == m_aEventNameAccess.end() )
+ throw NoSuchElementException( ::rtl::OUString(), *this );
+
+ Sequence< PropertyValue > aScriptDescriptor;
+ OSL_VERIFY( _rElement >>= aScriptDescriptor );
+
+ ::comphelper::NamedValueCollection aExtractor( aScriptDescriptor );
+
+ pos->second.ScriptType = aExtractor.getOrDefault( "EventType", ::rtl::OUString() );
+ pos->second.ScriptCode = aExtractor.getOrDefault( "Script", ::rtl::OUString() );
+ }
+
+ //------------------------------------------------------------------------
+ Any SAL_CALL EventHolder::getByName( const ::rtl::OUString& _rName ) throw (NoSuchElementException, WrappedTargetException, RuntimeException)
+ {
+ ScriptEventDescriptor aDescriptor( impl_getDescriptor_throw( _rName ) );
+
+ Any aRet;
+ Sequence< PropertyValue > aScriptDescriptor( 2 );
+ aScriptDescriptor[0].Name = ::rtl::OUString::createFromAscii( "EventType" );
+ aScriptDescriptor[0].Value <<= aDescriptor.ScriptType;
+ aScriptDescriptor[1].Name = ::rtl::OUString::createFromAscii( "Script" );
+ aScriptDescriptor[1].Value <<= aDescriptor.ScriptCode;
+
+ return makeAny( aScriptDescriptor );
+ }
+
+ //------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL EventHolder::getElementNames( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aReturn( m_aEventIndexAccess.size() );
+ ::rtl::OUString* pReturn = aReturn.getArray();
+
+ // SvxMacroAssignDlg has a weird API: It expects a XNameReplace, means a container whose
+ // main access method is by name. In it's UI, it shows the possible events in exactly the
+ // order in which XNameAccess::getElementNames returns them.
+ // However, SvxMacroAssignDlg *also* takes an index for the initial selection, which is
+ // relative to the sequence returned by XNameAccess::getElementNames.
+ // This is IMO weird, since it mixes index access with name access, which decreases efficiency
+ // of the implementation.
+ // Well, it means we're forced to return the events in getElementNames in exactly the same as they
+ // appear in the property browser UI.
+ for ( EventMapIndexAccess::const_iterator loop = m_aEventIndexAccess.begin();
+ loop != m_aEventIndexAccess.end();
+ ++loop, ++pReturn
+ )
+ *pReturn = loop->second->first;
+ return aReturn;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool SAL_CALL EventHolder::hasByName( const ::rtl::OUString& _rName ) throw (RuntimeException)
+ {
+ EventMap::const_iterator pos = m_aEventNameAccess.find( _rName );
+ return pos != m_aEventNameAccess.end();
+ }
+
+ //------------------------------------------------------------------------
+ Type SAL_CALL EventHolder::getElementType( ) throw (RuntimeException)
+ {
+ return ::getCppuType( static_cast< Sequence< PropertyValue >* >( NULL ) );
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool SAL_CALL EventHolder::hasElements( ) throw (RuntimeException)
+ {
+ return !m_aEventNameAccess.empty();
+ }
+
+
+ //====================================================================
+ //= EventHandler
+ //====================================================================
+ DBG_NAME( EventHandler )
+ //--------------------------------------------------------------------
+ EventHandler::EventHandler( const Reference< XComponentContext >& _rxContext )
+ :EventHandler_Base( m_aMutex )
+ ,m_aContext( _rxContext )
+ ,m_aPropertyListeners( m_aMutex )
+ ,m_bEventsMapInitialized( false )
+ ,m_bIsDialogElement( false )
+ ,m_nGridColumnType( -1 )
+ {
+ DBG_CTOR( EventHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ EventHandler::~EventHandler()
+ {
+ DBG_DTOR( EventHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL EventHandler::getImplementationName( ) throw (RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL EventHandler::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException)
+ {
+ StlSyntaxSequence< ::rtl::OUString > aAllServices( getSupportedServiceNames() );
+ return ::std::find( aAllServices.begin(), aAllServices.end(), ServiceName ) != aAllServices.end();
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL EventHandler::getSupportedServiceNames( ) throw (RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL EventHandler::getImplementationName_static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.EventHandler" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL EventHandler::getSupportedServiceNames_static( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported( 1 );
+ aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.EventHandler" ) );
+ return aSupported;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL EventHandler::Create( const Reference< XComponentContext >& _rxContext )
+ {
+ return *( new EventHandler( _rxContext ) );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EventHandler::inspect( const Reference< XInterface >& _rxIntrospectee ) throw (RuntimeException, NullPointerException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !_rxIntrospectee.is() )
+ throw NullPointerException();
+
+ m_xComponent = Reference< XPropertySet >( _rxIntrospectee, UNO_QUERY_THROW );
+
+ m_bEventsMapInitialized = false;
+ EventMap aEmpty;
+ m_aEvents.swap( aEmpty );
+
+ m_bIsDialogElement = false;
+ m_nGridColumnType = -1;
+ try
+ {
+ Reference< XPropertySetInfo > xPSI( m_xComponent->getPropertySetInfo() );
+ m_bIsDialogElement = xPSI.is()
+ && xPSI->hasPropertyByName( PROPERTY_WIDTH )
+ && xPSI->hasPropertyByName( PROPERTY_HEIGHT )
+ && xPSI->hasPropertyByName( PROPERTY_POSITIONX )
+ && xPSI->hasPropertyByName( PROPERTY_POSITIONY );
+
+ Reference< XChild > xAsChild( _rxIntrospectee, UNO_QUERY );
+ if ( xAsChild.is() && !Reference< XForm >( _rxIntrospectee, UNO_QUERY ).is() )
+ {
+ if ( FormComponentType::GRIDCONTROL == classifyComponent( xAsChild->getParent() ) )
+ {
+ m_nGridColumnType = classifyComponent( _rxIntrospectee );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL EventHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ const EventDescription& rEvent = impl_getEventForName_throw( _rPropertyName );
+
+ Sequence< ScriptEventDescriptor > aEvents;
+ impl_getComponentScriptEvents_nothrow( aEvents );
+
+ sal_Int32 nEventCount = aEvents.getLength();
+ const ScriptEventDescriptor* pEvents = aEvents.getConstArray();
+
+ ScriptEventDescriptor aPropertyValue;
+ for ( sal_Int32 event = 0; event < nEventCount; ++event, ++pEvents )
+ {
+ if ( rEvent.sListenerClassName == pEvents->ListenerType
+ && rEvent.sListenerMethodName == pEvents->EventMethod
+ )
+ {
+ aPropertyValue = *pEvents;
+ break;
+ }
+ }
+
+ return makeAny( aPropertyValue );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EventHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ const EventDescription& rEvent = impl_getEventForName_throw( _rPropertyName );
+
+ ScriptEventDescriptor aNewScriptEvent;
+ OSL_VERIFY( _rValue >>= aNewScriptEvent );
+
+ ScriptEventDescriptor aOldScriptEvent;
+ OSL_VERIFY( getPropertyValue( _rPropertyName ) >>= aOldScriptEvent );
+ if ( aOldScriptEvent == aNewScriptEvent )
+ return;
+
+ if ( m_bIsDialogElement )
+ impl_setDialogElementScriptEvent_nothrow( aNewScriptEvent );
+ else
+ impl_setFormComponentScriptEvent_nothrow( aNewScriptEvent );
+
+ Reference< XModifiable > xDoc( m_aContext.getContextValueByAsciiName( "ContextDocument" ), UNO_QUERY );
+ if ( xDoc.is() )
+ xDoc->setModified( sal_True );
+
+ PropertyChangeEvent aEvent;
+ aEvent.Source = m_xComponent;
+ aEvent.PropertyHandle = rEvent.nId;
+ aEvent.PropertyName = _rPropertyName;
+ aEvent.OldValue <<= aOldScriptEvent;
+ aEvent.NewValue <<= aNewScriptEvent;
+ m_aPropertyListeners.notify( aEvent, &XPropertyChangeListener::propertyChange );
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL EventHandler::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ::rtl::OUString sNewScriptCode;
+ OSL_VERIFY( _rControlValue >>= sNewScriptCode );
+
+ Sequence< ScriptEventDescriptor > aAllAssignedEvents;
+ impl_getComponentScriptEvents_nothrow( aAllAssignedEvents );
+
+ const EventDescription& rEvent = impl_getEventForName_throw( _rPropertyName );
+ ScriptEventDescriptor aAssignedScript = lcl_getAssignedScriptEvent( rEvent, aAllAssignedEvents );
+
+ OSL_ENSURE( !sNewScriptCode.getLength(), "EventHandler::convertToPropertyValue: cannot convert a non-empty display name!" );
+ // Usually, there is no possibility for the user to change the content of an event binding directly in the
+ // input field, this instead is done with the macro assignment dialog.
+ // The only exception is the user pressing "DEL" while the control has the focus, in this case, we reset the
+ // control content to an empty string. So this is the only scenario where this method is allowed to be called.
+
+ // Striclty, we would be able to convert the display value to a property value,
+ // using the "name (location, language)" format we used in convertToControlValue. However,
+ // there is no need for this code ...
+
+ aAssignedScript.ScriptCode = sNewScriptCode;
+ return makeAny( aAssignedScript );
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL EventHandler::convertToControlValue( const ::rtl::OUString& /*_rPropertyName*/, const Any& _rPropertyValue, const Type& _rControlValueType ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ScriptEventDescriptor aScriptEvent;
+ OSL_VERIFY( _rPropertyValue >>= aScriptEvent );
+
+ OSL_ENSURE( _rControlValueType.getTypeClass() == TypeClass_STRING,
+ "EventHandler::convertToControlValue: unexpected ControlValue type class!" );
+ (void)_rControlValueType;
+
+ ::rtl::OUString sScript( aScriptEvent.ScriptCode );
+ if ( sScript.getLength() )
+ {
+ // format is: "name (location, language)"
+ try
+ {
+ // parse
+ Reference< XUriReferenceFactory > xUriRefFac = UriReferenceFactory::create( m_aContext.getUNOContext() );
+ Reference< XVndSunStarScriptUrlReference > xScriptUri( xUriRefFac->parse( sScript ), UNO_QUERY_THROW );
+
+ ::rtl::OUStringBuffer aComposeBuffer;
+
+ // name
+ aComposeBuffer.append( xScriptUri->getName() );
+
+ // location
+ const ::rtl::OUString sLocationParamName( RTL_CONSTASCII_USTRINGPARAM( "location" ) );
+ const ::rtl::OUString sLocation = xScriptUri->getParameter( sLocationParamName );
+ const ::rtl::OUString sLangParamName( RTL_CONSTASCII_USTRINGPARAM( "language" ) );
+ const ::rtl::OUString sLanguage = xScriptUri->getParameter( sLangParamName );
+
+ if ( sLocation.getLength() || sLanguage.getLength() )
+ {
+ aComposeBuffer.appendAscii( " (" );
+
+ // location
+ OSL_ENSURE( sLocation.getLength(), "EventHandler::convertToControlValue: unexpected: no location!" );
+ if ( sLocation.getLength() )
+ {
+ aComposeBuffer.append( sLocation );
+ aComposeBuffer.appendAscii( ", " );
+ }
+
+ // language
+ if ( sLanguage.getLength() )
+ {
+ aComposeBuffer.append( sLanguage );
+ }
+
+ aComposeBuffer.append( sal_Unicode( ')' ) );
+ }
+
+ sScript = aComposeBuffer.makeStringAndClear();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ return makeAny( sScript );
+ }
+
+ //--------------------------------------------------------------------
+ PropertyState SAL_CALL EventHandler::getPropertyState( const ::rtl::OUString& /*_rPropertyName*/ ) throw (UnknownPropertyException, RuntimeException)
+ {
+ return PropertyState_DIRECT_VALUE;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EventHandler::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !_rxListener.is() )
+ throw NullPointerException();
+ m_aPropertyListeners.addListener( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EventHandler::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_aPropertyListeners.removeListener( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Property > SAL_CALL EventHandler::getSupportedProperties() throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_bEventsMapInitialized )
+ {
+ const_cast< EventHandler* >( this )->m_bEventsMapInitialized = true;
+ try
+ {
+ Sequence< Type > aListeners;
+ impl_getCopmonentListenerTypes_nothrow( aListeners );
+ sal_Int32 listenerCount = aListeners.getLength();
+
+ Property aCurrentProperty;
+ ::rtl::OUString sListenerClassName;
+
+ // loop through all listeners and all methods, and see which we can present at the UI
+ const Type* pListeners = aListeners.getConstArray();
+ for ( sal_Int32 listener = 0; listener < listenerCount; ++listener, ++pListeners )
+ {
+ aCurrentProperty = Property();
+
+ // the programmatic name of the listener, to be used as "property" name
+ sListenerClassName = pListeners->getTypeName();
+ OSL_ENSURE( sListenerClassName.getLength(), "EventHandler::getSupportedProperties: strange - no listener name ..." );
+ if ( !sListenerClassName.getLength() )
+ continue;
+
+ // loop through all methods
+ Sequence< ::rtl::OUString > aMethods( comphelper::getEventMethodsForType( *pListeners ) );
+
+ const ::rtl::OUString* pMethods = aMethods.getConstArray();
+ sal_uInt32 methodCount = aMethods.getLength();
+
+ for (sal_uInt32 method = 0 ; method < methodCount ; ++method, ++pMethods )
+ {
+ EventDescription aEvent;
+ if ( !lcl_getEventDescriptionForMethod( *pMethods, aEvent ) )
+ continue;
+
+ if ( !impl_filterMethod_nothrow( aEvent ) )
+ continue;
+
+ const_cast< EventHandler* >( this )->m_aEvents.insert( EventMap::value_type(
+ lcl_getEventPropertyName( sListenerClassName, *pMethods ), aEvent ) );
+ }
+ }
+
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ // sort them by ID - this is the relative ordering in the UI
+ ::std::map< EventId, Property > aOrderedProperties;
+ for ( EventMap::const_iterator loop = m_aEvents.begin();
+ loop != m_aEvents.end();
+ ++loop
+ )
+ {
+ aOrderedProperties[ loop->second.nId ] = Property(
+ loop->first, loop->second.nId,
+ ::getCppuType( static_cast< const ::rtl::OUString* >( NULL ) ),
+ PropertyAttribute::BOUND );
+ }
+
+ StlSyntaxSequence< Property > aReturn( aOrderedProperties.size() );
+ ::std::transform( aOrderedProperties.begin(), aOrderedProperties.end(), aReturn.begin(),
+ ::std::select2nd< ::std::map< EventId, Property >::value_type >() );
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL EventHandler::getSupersededProperties( ) throw (RuntimeException)
+ {
+ // none
+ return Sequence< ::rtl::OUString >( );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL EventHandler::getActuatingProperties( ) throw (RuntimeException)
+ {
+ // none
+ return Sequence< ::rtl::OUString >( );
+ }
+
+ //--------------------------------------------------------------------
+ LineDescriptor SAL_CALL EventHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName,
+ const Reference< XPropertyControlFactory >& _rxControlFactory )
+ throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ if ( !_rxControlFactory.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ LineDescriptor aDescriptor;
+
+ aDescriptor.Control = _rxControlFactory->createPropertyControl( PropertyControlType::TextField, sal_True );
+ Reference< XEventListener > xControlExtender = new PropertyControlExtender( aDescriptor.Control );
+
+ const EventDescription& rEvent = impl_getEventForName_throw( _rPropertyName );
+ aDescriptor.DisplayName = rEvent.sDisplayName;
+ aDescriptor.HelpURL = HelpIdUrl::getHelpURL( rEvent.sHelpId );
+ aDescriptor.PrimaryButtonId = rtl::OStringToOUString(rEvent.sUniqueBrowseId, RTL_TEXTENCODING_UTF8);
+ aDescriptor.HasPrimaryButton = sal_True;
+ aDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Events" ) );
+ return aDescriptor;
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL EventHandler::isComposable( const ::rtl::OUString& /*_rPropertyName*/ ) throw (UnknownPropertyException, RuntimeException)
+ {
+ return sal_False;
+ }
+
+ //--------------------------------------------------------------------
+ InteractiveSelectionResult SAL_CALL EventHandler::onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool /*_bPrimary*/, Any& /*_rData*/, const Reference< XObjectInspectorUI >& _rxInspectorUI ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ const EventDescription& rForEvent = impl_getEventForName_throw( _rPropertyName );
+
+ Sequence< ScriptEventDescriptor > aAllAssignedEvents;
+ impl_getComponentScriptEvents_nothrow( aAllAssignedEvents );
+
+ // SvxMacroAssignDlg-compatible structure holding all event/assignments
+ ::rtl::Reference< EventHolder > pEventHolder( new EventHolder );
+
+ for ( EventMap::const_iterator event = m_aEvents.begin();
+ event != m_aEvents.end();
+ ++event
+ )
+ {
+ // the script which is assigned to the current event (if any)
+ ScriptEventDescriptor aAssignedScript = lcl_getAssignedScriptEvent( event->second, aAllAssignedEvents );
+ pEventHolder->addEvent( event->second.nId, event->second.sListenerMethodName, aAssignedScript );
+ }
+
+ // the inital selection in the dialog
+ Sequence< ::rtl::OUString > aNames( pEventHolder->getElementNames() );
+ const ::rtl::OUString* pChosenEvent = ::std::find( aNames.getConstArray(), aNames.getConstArray() + aNames.getLength(), rForEvent.sListenerMethodName );
+ sal_uInt16 nInitialSelection = (sal_uInt16)( pChosenEvent - aNames.getConstArray() );
+
+ // the dialog
+ SvxAbstractDialogFactory* pFactory = SvxAbstractDialogFactory::Create();
+ if ( !pFactory )
+ return InteractiveSelectionResult_Cancelled;
+
+ ::std::auto_ptr< VclAbstractDialog > pDialog( pFactory->CreateSvxMacroAssignDlg(
+ PropertyHandlerHelper::getDialogParentWindow( m_aContext ),
+ impl_getContextFrame_nothrow(),
+ m_bIsDialogElement,
+ pEventHolder.get(),
+ nInitialSelection
+ ) );
+
+ if ( !pDialog.get() )
+ return InteractiveSelectionResult_Cancelled;
+
+ // DF definite problem here
+ // OK & Cancel seem to be both returning 0
+ if ( pDialog->Execute() != 0 )
+ return InteractiveSelectionResult_Cancelled;
+
+ try
+ {
+ for ( EventMap::const_iterator event = m_aEvents.begin();
+ event != m_aEvents.end();
+ ++event
+ )
+ {
+ ScriptEventDescriptor aScriptDescriptor( pEventHolder->getNormalizedDescriptorByName( event->second.sListenerMethodName ) );
+
+ // set the new "property value"
+ setPropertyValue(
+ lcl_getEventPropertyName( event->second.sListenerClassName, event->second.sListenerMethodName ),
+ makeAny( aScriptDescriptor )
+ );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return InteractiveSelectionResult_Success;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EventHandler::actuatingPropertyChanged( const ::rtl::OUString& /*_rActuatingPropertyName*/, const Any& /*_rNewValue*/, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& /*_rxInspectorUI*/, sal_Bool /*_bFirstTimeInit*/ ) throw (NullPointerException, RuntimeException)
+ {
+ DBG_ERROR( "EventHandler::actuatingPropertyChanged: no actuating properties -> no callback (well, this is how it *should* be!)" );
+ }
+
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XCOMPONENT( EventHandler, EventHandler_Base )
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EventHandler::disposing()
+ {
+ EventMap aEmpty;
+ m_aEvents.swap( aEmpty );
+ m_xComponent.clear();
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL EventHandler::suspend( sal_Bool /*_bSuspend*/ ) throw (RuntimeException)
+ {
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XFrame > EventHandler::impl_getContextFrame_nothrow() const
+ {
+ Reference< XFrame > xContextFrame;
+
+ try
+ {
+ Reference< XModel > xContextDocument( m_aContext.getContextValueByAsciiName( "ContextDocument" ), UNO_QUERY_THROW );
+ Reference< XController > xController( xContextDocument->getCurrentController(), UNO_SET_THROW );
+ xContextFrame.set( xController->getFrame(), UNO_SET_THROW );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return xContextFrame;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 EventHandler::impl_getComponentIndexInParent_throw() const
+ {
+ Reference< XChild > xChild( m_xComponent, UNO_QUERY_THROW );
+ Reference< XIndexAccess > xParentAsIndexAccess( xChild->getParent(), UNO_QUERY_THROW );
+
+ // get the index of the inspected object within it's parent container
+ sal_Int32 nElements = xParentAsIndexAccess->getCount();
+ for ( sal_Int32 i=0; i<nElements; ++i )
+ {
+ Reference< XInterface > xElement( xParentAsIndexAccess->getByIndex( i ), UNO_QUERY_THROW );
+ if ( xElement == m_xComponent )
+ return i;
+ }
+ throw NoSuchElementException();
+ }
+
+ //--------------------------------------------------------------------
+ void EventHandler::impl_getFormComponentScriptEvents_nothrow( Sequence < ScriptEventDescriptor >& _out_rEvents ) const
+ {
+ _out_rEvents = Sequence < ScriptEventDescriptor >();
+ try
+ {
+ Reference< XChild > xChild( m_xComponent, UNO_QUERY_THROW );
+ Reference< XEventAttacherManager > xEventManager( xChild->getParent(), UNO_QUERY_THROW );
+ _out_rEvents = xEventManager->getScriptEvents( impl_getComponentIndexInParent_throw() );
+
+ // the form component script API has unqualified listener names, but for normalization
+ // purpose, we want fully qualified ones
+ ScriptEventDescriptor* pEvents = _out_rEvents.getArray();
+ ScriptEventDescriptor* pEventsEnd = _out_rEvents.getArray() + _out_rEvents.getLength();
+ while ( pEvents != pEventsEnd )
+ {
+ pEvents->ListenerType = lcl_getQualifiedKnownListenerName( *pEvents );
+ ++pEvents;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void EventHandler::impl_getCopmonentListenerTypes_nothrow( Sequence< Type >& _out_rTypes ) const
+ {
+ _out_rTypes.realloc( 0 );
+ try
+ {
+ // we use a set to avoid duplicates
+ TypeBag aListeners;
+
+ Reference< XIntrospection > xIntrospection( m_aContext.createComponent( "com.sun.star.beans.Introspection" ), UNO_QUERY_THROW );
+
+ // --- model listeners
+ lcl_addListenerTypesFor_throw(
+ m_xComponent, xIntrospection, aListeners );
+
+ // --- "secondary component" (usually: "control" listeners)
+ {
+ Reference< XInterface > xSecondaryComponent( impl_getSecondaryComponentForEventInspection_throw() );
+ lcl_addListenerTypesFor_throw( xSecondaryComponent, xIntrospection, aListeners );
+ ::comphelper::disposeComponent( xSecondaryComponent );
+ }
+
+ // now that they're disambiguated, copy these types into our member
+ _out_rTypes.realloc( aListeners.size() );
+ ::std::copy( aListeners.begin(), aListeners.end(), _out_rTypes.getArray() );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void EventHandler::impl_getDialogElementScriptEvents_nothrow( Sequence < ScriptEventDescriptor >& _out_rEvents ) const
+ {
+ _out_rEvents = Sequence < ScriptEventDescriptor >();
+ try
+ {
+ Reference< XScriptEventsSupplier > xEventsSupplier( m_xComponent, UNO_QUERY_THROW );
+ Reference< XNameContainer > xEvents( xEventsSupplier->getEvents(), UNO_QUERY_THROW );
+ Sequence< ::rtl::OUString > aEventNames( xEvents->getElementNames() );
+
+ sal_Int32 nEventCount = aEventNames.getLength();
+ _out_rEvents.realloc( nEventCount );
+
+ const ::rtl::OUString* pNames = aEventNames.getConstArray();
+ ScriptEventDescriptor* pDescs = _out_rEvents.getArray();
+
+ for( sal_Int32 i = 0 ; i < nEventCount ; ++i, ++pNames, ++pDescs )
+ OSL_VERIFY( xEvents->getByName( *pNames ) >>= *pDescs );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XInterface > EventHandler::impl_getSecondaryComponentForEventInspection_throw( ) const
+ {
+ Reference< XInterface > xReturn;
+
+ // if it's a form, create a form controller for the additional events
+ Reference< XForm > xComponentAsForm( m_xComponent, UNO_QUERY );
+ if ( xComponentAsForm.is() )
+ {
+ Reference< XTabControllerModel > xComponentAsTCModel( m_xComponent, UNO_QUERY_THROW );
+ Reference< XFormController > xController(
+ m_aContext.createComponent( "com.sun.star.form.runtime.FormController" ), UNO_QUERY_THROW );
+ xController->setModel( xComponentAsTCModel );
+
+ xReturn = xController;
+ }
+ else
+ {
+ ::rtl::OUString sControlService;
+ OSL_VERIFY( m_xComponent->getPropertyValue( PROPERTY_DEFAULTCONTROL ) >>= sControlService );
+
+ xReturn = m_aContext.createComponent( sControlService );
+ }
+ return xReturn;
+ }
+
+ //--------------------------------------------------------------------
+ const EventDescription& EventHandler::impl_getEventForName_throw( const ::rtl::OUString& _rPropertyName ) const
+ {
+ EventMap::const_iterator pos = m_aEvents.find( _rPropertyName );
+ if ( pos == m_aEvents.end() )
+ throw UnknownPropertyException();
+ return pos->second;
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ static bool lcl_endsWith( const ::rtl::OUString& _rText, const ::rtl::OUString& _rCheck )
+ {
+ sal_Int32 nTextLen = _rText.getLength();
+ sal_Int32 nCheckLen = _rCheck.getLength();
+ if ( nCheckLen > nTextLen )
+ return false;
+
+ return _rText.indexOf( _rCheck ) == ( nTextLen - nCheckLen );
+ }
+ }
+ //--------------------------------------------------------------------
+ void EventHandler::impl_setFormComponentScriptEvent_nothrow( const ScriptEventDescriptor& _rScriptEvent )
+ {
+ try
+ {
+ ::rtl::OUString sScriptCode( _rScriptEvent.ScriptCode );
+ ::rtl::OUString sScriptType( _rScriptEvent.ScriptType );
+ bool bResetScript = ( sScriptCode.getLength() == 0 );
+
+ sal_Int32 nObjectIndex = impl_getComponentIndexInParent_throw();
+ Reference< XChild > xChild( m_xComponent, UNO_QUERY_THROW );
+ Reference< XEventAttacherManager > xEventManager( xChild->getParent(), UNO_QUERY_THROW );
+ Sequence< ScriptEventDescriptor > aEvents( xEventManager->getScriptEvents( nObjectIndex ) );
+
+ // is there already a registered script for this event?
+ ScriptEventDescriptor* pEvent = aEvents.getArray();
+ sal_Int32 eventCount = aEvents.getLength(), event = 0;
+ for ( event = 0; event < eventCount; ++event, ++pEvent )
+ {
+ if ( ( pEvent->EventMethod == _rScriptEvent.EventMethod )
+ && ( lcl_endsWith( _rScriptEvent.ListenerType, pEvent->ListenerType ) )
+ // (strange enough, the events we get from getScriptEvents are not fully qualified)
+ )
+ {
+ // yes
+ if ( !bResetScript )
+ {
+ // set to something non-empty -> overwrite
+ pEvent->ScriptCode = sScriptCode;
+ pEvent->ScriptType = sScriptType;
+ }
+ else
+ {
+ // set to empty -> remove from sequence
+ ::std::copy( pEvent + 1, aEvents.getArray() + eventCount, pEvent );
+ aEvents.realloc( eventCount - 1 );
+ --eventCount;
+ }
+ break;
+ }
+ }
+ if ( ( event >= eventCount ) && !bResetScript )
+ {
+ // no, did not find it -> append
+ aEvents.realloc( eventCount + 1 );
+ aEvents[ eventCount ] = _rScriptEvent;
+ }
+
+ xEventManager->revokeScriptEvents( nObjectIndex );
+ xEventManager->registerScriptEvents( nObjectIndex, aEvents );
+
+ PropertyHandlerHelper::setContextDocumentModified( m_aContext );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void EventHandler::impl_setDialogElementScriptEvent_nothrow( const ScriptEventDescriptor& _rScriptEvent )
+ {
+ try
+ {
+ ::rtl::OUString sScriptCode( _rScriptEvent.ScriptCode );
+ bool bResetScript = ( sScriptCode.getLength() == 0 );
+
+ Reference< XScriptEventsSupplier > xEventsSupplier( m_xComponent, UNO_QUERY_THROW );
+ Reference< XNameContainer > xEvents( xEventsSupplier->getEvents(), UNO_QUERY_THROW );
+
+ ::rtl::OUStringBuffer aCompleteName;
+ aCompleteName.append( _rScriptEvent.ListenerType );
+ aCompleteName.appendAscii( "::" );
+ aCompleteName.append( _rScriptEvent.EventMethod );
+ ::rtl::OUString sCompleteName( aCompleteName.makeStringAndClear() );
+
+ bool bExists = xEvents->hasByName( sCompleteName );
+
+ if ( bResetScript )
+ {
+ if ( bExists )
+ xEvents->removeByName( sCompleteName );
+ }
+ else
+ {
+ Any aNewValue; aNewValue <<= _rScriptEvent;
+
+ if ( bExists )
+ xEvents->replaceByName( sCompleteName, aNewValue );
+ else
+ xEvents->insertByName( sCompleteName, aNewValue );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool EventHandler::impl_filterMethod_nothrow( const EventDescription& _rEvent ) const
+ {
+ // some (control-triggered) events do not make sense for certain grid control columns. However,
+ // our mechnism to retrieve control-triggered events does not know about this, so we do some
+ // late filtering here.
+ switch ( m_nGridColumnType )
+ {
+ case FormComponentType::COMBOBOX:
+ if ( UID_BRWEVT_ACTIONPERFORMED == _rEvent.sUniqueBrowseId )
+ return false;
+ break;
+ case FormComponentType::LISTBOX:
+ if ( ( UID_BRWEVT_CHANGED == _rEvent.sUniqueBrowseId )
+ || ( UID_BRWEVT_ACTIONPERFORMED == _rEvent.sUniqueBrowseId )
+ )
+ return false;
+ break;
+ }
+
+ return true;
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
diff --git a/extensions/source/propctrlr/eventhandler.hxx b/extensions/source/propctrlr/eventhandler.hxx
new file mode 100644
index 000000000000..a2d9003a75f4
--- /dev/null
+++ b/extensions/source/propctrlr/eventhandler.hxx
@@ -0,0 +1,265 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_EVENTHANDLER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_EVENTHANDLER_HXX
+
+#include "pcrcomponentcontext.hxx"
+#include "pcrcommontypes.hxx"
+#include "pcrcommon.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/script/ScriptEventDescriptor.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/inspection/XPropertyHandler.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+/** === end UNO includes === **/
+#include <cppuhelper/compbase2.hxx>
+#include <comphelper/listenernotification.hxx>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= EventDescription
+ //====================================================================
+ typedef sal_Int32 EventId;
+ struct EventDescription
+ {
+ public:
+ ::rtl::OUString sDisplayName;
+ ::rtl::OUString sListenerClassName;
+ ::rtl::OUString sListenerMethodName;
+ ::rtl::OString sHelpId;
+ ::rtl::OString sUniqueBrowseId;
+ EventId nId;
+
+ EventDescription()
+ :nId( 0 )
+ {
+ }
+
+ EventDescription(
+ EventId _nId,
+ const sal_Char* _pListenerNamespaceAscii,
+ const sal_Char* _pListenerClassAsciiName,
+ const sal_Char* _pListenerMethodAsciiName,
+ sal_uInt16 _nDisplayNameResId,
+ const rtl::OString& _sHelpId,
+ const rtl::OString& _sUniqueBrowseId );
+ };
+
+ typedef ::std::hash_map< ::rtl::OUString, EventDescription, ::rtl::OUStringHash > EventMap;
+
+ //====================================================================
+ //= EventHandler
+ //====================================================================
+ typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::inspection::XPropertyHandler
+ , ::com::sun::star::lang::XServiceInfo
+ > EventHandler_Base;
+ class EventHandler : public EventHandler_Base
+ {
+ private:
+ mutable ::osl::Mutex m_aMutex;
+
+ /// the context in which the instance was created
+ ComponentContext m_aContext;
+ /// the properties of the object we're handling
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xComponent;
+ /// our XPropertyChangeListener(s)
+ PropertyChangeListeners m_aPropertyListeners;
+ /// cache of the events we found at our introspectee
+ EventMap m_aEvents;
+ /// has m_aEvents been initialized?
+ bool m_bEventsMapInitialized;
+ /// is our introspectee a dialog element?
+ bool m_bIsDialogElement;
+ // TODO: move different handling into different derived classes?
+ /// (FormComponent) type of the grid column being inspected, or -1 if we're not inspecting a grid column
+ sal_Int16 m_nGridColumnType;
+
+ public:
+ // XServiceInfo - static versions
+ static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
+
+ protected:
+ EventHandler(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
+ );
+
+ ~EventHandler();
+
+ protected:
+ // XPropertyHandler overridables
+ virtual void SAL_CALL inspect( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxIntrospectee ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rControlValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToControlValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rPropertyValue, const ::com::sun::star::uno::Type& _rControlValueType ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
+ SAL_CALL getSupportedProperties() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupersededProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::LineDescriptor SAL_CALL describePropertyLine( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isComposable( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::InteractiveSelectionResult
+ SAL_CALL onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, ::com::sun::star::uno::Any& _rData, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL suspend( sal_Bool _bSuspend ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XComponent
+ DECLARE_XCOMPONENT()
+ virtual void SAL_CALL disposing();
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ /** returns the script events associated with our introspectee
+ @param _out_rEvents
+ Takes, upon successfull return, the events currently associated with the introspectee
+ @precond
+ Our introspectee is a form component
+ */
+ void impl_getFormComponentScriptEvents_nothrow(
+ ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _out_rEvents
+ ) const;
+
+ /** returns the script events associated with our introspectee
+ @param _out_rEvents
+ Takes, upon successfull return, the events currently associated with the introspectee
+ @precond
+ Our introspectee is a dialog element
+ */
+ void impl_getDialogElementScriptEvents_nothrow(
+ ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _out_rEvents
+ ) const;
+
+ /** returns the script events associated with our introspectee
+ @param _out_rEvents
+ Takes, the events currently associated with the introspectee
+ */
+ inline void impl_getComponentScriptEvents_nothrow(
+ ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _out_rEvents
+ ) const
+ {
+ if ( m_bIsDialogElement )
+ impl_getDialogElementScriptEvents_nothrow( _out_rEvents );
+ else
+ impl_getFormComponentScriptEvents_nothrow( _out_rEvents );
+ }
+
+ /** returns the types of the listeners which can be registered at our introspectee
+ @param _out_rTypes
+ Takes, upon successfull return, the types of possible listeners at the introspectee
+ */
+ void impl_getCopmonentListenerTypes_nothrow(
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >& _out_rTypes
+ ) const;
+
+ /** returns a secondary component to be used for event inspection
+
+ In the UI, we want to mix events for the control model with events for the control.
+ Since our introspectee is a model, this method creates a control for it (if possible).
+
+ @return
+ the secondary component whose events should be mixed with the introspectee's events
+ The caller takes the ownership of the component (if not <NULL/>).
+
+ @throws
+ if an unexpected error occurs during creation of the secondary component.
+ A <NULL/> component to be returned is not unexpected, but allowed
+
+ @precond
+ ->m_xComponent is not <NULL/>
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ impl_getSecondaryComponentForEventInspection_throw( ) const;
+
+ /** returns the event description for the given (programmatic) property name
+ @param _rPropertyName
+ the name whose event description should be looked up
+ @return
+ the event description for the property name
+ @throws ::com::sun::star::beans::UnknownPropertyException
+ if our introspectee does not have an event with the given logical name (see ->getSupportedProperties)
+ */
+ const EventDescription&
+ impl_getEventForName_throw( const ::rtl::OUString& _rPropertyName ) const;
+
+ /** returns the index of our component within its parent, if this parent can be
+ obtained (XChild::getParent) and supports an ->XIndexAccess interface
+ */
+ sal_Int32 impl_getComponentIndexInParent_throw() const;
+
+ /** sets a given script event as event handler at a form component
+
+ @param _rScriptEvent
+ the script event to set
+ */
+ void impl_setFormComponentScriptEvent_nothrow( const ::com::sun::star::script::ScriptEventDescriptor& _rScriptEvent );
+
+ /** sets a given script event as event handler at a dialog component
+
+ @param _rScriptEvent
+ the script event to set
+ */
+ void impl_setDialogElementScriptEvent_nothrow( const ::com::sun::star::script::ScriptEventDescriptor& _rScriptEvent );
+
+ /** returns the frame associated with our context document
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >
+ impl_getContextFrame_nothrow() const;
+
+ /** approves or denies a certain method to be included in the UI
+ @return
+ <TRUE/> if and only if the given method is allowed.
+ */
+ bool impl_filterMethod_nothrow( const EventDescription& _rEvent ) const;
+
+ private:
+ EventHandler(); // never implemented
+ EventHandler( const EventHandler& ); // never implemented
+ EventHandler& operator=( const EventHandler& ); // never implemented
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_EVENTHANDLER_HXX
+
diff --git a/extensions/source/propctrlr/fontdialog.cxx b/extensions/source/propctrlr/fontdialog.cxx
new file mode 100644
index 000000000000..e1fe31c56bb8
--- /dev/null
+++ b/extensions/source/propctrlr/fontdialog.cxx
@@ -0,0 +1,631 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <sfx2/sfxsids.hrc>
+#include "fontdialog.hxx"
+#ifndef EXTENSIONS_PROPRESID_HRC
+#include "formresid.hrc"
+#endif
+#ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
+#include "modulepcr.hxx"
+#endif
+#ifndef _EXTENSIONS_PROPCTRLR_FORMLOCALID_HRC_
+#include "formlocalid.hrc"
+#endif
+#include <vcl/svapp.hxx>
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/unohlp.hxx>
+#endif
+#include <comphelper/types.hxx>
+#include <comphelper/extract.hxx>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
+#include <com/sun/star/awt/FontStrikeout.hpp>
+#include "formstrings.hxx"
+#include "fontitemids.hxx"
+#include <editeng/charreliefitem.hxx>
+#ifndef _SVX_EMPHITEM_HXX
+#include <editeng/emphitem.hxx>
+#endif
+#include <editeng/fontitem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/crsditem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/flstitem.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/wrlmitem.hxx>
+#include <editeng/cmapitem.hxx>
+#include <editeng/cntritem.hxx>
+#include <editeng/shdditem.hxx>
+#include <editeng/flstitem.hxx>
+#include <svtools/ctrltool.hxx>
+#include <tools/diagnose_ex.h>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#ifndef _SVX_SVXIDS_HRC
+#include <svx/svxids.hrc> //CHINA001
+#endif
+#include <svx/svxdlg.hxx> //CHINA001
+#include <svx/dialogs.hrc> //CHINA001
+#include <svx/flagsdef.hxx>
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+
+ //========================================================================
+ //= OFontPropertyExtractor
+ //========================================================================
+ class OFontPropertyExtractor
+ {
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xPropValueAccess;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >
+ m_xPropStateAccess;
+
+ public:
+ OFontPropertyExtractor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >&
+ _rxProps );
+
+ public:
+ sal_Bool getCheckFontProperty(const ::rtl::OUString& _rPropName, ::com::sun::star::uno::Any& _rValue);
+ ::rtl::OUString getStringFontProperty(const ::rtl::OUString& _rPropName, const ::rtl::OUString& _rDefault);
+ sal_Int16 getInt16FontProperty(const ::rtl::OUString& _rPropName, const sal_Int16 _nDefault);
+ sal_Int32 getInt32FontProperty(const ::rtl::OUString& _rPropName, const sal_Int32 _nDefault);
+ float getFloatFontProperty(const ::rtl::OUString& _rPropName, const float _nDefault);
+
+ void invalidateItem(
+ const ::rtl::OUString& _rPropName,
+ sal_uInt16 _nItemId,
+ SfxItemSet& _rSet,
+ sal_Bool _bForceInvalidation = sal_False);
+ };
+
+ //------------------------------------------------------------------------
+ OFontPropertyExtractor::OFontPropertyExtractor(const Reference< XPropertySet >& _rxProps)
+ :m_xPropValueAccess(_rxProps)
+ ,m_xPropStateAccess(_rxProps, UNO_QUERY)
+ {
+ OSL_ENSURE(m_xPropValueAccess.is(), "OFontPropertyExtractor::OFontPropertyExtractor: invalid property set!");
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool OFontPropertyExtractor::getCheckFontProperty(const ::rtl::OUString& _rPropName, Any& _rValue)
+ {
+ _rValue = m_xPropValueAccess->getPropertyValue(_rPropName);
+ if (m_xPropStateAccess.is())
+ return PropertyState_DEFAULT_VALUE == m_xPropStateAccess->getPropertyState(_rPropName);
+
+ return sal_False;
+ }
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString OFontPropertyExtractor::getStringFontProperty(const ::rtl::OUString& _rPropName, const ::rtl::OUString& _rDefault)
+ {
+ Any aValue;
+ if (getCheckFontProperty(_rPropName, aValue))
+ return _rDefault;
+
+ return ::comphelper::getString(aValue);
+ }
+
+ //------------------------------------------------------------------------
+ sal_Int16 OFontPropertyExtractor::getInt16FontProperty(const ::rtl::OUString& _rPropName, const sal_Int16 _nDefault)
+ {
+ Any aValue;
+ if (getCheckFontProperty(_rPropName, aValue))
+ return _nDefault;
+
+ sal_Int32 nValue(_nDefault);
+ ::cppu::enum2int(nValue, aValue);
+ return (sal_Int16)nValue;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Int32 OFontPropertyExtractor::getInt32FontProperty(const ::rtl::OUString& _rPropName, const sal_Int32 _nDefault)
+ {
+ Any aValue;
+ if (getCheckFontProperty(_rPropName, aValue))
+ return _nDefault;
+
+ sal_Int32 nValue(_nDefault);
+ ::cppu::enum2int(nValue, aValue);
+ return nValue;
+ }
+
+ //------------------------------------------------------------------------
+ float OFontPropertyExtractor::getFloatFontProperty(const ::rtl::OUString& _rPropName, const float _nDefault)
+ {
+ Any aValue;
+ if (getCheckFontProperty(_rPropName, aValue))
+ return _nDefault;
+
+ return ::comphelper::getFloat(aValue);
+ }
+
+ //------------------------------------------------------------------------
+ void OFontPropertyExtractor::invalidateItem(const ::rtl::OUString& _rPropName, sal_uInt16 _nItemId, SfxItemSet& _rSet, sal_Bool _bForceInvalidation)
+ {
+ if ( _bForceInvalidation
+ || ( m_xPropStateAccess.is()
+ && (PropertyState_AMBIGUOUS_VALUE == m_xPropStateAccess->getPropertyState(_rPropName))
+ )
+ )
+ _rSet.InvalidateItem(_nItemId);
+ }
+
+ //========================================================================
+ //= ControlCharacterDialog
+ //========================================================================
+ //------------------------------------------------------------------------
+ ControlCharacterDialog::ControlCharacterDialog(Window* _pParent, const SfxItemSet& _rCoreSet)
+ :SfxTabDialog(_pParent, PcrRes(RID_TABDLG_FONTDIALOG), &_rCoreSet)
+ {
+ FreeResource();
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "CreateFactory fail!");
+ AddTabPage(TABPAGE_CHARACTERS, pFact->GetTabPageCreatorFunc(RID_SVXPAGE_CHAR_NAME), 0 );
+ AddTabPage(TABPAGE_CHARACTERS_EXT, pFact->GetTabPageCreatorFunc(RID_SVXPAGE_CHAR_EFFECTS), 0 );
+ }
+
+ //------------------------------------------------------------------------
+ ControlCharacterDialog::~ControlCharacterDialog()
+ {
+ }
+
+ //------------------------------------------------------------------------
+ void ControlCharacterDialog::translatePropertiesToItems(const Reference< XPropertySet >& _rxModel, SfxItemSet* _pSet)
+ {
+ OSL_ENSURE(_pSet && _rxModel.is(), "ControlCharacterDialog::translatePropertiesToItems: invalid arguments!");
+ if (!_pSet || !_rxModel.is())
+ return;
+
+ try
+ {
+ OFontPropertyExtractor aPropExtractor(_rxModel);
+
+ // some items, which may be in default state, have to be filled with non-void information
+ Font aDefaultVCLFont = Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
+ ::com::sun::star::awt::FontDescriptor aDefaultFont = VCLUnoHelper::CreateFontDescriptor(aDefaultVCLFont);
+
+ // get the current properties
+ ::rtl::OUString aFontName = aPropExtractor.getStringFontProperty(PROPERTY_FONT_NAME, aDefaultFont.Name);
+ ::rtl::OUString aFontStyleName = aPropExtractor.getStringFontProperty(PROPERTY_FONT_STYLENAME, aDefaultFont.StyleName);
+ sal_Int16 nFontFamily = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_FAMILY, aDefaultFont.Family);
+ sal_Int16 nFontCharset = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_CHARSET, aDefaultFont.CharSet);
+ float nFontHeight = aPropExtractor.getFloatFontProperty(PROPERTY_FONT_HEIGHT, (float)aDefaultFont.Height);
+ float nFontWeight = aPropExtractor.getFloatFontProperty(PROPERTY_FONT_WEIGHT, aDefaultFont.Weight);
+ sal_Int16 nFontSlant = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_SLANT, (sal_Int16)aDefaultFont.Slant);
+ sal_Int16 nFontUnderline = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_UNDERLINE, aDefaultFont.Underline);
+ sal_Int16 nFontStrikeout = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_STRIKEOUT, aDefaultFont.Strikeout);
+
+ sal_Int32 nTextLineColor = aPropExtractor.getInt32FontProperty(PROPERTY_TEXTLINECOLOR, COL_AUTO);
+ sal_Int16 nFontRelief = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_RELIEF, (sal_Int16)aDefaultVCLFont.GetRelief());
+ sal_Int16 nFontEmphasisMark = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_EMPHASIS_MARK, aDefaultVCLFont.GetEmphasisMark());
+
+ Any aValue;
+ sal_Bool bWordLineMode = aPropExtractor.getCheckFontProperty(PROPERTY_WORDLINEMODE, aValue) ? aDefaultFont.WordLineMode : ::cppu::any2bool(aValue);
+ sal_Int32 nColor32 = aPropExtractor.getInt32FontProperty(PROPERTY_TEXTCOLOR, 0);
+
+ // build SfxItems with the values
+ SvxFontItem aFontItem((FontFamily)nFontFamily, aFontName, aFontStyleName, PITCH_DONTKNOW, nFontCharset, CFID_FONT);
+
+ nFontHeight = (float)OutputDevice::LogicToLogic(Size(0, (sal_Int32)nFontHeight), MAP_POINT, MAP_TWIP).Height();
+ SvxFontHeightItem aSvxFontHeightItem((sal_uInt32)nFontHeight,100,CFID_HEIGHT);
+
+ FontWeight eWeight=VCLUnoHelper::ConvertFontWeight(nFontWeight);
+ FontItalic eItalic=(FontItalic)nFontSlant;
+ FontUnderline eUnderline=(FontUnderline)nFontUnderline;
+ FontStrikeout eStrikeout=(FontStrikeout)nFontStrikeout;
+
+ SvxWeightItem aWeightItem(eWeight,CFID_WEIGHT);
+ SvxPostureItem aPostureItem(eItalic,CFID_POSTURE);
+
+ SvxCrossedOutItem aCrossedOutItem(eStrikeout,CFID_STRIKEOUT);
+ SvxWordLineModeItem aWordLineModeItem(bWordLineMode, CFID_WORDLINEMODE);
+
+ SvxUnderlineItem aUnderlineItem(eUnderline,CFID_UNDERLINE);
+ aUnderlineItem.SetColor(Color(nTextLineColor));
+
+ SvxColorItem aSvxColorItem(nColor32,CFID_CHARCOLOR);
+ SvxLanguageItem aLanguageItem(Application::GetSettings().GetUILanguage(), CFID_LANGUAGE);
+
+ // the 2 CJK props
+ SvxCharReliefItem aFontReliefItem((FontRelief)nFontRelief, CFID_RELIEF);
+ SvxEmphasisMarkItem aEmphasisMarkitem((FontEmphasisMark)nFontEmphasisMark, CFID_EMPHASIS);
+
+ _pSet->Put(aFontItem, CFID_FONT);
+ _pSet->Put(aSvxFontHeightItem,CFID_HEIGHT);
+ _pSet->Put(aWeightItem, CFID_WEIGHT);
+ _pSet->Put(aPostureItem, CFID_POSTURE);
+ _pSet->Put(aLanguageItem, CFID_LANGUAGE);
+ _pSet->Put(aUnderlineItem,CFID_UNDERLINE);
+ _pSet->Put(aCrossedOutItem,CFID_STRIKEOUT);
+ _pSet->Put(aWordLineModeItem, CFID_WORDLINEMODE);
+ _pSet->Put(aSvxColorItem, CFID_CHARCOLOR);
+ _pSet->Put(aFontReliefItem, CFID_RELIEF);
+ _pSet->Put(aEmphasisMarkitem, CFID_EMPHASIS);
+
+ aPropExtractor.invalidateItem(PROPERTY_FONT_NAME, CFID_FONT, *_pSet);
+ aPropExtractor.invalidateItem(PROPERTY_FONT_HEIGHT, CFID_HEIGHT, *_pSet);
+ aPropExtractor.invalidateItem(PROPERTY_FONT_WEIGHT, CFID_WEIGHT, *_pSet, ::com::sun::star::awt::FontWeight::DONTKNOW == nFontWeight);
+ aPropExtractor.invalidateItem(PROPERTY_FONT_SLANT, CFID_POSTURE, *_pSet, ::com::sun::star::awt::FontSlant_DONTKNOW == nFontSlant);
+ aPropExtractor.invalidateItem(PROPERTY_FONT_UNDERLINE, CFID_UNDERLINE, *_pSet, ::com::sun::star::awt::FontUnderline::DONTKNOW == nFontUnderline);
+ aPropExtractor.invalidateItem(PROPERTY_FONT_STRIKEOUT, CFID_STRIKEOUT, *_pSet, ::com::sun::star::awt::FontStrikeout::DONTKNOW == nFontStrikeout);
+ aPropExtractor.invalidateItem(PROPERTY_WORDLINEMODE, CFID_WORDLINEMODE, *_pSet);
+ aPropExtractor.invalidateItem(PROPERTY_TEXTCOLOR, CFID_CHARCOLOR, *_pSet);
+ aPropExtractor.invalidateItem(PROPERTY_FONT_RELIEF, CFID_RELIEF, *_pSet);
+ aPropExtractor.invalidateItem(PROPERTY_FONT_EMPHASIS_MARK, CFID_EMPHASIS, *_pSet);
+ }
+ catch (Exception&)
+ {
+ DBG_ERROR("ControlCharacterDialog::translatePropertiesToItems: caught an exception!");
+ }
+
+ _pSet->DisableItem(SID_ATTR_CHAR_CJK_FONT);
+ _pSet->DisableItem(SID_ATTR_CHAR_CJK_FONTHEIGHT);
+ _pSet->DisableItem(SID_ATTR_CHAR_CJK_LANGUAGE);
+ _pSet->DisableItem(SID_ATTR_CHAR_CJK_POSTURE);
+ _pSet->DisableItem(SID_ATTR_CHAR_CJK_WEIGHT);
+
+ _pSet->DisableItem(SID_ATTR_CHAR_CASEMAP);
+ _pSet->DisableItem(SID_ATTR_CHAR_CONTOUR);
+ _pSet->DisableItem(SID_ATTR_CHAR_SHADOWED);
+
+ }
+
+ //------------------------------------------------------------------------
+ namespace
+ {
+ void lcl_pushBackPropertyValue( Sequence< NamedValue >& _out_properties, const ::rtl::OUString& _name, const Any& _value )
+ {
+ _out_properties.realloc( _out_properties.getLength() + 1 );
+ _out_properties[ _out_properties.getLength() - 1 ] = NamedValue( _name, _value );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void ControlCharacterDialog::translateItemsToProperties( const SfxItemSet& _rSet, Sequence< NamedValue >& _out_properties )
+ {
+ _out_properties.realloc( 0 );
+
+ try
+ {
+ // --------------------------
+ // font name
+ SfxItemState eState = _rSet.GetItemState(CFID_FONT);
+
+ if ( eState == SFX_ITEM_SET )
+ {
+ const SvxFontItem& rFontItem =
+ static_cast<const SvxFontItem&>(_rSet.Get(CFID_FONT));
+
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_NAME , makeAny(::rtl::OUString(rFontItem.GetFamilyName())));
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_STYLENAME, makeAny(::rtl::OUString(rFontItem.GetStyleName())));
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_FAMILY , makeAny((sal_Int16)rFontItem.GetFamily()));
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_CHARSET , makeAny((sal_Int16)rFontItem.GetCharSet()));
+ }
+
+ // --------------------------
+ // font height
+ eState = _rSet.GetItemState(CFID_HEIGHT);
+
+ if ( eState == SFX_ITEM_SET )
+ {
+ const SvxFontHeightItem& rSvxFontHeightItem =
+ static_cast<const SvxFontHeightItem&>(_rSet.Get(CFID_HEIGHT));
+
+ float nHeight = (float)OutputDevice::LogicToLogic(Size(0, rSvxFontHeightItem.GetHeight()), MAP_TWIP, MAP_POINT).Height();
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_HEIGHT,makeAny(nHeight));
+
+ }
+
+ // --------------------------
+ // font weight
+ eState = _rSet.GetItemState(CFID_WEIGHT);
+
+ if ( eState == SFX_ITEM_SET )
+ {
+ const SvxWeightItem& rWeightItem =
+ static_cast<const SvxWeightItem&>(_rSet.Get(CFID_WEIGHT));
+
+ float nWeight = VCLUnoHelper::ConvertFontWeight( rWeightItem.GetWeight());
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_WEIGHT,makeAny(nWeight));
+ }
+
+ // --------------------------
+ // font slant
+ eState = _rSet.GetItemState(CFID_POSTURE);
+
+ if ( eState == SFX_ITEM_SET )
+ {
+ const SvxPostureItem& rPostureItem =
+ static_cast<const SvxPostureItem&>(_rSet.Get(CFID_POSTURE));
+
+ ::com::sun::star::awt::FontSlant eSlant = (::com::sun::star::awt::FontSlant)rPostureItem.GetPosture();
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_SLANT, makeAny((sal_Int16)eSlant));
+ }
+
+ // --------------------------
+ // font underline
+ eState = _rSet.GetItemState(CFID_UNDERLINE);
+
+ if ( eState == SFX_ITEM_SET )
+ {
+ const SvxUnderlineItem& rUnderlineItem =
+ static_cast<const SvxUnderlineItem&>(_rSet.Get(CFID_UNDERLINE));
+
+ sal_Int16 nUnderline = (sal_Int16)rUnderlineItem.GetLineStyle();
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_UNDERLINE,makeAny(nUnderline));
+
+ // the text line color is transported in this item, too
+ sal_Int32 nColor = rUnderlineItem.GetColor().GetColor();
+
+ Any aUnoColor;
+ if (COL_AUTO != (sal_uInt32)nColor)
+ aUnoColor <<= nColor;
+
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_TEXTLINECOLOR, aUnoColor );
+ }
+
+ // --------------------------
+ // font strikeout
+ eState = _rSet.GetItemState(CFID_STRIKEOUT);
+
+ if ( eState == SFX_ITEM_SET )
+ {
+ const SvxCrossedOutItem& rCrossedOutItem =
+ static_cast<const SvxCrossedOutItem&>(_rSet.Get(CFID_STRIKEOUT));
+
+ sal_Int16 nStrikeout = (sal_Int16)rCrossedOutItem.GetStrikeout();
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_STRIKEOUT,makeAny(nStrikeout));
+ }
+
+
+ // --------------------------
+ // font wordline mode
+ eState = _rSet.GetItemState(CFID_WORDLINEMODE);
+
+ if ( eState == SFX_ITEM_SET )
+ {
+ const SvxWordLineModeItem& rWordLineModeItem =
+ static_cast<const SvxWordLineModeItem&>(_rSet.Get(CFID_WORDLINEMODE));
+
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_WORDLINEMODE, ::cppu::bool2any(rWordLineModeItem.GetValue()));
+ }
+
+
+ // --------------------------
+ // text color
+ eState = _rSet.GetItemState(CFID_CHARCOLOR);
+
+ if ( eState == SFX_ITEM_SET )
+ {
+ const SvxColorItem& rColorItem =
+ static_cast<const SvxColorItem&>(_rSet.Get(CFID_CHARCOLOR));
+
+ sal_Int32 nColor = rColorItem.GetValue().GetColor();
+
+ Any aUnoColor;
+ if (COL_AUTO != (sal_uInt32)nColor)
+ aUnoColor <<= nColor;
+
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_TEXTCOLOR, aUnoColor );
+ }
+
+ // --------------------------
+ // font relief
+ eState = _rSet.GetItemState(CFID_RELIEF);
+
+ if ( eState == SFX_ITEM_SET )
+ {
+ const SvxCharReliefItem& rReliefItem =
+ static_cast<const SvxCharReliefItem&>(_rSet.Get(CFID_RELIEF));
+
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_RELIEF, makeAny((sal_Int16)rReliefItem.GetValue()) );
+ }
+
+ // --------------------------
+ // font emphasis mark
+ eState = _rSet.GetItemState(CFID_EMPHASIS);
+
+ if ( eState == SFX_ITEM_SET )
+ {
+ const SvxEmphasisMarkItem& rEmphMarkItem =
+ static_cast<const SvxEmphasisMarkItem&>(_rSet.Get(CFID_EMPHASIS));
+
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_EMPHASIS_MARK, makeAny((sal_Int16)rEmphMarkItem.GetEmphasisMark()) );
+ }
+ }
+ catch (const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void ControlCharacterDialog::translateItemsToProperties( const SfxItemSet& _rSet, const Reference< XPropertySet >& _rxModel)
+ {
+ OSL_ENSURE( _rxModel.is(), "ControlCharacterDialog::translateItemsToProperties: invalid arguments!" );
+ if ( !_rxModel.is())
+ return;
+
+ Sequence< NamedValue > aPropertyValues;
+ translateItemsToProperties( _rSet, aPropertyValues );
+ try
+ {
+ const NamedValue* propertyValue = aPropertyValues.getConstArray();
+ const NamedValue* propertyValueEnd = propertyValue + aPropertyValues.getLength();
+ for ( ; propertyValue != propertyValueEnd; ++propertyValue )
+ _rxModel->setPropertyValue( propertyValue->Name, propertyValue->Value );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------------
+ SfxItemSet* ControlCharacterDialog::createItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults)
+ {
+ // just to be sure ....
+ _rpSet = NULL;
+ _rpPool = NULL;
+ _rppDefaults = NULL;
+
+ // create and initialize the defaults
+ _rppDefaults = new SfxPoolItem*[CFID_LAST_ITEM_ID - CFID_FIRST_ITEM_ID + 1];
+
+ Font aDefaultVCLFont = Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
+
+ SfxPoolItem** pCounter = _rppDefaults; // want to modify this without affecting the out param _rppDefaults
+ *pCounter++ = new SvxFontItem(aDefaultVCLFont.GetFamily(), aDefaultVCLFont.GetName(), aDefaultVCLFont.GetStyleName(), aDefaultVCLFont.GetPitch(), aDefaultVCLFont.GetCharSet(), CFID_FONT);
+ *pCounter++ = new SvxFontHeightItem(aDefaultVCLFont.GetHeight(), 100, CFID_HEIGHT);
+ *pCounter++ = new SvxWeightItem(aDefaultVCLFont.GetWeight(), CFID_WEIGHT);
+ *pCounter++ = new SvxPostureItem(aDefaultVCLFont.GetItalic(), CFID_POSTURE);
+ *pCounter++ = new SvxLanguageItem(Application::GetSettings().GetUILanguage(), CFID_LANGUAGE);
+ *pCounter++ = new SvxUnderlineItem(aDefaultVCLFont.GetUnderline(), CFID_UNDERLINE);
+ *pCounter++ = new SvxCrossedOutItem(aDefaultVCLFont.GetStrikeout(), CFID_STRIKEOUT);
+ *pCounter++ = new SvxWordLineModeItem(aDefaultVCLFont.IsWordLineMode(), CFID_WORDLINEMODE);
+ *pCounter++ = new SvxColorItem(aDefaultVCLFont.GetColor(), CFID_CHARCOLOR);
+ *pCounter++ = new SvxCharReliefItem(aDefaultVCLFont.GetRelief(), CFID_RELIEF);
+ *pCounter++ = new SvxEmphasisMarkItem(aDefaultVCLFont.GetEmphasisMark(), CFID_EMPHASIS);
+
+ *pCounter++ = new SvxFontItem(aDefaultVCLFont.GetFamily(), aDefaultVCLFont.GetName(), aDefaultVCLFont.GetStyleName(), aDefaultVCLFont.GetPitch(), aDefaultVCLFont.GetCharSet(), CFID_CJK_FONT);
+ *pCounter++ = new SvxFontHeightItem(aDefaultVCLFont.GetHeight(), 100, CFID_CJK_HEIGHT);
+ *pCounter++ = new SvxWeightItem(aDefaultVCLFont.GetWeight(), CFID_CJK_WEIGHT);
+ *pCounter++ = new SvxPostureItem(aDefaultVCLFont.GetItalic(), CFID_CJK_POSTURE);
+ *pCounter++ = new SvxLanguageItem(Application::GetSettings().GetUILanguage(), CFID_CJK_LANGUAGE);
+
+ *pCounter++ = new SvxCaseMapItem(SVX_CASEMAP_NOT_MAPPED, CFID_CASEMAP);
+ *pCounter++ = new SvxContourItem(sal_False, CFID_CONTOUR);
+ *pCounter++ = new SvxShadowedItem(sal_False, CFID_SHADOWED);
+
+ *pCounter++ = new SvxFontListItem (new FontList(Application::GetDefaultDevice()), CFID_FONTLIST);
+
+ // create the pool
+ static SfxItemInfo __READONLY_DATA aItemInfos[CFID_LAST_ITEM_ID - CFID_FIRST_ITEM_ID + 1] =
+ {
+ { SID_ATTR_CHAR_FONT, 0 },
+ { SID_ATTR_CHAR_FONTHEIGHT, 0 },
+ { SID_ATTR_CHAR_WEIGHT, 0 },
+ { SID_ATTR_CHAR_POSTURE, 0 },
+ { SID_ATTR_CHAR_LANGUAGE, 0 },
+ { SID_ATTR_CHAR_UNDERLINE, 0 },
+ { SID_ATTR_CHAR_STRIKEOUT, 0 },
+ { SID_ATTR_CHAR_WORDLINEMODE, 0 },
+ { SID_ATTR_CHAR_COLOR, 0 },
+ { SID_ATTR_CHAR_RELIEF, 0 },
+ { SID_ATTR_CHAR_EMPHASISMARK, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { SID_ATTR_CHAR_FONTLIST, 0 }
+ };
+
+ _rpPool = new SfxItemPool(String::CreateFromAscii("PCRControlFontItemPool"), CFID_FIRST_ITEM_ID, CFID_LAST_ITEM_ID,
+ aItemInfos, _rppDefaults);
+ _rpPool->FreezeIdRanges();
+
+ // and, finally, the set
+ _rpSet = new SfxItemSet(*_rpPool, sal_True);
+
+ return _rpSet;
+ }
+
+ //-------------------------------------------------------------------------
+ void ControlCharacterDialog::destroyItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults)
+ {
+ // from the pool, get and remember the font list (needs to be deleted)
+ const SvxFontListItem& rFontListItem = static_cast<const SvxFontListItem&>(_rpPool->GetDefaultItem(CFID_FONTLIST));
+ const FontList* pFontList = rFontListItem.GetFontList();
+
+ // _first_ delete the set (refering the pool)
+ if (_rpSet)
+ {
+ delete _rpSet;
+ _rpSet = NULL;
+ }
+
+ // delete the pool
+ if (_rpPool)
+ {
+ _rpPool->ReleaseDefaults(sal_True);
+ // the "true" means delete the items, too
+ SfxItemPool::Free(_rpPool);
+ _rpPool = NULL;
+ }
+
+ // reset the defaults ptr
+ _rppDefaults = NULL;
+ // no need to explicitly delete the defaults, this has been done by the ReleaseDefaults
+
+ delete pFontList;
+ }
+
+ //------------------------------------------------------------------------
+ void ControlCharacterDialog::PageCreated( sal_uInt16 _nId, SfxTabPage& _rPage )
+ {
+ SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
+ switch ( _nId )
+ {
+ case TABPAGE_CHARACTERS:
+//CHINA001 static_cast<SvxCharNamePage&>(_rPage).SetFontList(
+//CHINA001 static_cast<const SvxFontListItem&>(GetInputSetImpl()->Get(CFID_FONTLIST))
+//CHINA001 );
+//CHINA001 static_cast<SvxCharNamePage&>(_rPage).DisableControls( DISABLE_HIDE_LANGUAGE );
+
+//CHINA001 SvxFontListItem aFontListItem( static_cast<const SvxFontListItem&>(GetInputSetImpl()->Get(CFID_FONTLIST) ));
+//CHINA001 aSet.Put ( SvxFontListItem( aFontListItem.GetFontList(), SID_ATTR_CHAR_FONTLIST));
+
+// aSet.Put (SfxUInt16Item(SID_CFID_FONTLIST,CFID_FONTLIST));
+ aSet.Put (SvxFontListItem(static_cast<const SvxFontListItem&>(GetInputSetImpl()->Get(CFID_FONTLIST))));
+ aSet.Put (SfxUInt16Item(SID_DISABLE_CTL,DISABLE_HIDE_LANGUAGE));
+ _rPage.PageCreated(aSet);
+ break;
+ }
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
diff --git a/extensions/source/propctrlr/fontdialog.hxx b/extensions/source/propctrlr/fontdialog.hxx
new file mode 100644
index 000000000000..5604270ac037
--- /dev/null
+++ b/extensions/source/propctrlr/fontdialog.hxx
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_FONTDIALOG_HXX_
+#define _EXTENSIONS_PROPCTRLR_FONTDIALOG_HXX_
+
+#include <sfx2/tabdlg.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+
+class SvxFontListItem;
+class FontList;
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ //========================================================================
+ //= ControlCharacterDialog
+ //========================================================================
+ class ControlCharacterDialog : public SfxTabDialog
+ {
+ public:
+ ControlCharacterDialog(Window* _pParent, const SfxItemSet& _rCoreSet);
+ ~ControlCharacterDialog();
+
+ /// creates an item set to be used with this dialog
+ static SfxItemSet* createItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults);
+
+ /// destroys an item previously created with <method>createItemSet</method>
+ static void destroyItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults);
+
+ /// fills the given item set with values obtained from the given property set
+ static void translatePropertiesToItems(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel,
+ SfxItemSet* _pSet);
+
+ /** fills the given property set with values obtained from the given item set
+ */
+ static void translateItemsToProperties(
+ const SfxItemSet& _rSet,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel);
+
+ /** fills the given property set with values obtained from the given item set
+ */
+ static void translateItemsToProperties(
+ const SfxItemSet& _rSet,
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& _out_properties );
+
+ protected:
+ virtual void PageCreated(sal_uInt16 _nId, SfxTabPage& _rPage);
+ };
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_FONTDIALOG_HXX_
+
diff --git a/extensions/source/propctrlr/fontdialog.src b/extensions/source/propctrlr/fontdialog.src
new file mode 100644
index 000000000000..51dbb6913178
--- /dev/null
+++ b/extensions/source/propctrlr/fontdialog.src
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_PROPRESID_HRC
+#include "formresid.hrc"
+#endif
+#ifndef _EXTENSIONS_PROPCTRLR_FORMLOCALID_HRC_
+#include "formlocalid.hrc"
+#endif
+
+TabDialog RID_TABDLG_FONTDIALOG
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Text [ en-US ] = "Character" ;
+ Moveable = TRUE ;
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = TABPAGE_CHARACTERS ;
+ PageResID = TABPAGE_CHARACTERS ;
+ Text [ en-US ] = "Font" ;
+ };
+ PageItem
+ {
+ Identifier = TABPAGE_CHARACTERS_EXT ;
+ PageResID = TABPAGE_CHARACTERS_EXT ;
+ Text [ en-US ] = "Font Effects" ;
+ };
+ };
+ };
+};
diff --git a/extensions/source/propctrlr/fontitemids.hxx b/extensions/source/propctrlr/fontitemids.hxx
new file mode 100644
index 000000000000..0296f31f5d9d
--- /dev/null
+++ b/extensions/source/propctrlr/fontitemids.hxx
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_FONTITEMIDS_HXX_
+#define _EXTENSIONS_PROPCTRLR_FONTITEMIDS_HXX_
+
+#define CFID_FONT 1
+#define CFID_HEIGHT 2
+#define CFID_WEIGHT 3
+#define CFID_POSTURE 4
+#define CFID_LANGUAGE 5
+#define CFID_UNDERLINE 6
+#define CFID_STRIKEOUT 7
+#define CFID_WORDLINEMODE 8
+#define CFID_CHARCOLOR 9
+#define CFID_RELIEF 10
+#define CFID_EMPHASIS 11
+
+#define CFID_CJK_FONT 12
+#define CFID_CJK_HEIGHT 13
+#define CFID_CJK_WEIGHT 14
+#define CFID_CJK_POSTURE 15
+#define CFID_CJK_LANGUAGE 16
+#define CFID_CASEMAP 17
+#define CFID_CONTOUR 18
+#define CFID_SHADOWED 19
+
+#define CFID_FONTLIST 20
+
+#define CFID_FIRST_ITEM_ID CFID_FONT
+#define CFID_LAST_ITEM_ID CFID_FONTLIST
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_FONTITEMIDS_HXX_
+
diff --git a/extensions/source/propctrlr/formbrowsertools.cxx b/extensions/source/propctrlr/formbrowsertools.cxx
new file mode 100644
index 000000000000..ed75149ac460
--- /dev/null
+++ b/extensions/source/propctrlr/formbrowsertools.cxx
@@ -0,0 +1,148 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "formbrowsertools.hxx"
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
+#include "formresid.hrc"
+#endif
+#ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
+#include "modulepcr.hxx"
+#endif
+#include <tools/string.hxx>
+#include "formstrings.hxx"
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::form;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString GetUIHeadlineName(sal_Int16 nClassId, const Any& aUnoObj)
+ {
+ PcrClient aResourceAccess;
+ // this ensures that we have our resource file loaded
+
+ ::rtl::OUString sClassName;
+ switch (nClassId)
+ {
+ case FormComponentType::TEXTFIELD:
+ {
+ Reference< XInterface > xIFace;
+ aUnoObj >>= xIFace;
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_EDIT));
+ if (xIFace.is())
+ { // we have a chance to check if it's a formatted field model
+ Reference< XServiceInfo > xInfo(xIFace, UNO_QUERY);
+ if (xInfo.is() && (xInfo->supportsService(SERVICE_COMPONENT_FORMATTEDFIELD)))
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_FORMATTED));
+ else if (!xInfo.is())
+ {
+ // couldn't distinguish between formatted and edit with the service name, so try with the properties
+ Reference< XPropertySet > xProps(xIFace, UNO_QUERY);
+ if (xProps.is())
+ {
+ Reference< XPropertySetInfo > xPropsInfo = xProps->getPropertySetInfo();
+ if (xPropsInfo.is() && xPropsInfo->hasPropertyByName(PROPERTY_FORMATSSUPPLIER))
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_FORMATTED));
+ }
+ }
+ }
+ }
+ break;
+
+ case FormComponentType::COMMANDBUTTON:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_PUSHBUTTON)); break;
+ case FormComponentType::RADIOBUTTON:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_RADIOBUTTON)); break;
+ case FormComponentType::CHECKBOX:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_CHECKBOX)); break;
+ case FormComponentType::LISTBOX:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_LISTBOX)); break;
+ case FormComponentType::COMBOBOX:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_COMBOBOX)); break;
+ case FormComponentType::GROUPBOX:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_GROUPBOX)); break;
+ case FormComponentType::IMAGEBUTTON:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_IMAGEBUTTON)); break;
+ case FormComponentType::FIXEDTEXT:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_FIXEDTEXT)); break;
+ case FormComponentType::GRIDCONTROL:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_DBGRID)); break;
+ case FormComponentType::FILECONTROL:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_FILECONTROL)); break;
+
+ case FormComponentType::DATEFIELD:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_DATEFIELD)); break;
+ case FormComponentType::TIMEFIELD:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_TIMEFIELD)); break;
+ case FormComponentType::NUMERICFIELD:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_NUMERICFIELD)); break;
+ case FormComponentType::CURRENCYFIELD:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_CURRENCYFIELD)); break;
+ case FormComponentType::PATTERNFIELD:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_PATTERNFIELD)); break;
+ case FormComponentType::IMAGECONTROL:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_IMAGECONTROL)); break;
+ case FormComponentType::HIDDENCONTROL:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_HIDDENCONTROL)); break;
+
+ case FormComponentType::CONTROL:
+ default:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_UNKNOWNCONTROL)); break;
+ }
+
+ return sClassName;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Int16 classifyComponent( const Reference< XInterface >& _rxComponent )
+ {
+ Reference< XPropertySet > xComponentProps( _rxComponent, UNO_QUERY_THROW );
+ Reference< XPropertySetInfo > xPSI( xComponentProps->getPropertySetInfo(), UNO_SET_THROW );
+
+ sal_Int16 nControlType( FormComponentType::CONTROL );
+ if ( xPSI->hasPropertyByName( PROPERTY_CLASSID ) )
+ {
+ OSL_VERIFY( xComponentProps->getPropertyValue( PROPERTY_CLASSID ) >>= nControlType );
+ }
+ return nControlType;
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
diff --git a/extensions/source/propctrlr/formbrowsertools.hxx b/extensions/source/propctrlr/formbrowsertools.hxx
new file mode 100644
index 000000000000..619c48cb4d6b
--- /dev/null
+++ b/extensions/source/propctrlr/formbrowsertools.hxx
@@ -0,0 +1,108 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_FORMSCTRLR_FORMBROWSERTOOLS_HXX_
+#define _EXTENSIONS_FORMSCTRLR_FORMBROWSERTOOLS_HXX_
+
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/beans/Property.hpp>
+#include <rtl/ustring.hxx>
+
+#include <functional>
+#include <set>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ ::rtl::OUString GetUIHeadlineName(sal_Int16 _nClassId, const ::com::sun::star::uno::Any& _rUnoObject);
+ sal_Int16 classifyComponent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent );
+
+ //========================================================================
+ struct FindPropertyByHandle : public ::std::unary_function< ::com::sun::star::beans::Property, bool >
+ {
+ private:
+ sal_Int32 m_nId;
+
+ public:
+ FindPropertyByHandle( sal_Int32 _nId ) : m_nId ( _nId ) { }
+ bool operator()( const ::com::sun::star::beans::Property& _rProp ) const
+ {
+ return m_nId == _rProp.Handle;
+ }
+ };
+
+ //========================================================================
+ struct FindPropertyByName : public ::std::unary_function< ::com::sun::star::beans::Property, bool >
+ {
+ private:
+ ::rtl::OUString m_sName;
+
+ public:
+ FindPropertyByName( const ::rtl::OUString& _rName ) : m_sName( _rName ) { }
+ bool operator()( const ::com::sun::star::beans::Property& _rProp ) const
+ {
+ return m_sName == _rProp.Name;
+ }
+ };
+
+ //========================================================================
+ struct PropertyLessByName
+ :public ::std::binary_function < ::com::sun::star::beans::Property,
+ ::com::sun::star::beans::Property,
+ bool
+ >
+ {
+ bool operator() (::com::sun::star::beans::Property _rLhs, ::com::sun::star::beans::Property _rRhs) const
+ {
+ return _rLhs.Name < _rRhs.Name ? true : false;
+ }
+ };
+
+ //========================================================================
+ struct TypeLessByName
+ :public ::std::binary_function < ::com::sun::star::uno::Type,
+ ::com::sun::star::uno::Type,
+ bool
+ >
+ {
+ bool operator() (::com::sun::star::uno::Type _rLhs, ::com::sun::star::uno::Type _rRhs) const
+ {
+ return _rLhs.getTypeName() < _rRhs.getTypeName() ? true : false;
+ }
+ };
+
+ //========================================================================
+ typedef ::std::set< ::com::sun::star::beans::Property, PropertyLessByName > PropertyBag;
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_FORMSCTRLR_FORMBROWSERTOOLS_HXX_
+
diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx
new file mode 100644
index 000000000000..bc83c820e909
--- /dev/null
+++ b/extensions/source/propctrlr/formcomponenthandler.cxx
@@ -0,0 +1,3341 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "controltype.hxx"
+#include "propctrlr.hrc"
+#include "extensio.hrc"
+#include "fontdialog.hxx"
+#include "formcomponenthandler.hxx"
+#include "formlinkdialog.hxx"
+#include "formmetadata.hxx"
+#include "formresid.hrc"
+#include "formstrings.hxx"
+#include "handlerhelper.hxx"
+#include "listselectiondlg.hxx"
+#include "pcrcommon.hxx"
+#include "selectlabeldialog.hxx"
+#include "taborder.hxx"
+#include "usercontrol.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/NullPointerException.hpp>
+#include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/form/XGridColumnFactory.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/form/ListSourceType.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
+#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
+#include <com/sun/star/awt/XTabControllerModel.hpp>
+#include <com/sun/star/form/FormSubmitEncoding.hpp>
+#include <com/sun/star/awt/VisualEffect.hpp>
+#include <com/sun/star/form/FormButtonType.hpp>
+#include <com/sun/star/inspection/PropertyControlType.hpp>
+#include <com/sun/star/util/MeasureUnit.hpp>
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+#include <com/sun/star/inspection/PropertyLineElement.hpp>
+#include <com/sun/star/resource/XStringResourceManager.hpp>
+#include <com/sun/star/resource/MissingResourceException.hpp>
+#include <com/sun/star/graphic/GraphicObject.hpp>
+#include <com/sun/star/text/WritingMode2.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/extract.hxx>
+#include <connectivity/dbconversion.hxx>
+#include <connectivity/dbexception.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <svl/ctloptions.hxx>
+#include <svtools/colrdlg.hxx>
+#include <svl/filenotation.hxx>
+#include <svl/intitem.hxx>
+#include <svl/itemset.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <svl/numuno.hxx>
+#include <svl/urihelper.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/numinf.hxx>
+#include <svx/svxdlg.hxx>
+#include <svx/svxids.hrc>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/msgbox.hxx>
+#include <vcl/stdtext.hxx>
+#include <vcl/wrkwin.hxx>
+#include <tools/StringListResource.hxx>
+
+#include <limits>
+
+#define GRAPHOBJ_URLPREFIX "vnd.sun.star.GraphicObject:"
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_FormComponentPropertyHandler()
+{
+ ::pcr::FormComponentPropertyHandler::registerImplementation();
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star;
+ using namespace uno;
+ using namespace lang;
+ using namespace beans;
+ using namespace frame;
+ using namespace script;
+ using namespace form;
+ using namespace util;
+ using namespace awt;
+ using namespace sdb;
+ using namespace sdbc;
+ using namespace sdbcx;
+ using namespace form;
+ using namespace container;
+ using namespace ui::dialogs;
+ using namespace inspection;
+ using namespace ::dbtools;
+
+ namespace WritingMode2 = ::com::sun::star::text::WritingMode2;
+
+ //====================================================================
+ //= FormComponentPropertyHandler
+ //====================================================================
+ DBG_NAME( FormComponentPropertyHandler )
+#define PROPERTY_ID_ROWSET 1
+ //--------------------------------------------------------------------
+ FormComponentPropertyHandler::FormComponentPropertyHandler( const Reference< XComponentContext >& _rxContext )
+ :FormComponentPropertyHandler_Base( _rxContext )
+ ,::comphelper::OPropertyContainer(FormComponentPropertyHandler_Base::rBHelper)
+ ,m_sDefaultValueString( String( PcrRes( RID_STR_STANDARD ) ) )
+ ,m_eComponentClass( eUnknown )
+ ,m_bComponentIsSubForm( false )
+ ,m_bHaveListSource( false )
+ ,m_bHaveCommand( false )
+ ,m_nClassId( 0 )
+ {
+ DBG_CTOR( FormComponentPropertyHandler, NULL );
+ registerProperty(PROPERTY_ROWSET,PROPERTY_ID_ROWSET,0,&m_xRowSet,::getCppuType(&m_xRowSet));
+ }
+
+ //--------------------------------------------------------------------
+ FormComponentPropertyHandler::~FormComponentPropertyHandler()
+ {
+ DBG_DTOR( FormComponentPropertyHandler, NULL );
+ }
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XINTERFACE2(FormComponentPropertyHandler,FormComponentPropertyHandler_Base,::comphelper::OPropertyContainer)
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL FormComponentPropertyHandler::getImplementationName_static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.FormComponentPropertyHandler" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL FormComponentPropertyHandler::getSupportedServiceNames_static( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported( 1 );
+ aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.FormComponentPropertyHandler" ) );
+ return aSupported;
+ }
+
+ //============================================
+ // TODO: -> export from toolkit
+ struct LanguageDependentProp
+ {
+ const char* pPropName;
+ sal_Int32 nPropNameLength;
+ };
+
+ static LanguageDependentProp aLanguageDependentProp[] =
+ {
+ { "Text", 4 },
+ { "Label", 5 },
+ { "Title", 5 },
+ { "HelpText", 8 },
+ { "CurrencySymbol", 14 },
+ { "StringItemList", 14 },
+ { 0, 0 }
+ };
+
+ namespace
+ {
+ bool lcl_isLanguageDependentProperty( ::rtl::OUString aName )
+ {
+ bool bRet = false;
+
+ LanguageDependentProp* pLangDepProp = aLanguageDependentProp;
+ while( pLangDepProp->pPropName != 0 )
+ {
+ if( aName.equalsAsciiL( pLangDepProp->pPropName, pLangDepProp->nPropNameLength ))
+ {
+ bRet = true;
+ break;
+ }
+ pLangDepProp++;
+ }
+ return bRet;
+ }
+
+ Reference< resource::XStringResourceResolver > lcl_getStringResourceResolverForProperty
+ ( Reference< XPropertySet > _xComponent, const ::rtl::OUString& _rPropertyName,
+ const Any& _rPropertyValue )
+ {
+ Reference< resource::XStringResourceResolver > xRet;
+ const TypeClass eType = _rPropertyValue.getValueType().getTypeClass();
+ if ( (eType == TypeClass_STRING || eType == TypeClass_SEQUENCE) &&
+ lcl_isLanguageDependentProperty( _rPropertyName ) )
+ {
+ static const ::rtl::OUString s_sResourceResolverPropName(RTL_CONSTASCII_USTRINGPARAM("ResourceResolver"));
+
+ Reference< resource::XStringResourceResolver > xStringResourceResolver;
+ try
+ {
+ xStringResourceResolver.set( _xComponent->getPropertyValue( s_sResourceResolverPropName ),UNO_QUERY);
+ if( xStringResourceResolver.is() &&
+ xStringResourceResolver->getLocales().getLength() > 0 )
+ {
+ xRet = xStringResourceResolver;
+ }
+ }
+ catch(UnknownPropertyException&)
+ {
+ // nii
+ }
+ }
+
+ return xRet;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Any FormComponentPropertyHandler::impl_getPropertyValue_throw( const ::rtl::OUString& _rPropertyName ) const
+ {
+ const PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ Any aPropertyValue( m_xComponent->getPropertyValue( _rPropertyName ) );
+
+ Reference< resource::XStringResourceResolver > xStringResourceResolver
+ = lcl_getStringResourceResolverForProperty( m_xComponent, _rPropertyName, aPropertyValue );
+ if( xStringResourceResolver.is() )
+ {
+ TypeClass eType = aPropertyValue.getValueType().getTypeClass();
+ if( eType == TypeClass_STRING )
+ {
+ ::rtl::OUString aPropStr;
+ aPropertyValue >>= aPropStr;
+ if( aPropStr.getLength() > 1 )
+ {
+ ::rtl::OUString aPureIdStr = aPropStr.copy( 1 );
+ if( xStringResourceResolver->hasEntryForId( aPureIdStr ) )
+ {
+ ::rtl::OUString aResourceStr = xStringResourceResolver->resolveString( aPureIdStr );
+ aPropertyValue <<= aResourceStr;
+ }
+ }
+ }
+ // StringItemList?
+ else if( eType == TypeClass_SEQUENCE )
+ {
+ Sequence< ::rtl::OUString > aStrings;
+ aPropertyValue >>= aStrings;
+
+ const ::rtl::OUString* pStrings = aStrings.getConstArray();
+ sal_Int32 nCount = aStrings.getLength();
+
+ Sequence< ::rtl::OUString > aResolvedStrings;
+ aResolvedStrings.realloc( nCount );
+ ::rtl::OUString* pResolvedStrings = aResolvedStrings.getArray();
+ try
+ {
+ for ( sal_Int32 i = 0; i < nCount; ++i )
+ {
+ ::rtl::OUString aIdStr = pStrings[i];
+ ::rtl::OUString aPureIdStr = aIdStr.copy( 1 );
+ if( xStringResourceResolver->hasEntryForId( aPureIdStr ) )
+ pResolvedStrings[i] = xStringResourceResolver->resolveString( aPureIdStr );
+ else
+ pResolvedStrings[i] = aIdStr;
+ }
+ }
+ catch( resource::MissingResourceException & )
+ {}
+ aPropertyValue <<= aResolvedStrings;
+ }
+ }
+ else
+ impl_normalizePropertyValue_nothrow( aPropertyValue, nPropId );
+
+ return aPropertyValue;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL FormComponentPropertyHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ if( _rPropertyName == PROPERTY_ROWSET )
+ return ::comphelper::OPropertyContainer::getPropertyValue( _rPropertyName );
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return impl_getPropertyValue_throw( _rPropertyName );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormComponentPropertyHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ if( _rPropertyName == PROPERTY_ROWSET )
+ {
+ ::comphelper::OPropertyContainer::setPropertyValue( _rPropertyName, _rValue );
+ return;
+ }
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) ); // check if property is known by the handler
+
+ Reference< graphic::XGraphicObject > xGrfObj;
+ if ( PROPERTY_ID_IMAGE_URL == nPropId && ( _rValue >>= xGrfObj ) )
+ {
+ DBG_ASSERT( xGrfObj.is(), "FormComponentPropertyHandler::setPropertyValue() xGrfObj is invalid");
+ rtl::OUString sObjectID( RTL_CONSTASCII_USTRINGPARAM( GRAPHOBJ_URLPREFIX ) );
+ sObjectID = sObjectID + xGrfObj->getUniqueID();
+ m_xComponent->setPropertyValue( _rPropertyName, uno::makeAny( sObjectID ) );
+ }
+ else if ( PROPERTY_ID_FONT == nPropId )
+ {
+ // special handling, the value is a faked value we generated ourself in impl_executeFontDialog_nothrow
+ Sequence< NamedValue > aFontPropertyValues;
+ OSL_VERIFY( _rValue >>= aFontPropertyValues );
+ const NamedValue* fontPropertyValue = aFontPropertyValues.getConstArray();
+ const NamedValue* fontPropertyValueEnd = fontPropertyValue + aFontPropertyValues.getLength();
+ for ( ; fontPropertyValue != fontPropertyValueEnd; ++fontPropertyValue )
+ m_xComponent->setPropertyValue( fontPropertyValue->Name, fontPropertyValue->Value );
+ }
+ else
+ {
+ Any aValue = _rValue;
+
+ Reference< resource::XStringResourceResolver > xStringResourceResolver
+ = lcl_getStringResourceResolverForProperty( m_xComponent, _rPropertyName, _rValue );
+ if( xStringResourceResolver.is() )
+ {
+ Reference< resource::XStringResourceManager >
+ xStringResourceManager( xStringResourceResolver, UNO_QUERY );
+ if( xStringResourceManager.is() )
+ {
+ Any aPropertyValue( m_xComponent->getPropertyValue( _rPropertyName ) );
+ TypeClass eType = aPropertyValue.getValueType().getTypeClass();
+ if( eType == TypeClass_STRING )
+ {
+ ::rtl::OUString aPropStr;
+ aPropertyValue >>= aPropStr;
+ if( aPropStr.getLength() > 1 )
+ {
+ ::rtl::OUString aPureIdStr = aPropStr.copy( 1 );
+ ::rtl::OUString aValueStr;
+ _rValue >>= aValueStr;
+ xStringResourceManager->setString( aPureIdStr, aValueStr );
+ aValue = aPropertyValue; // set value to force modified
+ }
+ }
+ // StringItemList?
+ else if( eType == TypeClass_SEQUENCE )
+ {
+ static ::rtl::OUString aDot = ::rtl::OUString::createFromAscii( "." );
+ static ::rtl::OUString aEsc = ::rtl::OUString::createFromAscii( "&" );
+
+ // Put strings into resource using new ids
+ Sequence< ::rtl::OUString > aNewStrings;
+ _rValue >>= aNewStrings;
+
+ const ::rtl::OUString* pNewStrings = aNewStrings.getConstArray();
+ sal_Int32 nNewCount = aNewStrings.getLength();
+
+ // Create new Ids
+ ::rtl::OUString* pNewPureIds = new ::rtl::OUString[nNewCount];
+ ::rtl::OUString aIdStrBase = aDot;
+ Any aNameAny = m_xComponent->getPropertyValue(PROPERTY_NAME);
+ ::rtl::OUString sControlName;
+ aNameAny >>= sControlName;
+ aIdStrBase += sControlName;
+ aIdStrBase += aDot;
+ aIdStrBase += _rPropertyName;
+ sal_Int32 i;
+ ::rtl::OUString aDummyStr;
+ for ( i = 0; i < nNewCount; ++i )
+ {
+ sal_Int32 nUniqueId = xStringResourceManager->getUniqueNumericId();
+ ::rtl::OUString aPureIdStr = ::rtl::OUString::valueOf( nUniqueId );
+ aPureIdStr += aIdStrBase;
+ pNewPureIds[i] = aPureIdStr;
+ // Force usage of next Unique Id
+ xStringResourceManager->setString( aPureIdStr, aDummyStr );
+ }
+
+ // Move strings to new Ids for all locales
+ Sequence< Locale > aLocaleSeq = xStringResourceManager->getLocales();
+ const Locale* pLocale = aLocaleSeq.getConstArray();
+ sal_Int32 nLocaleCount = aLocaleSeq.getLength();
+ Sequence< ::rtl::OUString > aOldIdStrings;
+ aPropertyValue >>= aOldIdStrings;
+ try
+ {
+ const ::rtl::OUString* pOldIdStrings = aOldIdStrings.getConstArray();
+ sal_Int32 nOldIdCount = aOldIdStrings.getLength();
+ for ( i = 0; i < nNewCount; ++i )
+ {
+ ::rtl::OUString aOldIdStr;
+ ::rtl::OUString aOldPureIdStr;
+ if( i < nOldIdCount )
+ {
+ aOldIdStr = pOldIdStrings[i];
+ aOldPureIdStr = aOldIdStr.copy( 1 );
+ }
+ ::rtl::OUString aNewPureIdStr = pNewPureIds[i];
+
+ for ( sal_Int32 iLocale = 0; iLocale < nLocaleCount; ++iLocale )
+ {
+ Locale aLocale = pLocale[iLocale];
+
+ ::rtl::OUString aResourceStr;
+ if( aOldPureIdStr.getLength() != 0 )
+ {
+ if( xStringResourceManager->hasEntryForIdAndLocale( aOldPureIdStr, aLocale ) )
+ {
+ aResourceStr = xStringResourceManager->
+ resolveStringForLocale( aOldPureIdStr, aLocale );
+ }
+ }
+ xStringResourceManager->setStringForLocale( aNewPureIdStr, aResourceStr, aLocale );
+ }
+ }
+ }
+ catch( resource::MissingResourceException & )
+ {}
+
+
+ // Set new strings for current locale and create
+ // new Id sequence as new property value
+ Sequence< ::rtl::OUString > aNewIdStrings;
+ aNewIdStrings.realloc( nNewCount );
+ ::rtl::OUString* pNewIdStrings = aNewIdStrings.getArray();
+ for ( i = 0; i < nNewCount; ++i )
+ {
+ ::rtl::OUString aPureIdStr = pNewPureIds[i];
+ ::rtl::OUString aStr = pNewStrings[i];
+ xStringResourceManager->setString( aPureIdStr, aStr );
+
+ ::rtl::OUString aIdStr = aEsc;
+ aIdStr += aPureIdStr;
+ pNewIdStrings[i] = aIdStr;
+ }
+ aValue <<= aNewIdStrings;
+
+ // Remove old ids from resource for all locales
+ const ::rtl::OUString* pOldIdStrings = aOldIdStrings.getConstArray();
+ sal_Int32 nOldIdCount = aOldIdStrings.getLength();
+ for( i = 0 ; i < nOldIdCount ; ++i )
+ {
+ ::rtl::OUString aIdStr = pOldIdStrings[i];
+ ::rtl::OUString aPureIdStr = aIdStr.copy( 1 );
+ for ( sal_Int32 iLocale = 0; iLocale < nLocaleCount; ++iLocale )
+ {
+ Locale aLocale = pLocale[iLocale];
+ try
+ {
+ xStringResourceManager->removeIdForLocale( aPureIdStr, aLocale );
+ }
+ catch( resource::MissingResourceException & )
+ {}
+ }
+ }
+ delete[] pNewPureIds;
+ }
+ }
+ }
+
+ m_xComponent->setPropertyValue( _rPropertyName, aValue );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL FormComponentPropertyHandler::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+ Property aProperty( impl_getPropertyFromId_throw( nPropId ) );
+
+ Any aPropertyValue( _rControlValue );
+ if ( !aPropertyValue.hasValue() )
+ {
+ if ( ( aProperty.Attributes & PropertyAttribute::MAYBEVOID ) == 0 )
+ // default construct an instance of the proper type
+ aPropertyValue = Any( NULL, aProperty.Type );
+ // nothing to do
+ return aPropertyValue;
+ }
+
+ /// care for the special "default" string, translate it to VOID
+ if ( m_aPropertiesWithDefListEntry.find( _rPropertyName ) != m_aPropertiesWithDefListEntry.end() )
+ {
+ // it's a control with a string list
+ ::rtl::OUString sStringValue;
+ if ( _rControlValue >>= sStringValue )
+ { // note that ColorListBoxes might transfer values either as string or as css.util.Color,
+ // so this check here is important
+ if ( sStringValue == m_sDefaultValueString )
+ return Any();
+ }
+ }
+
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_DATASOURCE:
+ {
+ ::rtl::OUString sControlValue;
+ OSL_VERIFY( _rControlValue >>= sControlValue );
+
+ if ( sControlValue.getLength() )
+ {
+ Reference< XNameAccess > xDatabaseContext;
+ m_aContext.createComponent( (::rtl::OUString)SERVICE_DATABASE_CONTEXT, xDatabaseContext );
+ if ( !xDatabaseContext.is() || !xDatabaseContext->hasByName( sControlValue ) )
+ {
+ ::svt::OFileNotation aTransformer(sControlValue);
+ aPropertyValue <<= ::rtl::OUString( aTransformer.get( ::svt::OFileNotation::N_URL ) );
+ }
+ }
+ }
+ break; // case PROPERTY_ID_DATASOURCE
+
+ case PROPERTY_ID_SHOW_POSITION:
+ case PROPERTY_ID_SHOW_NAVIGATION:
+ case PROPERTY_ID_SHOW_RECORDACTIONS:
+ case PROPERTY_ID_SHOW_FILTERSORT:
+ {
+ ::rtl::OUString sControlValue;
+ OSL_VERIFY( _rControlValue >>= sControlValue );
+
+ ::std::vector< ::rtl::OUString > aListEntries;
+ tools::StringListResource aRes( PcrRes( RID_RSC_ENUM_SHOWHIDE ), aListEntries );
+ OSL_ENSURE( aListEntries.size() == 2, "FormComponentPropertyHandler::convertToPropertyValue: broken resource for Show/Hide!" );
+ sal_Bool bShow = ( aListEntries.size() < 2 ) || ( sControlValue == aListEntries[1] );
+
+ aPropertyValue <<= bShow;
+ }
+ break;
+
+ case PROPERTY_ID_TARGET_URL:
+ case PROPERTY_ID_IMAGE_URL:
+ {
+ ::rtl::OUString sControlValue;
+ OSL_VERIFY( _rControlValue >>= sControlValue );
+ // Don't convert a placeholder
+ if ( nPropId == PROPERTY_ID_IMAGE_URL && sControlValue.equals( String( PcrRes( RID_EMBED_IMAGE_PLACEHOLDER ) ) ) )
+ aPropertyValue <<= sControlValue;
+ else
+ {
+ INetURLObject aDocURL( impl_getDocumentURL_nothrow() );
+ aPropertyValue <<= (::rtl::OUString)URIHelper::SmartRel2Abs( aDocURL, sControlValue, Link(), false, true, INetURLObject::WAS_ENCODED, INetURLObject::DECODE_TO_IURI );
+ }
+ }
+ break;
+
+ case PROPERTY_ID_DATEMIN:
+ case PROPERTY_ID_DATEMAX:
+ case PROPERTY_ID_DEFAULT_DATE:
+ case PROPERTY_ID_DATE:
+ {
+ util::Date aDate;
+ OSL_VERIFY( _rControlValue >>= aDate );
+ aPropertyValue <<= (sal_Int32)DBTypeConversion::toINT32( aDate );
+ }
+ break;
+
+ case PROPERTY_ID_TIMEMIN:
+ case PROPERTY_ID_TIMEMAX:
+ case PROPERTY_ID_DEFAULT_TIME:
+ case PROPERTY_ID_TIME:
+ {
+ util::Time aTime;
+ OSL_VERIFY( _rControlValue >>= aTime );
+ aPropertyValue <<= (sal_Int32)DBTypeConversion::toINT32( aTime );
+ }
+ break;
+
+ case PROPERTY_ID_WRITING_MODE:
+ {
+ aPropertyValue = FormComponentPropertyHandler_Base::convertToPropertyValue( _rPropertyName, _rControlValue );
+
+ sal_Int16 nNormalizedValue( 2 );
+ OSL_VERIFY( aPropertyValue >>= nNormalizedValue );
+ sal_Int16 nWritingMode = WritingMode2::CONTEXT;
+ switch ( nNormalizedValue )
+ {
+ case 0: nWritingMode = WritingMode2::LR_TB; break;
+ case 1: nWritingMode = WritingMode2::RL_TB; break;
+ case 2: nWritingMode = WritingMode2::CONTEXT; break;
+ default:
+ OSL_ENSURE( false, "FormComponentPropertyHandler::convertToPropertyValue: unexpected 'normalized value' for WritingMode!" );
+ nWritingMode = WritingMode2::CONTEXT;
+ break;
+ }
+
+ aPropertyValue <<= nWritingMode;
+ }
+ break;
+
+ default:
+ aPropertyValue = FormComponentPropertyHandler_Base::convertToPropertyValue( _rPropertyName, _rControlValue );
+ break; // default
+
+ } // switch ( nPropId )
+
+ return aPropertyValue;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL FormComponentPropertyHandler::convertToControlValue( const ::rtl::OUString& _rPropertyName, const Any& _rPropertyValue, const Type& _rControlValueType ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ sal_Int32 nPropId = m_pInfoService->getPropertyId( _rPropertyName );
+ DBG_ASSERT( nPropId != -1, "FormComponentPropertyHandler::convertToPropertyValue: not one of my properties!!" );
+
+ Property aProperty( impl_getPropertyFromId_throw( nPropId ) );
+
+ Any aControlValue( _rPropertyValue );
+ if ( !aControlValue.hasValue() )
+ {
+ // if the property is represented with a list box or color list box, we need to
+ // translate this into the string "Default"
+ if ( m_aPropertiesWithDefListEntry.find( _rPropertyName ) != m_aPropertiesWithDefListEntry.end() )
+ aControlValue <<= m_sDefaultValueString;
+
+ return aControlValue;
+ }
+
+ switch ( nPropId )
+ {
+ //////////////////////////////////////////////////////////////
+ case PROPERTY_ID_SHOW_POSITION:
+ case PROPERTY_ID_SHOW_NAVIGATION:
+ case PROPERTY_ID_SHOW_RECORDACTIONS:
+ case PROPERTY_ID_SHOW_FILTERSORT:
+ {
+ ::std::vector< ::rtl::OUString > aListEntries;
+ tools::StringListResource aRes( PcrRes( RID_RSC_ENUM_SHOWHIDE ), aListEntries );
+ OSL_ENSURE( aListEntries.size() == 2, "FormComponentPropertyHandler::convertToControlValue: broken resource for Show/Hide!" );
+
+ if ( aListEntries.size() == 2 )
+ {
+ ::rtl::OUString sControlValue = ::comphelper::getBOOL( _rPropertyValue )
+ ? aListEntries[1]
+ : aListEntries[0];
+ aControlValue <<= sControlValue;
+ }
+ }
+ break;
+
+ //////////////////////////////////////////////////////////////
+ case PROPERTY_ID_DATASOURCE:
+ {
+ OSL_ENSURE( _rControlValueType.getTypeClass() == TypeClass_STRING,
+ "FormComponentPropertyHandler::convertToControlValue: wrong ControlValueType!" );
+
+ ::rtl::OUString sDataSource;
+ _rPropertyValue >>= sDataSource;
+ if ( sDataSource.getLength() )
+ {
+ ::svt::OFileNotation aTransformer( sDataSource );
+ sDataSource = aTransformer.get( ::svt::OFileNotation::N_SYSTEM );
+ }
+ aControlValue <<= sDataSource;
+ }
+ break;
+
+ //////////////////////////////////////////////////////////////
+ case PROPERTY_ID_CONTROLLABEL:
+ {
+ ::rtl::OUString sControlValue;
+
+ Reference< XPropertySet > xSet;
+ _rPropertyValue >>= xSet;
+ Reference< XPropertySetInfo > xPSI;
+ if ( xSet.is() )
+ xPSI = xSet->getPropertySetInfo();
+ if ( xPSI.is() && xPSI->hasPropertyByName( PROPERTY_LABEL ) )
+ {
+ ::rtl::OUStringBuffer aValue;
+ aValue.append( (sal_Unicode)'<' );
+ ::rtl::OUString sLabel;
+ OSL_VERIFY( xSet->getPropertyValue( PROPERTY_LABEL ) >>= sLabel );
+ aValue.append( sLabel );
+ aValue.append( (sal_Unicode)'>' );
+ sControlValue = aValue.makeStringAndClear();
+ }
+
+ aControlValue <<= sControlValue;
+ }
+ break;
+
+ //////////////////////////////////////////////////////////////
+ case PROPERTY_ID_DATEMIN:
+ case PROPERTY_ID_DATEMAX:
+ case PROPERTY_ID_DEFAULT_DATE:
+ case PROPERTY_ID_DATE:
+ {
+ sal_Int32 nDate = 0;
+ OSL_VERIFY( _rPropertyValue >>= nDate );
+ aControlValue <<= DBTypeConversion::toDate( nDate );
+ }
+ break;
+
+ case PROPERTY_ID_TIMEMIN:
+ case PROPERTY_ID_TIMEMAX:
+ case PROPERTY_ID_DEFAULT_TIME:
+ case PROPERTY_ID_TIME:
+ {
+ sal_Int32 nTime = 0;
+ OSL_VERIFY( _rPropertyValue >>= nTime );
+ aControlValue <<= DBTypeConversion::toTime( nTime );
+ }
+ break;
+
+ case PROPERTY_ID_WRITING_MODE:
+ {
+ sal_Int16 nWritingMode( WritingMode2::CONTEXT );
+ OSL_VERIFY( _rPropertyValue >>= nWritingMode );
+ sal_Int16 nNormalized = 2;
+ switch ( nWritingMode )
+ {
+ case WritingMode2::LR_TB: nNormalized = 0; break;
+ case WritingMode2::RL_TB: nNormalized = 1; break;
+ case WritingMode2::CONTEXT: nNormalized = 2; break;
+ default:
+ OSL_ENSURE( false, "FormComponentPropertyHandler::convertToControlValue: unsupported API value for WritingMode!" );
+ nNormalized = 2;
+ break;
+ }
+
+ aControlValue = FormComponentPropertyHandler_Base::convertToControlValue( _rPropertyName, makeAny( nNormalized ), _rControlValueType );
+ }
+ break;
+
+ case PROPERTY_ID_FONT:
+ {
+ FontDescriptor aFont;
+ OSL_VERIFY( _rPropertyValue >>= aFont );
+
+ ::rtl::OUStringBuffer displayName;
+ if ( !aFont.Name.getLength() )
+ {
+ displayName.append( String( PcrRes( RID_STR_FONT_DEFAULT ) ) );
+ }
+ else
+ {
+ // font name
+ displayName.append( aFont.Name );
+ displayName.appendAscii( ", " );
+
+ // font style
+ ::FontWeight eWeight = VCLUnoHelper::ConvertFontWeight( aFont.Weight );
+ sal_uInt16 nStyleResID = RID_STR_FONTSTYLE_REGULAR;
+ if ( aFont.Slant == FontSlant_ITALIC )
+ {
+ if ( eWeight > WEIGHT_NORMAL )
+ nStyleResID = RID_STR_FONTSTYLE_BOLD_ITALIC;
+ else
+ nStyleResID = RID_STR_FONTSTYLE_ITALIC;
+ }
+ else
+ {
+ if ( eWeight > WEIGHT_NORMAL )
+ nStyleResID = RID_STR_FONTSTYLE_BOLD;
+ }
+ displayName.append( String( PcrRes( nStyleResID ) ) );
+
+ // font size
+ if ( aFont.Height )
+ {
+ displayName.appendAscii( ", " );
+ displayName.append( sal_Int32( aFont.Height ) );
+ }
+ }
+
+ aControlValue <<= displayName.makeStringAndClear();
+ }
+ break;
+
+ default:
+ aControlValue = FormComponentPropertyHandler_Base::convertToControlValue( _rPropertyName, _rPropertyValue, _rControlValueType );
+ break;
+
+ } // switch ( nPropId )
+
+ return aControlValue;
+ }
+
+ //--------------------------------------------------------------------
+ PropertyState SAL_CALL FormComponentPropertyHandler::getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_xPropertyState.is() )
+ return m_xPropertyState->getPropertyState( _rPropertyName );
+ return PropertyState_DIRECT_VALUE;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormComponentPropertyHandler::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ FormComponentPropertyHandler_Base::addPropertyChangeListener( _rxListener );
+ if ( m_xComponent.is() )
+ m_xComponent->addPropertyChangeListener( ::rtl::OUString(), _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormComponentPropertyHandler::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_xComponent.is() )
+ m_xComponent->removePropertyChangeListener( ::rtl::OUString(), _rxListener );
+ FormComponentPropertyHandler_Base::removePropertyChangeListener( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void FormComponentPropertyHandler::onNewComponent()
+ {
+ FormComponentPropertyHandler_Base::onNewComponent();
+ if ( !m_xComponentPropertyInfo.is() && m_xComponent.is() )
+ throw NullPointerException();
+
+ m_xPropertyState.set( m_xComponent, UNO_QUERY );
+ m_eComponentClass = eUnknown;
+ m_bComponentIsSubForm = m_bHaveListSource = m_bHaveCommand = false;
+ m_nClassId = 0;
+
+ impl_initComponentMetaData_throw();
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Property > SAL_CALL FormComponentPropertyHandler::doDescribeSupportedProperties() const
+ {
+ if ( !m_xComponentPropertyInfo.is() )
+ return Sequence< Property >();
+
+ ::std::vector< Property > aProperties;
+
+ Sequence< Property > aAllProperties( m_xComponentPropertyInfo->getProperties() );
+ aProperties.reserve( aAllProperties.getLength() );
+
+ // filter the properties
+ PropertyId nPropId( 0 );
+ ::rtl::OUString sDisplayName;
+
+ Property* pProperty = aAllProperties.getArray();
+ Property* pPropertiesEnd = pProperty + aAllProperties.getLength();
+ for ( ; pProperty != pPropertiesEnd; ++pProperty )
+ {
+ nPropId = m_pInfoService->getPropertyId( pProperty->Name );
+ if ( nPropId == -1 )
+ continue;
+ pProperty->Handle = nPropId;
+
+ sDisplayName = m_pInfoService->getPropertyTranslation( nPropId );
+ if ( !sDisplayName.getLength() )
+ continue;
+
+ sal_uInt32 nPropertyUIFlags = m_pInfoService->getPropertyUIFlags( nPropId );
+ bool bIsVisibleForForms = ( nPropertyUIFlags & PROP_FLAG_FORM_VISIBLE ) != 0;
+ bool bIsVisibleForDialogs = ( nPropertyUIFlags & PROP_FLAG_DIALOG_VISIBLE ) != 0;
+
+ // depending on whether we're working for a form or a UNO dialog, some
+ // properties are not displayed
+ if ( ( m_eComponentClass == eFormControl && !bIsVisibleForForms )
+ || ( m_eComponentClass == eDialogControl && !bIsVisibleForDialogs )
+ )
+ continue;
+
+ // some generic sanity checks
+ if ( impl_shouldExcludeProperty_nothrow( *pProperty ) )
+ continue;
+
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_BORDER:
+ case PROPERTY_ID_TABSTOP:
+ // BORDER and TABSTOP are normalized (see impl_normalizePropertyValue_nothrow)
+ // to not allow VOID values
+ pProperty->Attributes &= ~( PropertyAttribute::MAYBEVOID );
+ break;
+
+ case PROPERTY_ID_LISTSOURCE:
+ // no cursor source if no Base is installed. #124939#
+ // This fix is not intendend to appear on the main trunk. If you find it there,
+ // please tell me! frank.schoenheit@sun.com
+ if ( SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
+ const_cast< FormComponentPropertyHandler* >( this )->m_bHaveListSource = true;
+ break;
+
+ case PROPERTY_ID_COMMAND:
+ // no cursor source if no Base is installed. #124939#
+ // This fix is not intendend to appear on the main trunk. If you find it there,
+ // please tell me! frank.schoenheit@sun.com
+ if ( SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
+ const_cast< FormComponentPropertyHandler* >( this )->m_bHaveCommand = true;
+ break;
+ } // switch ( nPropId )
+
+ aProperties.push_back( *pProperty );
+ }
+
+ if ( aProperties.empty() )
+ return Sequence< Property >();
+ return Sequence< Property >( &(*aProperties.begin()), aProperties.size() );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL FormComponentPropertyHandler::getSupersededProperties( ) throw (RuntimeException)
+ {
+ return Sequence< ::rtl::OUString >( );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL FormComponentPropertyHandler::getActuatingProperties( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ ::std::vector< ::rtl::OUString > aInterestingProperties;
+ aInterestingProperties.push_back( PROPERTY_DATASOURCE );
+ aInterestingProperties.push_back( PROPERTY_COMMAND );
+ aInterestingProperties.push_back( PROPERTY_COMMANDTYPE );
+ aInterestingProperties.push_back( PROPERTY_LISTSOURCE );
+ aInterestingProperties.push_back( PROPERTY_LISTSOURCETYPE );
+ aInterestingProperties.push_back( PROPERTY_SUBMIT_ENCODING );
+ aInterestingProperties.push_back( PROPERTY_REPEAT );
+ aInterestingProperties.push_back( PROPERTY_TABSTOP );
+ aInterestingProperties.push_back( PROPERTY_BORDER );
+ aInterestingProperties.push_back( PROPERTY_CONTROLSOURCE );
+ aInterestingProperties.push_back( PROPERTY_DROPDOWN );
+ aInterestingProperties.push_back( PROPERTY_IMAGE_URL );
+ aInterestingProperties.push_back( PROPERTY_TARGET_URL );
+ aInterestingProperties.push_back( PROPERTY_STRINGITEMLIST );
+ aInterestingProperties.push_back( PROPERTY_BUTTONTYPE );
+ aInterestingProperties.push_back( PROPERTY_ESCAPE_PROCESSING );
+ aInterestingProperties.push_back( PROPERTY_TRISTATE );
+ aInterestingProperties.push_back( PROPERTY_DECIMAL_ACCURACY );
+ aInterestingProperties.push_back( PROPERTY_SHOWTHOUSANDSEP );
+ aInterestingProperties.push_back( PROPERTY_FORMATKEY );
+ aInterestingProperties.push_back( PROPERTY_EMPTY_IS_NULL );
+ aInterestingProperties.push_back( PROPERTY_TOGGLE );
+ return Sequence< ::rtl::OUString >( &(*aInterestingProperties.begin()), aInterestingProperties.size() );
+ }
+
+ //--------------------------------------------------------------------
+ LineDescriptor SAL_CALL FormComponentPropertyHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName,
+ const Reference< XPropertyControlFactory >& _rxControlFactory )
+ throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ if ( !_rxControlFactory.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+ Property aProperty( impl_getPropertyFromId_throw( nPropId ) );
+
+ //////////////////////////////////////////////////////////////////////
+ // for the MultiLine property, we have different UI translations depending on the control
+ // type
+ if ( nPropId == PROPERTY_ID_MULTILINE )
+ {
+ if ( ( m_nClassId == FormComponentType::FIXEDTEXT )
+ || ( m_nClassId == FormComponentType::COMMANDBUTTON )
+ || ( m_nClassId == FormComponentType::RADIOBUTTON )
+ || ( m_nClassId == FormComponentType::CHECKBOX )
+ )
+ nPropId = PROPERTY_ID_WORDBREAK;
+ }
+
+ String sDisplayName = m_pInfoService->getPropertyTranslation( nPropId );
+ if ( !sDisplayName.Len() )
+ {
+ DBG_ERROR( "FormComponentPropertyHandler::describePropertyLine: did getSupportedProperties not work properly?" );
+ throw UnknownPropertyException();
+ }
+
+ //////////////////////////////////////////////////////////////////////
+
+ LineDescriptor aDescriptor;
+ aDescriptor.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( nPropId ) );
+ aDescriptor.DisplayName = sDisplayName;
+
+ // for the moment, assume a text field
+ sal_Int16 nControlType = PropertyControlType::TextField;
+ sal_Bool bReadOnly = sal_False;
+ aDescriptor.Control.clear();
+
+ //////////////////////////////////////////////////////////////////////
+
+ bool bNeedDefaultStringIfVoidAllowed = false;
+
+ TypeClass eType = aProperty.Type.getTypeClass();
+
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_DEFAULT_SELECT_SEQ:
+ case PROPERTY_ID_SELECTEDITEMS:
+ aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_SELECTION);
+ break;
+
+ case PROPERTY_ID_FILTER:
+ aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_FILTER);
+ break;
+
+ case PROPERTY_ID_SORT:
+ aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_ORDER);
+ break;
+
+ case PROPERTY_ID_MASTERFIELDS:
+ case PROPERTY_ID_DETAILFIELDS:
+ nControlType = PropertyControlType::StringListField;
+ aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_FORMLINKFIELDS);
+ break;
+
+ case PROPERTY_ID_COMMAND:
+ aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_SQLCOMMAND);
+ break;
+
+ case PROPERTY_ID_TABINDEX:
+ {
+ Reference< XControlContainer > xControlContext( impl_getContextControlContainer_nothrow() );
+ if ( xControlContext.is() )
+ aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_TABINDEX);
+ nControlType = PropertyControlType::NumericField;
+ };
+ break;
+
+ case PROPERTY_ID_FONT:
+ bReadOnly = sal_True;
+ aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_FONT_TYPE);
+ break;
+
+ case PROPERTY_ID_TARGET_URL:
+ case PROPERTY_ID_IMAGE_URL:
+ {
+ aDescriptor.Control = new OFileUrlControl( impl_getDefaultDialogParent_nothrow(), WB_TABSTOP | WB_BORDER );
+
+ aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(( PROPERTY_ID_TARGET_URL == nPropId )
+ ? UID_PROP_DLG_ATTR_TARGET_URL : UID_PROP_DLG_IMAGE_URL);
+ }
+ break;
+
+ case PROPERTY_ID_ECHO_CHAR:
+ nControlType = PropertyControlType::CharacterField;
+ break;
+
+ case PROPERTY_ID_BACKGROUNDCOLOR:
+ case PROPERTY_ID_FILLCOLOR:
+ case PROPERTY_ID_SYMBOLCOLOR:
+ case PROPERTY_ID_BORDERCOLOR:
+ nControlType = PropertyControlType::ColorListBox;
+
+ switch( nPropId )
+ {
+ case PROPERTY_ID_BACKGROUNDCOLOR:
+ aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_BACKGROUNDCOLOR); break;
+ case PROPERTY_ID_FILLCOLOR:
+ aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_FILLCOLOR); break;
+ case PROPERTY_ID_SYMBOLCOLOR:
+ aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_SYMBOLCOLOR); break;
+ case PROPERTY_ID_BORDERCOLOR:
+ aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_BORDERCOLOR); break;
+ }
+ break;
+
+ case PROPERTY_ID_LABEL:
+ nControlType = PropertyControlType::MultiLineTextField;
+ break;
+
+ case PROPERTY_ID_DEFAULT_TEXT:
+ {
+ if (FormComponentType::FILECONTROL == m_nClassId)
+ nControlType = PropertyControlType::TextField;
+ else
+ nControlType = PropertyControlType::MultiLineTextField;
+ }
+ break;
+
+ case PROPERTY_ID_TEXT:
+ if ( impl_componentHasProperty_throw( PROPERTY_MULTILINE ) )
+ nControlType = PropertyControlType::MultiLineTextField;
+ break;
+
+ case PROPERTY_ID_CONTROLLABEL:
+ bReadOnly = sal_True;
+ aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_CONTROLLABEL);
+ break;
+
+ case PROPERTY_ID_FORMATKEY:
+ case PROPERTY_ID_EFFECTIVE_MIN:
+ case PROPERTY_ID_EFFECTIVE_MAX:
+ case PROPERTY_ID_EFFECTIVE_DEFAULT:
+ case PROPERTY_ID_EFFECTIVE_VALUE:
+ {
+ // and the supplier is really available
+ Reference< XNumberFormatsSupplier > xSupplier;
+ m_xComponent->getPropertyValue( PROPERTY_FORMATSSUPPLIER ) >>= xSupplier;
+ if (xSupplier.is())
+ {
+ Reference< XUnoTunnel > xTunnel(xSupplier,UNO_QUERY);
+ DBG_ASSERT(xTunnel.is(), "FormComponentPropertyHandler::describePropertyLine : xTunnel is invalid!");
+ SvNumberFormatsSupplierObj* pSupplier = reinterpret_cast<SvNumberFormatsSupplierObj*>(xTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
+
+ if (pSupplier != NULL)
+ {
+ sal_Bool bIsFormatKey = (PROPERTY_ID_FORMATKEY == nPropId);
+
+ bReadOnly = bIsFormatKey;
+
+ if ( bIsFormatKey )
+ {
+ OFormatSampleControl* pControl = new OFormatSampleControl( impl_getDefaultDialogParent_nothrow(), WB_READONLY | WB_TABSTOP | WB_BORDER );
+ aDescriptor.Control = pControl;
+ pControl->SetFormatSupplier( pSupplier );
+
+ aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_NUMBER_FORMAT);
+ }
+ else
+ {
+ OFormattedNumericControl* pControl = new OFormattedNumericControl( impl_getDefaultDialogParent_nothrow(), WB_TABSTOP | WB_BORDER );
+ aDescriptor.Control = pControl;
+
+ FormatDescription aDesc;
+ aDesc.pSupplier = pSupplier;
+ Any aFormatKeyValue = m_xComponent->getPropertyValue(PROPERTY_FORMATKEY);
+ if ( !( aFormatKeyValue >>= aDesc.nKey ) )
+ aDesc.nKey = 0;
+
+ pControl->SetFormatDescription( aDesc );
+ }
+ }
+ }
+ }
+ break;
+
+ case PROPERTY_ID_DATEMIN:
+ case PROPERTY_ID_DATEMAX:
+ case PROPERTY_ID_DEFAULT_DATE:
+ case PROPERTY_ID_DATE:
+ nControlType = PropertyControlType::DateField;
+ break;
+
+ case PROPERTY_ID_TIMEMIN:
+ case PROPERTY_ID_TIMEMAX:
+ case PROPERTY_ID_DEFAULT_TIME:
+ case PROPERTY_ID_TIME:
+ nControlType = PropertyControlType::TimeField;
+ break;
+
+ case PROPERTY_ID_VALUEMIN:
+ case PROPERTY_ID_VALUEMAX:
+ case PROPERTY_ID_DEFAULT_VALUE:
+ case PROPERTY_ID_VALUE:
+ {
+ OFormattedNumericControl* pControl = new OFormattedNumericControl( impl_getDefaultDialogParent_nothrow(), WB_TABSTOP | WB_BORDER | WB_SPIN | WB_REPEAT );
+ aDescriptor.Control = pControl;
+
+ // we don't set a formatter so the control uses a default (which uses the application
+ // language and a default numeric format)
+ // but we set the decimal digits
+ pControl->SetDecimalDigits(
+ ::comphelper::getINT16( m_xComponent->getPropertyValue( PROPERTY_DECIMAL_ACCURACY ) )
+ );
+
+ // and the thousands separator
+ pControl->SetThousandsSep(
+ ::comphelper::getBOOL( m_xComponent->getPropertyValue(PROPERTY_SHOWTHOUSANDSEP) )
+ );
+
+ // and the default value for the property
+ try
+ {
+ if (m_xPropertyState.is() && ((PROPERTY_ID_VALUEMIN == nPropId) || (PROPERTY_ID_VALUEMAX == nPropId)))
+ {
+ double nDefault = 0;
+ if ( m_xPropertyState->getPropertyDefault( aProperty.Name ) >>= nDefault )
+ pControl->SetDefaultValue( nDefault );
+ }
+ }
+ catch (Exception&)
+ {
+ // just ignore it
+ }
+
+ // and allow empty values only for the default value and the value
+ pControl->EnableEmptyField( ( PROPERTY_ID_DEFAULT_VALUE == nPropId )
+ || ( PROPERTY_ID_VALUE == nPropId ) );
+ }
+ break;
+
+ default:
+ if ( TypeClass_BYTE <= eType && eType <= TypeClass_DOUBLE )
+ {
+ sal_Int16 nDigits = 0;
+ sal_Int16 nValueUnit = -1;
+ sal_Int16 nDisplayUnit = -1;
+ if ( m_eComponentClass == eFormControl )
+ {
+ if ( ( nPropId == PROPERTY_ID_WIDTH )
+ || ( nPropId == PROPERTY_ID_ROWHEIGHT )
+ || ( nPropId == PROPERTY_ID_HEIGHT )
+ )
+ {
+ nValueUnit = MeasureUnit::MM_10TH;
+ nDisplayUnit = impl_getDocumentMeasurementUnit_throw();
+ nDigits = 2;
+ }
+ }
+
+ Optional< double > aValueNotPresent( sal_False, 0 );
+ aDescriptor.Control = PropertyHandlerHelper::createNumericControl(
+ _rxControlFactory, nDigits, aValueNotPresent, aValueNotPresent, sal_False );
+
+ Reference< XNumericControl > xNumericControl( aDescriptor.Control, UNO_QUERY_THROW );
+ if ( nValueUnit != -1 )
+ xNumericControl->setValueUnit( nValueUnit );
+ if ( nDisplayUnit != -1 )
+ xNumericControl->setDisplayUnit( nDisplayUnit );
+ }
+ break;
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ if ( eType == TypeClass_SEQUENCE )
+ nControlType = PropertyControlType::StringListField;
+
+ //////////////////////////////////////////////////////////////////////
+ // boolean values
+ if ( eType == TypeClass_BOOLEAN )
+ {
+ sal_uInt16 nResId = RID_RSC_ENUM_YESNO;
+ if ( ( nPropId == PROPERTY_ID_SHOW_POSITION )
+ || ( nPropId == PROPERTY_ID_SHOW_NAVIGATION )
+ || ( nPropId == PROPERTY_ID_SHOW_RECORDACTIONS )
+ || ( nPropId == PROPERTY_ID_SHOW_FILTERSORT )
+ )
+ nResId = RID_RSC_ENUM_SHOWHIDE;
+
+ ::std::vector< ::rtl::OUString > aListEntries;
+ tools::StringListResource aRes(PcrRes(nResId),aListEntries);
+ aDescriptor.Control = PropertyHandlerHelper::createListBoxControl( _rxControlFactory, aListEntries, sal_False, sal_False );
+ bNeedDefaultStringIfVoidAllowed = true;
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // enum properties
+ sal_uInt32 nPropertyUIFlags = m_pInfoService->getPropertyUIFlags( nPropId );
+ bool bIsEnumProperty = ( nPropertyUIFlags & PROP_FLAG_ENUM ) != 0;
+ if ( bIsEnumProperty || ( PROPERTY_ID_TARGET_FRAME == nPropId ) )
+ {
+ ::std::vector< ::rtl::OUString > aEnumValues = m_pInfoService->getPropertyEnumRepresentations( nPropId );
+ ::std::vector< ::rtl::OUString >::const_iterator pStart = aEnumValues.begin();
+ ::std::vector< ::rtl::OUString >::const_iterator pEnd = aEnumValues.end();
+
+ // for a checkbox: if "ambiguous" is not allowed, remove this from the sequence
+ if ( ( PROPERTY_ID_DEFAULT_STATE == nPropId )
+ || ( PROPERTY_ID_STATE == nPropId )
+ )
+ {
+ if ( impl_componentHasProperty_throw( PROPERTY_TRISTATE ) )
+ {
+ if ( !::comphelper::getBOOL( m_xComponent->getPropertyValue( PROPERTY_TRISTATE ) ) )
+ { // remove the last sequence element
+ if ( pEnd > pStart )
+ --pEnd;
+ }
+ }
+ else
+ --pEnd;
+ }
+
+ if ( PROPERTY_ID_LISTSOURCETYPE == nPropId )
+ if ( FormComponentType::COMBOBOX == m_nClassId )
+ // remove the first sequence element -> value list not possible for combo boxes
+ ++pStart;
+
+ // copy the sequence
+ ::std::vector< ::rtl::OUString > aListEntries( pEnd - pStart );
+ ::std::copy( pStart, pEnd, aListEntries.begin() );
+
+ // create the control
+ if ( PROPERTY_ID_TARGET_FRAME == nPropId )
+ aDescriptor.Control = PropertyHandlerHelper::createComboBoxControl( _rxControlFactory, aListEntries, sal_False, sal_False );
+ else
+ {
+ aDescriptor.Control = PropertyHandlerHelper::createListBoxControl( _rxControlFactory, aListEntries, sal_False, sal_False );
+ bNeedDefaultStringIfVoidAllowed = true;
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ switch( nPropId )
+ {
+ case PROPERTY_ID_REPEAT_DELAY:
+ {
+ OTimeDurationControl* pControl = new OTimeDurationControl( impl_getDefaultDialogParent_nothrow(), WB_BORDER | WB_TABSTOP );
+ aDescriptor.Control = pControl;
+
+ pControl->setMinValue( Optional< double >( sal_True, 0 ) );
+ pControl->setMaxValue( Optional< double >( sal_True, ::std::numeric_limits< double >::max() ) );
+ }
+ break;
+
+ case PROPERTY_ID_TABINDEX:
+ case PROPERTY_ID_BOUNDCOLUMN:
+ case PROPERTY_ID_VISIBLESIZE:
+ case PROPERTY_ID_MAXTEXTLEN:
+ case PROPERTY_ID_LINEINCREMENT:
+ case PROPERTY_ID_BLOCKINCREMENT:
+ case PROPERTY_ID_SPININCREMENT:
+ {
+ Optional< double > aMinValue( sal_True, 0 );
+ Optional< double > aMaxValue( sal_True, 0x7FFFFFFF );
+
+ if ( nPropId == PROPERTY_ID_MAXTEXTLEN )
+ aMinValue.Value = -1;
+ else if ( nPropId == PROPERTY_ID_VISIBLESIZE )
+ aMinValue.Value = 1;
+ else
+ aMinValue.Value = 0;
+
+ aDescriptor.Control = PropertyHandlerHelper::createNumericControl(
+ _rxControlFactory, 0, aMinValue, aMaxValue, sal_False );
+ }
+ break;
+
+ case PROPERTY_ID_DECIMAL_ACCURACY:
+ {
+ Optional< double > aMinValue( sal_True, 0 );
+ Optional< double > aMaxValue( sal_True, 20 );
+
+ aDescriptor.Control = PropertyHandlerHelper::createNumericControl(
+ _rxControlFactory, 0, aMinValue, aMaxValue, sal_False );
+ }
+ break;
+
+ //////////////////////////////////////////////////////////////////////
+ // DataSource
+ case PROPERTY_ID_DATASOURCE:
+ {
+ aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_ATTR_DATASOURCE);
+
+ ::std::vector< ::rtl::OUString > aListEntries;
+
+ Reference< XNameAccess > xDatabaseContext;
+ m_aContext.createComponent( (rtl::OUString)SERVICE_DATABASE_CONTEXT, xDatabaseContext );
+ if (xDatabaseContext.is())
+ {
+ Sequence< ::rtl::OUString > aDatasources = xDatabaseContext->getElementNames();
+ aListEntries.resize( aDatasources.getLength() );
+ ::std::copy( aDatasources.getConstArray(), aDatasources.getConstArray() + aDatasources.getLength(),
+ aListEntries.begin() );
+ }
+ aDescriptor.Control = PropertyHandlerHelper::createComboBoxControl(
+ _rxControlFactory, aListEntries, sal_False, sal_True );
+ }
+ break;
+
+ case PROPERTY_ID_CONTROLSOURCE:
+ {
+ ::std::vector< ::rtl::OUString > aFieldNames;
+ impl_initFieldList_nothrow( aFieldNames );
+ aDescriptor.Control = PropertyHandlerHelper::createComboBoxControl(
+ _rxControlFactory, aFieldNames, sal_False, sal_False );
+ }
+ break;
+
+ case PROPERTY_ID_COMMAND:
+ impl_describeCursorSource_nothrow( aDescriptor, _rxControlFactory );
+ break;
+
+ case PROPERTY_ID_LISTSOURCE:
+ impl_describeListSourceUI_throw( aDescriptor, _rxControlFactory );
+ break;
+ }
+
+ if ( !aDescriptor.Control.is() )
+ aDescriptor.Control = _rxControlFactory->createPropertyControl( nControlType, bReadOnly );
+
+ if ( ( aProperty.Attributes & PropertyAttribute::MAYBEVOID ) != 0 )
+ {
+ // insert the string "Default" string, if necessary
+ if ( bNeedDefaultStringIfVoidAllowed || ( nControlType == PropertyControlType::ColorListBox ) )
+ {
+ Reference< XStringListControl > xStringList( aDescriptor.Control, UNO_QUERY_THROW );
+ xStringList->prependListEntry( m_sDefaultValueString );
+ m_aPropertiesWithDefListEntry.insert( _rPropertyName );
+ }
+ }
+
+ if ( aDescriptor.PrimaryButtonId.getLength() )
+ aDescriptor.HasPrimaryButton = sal_True;
+ if ( aDescriptor.SecondaryButtonId.getLength() )
+ aDescriptor.HasSecondaryButton = sal_True;
+
+ bool bIsDataProperty = ( nPropertyUIFlags & PROP_FLAG_DATA_PROPERTY ) != 0;
+ aDescriptor.Category = ::rtl::OUString::createFromAscii( bIsDataProperty ? "Data" : "General" );
+ return aDescriptor;
+ }
+
+ //--------------------------------------------------------------------
+ InteractiveSelectionResult SAL_CALL FormComponentPropertyHandler::onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool /*_bPrimary*/, Any& _rData, const Reference< XObjectInspectorUI >& _rxInspectorUI ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ InteractiveSelectionResult eResult = InteractiveSelectionResult_Cancelled;
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_DEFAULT_SELECT_SEQ:
+ case PROPERTY_ID_SELECTEDITEMS:
+ if ( impl_dialogListSelection_nothrow( _rPropertyName, aGuard ) )
+ eResult = InteractiveSelectionResult_Success;
+ break;
+
+ case PROPERTY_ID_FILTER:
+ case PROPERTY_ID_SORT:
+ {
+ ::rtl::OUString sClause;
+ if ( impl_dialogFilterOrSort_nothrow( PROPERTY_ID_FILTER == nPropId, sClause, aGuard ) )
+ {
+ _rData <<= sClause;
+ eResult = InteractiveSelectionResult_ObtainedValue;
+ }
+ }
+ break;
+
+ case PROPERTY_ID_MASTERFIELDS:
+ case PROPERTY_ID_DETAILFIELDS:
+ if ( impl_dialogLinkedFormFields_nothrow( aGuard ) )
+ eResult = InteractiveSelectionResult_Success;
+ break;
+
+ case PROPERTY_ID_FORMATKEY:
+ if ( impl_dialogFormatting_nothrow( _rData, aGuard ) )
+ eResult = InteractiveSelectionResult_ObtainedValue;
+ break;
+
+ case PROPERTY_ID_IMAGE_URL:
+ if ( impl_browseForImage_nothrow( _rData, aGuard ) )
+ eResult = InteractiveSelectionResult_ObtainedValue;
+ break;
+
+ case PROPERTY_ID_TARGET_URL:
+ if ( impl_browseForTargetURL_nothrow( _rData, aGuard ) )
+ eResult = InteractiveSelectionResult_ObtainedValue;
+ break;
+
+ case PROPERTY_ID_FONT:
+ if ( impl_executeFontDialog_nothrow( _rData, aGuard ) )
+ eResult = InteractiveSelectionResult_ObtainedValue;
+ break;
+
+ case PROPERTY_ID_DATASOURCE:
+ if ( impl_browseForDatabaseDocument_throw( _rData, aGuard ) )
+ eResult = InteractiveSelectionResult_ObtainedValue;
+ break;
+
+ case PROPERTY_ID_BACKGROUNDCOLOR:
+ case PROPERTY_ID_FILLCOLOR:
+ case PROPERTY_ID_SYMBOLCOLOR:
+ case PROPERTY_ID_BORDERCOLOR:
+ if ( impl_dialogColorChooser_throw( nPropId, _rData, aGuard ) )
+ eResult = InteractiveSelectionResult_ObtainedValue;
+ break;
+
+ case PROPERTY_ID_CONTROLLABEL:
+ if ( impl_dialogChooseLabelControl_nothrow( _rData, aGuard ) )
+ eResult = InteractiveSelectionResult_ObtainedValue;
+ break;
+
+ case PROPERTY_ID_TABINDEX:
+ if ( impl_dialogChangeTabOrder_nothrow( aGuard ) )
+ eResult = InteractiveSelectionResult_Success;
+ break;
+
+ case PROPERTY_ID_COMMAND:
+ case PROPERTY_ID_LISTSOURCE:
+ if ( impl_doDesignSQLCommand_nothrow( _rxInspectorUI, nPropId ) )
+ eResult = InteractiveSelectionResult_Pending;
+ break;
+ default:
+ DBG_ERROR( "FormComponentPropertyHandler::onInteractivePropertySelection: request for a property which does not have dedicated UI!" );
+ break;
+ }
+ return eResult;
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ void lcl_rebuildAndResetCommand( const Reference< XObjectInspectorUI >& _rxInspectorUI, const Reference< XPropertyHandler >& _rxHandler )
+ {
+ OSL_PRECOND( _rxInspectorUI.is(), "lcl_rebuildAndResetCommand: invalid BrowserUI!" );
+ OSL_PRECOND( _rxHandler.is(), "lcl_rebuildAndResetCommand: invalid handler!" );
+ _rxInspectorUI->rebuildPropertyUI( PROPERTY_COMMAND );
+ _rxHandler->setPropertyValue( PROPERTY_COMMAND, makeAny( ::rtl::OUString() ) );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormComponentPropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nActuatingPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) );
+
+ ::std::vector< PropertyId > aDependentProperties;
+
+ switch ( nActuatingPropId )
+ {
+ // ----- EscapeProcessing -----
+ case PROPERTY_ID_ESCAPE_PROCESSING:
+ aDependentProperties.push_back( PROPERTY_ID_FILTER );
+ aDependentProperties.push_back( PROPERTY_ID_SORT );
+ break; // case PROPERTY_ID_ESCAPE_PROCESSING
+
+ // ----- CommandType -----
+ case PROPERTY_ID_COMMANDTYPE:
+ // available commands (tables or queries) might have changed
+ if ( !_bFirstTimeInit && m_bHaveCommand )
+ lcl_rebuildAndResetCommand( _rxInspectorUI, this );
+ aDependentProperties.push_back( PROPERTY_ID_COMMAND );
+ break; // case PROPERTY_ID_COMMANDTYPE
+
+ // ----- DataSourceName -----
+ case PROPERTY_ID_DATASOURCE:
+ // reset the connection, now that we have a new data source
+ impl_clearRowsetConnection_nothrow();
+
+ // available list source values (tables or queries) might have changed
+ if ( !_bFirstTimeInit && m_bHaveListSource )
+ _rxInspectorUI->rebuildPropertyUI( PROPERTY_LISTSOURCE );
+
+ // available commands (tables or queries) might have changed
+ if ( !_bFirstTimeInit && m_bHaveCommand )
+ lcl_rebuildAndResetCommand( _rxInspectorUI, this );
+
+ // Command also depends on DataSource
+ aDependentProperties.push_back( PROPERTY_ID_COMMAND );
+ // NO break!
+
+ // ----- Command -----
+ case PROPERTY_ID_COMMAND:
+ aDependentProperties.push_back( PROPERTY_ID_FILTER );
+ aDependentProperties.push_back( PROPERTY_ID_SORT );
+ if ( m_bComponentIsSubForm )
+ aDependentProperties.push_back( PROPERTY_ID_DETAILFIELDS );
+ break;
+
+ // ----- ListSourceType -----
+ case PROPERTY_ID_LISTSOURCETYPE:
+ if ( !_bFirstTimeInit && m_bHaveListSource )
+ // available list source values (tables or queries) might have changed
+ _rxInspectorUI->rebuildPropertyUI( PROPERTY_LISTSOURCE );
+ aDependentProperties.push_back( PROPERTY_ID_BOUNDCOLUMN );
+ aDependentProperties.push_back( PROPERTY_ID_STRINGITEMLIST );
+ // NO break!
+
+ // ----- StringItemList -----
+ case PROPERTY_ID_STRINGITEMLIST:
+ aDependentProperties.push_back( PROPERTY_ID_SELECTEDITEMS );
+ aDependentProperties.push_back( PROPERTY_ID_DEFAULT_SELECT_SEQ );
+ break;
+
+ // ----- ListSource -----
+ case PROPERTY_ID_LISTSOURCE:
+ aDependentProperties.push_back( PROPERTY_ID_STRINGITEMLIST );
+ break;
+
+ // ----- DataField -----
+ case PROPERTY_ID_CONTROLSOURCE:
+ {
+ ::rtl::OUString sControlSource;
+ _rNewValue >>= sControlSource;
+ if ( impl_componentHasProperty_throw( PROPERTY_FILTERPROPOSAL ) )
+ _rxInspectorUI->enablePropertyUI( PROPERTY_FILTERPROPOSAL, sControlSource.getLength() > 0 );
+ if ( impl_componentHasProperty_throw( PROPERTY_EMPTY_IS_NULL ) )
+ _rxInspectorUI->enablePropertyUI( PROPERTY_EMPTY_IS_NULL, sControlSource.getLength() > 0 );
+
+ aDependentProperties.push_back( PROPERTY_ID_BOUNDCOLUMN );
+ aDependentProperties.push_back( PROPERTY_ID_SCALEIMAGE );
+ aDependentProperties.push_back( PROPERTY_ID_SCALE_MODE );
+ aDependentProperties.push_back( PROPERTY_ID_INPUT_REQUIRED );
+ }
+ break;
+
+ case PROPERTY_ID_EMPTY_IS_NULL:
+ aDependentProperties.push_back( PROPERTY_ID_INPUT_REQUIRED );
+ break;
+
+ // ----- SubmitEncoding -----
+ case PROPERTY_ID_SUBMIT_ENCODING:
+ {
+ FormSubmitEncoding eEncoding = FormSubmitEncoding_URL;
+ OSL_VERIFY( _rNewValue >>= eEncoding );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_SUBMIT_METHOD, eEncoding == FormSubmitEncoding_URL );
+ }
+ break;
+
+ // ----- Repeat -----
+ case PROPERTY_ID_REPEAT:
+ {
+ sal_Bool bIsRepeating = sal_False;
+ OSL_VERIFY( _rNewValue >>= bIsRepeating );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_REPEAT_DELAY, bIsRepeating );
+ }
+ break;
+
+ // ----- TabStop -----
+ case PROPERTY_ID_TABSTOP:
+ {
+ if ( !impl_componentHasProperty_throw( PROPERTY_TABINDEX ) )
+ break;
+ sal_Bool bHasTabStop = sal_False;
+ _rNewValue >>= bHasTabStop;
+ _rxInspectorUI->enablePropertyUI( PROPERTY_TABINDEX, bHasTabStop );
+ }
+ break;
+
+ // ----- Border -----
+ case PROPERTY_ID_BORDER:
+ {
+ sal_Int16 nBordeType = VisualEffect::NONE;
+ OSL_VERIFY( _rNewValue >>= nBordeType );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_BORDERCOLOR, nBordeType == VisualEffect::FLAT );
+ }
+ break;
+
+ // ----- DropDown -----
+ case PROPERTY_ID_DROPDOWN:
+ {
+ if ( impl_isSupportedProperty_nothrow( PROPERTY_ID_LINECOUNT ) )
+ {
+ sal_Bool bDropDown = sal_True;
+ _rNewValue >>= bDropDown;
+ _rxInspectorUI->enablePropertyUI( PROPERTY_LINECOUNT, bDropDown );
+ }
+ }
+ break;
+
+ // ----- ImageURL -----
+ case PROPERTY_ID_IMAGE_URL:
+ {
+ if ( impl_isSupportedProperty_nothrow( PROPERTY_ID_IMAGEPOSITION ) )
+ {
+ ::rtl::OUString sImageURL;
+ OSL_VERIFY( _rNewValue >>= sImageURL );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_IMAGEPOSITION, sImageURL.getLength() != 0 );
+ }
+
+ aDependentProperties.push_back( PROPERTY_ID_SCALEIMAGE );
+ aDependentProperties.push_back( PROPERTY_ID_SCALE_MODE );
+ }
+ break;
+
+ // ----- ButtonType -----
+ case PROPERTY_ID_BUTTONTYPE:
+ {
+ FormButtonType eButtonType( FormButtonType_PUSH );
+ OSL_VERIFY( _rNewValue >>= eButtonType );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_TARGET_URL, FormButtonType_URL == eButtonType );
+ }
+ // NO break!
+
+ // ----- TargetURL -----
+ case PROPERTY_ID_TARGET_URL:
+ aDependentProperties.push_back( PROPERTY_ID_TARGET_FRAME );
+ break; // case PROPERTY_ID_TARGET_URL
+
+ // ----- TriState -----
+ case PROPERTY_ID_TRISTATE:
+ if ( !_bFirstTimeInit )
+ _rxInspectorUI->rebuildPropertyUI( m_eComponentClass == eFormControl ? PROPERTY_DEFAULT_STATE : PROPERTY_STATE );
+ break; // case PROPERTY_ID_TRISTATE
+
+ // ----- DecimalAccuracy -----
+ case PROPERTY_ID_DECIMAL_ACCURACY:
+ // ----- ShowThousandsSeparator -----
+ case PROPERTY_ID_SHOWTHOUSANDSEP:
+ {
+ sal_Bool bAccuracy = (PROPERTY_ID_DECIMAL_ACCURACY == nActuatingPropId);
+ sal_uInt16 nNewDigits = 0;
+ sal_Bool bUseSep = sal_False;
+ if ( bAccuracy )
+ OSL_VERIFY( _rNewValue >>= nNewDigits );
+ else
+ OSL_VERIFY( _rNewValue >>= bUseSep );
+
+ // propagate the changes to the min/max/default fields
+ Any aCurrentProp;
+ ::rtl::OUString aAffectedProps[] = { PROPERTY_VALUE, PROPERTY_DEFAULT_VALUE, PROPERTY_VALUEMIN, PROPERTY_VALUEMAX };
+ for (sal_uInt16 i=0; i<sizeof(aAffectedProps)/sizeof(aAffectedProps[0]); ++i)
+ {
+ Reference< XPropertyControl > xControl;
+ try
+ {
+ xControl = _rxInspectorUI->getPropertyControl( aAffectedProps[i] );
+ }
+ catch( const UnknownPropertyException& e ) { (void)e; }
+ if ( xControl.is() )
+ {
+ OFormattedNumericControl* pControl = dynamic_cast< OFormattedNumericControl* >( xControl.get() );
+ DBG_ASSERT( pControl, "FormComponentPropertyHandler::actuatingPropertyChanged: invalid control!" );
+ if ( pControl )
+ {
+ if ( bAccuracy )
+ pControl->SetDecimalDigits( nNewDigits );
+ else
+ pControl->SetThousandsSep( bUseSep );
+ }
+ }
+ }
+ }
+ break;
+
+ // ----- FormatKey -----
+ case PROPERTY_ID_FORMATKEY:
+ {
+ FormatDescription aNewDesc;
+
+ Reference< XNumberFormatsSupplier > xSupplier;
+ OSL_VERIFY( m_xComponent->getPropertyValue( PROPERTY_FORMATSSUPPLIER ) >>= xSupplier );
+
+ Reference< XUnoTunnel > xTunnel( xSupplier, UNO_QUERY );
+ DBG_ASSERT(xTunnel.is(), "FormComponentPropertyHandler::actuatingPropertyChanged: xTunnel is invalid!");
+ if ( xTunnel.is() )
+ {
+ SvNumberFormatsSupplierObj* pSupplier = reinterpret_cast<SvNumberFormatsSupplierObj*>(xTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
+ // the same again
+
+ aNewDesc.pSupplier = pSupplier;
+ if ( !( _rNewValue >>= aNewDesc.nKey ) )
+ aNewDesc.nKey = 0;
+
+ // give each control which has to know this an own copy of the description
+ ::rtl::OUString aFormattedPropertyControls[] = {
+ PROPERTY_EFFECTIVE_MIN, PROPERTY_EFFECTIVE_MAX, PROPERTY_EFFECTIVE_DEFAULT, PROPERTY_EFFECTIVE_VALUE
+ };
+ for ( sal_uInt16 i=0; i<sizeof(aFormattedPropertyControls)/sizeof(aFormattedPropertyControls[0]); ++i )
+ {
+ Reference< XPropertyControl > xControl;
+ try
+ {
+ xControl = _rxInspectorUI->getPropertyControl( aFormattedPropertyControls[i] );
+ }
+ catch( const UnknownPropertyException& e ) { (void)e; }
+ if ( xControl.is() )
+ {
+ OFormattedNumericControl* pControl = dynamic_cast< OFormattedNumericControl* >( xControl.get() );
+ DBG_ASSERT( pControl, "FormComponentPropertyHandler::actuatingPropertyChanged: invalid control!" );
+ if ( pControl )
+ pControl->SetFormatDescription( aNewDesc );
+ }
+ }
+ }
+ }
+ break;
+
+ case PROPERTY_ID_TOGGLE:
+ {
+ sal_Bool bIsToggleButton = sal_False;
+ OSL_VERIFY( _rNewValue >>= bIsToggleButton );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_DEFAULT_STATE, bIsToggleButton );
+ }
+ break;
+
+ default:
+ DBG_ERROR( "FormComponentPropertyHandler::actuatingPropertyChanged: did not register for this property!" );
+ break;
+
+ } // switch ( nActuatingPropId )
+
+ for ( ::std::vector< PropertyId >::const_iterator loopAffected = aDependentProperties.begin();
+ loopAffected != aDependentProperties.end();
+ ++loopAffected
+ )
+ {
+ if ( impl_isSupportedProperty_nothrow( *loopAffected ) )
+ impl_updateDependentProperty_nothrow( *loopAffected, _rxInspectorUI );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void FormComponentPropertyHandler::impl_updateDependentProperty_nothrow( PropertyId _nPropId, const Reference< XObjectInspectorUI >& _rxInspectorUI ) const
+ {
+ try
+ {
+ switch ( _nPropId )
+ {
+ // ----- StringItemList -----
+ case PROPERTY_ID_STRINGITEMLIST:
+ {
+ ListSourceType eLSType = ListSourceType_VALUELIST;
+ OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_LISTSOURCETYPE ) >>= eLSType );
+
+ ::rtl::OUString sListSource;
+ {
+ Sequence< ::rtl::OUString > aListSource;
+ Any aListSourceValue( impl_getPropertyValue_throw( PROPERTY_LISTSOURCE ) );
+ if ( aListSourceValue >>= aListSource )
+ {
+ if ( aListSource.getLength() )
+ sListSource = aListSource[0];
+ }
+ else
+ OSL_VERIFY( aListSourceValue >>= sListSource );
+ }
+
+ sal_Bool bIsEnabled = ( ( eLSType == ListSourceType_VALUELIST )
+ || ( sListSource.getLength() == 0 )
+ );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_STRINGITEMLIST, bIsEnabled );
+ }
+ break; // case PROPERTY_ID_STRINGITEMLIST
+
+ // ----- BoundColumn -----
+ case PROPERTY_ID_BOUNDCOLUMN:
+ {
+ ::rtl::OUString sControlSource;
+ OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_CONTROLSOURCE ) >>= sControlSource );
+
+ ListSourceType eLSType = ListSourceType_VALUELIST;
+ OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_LISTSOURCETYPE ) >>= eLSType );
+
+ _rxInspectorUI->enablePropertyUI( PROPERTY_BOUNDCOLUMN,
+ ( sControlSource.getLength() > 0 )
+ && ( eLSType != ListSourceType_TABLEFIELDS )
+ && ( eLSType != ListSourceType_VALUELIST )
+ );
+ }
+ break; // case PROPERTY_ID_BOUNDCOLUMN
+
+ // ----- ScaleImage, ScaleMode -----
+ case PROPERTY_ID_SCALEIMAGE:
+ case PROPERTY_ID_SCALE_MODE:
+ {
+ ::rtl::OUString sControlSource;
+ if ( impl_isSupportedProperty_nothrow( PROPERTY_ID_CONTROLSOURCE ) )
+ impl_getPropertyValue_throw( PROPERTY_CONTROLSOURCE ) >>= sControlSource;
+
+ ::rtl::OUString sImageURL;
+ impl_getPropertyValue_throw( PROPERTY_IMAGE_URL ) >>= sImageURL;
+
+ _rxInspectorUI->enablePropertyUI( impl_getPropertyNameFromId_nothrow( _nPropId ),
+ ( sControlSource.getLength() != 0 ) || ( sImageURL.getLength() != 0 )
+ );
+ }
+ break; // case PROPERTY_ID_SCALEIMAGE, PROPERTY_ID_SCALE_MODE
+
+ // ----- InputRequired -----
+ case PROPERTY_ID_INPUT_REQUIRED:
+ {
+ ::rtl::OUString sControlSource;
+ OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_CONTROLSOURCE ) >>= sControlSource );
+
+ sal_Bool bEmptyIsNULL = sal_False;
+ sal_Bool bHasEmptyIsNULL = impl_componentHasProperty_throw( PROPERTY_EMPTY_IS_NULL );
+ if ( bHasEmptyIsNULL )
+ OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_EMPTY_IS_NULL ) >>= bEmptyIsNULL );
+
+ // if the control is not bound to a DB field, there is no sense in having the "Input required"
+ // property
+ // Also, if an empty input of this control are *not* written as NULL, but as empty strings,
+ // then "Input required" does not make sense, too (since there's always an input, even if the control
+ // is empty).
+ _rxInspectorUI->enablePropertyUI( PROPERTY_INPUT_REQUIRED,
+ ( sControlSource.getLength() != 0 ) && ( !bHasEmptyIsNULL || bEmptyIsNULL )
+ );
+ }
+ break;
+
+ // ----- SelectedItems, DefaultSelection -----
+ case PROPERTY_ID_SELECTEDITEMS:
+ case PROPERTY_ID_DEFAULT_SELECT_SEQ:
+ {
+ Sequence< ::rtl::OUString > aEntries;
+ impl_getPropertyValue_throw( PROPERTY_STRINGITEMLIST ) >>= aEntries;
+ bool isEnabled = aEntries.getLength() != 0;
+
+ if ( ( m_nClassId == FormComponentType::LISTBOX ) && ( m_eComponentClass == eFormControl ) )
+ {
+ ListSourceType eLSType = ListSourceType_VALUELIST;
+ impl_getPropertyValue_throw( PROPERTY_LISTSOURCETYPE ) >>= eLSType;
+ isEnabled &= ( eLSType == ListSourceType_VALUELIST );
+ }
+ _rxInspectorUI->enablePropertyUIElements( impl_getPropertyNameFromId_nothrow( _nPropId ),
+ PropertyLineElement::PrimaryButton, isEnabled );
+ }
+ break; // case PROPERTY_ID_DEFAULT_SELECT_SEQ
+
+ // ----- TargetFrame ------
+ case PROPERTY_ID_TARGET_FRAME:
+ {
+ ::rtl::OUString sTargetURL;
+ impl_getPropertyValue_throw( PROPERTY_TARGET_URL ) >>= sTargetURL;
+ FormButtonType eButtonType( FormButtonType_URL );
+ if ( 0 != m_nClassId )
+ {
+ OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_BUTTONTYPE ) >>= eButtonType );
+ }
+ // if m_nClassId is 0, then we're inspecting a form. In this case, eButtonType is always
+ // FormButtonType_URL here
+ _rxInspectorUI->enablePropertyUI( PROPERTY_TARGET_FRAME,
+ ( eButtonType == FormButtonType_URL ) && ( sTargetURL.getLength() > 0 )
+ );
+ }
+ break;
+
+ // ----- Order ------
+ case PROPERTY_ID_SORT:
+ // ----- Filter ------
+ case PROPERTY_ID_FILTER:
+ {
+ Reference< XConnection > xConnection;
+ bool bAllowEmptyDS = ::dbtools::isEmbeddedInDatabase( m_xComponent, xConnection );
+
+ // if there's no escape processing, we cannot enter any values for this property
+ sal_Bool bDoEscapeProcessing( sal_False );
+ impl_getPropertyValue_throw( PROPERTY_ESCAPE_PROCESSING ) >>= bDoEscapeProcessing;
+ _rxInspectorUI->enablePropertyUI(
+ impl_getPropertyNameFromId_nothrow( _nPropId ),
+ bDoEscapeProcessing
+ );
+
+ // also care for the browse button - enabled if we have escape processing, and a valid
+ // data source signature
+ _rxInspectorUI->enablePropertyUIElements(
+ impl_getPropertyNameFromId_nothrow( _nPropId ),
+ PropertyLineElement::PrimaryButton,
+ impl_hasValidDataSourceSignature_nothrow( m_xComponent, bAllowEmptyDS )
+ && bDoEscapeProcessing
+ );
+ }
+ break; // case PROPERTY_ID_FILTER:
+
+ // ----- Command -----
+ case PROPERTY_ID_COMMAND:
+ {
+ sal_Int32 nCommandType( CommandType::COMMAND );
+ OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_COMMANDTYPE ) >>= nCommandType );
+
+ impl_ensureRowsetConnection_nothrow();
+ Reference< XConnection > xConnection = m_xRowSetConnection.getTyped();
+ bool bAllowEmptyDS = false;
+ if ( !xConnection.is() )
+ bAllowEmptyDS = ::dbtools::isEmbeddedInDatabase( m_xComponent, xConnection );
+
+ bool doEnable = ( nCommandType == CommandType::COMMAND )
+ && ( m_xRowSetConnection.is()
+ || xConnection.is()
+ || impl_hasValidDataSourceSignature_nothrow( m_xComponent, bAllowEmptyDS)
+ );
+
+ _rxInspectorUI->enablePropertyUIElements(
+ PROPERTY_COMMAND,
+ PropertyLineElement::PrimaryButton,
+ doEnable
+ );
+ }
+ break; // case PROPERTY_ID_COMMAND
+
+ // ----- DetailFields -----
+ case PROPERTY_ID_DETAILFIELDS:
+ {
+ Reference< XConnection > xConnection;
+ bool bAllowEmptyDS = ::dbtools::isEmbeddedInDatabase( m_xComponent, xConnection );
+
+ // both our current form, and it's parent form, need to have a valid
+ // data source signature
+ bool bDoEnableMasterDetailFields =
+ impl_hasValidDataSourceSignature_nothrow( m_xComponent, bAllowEmptyDS )
+ && impl_hasValidDataSourceSignature_nothrow( Reference< XPropertySet >( m_xObjectParent, UNO_QUERY ), bAllowEmptyDS );
+
+ // in opposite to the other properties, here in real *two* properties are
+ // affected
+ _rxInspectorUI->enablePropertyUIElements( PROPERTY_DETAILFIELDS, PropertyLineElement::PrimaryButton, bDoEnableMasterDetailFields );
+ _rxInspectorUI->enablePropertyUIElements( PROPERTY_MASTERFIELDS, PropertyLineElement::PrimaryButton, bDoEnableMasterDetailFields );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( false, "FormComponentPropertyHandler::impl_updateDependentProperty_nothrow: unexpected property to update!" );
+ break;
+
+ } // switch
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormComponentPropertyHandler::impl_updateDependentProperty_nothrow: caught an exception!" );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL FormComponentPropertyHandler::disposing()
+ {
+ FormComponentPropertyHandler_Base::disposing();
+ if ( m_xCommandDesigner.is() && m_xCommandDesigner->isActive() )
+ m_xCommandDesigner->dispose();
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool SAL_CALL FormComponentPropertyHandler::suspend( sal_Bool _bSuspend ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( _bSuspend )
+ if ( m_xCommandDesigner.is() && m_xCommandDesigner->isActive() )
+ return m_xCommandDesigner->suspend();
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------------
+ void FormComponentPropertyHandler::impl_initComponentMetaData_throw()
+ {
+ try
+ {
+ //////////////////////////////////////////////////////////////////
+ // component class
+ m_eComponentClass = eUnknown;
+
+ if ( impl_componentHasProperty_throw( PROPERTY_WIDTH )
+ && impl_componentHasProperty_throw( PROPERTY_HEIGHT )
+ && impl_componentHasProperty_throw( PROPERTY_POSITIONX )
+ && impl_componentHasProperty_throw( PROPERTY_POSITIONY )
+ && impl_componentHasProperty_throw( PROPERTY_STEP )
+ && impl_componentHasProperty_throw( PROPERTY_TABINDEX )
+ )
+ {
+ m_eComponentClass = eDialogControl;
+ }
+ else
+ {
+ m_eComponentClass = eFormControl;
+ }
+
+ //////////////////////////////////////////////////////////////////
+ // (database) sub form?
+ Reference< XForm > xAsForm( m_xComponent, UNO_QUERY );
+ if ( xAsForm.is() )
+ {
+ Reference< XChild > xFormAsChild( xAsForm, UNO_QUERY );
+ Reference< XForm > xFormsParent;
+ if ( xFormAsChild.is() )
+ xFormsParent = xFormsParent.query( xFormAsChild->getParent() );
+ m_bComponentIsSubForm = xFormsParent.is();
+ }
+
+ //////////////////////////////////////////////////////////////////
+ // ClassId
+ Reference< XChild > xCompAsChild( m_xComponent, UNO_QUERY );
+ if ( xCompAsChild.is() )
+ m_xObjectParent = xCompAsChild->getParent();
+
+ //////////////////////////////////////////////////////////////////
+ // ClassId
+ impl_classifyControlModel_throw();
+ }
+ catch( const RuntimeException& )
+ {
+ throw;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormComponentPropertyHandler::impl_initComponentMetaData_throw: caught an exception!" );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void FormComponentPropertyHandler::impl_classifyControlModel_throw( )
+ {
+ if ( impl_componentHasProperty_throw( PROPERTY_CLASSID ) )
+ {
+ OSL_VERIFY( m_xComponent->getPropertyValue( PROPERTY_CLASSID ) >>= m_nClassId );
+ }
+ else if ( eDialogControl == m_eComponentClass )
+ {
+ Reference< XControlModel > xControlModel( m_xComponent, UNO_QUERY );
+ Reference< XServiceInfo > xServiceInfo( m_xComponent, UNO_QUERY );
+ if ( xServiceInfo.is() )
+ {
+ // it's a control model, and can tell about it's supported services
+ m_nClassId = FormComponentType::CONTROL;
+
+ const sal_Char* aControlModelServiceNames[] =
+ {
+ "UnoControlButtonModel",
+ "UnoControlCheckBoxModel",
+ "UnoControlComboBoxModel",
+ "UnoControlCurrencyFieldModel",
+ "UnoControlDateFieldModel",
+ "UnoControlEditModel",
+ "UnoControlFileControlModel",
+ "UnoControlFixedTextModel",
+ "UnoControlGroupBoxModel",
+ "UnoControlImageControlModel",
+ "UnoControlListBoxModel",
+ "UnoControlNumericFieldModel",
+ "UnoControlPatternFieldModel",
+ "UnoControlRadioButtonModel",
+ "UnoControlScrollBarModel",
+ "UnoControlSpinButtonModel",
+ "UnoControlTimeFieldModel",
+
+ "UnoControlFixedLineModel",
+ "UnoControlFormattedFieldModel",
+ "UnoControlProgressBarModel"
+ };
+ const sal_Int16 nClassIDs[] =
+ {
+ FormComponentType::COMMANDBUTTON,
+ FormComponentType::CHECKBOX,
+ FormComponentType::COMBOBOX,
+ FormComponentType::CURRENCYFIELD,
+ FormComponentType::DATEFIELD,
+ FormComponentType::TEXTFIELD,
+ FormComponentType::FILECONTROL,
+ FormComponentType::FIXEDTEXT,
+ FormComponentType::GROUPBOX,
+ FormComponentType::IMAGECONTROL,
+ FormComponentType::LISTBOX,
+ FormComponentType::NUMERICFIELD,
+ FormComponentType::PATTERNFIELD,
+ FormComponentType::RADIOBUTTON,
+ FormComponentType::SCROLLBAR,
+ FormComponentType::SPINBUTTON,
+ FormComponentType::TIMEFIELD,
+
+ ControlType::FIXEDLINE,
+ ControlType::FORMATTEDFIELD,
+ ControlType::PROGRESSBAR
+ };
+
+ sal_Int32 nKnownControlTypes = sizeof( aControlModelServiceNames ) / sizeof( aControlModelServiceNames[ 0 ] );
+ OSL_ENSURE( nKnownControlTypes == sizeof( nClassIDs ) / sizeof( nClassIDs[ 0 ] ),
+ "FormComponentPropertyHandler::impl_classifyControlModel_throw: inconsistence" );
+
+ for ( sal_Int32 i = 0; i < nKnownControlTypes; ++i )
+ {
+ ::rtl::OUString sServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt." ) );
+ sServiceName += ::rtl::OUString::createFromAscii( aControlModelServiceNames[ i ] );
+
+ if ( xServiceInfo->supportsService( sServiceName ) )
+ {
+ m_nClassId = nClassIDs[ i ];
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void FormComponentPropertyHandler::impl_normalizePropertyValue_nothrow( Any& _rValue, PropertyId _nPropId ) const
+ {
+ switch ( _nPropId )
+ {
+ case PROPERTY_ID_TABSTOP:
+ if ( !_rValue.hasValue() )
+ {
+ switch ( m_nClassId )
+ {
+ case FormComponentType::COMMANDBUTTON:
+ case FormComponentType::RADIOBUTTON:
+ case FormComponentType::CHECKBOX:
+ case FormComponentType::TEXTFIELD:
+ case FormComponentType::LISTBOX:
+ case FormComponentType::COMBOBOX:
+ case FormComponentType::FILECONTROL:
+ case FormComponentType::DATEFIELD:
+ case FormComponentType::TIMEFIELD:
+ case FormComponentType::NUMERICFIELD:
+ case ControlType::FORMATTEDFIELD:
+ case FormComponentType::CURRENCYFIELD:
+ case FormComponentType::PATTERNFIELD:
+ _rValue = makeAny( (sal_Bool)sal_True );
+ break;
+ default:
+ _rValue = makeAny( (sal_Bool)sal_False );
+ break;
+ }
+ }
+ break;
+ }
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_shouldExcludeProperty_nothrow( const Property& _rProperty ) const
+ {
+ OSL_ENSURE( _rProperty.Handle == m_pInfoService->getPropertyId( _rProperty.Name ),
+ "FormComponentPropertyHandler::impl_shouldExcludeProperty_nothrow: insonsistency in the property!" );
+
+ if ( _rProperty.Handle == PROPERTY_ID_CONTROLLABEL )
+ // prevent that this is caught below
+ return false;
+
+ if ( ( _rProperty.Type.getTypeClass() == TypeClass_INTERFACE )
+ || ( _rProperty.Type.getTypeClass() == TypeClass_ARRAY )
+ || ( _rProperty.Type.getTypeClass() == TypeClass_UNKNOWN )
+ )
+ return true;
+
+ if ( ( _rProperty.Attributes & PropertyAttribute::TRANSIENT ) && ( m_eComponentClass != eDialogControl ) )
+ // strange enough, dialog controls declare a lot of their properties as transient
+ return true;
+
+ if ( _rProperty.Attributes & PropertyAttribute::READONLY )
+ return true;
+
+ switch ( _rProperty.Handle )
+ {
+ case PROPERTY_ID_MASTERFIELDS:
+ case PROPERTY_ID_DETAILFIELDS:
+ if ( !m_bComponentIsSubForm )
+ // no master and detail fields for forms which are no sub forms
+ return true;
+ break;
+
+ case PROPERTY_ID_DATASOURCE:
+ {
+ // don't show DataSource if the component is part of an embedded form document
+ Reference< XConnection > xConn;
+ if ( isEmbeddedInDatabase( m_xComponent, xConn ) )
+ return true;
+ }
+ break;
+
+ case PROPERTY_ID_TEXT:
+ // don't show the "Text" property of formatted fields
+ if ( ControlType::FORMATTEDFIELD == m_nClassId )
+ return true;
+ break;
+
+ case PROPERTY_ID_FORMATKEY:
+ case PROPERTY_ID_EFFECTIVE_MIN:
+ case PROPERTY_ID_EFFECTIVE_MAX:
+ case PROPERTY_ID_EFFECTIVE_DEFAULT:
+ case PROPERTY_ID_EFFECTIVE_VALUE:
+ // only if the set has a formats supplier, too
+ if ( !impl_componentHasProperty_throw( PROPERTY_FORMATSSUPPLIER ) )
+ return true;
+ // (form) date and time fields also have a formats supplier, but the format itself
+ // is reflected in another property
+ if ( ( FormComponentType::DATEFIELD == m_nClassId )
+ || ( FormComponentType::TIMEFIELD == m_nClassId )
+ )
+ return true;
+ break;
+
+ case PROPERTY_ID_SCALEIMAGE:
+ if ( impl_componentHasProperty_throw( PROPERTY_SCALE_MODE ) )
+ // ScaleImage is superseded by ScaleMode
+ return true;
+ break;
+
+ case PROPERTY_ID_WRITING_MODE:
+ if ( !SvtCTLOptions().IsCTLFontEnabled() )
+ return true;
+ break;
+ }
+
+ sal_uInt32 nPropertyUIFlags = m_pInfoService->getPropertyUIFlags( _rProperty.Handle );
+
+ // don't show experimental properties unless allowed to do so
+ if ( ( nPropertyUIFlags & PROP_FLAG_EXPERIMENTAL ) != 0 )
+ {
+ if ( true ) // TODO
+ return true;
+ }
+
+ // no data properties if no Base is installed. #124939#
+ // This fix is not intendend to appear on the main trunk. If you find it there,
+ // please tell me! frank.schoenheit@sun.com
+ if ( ( nPropertyUIFlags & PROP_FLAG_DATA_PROPERTY ) != 0 )
+ if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
+ return true;
+
+ return false;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XRowSet > FormComponentPropertyHandler::impl_getRowSet_throw( ) const
+ {
+ Reference< XRowSet > xRowSet = m_xRowSet;
+ if ( !xRowSet.is() )
+ {
+ xRowSet.set( m_xComponent, UNO_QUERY );
+ if ( !xRowSet.is() )
+ {
+ xRowSet = Reference< XRowSet >( m_xObjectParent, UNO_QUERY );
+ if ( !xRowSet.is() )
+ {
+ // are we inspecting a grid column?
+ if (Reference< XGridColumnFactory >( m_xObjectParent, UNO_QUERY) .is())
+ { // yes
+ Reference< XChild > xParentAsChild( m_xObjectParent, UNO_QUERY );
+ if ( xParentAsChild.is() )
+ xRowSet = Reference< XRowSet >( xParentAsChild->getParent(), UNO_QUERY );
+ }
+ }
+ if ( !xRowSet.is() )
+ xRowSet = m_xRowSet;
+ }
+ DBG_ASSERT( xRowSet.is(), "FormComponentPropertyHandler::impl_getRowSet_throw: could not obtain the rowset for the introspectee!" );
+ }
+ return xRowSet;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XRowSet > FormComponentPropertyHandler::impl_getRowSet_nothrow( ) const
+ {
+ Reference< XRowSet > xReturn;
+ try
+ {
+ xReturn = impl_getRowSet_throw();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormComponentPropertyHandler::impl_getRowSet_nothrow: caught an exception!" );
+ }
+ return xReturn;
+ }
+
+ //------------------------------------------------------------------------
+ void FormComponentPropertyHandler::impl_initFieldList_nothrow( ::std::vector< ::rtl::OUString >& _rFieldNames ) const
+ {
+ clearContainer( _rFieldNames );
+ try
+ {
+ WaitCursor aWaitCursor( impl_getDefaultDialogParent_nothrow() );
+
+ Reference< XPreparedStatement > xStatement;
+
+ // get the form of the control we're inspecting
+ Reference< XPropertySet > xFormSet( impl_getRowSet_throw(), UNO_QUERY );
+ if ( !xFormSet.is() )
+ return;
+
+ ::rtl::OUString sObjectName;
+ OSL_VERIFY( xFormSet->getPropertyValue( PROPERTY_COMMAND ) >>= sObjectName );
+ // when there is no command we don't need to ask for columns
+ if ( sObjectName.getLength() && impl_ensureRowsetConnection_nothrow() )
+ {
+ ::rtl::OUString aDatabaseName;
+ OSL_VERIFY( xFormSet->getPropertyValue( PROPERTY_DATASOURCE ) >>= aDatabaseName );
+ sal_Int32 nObjectType = CommandType::COMMAND;
+ OSL_VERIFY( xFormSet->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nObjectType );
+
+ Sequence< ::rtl::OUString > aFields( ::dbtools::getFieldNamesByCommandDescriptor( m_xRowSetConnection, nObjectType, sObjectName ) );
+
+ const ::rtl::OUString* pFields = aFields.getConstArray();
+ for ( sal_Int32 i = 0; i < aFields.getLength(); ++i, ++pFields )
+ _rFieldNames.push_back( *pFields );
+ }
+ }
+ catch (Exception&)
+ {
+ DBG_ERROR( "FormComponentPropertyHandler::impl_initFieldList_nothrow: caught an exception!" );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void FormComponentPropertyHandler::impl_clearRowsetConnection_nothrow()
+ {
+ m_xRowSetConnection.clear();
+ }
+
+ //------------------------------------------------------------------------
+ void FormComponentPropertyHandler::impl_displaySQLError_nothrow( const ::dbtools::SQLExceptionInfo& _rErrorDescriptor ) const
+ {
+ ::dbtools::showError( _rErrorDescriptor, VCLUnoHelper::GetInterface( impl_getDefaultDialogParent_nothrow() ), m_aContext.getLegacyServiceFactory() );
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_ensureRowsetConnection_nothrow() const
+ {
+ if ( !m_xRowSetConnection.is() )
+ {
+ uno::Reference<sdbc::XConnection> xConnection(m_aContext.getContextValueByAsciiName( "ActiveConnection" ),uno::UNO_QUERY);
+ m_xRowSetConnection.reset(xConnection,::dbtools::SharedConnection::NoTakeOwnership);
+ }
+ if ( m_xRowSetConnection.is() )
+ return true;
+
+ Reference< XRowSet > xRowSet( impl_getRowSet_throw() );
+ Reference< XPropertySet > xRowSetProps( xRowSet, UNO_QUERY );
+
+ // connect the row set - this is delegated to elsewhere - while observing errors
+ SQLExceptionInfo aError;
+ try
+ {
+ if ( xRowSetProps.is() )
+ {
+ WaitCursor aWaitCursor( impl_getDefaultDialogParent_nothrow() );
+ m_xRowSetConnection = ::dbtools::ensureRowSetConnection( xRowSet, m_aContext.getLegacyServiceFactory(), false );
+ }
+ }
+ catch ( const SQLException& ) { aError = SQLExceptionInfo( ::cppu::getCaughtException() ); }
+ catch ( const WrappedTargetException& e ) { aError = SQLExceptionInfo( e.TargetException ); }
+ catch ( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); }
+
+ // report errors, if necessary
+ if ( aError.isValid() )
+ {
+ ::rtl::OUString sDataSourceName;
+ try
+ {
+ xRowSetProps->getPropertyValue( PROPERTY_DATASOURCE ) >>= sDataSourceName;
+ }
+ catch( const Exception& )
+ {
+ DBG_ERROR( "FormComponentPropertyHandler::impl_ensureRowsetConnection_nothrow: caught an exception during error handling!" );
+ }
+ // additional info about what happended
+ String sInfo( PcrRes( RID_STR_UNABLETOCONNECT ) );
+ INetURLObject aParser( sDataSourceName );
+ if ( aParser.GetProtocol() != INET_PROT_NOT_VALID )
+ sDataSourceName = aParser.getBase( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
+ sInfo.SearchAndReplaceAllAscii( "$name$", sDataSourceName );
+
+ SQLContext aContext;
+ aContext.Message = sInfo;
+ aContext.NextException = aError.get();
+ impl_displaySQLError_nothrow( aContext );
+ }
+
+ return m_xRowSetConnection.is();
+ }
+
+ //------------------------------------------------------------------------
+ void FormComponentPropertyHandler::impl_describeCursorSource_nothrow( LineDescriptor& _out_rProperty, const Reference< XPropertyControlFactory >& _rxControlFactory ) const
+ {
+ try
+ {
+ WaitCursor aWaitCursor( impl_getDefaultDialogParent_nothrow() );
+
+ ////////////////////////////////////////////////////////////
+ // Setzen der UI-Daten
+ _out_rProperty.DisplayName = m_pInfoService->getPropertyTranslation( PROPERTY_ID_COMMAND );
+
+ _out_rProperty.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( PROPERTY_ID_COMMAND ) );
+ _out_rProperty.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_SQLCOMMAND);
+
+ ////////////////////////////////////////////////////////////
+ sal_Int32 nCommandType = CommandType::COMMAND;
+ impl_getPropertyValue_throw( PROPERTY_COMMANDTYPE ) >>= nCommandType;
+
+ switch ( nCommandType )
+ {
+ case CommandType::TABLE:
+ case CommandType::QUERY:
+ {
+ ::std::vector< ::rtl::OUString > aNames;
+ if ( impl_ensureRowsetConnection_nothrow() )
+ {
+ if ( nCommandType == CommandType::TABLE )
+ impl_fillTableNames_throw( aNames );
+ else
+ impl_fillQueryNames_throw( aNames );
+ }
+ _out_rProperty.Control = PropertyHandlerHelper::createComboBoxControl( _rxControlFactory, aNames, sal_False, sal_True );
+ }
+ break;
+
+ default:
+ _out_rProperty.Control = _rxControlFactory->createPropertyControl( PropertyControlType::MultiLineTextField, sal_False );
+ break;
+ }
+ }
+ catch (Exception&)
+ {
+ DBG_ERROR("FormComponentPropertyHandler::impl_describeCursorSource_nothrow: caught an exception !");
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void FormComponentPropertyHandler::impl_fillTableNames_throw( ::std::vector< ::rtl::OUString >& _out_rNames ) const
+ {
+ OSL_PRECOND( m_xRowSetConnection.is(), "FormComponentPropertyHandler::impl_fillTableNames_throw: need a connection!" );
+ _out_rNames.resize( 0 );
+
+ Reference< XTablesSupplier > xSupplyTables( m_xRowSetConnection, UNO_QUERY );
+ Reference< XNameAccess > xTableNames;
+ if ( xSupplyTables.is() )
+ xTableNames = xSupplyTables->getTables();
+ DBG_ASSERT( xTableNames.is(), "FormComponentPropertyHandler::impl_fillTableNames_throw: no way to obtain the tables of the connection!" );
+ if ( !xTableNames.is() )
+ return;
+
+ Sequence< ::rtl::OUString> aTableNames = xTableNames->getElementNames();
+ sal_uInt32 nCount = aTableNames.getLength();
+ const ::rtl::OUString* pTableNames = aTableNames.getConstArray();
+
+ for ( sal_uInt32 i=0; i<nCount; ++i ,++pTableNames )
+ _out_rNames.push_back( *pTableNames );
+ }
+
+ //------------------------------------------------------------------------
+ void FormComponentPropertyHandler::impl_fillQueryNames_throw( ::std::vector< ::rtl::OUString >& _out_rNames ) const
+ {
+ OSL_PRECOND( m_xRowSetConnection.is(), "FormComponentPropertyHandler::impl_fillQueryNames_throw: need a connection!" );
+ _out_rNames.resize( 0 );
+
+ Reference< XQueriesSupplier > xSupplyQueries( m_xRowSetConnection, UNO_QUERY );
+ Reference< XNameAccess > xQueryNames;
+ if ( xSupplyQueries.is() )
+ {
+ xQueryNames = xSupplyQueries->getQueries();
+ impl_fillQueryNames_throw(xQueryNames,_out_rNames);
+ }
+ }
+ //------------------------------------------------------------------------
+ void FormComponentPropertyHandler::impl_fillQueryNames_throw( const Reference< XNameAccess >& _xQueryNames,::std::vector< ::rtl::OUString >& _out_rNames,const ::rtl::OUString& _sName ) const
+ {
+ DBG_ASSERT( _xQueryNames.is(), "FormComponentPropertyHandler::impl_fillQueryNames_throw: no way to obtain the queries of the connection!" );
+ if ( !_xQueryNames.is() )
+ return;
+
+ Sequence< ::rtl::OUString> aQueryNames = _xQueryNames->getElementNames();
+ sal_uInt32 nCount = aQueryNames.getLength();
+ const ::rtl::OUString* pQueryNames = aQueryNames.getConstArray();
+ sal_Bool bAdd = _sName.getLength();
+
+ for ( sal_uInt32 i=0; i<nCount; i++, ++pQueryNames )
+ {
+ ::rtl::OUStringBuffer sTemp;
+ if ( bAdd )
+ {
+ sTemp.append(_sName);
+ sTemp.appendAscii("/");
+ }
+ sTemp.append(*pQueryNames);
+ Reference< XNameAccess > xSubQueries(_xQueryNames->getByName(*pQueryNames),UNO_QUERY);
+ if ( xSubQueries.is() )
+ impl_fillQueryNames_throw(xSubQueries,_out_rNames,sTemp.makeStringAndClear());
+ else
+ _out_rNames.push_back( sTemp.makeStringAndClear() );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void FormComponentPropertyHandler::impl_describeListSourceUI_throw( LineDescriptor& _out_rDescriptor, const Reference< XPropertyControlFactory >& _rxControlFactory ) const
+ {
+ OSL_PRECOND( m_xComponent.is(), "FormComponentPropertyHandler::impl_describeListSourceUI_throw: no component!" );
+
+ ////////////////////////////////////////////////////////////
+ // Auslesen des ListSourceTypes
+ Any aListSourceType( m_xComponent->getPropertyValue( PROPERTY_LISTSOURCETYPE ) );
+
+ sal_Int32 nListSourceType = ListSourceType_VALUELIST;
+ ::cppu::enum2int( nListSourceType, aListSourceType );
+
+ _out_rDescriptor.DisplayName = m_pInfoService->getPropertyTranslation( PROPERTY_ID_LISTSOURCE );
+ _out_rDescriptor.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( PROPERTY_ID_LISTSOURCE ) );
+
+ ////////////////////////////////////////////////////////////
+ // Enums setzen
+ switch( nListSourceType )
+ {
+ case ListSourceType_VALUELIST:
+ _out_rDescriptor.Control = _rxControlFactory->createPropertyControl( PropertyControlType::StringListField, sal_False );
+ break;
+
+ case ListSourceType_TABLEFIELDS:
+ case ListSourceType_TABLE:
+ case ListSourceType_QUERY:
+ {
+ ::std::vector< ::rtl::OUString > aListEntries;
+ if ( impl_ensureRowsetConnection_nothrow() )
+ {
+ if ( nListSourceType == ListSourceType_QUERY )
+ impl_fillQueryNames_throw( aListEntries );
+ else
+ impl_fillTableNames_throw( aListEntries );
+ }
+ _out_rDescriptor.Control = PropertyHandlerHelper::createComboBoxControl( _rxControlFactory, aListEntries, sal_False, sal_False );
+ }
+ break;
+ case ListSourceType_SQL:
+ case ListSourceType_SQLPASSTHROUGH:
+ impl_ensureRowsetConnection_nothrow();
+ _out_rDescriptor.HasPrimaryButton = m_xRowSetConnection.is();
+ break;
+ }
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_dialogListSelection_nothrow( const ::rtl::OUString& _rProperty, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
+ {
+ OSL_PRECOND( m_pInfoService.get(), "FormComponentPropertyHandler::impl_dialogListSelection_nothrow: no property meta data!" );
+
+ String sPropertyUIName( m_pInfoService->getPropertyTranslation( m_pInfoService->getPropertyId( _rProperty ) ) );
+ ListSelectionDialog aDialog( impl_getDefaultDialogParent_nothrow(), m_xComponent, _rProperty, sPropertyUIName );
+ _rClearBeforeDialog.clear();
+ return ( RET_OK == aDialog.Execute() );
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_dialogFilterOrSort_nothrow( bool _bFilter, ::rtl::OUString& _out_rSelectedClause, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
+ {
+ OSL_PRECOND( Reference< XRowSet >( m_xComponent, UNO_QUERY ).is(),
+ "FormComponentPropertyHandler::impl_dialogFilterOrSort_nothrow: to be called for forms only!" );
+
+ _out_rSelectedClause = ::rtl::OUString();
+ bool bSuccess = false;
+ SQLExceptionInfo aErrorInfo;
+ try
+ {
+ if ( !impl_ensureRowsetConnection_nothrow() )
+ return false;
+
+ // get a composer for the statement which the form is currently based on
+ Reference< XSingleSelectQueryComposer > xComposer( ::dbtools::getCurrentSettingsComposer( m_xComponent, m_aContext.getLegacyServiceFactory() ) );
+ OSL_ENSURE( xComposer.is(), "FormComponentPropertyHandler::impl_dialogFilterOrSort_nothrow: could not obtain a composer!" );
+ if ( !xComposer.is() )
+ return false;
+
+ ::rtl::OUString sPropertyUIName( m_pInfoService->getPropertyTranslation( _bFilter ? PROPERTY_ID_FILTER : PROPERTY_ID_SORT ) );
+
+ const sal_Char* pAsciiServiceName = _bFilter ? "com.sun.star.sdb.FilterDialog" : "com.sun.star.sdb.OrderDialog";
+
+ // create the dialog
+ Reference< XExecutableDialog > xDialog;
+ if ( !m_aContext.createComponent( pAsciiServiceName, xDialog ) )
+ {
+ ShowServiceNotAvailableError( impl_getDefaultDialogParent_nothrow(), ::rtl::OUString::createFromAscii( pAsciiServiceName ), sal_True );
+ return false;
+ }
+
+ // initialize the dialog
+ Reference< XPropertySet > xDialogProps( xDialog, UNO_QUERY_THROW );
+ xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "QueryComposer" ) ), makeAny( xComposer ) );
+ xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RowSet" ) ), makeAny( m_xComponent ) );
+ xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" ) ), makeAny( VCLUnoHelper::GetInterface( impl_getDefaultDialogParent_nothrow() ) ) );
+ xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), makeAny( sPropertyUIName ) );
+
+ _rClearBeforeDialog.clear();
+ bSuccess = ( xDialog->execute() != 0 );
+ if ( bSuccess )
+ _out_rSelectedClause = _bFilter ? xComposer->getFilter() : xComposer->getOrder();
+ }
+ catch (SQLContext& e) { aErrorInfo = e; }
+ catch (SQLWarning& e) { aErrorInfo = e; }
+ catch (SQLException& e) { aErrorInfo = e; }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormComponentPropertyHandler::impl_dialogFilterOrSort_nothrow: caught an exception!" );
+ }
+
+ if ( aErrorInfo.isValid() )
+ impl_displaySQLError_nothrow( aErrorInfo );
+
+ return bSuccess;
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_dialogLinkedFormFields_nothrow( ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
+ {
+ Reference< XForm > xDetailForm( m_xComponent, UNO_QUERY );
+ Reference< XForm > xMasterForm( m_xObjectParent, UNO_QUERY );
+ uno::Reference<beans::XPropertySet> xMasterProp(m_xObjectParent,uno::UNO_QUERY);
+ OSL_PRECOND( xDetailForm.is() && xMasterForm.is(), "FormComponentPropertyHandler::impl_dialogLinkedFormFields_nothrow: no forms!" );
+ if ( !xDetailForm.is() || !xMasterForm.is() )
+ return false;
+
+
+ FormLinkDialog aDialog( impl_getDefaultDialogParent_nothrow(), m_xComponent, xMasterProp, m_aContext.getLegacyServiceFactory() );
+ _rClearBeforeDialog.clear();
+ return ( RET_OK == aDialog.Execute() );
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_dialogFormatting_nothrow( Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
+ {
+ bool bChanged = false;
+ try
+ {
+ // create the itemset for the dialog
+ SfxItemSet aCoreSet(SFX_APP()->GetPool(),
+ SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_VALUE,
+ SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO,
+ 0); // ripped this somewhere ... don't understand it :(
+
+ // get the number formats supplier
+ Reference< XNumberFormatsSupplier > xSupplier;
+ m_xComponent->getPropertyValue( PROPERTY_FORMATSSUPPLIER ) >>= xSupplier;
+
+ DBG_ASSERT(xSupplier.is(), "FormComponentPropertyHandler::impl_dialogFormatting_nothrow: invalid call !" );
+ Reference< XUnoTunnel > xTunnel( xSupplier, UNO_QUERY_THROW );
+ SvNumberFormatsSupplierObj* pSupplier =
+ reinterpret_cast< SvNumberFormatsSupplierObj* >( xTunnel->getSomething( SvNumberFormatsSupplierObj::getUnoTunnelId() ) );
+ DBG_ASSERT( pSupplier != NULL, "FormComponentPropertyHandler::impl_dialogFormatting_nothrow: invalid call !" );
+
+ sal_Int32 nFormatKey = 0;
+ impl_getPropertyValue_throw( PROPERTY_FORMATKEY ) >>= nFormatKey;
+ aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE, nFormatKey ) );
+
+ SvNumberFormatter* pFormatter = pSupplier->GetNumberFormatter();
+ double dPreviewVal = OFormatSampleControl::getPreviewValue(pFormatter,nFormatKey);
+ SvxNumberInfoItem aFormatter( pFormatter, dPreviewVal, String( PcrRes( RID_STR_TEXT_FORMAT ) ), SID_ATTR_NUMBERFORMAT_INFO );
+ aCoreSet.Put( aFormatter );
+
+ // a tab dialog with a single page
+ ::std::auto_ptr< SfxSingleTabDialog > pDialog( new SfxSingleTabDialog( impl_getDefaultDialogParent_nothrow(), aCoreSet, 0 ) );
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ DBG_ASSERT( pFact, "CreateFactory fail!" );
+ ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( RID_SVXPAGE_NUMBERFORMAT );
+ if ( !fnCreatePage )
+ throw RuntimeException(); // caught below
+
+ SfxTabPage* pPage = (*fnCreatePage)( pDialog.get(), aCoreSet );
+ pDialog->SetTabPage( pPage );
+
+ _rClearBeforeDialog.clear();
+ if ( RET_OK == pDialog->Execute() )
+ {
+ const SfxItemSet* pResult = pDialog->GetOutputItemSet();
+
+ const SfxPoolItem* pItem = pResult->GetItem( SID_ATTR_NUMBERFORMAT_INFO );
+ const SvxNumberInfoItem* pInfoItem = dynamic_cast< const SvxNumberInfoItem* >( pItem );
+ if (pInfoItem && pInfoItem->GetDelCount())
+ {
+ const sal_uInt32* pDeletedKeys = pInfoItem->GetDelArray();
+
+ for (sal_uInt16 i=0; i< pInfoItem->GetDelCount(); ++i, ++pDeletedKeys)
+ pFormatter->DeleteEntry(*pDeletedKeys);
+ }
+
+ pItem = NULL;
+ if ( SFX_ITEM_SET == pResult->GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, sal_False, &pItem ) )
+ {
+ _out_rNewValue <<= (sal_Int32)( static_cast< const SfxUInt32Item* >( pItem )->GetValue() );
+ bChanged = true;
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormComponentPropertyHandler::impl_dialogFormatting_nothrow: : caught an exception!" );
+ }
+ return bChanged;
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_browseForImage_nothrow( Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
+ {
+ bool bIsLink = true;// reflect the legacy behavior
+ ::rtl::OUString aStrTrans = m_pInfoService->getPropertyTranslation( PROPERTY_ID_IMAGE_URL );
+
+ ::sfx2::FileDialogHelper aFileDlg(SFXWB_GRAPHIC);
+
+ aFileDlg.SetTitle(aStrTrans);
+ // non-linked images ( e.g. those located in the document
+ // stream ) cannot *currently* be handled by openoffice basic dialogs.
+ bool bHandleNonLink = ( m_eComponentClass == eFormControl );
+
+ Reference< XFilePickerControlAccess > xController(aFileDlg.GetFilePicker(), UNO_QUERY);
+ DBG_ASSERT(xController.is(), "FormComponentPropertyHandler::impl_browseForImage_nothrow: missing the controller interface on the file picker!");
+ if (xController.is())
+ {
+ // do a preview by default
+ xController->setValue(ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0, ::cppu::bool2any(sal_True));
+
+ xController->setValue(ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, ::cppu::bool2any(bIsLink));
+ xController->enableControl(ExtendedFilePickerElementIds::CHECKBOX_LINK, bHandleNonLink );
+
+ }
+
+ ::rtl::OUString sCurValue;
+ OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_IMAGE_URL ) >>= sCurValue );
+ if ( sCurValue.getLength() != 0 && sCurValue.compareToAscii(GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH(GRAPHOBJ_URLPREFIX) ) != 0 )
+ {
+ aFileDlg.SetDisplayDirectory( sCurValue );
+ // TODO: need to set the display directory _and_ the default name
+ }
+
+ _rClearBeforeDialog.clear();
+ bool bSuccess = ( 0 == aFileDlg.Execute() );
+ if ( bSuccess )
+ {
+ if ( bHandleNonLink && xController.is() )
+ {
+ xController->getValue(ExtendedFilePickerElementIds::CHECKBOX_LINK, 0) >>= bIsLink;
+ }
+ if ( !bIsLink )
+ {
+ Graphic aGraphic;
+ aFileDlg.GetGraphic( aGraphic );
+
+ Reference< graphic::XGraphicObject > xGrfObj = graphic::GraphicObject::create( m_aContext.getUNOContext() );
+ xGrfObj->setGraphic( aGraphic.GetXGraphic() );
+
+
+ _out_rNewValue <<= xGrfObj;
+
+ }
+ else
+ _out_rNewValue <<= (::rtl::OUString)aFileDlg.GetPath();
+ }
+ return bSuccess;
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_browseForTargetURL_nothrow( Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
+ {
+ ::sfx2::FileDialogHelper aFileDlg( WB_3DLOOK );
+
+ ::rtl::OUString sURL;
+ OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_TARGET_URL ) >>= sURL );
+ INetURLObject aParser( sURL );
+ if ( INET_PROT_FILE == aParser.GetProtocol() )
+ // set the initial directory only for file-URLs. Everything else
+ // is considered to be potentially expensive
+ // 106126 - 2002/12/10 - fs@openoffice.org
+ aFileDlg.SetDisplayDirectory( sURL );
+
+ _rClearBeforeDialog.clear();
+ bool bSuccess = ( 0 == aFileDlg.Execute() );
+ if ( bSuccess )
+ _out_rNewValue <<= (::rtl::OUString)aFileDlg.GetPath();
+ return bSuccess;
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_executeFontDialog_nothrow( Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
+ {
+ bool bSuccess = false;
+
+ // create an item set for use with the dialog
+ SfxItemSet* pSet = NULL;
+ SfxItemPool* pPool = NULL;
+ SfxPoolItem** pDefaults = NULL;
+ ControlCharacterDialog::createItemSet(pSet, pPool, pDefaults);
+ ControlCharacterDialog::translatePropertiesToItems(m_xComponent, pSet);
+
+ { // do this in an own block. The dialog needs to be destroyed before we call
+ // destroyItemSet
+ ControlCharacterDialog aDlg( impl_getDefaultDialogParent_nothrow(), *pSet );
+ _rClearBeforeDialog.clear();
+ if ( RET_OK == aDlg.Execute() )
+ {
+ const SfxItemSet* pOut = aDlg.GetOutputItemSet();
+ if ( pOut )
+ {
+ Sequence< NamedValue > aFontPropertyValues;
+ ControlCharacterDialog::translateItemsToProperties( *pOut, aFontPropertyValues );
+ _out_rNewValue <<= aFontPropertyValues;
+ bSuccess = true;
+ }
+ }
+ }
+
+ ControlCharacterDialog::destroyItemSet(pSet, pPool, pDefaults);
+ return bSuccess;
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_browseForDatabaseDocument_throw( Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
+ {
+ ::sfx2::FileDialogHelper aFileDlg(WB_3DLOOK|WB_OPEN,::String::CreateFromAscii("sdatabase"));
+
+ ::rtl::OUString sDataSource;
+ OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_DATASOURCE ) >>= sDataSource );
+ INetURLObject aParser( sDataSource );
+ if ( INET_PROT_FILE == aParser.GetProtocol() )
+ // set the initial directory only for file-URLs. Everything else
+ // is considered to be potentially expensive
+ // 106126 - 2002/12/10 - fs@openoffice.org
+ aFileDlg.SetDisplayDirectory( sDataSource );
+
+ const String s_sDatabaseType = String::CreateFromAscii("StarOffice XML (Base)");
+ const SfxFilter* pFilter = SfxFilter::GetFilterByName( s_sDatabaseType);
+ OSL_ENSURE(pFilter,"Filter: StarOffice XML (Base) could not be found!");
+ if ( pFilter )
+ {
+ aFileDlg.SetCurrentFilter(pFilter->GetUIName());
+ //aFileDlg.AddFilter(pFilter->GetFilterName(),pFilter->GetDefaultExtension());
+ }
+
+ _rClearBeforeDialog.clear();
+ bool bSuccess = ( 0 == aFileDlg.Execute() );
+ if ( bSuccess )
+ _out_rNewValue <<= (::rtl::OUString)aFileDlg.GetPath();
+ return bSuccess;
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_dialogColorChooser_throw( sal_Int32 _nColorPropertyId, Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
+ {
+ sal_Int32 nColor = 0;
+ OSL_VERIFY( impl_getPropertyValue_throw( impl_getPropertyNameFromId_nothrow( _nColorPropertyId ) ) >>= nColor );
+ ::Color aColor( nColor );
+ SvColorDialog aColorDlg( impl_getDefaultDialogParent_nothrow() );
+ aColorDlg.SetColor( aColor );
+
+ _rClearBeforeDialog.clear();
+ if ( !aColorDlg.Execute() )
+ return false;
+
+ aColor = aColorDlg.GetColor();
+ nColor = aColor.GetColor();
+ _out_rNewValue <<= (sal_Int32)nColor;
+ return true;
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_dialogChooseLabelControl_nothrow( Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
+ {
+ OSelectLabelDialog dlgSelectLabel( impl_getDefaultDialogParent_nothrow(), m_xComponent );
+ _rClearBeforeDialog.clear();
+ bool bSuccess = ( RET_OK == dlgSelectLabel.Execute() );
+ if ( bSuccess )
+ _out_rNewValue <<= dlgSelectLabel.GetSelected();
+ return bSuccess;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XControlContainer > FormComponentPropertyHandler::impl_getContextControlContainer_nothrow() const
+ {
+ Reference< XControlContainer > xControlContext(
+ m_aContext.getContextValueByAsciiName( "ControlContext" ),
+ UNO_QUERY );
+ return xControlContext;
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_dialogChangeTabOrder_nothrow( ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
+ {
+ OSL_PRECOND( impl_getContextControlContainer_nothrow().is(), "FormComponentPropertyHandler::impl_dialogChangeTabOrder_nothrow: invalid control context!" );
+
+ Reference< XTabControllerModel > xTabControllerModel( impl_getRowSet_nothrow(), UNO_QUERY );
+ TabOrderDialog aDialog(
+ impl_getDefaultDialogParent_nothrow(),
+ xTabControllerModel,
+ impl_getContextControlContainer_nothrow(),
+ m_aContext.getLegacyServiceFactory()
+ );
+ _rClearBeforeDialog.clear();
+ return ( RET_OK == aDialog.Execute() );
+ }
+
+ //------------------------------------------------------------------------
+ namespace
+ {
+ //--------------------------------------------------------------------
+ //- ISQLCommandPropertyUI
+ //--------------------------------------------------------------------
+ class ISQLCommandPropertyUI : public ISQLCommandAdapter
+ {
+ public:
+ /** returns the empty-string-terminated list of names of properties
+ whose UI is to be disabled while the SQL command property is
+ being edited.
+ */
+ virtual ::rtl::OUString* getPropertiesToDisable() = 0;
+ };
+
+ //--------------------------------------------------------------------
+ //- SQLCommandPropertyUI
+ //--------------------------------------------------------------------
+ class SQLCommandPropertyUI : public ISQLCommandPropertyUI
+ {
+ protected:
+ SQLCommandPropertyUI( const Reference< XPropertySet >& _rxObject )
+ :m_xObject( _rxObject )
+ {
+ if ( !m_xObject.is() )
+ throw NullPointerException();
+ }
+
+ virtual oslInterlockedCount SAL_CALL acquire()
+ {
+ return osl_incrementInterlockedCount( &m_refCount );
+ }
+
+ virtual oslInterlockedCount SAL_CALL release()
+ {
+ if ( 0 == osl_decrementInterlockedCount( &m_refCount ) )
+ {
+ delete this;
+ return 0;
+ }
+ return m_refCount;
+ }
+
+ protected:
+ Reference< XPropertySet > m_xObject;
+
+ private:
+ oslInterlockedCount m_refCount;
+ };
+
+ //--------------------------------------------------------------------
+ //- FormSQLCommandUI - declaration
+ //--------------------------------------------------------------------
+ class FormSQLCommandUI : public SQLCommandPropertyUI
+ {
+ public:
+ FormSQLCommandUI( const Reference< XPropertySet >& _rxForm );
+
+ // ISQLCommandAdapter
+ virtual ::rtl::OUString getSQLCommand() const;
+ virtual sal_Bool getEscapeProcessing() const;
+ virtual void setSQLCommand( const ::rtl::OUString& _rCommand ) const;
+ virtual void setEscapeProcessing( const sal_Bool _bEscapeProcessing ) const;
+
+ // ISQLCommandPropertyUI
+ virtual ::rtl::OUString* getPropertiesToDisable();
+ };
+
+ //--------------------------------------------------------------------
+ //- FormSQLCommandUI - implementation
+ //--------------------------------------------------------------------
+ //....................................................................
+ FormSQLCommandUI::FormSQLCommandUI( const Reference< XPropertySet >& _rxForm )
+ :SQLCommandPropertyUI( _rxForm )
+ {
+ }
+
+ //....................................................................
+ ::rtl::OUString FormSQLCommandUI::getSQLCommand() const
+ {
+ ::rtl::OUString sCommand;
+ OSL_VERIFY( m_xObject->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand );
+ return sCommand;
+ }
+
+ //....................................................................
+ sal_Bool FormSQLCommandUI::getEscapeProcessing() const
+ {
+ sal_Bool bEscapeProcessing( sal_False );
+ OSL_VERIFY( m_xObject->getPropertyValue( PROPERTY_ESCAPE_PROCESSING ) >>= bEscapeProcessing );
+ return bEscapeProcessing;
+ }
+
+ //....................................................................
+ void FormSQLCommandUI::setSQLCommand( const ::rtl::OUString& _rCommand ) const
+ {
+ m_xObject->setPropertyValue( PROPERTY_COMMAND, makeAny( _rCommand ) );
+ }
+
+ //....................................................................
+ void FormSQLCommandUI::setEscapeProcessing( const sal_Bool _bEscapeProcessing ) const
+ {
+ m_xObject->setPropertyValue( PROPERTY_ESCAPE_PROCESSING, makeAny( _bEscapeProcessing ) );
+ }
+
+ //....................................................................
+ ::rtl::OUString* FormSQLCommandUI::getPropertiesToDisable()
+ {
+ static ::rtl::OUString s_aCommandProps[] = {
+ PROPERTY_DATASOURCE,
+ PROPERTY_COMMAND,
+ PROPERTY_COMMANDTYPE,
+ PROPERTY_ESCAPE_PROCESSING,
+ ::rtl::OUString()
+ };
+ return s_aCommandProps;
+ }
+ //--------------------------------------------------------------------
+ //- ValueListCommandUI - declaration
+ //--------------------------------------------------------------------
+ class ValueListCommandUI : public SQLCommandPropertyUI
+ {
+ public:
+ ValueListCommandUI( const Reference< XPropertySet >& _rxListOrCombo );
+
+ // ISQLCommandAdapter
+ virtual ::rtl::OUString getSQLCommand() const;
+ virtual sal_Bool getEscapeProcessing() const;
+ virtual void setSQLCommand( const ::rtl::OUString& _rCommand ) const;
+ virtual void setEscapeProcessing( const sal_Bool _bEscapeProcessing ) const;
+
+ // ISQLCommandPropertyUI
+ virtual ::rtl::OUString* getPropertiesToDisable();
+ private:
+ mutable bool m_bPropertyValueIsList;
+ };
+
+ //--------------------------------------------------------------------
+ //- ValueListCommandUI - implementation
+ //--------------------------------------------------------------------
+ //....................................................................
+ ValueListCommandUI::ValueListCommandUI( const Reference< XPropertySet >& _rxListOrCombo )
+ :SQLCommandPropertyUI( _rxListOrCombo )
+ ,m_bPropertyValueIsList( false )
+ {
+ }
+
+ //....................................................................
+ ::rtl::OUString ValueListCommandUI::getSQLCommand() const
+ {
+ ::rtl::OUString sValue;
+ m_bPropertyValueIsList = false;
+
+ // for combo boxes, the property is a mere string
+ Any aValue( m_xObject->getPropertyValue( PROPERTY_LISTSOURCE ) );
+ if ( aValue >>= sValue )
+ return sValue;
+
+ Sequence< ::rtl::OUString > aValueList;
+ if ( aValue >>= aValueList )
+ {
+ m_bPropertyValueIsList = true;
+ if ( aValueList.getLength() )
+ sValue = aValueList[0];
+ return sValue;
+ }
+
+ OSL_ENSURE( false, "ValueListCommandUI::getSQLCommand: unexpected property type!" );
+ return sValue;
+ }
+
+ //....................................................................
+ sal_Bool ValueListCommandUI::getEscapeProcessing() const
+ {
+ enum ListSourceType eType( ListSourceType_SQL );
+ OSL_VERIFY( m_xObject->getPropertyValue( PROPERTY_LISTSOURCETYPE ) >>= eType );
+ OSL_ENSURE( ( eType == ListSourceType_SQL ) || ( eType == ListSourceType_SQLPASSTHROUGH ),
+ "ValueListCommandUI::getEscapeProcessing: unexpected list source type!" );
+ return ( eType == ListSourceType_SQL );
+ }
+
+ //....................................................................
+ void ValueListCommandUI::setSQLCommand( const ::rtl::OUString& _rCommand ) const
+ {
+ Any aValue;
+ if ( m_bPropertyValueIsList )
+ aValue <<= Sequence< ::rtl::OUString >( &_rCommand, 1 );
+ else
+ aValue <<= _rCommand;
+ m_xObject->setPropertyValue( PROPERTY_LISTSOURCE, aValue );
+ }
+
+ //....................................................................
+ void ValueListCommandUI::setEscapeProcessing( const sal_Bool _bEscapeProcessing ) const
+ {
+ m_xObject->setPropertyValue( PROPERTY_LISTSOURCETYPE, makeAny(
+ _bEscapeProcessing ? ListSourceType_SQL : ListSourceType_SQLPASSTHROUGH ) );
+ }
+
+ //....................................................................
+ ::rtl::OUString* ValueListCommandUI::getPropertiesToDisable()
+ {
+ static ::rtl::OUString s_aListSourceProps[] = {
+ PROPERTY_LISTSOURCETYPE,
+ PROPERTY_LISTSOURCE,
+ ::rtl::OUString()
+ };
+ return s_aListSourceProps;
+ }
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_doDesignSQLCommand_nothrow( const Reference< XObjectInspectorUI >& _rxInspectorUI, PropertyId _nDesignForProperty )
+ {
+ try
+ {
+ if ( m_xCommandDesigner.is() )
+ {
+ if ( m_xCommandDesigner->isActive() )
+ {
+ m_xCommandDesigner->raise();
+ return true;
+ }
+ m_xCommandDesigner->dispose();
+ m_xCommandDesigner.set( NULL );
+ }
+
+ if ( !impl_ensureRowsetConnection_nothrow() )
+ return false;
+
+ Reference< XPropertySet > xComponentProperties( m_xComponent, UNO_QUERY_THROW );
+
+ ::rtl::Reference< ISQLCommandPropertyUI > xCommandUI;
+ switch ( _nDesignForProperty )
+ {
+ case PROPERTY_ID_COMMAND:
+ xCommandUI = new FormSQLCommandUI( xComponentProperties );
+ break;
+ case PROPERTY_ID_LISTSOURCE:
+ xCommandUI = new ValueListCommandUI( xComponentProperties );
+ break;
+ default:
+ OSL_ENSURE( false, "FormComponentPropertyHandler::OnDesignerClosed: invalid property id!" );
+ return false;
+ }
+
+ m_xCommandDesigner.set( new SQLCommandDesigner( m_aContext.getUNOContext(), xCommandUI.get(), m_xRowSetConnection, LINK( this, FormComponentPropertyHandler, OnDesignerClosed ) ) );
+
+ DBG_ASSERT( _rxInspectorUI.is(), "FormComponentPropertyHandler::OnDesignerClosed: no access to the property browser ui!" );
+ if ( m_xCommandDesigner->isActive() && _rxInspectorUI.is() )
+ {
+ m_xBrowserUI = _rxInspectorUI;
+ // disable everything which would affect this property
+ const ::rtl::OUString* pToDisable = xCommandUI->getPropertiesToDisable();
+ while ( pToDisable->getLength() )
+ {
+ m_xBrowserUI->enablePropertyUIElements( *pToDisable++, PropertyLineElement::All, sal_False );
+ }
+
+ // but enable the browse button for the property itself - so it can be used to raise the query designer
+ ::rtl::OUString sPropertyName( impl_getPropertyNameFromId_nothrow( _nDesignForProperty ) );
+ m_xBrowserUI->enablePropertyUIElements( sPropertyName, PropertyLineElement::PrimaryButton, sal_True );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return m_xCommandDesigner.is();
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( FormComponentPropertyHandler, OnDesignerClosed, void*, /*NOTINTERESTEDIN*/ )
+ {
+ OSL_ENSURE( m_xBrowserUI.is() && m_xCommandDesigner.is(), "FormComponentPropertyHandler::OnDesignerClosed: too many NULLs!" );
+ if ( m_xBrowserUI.is() && m_xCommandDesigner.is() )
+ {
+ try
+ {
+ ::rtl::Reference< ISQLCommandPropertyUI > xCommandUI(
+ dynamic_cast< ISQLCommandPropertyUI* >( m_xCommandDesigner->getPropertyAdapter().get() ) );
+ if ( !xCommandUI.is() )
+ throw NullPointerException();
+
+ const ::rtl::OUString* pToEnable = xCommandUI->getPropertiesToDisable();
+ while ( pToEnable->getLength() )
+ {
+ m_xBrowserUI->enablePropertyUIElements( *pToEnable++, PropertyLineElement::All, sal_True );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_hasValidDataSourceSignature_nothrow( const Reference< XPropertySet >& _xFormProperties, bool _bAllowEmptyDataSourceName ) SAL_THROW(())
+ {
+ bool bHas = false;
+ if ( _xFormProperties.is() )
+ {
+ try
+ {
+ ::rtl::OUString sPropertyValue;
+ // first, we need the name of an existent data source
+ if ( _xFormProperties->getPropertySetInfo()->hasPropertyByName(PROPERTY_DATASOURCE) )
+ _xFormProperties->getPropertyValue( PROPERTY_DATASOURCE ) >>= sPropertyValue;
+ bHas = ( sPropertyValue.getLength() != 0 ) || _bAllowEmptyDataSourceName;
+
+ // then, the command should not be empty
+ if ( bHas )
+ {
+ if ( _xFormProperties->getPropertySetInfo()->hasPropertyByName(PROPERTY_COMMAND) )
+ _xFormProperties->getPropertyValue( PROPERTY_COMMAND ) >>= sPropertyValue;
+ bHas = ( sPropertyValue.getLength() != 0 );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( false, "FormComponentPropertyHandler::impl_hasValidDataSourceSignature_nothrow: caught an exception!" );
+ }
+ }
+ return bHas;
+ }
+ //------------------------------------------------------------------------
+ ::rtl::OUString FormComponentPropertyHandler::impl_getDocumentURL_nothrow() const
+ {
+ ::rtl::OUString sURL;
+ try
+ {
+ Reference< XModel > xDocument( impl_getContextDocument_nothrow() );
+ if ( xDocument.is() )
+ sURL = xDocument->getURL();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return sURL;
+ }
+ // -------------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper* FormComponentPropertyHandler::createArrayHelper( ) const
+ {
+ uno::Sequence< beans::Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+
+ }
+ // -------------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper & FormComponentPropertyHandler::getInfoHelper()
+ {
+ return *const_cast<FormComponentPropertyHandler*>(this)->getArrayHelper();
+ }
+ // -----------------------------------------------------------------------------
+ uno::Reference< beans::XPropertySetInfo > SAL_CALL FormComponentPropertyHandler::getPropertySetInfo( ) throw(uno::RuntimeException)
+ {
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
diff --git a/extensions/source/propctrlr/formcomponenthandler.hxx b/extensions/source/propctrlr/formcomponenthandler.hxx
new file mode 100644
index 000000000000..01f56bd7ac0d
--- /dev/null
+++ b/extensions/source/propctrlr/formcomponenthandler.hxx
@@ -0,0 +1,479 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_FORMCOMPONENTHANDLER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_FORMCOMPONENTHANDLER_HXX
+
+#include "propertyhandler.hxx"
+#include "sqlcommanddesign.hxx"
+#include "pcrcommon.hxx"
+#include <comphelper/uno3.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/propertycontainer.hxx>
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/form/XForm.hpp>
+/** === end UNO includes === **/
+#include <tools/fldunit.hxx>
+#include <vcl/waitobj.hxx>
+#include <connectivity/dbtools.hxx>
+
+#include <set>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= ComponentClassification
+ //====================================================================
+ enum ComponentClassification
+ {
+ eFormControl,
+ eDialogControl,
+ eUnknown
+ };
+
+ //====================================================================
+ //= FormComponentPropertyHandler
+ //====================================================================
+ class FormComponentPropertyHandler;
+ typedef HandlerComponentBase< FormComponentPropertyHandler > FormComponentPropertyHandler_Base;
+ typedef ::comphelper::OPropertyArrayUsageHelper<FormComponentPropertyHandler> FormComponentPropertyHandler_PROP;
+ /** default ->XPropertyHandler for all form components.
+ */
+ class FormComponentPropertyHandler : public FormComponentPropertyHandler_Base,
+ public ::comphelper::OPropertyContainer,
+ public FormComponentPropertyHandler_PROP
+ {
+ private:
+ /// access to property states
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState > m_xPropertyState;
+ /// the parent of our component
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xObjectParent;
+
+ /// the database connection. Owned by us if and only if we created it ourself.
+ mutable ::dbtools::SharedConnection m_xRowSetConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > m_xRowSet;
+ /** helper component encapsulating the handling for the QueryDesign component for
+ interactively designing an SQL command
+ */
+ ::rtl::Reference< SQLCommandDesigner > m_xCommandDesigner;
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI > m_xBrowserUI;
+
+ /// the string indicating a "default" (VOID) value in list-like controls
+ ::rtl::OUString m_sDefaultValueString;
+ /// all properties to whose control's we added ->m_sDefaultValueString
+ ::std::set< ::rtl::OUString > m_aPropertiesWithDefListEntry;
+ /// type of our component
+ ComponentClassification m_eComponentClass;
+ /// is our component a (database) sub form?
+ bool m_bComponentIsSubForm : 1;
+ /// our component has a "ListSource" property
+ bool m_bHaveListSource : 1;
+ /// our component has a "Command" property
+ bool m_bHaveCommand : 1;
+ /// the class id of the component - if appliable
+ sal_Int16 m_nClassId;
+
+ public:
+ FormComponentPropertyHandler(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
+ );
+
+ DECLARE_XINTERFACE( )
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+
+ static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ ~FormComponentPropertyHandler();
+
+ protected:
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+ // XPropertyHandler overridables
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rControlValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToControlValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rPropertyValue, const ::com::sun::star::uno::Type& _rControlValueType ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupersededProperties() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getActuatingProperties() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::LineDescriptor SAL_CALL describePropertyLine( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::InteractiveSelectionResult
+ SAL_CALL onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, ::com::sun::star::uno::Any& _rData, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL suspend( sal_Bool _bSuspend ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XComponent
+ virtual void SAL_CALL disposing();
+
+ // PropertyHandler
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
+ SAL_CALL doDescribeSupportedProperties() const;
+ virtual void onNewComponent();
+
+ private:
+ /** initializes some (cached) meta data about the component
+ @throws RuntimeException
+ if a serious error occurs, for instance if the component does not provide an XPropertySetInfo instance
+ */
+ void impl_initComponentMetaData_throw();
+
+ /** classifies our component, in case it's a control model, by ClassId
+
+ Note that UNO dialog controls are also classified, though they don't have the ClassId property
+ */
+ void impl_classifyControlModel_throw();
+
+ /** const-version of ->getPropertyValue
+ */
+ ::com::sun::star::uno::Any impl_getPropertyValue_throw( const ::rtl::OUString& _rPropertyName ) const;
+
+ // some property values are faked, and not used in the way they're provided by our component
+ void impl_normalizePropertyValue_nothrow( ::com::sun::star::uno::Any& _rValue, PropertyId _nPropId ) const;
+
+ /** determines whether we should exclude a given property from our "supported properties"
+ */
+ bool impl_shouldExcludeProperty_nothrow( const ::com::sun::star::beans::Property& _rProperty ) const;
+
+ /** initializes the list of field names, if we're handling a control which supports the
+ DataField property
+ */
+ void impl_initFieldList_nothrow( ::std::vector< ::rtl::OUString >& rFieldNames ) const;
+
+ /** obtaines the RowSet to which our component belongs
+
+ If the component is a RowSet itself, it's returned directly. Else, the parent
+ is examined for the XRowSet interface. If the parent is no XRowSet, then
+ a check is made whether our component is a grid control column, and if so,
+ the parent of the grid control is examied for the XRowSet interace.
+
+ Normally, at least one of those methods should succeed.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > impl_getRowSet_throw( ) const;
+
+ /** nothrow-version of ->impl_getRowSet_throw
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > impl_getRowSet_nothrow( ) const;
+
+ /** connects the row set belonging to our introspected data aware form component,
+ and remembers the connection in ->m_xRowSetConnection.
+
+ If the row set already is connected, ->m_xRowSetConnection will be set, too, but
+ not take the ownership of the connection.
+
+ If ->m_xRowSetConnection is already set, nothing happens, so if you want to
+ force creation of a connection, you need to clear ->m_xRowSetConnection.
+ */
+ bool impl_ensureRowsetConnection_nothrow() const;
+
+ /** clears ->m_xRowSetConnection
+ */
+ void impl_clearRowsetConnection_nothrow();
+
+ /** fills an ->LineDescriptor with information to represent a cursor source
+ of our form - that is, a table, a query, or an SQL statement.
+
+ As an example, if our form has currently a CommandType of TABLE, then the
+ value list in the LineDescriptor will contain a list of all tables
+ of the data source which the form is bound to.
+
+ @seealso impl_fillTableNames_throw
+ @seealso impl_fillQueryNames_throw
+ */
+ void impl_describeCursorSource_nothrow(
+ ::com::sun::star::inspection::LineDescriptor& _out_rProperty,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory
+ ) const;
+
+ /** describes the UI for selecting a table name
+
+ @precond
+ m_xRowSetConnection is not <NULL/>
+ */
+ void impl_fillTableNames_throw( ::std::vector< ::rtl::OUString >& _out_rNames ) const;
+
+ /** describes the UI for selecting a query name
+
+ @precond
+ m_xRowSetConnection is not <NULL/>
+ */
+ void impl_fillQueryNames_throw( ::std::vector< ::rtl::OUString >& _out_rNames ) const;
+
+ /** describes the UI for selecting a query name
+
+ @precond
+ m_xRowSetConnection is not <NULL/>
+ */
+ void impl_fillQueryNames_throw( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xQueryNames
+ ,::std::vector< ::rtl::OUString >& _out_rNames
+ ,const ::rtl::OUString& _sName = ::rtl::OUString() ) const;
+
+ /** describes the UI for selecting a ListSource (for list-like form controls)
+ @precond
+ ->m_xRowSetConnection is not <NULL/>
+ @precond
+ ->m_xComponent is not <NULL/>
+ */
+ void impl_describeListSourceUI_throw(
+ ::com::sun::star::inspection::LineDescriptor& _out_rDescriptor,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory
+ ) const;
+
+ /** displays a datbase-related error to the user
+ */
+ void impl_displaySQLError_nothrow( const ::dbtools::SQLExceptionInfo& _rErrorDescriptor ) const;
+
+ /** let's the user chose a selection of entries from a string list, and stores this
+ selection in the given property
+ @return
+ <TRUE/> if and only if the user successfully changed the property
+ */
+ bool impl_dialogListSelection_nothrow( const ::rtl::OUString& _rProperty, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
+
+ /** executes a dialog for chosing a filter or sort criterion for a database form
+ @param _bFilter
+ <TRUE/> if the Filter property should be used, <FALSE/> if it's the Order
+ property
+ @param _out_rSelectedClause
+ the filter or order clause as chosen by the user
+ @precond
+ we're really inspecting a database form (well, a RowSet at least)
+ @return
+ <TRUE/> if and only if the user successfully chose a clause
+ */
+ bool impl_dialogFilterOrSort_nothrow( bool _bFilter, ::rtl::OUString& _out_rSelectedClause, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
+
+ /** executes a dialog which allows the user to chose the columns linking
+ a sub to a master form, and sets the respective MasterFields / SlaveFields
+ properties at the form.
+ @precond
+ we're inspecting (sub) database form
+ @return
+ <TRUE/> if and only if the user successfully eneter master and slave fields
+ */
+ bool impl_dialogLinkedFormFields_nothrow( ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
+
+ /** executes a dialog which allows the user to modify the FormatKey
+ property of our component, by chosing a (number) format.
+ @precond
+ Our component actually has a FormatKey property.
+ @param _out_rNewValue
+ the new property value, if the user chose a new formatting
+ @return
+ <TRUE/> if and only if a new formatting has been chosen by the user.
+ In this case, ->_out_rNewValue is filled with the new property value
+ */
+ bool impl_dialogFormatting_nothrow( ::com::sun::star::uno::Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
+
+ /** executes a dialog which allows to the user to change the ImageURL property
+ of our component by browsing for an image file.
+ @precond
+ our component actually has a ImageURL property
+ @param _out_rNewValue
+ the new property value, if the user chose a new image url
+ @return
+ <TRUE/> if and only if a new image URL has been chosen by the user.
+ In this case, ->_out_rNewValue is filled with the new property value
+ */
+ bool impl_browseForImage_nothrow( ::com::sun::star::uno::Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
+
+ /** executes a dialog which allows the user to change the TargetURL property of
+ our component
+ @precond
+ our component actually has a TargetURL property
+ @param _out_rNewValue
+ the new property value, if the user chose a new TargetURL
+ @return
+ <TRUE/> if and only if a new TargetURL has been chosen by the user.
+ In this case, ->_out_rNewValue is filled with the new property value
+ */
+ bool impl_browseForTargetURL_nothrow( ::com::sun::star::uno::Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
+
+ /** executes a dialog which allows the user to change the font, plus related properties,
+ of our component
+ @precond
+ our component actually has a Font property
+ @param _out_rNewValue
+ a value desribing the new font, as <code>Sequence&lt; NamedValue &gt;</code>
+ @return
+ <TRUE/> if and only if the user successfully changed the font of our component
+ */
+ bool impl_executeFontDialog_nothrow( ::com::sun::star::uno::Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
+
+ /** allows the user browsing for a database document
+ @precond
+ our component actually has a DataSource property
+ @param _out_rNewValue
+ the new property value, if the user chose a new DataSource
+ @return
+ <TRUE/> if and only if a new DataSource has been chosen by the user.
+ In this case, ->_out_rNewValue is filled with the new property value
+ */
+ bool impl_browseForDatabaseDocument_throw( ::com::sun::star::uno::Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
+
+ /** raises a dialog which allows the user to choose a color
+ @param _nColorPropertyId
+ the ID of the color property
+ @param _out_rNewValue
+ the chosen color value
+ @return
+ <TRUE/> if and only if a color was chosen by the user
+ */
+ bool impl_dialogColorChooser_throw( sal_Int32 _nColorPropertyId, ::com::sun::star::uno::Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
+
+ /** raises a dialog which allows the user to choose a label control for our component
+ @param _out_rNewValue
+ the chosen label control, if any
+ @return
+ <TRUE/> if and only if a label control was chosen by the user
+ */
+ bool impl_dialogChooseLabelControl_nothrow( ::com::sun::star::uno::Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
+
+ /** raises a dialog which lets the user chose the tab order of controls of a form
+ @precond
+ we have a view control container in which our controls live
+ @return
+ <TRUE/> if and only if the user successfully changed the tab order
+ @seealso impl_getContextControlContainer_nothrow
+ */
+ bool impl_dialogChangeTabOrder_nothrow( ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
+
+ /** retrieves the context for controls, whose model(s) we're inspecting
+
+ If we're inspecting a control model, this is usually part of a set of controls
+ and control models, where the controls live in a certain context (a ->XControlContainer).
+ If we know this context, we can enable additional special functionality.
+
+ The ->XComponentContext in which we were created is examined for a value
+ named "ControlContext", and this value is returned.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >
+ impl_getContextControlContainer_nothrow() const;
+
+ /** opens a query design window for interactively designing the SQL command of a
+ database form
+ @param _rxUIUpdate
+ access to the property browser UI
+ @param _nDesignForProperty
+ the ID for the property for which the designer is opened
+ @return
+ <TRUE/> if the window was successfully opened, or was previously open,
+ <FALSE/> otherwise
+ */
+ bool impl_doDesignSQLCommand_nothrow(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI,
+ PropertyId _nDesignForProperty
+ );
+
+ /** updates a property (UI) whose state depends on more than one other property
+
+ ->actuatingPropertyChanged is called for certain properties in whose changes
+ we expressed interes (->getActuatingProperty). Now such a property change can
+ result in simple UI updates, for instance another property being enabled or disabled.
+
+ However, it can also result in a more complex change: The current (UI) state might
+ depend on the value of more than one other property. Those dependent properties (their
+ UI, more precisly) are updated in this method.
+
+ @param _nPropid
+ the ->PropertyId of the dependent property whose UI state is to be updated
+
+ @param _rxInspectorUI
+ provides access to the property browser UI. Must not be <NULL/>.
+ */
+ void impl_updateDependentProperty_nothrow( PropertyId _nPropId, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ) const;
+
+ /** determines whether the given form has a valid data source signature.
+
+ Valid here means that the DataSource property denotes an existing data source, and the
+ Command property is not empty. No check is made whether the value of the Command property
+ denotes an existent object, since this would be way too expensive.
+
+ @param _xFormProperties
+ the form to check. Must not be <NULL/>.
+ @param _bAllowEmptyDataSourceName
+ determine whether an empty data source name is allowed (<TRUE/>), and should not
+ lead to rejection
+ */
+ static bool impl_hasValidDataSourceSignature_nothrow(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xFormProperties,
+ bool _bAllowEmptyDataSourceName );
+
+ /** returns the URL of our context document
+ @return
+ */
+ ::rtl::OUString impl_getDocumentURL_nothrow() const;
+
+ private:
+ DECL_LINK( OnDesignerClosed, void* );
+
+ private:
+ FormComponentPropertyHandler(); // never implemented
+ FormComponentPropertyHandler( const FormComponentPropertyHandler& ); // never implemented
+ FormComponentPropertyHandler& operator=( const FormComponentPropertyHandler& ); // never implemented
+
+ private:
+ using ::comphelper::OPropertyContainer::addPropertyChangeListener;
+ using ::comphelper::OPropertyContainer::removePropertyChangeListener;
+ };
+
+ //====================================================================
+ //= WaitCursor
+ //====================================================================
+ /** wrapper around a ->WaitObject which can cope with a NULL window
+ */
+ class WaitCursor
+ {
+ private:
+ ::std::auto_ptr< WaitObject > m_aWaitObject;
+
+ public:
+ WaitCursor( Window* _pWindow )
+ {
+ if ( _pWindow )
+ m_aWaitObject.reset( new WaitObject( _pWindow ) );
+ }
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_FORMCOMPONENTHANDLER_HXX
+
diff --git a/extensions/source/propctrlr/formcontroller.cxx b/extensions/source/propctrlr/formcontroller.cxx
new file mode 100644
index 000000000000..1e894452edbe
--- /dev/null
+++ b/extensions/source/propctrlr/formcontroller.cxx
@@ -0,0 +1,299 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "formcontroller.hxx"
+#include "pcrcommon.hxx"
+#include "formstrings.hxx"
+#include "defaultforminspection.hxx"
+#ifndef _EXTENSIONS_FORMCTRLR_FORMHELPID_HRC_
+#include "propctrlr.hrc"
+#endif
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/form/XGridColumnFactory.hpp>
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/container/XChild.hpp>
+/** === end UNO includes === **/
+#include <cppuhelper/typeprovider.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_FormController()
+{
+ ::pcr::OAutoRegistration< ::pcr::FormController > aFormControllerRegistration;
+ ::pcr::OAutoRegistration< ::pcr::DialogController > aDialogControllerRegistration;
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::TypeClass_INTERFACE;
+ using ::com::sun::star::uno::TypeClass_STRING;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::inspection::XObjectInspectorModel;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::beans::Property;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::util::VetoException;
+ using ::com::sun::star::beans::PropertyVetoException;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::form::XGridColumnFactory;
+ using ::com::sun::star::form::XForm;
+ using ::com::sun::star::container::XChild;
+ using ::com::sun::star::frame::XFrame;
+ using ::com::sun::star::awt::XWindow;
+ /** === end UNO using === **/
+
+ namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
+
+ //====================================================================
+ //= FormController
+ //====================================================================
+ //--------------------------------------------------------------------
+ FormController::FormController( const Reference< XComponentContext >& _rxContext, ServiceDescriptor _aServiceDescriptor,
+ bool _bUseFormFormComponentHandlers )
+ :OPropertyBrowserController( _rxContext )
+ ,FormController_PropertyBase1( m_aBHelper )
+ ,m_aServiceDescriptor( _aServiceDescriptor )
+ {
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ Reference< XObjectInspectorModel > xModel(
+ *(new DefaultFormComponentInspectorModel( _rxContext, _bUseFormFormComponentHandlers )),
+ UNO_QUERY_THROW
+ );
+ setInspectorModel( xModel );
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+
+ //------------------------------------------------------------------------
+ FormController::~FormController()
+ {
+ }
+
+ //------------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XINTERFACE2( FormController, OPropertyBrowserController, FormController_PropertyBase1 )
+
+ //------------------------------------------------------------------------
+ Sequence< Type > SAL_CALL FormController::getTypes( ) throw(RuntimeException)
+ {
+ ::cppu::OTypeCollection aTypes(
+ ::getCppuType( static_cast< Reference< XPropertySet >* >(NULL) ),
+ ::getCppuType( static_cast< Reference< XMultiPropertySet >* >(NULL) ),
+ ::getCppuType( static_cast< Reference< XFastPropertySet >* >(NULL) ),
+ OPropertyBrowserController::getTypes());
+ return aTypes.getTypes();
+ }
+
+ //------------------------------------------------------------------------
+ IMPLEMENT_GET_IMPLEMENTATION_ID( FormController )
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL FormController::getImplementationName( ) throw(RuntimeException)
+ {
+ return m_aServiceDescriptor.GetImplementationName();
+ }
+
+ //------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL FormController::getSupportedServiceNames( ) throw(RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported( m_aServiceDescriptor.GetSupportedServiceNames() );
+ aSupported.realloc( aSupported.getLength() + 1 );
+ aSupported[ aSupported.getLength() - 1 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.inspection.ObjectInspector" ) );
+ return aSupported;
+ }
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString FormController::getImplementationName_static( ) throw(RuntimeException)
+ {
+ return ::rtl::OUString::createFromAscii("org.openoffice.comp.extensions.FormController");
+ }
+
+ //------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > FormController::getSupportedServiceNames_static( ) throw(RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported(1);
+ aSupported[0] = ::rtl::OUString::createFromAscii( "com.sun.star.form.PropertyBrowserController" );
+ return aSupported;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL FormController::Create(const Reference< XComponentContext >& _rxContext )
+ {
+ ServiceDescriptor aService;
+ aService.GetImplementationName = &FormController::getImplementationName_static;
+ aService.GetSupportedServiceNames = &FormController::getSupportedServiceNames_static;
+ return *(new FormController( _rxContext, aService, true ) );
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XPropertySetInfo > SAL_CALL FormController::getPropertySetInfo( ) throw(RuntimeException)
+ {
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+ }
+
+ //------------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper& SAL_CALL FormController::getInfoHelper()
+ {
+ return *getArrayHelper();
+ }
+
+ //------------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper* FormController::createArrayHelper( ) const
+ {
+ Sequence< Property > aProps( 2 );
+ aProps[0] = Property(
+ PROPERTY_CURRENTPAGE,
+ OWN_PROPERTY_ID_CURRENTPAGE,
+ ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ),
+ PropertyAttribute::TRANSIENT
+ );
+ aProps[1] = Property(
+ PROPERTY_INTROSPECTEDOBJECT,
+ OWN_PROPERTY_ID_INTROSPECTEDOBJECT,
+ XPropertySet::static_type(),
+ PropertyAttribute::TRANSIENT | PropertyAttribute::CONSTRAINED
+ );
+ return new ::cppu::OPropertyArrayHelper( aProps );
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool SAL_CALL FormController::convertFastPropertyValue( Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue ) throw (IllegalArgumentException)
+ {
+ switch ( nHandle )
+ {
+ case OWN_PROPERTY_ID_INTROSPECTEDOBJECT:
+ if ( rValue.getValueTypeClass() != TypeClass_INTERFACE )
+ throw IllegalArgumentException();
+ break;
+ case OWN_PROPERTY_ID_CURRENTPAGE:
+ if ( rValue.getValueTypeClass() != TypeClass_STRING )
+ throw IllegalArgumentException();
+ break;
+ }
+
+ getFastPropertyValue( rOldValue, nHandle );
+ rConvertedValue = rValue;
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL FormController::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue) throw (Exception)
+ {
+ switch ( _nHandle )
+ {
+ case OWN_PROPERTY_ID_INTROSPECTEDOBJECT:
+ {
+ Reference< XObjectInspectorModel > xModel( getInspectorModel() );
+ if ( xModel.is() )
+ {
+ try
+ {
+ m_xCurrentInspectee.set( _rValue, UNO_QUERY );
+ Sequence< Reference< XInterface > > aObjects;
+ if ( m_xCurrentInspectee.is() )
+ {
+ aObjects.realloc( 1 );
+ aObjects[0] = m_xCurrentInspectee;
+ }
+
+ Reference< XObjectInspector > xInspector( *this, UNO_QUERY_THROW );
+ xInspector->inspect( aObjects );
+ }
+ catch( const VetoException& e )
+ {
+ throw PropertyVetoException( e.Message, e.Context );
+ }
+ }
+ }
+ break;
+ case OWN_PROPERTY_ID_CURRENTPAGE:
+ restoreViewData( _rValue );
+ break;
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL FormController::getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const
+ {
+ switch ( nHandle )
+ {
+ case OWN_PROPERTY_ID_INTROSPECTEDOBJECT:
+ rValue <<= m_xCurrentInspectee;
+ break;
+
+ case OWN_PROPERTY_ID_CURRENTPAGE:
+ rValue = const_cast< FormController* >( this )->getViewData();
+ break;
+ }
+ }
+
+ //====================================================================
+ //= DialogController
+ //====================================================================
+ //------------------------------------------------------------------------
+ ::rtl::OUString DialogController::getImplementationName_static( ) throw(RuntimeException)
+ {
+ return ::rtl::OUString::createFromAscii("org.openoffice.comp.extensions.DialogController");
+ }
+
+ //------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > DialogController::getSupportedServiceNames_static( ) throw(RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported(1);
+ aSupported[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.PropertyBrowserController" );
+ return aSupported;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL DialogController::Create(const Reference< XComponentContext >& _rxContext)
+ {
+ ServiceDescriptor aService;
+ aService.GetImplementationName = &DialogController::getImplementationName_static;
+ aService.GetSupportedServiceNames = &DialogController::getSupportedServiceNames_static;
+ return *(new FormController( _rxContext, aService, false ) );
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
diff --git a/extensions/source/propctrlr/formcontroller.hxx b/extensions/source/propctrlr/formcontroller.hxx
new file mode 100644
index 000000000000..e62a47586087
--- /dev/null
+++ b/extensions/source/propctrlr/formcontroller.hxx
@@ -0,0 +1,140 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_FORMCONTROLLER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_FORMCONTROLLER_HXX
+
+#include "propcontroller.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+#include <cppuhelper/propshlp.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/uno3.hxx>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= ServiceDescriptor
+ //====================================================================
+ struct ServiceDescriptor
+ {
+ ::rtl::OUString
+ ( *GetImplementationName )( void );
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ ( *GetSupportedServiceNames )( void );
+ };
+
+ //====================================================================
+ //= FormController
+ //====================================================================
+ class FormController;
+ typedef ::cppu::OPropertySetHelper FormController_PropertyBase1;
+ typedef ::comphelper::OPropertyArrayUsageHelper< FormController > FormController_PropertyBase2;
+
+ /** Legacy implementation of com.sun.star.form.PropertyBrowserController
+
+ Nowadays only a wrapper around an ObjectInspector using a
+ DefaultFormComponentInspectorModel.
+ */
+ class FormController :public OPropertyBrowserController
+ ,public FormController_PropertyBase1
+ ,public FormController_PropertyBase2
+ {
+ private:
+ ServiceDescriptor m_aServiceDescriptor;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xCurrentInspectee;
+ bool m_bUseFormComponentHandlers;
+ public:
+ FormController(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
+ ServiceDescriptor _aServiceDescriptor,
+ bool _bUseFormFormComponentHandlers
+ );
+
+ // XServiceInfo - static versions
+ static ::rtl::OUString getImplementationName_static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+ Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
+
+ protected:
+ ~FormController();
+
+ DECLARE_XINTERFACE()
+ DECLARE_XTYPEPROVIDER()
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XPropertySet and friends
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(
+ ::com::sun::star::uno::Any & rConvertedValue, ::com::sun::star::uno::Any & rOldValue, sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue
+ ) throw (::com::sun::star::lang::IllegalArgumentException);
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue
+ ) throw (::com::sun::star::uno::Exception);
+ virtual void SAL_CALL getFastPropertyValue(
+ ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle
+ ) const;
+ private:
+ using FormController_PropertyBase1::getFastPropertyValue;
+ };
+
+ //====================================================================
+ //= DialogController
+ //====================================================================
+ /** Legacy implementation of com.sun.star.awt.PropertyBrowserController
+ */
+ class DialogController
+ {
+ public:
+ // XServiceInfo - static versions
+ static ::rtl::OUString getImplementationName_static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+ Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
+
+ private:
+ DialogController(); // never implemented
+ DialogController( const DialogController& ); // never implemented
+ DialogController& operator=( const DialogController& ); // never implemented
+ };
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_FORMCONTROLLER_HXX
+
diff --git a/extensions/source/propctrlr/formgeometryhandler.cxx b/extensions/source/propctrlr/formgeometryhandler.cxx
new file mode 100644
index 000000000000..31a2b9315238
--- /dev/null
+++ b/extensions/source/propctrlr/formgeometryhandler.cxx
@@ -0,0 +1,826 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "propertyhandler.hxx"
+#include "formmetadata.hxx"
+#include "formstrings.hxx"
+#include "handlerhelper.hxx"
+#include "cellbindinghelper.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+#include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/drawing/XControlShape.hpp>
+#include <com/sun/star/container/XMap.hpp>
+#include <com/sun/star/inspection/XNumericControl.hpp>
+#include <com/sun/star/util/MeasureUnit.hpp>
+#include <com/sun/star/text/TextContentAnchorType.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/table/XColumnRowRange.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/form/XGridColumnFactory.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/interfacecontainer.hxx>
+#include <comphelper/componentbase.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::beans::UnknownPropertyException;
+ using ::com::sun::star::beans::Property;
+ using ::com::sun::star::awt::XControlModel;
+ using ::com::sun::star::drawing::XControlShape;
+ using ::com::sun::star::container::XMap;
+ using ::com::sun::star::inspection::LineDescriptor;
+ using ::com::sun::star::inspection::XPropertyControlFactory;
+ using ::com::sun::star::lang::NullPointerException;
+ using ::com::sun::star::beans::Optional;
+ using ::com::sun::star::inspection::XNumericControl;
+ using ::com::sun::star::drawing::XShape;
+ using ::com::sun::star::beans::PropertyChangeEvent;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::beans::XPropertyChangeListener;
+ using ::com::sun::star::text::TextContentAnchorType;
+ using ::com::sun::star::text::TextContentAnchorType_AT_PARAGRAPH;
+ using ::com::sun::star::text::TextContentAnchorType_AS_CHARACTER;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::inspection::XObjectInspectorUI;
+ using ::com::sun::star::lang::XServiceInfo;
+ using ::com::sun::star::sheet::XSpreadsheet;
+ using ::com::sun::star::table::XColumnRowRange;
+ using ::com::sun::star::table::XTableColumns;
+ using ::com::sun::star::table::XTableRows;
+ using ::com::sun::star::table::XCellRange;
+ using ::com::sun::star::container::XIndexAccess;
+ using ::com::sun::star::container::XChild;
+ using ::com::sun::star::form::XGridColumnFactory;
+ /** === end UNO using === **/
+ namespace MeasureUnit = ::com::sun::star::util::MeasureUnit;
+
+ typedef ::com::sun::star::awt::Point AwtPoint;
+ typedef ::com::sun::star::awt::Size AwtSize;
+
+ #define ANCHOR_TO_SHEET 0
+ #define ANCHOR_TO_CELL 1
+
+ //====================================================================
+ //= BroadcastHelperBase
+ //====================================================================
+ class BroadcastHelperBase
+ {
+ protected:
+ BroadcastHelperBase( ::osl::Mutex& _rMutex )
+ :maBHelper( _rMutex )
+ {
+ }
+
+ protected:
+ ::cppu::OBroadcastHelper& getBroadcastHelper() { return maBHelper; }
+
+ private:
+ ::cppu::OBroadcastHelper maBHelper;
+ };
+
+ //====================================================================
+ //= ShapeGeometryChangeNotifier - declaration
+ //====================================================================
+ /** helper class to work around the ...unfortunate implementation of property change broadcasts
+ in the XShape implementation, which broadcasts way too generous and unspecified
+ */
+ typedef ::comphelper::ComponentBase ShapeGeometryChangeNotifier_CBase;
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::beans::XPropertyChangeListener
+ > ShapeGeometryChangeNotifier_IBase;
+
+ class ShapeGeometryChangeNotifier :public BroadcastHelperBase
+ ,public ShapeGeometryChangeNotifier_CBase
+ ,public ShapeGeometryChangeNotifier_IBase
+ {
+ public:
+ ShapeGeometryChangeNotifier( ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rParentMutex, const Reference< XShape >& _shape )
+ :BroadcastHelperBase( _rParentMutex )
+ ,ShapeGeometryChangeNotifier_CBase( BroadcastHelperBase::getBroadcastHelper(), ::comphelper::ComponentBase::NoInitializationNeeded() )
+ ,ShapeGeometryChangeNotifier_IBase()
+ ,m_rParent( _rParent )
+ ,m_aPropertyChangeListeners( _rParentMutex )
+ ,m_xShape( _shape )
+ {
+ ENSURE_OR_THROW( m_xShape.is(), "illegal shape!" );
+ impl_init_nothrow();
+ }
+
+ // property change broadcasting
+ void addPropertyChangeListener( const Reference< XPropertyChangeListener >& _listener )
+ {
+ m_aPropertyChangeListeners.addInterface( _listener );
+ }
+ void removePropertyChangeListener( const Reference< XPropertyChangeListener >& _listener )
+ {
+ m_aPropertyChangeListeners.removeInterface( _listener );
+ }
+
+ // XComponent equivalent
+ void dispose()
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ impl_dispose_nothrow();
+ }
+
+ // XInterface
+ virtual void SAL_CALL acquire( ) throw ()
+ {
+ m_rParent.acquire();
+ }
+
+ virtual void SAL_CALL release( ) throw ()
+ {
+ m_rParent.release();
+ }
+
+ // XPropertyChangeListener
+ virtual void SAL_CALL propertyChange( const PropertyChangeEvent& _event ) throw (RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const EventObject& _event ) throw (RuntimeException);
+
+ protected:
+ virtual ~ShapeGeometryChangeNotifier()
+ {
+ if ( !getBroadcastHelper().bDisposed )
+ {
+ acquire();
+ dispose();
+ }
+ }
+
+ protected:
+ ::cppu::OBroadcastHelper& getBroadcastHelper() { return BroadcastHelperBase::getBroadcastHelper(); }
+
+ private:
+ void impl_init_nothrow();
+ void impl_dispose_nothrow();
+
+ private:
+ ::cppu::OWeakObject& m_rParent;
+ ::cppu::OInterfaceContainerHelper m_aPropertyChangeListeners;
+ Reference< XShape > m_xShape;
+ };
+
+ //====================================================================
+ //= FormGeometryHandler - declaration
+ //====================================================================
+ class FormGeometryHandler;
+ typedef HandlerComponentBase< FormGeometryHandler > FormGeometryHandler_Base;
+ /** a property handler for any virtual string properties
+ */
+ class FormGeometryHandler : public FormGeometryHandler_Base
+ {
+ public:
+ FormGeometryHandler(
+ const Reference< XComponentContext >& _rxContext
+ );
+
+ static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (RuntimeException);
+ static Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (RuntimeException);
+
+ protected:
+ ~FormGeometryHandler();
+
+ protected:
+ // XPropertyHandler overriables
+ virtual Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException);
+ virtual LineDescriptor SAL_CALL describePropertyLine( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual Sequence< ::rtl::OUString > SAL_CALL getActuatingProperties( ) throw (RuntimeException);
+ virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& _rOldValue, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (NullPointerException, RuntimeException);
+
+ // OComponentHandler overridables
+ virtual void SAL_CALL disposing();
+
+ // PropertyHandler overridables
+ virtual Sequence< Property > SAL_CALL doDescribeSupportedProperties() const;
+
+ protected:
+ virtual void onNewComponent();
+
+ private:
+ bool impl_haveTextAnchorType_nothrow() const;
+ bool impl_haveSheetAnchorType_nothrow() const;
+ void impl_setSheetAnchorType_nothrow( const sal_Int32 _nAnchorType ) const;
+
+ private:
+ Reference< XControlShape > m_xAssociatedShape;
+ Reference< XPropertySet > m_xShapeProperties;
+ ::rtl::Reference< ShapeGeometryChangeNotifier > m_xChangeNotifier;
+ };
+
+ //====================================================================
+ //= FormGeometryHandler - implementation
+ //====================================================================
+ DBG_NAME( FormGeometryHandler )
+ //--------------------------------------------------------------------
+ FormGeometryHandler::FormGeometryHandler( const Reference< XComponentContext >& _rxContext )
+ :FormGeometryHandler_Base( _rxContext )
+ {
+ DBG_CTOR( FormGeometryHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ FormGeometryHandler::~FormGeometryHandler( )
+ {
+ if ( !rBHelper.bDisposed )
+ {
+ acquire();
+ dispose();
+ }
+
+ DBG_DTOR( FormGeometryHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ void FormGeometryHandler::onNewComponent()
+ {
+ if ( m_xChangeNotifier.is() )
+ {
+ m_xChangeNotifier->dispose();
+ m_xChangeNotifier.clear();
+ }
+ m_xAssociatedShape.clear();
+ m_xShapeProperties.clear();
+
+ FormGeometryHandler_Base::onNewComponent();
+
+ try
+ {
+ Reference< XControlModel > xControlModel( m_xComponent, UNO_QUERY );
+ if ( xControlModel.is() )
+ {
+ // do not ask the map for shapes for grid control columns ....
+ Reference< XChild > xCompChild( m_xComponent, UNO_QUERY_THROW );
+ Reference< XGridColumnFactory > xCheckGrid( xCompChild->getParent(), UNO_QUERY );
+ if ( !xCheckGrid.is() )
+ {
+ Reference< XMap > xControlMap( m_aContext.getContextValueByAsciiName( "ControlShapeAccess" ), UNO_QUERY_THROW );
+ m_xAssociatedShape.set( xControlMap->get( makeAny( xControlModel ) ), UNO_QUERY_THROW );
+ m_xShapeProperties.set( m_xAssociatedShape, UNO_QUERY_THROW );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( m_xAssociatedShape.is() )
+ m_xChangeNotifier = new ShapeGeometryChangeNotifier( *this, m_aMutex, m_xAssociatedShape.get() );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL FormGeometryHandler::getImplementationName_static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.FormGeometryHandler" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL FormGeometryHandler::getSupportedServiceNames_static( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported( 1 );
+ aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.FormGeometryHandler" ) );
+ return aSupported;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL FormGeometryHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ ENSURE_OR_THROW2( m_xAssociatedShape.is(), "internal error: properties, but no shape!", *this );
+ ENSURE_OR_THROW2( m_xShapeProperties.is(), "internal error: no shape properties!", *this );
+
+ Any aReturn;
+ try
+ {
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_POSITIONX:
+ aReturn <<= m_xAssociatedShape->getPosition().X;
+ break;
+ case PROPERTY_ID_POSITIONY:
+ aReturn <<= m_xAssociatedShape->getPosition().Y;
+ break;
+ case PROPERTY_ID_WIDTH:
+ aReturn <<= m_xAssociatedShape->getSize().Width;
+ break;
+ case PROPERTY_ID_HEIGHT:
+ aReturn <<= m_xAssociatedShape->getSize().Height;
+ break;
+ case PROPERTY_ID_TEXT_ANCHOR_TYPE:
+ aReturn = m_xShapeProperties->getPropertyValue( PROPERTY_ANCHOR_TYPE );
+ OSL_ENSURE( aReturn.hasValue(), "FormGeometryHandler::getPropertyValue: illegal anchor type!" );
+ break;
+ case PROPERTY_ID_SHEET_ANCHOR_TYPE:
+ {
+ Reference< XSpreadsheet > xAnchorSheet( m_xShapeProperties->getPropertyValue( PROPERTY_ANCHOR ), UNO_QUERY );
+ aReturn <<= sal_Int32( xAnchorSheet.is() ? ANCHOR_TO_SHEET : ANCHOR_TO_CELL );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( false, "FormGeometryHandler::getPropertyValue: huh?" );
+ break;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormGeometryHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ ENSURE_OR_THROW2( m_xAssociatedShape.is(), "internal error: properties, but no shape!", *this );
+ ENSURE_OR_THROW2( m_xShapeProperties.is(), "internal error: properties, but no shape!", *this );
+
+ try
+ {
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_POSITIONX:
+ case PROPERTY_ID_POSITIONY:
+ {
+ sal_Int32 nPosition(0);
+ OSL_VERIFY( _rValue >>= nPosition );
+
+ AwtPoint aPos( m_xAssociatedShape->getPosition() );
+ if ( nPropId == PROPERTY_ID_POSITIONX )
+ aPos.X = nPosition;
+ else
+ aPos.Y = nPosition;
+ m_xAssociatedShape->setPosition( aPos );
+ }
+ break;
+
+ case PROPERTY_ID_WIDTH:
+ case PROPERTY_ID_HEIGHT:
+ {
+ sal_Int32 nSize(0);
+ OSL_VERIFY( _rValue >>= nSize );
+
+ AwtSize aSize( m_xAssociatedShape->getSize() );
+ if ( nPropId == PROPERTY_ID_WIDTH )
+ aSize.Width = nSize;
+ else
+ aSize.Height = nSize;
+ m_xAssociatedShape->setSize( aSize );
+ }
+ break;
+
+ case PROPERTY_ID_TEXT_ANCHOR_TYPE:
+ m_xShapeProperties->setPropertyValue( PROPERTY_ANCHOR_TYPE, _rValue );
+ break;
+
+ case PROPERTY_ID_SHEET_ANCHOR_TYPE:
+ {
+ sal_Int32 nSheetAnchorType = 0;
+ OSL_VERIFY( _rValue >>= nSheetAnchorType );
+ impl_setSheetAnchorType_nothrow( nSheetAnchorType );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( false, "FormGeometryHandler::getPropertyValue: huh?" );
+ break;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ LineDescriptor SAL_CALL FormGeometryHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName,
+ const Reference< XPropertyControlFactory >& _rxControlFactory )
+ throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ LineDescriptor aLineDesc( PropertyHandler::describePropertyLine( _rPropertyName, _rxControlFactory ) );
+ try
+ {
+ bool bIsSize = false;
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_WIDTH:
+ case PROPERTY_ID_HEIGHT:
+ bIsSize = true;
+ // NO break!
+ case PROPERTY_ID_POSITIONX:
+ case PROPERTY_ID_POSITIONY:
+ {
+ Optional< double > aZero( sal_True, 0 );
+ Optional< double > aValueNotPresent( sal_False, 0 );
+ aLineDesc.Control = PropertyHandlerHelper::createNumericControl(
+ _rxControlFactory, 2, bIsSize ? aZero : aValueNotPresent, aValueNotPresent, sal_False );
+
+ Reference< XNumericControl > xNumericControl( aLineDesc.Control, UNO_QUERY_THROW );
+ xNumericControl->setValueUnit( MeasureUnit::MM_100TH );
+ xNumericControl->setDisplayUnit( impl_getDocumentMeasurementUnit_throw() );
+ }
+ break;
+
+ case PROPERTY_ID_TEXT_ANCHOR_TYPE:
+ case PROPERTY_ID_SHEET_ANCHOR_TYPE:
+ // default handling from PropertyHandler is sufficient
+ break;
+
+ default:
+ OSL_ENSURE( false, "FormGeometryHandler::describePropertyLine: huh?" );
+ break;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return aLineDesc;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormGeometryHandler::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _listener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ OSL_PRECOND( m_xChangeNotifier.is(), "FormGeometryHandler::addPropertyChangeListener: no notified, implies no shape!?" );
+ if ( m_xChangeNotifier.is() )
+ m_xChangeNotifier->addPropertyChangeListener( _listener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormGeometryHandler::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _listener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ OSL_PRECOND( m_xChangeNotifier.is(), "FormGeometryHandler::removePropertyChangeListener: no notified, implies no shape!?" );
+ if ( m_xChangeNotifier.is() )
+ m_xChangeNotifier->removePropertyChangeListener( _listener );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL FormGeometryHandler::getActuatingProperties( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aInterestedIn(1);
+ aInterestedIn[0] = PROPERTY_TEXT_ANCHOR_TYPE;
+ return aInterestedIn;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormGeometryHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool /*_bFirstTimeInit*/ ) throw (NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nActuatingPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) );
+
+ switch ( nActuatingPropId )
+ {
+ case PROPERTY_ID_TEXT_ANCHOR_TYPE:
+ {
+ TextContentAnchorType eAnchorType( TextContentAnchorType_AT_PARAGRAPH );
+ OSL_VERIFY( _rNewValue >>= eAnchorType );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_POSITIONX, eAnchorType != TextContentAnchorType_AS_CHARACTER );
+ }
+ break;
+ default:
+ OSL_ENSURE( false, "FormGeometryHandler::actuatingPropertyChanged: not registered for this property!" );
+ break;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Property > SAL_CALL FormGeometryHandler::doDescribeSupportedProperties() const
+ {
+ if ( !m_xAssociatedShape.is() )
+ return Sequence< Property >();
+
+ ::std::vector< Property > aProperties;
+
+ addInt32PropertyDescription( aProperties, PROPERTY_POSITIONX );
+ addInt32PropertyDescription( aProperties, PROPERTY_POSITIONY );
+ addInt32PropertyDescription( aProperties, PROPERTY_WIDTH );
+ addInt32PropertyDescription( aProperties, PROPERTY_HEIGHT );
+
+ if ( impl_haveTextAnchorType_nothrow() )
+ implAddPropertyDescription( aProperties, PROPERTY_TEXT_ANCHOR_TYPE, ::cppu::UnoType< TextContentAnchorType >::get() );
+
+ if ( impl_haveSheetAnchorType_nothrow() )
+ addInt32PropertyDescription( aProperties, PROPERTY_SHEET_ANCHOR_TYPE );
+
+ return Sequence< Property >( &(*aProperties.begin()), aProperties.size() );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormGeometryHandler::disposing()
+ {
+ FormGeometryHandler_Base::disposing();
+
+ if ( m_xChangeNotifier.is() )
+ {
+ m_xChangeNotifier->dispose();
+ m_xChangeNotifier.clear();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool FormGeometryHandler::impl_haveTextAnchorType_nothrow() const
+ {
+ ENSURE_OR_THROW( m_xShapeProperties.is(), "not to be called without shape properties" );
+ try
+ {
+ Reference< XPropertySetInfo > xPSI( m_xShapeProperties->getPropertySetInfo(), UNO_SET_THROW );
+ if ( xPSI->hasPropertyByName( PROPERTY_ANCHOR_TYPE ) )
+ return true;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return false;
+ }
+
+ //--------------------------------------------------------------------
+ bool FormGeometryHandler::impl_haveSheetAnchorType_nothrow() const
+ {
+ ENSURE_OR_THROW( m_xShapeProperties.is(), "not to be called without shape properties" );
+ try
+ {
+ Reference< XPropertySetInfo > xPSI( m_xShapeProperties->getPropertySetInfo(), UNO_SET_THROW );
+ if ( !xPSI->hasPropertyByName( PROPERTY_ANCHOR ) )
+ return false;
+ Reference< XServiceInfo > xSI( m_xAssociatedShape, UNO_QUERY_THROW );
+ if ( xSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.Shape" ) ) ) )
+ return true;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return false;
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ static sal_Int32 lcl_getLowerBoundRowOrColumn( const Reference< XIndexAccess >& _rxRowsOrColumns, const bool _bRows,
+ const AwtPoint& _rRelativePosition )
+ {
+ sal_Int32 nAccumulated = 0;
+
+ const sal_Int32& rRelativePos = _bRows ? _rRelativePosition.Y : _rRelativePosition.X;
+
+ sal_Int32 nElements = _rxRowsOrColumns->getCount();
+ sal_Int32 currentPos = 0;
+ for ( currentPos=0; currentPos<nElements; ++currentPos )
+ {
+ Reference< XPropertySet > xRowOrColumn( _rxRowsOrColumns->getByIndex( currentPos ), UNO_QUERY_THROW );
+
+ sal_Bool bIsVisible = sal_True;
+ OSL_VERIFY( xRowOrColumn->getPropertyValue( PROPERTY_IS_VISIBLE ) >>= bIsVisible );
+ if ( !bIsVisible )
+ continue;
+
+ sal_Int32 nHeightOrWidth( 0 );
+ OSL_VERIFY( xRowOrColumn->getPropertyValue( _bRows ? PROPERTY_HEIGHT : PROPERTY_WIDTH ) >>= nHeightOrWidth );
+
+ if ( nAccumulated + nHeightOrWidth > rRelativePos )
+ break;
+
+ nAccumulated += nHeightOrWidth;
+ }
+
+ return currentPos;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void FormGeometryHandler::impl_setSheetAnchorType_nothrow( const sal_Int32 _nAnchorType ) const
+ {
+ ENSURE_OR_THROW( m_xShapeProperties.is(), "illegal to be called without shape properties." );
+ try
+ {
+ CellBindingHelper aHelper( m_xComponent, impl_getContextDocument_nothrow() );
+ // find the sheet which the control belongs to
+ Reference< XSpreadsheet > xSheet;
+ aHelper.getControlSheetIndex( xSheet );
+
+ switch ( _nAnchorType )
+ {
+ case ANCHOR_TO_SHEET:
+ OSL_ENSURE( xSheet.is(),
+ "FormGeometryHandler::impl_setSheetAnchorType_nothrow: sheet not found!" );
+ if ( xSheet.is() )
+ {
+ AwtPoint aPreservePosition( m_xAssociatedShape->getPosition() );
+ m_xShapeProperties->setPropertyValue( PROPERTY_ANCHOR, makeAny( xSheet ) );
+ m_xAssociatedShape->setPosition( aPreservePosition );
+ }
+ break;
+
+ case ANCHOR_TO_CELL:
+ {
+ Reference< XColumnRowRange > xColsRows( xSheet, UNO_QUERY_THROW );
+
+ // get the current anchor
+ Reference< XSpreadsheet > xCurrentAnchor;
+ OSL_VERIFY( m_xShapeProperties->getPropertyValue( PROPERTY_ANCHOR ) >>= xCurrentAnchor );
+ OSL_ENSURE( xCurrentAnchor.is(), "FormGeometryHandler::impl_setSheetAnchorType_nothrow: only to be called when currently anchored to a sheet!" );
+
+ // get the current position
+ AwtPoint aRelativePosition( m_xAssociatedShape->getPosition() );
+
+ Reference< XTableColumns > xCols( xColsRows->getColumns(), UNO_SET_THROW );
+ sal_Int32 nNewAnchorCol = lcl_getLowerBoundRowOrColumn( xCols.get(), false, aRelativePosition );
+
+ Reference< XTableRows > xRows( xColsRows->getRows(), UNO_SET_THROW );
+ sal_Int32 nNewAnchorRow = lcl_getLowerBoundRowOrColumn( xRows.get(), true, aRelativePosition );
+
+ Reference< XCellRange > xSheetCellRange( xSheet, UNO_QUERY_THROW );
+ Any aNewAnchorCell( xSheetCellRange->getCellByPosition( nNewAnchorCol, nNewAnchorRow ) );
+ m_xShapeProperties->setPropertyValue( PROPERTY_ANCHOR, aNewAnchorCell );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( false, "FormGeometryHandler::impl_setSheetAnchorType_nothrow: illegal anchor type!" );
+ break;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //====================================================================
+ //= ShapeGeometryChangeNotifier - implementation
+ //====================================================================
+ namespace
+ {
+ struct EventTranslation
+ {
+ ::rtl::OUString sPropertyName;
+ Any aNewPropertyValue;
+
+ EventTranslation( const ::rtl::OUString& _propertyName, const Any& _newPropertyValue )
+ :sPropertyName( _propertyName )
+ ,aNewPropertyValue( _newPropertyValue )
+ {
+ }
+ };
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ShapeGeometryChangeNotifier::propertyChange( const PropertyChangeEvent& _event ) throw (RuntimeException)
+ {
+ ::comphelper::ComponentMethodGuard aGuard( *this );
+
+ ::std::vector< EventTranslation > aEventTranslations;
+ aEventTranslations.reserve(2);
+
+ if ( _event.PropertyName.equalsAscii( "Position" ) )
+ {
+ AwtPoint aPos = m_xShape->getPosition();
+ aEventTranslations.push_back( EventTranslation( PROPERTY_POSITIONX, makeAny( aPos.X ) ) );
+ aEventTranslations.push_back( EventTranslation( PROPERTY_POSITIONY, makeAny( aPos.Y ) ) );
+ }
+ else if ( _event.PropertyName.equalsAscii( "Size" ) )
+ {
+ AwtSize aSize = m_xShape->getSize();
+ aEventTranslations.push_back( EventTranslation( PROPERTY_WIDTH, makeAny( aSize.Width ) ) );
+ aEventTranslations.push_back( EventTranslation( PROPERTY_HEIGHT, makeAny( aSize.Height ) ) );
+ }
+ else if ( _event.PropertyName == PROPERTY_ANCHOR_TYPE )
+ {
+ aEventTranslations.push_back( EventTranslation( PROPERTY_TEXT_ANCHOR_TYPE, makeAny( _event.NewValue ) ) );
+ }
+ else if ( _event.PropertyName == PROPERTY_ANCHOR )
+ {
+ aEventTranslations.push_back( EventTranslation( PROPERTY_SHEET_ANCHOR_TYPE, makeAny( _event.NewValue ) ) );
+ }
+
+ PropertyChangeEvent aTranslatedEvent( _event );
+ aTranslatedEvent.Source = m_rParent;
+
+ aGuard.clear();
+ for ( ::std::vector< EventTranslation >::const_iterator t = aEventTranslations.begin();
+ t != aEventTranslations.end();
+ ++t
+ )
+ {
+ aTranslatedEvent.PropertyName = t->sPropertyName;
+ aTranslatedEvent.NewValue = t->aNewPropertyValue;
+ m_aPropertyChangeListeners.notifyEach( &XPropertyChangeListener::propertyChange, aTranslatedEvent );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ShapeGeometryChangeNotifier::disposing( const EventObject& /*_event*/ ) throw (RuntimeException)
+ {
+ ::comphelper::ComponentMethodGuard aGuard( *this );
+ impl_dispose_nothrow();
+ }
+
+ //--------------------------------------------------------------------
+ void ShapeGeometryChangeNotifier::impl_init_nothrow()
+ {
+ osl_incrementInterlockedCount( &m_refCount );
+ try
+ {
+ Reference< XPropertySet > xShapeProperties( m_xShape, UNO_QUERY_THROW );
+ xShapeProperties->addPropertyChangeListener( ::rtl::OUString(), this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+
+ //--------------------------------------------------------------------
+ void ShapeGeometryChangeNotifier::impl_dispose_nothrow()
+ {
+ try
+ {
+ Reference< XPropertySet > xShapeProperties( m_xShape, UNO_QUERY_THROW );
+ xShapeProperties->removePropertyChangeListener( ::rtl::OUString(), this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ getBroadcastHelper().bDisposed = true;
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+extern "C" void SAL_CALL createRegistryInfo_FormGeometryHandler()
+{
+ ::pcr::FormGeometryHandler::registerImplementation();
+}
diff --git a/extensions/source/propctrlr/formlinkdialog.cxx b/extensions/source/propctrlr/formlinkdialog.cxx
new file mode 100644
index 000000000000..7010c9102188
--- /dev/null
+++ b/extensions/source/propctrlr/formlinkdialog.cxx
@@ -0,0 +1,676 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "formlinkdialog.hxx"
+#include "formlinkdialog.hrc"
+
+#ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
+#include "modulepcr.hxx"
+#endif
+#ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
+#include "formresid.hrc"
+#endif
+#include "formstrings.hxx"
+#include <vcl/combobox.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/waitobj.hxx>
+#include <svtools/localresaccess.hxx>
+#include <connectivity/dbtools.hxx>
+#include <connectivity/dbexception.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+/** === end UNO includes === **/
+
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::form;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::container;
+
+ //========================================================================
+ //= FieldLinkRow
+ //========================================================================
+ class FieldLinkRow : public Window
+ {
+ private:
+ ComboBox m_aDetailColumn;
+ FixedText m_aEqualSign;
+ ComboBox m_aMasterColumn;
+
+ Link m_aLinkChangeHandler;
+
+ public:
+ FieldLinkRow( Window* _pParent, const ResId& _rId );
+
+ inline void SetLinkChangeHandler( const Link& _rHdl ) { m_aLinkChangeHandler = _rHdl; }
+ inline const Link& GetLinkChangeHandler( ) const { return m_aLinkChangeHandler; }
+
+ enum LinkParticipant
+ {
+ eDetailField,
+ eMasterField
+ };
+ /** retrieves the selected field name for either the master or the detail field
+ @return <TRUE/> if and only a valid field is selected
+ */
+ bool GetFieldName( LinkParticipant _eWhich, String& /* [out] */ _rName ) const;
+ void SetFieldName( LinkParticipant _eWhich, const String& _rName );
+
+ void fillList( LinkParticipant _eWhich, const Sequence< ::rtl::OUString >& _rFieldNames );
+
+ private:
+ DECL_LINK( OnFieldNameChanged, ComboBox* );
+ };
+
+ //------------------------------------------------------------------------
+ FieldLinkRow::FieldLinkRow( Window* _pParent, const ResId& _rId )
+ :Window( _pParent, _rId )
+ ,m_aDetailColumn( this, ResId( 1, *_rId.GetResMgr() ) )
+ ,m_aEqualSign ( this, ResId( 1, *_rId.GetResMgr() ) )
+ ,m_aMasterColumn( this, ResId( 2, *_rId.GetResMgr() ) )
+ {
+ FreeResource();
+
+ m_aDetailColumn.SetDropDownLineCount( 10 );
+ m_aMasterColumn.SetDropDownLineCount( 10 );
+
+ m_aDetailColumn.SetModifyHdl( LINK( this, FieldLinkRow, OnFieldNameChanged ) );
+ m_aMasterColumn.SetModifyHdl( LINK( this, FieldLinkRow, OnFieldNameChanged ) );
+ }
+
+ //------------------------------------------------------------------------
+ void FieldLinkRow::fillList( LinkParticipant _eWhich, const Sequence< ::rtl::OUString >& _rFieldNames )
+ {
+ ComboBox* pBox = ( _eWhich == eDetailField ) ? &m_aDetailColumn : &m_aMasterColumn;
+
+ const ::rtl::OUString* pFieldName = _rFieldNames.getConstArray();
+ const ::rtl::OUString* pFieldNameEnd = pFieldName + _rFieldNames.getLength();
+ for ( ; pFieldName != pFieldNameEnd; ++pFieldName )
+ pBox->InsertEntry( *pFieldName );
+ }
+
+ //------------------------------------------------------------------------
+ bool FieldLinkRow::GetFieldName( LinkParticipant _eWhich, String& /* [out] */ _rName ) const
+ {
+ const ComboBox* pBox = ( _eWhich == eDetailField ) ? &m_aDetailColumn : &m_aMasterColumn;
+ _rName = pBox->GetText();
+ return _rName.Len() != 0;
+ }
+
+ //------------------------------------------------------------------------
+ void FieldLinkRow::SetFieldName( LinkParticipant _eWhich, const String& _rName )
+ {
+ ComboBox* pBox = ( _eWhich == eDetailField ) ? &m_aDetailColumn : &m_aMasterColumn;
+ pBox->SetText( _rName );
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( FieldLinkRow, OnFieldNameChanged, ComboBox*, /*_pBox*/ )
+ {
+ if ( m_aLinkChangeHandler.IsSet() )
+ return m_aLinkChangeHandler.Call( this );
+
+ return 0L;
+ }
+
+ //========================================================================
+ //= FormLinkDialog
+ //========================================================================
+ //------------------------------------------------------------------------
+ FormLinkDialog::FormLinkDialog( Window* _pParent, const Reference< XPropertySet >& _rxDetailForm,
+ const Reference< XPropertySet >& _rxMasterForm, const Reference< XMultiServiceFactory >& _rxORB,
+ const ::rtl::OUString& _sExplanation,
+ const ::rtl::OUString& _sDetailLabel,
+ const ::rtl::OUString& _sMasterLabel)
+ :ModalDialog( _pParent, PcrRes( RID_DLG_FORMLINKS ) )
+ ,m_aExplanation( this, PcrRes( FT_EXPLANATION ) )
+ ,m_aDetailLabel( this, PcrRes( FT_DETAIL_LABEL ) )
+ ,m_aMasterLabel( this, PcrRes( FT_MASTER_LABEL ) )
+ ,m_aRow1 ( new FieldLinkRow( this, PcrRes( 1 ) ) )
+ ,m_aRow2 ( new FieldLinkRow( this, PcrRes( 2 ) ) )
+ ,m_aRow3 ( new FieldLinkRow( this, PcrRes( 3 ) ) )
+ ,m_aRow4 ( new FieldLinkRow( this, PcrRes( 4 ) ) )
+ ,m_aOK ( this, PcrRes( PB_OK ) )
+ ,m_aCancel ( this, PcrRes( PB_CANCEL ) )
+ ,m_aHelp ( this, PcrRes( PB_HELP ) )
+ ,m_aSuggest ( this, PcrRes( PB_SUGGEST ) )
+ ,m_xORB ( _rxORB )
+ ,m_xDetailForm( _rxDetailForm )
+ ,m_xMasterForm( _rxMasterForm )
+ ,m_sDetailLabel(_sDetailLabel)
+ ,m_sMasterLabel(_sMasterLabel)
+ {
+ FreeResource();
+ if ( _sExplanation.getLength() )
+ m_aExplanation.SetText(_sExplanation);
+
+ m_aSuggest.SetClickHdl ( LINK( this, FormLinkDialog, OnSuggest ) );
+ m_aRow1->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) );
+ m_aRow2->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) );
+ m_aRow3->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) );
+ m_aRow4->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) );
+
+ PostUserEvent( LINK( this, FormLinkDialog, OnInitialize ) );
+
+ updateOkButton();
+ }
+
+ //------------------------------------------------------------------------
+ FormLinkDialog::~FormLinkDialog( )
+ {
+ }
+
+ //------------------------------------------------------------------------
+ void FormLinkDialog::commitLinkPairs()
+ {
+ // collect the field lists from the rows
+ ::std::vector< ::rtl::OUString > aDetailFields; aDetailFields.reserve( 4 );
+ ::std::vector< ::rtl::OUString > aMasterFields; aMasterFields.reserve( 4 );
+
+ const FieldLinkRow* aRows[] = {
+ m_aRow1.get(), m_aRow2.get(), m_aRow3.get(), m_aRow4.get()
+ };
+
+ for ( sal_Int32 i = 0; i < 4; ++i )
+ {
+ String sDetailField, sMasterField;
+ aRows[ i ]->GetFieldName( FieldLinkRow::eDetailField, sDetailField );
+ aRows[ i ]->GetFieldName( FieldLinkRow::eMasterField, sMasterField );
+ if ( !sDetailField.Len() && !sMasterField.Len() )
+ continue;
+
+ aDetailFields.push_back( sDetailField );
+ aMasterFields.push_back( sMasterField );
+ }
+
+ // and set as property values
+ try
+ {
+ Reference< XPropertySet > xDetailFormProps( m_xDetailForm, UNO_QUERY );
+ if ( xDetailFormProps.is() )
+ {
+ ::rtl::OUString *pFields = aDetailFields.empty() ? 0 : &aDetailFields[0];
+ xDetailFormProps->setPropertyValue( PROPERTY_DETAILFIELDS, makeAny( Sequence< ::rtl::OUString >( pFields, aDetailFields.size() ) ) );
+ pFields = aMasterFields.empty() ? 0 : &aMasterFields[0];
+ xDetailFormProps->setPropertyValue( PROPERTY_MASTERFIELDS, makeAny( Sequence< ::rtl::OUString >( pFields, aMasterFields.size() ) ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormLinkDialog::commitLinkPairs: caught an exception while setting the properties!" );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ short FormLinkDialog::Execute()
+ {
+ short nResult = ModalDialog::Execute();
+
+ if ( RET_OK == nResult )
+ commitLinkPairs();
+
+ return nResult;
+ }
+
+ //------------------------------------------------------------------------
+ void FormLinkDialog::initializeFieldLists()
+ {
+ Sequence< ::rtl::OUString > sDetailFields;
+ getFormFields( m_xDetailForm, sDetailFields );
+
+ Sequence< ::rtl::OUString > sMasterFields;
+ getFormFields( m_xMasterForm, sMasterFields );
+
+ FieldLinkRow* aRows[] = {
+ m_aRow1.get(), m_aRow2.get(), m_aRow3.get(), m_aRow4.get()
+ };
+ for ( sal_Int32 i = 0; i < 4 ; ++i )
+ {
+ aRows[i]->fillList( FieldLinkRow::eDetailField, sDetailFields );
+ aRows[i]->fillList( FieldLinkRow::eMasterField, sMasterFields );
+ }
+
+ }
+
+ //------------------------------------------------------------------------
+ void FormLinkDialog::initializeColumnLabels()
+ {
+ // label for the detail form
+ String sDetailType = getFormDataSourceType( m_xDetailForm );
+ if ( !sDetailType.Len() )
+ {
+ if ( !m_sDetailLabel.getLength() )
+ {
+ ::svt::OLocalResourceAccess aStringAccess( PcrRes( RID_DLG_FORMLINKS ), RSC_MODALDIALOG );
+ m_sDetailLabel = String( PcrRes( STR_DETAIL_FORM ) );
+ }
+ sDetailType = m_sDetailLabel;
+ }
+ m_aDetailLabel.SetText( sDetailType );
+
+ // label for the master form
+ String sMasterType = getFormDataSourceType( m_xMasterForm );
+ if ( !sMasterType.Len() )
+ {
+ if ( !m_sMasterLabel.getLength() )
+ {
+ ::svt::OLocalResourceAccess aStringAccess( PcrRes( RID_DLG_FORMLINKS ), RSC_MODALDIALOG );
+ m_sMasterLabel = String( PcrRes( STR_MASTER_FORM ) );
+ }
+ sMasterType = m_sMasterLabel;
+ }
+ m_aMasterLabel.SetText( sMasterType );
+ }
+
+ //------------------------------------------------------------------------
+ void FormLinkDialog::initializeFieldRowsFrom( Sequence< ::rtl::OUString >& _rDetailFields, Sequence< ::rtl::OUString >& _rMasterFields )
+ {
+ // our UI does allow 4 fields max
+ _rDetailFields.realloc( 4 );
+ _rMasterFields.realloc( 4 );
+
+ const ::rtl::OUString* pDetailFields = _rDetailFields.getConstArray();
+ const ::rtl::OUString* pMasterFields = _rMasterFields.getConstArray();
+
+ FieldLinkRow* aRows[] = {
+ m_aRow1.get(), m_aRow2.get(), m_aRow3.get(), m_aRow4.get()
+ };
+ for ( sal_Int32 i = 0; i < 4; ++i, ++pDetailFields, ++pMasterFields )
+ {
+ aRows[ i ]->SetFieldName( FieldLinkRow::eDetailField, *pDetailFields );
+ aRows[ i ]->SetFieldName( FieldLinkRow::eMasterField, *pMasterFields );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void FormLinkDialog::initializeLinks()
+ {
+ try
+ {
+ Sequence< ::rtl::OUString > aDetailFields;
+ Sequence< ::rtl::OUString > aMasterFields;
+
+ Reference< XPropertySet > xDetailFormProps( m_xDetailForm, UNO_QUERY );
+ if ( xDetailFormProps.is() )
+ {
+ xDetailFormProps->getPropertyValue( PROPERTY_DETAILFIELDS ) >>= aDetailFields;
+ xDetailFormProps->getPropertyValue( PROPERTY_MASTERFIELDS ) >>= aMasterFields;
+ }
+
+ initializeFieldRowsFrom( aDetailFields, aMasterFields );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormLinkDialog::initializeLinks: caught an exception!" );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void FormLinkDialog::updateOkButton()
+ {
+ // in all rows, there must be either two valid selections, or none at all
+ // If there is at least one row with exactly one valid selection, then the
+ // OKButton needs to be disabled
+ sal_Bool bEnable = sal_True;
+
+ const FieldLinkRow* aRows[] = {
+ m_aRow1.get(), m_aRow2.get(), m_aRow3.get(), m_aRow4.get()
+ };
+
+ for ( sal_Int32 i = 0; ( i < 4 ) && bEnable; ++i )
+ {
+ String sNotInterestedInRightNow;
+ if ( aRows[ i ]->GetFieldName( FieldLinkRow::eDetailField, sNotInterestedInRightNow )
+ != aRows[ i ]->GetFieldName( FieldLinkRow::eMasterField, sNotInterestedInRightNow )
+ )
+ bEnable = sal_False;
+ }
+
+ m_aOK.Enable( bEnable );
+ }
+
+ //------------------------------------------------------------------------
+ String FormLinkDialog::getFormDataSourceType( const Reference< XPropertySet >& _rxForm ) const SAL_THROW(())
+ {
+ String sReturn;
+ Reference< XPropertySet > xFormProps( _rxForm, UNO_QUERY );
+ if ( !xFormProps.is() )
+ return sReturn;
+
+ try
+ {
+ sal_Int32 nCommandType = CommandType::COMMAND;
+ ::rtl::OUString sCommand;
+
+ xFormProps->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nCommandType;
+ xFormProps->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand;
+
+ if ( ( nCommandType == CommandType::TABLE )
+ || ( nCommandType == CommandType::QUERY )
+ )
+ sReturn = sCommand;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormLinkDialog::getFormDataSourceType: caught an exception!" );
+ }
+ return sReturn;
+ }
+
+ //------------------------------------------------------------------------
+ void FormLinkDialog::getFormFields( const Reference< XPropertySet >& _rxForm, Sequence< ::rtl::OUString >& /* [out] */ _rNames ) const SAL_THROW(( ))
+ {
+ _rNames.realloc( 0 );
+
+ ::dbtools::SQLExceptionInfo aErrorInfo;
+ ::rtl::OUString sCommand;
+ try
+ {
+ WaitObject aWaitCursor( const_cast< FormLinkDialog* >( this ) );
+
+ Reference< XPropertySet > xFormProps( _rxForm, UNO_QUERY );
+ OSL_ENSURE( xFormProps.is(), "FormLinkDialog::getFormFields: invalid form!" );
+
+ sal_Int32 nCommandType = CommandType::COMMAND;
+
+ xFormProps->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nCommandType;
+ xFormProps->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand;
+
+ Reference< XConnection > xConnection;
+ ensureFormConnection( xFormProps, xConnection );
+
+ _rNames = ::dbtools::getFieldNamesByCommandDescriptor(
+ xConnection,
+ nCommandType,
+ sCommand,
+ &aErrorInfo
+ );
+ }
+ catch (const SQLContext& e) { aErrorInfo = e; }
+ catch (const SQLWarning& e) { aErrorInfo = e; }
+ catch (const SQLException& e ) { aErrorInfo = e; }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormLinkDialog::getFormFields: caught a non-SQL exception!" );
+ }
+
+ if ( aErrorInfo.isValid() )
+ {
+ String sErrorMessage;
+ {
+ ::svt::OLocalResourceAccess aStringAccess( PcrRes( RID_DLG_FORMLINKS ), RSC_MODALDIALOG );
+ sErrorMessage = String( PcrRes( STR_ERROR_RETRIEVING_COLUMNS) );
+ sErrorMessage.SearchAndReplace('#',sCommand);
+ }
+
+ SQLContext aContext;
+ aContext.Message = sErrorMessage;
+ aContext.NextException = aErrorInfo.get();
+ ::dbtools::showError( aContext, VCLUnoHelper::GetInterface( const_cast< FormLinkDialog* >( this ) ), m_xORB );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void FormLinkDialog::ensureFormConnection( const Reference< XPropertySet >& _rxFormProps, Reference< XConnection >& /* [out] */ _rxConnection ) const SAL_THROW(( Exception ))
+ {
+ OSL_PRECOND( _rxFormProps.is(), "FormLinkDialog::ensureFormConnection: invalid form!" );
+ if ( !_rxFormProps.is() )
+ return;
+ if ( _rxFormProps->getPropertySetInfo()->hasPropertyByName(PROPERTY_ACTIVE_CONNECTION) )
+ _rxConnection.set(_rxFormProps->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY);
+
+ if ( !_rxConnection.is() )
+ _rxConnection = ::dbtools::connectRowset( Reference< XRowSet >( _rxFormProps, UNO_QUERY ), m_xORB, sal_True );
+ }
+
+ //------------------------------------------------------------------------
+ void FormLinkDialog::getConnectionMetaData( const Reference< XPropertySet >& _rxFormProps, Reference< XDatabaseMetaData >& /* [out] */ _rxMeta ) const SAL_THROW(( Exception ))
+ {
+ if ( _rxFormProps.is() )
+ {
+ Reference< XConnection > xConnection;
+ if ( !::dbtools::isEmbeddedInDatabase( _rxFormProps, xConnection ) )
+ _rxFormProps->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xConnection;
+ if ( xConnection.is() )
+ _rxMeta = xConnection->getMetaData();
+ }
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XPropertySet > FormLinkDialog::getCanonicUnderlyingTable( const Reference< XPropertySet >& _rxFormProps ) const
+ {
+ Reference< XPropertySet > xTable;
+ try
+ {
+ Reference< XTablesSupplier > xTablesInForm( ::dbtools::getCurrentSettingsComposer( _rxFormProps, m_xORB ), UNO_QUERY );
+ Reference< XNameAccess > xTables;
+ if ( xTablesInForm.is() )
+ xTables = xTablesInForm->getTables();
+ Sequence< ::rtl::OUString > aTableNames;
+ if ( xTables.is() )
+ aTableNames = xTables->getElementNames();
+
+ if ( aTableNames.getLength() == 1 )
+ {
+ xTables->getByName( aTableNames[ 0 ] ) >>= xTable;
+ OSL_ENSURE( xTable.is(), "FormLinkDialog::getCanonicUnderlyingTable: invalid table!" );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormLinkDialog::getCanonicUnderlyingTable: caught an exception!" );
+ }
+ return xTable;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool FormLinkDialog::getExistingRelation( const Reference< XPropertySet >& _rxLHS, const Reference< XPropertySet >& /*_rxRHS*/,
+ // TODO: fix the usage of _rxRHS. This is issue #i81956#.
+ Sequence< ::rtl::OUString >& _rLeftFields, Sequence< ::rtl::OUString >& _rRightFields ) const
+ {
+ try
+ {
+ Reference< XKeysSupplier > xSuppKeys( _rxLHS, UNO_QUERY );
+ Reference< XIndexAccess > xKeys;
+ if ( xSuppKeys.is() )
+ xKeys = xSuppKeys->getKeys();
+
+ if ( xKeys.is() )
+ {
+ Reference< XPropertySet > xKey;
+ Reference< XColumnsSupplier > xKeyColSupp( xKey, UNO_QUERY );
+ Reference< XIndexAccess > xKeyColumns;
+ Reference< XPropertySet > xKeyColumn;
+ ::rtl::OUString sColumnName, sRelatedColumnName;
+
+ const sal_Int32 keyCount = xKeys->getCount();
+ for ( sal_Int32 key = 0; key < keyCount; ++key )
+ {
+ xKeys->getByIndex( key ) >>= xKey;
+ sal_Int32 nKeyType = 0;
+ xKey->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Type" ) ) ) >>= nKeyType;
+ if ( nKeyType != KeyType::FOREIGN )
+ continue;
+
+ xKeyColumns.clear();
+ xKeyColSupp = xKeyColSupp.query( xKey );
+ if ( xKeyColSupp.is() )
+ xKeyColumns = xKeyColumns.query( xKeyColSupp->getColumns() );
+ OSL_ENSURE( xKeyColumns.is(), "FormLinkDialog::getExistingRelation: could not obtain the columns for the key!" );
+
+ if ( !xKeyColumns.is() )
+ continue;
+
+ const sal_Int32 columnCount = xKeyColumns->getCount();
+ _rLeftFields.realloc( columnCount );
+ _rRightFields.realloc( columnCount );
+ for ( sal_Int32 column = 0; column < columnCount; ++column )
+ {
+ xKeyColumn.clear();
+ xKeyColumns->getByIndex( column ) >>= xKeyColumn;
+ OSL_ENSURE( xKeyColumn.is(), "FormLinkDialog::getExistingRelation: invalid key column!" );
+ if ( xKeyColumn.is() )
+ {
+ xKeyColumn->getPropertyValue( PROPERTY_NAME ) >>= sColumnName;
+ xKeyColumn->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RelatedColumn" ) ) ) >>= sRelatedColumnName;
+
+ _rLeftFields[ column ] = sColumnName;
+ _rRightFields[ column ] = sRelatedColumnName;
+ }
+ }
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormLinkDialog::getExistingRelation: caught an exception!" );
+ }
+
+ return ( _rLeftFields.getLength() > 0 ) && ( _rLeftFields[ 0 ].getLength() > 0 );
+ }
+
+ //------------------------------------------------------------------------
+ void FormLinkDialog::initializeSuggest()
+ {
+ Reference< XPropertySet > xDetailFormProps( m_xDetailForm, UNO_QUERY );
+ Reference< XPropertySet > xMasterFormProps( m_xMasterForm, UNO_QUERY );
+ if ( !xDetailFormProps.is() || !xMasterFormProps.is() )
+ return;
+
+ try
+ {
+ sal_Bool bEnable = sal_True;
+
+ // only show the button when both forms are based on the same data source
+ if ( bEnable )
+ {
+ ::rtl::OUString sMasterDS, sDetailDS;
+ xMasterFormProps->getPropertyValue( PROPERTY_DATASOURCE ) >>= sMasterDS;
+ xDetailFormProps->getPropertyValue( PROPERTY_DATASOURCE ) >>= sDetailDS;
+ bEnable = ( sMasterDS == sDetailDS );
+ }
+
+ // only show the button when the connection supports relations
+ if ( bEnable )
+ {
+ Reference< XDatabaseMetaData > xMeta;
+ getConnectionMetaData( xDetailFormProps, xMeta );
+ OSL_ENSURE( xMeta.is(), "FormLinkDialog::initializeSuggest: unable to retrieve the meta data for the connection!" );
+ try
+ {
+ bEnable = xMeta.is() && xMeta->supportsIntegrityEnhancementFacility();
+ }
+ catch(const Exception&)
+ {
+ bEnable = sal_False;
+ }
+ }
+
+ // only enable the button if there is a "canonic" table underlying both forms
+ Reference< XPropertySet > xDetailTable, xMasterTable;
+ if ( bEnable )
+ {
+ xDetailTable = getCanonicUnderlyingTable( xDetailFormProps );
+ xMasterTable = getCanonicUnderlyingTable( xMasterFormProps );
+ bEnable = xDetailTable.is() && xMasterTable.is();
+ }
+
+ // only enable the button if there is a relation between both tables
+ m_aRelationDetailColumns.realloc( 0 );
+ m_aRelationMasterColumns.realloc( 0 );
+ if ( bEnable )
+ {
+ bEnable = getExistingRelation( xDetailTable, xMasterTable, m_aRelationDetailColumns, m_aRelationMasterColumns );
+ OSL_POSTCOND( m_aRelationMasterColumns.getLength() == m_aRelationDetailColumns.getLength(), "FormLinkDialog::initializeSuggest: nonsense!" );
+ if ( m_aRelationMasterColumns.getLength() == 0 )
+ { // okay, there is no relation "pointing" (via a foreign key) from the detail table to the master table
+ // but perhaps the other way round (would make less sense, but who knows ...)
+ bEnable = getExistingRelation( xMasterTable, xDetailTable, m_aRelationMasterColumns, m_aRelationDetailColumns );
+ }
+ }
+
+ // only enable the button if the relation contains at most 4 field pairs
+ if ( bEnable )
+ {
+ bEnable = ( m_aRelationMasterColumns.getLength() <= 4 );
+ }
+
+ m_aSuggest.Enable( bEnable );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormLinkDialog::initializeSuggest: caught an exception!" );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( FormLinkDialog, OnSuggest, void*, /*_pNotInterestedIn*/ )
+ {
+ initializeFieldRowsFrom( m_aRelationDetailColumns, m_aRelationMasterColumns );
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( FormLinkDialog, OnFieldChanged, FieldLinkRow*, /*_pRow*/ )
+ {
+ updateOkButton();
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( FormLinkDialog, OnInitialize, void*, /*_pNotInterestedIn*/ )
+ {
+ initializeColumnLabels();
+ initializeFieldLists();
+ initializeLinks();
+ initializeSuggest();
+ return 0L;
+ }
+//............................................................................
+} // namespace pcr
+//............................................................................
diff --git a/extensions/source/propctrlr/formlinkdialog.hrc b/extensions/source/propctrlr/formlinkdialog.hrc
new file mode 100644
index 000000000000..768034901182
--- /dev/null
+++ b/extensions/source/propctrlr/formlinkdialog.hrc
@@ -0,0 +1,44 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_FORMLINKDIALOG_HRC
+#define EXTENSIONS_SOURCE_PROPCTRLR_FORMLINKDIALOG_HRC
+
+#define FT_EXPLANATION 1
+#define FT_DETAIL_LABEL 2
+#define FT_MASTER_LABEL 3
+
+#define PB_OK 1
+#define PB_CANCEL 2
+#define PB_HELP 3
+#define PB_SUGGEST 4
+
+#define STR_DETAIL_FORM 1
+#define STR_MASTER_FORM 2
+#define STR_ERROR_RETRIEVING_COLUMNS 3
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_FORMLINKDIALOG_HRC
diff --git a/extensions/source/propctrlr/formlinkdialog.hxx b/extensions/source/propctrlr/formlinkdialog.hxx
new file mode 100644
index 000000000000..9605ee622234
--- /dev/null
+++ b/extensions/source/propctrlr/formlinkdialog.hxx
@@ -0,0 +1,150 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_FORMLINKDIALOG_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_FORMLINKDIALOG_HXX
+
+#include <vcl/dialog.hxx>
+#include <vcl/fixed.hxx>
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+
+/** === begin UNO includes === **/
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+/** === end UNO includes === **/
+
+#include <memory>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ class FieldLinkRow;
+ //========================================================================
+ //= FormLinkDialog
+ //========================================================================
+ class FormLinkDialog : public ModalDialog
+ {
+ private:
+ FixedText m_aExplanation;
+ FixedText m_aDetailLabel;
+ FixedText m_aMasterLabel;
+ ::std::auto_ptr< FieldLinkRow > m_aRow1;
+ ::std::auto_ptr< FieldLinkRow > m_aRow2;
+ ::std::auto_ptr< FieldLinkRow > m_aRow3;
+ ::std::auto_ptr< FieldLinkRow > m_aRow4;
+ OKButton m_aOK;
+ CancelButton m_aCancel;
+ HelpButton m_aHelp;
+ PushButton m_aSuggest;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xDetailForm;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xMasterForm;
+
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ m_aRelationDetailColumns;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ m_aRelationMasterColumns;
+
+ ::rtl::OUString m_sDetailLabel;
+ ::rtl::OUString m_sMasterLabel;
+
+ public:
+ FormLinkDialog(
+ Window* _pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDetailForm,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxMasterForm,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ::rtl::OUString& _sExplanation = ::rtl::OUString(),
+ const ::rtl::OUString& _sDetailLabel = ::rtl::OUString(),
+ const ::rtl::OUString& _sMasterLabel = ::rtl::OUString()
+ );
+ ~FormLinkDialog( );
+
+ // Dialog overridables
+ virtual short Execute();
+
+ private:
+ DECL_LINK( OnSuggest, void* );
+ DECL_LINK( OnFieldChanged, FieldLinkRow* );
+ DECL_LINK( OnInitialize, void* );
+
+ void updateOkButton();
+ void initializeFieldLists();
+ void initializeColumnLabels();
+ void initializeLinks();
+ void initializeSuggest();
+ void commitLinkPairs();
+
+ void initializeFieldRowsFrom(
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rDetailFields,
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rMasterFields
+ );
+
+ String getFormDataSourceType(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxForm
+ ) const SAL_THROW(());
+
+ void getFormFields(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxForm,
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >& /* [out] */ _rNames
+ ) const SAL_THROW(());
+
+ void ensureFormConnection(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxFormProps,
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& /* [out] */ _rxConnection
+ ) const SAL_THROW(( ::com::sun::star::uno::Exception ));
+
+ void getConnectionMetaData(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxFormProps,
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& /* [out] */ _rxMeta
+ ) const SAL_THROW(( ::com::sun::star::uno::Exception ));
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ getCanonicUnderlyingTable( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxFormProps ) const;
+ sal_Bool getExistingRelation(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxLHS,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxRHS,
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >& /* [out] */ _rLeftFields,
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >& /* [out] */ _rRightFields
+ ) const;
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_FORMLINKDIALOG_HXX
diff --git a/extensions/source/propctrlr/formlinkdialog.src b/extensions/source/propctrlr/formlinkdialog.src
new file mode 100644
index 000000000000..2f993fc8efca
--- /dev/null
+++ b/extensions/source/propctrlr/formlinkdialog.src
@@ -0,0 +1,162 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
+#include "formresid.hrc"
+#endif
+#include "propctrlr.hrc"
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_FORMLINKDIALOG_HRC
+#include "formlinkdialog.hrc"
+#endif
+
+ModalDialog RID_DLG_FORMLINKS
+{
+ HelpID = "extensions:ModalDialog:RID_DLG_FORMLINKS";
+ OutputSize = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 252, 110 ) ;
+
+ Text [ en-US ] = "Link fields";
+
+ FixedText FT_EXPLANATION
+ {
+ Pos = MAP_APPFONT( 6, 6 );
+ Size = MAP_APPFONT( 187, 24 );
+
+ WordBreak = TRUE;
+
+ Text [ en-US ] = "Sub forms can be used to display detailed data about the current record of the master form. To do this, you can specify which columns in the sub form match which columns in the master form.";
+ };
+
+ FixedText FT_DETAIL_LABEL
+ {
+ Pos = MAP_APPFONT( 6, 36 );
+ Size = MAP_APPFONT( 85, 8 );
+ };
+
+ FixedText FT_MASTER_LABEL
+ {
+ Pos = MAP_APPFONT( 102, 36 );
+ Size = MAP_APPFONT( 85, 8 );
+ };
+
+#define ROW( n ) \
+ Window n \
+ { \
+ Pos = MAP_APPFONT( 6, 47 + 15 * ( n - 1 ) ); \
+ Size = MAP_APPFONT( 181, 13 ); \
+ \
+ Hide = FALSE; \
+ DialogControl = TRUE; \
+ \
+ ComboBox 1 \
+ { \
+ Pos = MAP_APPFONT( 0, 0 ); \
+ Size = MAP_APPFONT( 85, 12 ); \
+ \
+ DropDown = TRUE; \
+ TabStop = TRUE; \
+ \
+ HelpId = HID_FIELDLINK_DETAIL_COLUMN; \
+ UniqueId = UID_FIELDLINK_DETAIL#n; \
+ }; \
+ FixedText 1 \
+ { \
+ Pos = MAP_APPFONT( 85, 0 ); \
+ Size = MAP_APPFONT( 10, 12 ); \
+ Center = TRUE; \
+ }; \
+ ComboBox 2 \
+ { \
+ Pos = MAP_APPFONT( 95, 0 ); \
+ Size = MAP_APPFONT( 85, 12 ); \
+ \
+ DropDown = TRUE; \
+ TabStop = TRUE; \
+ \
+ HelpId = HID_FIELDLINK_MASTER_COLUMN; \
+ UniqueId = UID_FIELDLINK_MASTER#n; \
+ }; \
+ }
+
+ ROW( 1 );
+ ROW( 2 );
+ ROW( 3 );
+ ROW( 4 );
+
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT( 199, 6 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ DefButton = TRUE;
+ };
+
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT( 199, 23 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ };
+
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT( 199, 43 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ };
+
+ PushButton PB_SUGGEST
+ {
+ HelpID = "extensions:PushButton:RID_DLG_FORMLINKS:PB_SUGGEST";
+ Pos = MAP_APPFONT( 199, 90 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ Hide = FALSE;
+ Disable = TRUE;
+
+ Text [ en-US ] = "Suggest";
+ };
+
+ String STR_DETAIL_FORM
+ {
+ Text [ en-US ] = "Sub Form";
+ };
+
+ String STR_MASTER_FORM
+ {
+ Text [ en-US ] = "Master Form";
+ };
+
+ String STR_ERROR_RETRIEVING_COLUMNS
+ {
+ Text [ en-US ] = "The columns of '#' could not be retrieved.";
+ Text [ x-comment ] ="# will be replace with a name.";
+ };
+};
diff --git a/extensions/source/propctrlr/formlocalid.hrc b/extensions/source/propctrlr/formlocalid.hrc
new file mode 100644
index 000000000000..dca59a024321
--- /dev/null
+++ b/extensions/source/propctrlr/formlocalid.hrc
@@ -0,0 +1,39 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_FORMLOCALID_HRC_
+#define _EXTENSIONS_PROPCTRLR_FORMLOCALID_HRC_
+
+#define TABPAGE_CHARACTERS 1
+#define TABPAGE_CHARACTERS_EXT 2
+
+#define IMG_PLUS 1
+#define IMG_MINUS 2
+#define IMG_PLUS_HC 3
+#define IMG_MINUS_HC 4
+
+#endif // _EXTENSIONS_PROPCTRLR_FORMLOCALID_HRC_
diff --git a/extensions/source/propctrlr/formmetadata.cxx b/extensions/source/propctrlr/formmetadata.cxx
new file mode 100644
index 000000000000..d5dea0841c54
--- /dev/null
+++ b/extensions/source/propctrlr/formmetadata.cxx
@@ -0,0 +1,706 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "formmetadata.hxx"
+#ifndef _EXTENSIONS_FORMCTRLR_FORMHELPID_HRC_
+#include "propctrlr.hrc"
+#endif
+#include "formstrings.hxx"
+#ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
+#include "formresid.hrc"
+#endif
+#include "propctrlr.hrc"
+#include <svtools/localresaccess.hxx>
+#include <tools/debug.hxx>
+#include <comphelper/extract.hxx>
+
+#include <algorithm>
+#include <functional>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star::uno;
+
+ //========================================================================
+ //= OPropertyInfoImpl
+ //========================================================================
+ struct OPropertyInfoImpl
+ {
+ String sName;
+ String sTranslation;
+ rtl::OString sHelpId;
+ sal_Int32 nId;
+ sal_uInt16 nPos;
+ sal_uInt32 nUIFlags;
+
+ OPropertyInfoImpl(
+ const ::rtl::OUString& rName,
+ sal_Int32 _nId,
+ const String& aTranslation,
+ sal_uInt16 nPosId,
+ const rtl::OString&,
+ sal_uInt32 _nUIFlags);
+ };
+
+ //------------------------------------------------------------------------
+ OPropertyInfoImpl::OPropertyInfoImpl(const ::rtl::OUString& _rName, sal_Int32 _nId,
+ const String& aString, sal_uInt16 nP, const rtl::OString& sHid, sal_uInt32 _nUIFlags)
+ :sName(_rName)
+ ,sTranslation(aString)
+ ,sHelpId(sHid)
+ ,nId(_nId)
+ ,nPos(nP)
+ ,nUIFlags(_nUIFlags)
+ {
+ }
+
+ //------------------------------------------------------------------------
+ // Vergleichen von PropertyInfo
+ struct PropertyInfoLessByName : public ::std::binary_function< OPropertyInfoImpl, OPropertyInfoImpl, bool >
+ {
+ bool operator()( const OPropertyInfoImpl& _rLHS, const OPropertyInfoImpl& _rRHS )
+ {
+ return _rLHS.sName.CompareTo( _rRHS.sName ) == COMPARE_LESS;
+ }
+ };
+
+ //========================================================================
+ //= OPropertyInfoService
+ //========================================================================
+#define DEF_INFO( ident, uinameres, helpid, flags ) \
+ OPropertyInfoImpl( PROPERTY_##ident, PROPERTY_ID_##ident, \
+ String( PcrRes( RID_STR_##uinameres ) ), nPos++, HID_PROP_##helpid, flags )
+
+#define DEF_INFO_1( ident, uinameres, helpid, flag1 ) \
+ DEF_INFO( ident, uinameres, helpid, PROP_FLAG_##flag1 )
+
+#define DEF_INFO_2( ident, uinameres, helpid, flag1, flag2 ) \
+ DEF_INFO( ident, uinameres, helpid, PROP_FLAG_##flag1 | PROP_FLAG_##flag2 )
+
+#define DEF_INFO_3( ident, uinameres, helpid, flag1, flag2, flag3 ) \
+ DEF_INFO( ident, uinameres, helpid, PROP_FLAG_##flag1 | PROP_FLAG_##flag2 | PROP_FLAG_##flag3 )
+
+#define DEF_INFO_4( ident, uinameres, helpid, flag1, flag2, flag3, flag4 ) \
+ DEF_INFO( ident, uinameres, helpid, PROP_FLAG_##flag1 | PROP_FLAG_##flag2 | PROP_FLAG_##flag3 | PROP_FLAG_##flag4 )
+
+#define DEF_INFO_5( ident, uinameres, helpid, flag1, flag2, flag3, flag4, flag5 ) \
+ DEF_INFO( ident, uinameres, helpid, PROP_FLAG_##flag1 | PROP_FLAG_##flag2 | PROP_FLAG_##flag3 | PROP_FLAG_##flag4 | PROP_FLAG_##flag5 )
+
+ sal_uInt16 OPropertyInfoService::s_nCount = 0;
+ OPropertyInfoImpl* OPropertyInfoService::s_pPropertyInfos = NULL;
+ //------------------------------------------------------------------------
+ const OPropertyInfoImpl* OPropertyInfoService::getPropertyInfo()
+ {
+ if ( s_pPropertyInfos )
+ return s_pPropertyInfos;
+
+ PcrClient aResourceAccess;
+ // this ensures that we have our resource file loaded
+
+ sal_uInt16 nPos = 1;
+
+ static OPropertyInfoImpl aPropertyInfos[] =
+ {
+ /*
+ DEF_INFO_?( propname and id, resoure id, help id, flags ),
+ */
+ DEF_INFO_3( NAME, NAME, NAME, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( TITLE, TITLE, TITLE, FORM_VISIBLE, DIALOG_VISIBLE ),
+ DEF_INFO_3( LABEL, LABEL, LABEL, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( CONTROLLABEL, LABELCONTROL, CONTROLLABEL, FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( WRITING_MODE, WRITING_MODE, WRITING_MODE, FORM_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_2( TEXT, TEXT, TEXT, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( MAXTEXTLEN, MAXTEXTLEN, MAXTEXTLEN, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( EDITMASK, EDITMASK, EDITMASK, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( LITERALMASK, LITERALMASK, LITERALMASK, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( STRICTFORMAT, STRICTFORMAT, STRICTFORMAT, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( ENABLED, ENABLED, ENABLED, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( ENABLE_VISIBLE, ENABLE_VISIBLE, ENABLE_VISIBLE, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( READONLY, READONLY, READONLY, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( PRINTABLE, PRINTABLE, PRINTABLE, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( STEP, STEP, STEP, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( TABSTOP, TABSTOP, TABSTOP, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( TABINDEX, TABINDEX, TABINDEX, FORM_VISIBLE, DIALOG_VISIBLE ),
+ DEF_INFO_3( WHEEL_BEHAVIOR, WHEEL_BEHAVIOR, WHEEL_BEHAVIOR, FORM_VISIBLE, ENUM, COMPOSEABLE ),
+
+ DEF_INFO_2( BOUND_CELL, BOUND_CELL, BOUND_CELL, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_3( CELL_EXCHANGE_TYPE,CELL_EXCHANGE_TYPE, CELL_EXCHANGE_TYPE,FORM_VISIBLE, DATA_PROPERTY, ENUM ),
+ DEF_INFO_2( LIST_CELL_RANGE, LIST_CELL_RANGE, LIST_CELL_RANGE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_3( CONTROLSOURCE, CONTROLSOURCE, CONTROLSOURCE, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_3( EMPTY_IS_NULL, EMPTY_IS_NULL, EMPTY_IS_NULL, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_3( INPUT_REQUIRED, INPUT_REQUIRED, INPUT_REQUIRED, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_3( REFVALUE, REFVALUE, REFVALUE, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_3( UNCHECKEDREFVALUE, UNCHECKEDREFVALUE, UNCHECKEDREFVALUE, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_3( DATASOURCE, DATASOURCE, DATASOURCE, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_4( COMMANDTYPE, CURSORSOURCETYPE, CURSORSOURCETYPE, FORM_VISIBLE, DATA_PROPERTY, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( COMMAND, CURSORSOURCE, CURSORSOURCE, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_3( ESCAPE_PROCESSING, ESCAPE_PROCESSING, ESCAPE_PROCESSING, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_3( FILTER, FILTER, FILTER, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_3( SORT, SORT_CRITERIA, SORT_CRITERIA, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_2( MASTERFIELDS, MASTERFIELDS, MASTERFIELDS, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( DETAILFIELDS, SLAVEFIELDS, SLAVEFIELDS, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_3( ALLOWADDITIONS, ALLOW_ADDITIONS, ALLOW_ADDITIONS, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_3( ALLOWEDITS, ALLOW_EDITS, ALLOW_EDITS, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_3( ALLOWDELETIONS, ALLOW_DELETIONS, ALLOW_DELETIONS, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_4( INSERTONLY, DATAENTRY, DATAENTRY, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE, COMPOSEABLE ),
+ DEF_INFO_4( NAVIGATION, NAVIGATION, NAVIGATION, FORM_VISIBLE, DATA_PROPERTY, ENUM, COMPOSEABLE ),
+ DEF_INFO_4( CYCLE, CYCLE, CYCLE, FORM_VISIBLE, DATA_PROPERTY, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( FILTERPROPOSAL, FILTERPROPOSAL, FILTERPROPOSAL, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_4( LISTSOURCETYPE, LISTSOURCETYPE, LISTSOURCETYPE, FORM_VISIBLE, DATA_PROPERTY, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( LISTSOURCE, LISTSOURCE, LISTSOURCE, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_3( BOUNDCOLUMN, BOUNDCOLUMN, BOUNDCOLUMN, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+
+ // <!----------------->
+ // XML node binding
+ DEF_INFO_2( LIST_BINDING, LIST_BINDING, LIST_BINDING, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XML_DATA_MODEL, XML_DATA_MODEL, XML_DATA_MODEL, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( BINDING_NAME, BINDING_NAME, BINDING_NAME, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( BIND_EXPRESSION, BIND_EXPRESSION, BIND_EXPRESSION, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_REQUIRED, XSD_REQUIRED, XSD_REQUIRED, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_RELEVANT, XSD_RELEVANT, XSD_RELEVANT, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_READONLY, XSD_READONLY, XSD_READONLY, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_CONSTRAINT, XSD_CONSTRAINT, XSD_CONSTRAINT, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_CALCULATION, XSD_CALCULATION, XSD_CALCULATION, FORM_VISIBLE, DATA_PROPERTY ),
+
+ // data type
+ DEF_INFO_2( XSD_DATA_TYPE, XSD_DATA_TYPE, XSD_DATA_TYPE, FORM_VISIBLE, DATA_PROPERTY ),
+ // data types facets
+ // common
+ DEF_INFO_3( XSD_WHITESPACES, XSD_WHITESPACES, XSD_WHITESPACES, FORM_VISIBLE, DATA_PROPERTY, ENUM ),
+ DEF_INFO_2( XSD_PATTERN, XSD_PATTERN, XSD_PATTERN, FORM_VISIBLE, DATA_PROPERTY ),
+ // string
+ DEF_INFO_2( XSD_LENGTH, XSD_LENGTH, XSD_LENGTH, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MIN_LENGTH, XSD_MIN_LENGTH, XSD_MIN_LENGTH, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MAX_LENGTH, XSD_MAX_LENGTH, XSD_MAX_LENGTH, FORM_VISIBLE, DATA_PROPERTY ),
+ // decimal
+ DEF_INFO_2( XSD_TOTAL_DIGITS, XSD_TOTAL_DIGITS, XSD_TOTAL_DIGITS, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_FRACTION_DIGITS,XSD_FRACTION_DIGITS,XSD_FRACTION_DIGITS,FORM_VISIBLE, DATA_PROPERTY ),
+ // int value types (year, month, day)
+ DEF_INFO_2( XSD_MAX_INCLUSIVE_INT, XSD_MAX_INCLUSIVE, XSD_MAX_INCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MAX_EXCLUSIVE_INT, XSD_MAX_EXCLUSIVE, XSD_MAX_EXCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MIN_INCLUSIVE_INT, XSD_MIN_INCLUSIVE, XSD_MIN_INCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MIN_EXCLUSIVE_INT, XSD_MIN_EXCLUSIVE, XSD_MIN_EXCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ // double value types (double, float, decimal)
+ DEF_INFO_2( XSD_MAX_INCLUSIVE_DOUBLE, XSD_MAX_INCLUSIVE, XSD_MAX_INCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MAX_EXCLUSIVE_DOUBLE, XSD_MAX_EXCLUSIVE, XSD_MAX_EXCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MIN_INCLUSIVE_DOUBLE, XSD_MIN_INCLUSIVE, XSD_MIN_INCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MIN_EXCLUSIVE_DOUBLE, XSD_MIN_EXCLUSIVE, XSD_MIN_EXCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ // date value type
+ DEF_INFO_2( XSD_MAX_INCLUSIVE_DATE, XSD_MAX_INCLUSIVE, XSD_MAX_INCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MAX_EXCLUSIVE_DATE, XSD_MAX_EXCLUSIVE, XSD_MAX_EXCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MIN_INCLUSIVE_DATE, XSD_MIN_INCLUSIVE, XSD_MIN_INCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MIN_EXCLUSIVE_DATE, XSD_MIN_EXCLUSIVE, XSD_MIN_EXCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ // time value type
+ DEF_INFO_2( XSD_MAX_INCLUSIVE_TIME, XSD_MAX_INCLUSIVE, XSD_MAX_INCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MAX_EXCLUSIVE_TIME, XSD_MAX_EXCLUSIVE, XSD_MAX_EXCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MIN_INCLUSIVE_TIME, XSD_MIN_INCLUSIVE, XSD_MIN_INCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MIN_EXCLUSIVE_TIME, XSD_MIN_EXCLUSIVE, XSD_MIN_EXCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ // dateTime value type
+ DEF_INFO_2( XSD_MAX_INCLUSIVE_DATE_TIME, XSD_MAX_INCLUSIVE, XSD_MAX_INCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MAX_EXCLUSIVE_DATE_TIME, XSD_MAX_EXCLUSIVE, XSD_MAX_EXCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MIN_INCLUSIVE_DATE_TIME, XSD_MIN_INCLUSIVE, XSD_MIN_INCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MIN_EXCLUSIVE_DATE_TIME, XSD_MIN_EXCLUSIVE, XSD_MIN_EXCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ // <!----------------->
+
+ DEF_INFO_2( HIDDEN_VALUE, VALUE, HIDDEN_VALUE, FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( VALUE, VALUE, VALUE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( VALUEMIN, VALUEMIN, VALUEMIN, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( VALUEMAX, VALUEMAX, VALUEMAX, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( VALUESTEP, VALUESTEP, VALUESTEP, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( DEFAULT_VALUE, DEFAULTVALUE, DEFAULT_LONG_VALUE,FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( DECIMAL_ACCURACY, DECIMAL_ACCURACY, DECIMAL_ACCURACY, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( SHOWTHOUSANDSEP, SHOWTHOUSANDSEP, SHOWTHOUSANDSEP, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+
+ DEF_INFO_3( CURRENCYSYMBOL, CURRENCYSYMBOL, CURRENCYSYMBOL, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( CURRSYM_POSITION, CURRSYM_POSITION, CURRSYM_POSITION, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+
+ DEF_INFO_2( DATE, DATE, DATE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( DATEMIN, DATEMIN, DATEMIN, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( DATEMAX, DATEMAX, DATEMAX, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_4( DATEFORMAT, DATEFORMAT, DATEFORMAT, FORM_VISIBLE, DIALOG_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_2( DEFAULT_DATE, DEFAULTDATE, DEFAULT_DATE, FORM_VISIBLE, COMPOSEABLE ),
+
+ DEF_INFO_2( TIME, TIME, TIME, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( TIMEMIN, TIMEMIN, TIMEMIN, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( TIMEMAX, TIMEMAX, TIMEMAX, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_4( TIMEFORMAT, TIMEFORMAT, TIMEFORMAT, FORM_VISIBLE, DIALOG_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_2( DEFAULT_TIME, DEFAULTTIME, DEFAULT_TIME, FORM_VISIBLE, COMPOSEABLE ),
+
+ DEF_INFO_1( EFFECTIVE_VALUE, VALUE, VALUE, DIALOG_VISIBLE ),
+ DEF_INFO_3( EFFECTIVE_MIN, VALUEMIN, EFFECTIVEMIN, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( EFFECTIVE_MAX, VALUEMAX, EFFECTIVEMAX, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( EFFECTIVE_DEFAULT, DEFAULTVALUE, EFFECTIVEDEFAULT, FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( FORMATKEY, FORMATKEY, FORMATKEY, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+
+ DEF_INFO_3( PROGRESSVALUE, PROGRESSVALUE, PROGRESSVALUE, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( PROGRESSVALUE_MIN, PROGRESSVALUE_MIN, PROGRESSVALUE_MIN, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( PROGRESSVALUE_MAX, PROGRESSVALUE_MAX, PROGRESSVALUE_MAX, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+
+ DEF_INFO_2( SCROLLVALUE, SCROLLVALUE, SCROLLVALUE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( SCROLLVALUE_MIN, SCROLLVALUE_MIN, SCROLLVALUE_MIN, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( SCROLLVALUE_MAX, SCROLLVALUE_MAX, SCROLLVALUE_MAX, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( DEFAULT_SCROLLVALUE,DEFAULT_SCROLLVALUE,DEFAULT_SCROLLVALUE,FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( LINEINCREMENT, LINEINCREMENT, LINEINCREMENT, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( BLOCKINCREMENT, BLOCKINCREMENT, BLOCKINCREMENT, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+
+ DEF_INFO_2( SPINVALUE, VALUE, SPINVALUE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( SPINVALUE_MIN, VALUEMIN, SPINVALUE_MIN, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( SPINVALUE_MAX, VALUEMAX, SPINVALUE_MAX, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( DEFAULT_SPINVALUE,DEFAULTVALUE, DEFAULT_SPINVALUE, FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( SPININCREMENT, VALUESTEP, SPININCREMENT, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+
+ DEF_INFO_3( SPIN, SPIN, SPIN, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( REPEAT, REPEAT, REPEAT, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( REPEAT_DELAY, REPEAT_DELAY, REPEAT_DELAY, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( VISIBLESIZE, VISIBLESIZE, VISIBLESIZE, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_4( ORIENTATION, ORIENTATION, ORIENTATION, FORM_VISIBLE, DIALOG_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( FOCUSONCLICK, FOCUSONCLICK, FOCUSONCLICK, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( TOGGLE, TOGGLE, TOGGLE, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( DEFAULT_STATE, DEFAULT_STATE, DEFAULT_STATE, FORM_VISIBLE, ENUM, COMPOSEABLE ),
+
+ DEF_INFO_3( TEXT_ANCHOR_TYPE, ANCHOR_TYPE, ANCHOR_TYPE, FORM_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( SHEET_ANCHOR_TYPE, ANCHOR_TYPE, ANCHOR_TYPE, FORM_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( POSITIONX, POSITIONX, POSITIONX, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( POSITIONY, POSITIONY, POSITIONY, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( WIDTH, WIDTH, WIDTH, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( HEIGHT, HEIGHT, HEIGHT, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+
+ DEF_INFO_1( LISTINDEX, LISTINDEX, LISTINDEX, FORM_VISIBLE ),
+ DEF_INFO_3( STRINGITEMLIST, STRINGITEMLIST, STRINGITEMLIST, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( DEFAULT_TEXT, DEFAULTTEXT, DEFAULTVALUE, FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( FONT, FONT, FONT, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_4( VISUALEFFECT, VISUALEFFECT, VISUALEFFECT, FORM_VISIBLE, DIALOG_VISIBLE, ENUM_ONE, COMPOSEABLE ),
+ DEF_INFO_4( ALIGN, ALIGN, ALIGN, FORM_VISIBLE, DIALOG_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( VERTICAL_ALIGN, VERTICAL_ALIGN, VERTICAL_ALIGN, FORM_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( ROWHEIGHT, ROWHEIGHT, ROWHEIGHT, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( BACKGROUNDCOLOR, BACKGROUNDCOLOR, BACKGROUNDCOLOR, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( SYMBOLCOLOR, SYMBOLCOLOR, SYMBOLCOLOR, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( FILLCOLOR, FILLCOLOR, FILLCOLOR, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( LINECOLOR, LINECOLOR, LINECOLOR, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_4( BORDER, BORDER, BORDER, FORM_VISIBLE, DIALOG_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( BORDERCOLOR, BORDERCOLOR, BORDERCOLOR, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( ICONSIZE, ICONSIZE, ICONSIZE, FORM_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_2( SHOW_POSITION, SHOW_POSITION, SHOW_POSITION, FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( SHOW_NAVIGATION, SHOW_NAVIGATION, SHOW_NAVIGATION, FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( SHOW_RECORDACTIONS,SHOW_RECORDACTIONS, SHOW_RECORDACTIONS,FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( SHOW_FILTERSORT, SHOW_FILTERSORT, SHOW_FILTERSORT, FORM_VISIBLE, COMPOSEABLE ),
+
+ DEF_INFO_3( DROPDOWN, DROPDOWN, DROPDOWN, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( LINECOUNT, LINECOUNT, LINECOUNT, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( AUTOCOMPLETE, AUTOCOMPLETE, AUTOCOMPLETE, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( MULTILINE, MULTILINE, MULTILINE, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( WORDBREAK, WORDBREAK, WORDBREAK, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( TEXTTYPE, TEXTTYPE, TEXTTYPE, FORM_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( LINEEND_FORMAT, LINEEND_FORMAT, LINEEND_FORMAT, FORM_VISIBLE, ENUM_ONE, COMPOSEABLE ),
+ DEF_INFO_3( MULTISELECTION, MULTISELECTION, MULTISELECTION, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_4( SHOW_SCROLLBARS, SHOW_SCROLLBARS, SHOW_SCROLLBARS, FORM_VISIBLE, DIALOG_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( HSCROLL, HSCROLL, HSCROLL, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( VSCROLL, VSCROLL, VSCROLL, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( BUTTONTYPE, BUTTONTYPE, BUTTONTYPE, FORM_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_2( XFORMS_BUTTONTYPE, BUTTONTYPE, BUTTONTYPE, FORM_VISIBLE, ENUM ),
+ DEF_INFO_1( SUBMISSION_ID, SUBMISSION_ID, SUBMISSION_ID, FORM_VISIBLE ),
+ DEF_INFO_2( PUSHBUTTONTYPE, PUSHBUTTONTYPE, PUSHBUTTONTYPE, DIALOG_VISIBLE, ENUM ),
+ DEF_INFO_2( TARGET_URL, TARGET_URL, TARGET_URL, FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_1( TARGET_FRAME, TARGET_FRAME, TARGET_FRAME, FORM_VISIBLE ),
+ DEF_INFO_2( SUBMIT_ACTION, SUBMIT_ACTION, SUBMIT_ACTION, FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( SUBMIT_TARGET, SUBMIT_TARGET, SUBMIT_TARGET, FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( SUBMIT_ENCODING, SUBMIT_ENCODING, SUBMIT_ENCODING, FORM_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( SUBMIT_METHOD, SUBMIT_METHOD, SUBMIT_METHOD, FORM_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( STATE, STATE, STATE, DIALOG_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( DEFAULTBUTTON, DEFAULT_BUTTON, DEFAULT_BUTTON, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( IMAGE_URL, IMAGE_URL, IMAGE_URL, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_4( IMAGEPOSITION, IMAGEPOSITION, IMAGEPOSITION, FORM_VISIBLE, DIALOG_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( SCALEIMAGE, SCALEIMAGE, SCALEIMAGE, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_4( SCALE_MODE, SCALEIMAGE, SCALEIMAGE, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE, ENUM ),
+ DEF_INFO_2( DEFAULT_SELECT_SEQ,DEFAULT_SELECT_SEQ, DEFAULT_SELECT_SEQ,FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( SELECTEDITEMS, SELECTEDITEMS, SELECTEDITEMS, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( ECHO_CHAR, ECHO_CHAR, ECHO_CHAR, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( HIDEINACTIVESELECTION, HIDEINACTIVESELECTION, HIDEINACTIVESELECTION, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( TRISTATE, TRISTATE, TRISTATE, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( HASNAVIGATION, NAVIGATION, NAVIGATIONBAR, FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( RECORDMARKER, RECORDMARKER, RECORDMARKER, FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( TAG, TAG, TAG, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( HELPTEXT, HELPTEXT, HELPTEXT, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( HELPURL, HELPURL, HELPURL, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( SELECTION_TYPE, SELECTION_TYPE, SELECTION_TYPE, DIALOG_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_2( ROOT_DISPLAYED, ROOT_DISPLAYED, ROOT_DISPLAYED, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( SHOWS_HANDLES, SHOWS_HANDLES, SHOWS_HANDLES, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( SHOWS_ROOT_HANDLES, SHOWS_ROOT_HANDLES, SHOWS_ROOT_HANDLES, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( EDITABLE, EDITABLE, EDITABLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( INVOKES_STOP_NOT_EDITING, INVOKES_STOP_NOT_EDITING, INVOKES_STOP_NOT_EDITING, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( DECORATION, DECORATION, DECORATION, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( NOLABEL, NOLABEL, NOLABEL, DIALOG_VISIBLE, COMPOSEABLE )
+ };
+
+ s_pPropertyInfos = aPropertyInfos;
+ s_nCount = sizeof(aPropertyInfos) / sizeof(OPropertyInfoImpl);
+
+ // sort
+ ::std::sort( s_pPropertyInfos, s_pPropertyInfos + s_nCount, PropertyInfoLessByName() );
+
+#if OSL_DEBUG_LEVEL > 0
+ for ( const OPropertyInfoImpl* pCheck = s_pPropertyInfos; pCheck != s_pPropertyInfos + s_nCount - 1; ++pCheck )
+ {
+ OSL_ENSURE( pCheck->sName != ( pCheck + 1 )->sName, "OPropertyInfoService::getPropertyInfo: duplicate entry in the table!" );
+ }
+#endif
+
+ return s_pPropertyInfos;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Int32 OPropertyInfoService::getPropertyId(const String& _rName) const
+ {
+ const OPropertyInfoImpl* pInfo = getPropertyInfo(_rName);
+ return pInfo ? pInfo->nId : -1;
+ }
+
+ //------------------------------------------------------------------------
+ String OPropertyInfoService::getPropertyName( sal_Int32 _nPropId )
+ {
+ const OPropertyInfoImpl* pInfo = getPropertyInfo(_nPropId);
+ return pInfo ? pInfo->sName : String();
+ }
+
+ //------------------------------------------------------------------------
+ String OPropertyInfoService::getPropertyTranslation(sal_Int32 _nId) const
+ {
+ const OPropertyInfoImpl* pInfo = getPropertyInfo(_nId);
+ return (pInfo) ? pInfo->sTranslation : String();
+ }
+
+ //------------------------------------------------------------------------
+ rtl::OString OPropertyInfoService::getPropertyHelpId(sal_Int32 _nId) const
+ {
+ const OPropertyInfoImpl* pInfo = getPropertyInfo(_nId);
+ return (pInfo) ? pInfo->sHelpId : rtl::OString();
+ }
+
+ //------------------------------------------------------------------------
+ sal_Int16 OPropertyInfoService::getPropertyPos(sal_Int32 _nId) const
+ {
+ const OPropertyInfoImpl* pInfo = getPropertyInfo(_nId);
+ return (pInfo) ? pInfo->nPos : 0xFFFF;
+ }
+
+ //------------------------------------------------------------------------
+ sal_uInt32 OPropertyInfoService::getPropertyUIFlags(sal_Int32 _nId) const
+ {
+ const OPropertyInfoImpl* pInfo = getPropertyInfo(_nId);
+ return (pInfo) ? pInfo->nUIFlags : 0;
+ }
+
+ //------------------------------------------------------------------------
+ ::std::vector< ::rtl::OUString > OPropertyInfoService::getPropertyEnumRepresentations(sal_Int32 _nId) const
+ {
+ OSL_ENSURE( ( ( getPropertyUIFlags( _nId ) & PROP_FLAG_ENUM ) != 0 ) || ( _nId == PROPERTY_ID_TARGET_FRAME ),
+ "OPropertyInfoService::getPropertyEnumRepresentations: this is no enum property!" );
+
+ sal_Int16 nStringItemsResId = 0;
+ switch ( _nId )
+ {
+ case PROPERTY_ID_IMAGEPOSITION:
+ nStringItemsResId = RID_RSC_ENUM_IMAGE_POSITION;
+ break;
+ case PROPERTY_ID_BORDER:
+ nStringItemsResId = RID_RSC_ENUM_BORDER_TYPE;
+ break;
+ case PROPERTY_ID_ICONSIZE:
+ nStringItemsResId = RID_RSC_ENUM_ICONSIZE_TYPE;
+ break;
+ case PROPERTY_ID_COMMANDTYPE:
+ nStringItemsResId = RID_RSC_ENUM_COMMAND_TYPE;
+ break;
+ case PROPERTY_ID_LISTSOURCETYPE:
+ nStringItemsResId = RID_RSC_ENUM_LISTSOURCE_TYPE;
+ break;
+ case PROPERTY_ID_ALIGN:
+ nStringItemsResId = RID_RSC_ENUM_ALIGNMENT;
+ break;
+ case PROPERTY_ID_VERTICAL_ALIGN:
+ nStringItemsResId = RID_RSC_ENUM_VERTICAL_ALIGN;
+ break;
+ case PROPERTY_ID_BUTTONTYPE:
+ nStringItemsResId = RID_RSC_ENUM_BUTTONTYPE;
+ break;
+ case PROPERTY_ID_PUSHBUTTONTYPE:
+ nStringItemsResId = RID_RSC_ENUM_PUSHBUTTONTYPE;
+ break;
+ case PROPERTY_ID_SUBMIT_METHOD:
+ nStringItemsResId = RID_RSC_ENUM_SUBMIT_METHOD;
+ break;
+ case PROPERTY_ID_SUBMIT_ENCODING:
+ nStringItemsResId = RID_RSC_ENUM_SUBMIT_ENCODING;
+ break;
+ case PROPERTY_ID_DATEFORMAT:
+ nStringItemsResId = RID_RSC_ENUM_DATEFORMAT_LIST;
+ break;
+ case PROPERTY_ID_TIMEFORMAT:
+ nStringItemsResId = RID_RSC_ENUM_TIMEFORMAT_LIST;
+ break;
+ case PROPERTY_ID_DEFAULT_STATE:
+ case PROPERTY_ID_STATE:
+ nStringItemsResId = RID_RSC_ENUM_CHECKED;
+ break;
+ case PROPERTY_ID_CYCLE:
+ nStringItemsResId = RID_RSC_ENUM_CYCLE;
+ break;
+ case PROPERTY_ID_NAVIGATION:
+ nStringItemsResId = RID_RSC_ENUM_NAVIGATION;
+ break;
+ case PROPERTY_ID_TARGET_FRAME:
+ nStringItemsResId = RID_RSC_ENUM_SUBMIT_TARGET;
+ break;
+ case PROPERTY_ID_ORIENTATION:
+ nStringItemsResId = RID_RSC_ENUM_ORIENTATION;
+ break;
+ case PROPERTY_ID_CELL_EXCHANGE_TYPE:
+ nStringItemsResId = RID_RSC_ENUM_CELL_EXCHANGE_TYPE;
+ break;
+ case PROPERTY_ID_SHOW_SCROLLBARS:
+ nStringItemsResId = RID_RSC_ENUM_SCROLLBARS;
+ break;
+ case PROPERTY_ID_VISUALEFFECT:
+ nStringItemsResId = RID_RSC_ENUM_VISUALEFFECT;
+ break;
+ case PROPERTY_ID_TEXTTYPE:
+ nStringItemsResId = RID_RSC_ENUM_TEXTTYPE;
+ break;
+ case PROPERTY_ID_LINEEND_FORMAT:
+ nStringItemsResId = RID_RSC_ENUM_LINEEND_FORMAT;
+ break;
+ case PROPERTY_ID_XSD_WHITESPACES:
+ nStringItemsResId = RID_RSC_ENUM_WHITESPACE_HANDLING;
+ break;
+ case PROPERTY_ID_SELECTION_TYPE:
+ nStringItemsResId = RID_RSC_ENUM_SELECTION_TYPE;
+ break;
+ case PROPERTY_ID_SCALE_MODE:
+ nStringItemsResId = RID_RSC_ENUM_SCALE_MODE;
+ break;
+ case PROPERTY_ID_WRITING_MODE:
+ nStringItemsResId = RID_RSC_ENUM_WRITING_MODE;
+ break;
+ case PROPERTY_ID_WHEEL_BEHAVIOR:
+ nStringItemsResId = RID_RSC_ENUM_WHEEL_BEHAVIOR;
+ break;
+ case PROPERTY_ID_TEXT_ANCHOR_TYPE:
+ nStringItemsResId = RID_RSC_ENUM_TEXT_ANCHOR_TYPE;
+ break;
+ case PROPERTY_ID_SHEET_ANCHOR_TYPE:
+ nStringItemsResId = RID_RSC_ENUM_SHEET_ANCHOR_TYPE;
+ break;
+ default:
+ OSL_ENSURE( sal_False, "OPropertyInfoService::getPropertyEnumRepresentations: unknown enum property!" );
+ break;
+ }
+
+ ::std::vector< ::rtl::OUString > aReturn;
+
+ if ( nStringItemsResId )
+ {
+ PcrRes aResId( nStringItemsResId );
+ ::svt::OLocalResourceAccess aEnumStrings( aResId, RSC_RESOURCE );
+
+ sal_Int16 i = 1;
+ PcrRes aLocalId( i );
+ while ( aEnumStrings.IsAvailableRes( aLocalId.SetRT( RSC_STRING ) ) )
+ {
+ aReturn.push_back( String( aLocalId ) );
+ aLocalId = PcrRes( ++i );
+ }
+ }
+
+ return aReturn;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool OPropertyInfoService::isComposeable( const ::rtl::OUString& _rPropertyName ) const
+ {
+ sal_Int32 nId = getPropertyId( _rPropertyName );
+ if ( nId == -1 )
+ return sal_False;
+
+ sal_uInt32 nFlags = getPropertyUIFlags( nId );
+ return ( nFlags & PROP_FLAG_COMPOSEABLE ) != 0;
+ }
+
+ //------------------------------------------------------------------------
+ const OPropertyInfoImpl* OPropertyInfoService::getPropertyInfo(const String& _rName)
+ {
+ // intialisierung
+ if(!s_pPropertyInfos)
+ getPropertyInfo();
+ OPropertyInfoImpl aSearch(_rName, 0L, String(), 0, "", 0);
+
+ const OPropertyInfoImpl* pInfo = ::std::lower_bound(
+ s_pPropertyInfos, s_pPropertyInfos + s_nCount, aSearch, PropertyInfoLessByName() );
+
+ if ( pInfo == s_pPropertyInfos + s_nCount )
+ return NULL;
+
+ if ( pInfo->sName != _rName )
+ return NULL;
+
+ return pInfo;
+ }
+
+
+ //------------------------------------------------------------------------
+ const OPropertyInfoImpl* OPropertyInfoService::getPropertyInfo(sal_Int32 _nId)
+ {
+ // intialisierung
+ if(!s_pPropertyInfos)
+ getPropertyInfo();
+
+ // TODO: a real structure which allows quick access by name as well as by id
+ for (sal_uInt16 i = 0; i < s_nCount; i++)
+ if (s_pPropertyInfos[i].nId == _nId)
+ return &s_pPropertyInfos[i];
+
+ return NULL;
+ }
+
+ //====================================================================
+ //= DefaultEnumRepresentation
+ //====================================================================
+ DBG_NAME( DefaultEnumRepresentation )
+ //--------------------------------------------------------------------
+ DefaultEnumRepresentation::DefaultEnumRepresentation( const IPropertyInfoService& _rInfo, const Type& _rType, sal_Int32 _nPropertyId )
+ :m_refCount( 0 )
+ ,m_rMetaData( _rInfo )
+ ,m_aType( _rType )
+ ,m_nPropertyId( _nPropertyId )
+ {
+ DBG_CTOR( DefaultEnumRepresentation, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ DefaultEnumRepresentation::~DefaultEnumRepresentation()
+ {
+ DBG_DTOR( DefaultEnumRepresentation, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ ::std::vector< ::rtl::OUString > SAL_CALL DefaultEnumRepresentation::getDescriptions() const
+ {
+ return m_rMetaData.getPropertyEnumRepresentations( m_nPropertyId );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DefaultEnumRepresentation::getValueFromDescription( const ::rtl::OUString& _rDescription, Any& _out_rValue ) const
+ {
+ sal_uInt32 nPropertyUIFlags = m_rMetaData.getPropertyUIFlags( m_nPropertyId );
+ ::std::vector< ::rtl::OUString > aEnumStrings = m_rMetaData.getPropertyEnumRepresentations( m_nPropertyId );
+ ::std::vector< ::rtl::OUString >::const_iterator pos = ::std::find( aEnumStrings.begin(), aEnumStrings.end(), _rDescription );
+ if ( pos != aEnumStrings.end() )
+ {
+ sal_Int32 nPos = pos - aEnumStrings.begin();
+ if ( ( nPropertyUIFlags & PROP_FLAG_ENUM_ONE ) == PROP_FLAG_ENUM_ONE )
+ // enum value starting with 1
+ ++nPos;
+
+ switch ( m_aType.getTypeClass() )
+ {
+ case TypeClass_ENUM:
+ _out_rValue = ::cppu::int2enum( nPos, m_aType );
+ break;
+
+ case TypeClass_SHORT:
+ _out_rValue <<= (sal_Int16)nPos;
+ break;
+
+ case TypeClass_UNSIGNED_SHORT:
+ _out_rValue <<= (sal_uInt16)nPos;
+ break;
+
+ case TypeClass_UNSIGNED_LONG:
+ _out_rValue <<= (sal_uInt32)nPos;
+ break;
+
+ default:
+ _out_rValue <<= (sal_Int32)nPos;
+ break;
+ }
+ }
+ else
+ {
+ DBG_ERROR( "DefaultEnumRepresentation::getValueFromDescription: could not translate the enum string!" );
+ _out_rValue.clear();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL DefaultEnumRepresentation::getDescriptionForValue( const Any& _rEnumValue ) const
+ {
+ ::rtl::OUString sReturn;
+ sal_Int32 nIntValue = -1;
+ OSL_VERIFY( ::cppu::enum2int( nIntValue, _rEnumValue ) );
+
+ sal_uInt32 nUIFlags = m_rMetaData.getPropertyUIFlags( m_nPropertyId );
+ if ( ( nUIFlags & PROP_FLAG_ENUM_ONE ) == PROP_FLAG_ENUM_ONE )
+ // enum value starting with 1
+ --nIntValue;
+
+ ::std::vector< ::rtl::OUString > aEnumStrings = m_rMetaData.getPropertyEnumRepresentations( m_nPropertyId );
+ if ( ( nIntValue >= 0 ) && ( nIntValue < (sal_Int32)aEnumStrings.size() ) )
+ {
+ sReturn = aEnumStrings[ nIntValue ];
+ }
+ else
+ {
+ DBG_ERROR( "DefaultEnumRepresentation::getDescriptionForValue: could not translate an enum value" );
+ }
+ return sReturn;
+ }
+
+ //--------------------------------------------------------------------
+ oslInterlockedCount SAL_CALL DefaultEnumRepresentation::acquire()
+ {
+ return osl_incrementInterlockedCount( &m_refCount );
+ }
+
+ //--------------------------------------------------------------------
+ oslInterlockedCount SAL_CALL DefaultEnumRepresentation::release()
+ {
+ if ( 0 == osl_decrementInterlockedCount( &m_refCount ) )
+ {
+ delete this;
+ return 0;
+ }
+ return m_refCount;
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
diff --git a/extensions/source/propctrlr/formmetadata.hxx b/extensions/source/propctrlr/formmetadata.hxx
new file mode 100644
index 000000000000..82a313a70105
--- /dev/null
+++ b/extensions/source/propctrlr/formmetadata.hxx
@@ -0,0 +1,350 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_FORMMETADATA_HXX_
+#define _EXTENSIONS_PROPCTRLR_FORMMETADATA_HXX_
+
+#include "propertyinfo.hxx"
+#ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
+#include "modulepcr.hxx"
+#endif
+#include "enumrepresentation.hxx"
+#include <comphelper/composedprops.hxx>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ struct OPropertyInfoImpl;
+
+ //========================================================================
+ //= OPropertyInfoService
+ //========================================================================
+ class OPropertyInfoService
+ :public IPropertyInfoService
+ ,public ::comphelper::IPropertySetComposerCallback
+ ,public PcrClient
+ {
+ protected:
+ static sal_uInt16 s_nCount;
+ static OPropertyInfoImpl* s_pPropertyInfos;
+ // TODO: a real structure which allows quick access by name as well as by id
+
+ public:
+ // IPropertyInfoService
+ virtual sal_Int32 getPropertyId(const String& _rName) const;
+ virtual String getPropertyTranslation(sal_Int32 _nId) const;
+ virtual rtl::OString getPropertyHelpId(sal_Int32 _nId) const;
+ virtual sal_Int16 getPropertyPos(sal_Int32 _nId) const;
+ virtual sal_uInt32 getPropertyUIFlags(sal_Int32 _nId) const;
+ virtual ::std::vector< ::rtl::OUString > getPropertyEnumRepresentations(sal_Int32 _nId) const;
+ virtual String getPropertyName( sal_Int32 _nPropId );
+
+ // IPropertySetComposerCallback
+ virtual sal_Bool isComposeable( const ::rtl::OUString& _rPropertyName ) const;
+
+ protected:
+ static const OPropertyInfoImpl* getPropertyInfo();
+
+ static const OPropertyInfoImpl* getPropertyInfo(const String& _rName);
+ static const OPropertyInfoImpl* getPropertyInfo(sal_Int32 _nId);
+ };
+
+ //========================================================================
+ //= DefaultEnumRepresentation
+ //========================================================================
+ /** an implementation of the IPropertyEnumRepresentation
+
+ To be used with properties which, in formmetadata.cxx, are declared as ENUM.
+ */
+ class DefaultEnumRepresentation : public IPropertyEnumRepresentation
+ {
+ private:
+ oslInterlockedCount m_refCount;
+ const IPropertyInfoService& m_rMetaData;
+ ::com::sun::star::uno::Type m_aType;
+ const sal_Int32 m_nPropertyId;
+
+ public:
+ /** constructs an instance
+
+ @param _rInfo
+ An instance implementing IPropertyInfoService. Must live at least as
+ long as the DefaultEnumRepresentation should live.
+ */
+ DefaultEnumRepresentation( const IPropertyInfoService& _rInfo, const ::com::sun::star::uno::Type& _rType, sal_Int32 _nPropertyId );
+
+ protected:
+ ~DefaultEnumRepresentation();
+
+ protected:
+ // IPropertyEnumRepresentation implementqation
+ virtual ::std::vector< ::rtl::OUString >
+ SAL_CALL getDescriptions() const;
+ virtual void SAL_CALL getValueFromDescription( const ::rtl::OUString& _rDescription, ::com::sun::star::uno::Any& _out_rValue ) const;
+ virtual ::rtl::OUString SAL_CALL getDescriptionForValue( const ::com::sun::star::uno::Any& _rEnumValue ) const;
+
+ // IReference implementqation
+ virtual oslInterlockedCount SAL_CALL acquire();
+ virtual oslInterlockedCount SAL_CALL release();
+
+ private:
+ DefaultEnumRepresentation(); // never implemented
+ DefaultEnumRepresentation( const DefaultEnumRepresentation& ); // never implemented
+ DefaultEnumRepresentation& operator=( const DefaultEnumRepresentation& ); // never implemented
+ };
+
+ //========================================================================
+ //= UI flags (for all browseable properties)
+ //========================================================================
+
+#define PROP_FLAG_NONE 0x00000000 // no special flag
+#define PROP_FLAG_FORM_VISIBLE 0x00000001 // the property is visible when inspecting a form object
+#define PROP_FLAG_DIALOG_VISIBLE 0x00000002 // the property is visible when inspecting a dialog object
+#define PROP_FLAG_DATA_PROPERTY 0x00000004 // the property is to appear on the "Data" page
+#define PROP_FLAG_ENUM 0x00000020 // the property is some kind of enum property, i.e. its
+ // value is chosen from a fixed list of possible values
+#define PROP_FLAG_ENUM_ONE 0x00000060 // the property is an enum property starting with 1
+ // (note that this includes PROP_FLAG_ENUM)
+#define PROP_FLAG_COMPOSEABLE 0x00000080 // the property is "composeable", i.e. an intersection of property
+ // sets should expose it, if all elements do
+#define PROP_FLAG_EXPERIMENTAL 0x00000100 // the property is experimental, i.e. should not appear in the
+ // UI, unless experimental properties are enabled by a configuraiton
+ // option
+
+ //========================================================================
+ //= property ids (for all browseable properties)
+ //========================================================================
+
+ #define PROPERTY_ID_NAME 1
+ #define PROPERTY_ID_LABEL 2
+ #define PROPERTY_ID_CONTROLLABEL 3
+ #define PROPERTY_ID_MAXTEXTLEN 4
+ #define PROPERTY_ID_EDITMASK 5
+ #define PROPERTY_ID_LITERALMASK 6
+ #define PROPERTY_ID_STRICTFORMAT 7
+ #define PROPERTY_ID_ENABLED 8
+ #define PROPERTY_ID_READONLY 9
+ #define PROPERTY_ID_PRINTABLE 10
+ #define PROPERTY_ID_CONTROLSOURCE 11
+ #define PROPERTY_ID_TABSTOP 12
+ #define PROPERTY_ID_TABINDEX 13
+ #define PROPERTY_ID_DATASOURCE 14
+ #define PROPERTY_ID_COMMAND 15
+ #define PROPERTY_ID_COMMANDTYPE 16
+ #define PROPERTY_ID_FILTER 17
+ #define PROPERTY_ID_SORT 18
+ #define PROPERTY_ID_INSERTONLY 19
+ #define PROPERTY_ID_ALLOWADDITIONS 20
+ #define PROPERTY_ID_ALLOWEDITS 21
+ #define PROPERTY_ID_ALLOWDELETIONS 22
+ #define PROPERTY_ID_NAVIGATION 24
+ #define PROPERTY_ID_CYCLE 25
+ #define PROPERTY_ID_HIDDEN_VALUE 26
+ #define PROPERTY_ID_VALUEMIN 27
+ #define PROPERTY_ID_VALUEMAX 28
+ #define PROPERTY_ID_VALUESTEP 29
+ #define PROPERTY_ID_DEFAULT_VALUE 30
+ #define PROPERTY_ID_DECIMAL_ACCURACY 31
+ #define PROPERTY_ID_SHOWTHOUSANDSEP 32
+ #define PROPERTY_ID_REFVALUE 33
+ #define PROPERTY_ID_CURRENCYSYMBOL 34
+ #define PROPERTY_ID_CURRSYM_POSITION 35
+ #define PROPERTY_ID_DATEMIN 36
+ #define PROPERTY_ID_DATEMAX 37
+ #define PROPERTY_ID_DATEFORMAT 38
+ #define PROPERTY_ID_SELECTEDITEMS 39
+ #define PROPERTY_ID_DEFAULT_DATE 40
+ #define PROPERTY_ID_TIMEMIN 41
+ #define PROPERTY_ID_TIMEMAX 42
+ #define PROPERTY_ID_TIMEFORMAT 43
+ #define PROPERTY_ID_DEFAULT_TIME 44
+ #define PROPERTY_ID_EFFECTIVE_MIN 45
+ #define PROPERTY_ID_EFFECTIVE_MAX 46
+ #define PROPERTY_ID_EFFECTIVE_DEFAULT 47
+ #define PROPERTY_ID_FORMATKEY 48
+ #define PROPERTY_ID_CLASSID 50
+ #define PROPERTY_ID_HEIGHT 51
+ #define PROPERTY_ID_WIDTH 52
+ #define PROPERTY_ID_BOUNDCOLUMN 53
+ #define PROPERTY_ID_LISTSOURCETYPE 54
+ #define PROPERTY_ID_LISTSOURCE 55
+ #define PROPERTY_ID_LISTINDEX 56
+ #define PROPERTY_ID_STRINGITEMLIST 57
+ #define PROPERTY_ID_DEFAULT_TEXT 58
+ #define PROPERTY_ID_FONT 59
+ #define PROPERTY_ID_ALIGN 60
+ #define PROPERTY_ID_ROWHEIGHT 61
+ #define PROPERTY_ID_BACKGROUNDCOLOR 62
+ #define PROPERTY_ID_FILLCOLOR 63
+ #define PROPERTY_ID_ESCAPE_PROCESSING 64
+ #define PROPERTY_ID_LINECOLOR 65
+ #define PROPERTY_ID_BORDER 66
+ #define PROPERTY_ID_DROPDOWN 67
+ #define PROPERTY_ID_AUTOCOMPLETE 68
+ #define PROPERTY_ID_LINECOUNT 69
+ #define PROPERTY_ID_WORDBREAK 70
+ #define PROPERTY_ID_MULTILINE 71
+ #define PROPERTY_ID_MULTISELECTION 72
+ #define PROPERTY_ID_AUTOLINEBREAK 73
+ #define PROPERTY_ID_HSCROLL 74
+ #define PROPERTY_ID_VSCROLL 75
+ #define PROPERTY_ID_SPIN 76
+ #define PROPERTY_ID_BUTTONTYPE 77
+ #define PROPERTY_ID_TARGET_URL 78
+ #define PROPERTY_ID_TARGET_FRAME 79
+ #define PROPERTY_ID_SUBMIT_ACTION 80
+ #define PROPERTY_ID_SUBMIT_TARGET 81
+ #define PROPERTY_ID_SUBMIT_METHOD 82
+ #define PROPERTY_ID_SUBMIT_ENCODING 83
+ #define PROPERTY_ID_DEFAULT_STATE 84
+ #define PROPERTY_ID_DEFAULTBUTTON 85
+ #define PROPERTY_ID_IMAGE_URL 86
+ #define PROPERTY_ID_DEFAULT_SELECT_SEQ 87
+ #define PROPERTY_ID_ECHO_CHAR 88
+ #define PROPERTY_ID_EMPTY_IS_NULL 89
+ #define PROPERTY_ID_TRISTATE 90
+ #define PROPERTY_ID_MASTERFIELDS 91
+ #define PROPERTY_ID_DETAILFIELDS 92
+ #define PROPERTY_ID_RECORDMARKER 93
+ #define PROPERTY_ID_FILTERPROPOSAL 94
+ #define PROPERTY_ID_TAG 95
+ #define PROPERTY_ID_HELPTEXT 96
+ #define PROPERTY_ID_HELPURL 97
+ #define PROPERTY_ID_HASNAVIGATION 98
+ #define PROPERTY_ID_POSITIONX 99
+ #define PROPERTY_ID_POSITIONY 100
+ #define PROPERTY_ID_TITLE 101
+ #define PROPERTY_ID_STEP 102
+ #define PROPERTY_ID_PROGRESSVALUE 103
+ #define PROPERTY_ID_PROGRESSVALUE_MIN 104
+ #define PROPERTY_ID_PROGRESSVALUE_MAX 105
+ #define PROPERTY_ID_SCROLLVALUE 106
+ #define PROPERTY_ID_SCROLLVALUE_MAX 107
+ #define PROPERTY_ID_LINEINCREMENT 108
+ #define PROPERTY_ID_BLOCKINCREMENT 109
+ #define PROPERTY_ID_VISIBLESIZE 110
+ #define PROPERTY_ID_ORIENTATION 111
+ #define PROPERTY_ID_IMAGEPOSITION 112
+ #define PROPERTY_ID_DATE 113
+ #define PROPERTY_ID_STATE 114
+ #define PROPERTY_ID_TIME 115
+ #define PROPERTY_ID_VALUE 116
+ #define PROPERTY_ID_SCALEIMAGE 117
+ #define PROPERTY_ID_PUSHBUTTONTYPE 118
+ #define PROPERTY_ID_EFFECTIVE_VALUE 119
+ #define PROPERTY_ID_TEXT 120
+ #define PROPERTY_ID_BOUND_CELL 121
+ #define PROPERTY_ID_LIST_CELL_RANGE 122
+ #define PROPERTY_ID_CELL_EXCHANGE_TYPE 123
+ #define PROPERTY_ID_SCROLLVALUE_MIN 124
+ #define PROPERTY_ID_DEFAULT_SCROLLVALUE 125
+ #define PROPERTY_ID_REPEAT_DELAY 126
+ #define PROPERTY_ID_SYMBOLCOLOR 127
+ #define PROPERTY_ID_SPINVALUE 128
+ #define PROPERTY_ID_SPINVALUE_MIN 129
+ #define PROPERTY_ID_SPINVALUE_MAX 130
+ #define PROPERTY_ID_DEFAULT_SPINVALUE 131
+ #define PROPERTY_ID_SPININCREMENT 132
+ #define PROPERTY_ID_REPEAT 133
+ #define PROPERTY_ID_SHOW_SCROLLBARS 134
+ #define PROPERTY_ID_ICONSIZE 135
+ #define PROPERTY_ID_SHOW_POSITION 136
+ #define PROPERTY_ID_SHOW_NAVIGATION 137
+ #define PROPERTY_ID_SHOW_RECORDACTIONS 138
+ #define PROPERTY_ID_SHOW_FILTERSORT 139
+ #define PROPERTY_ID_TEXTTYPE 140
+ #define PROPERTY_ID_LINEEND_FORMAT 141
+ #define PROPERTY_ID_TOGGLE 142
+ #define PROPERTY_ID_FOCUSONCLICK 143
+ #define PROPERTY_ID_HIDEINACTIVESELECTION 144
+ #define PROPERTY_ID_VISUALEFFECT 145
+ #define PROPERTY_ID_BORDERCOLOR 146
+ #define PROPERTY_ID_XML_DATA_MODEL 147
+ #define PROPERTY_ID_BIND_EXPRESSION 148
+ #define PROPERTY_ID_XSD_REQUIRED 149
+ #define PROPERTY_ID_XSD_RELEVANT 150
+ #define PROPERTY_ID_XSD_READONLY 151
+ #define PROPERTY_ID_XSD_CONSTRAINT 152
+ #define PROPERTY_ID_XSD_CALCULATION 153
+ #define PROPERTY_ID_XSD_DATA_TYPE 154
+ #define PROPERTY_ID_XSD_WHITESPACES 155
+ #define PROPERTY_ID_XSD_PATTERN 156
+ #define PROPERTY_ID_XSD_LENGTH 157
+ #define PROPERTY_ID_XSD_MIN_LENGTH 158
+ #define PROPERTY_ID_XSD_MAX_LENGTH 159
+ #define PROPERTY_ID_XSD_TOTAL_DIGITS 160
+ #define PROPERTY_ID_XSD_FRACTION_DIGITS 161
+ #define PROPERTY_ID_XSD_MAX_INCLUSIVE_INT 162
+ #define PROPERTY_ID_XSD_MAX_EXCLUSIVE_INT 163
+ #define PROPERTY_ID_XSD_MIN_INCLUSIVE_INT 164
+ #define PROPERTY_ID_XSD_MIN_EXCLUSIVE_INT 165
+ #define PROPERTY_ID_XSD_MAX_INCLUSIVE_DOUBLE 166
+ #define PROPERTY_ID_XSD_MAX_EXCLUSIVE_DOUBLE 167
+ #define PROPERTY_ID_XSD_MIN_INCLUSIVE_DOUBLE 168
+ #define PROPERTY_ID_XSD_MIN_EXCLUSIVE_DOUBLE 169
+ #define PROPERTY_ID_XSD_MAX_INCLUSIVE_DATE 170
+ #define PROPERTY_ID_XSD_MAX_EXCLUSIVE_DATE 171
+ #define PROPERTY_ID_XSD_MIN_INCLUSIVE_DATE 172
+ #define PROPERTY_ID_XSD_MIN_EXCLUSIVE_DATE 173
+ #define PROPERTY_ID_XSD_MAX_INCLUSIVE_TIME 174
+ #define PROPERTY_ID_XSD_MAX_EXCLUSIVE_TIME 175
+ #define PROPERTY_ID_XSD_MIN_INCLUSIVE_TIME 176
+ #define PROPERTY_ID_XSD_MIN_EXCLUSIVE_TIME 177
+ #define PROPERTY_ID_XSD_MAX_INCLUSIVE_DATE_TIME 178
+ #define PROPERTY_ID_XSD_MAX_EXCLUSIVE_DATE_TIME 179
+ #define PROPERTY_ID_XSD_MIN_INCLUSIVE_DATE_TIME 180
+ #define PROPERTY_ID_XSD_MIN_EXCLUSIVE_DATE_TIME 181
+ #define PROPERTY_ID_UNCHECKEDREFVALUE 182
+ #define PROPERTY_ID_SUBMISSION_ID 183
+ #define PROPERTY_ID_XFORMS_BUTTONTYPE 184
+ #define PROPERTY_ID_LIST_BINDING 185
+ #define PROPERTY_ID_VERTICAL_ALIGN 186
+ #define PROPERTY_ID_BINDING_NAME 187
+ #define PROPERTY_ID_DECORATION 188
+ #define PROPERTY_ID_SELECTION_TYPE 189
+ #define PROPERTY_ID_ROOT_DISPLAYED 190
+ #define PROPERTY_ID_SHOWS_HANDLES 191
+ #define PROPERTY_ID_SHOWS_ROOT_HANDLES 192
+ #define PROPERTY_ID_EDITABLE 193
+ #define PROPERTY_ID_INVOKES_STOP_NOT_EDITING 194
+ #define PROPERTY_ID_NOLABEL 195
+ #define PROPERTY_ID_SCALE_MODE 196
+ #define PROPERTY_ID_INPUT_REQUIRED 197
+ #define PROPERTY_ID_WRITING_MODE 198
+ #define PROPERTY_ID_ENABLE_VISIBLE 199
+ #define PROPERTY_ID_WHEEL_BEHAVIOR 200
+ #define PROPERTY_ID_TEXT_ANCHOR_TYPE 201
+ #define PROPERTY_ID_SHEET_ANCHOR_TYPE 202
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_FORMMETADATA_HXX_
+
diff --git a/extensions/source/propctrlr/formres.src b/extensions/source/propctrlr/formres.src
new file mode 100644
index 000000000000..1daadd6e0f01
--- /dev/null
+++ b/extensions/source/propctrlr/formres.src
@@ -0,0 +1,1523 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_PROPRESID_HRC
+#include "formresid.hrc"
+#endif
+#ifndef _EXTENSIONS_PROPCTRLR_FORMLOCALID_HRC_
+#include "formlocalid.hrc"
+#endif
+
+String RID_STR_EDITMASK
+{
+ Text [ en-US ] = "Edit mask" ;
+};
+String RID_STR_LITERALMASK
+{
+ Text [ en-US ] = "Literal mask" ;
+};
+String RID_STR_READONLY
+{
+ Text [ en-US ] = "Read-only" ;
+};
+String RID_STR_ENABLED
+{
+ Text [ en-US ] = "Enabled" ;
+};
+String RID_STR_ENABLE_VISIBLE
+{
+ Text [ en-US ] = "Visible" ;
+};
+String RID_STR_AUTOCOMPLETE
+{
+ Text [ en-US ] = "AutoFill" ;
+};
+String RID_STR_LINECOUNT
+{
+ Text [ en-US ] = "Line count" ;
+};
+String RID_STR_MAXTEXTLEN
+{
+ Text [ en-US ] = "Max. text length" ;
+};
+String RID_STR_SPIN
+{
+ Text [ en-US ] = "Spin Button" ;
+};
+String RID_STR_STRICTFORMAT
+{
+ Text [ en-US ] = "Strict format" ;
+};
+String RID_STR_SHOWTHOUSANDSEP
+{
+ Text [ en-US ] = "Thousands separator" ;
+};
+String RID_STR_PRINTABLE
+{
+ Text [ en-US ] = "Printable" ;
+};
+String RID_STR_TARGET_URL
+{
+ Text [ en-US ] = "URL" ;
+};
+String RID_STR_TARGET_FRAME
+{
+ Text [ en-US ] = "Frame" ;
+};
+String RID_STR_HELPTEXT
+{
+ Text [ en-US ] = "Help text" ;
+};
+String RID_STR_HELPURL
+{
+ Text [ en-US ] = "Help URL";
+};
+String RID_STR_TAG
+{
+ Text [ en-US ] = "Additional information" ;
+};
+String RID_STR_ECHO_CHAR
+{
+ Text [ en-US ] = "Password character" ;
+};
+
+String RID_STR_TRISTATE
+{
+ Text [ en-US ] = "Tristate" ;
+};
+String RID_STR_EMPTY_IS_NULL
+{
+ Text [ en-US ] = "Empty string is NULL" ;
+};
+String RID_STR_DECIMAL_ACCURACY
+{
+ Text [ en-US ] = "Decimal accuracy" ;
+};
+String RID_STR_IMAGE_URL
+{
+ Text [ en-US ] = "Graphics" ;
+};
+String RID_STR_DEFAULT_SELECT_SEQ
+{
+ Text [ en-US ] = "Default selection" ;
+};
+String RID_STR_DEFAULT_BUTTON
+{
+ Text [ en-US ] = "Default button" ;
+};
+String RID_STR_LABELCONTROL
+{
+ Text [ en-US ] = "Label Field";
+};
+String RID_STR_LABEL
+{
+ Text [ en-US ] = "Label" ;
+};
+String RID_STR_ALIGN
+{
+ Text [ en-US ] = "Alignment" ;
+};
+String RID_STR_VERTICAL_ALIGN
+{
+ Text [ en-US ] = "Vert. Alignment" ;
+};
+Resource RID_RSC_ENUM_VERTICAL_ALIGN
+{
+ String 1
+ {
+ Text [ en-US ] = "Top";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Middle";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Bottom";
+ };
+};
+String RID_STR_IMAGEPOSITION
+{
+ Text [ en-US ] = "Graphics alignment";
+};
+String RID_STR_FONT
+{
+ Text [ en-US ] = "Font" ;
+};
+String RID_STR_BACKGROUNDCOLOR
+{
+ Text [ en-US ] = "Background color" ;
+};
+String RID_STR_BORDER
+{
+ Text [ en-US ] = "Border" ;
+};
+String RID_STR_ICONSIZE
+{
+ Text [ en-US ] = "Icon size" ;
+};
+Resource RID_RSC_ENUM_ICONSIZE_TYPE
+{
+ String 1
+ {
+ Text [ en-US ] = "Small" ;
+ };
+ String 2
+ {
+ Text [ en-US ] = "Large" ;
+ };
+};
+String RID_STR_SHOW_POSITION
+{
+ Text [ en-US ] = "Positioning";
+};
+String RID_STR_SHOW_NAVIGATION
+{
+ Text [ en-US ] = "Navigation";
+};
+String RID_STR_SHOW_RECORDACTIONS
+{
+ Text [ en-US ] = "Acting on a record";
+};
+String RID_STR_SHOW_FILTERSORT
+{
+ Text [ en-US ] = "Filtering / Sorting";
+};
+String RID_STR_HSCROLL
+{
+ Text [ en-US ] = "Horizontal scroll bar" ;
+};
+String RID_STR_VSCROLL
+{
+ Text [ en-US ] = "Vertical scroll bar" ;
+};
+String RID_STR_WORDBREAK
+{
+ Text [ en-US ] = "Word break";
+};
+String RID_STR_MULTILINE
+{
+ Text [ en-US ] = "Multiline input" ;
+};
+String RID_STR_MULTISELECTION
+{
+ Text [ en-US ] = "Multiselection" ;
+};
+String RID_STR_NAME
+{
+ Text [ en-US ] = "Name" ;
+};
+String RID_STR_TABINDEX
+{
+ Text [ en-US ] = "Tab order" ;
+};
+String RID_STR_WHEEL_BEHAVIOR
+{
+ Text [ en-US ] = "Mouse wheel scroll" ;
+};
+String RID_STR_FILTER
+{
+ Text [ en-US ] = "Filter" ;
+};
+String RID_STR_SORT_CRITERIA
+{
+ Text [ en-US ] = "Sort" ;
+};
+String RID_STR_RECORDMARKER
+{
+ Text [ en-US ] = "Record marker";
+};
+String RID_STR_FILTERPROPOSAL
+{
+ Text [ en-US ] = "Filter proposal";
+};
+String RID_STR_NAVIGATION
+{
+ Text [ en-US ] = "Navigation bar" ;
+};
+String RID_STR_CYCLE
+{
+ Text [ en-US ] = "Cycle" ;
+};
+String RID_STR_TABSTOP
+{
+ Text [ en-US ] = "Tabstop" ;
+};
+String RID_STR_CONTROLSOURCE
+{
+ Text [ en-US ] = "Data field" ;
+};
+String RID_STR_DROPDOWN
+{
+ Text [ en-US ] = "Dropdown" ;
+};
+String RID_STR_BOUNDCOLUMN
+{
+ Text [ en-US ] = "Bound field" ;
+};
+String RID_STR_LISTSOURCE
+{
+ Text [ en-US ] = "List content" ;
+};
+String RID_STR_LISTSOURCETYPE
+{
+ Text [ en-US ] = "Type of list contents" ;
+};
+String RID_STR_CURSORSOURCE
+{
+ Text [ en-US ] = "Content" ;
+};
+String RID_STR_CURSORSOURCETYPE
+{
+ Text [ en-US ] = "Content type";
+};
+String RID_STR_ALLOW_ADDITIONS
+{
+ Text [ en-US ] = "Allow additions" ;
+};
+String RID_STR_ALLOW_DELETIONS
+{
+ Text [ en-US ] = "Allow deletions" ;
+};
+String RID_STR_ALLOW_EDITS
+{
+ Text [ en-US ] = "Allow modifications" ;
+};
+String RID_STR_DATAENTRY
+{
+ Text [ en-US ] = "Add data only" ;
+};
+String RID_STR_DATASOURCE
+{
+ Text [ en-US ] = "Data source";
+};
+String RID_STR_MASTERFIELDS
+{
+ Text [ en-US ] = "Link master fields" ;
+};
+String RID_STR_SLAVEFIELDS
+{
+ Text [ en-US ] = "Link slave fields" ;
+};
+String RID_STR_VALUEMIN
+{
+ Text [ en-US ] = "Value min." ;
+};
+String RID_STR_VALUEMAX
+{
+ Text [ en-US ] = "Value max." ;
+};
+String RID_STR_VALUESTEP
+{
+ Text [ en-US ] = "Incr./decrement value" ;
+};
+String RID_STR_CURRENCYSYMBOL
+{
+ Text [ en-US ] = "Currency symbol" ;
+};
+String RID_STR_DATEMIN
+{
+ Text [ en-US ] = "Date min." ;
+};
+String RID_STR_DATEMAX
+{
+ Text [ en-US ] = "Date max." ;
+};
+String RID_STR_DATEFORMAT
+{
+ Text [ en-US ] = "Date format" ;
+};
+String RID_STR_SELECTEDITEMS
+{
+ Text [ en-US ] = "Selection" ;
+};
+String RID_STR_TIMEMIN
+{
+ Text [ en-US ] = "Time min." ;
+};
+String RID_STR_TIMEMAX
+{
+ Text [ en-US ] = "Time max." ;
+};
+String RID_STR_TIMEFORMAT
+{
+ Text [ en-US ] = "Time format" ;
+};
+String RID_STR_CURRSYM_POSITION
+{
+ Text [ en-US ] = "Prefix symbol";
+};
+String RID_STR_VALUE
+{
+ Text [ en-US ] = "Value" ;
+};
+String RID_STR_FORMATKEY
+{
+ Text [ en-US ] = "Formatting" ;
+};
+String RID_STR_CLASSID
+{
+ Text [ en-US ] = "Class ID" ;
+};
+String RID_STR_HEIGHT
+{
+ Text [ en-US ] = "Height" ;
+};
+String RID_STR_WIDTH
+{
+ Text [ en-US ] = "Width" ;
+};
+String RID_STR_LISTINDEX
+{
+ Text [ en-US ] = "List index" ;
+};
+String RID_STR_ROWHEIGHT
+{
+ Text [ en-US ] = "Row height" ;
+};
+String RID_STR_FILLCOLOR
+{
+ Text [ en-US ] = "Fill color" ;
+};
+String RID_STR_LINECOLOR
+{
+ Text [ en-US ] = "Line color" ;
+};
+String RID_STR_REFVALUE
+{
+ Text [ en-US ] = "Reference value (on)" ;
+};
+String RID_STR_UNCHECKEDREFVALUE
+{
+ Text [ en-US ] = "Reference value (off)";
+};
+String RID_STR_STRINGITEMLIST
+{
+ Text [ en-US ] = "List entries" ;
+};
+String RID_STR_BUTTONTYPE
+{
+ Text [ en-US ] = "Action";
+};
+String RID_STR_SUBMIT_ACTION
+{
+ Text [ en-US ] = "URL" ;
+};
+String RID_STR_SUBMIT_METHOD
+{
+ Text [ en-US ] = "Type of submission" ;
+};
+String RID_STR_DEFAULT_STATE
+{
+ Text [ en-US ] = "Default status" ;
+};
+String RID_STR_SUBMIT_ENCODING
+{
+ Text [ en-US ] = "Submission encoding" ;
+};
+String RID_STR_DEFAULTVALUE
+{
+ Text [ en-US ] = "Default value" ;
+};
+String RID_STR_DEFAULTTEXT
+{
+ Text [ en-US ] = "Default text";
+};
+String RID_STR_DEFAULTDATE
+{
+ Text [ en-US ] = "Default date";
+};
+String RID_STR_DEFAULTTIME
+{
+ Text [ en-US ] = "Default time";
+};
+String RID_STR_SUBMIT_TARGET
+{
+ Text [ en-US ] = "Frame" ;
+};
+
+Resource RID_RSC_ENUM_BORDER_TYPE
+{
+ String 1
+ {
+ Text [ en-US ] = "Without frame" ;
+ };
+ String 2
+ {
+ Text [ en-US ] = "3D look" ;
+ };
+ String 3
+ {
+ Text [ en-US ] = "Flat" ;
+ };
+};
+
+Resource RID_RSC_ENUM_LISTSOURCE_TYPE
+{
+ String 1
+ {
+ Text [ en-US ] = "Valuelist";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Table";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Query";
+ };
+ String 4
+ {
+ Text [ en-US ] = "Sql";
+ };
+ String 5
+ {
+ Text [ en-US ] = "Sql [Native]";
+ };
+ String 6
+ {
+ Text [ en-US ] = "Tablefields" ;
+ };
+};
+Resource RID_RSC_ENUM_ALIGNMENT
+{
+ String 1
+ {
+ Text [ en-US ] = "Left";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Center";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Right" ;
+ };
+};
+Resource RID_RSC_ENUM_BUTTONTYPE
+{
+ String 1
+ {
+ Text [ en-US ] = "None";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Submit form";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Reset form";
+ };
+ String 4
+ {
+ Text [ en-US ] = "Open document/web page";
+ };
+ String 5
+ {
+ Text [ en-US ] = "First record";
+ };
+ String 6
+ {
+ Text [ en-US ] = "Previous record";
+ };
+ String 7
+ {
+ Text [ en-US ] = "Next record";
+ };
+ String 8
+ {
+ Text [ en-US ] = "Last record";
+ };
+ String 9
+ {
+ Text [ en-US ] = "Save record";
+ };
+ String 10
+ {
+ Text [ en-US ] = "Undo data entry";
+ };
+ String 11
+ {
+ Text [ en-US ] = "New record";
+ };
+ String 12
+ {
+ Text [ en-US ] = "Delete record";
+ };
+ String 13
+ {
+ Text [ en-US ] = "Refresh form";
+ };
+};
+Resource RID_RSC_ENUM_SUBMIT_METHOD
+{
+ String 1
+ {
+ Text [ en-US ] = "Get";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Post" ;
+ };
+};
+Resource RID_RSC_ENUM_SUBMIT_ENCODING
+{
+ String 1
+ {
+ Text [ en-US ] = "URL";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Multipart";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Text" ;
+ };
+};
+Resource RID_RSC_ENUM_DATEFORMAT_LIST
+{
+ String 1
+ {
+ Text [ en-US ] = "Standard (short)";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Standard (short YY)";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Standard (short YYYY)";
+ };
+ String 4
+ {
+ Text [ en-US ] = "Standard (long)";
+ };
+ String 5
+ {
+ Text [ en-US ] = "DD/MM/YY";
+ };
+ String 6
+ {
+ Text [ en-US ] = "MM/DD/YY";
+ };
+ String 7
+ {
+ Text [ en-US ] = "YY/MM/DD";
+ };
+ String 8
+ {
+ Text [ en-US ] = "DD/MM/YYYY";
+ };
+ String 9
+ {
+ Text [ en-US ] = "MM/DD/YYYY";
+ };
+ String 10
+ {
+ Text [ en-US ] = "YYYY/MM/DD";
+ };
+ String 11
+ {
+ Text [ en-US ] = "YY-MM-DD";
+ };
+ String 12
+ {
+ Text [ en-US ] = "YYYY-MM-DD" ;
+ };
+};
+Resource RID_RSC_ENUM_TIMEFORMAT_LIST
+{
+ String 1
+ {
+ Text [ en-US ] = "13:45";
+ };
+ String 2
+ {
+ Text [ en-US ] = "13:45:00";
+ };
+ String 3
+ {
+ Text [ en-US ] = "01:45 PM";
+ };
+ String 4
+ {
+ Text [ en-US ] = "01:45:00 PM" ;
+ };
+};
+Resource RID_RSC_ENUM_CHECKED
+{
+ String 1
+ {
+ Text [ en-US ] = "Not Selected";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Selected";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Not Defined" ;
+ };
+};
+Resource RID_RSC_ENUM_CYCLE
+{
+ String 1
+ {
+ Text [ en-US ] = "All records";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Active record";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Current page" ;
+ };
+};
+Resource RID_RSC_ENUM_NAVIGATION
+{
+ String 1
+ {
+ Text [ en-US ] = "No";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Yes";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Parent Form";
+ };
+};
+Resource RID_RSC_ENUM_SUBMIT_TARGET
+{
+ String 1 { Text = "_blank"; };
+ String 2 { Text = "_parent"; };
+ String 3 { Text = "_self"; };
+ String 4 { Text = "_top"; };
+};
+
+Resource RID_RSC_ENUM_SELECTION_TYPE
+{
+ String 1
+ {
+ Text [ en-US ] = "None" ;
+ };
+ String 2
+ {
+ Text [ en-US ] = "Single" ;
+ };
+ String 3
+ {
+ Text [ en-US ] = "Multi" ;
+ };
+ String 4
+ {
+ Text [ en-US ] = "Range" ;
+ };
+
+};
+
+String RID_STR_EVT_APPROVEPARAMETER
+{
+ Text [ en-US ] = "Fill parameters" ;
+};
+String RID_STR_EVT_ACTIONPERFORMED
+{
+ Text [ en-US ] = "Execute action" ;
+};
+String RID_STR_EVT_AFTERUPDATE
+{
+ Text [ en-US ] = "After updating" ;
+};
+String RID_STR_EVT_BEFOREUPDATE
+{
+ Text [ en-US ] = "Before updating" ;
+};
+String RID_STR_EVT_APPROVEROWCHANGE
+{
+ Text [ en-US ] = "Before record action" ;
+};
+String RID_STR_EVT_ROWCHANGE
+{
+ Text [ en-US ] = "After record action" ;
+};
+String RID_STR_EVT_CONFIRMDELETE
+{
+ Text [ en-US ] = "Confirm deletion" ;
+};
+String RID_STR_EVT_ERROROCCURED
+{
+ Text [ en-US ] = "Error occurred" ;
+};
+String RID_STR_EVT_FOCUSGAINED
+{
+ Text [ en-US ] = "When receiving focus" ;
+};
+String RID_STR_EVT_FOCUSLOST
+{
+ Text [ en-US ] = "When losing focus" ;
+};
+String RID_STR_EVT_ITEMSTATECHANGED
+{
+ Text [ en-US ] = "Item status changed" ;
+};
+String RID_STR_EVT_KEYTYPED
+{
+ Text [ en-US ] = "Key pressed" ;
+};
+String RID_STR_EVT_KEYUP
+{
+ Text [ en-US ] = "Key released" ;
+};
+String RID_STR_EVT_LOADED
+{
+ Text [ en-US ] = "When loading" ;
+};
+String RID_STR_EVT_RELOADING
+{
+ Text [ en-US ] = "Before reloading" ;
+};
+String RID_STR_EVT_RELOADED
+{
+ Text [ en-US ] = "When reloading" ;
+};
+String RID_STR_EVT_MOUSEDRAGGED
+{
+ Text [ en-US ] = "Mouse moved while key pressed" ;
+};
+String RID_STR_EVT_MOUSEENTERED
+{
+ Text [ en-US ] = "Mouse inside" ;
+};
+String RID_STR_EVT_MOUSEEXITED
+{
+ Text [ en-US ] = "Mouse outside" ;
+};
+String RID_STR_EVT_MOUSEMOVED
+{
+ Text [ en-US ] = "Mouse moved" ;
+};
+String RID_STR_EVT_MOUSEPRESSED
+{
+ Text [ en-US ] = "Mouse button pressed" ;
+};
+String RID_STR_EVT_MOUSERELEASED
+{
+ Text [ en-US ] = "Mouse button released" ;
+};
+String RID_STR_EVT_POSITIONING
+{
+ Text [ en-US ] = "Before record change" ;
+};
+String RID_STR_EVT_POSITIONED
+{
+ Text [ en-US ] = "After record change" ;
+};
+String RID_STR_EVT_RESETTED
+{
+ Text [ en-US ] = "After resetting" ;
+};
+String RID_STR_EVT_APPROVERESETTED
+{
+ Text [ en-US ] = "Prior to reset" ;
+};
+String RID_STR_EVT_APPROVEACTIONPERFORMED
+{
+ Text [ en-US ] = "Approve action" ;
+};
+String RID_STR_EVT_SUBMITTED
+{
+ Text [ en-US ] = "Before submitting" ;
+};
+String RID_STR_EVT_TEXTCHANGED
+{
+ Text [ en-US ] = "Text modified" ;
+};
+String RID_STR_EVT_UNLOADING
+{
+ Text [ en-US ] = "Before unloading" ;
+};
+String RID_STR_EVT_UNLOADED
+{
+ Text [ en-US ] = "When unloading" ;
+};
+String RID_STR_EVT_CHANGED
+{
+ Text [ en-US ] = "Changed" ;
+};
+String RID_STR_EVENTS
+{
+ Text [ en-US ] = "Events" ;
+};
+String RID_STR_ESCAPE_PROCESSING
+{
+ Text [ en-US ] = "Analyze SQL command";
+};
+String RID_STR_POSITIONX
+{
+ Text [ en-US ] = "PositionX";
+};
+String RID_STR_POSITIONY
+{
+ Text [ en-US ] = "PositionY";
+};
+String RID_STR_TITLE
+{
+ Text [ en-US ] = "Title";
+};
+String RID_STR_STEP
+{
+ Text [ en-US ] = "Page (step)";
+};
+String RID_STR_PROGRESSVALUE
+{
+ Text [ en-US ] = "Progress value";
+};
+String RID_STR_PROGRESSVALUE_MIN
+{
+ Text [ en-US ] = "Progress value min.";
+};
+String RID_STR_PROGRESSVALUE_MAX
+{
+ Text [ en-US ] = "Progress value max.";
+};
+String RID_STR_SCROLLVALUE
+{
+ Text [ en-US ] = "Scroll value";
+};
+String RID_STR_SCROLLVALUE_MAX
+{
+ Text [ en-US ] = "Scroll value max.";
+};
+String RID_STR_SCROLLVALUE_MIN
+{
+ Text [ en-US ] = "Scroll value min.";
+};
+String RID_STR_DEFAULT_SCROLLVALUE
+{
+ Text [ en-US ] = "Default scroll value";
+};
+String RID_STR_LINEINCREMENT
+{
+ Text [ en-US ] = "Small change";
+};
+String RID_STR_BLOCKINCREMENT
+{
+ Text [ en-US ] = "Large change";
+};
+String RID_STR_REPEAT_DELAY
+{
+ Text [ en-US ] = "Delay";
+};
+String RID_STR_REPEAT
+{
+ Text [ en-US ] = "Repeat";
+};
+String RID_STR_VISIBLESIZE
+{
+ Text [ en-US ] = "Visible size";
+};
+String RID_STR_ORIENTATION
+{
+ Text [ en-US ] = "Orientation";
+};
+Resource RID_RSC_ENUM_ORIENTATION
+{
+ String 1
+ {
+ Text [ en-US ] = "Horizontal";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Vertical";
+ };
+};
+String RID_STR_EVT_ADJUSTMENTVALUECHANGED
+{
+ Text [ en-US ] = "While adjusting";
+};
+String RID_STR_DATE
+{
+ Text [ en-US ] = "Date";
+};
+String RID_STR_STATE
+{
+ Text [ en-US ] = "State";
+};
+String RID_STR_TIME
+{
+ Text [ en-US ] = "Time";
+};
+String RID_STR_SCALEIMAGE
+{
+ Text [ en-US ] = "Scale";
+};
+String RID_STR_PUSHBUTTONTYPE
+{
+ Text [ en-US ] = "Button type";
+};
+Resource RID_RSC_ENUM_PUSHBUTTONTYPE
+{
+ String 1
+ {
+ Text [ en-US ] = "Default";
+ };
+ String 2
+ {
+ Text [ en-US ] = "OK";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Cancel";
+ };
+ String 4
+ {
+ Text [ en-US ] = "Help";
+ };
+};
+String RID_STR_UNABLETOCONNECT
+{
+ Text [ en-US ] = "The connection to the data source \"$name$\" could not be established.";
+};
+String RID_STR_TEXT
+{
+ Text [ en-US ] = "Text";
+};
+
+String RID_STR_BOUND_CELL
+{
+ Text [ en-US ] = "Linked cell";
+};
+
+String RID_STR_LIST_CELL_RANGE
+{
+ Text [ en-US ] = "Source cell range";
+};
+
+String RID_STR_CELL_EXCHANGE_TYPE
+{
+ Text [ en-US ] = "Contents of the linked cell";
+};
+
+Resource RID_RSC_ENUM_CELL_EXCHANGE_TYPE
+{
+ String 1
+ {
+ Text [ en-US ] = "The selected entry";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Position of the selected entry";
+ };
+};
+
+String RID_STR_SHOW_SCROLLBARS
+{
+ Text [ en-US ] = "Scrollbars";
+};
+
+Resource RID_RSC_ENUM_TEXTTYPE
+{
+ String 1
+ {
+ Text [ en-US ] = "Single-line";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Multi-line";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Multi-line with formatting";
+ };
+};
+
+String RID_STR_SYMBOLCOLOR
+{
+ Text [ en-US ] = "Symbol color" ;
+};
+
+String RID_STR_LINEEND_FORMAT
+{
+ Text [ en-US ] = "Text lines end with";
+};
+
+Resource RID_RSC_ENUM_LINEEND_FORMAT
+{
+ String 1
+ {
+ Text [ en-US ] = "LF (Unix)";
+ };
+ String 2
+ {
+ Text [ en-US ] = "CR+LF (Windows)";
+ };
+};
+
+Resource RID_RSC_ENUM_SCROLLBARS
+{
+ String 1
+ {
+ Text [ en-US ] = "None";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Horizontal";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Vertical";
+ };
+ String 4
+ {
+ Text [ en-US ] = "Both";
+ };
+};
+
+Resource RID_RSC_ENUM_COMMAND_TYPE
+{
+ String 1
+ {
+ Text [ en-US ] = "Table";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Query";
+ };
+ String 3
+ {
+ Text [ en-US ] = "SQL command";
+ };
+};
+String RID_STR_TOGGLE
+{
+ Text [ en-US ] = "Toggle";
+};
+
+String RID_STR_FOCUSONCLICK
+{
+ Text [ en-US ] = "Take Focus on Click";
+};
+
+String RID_STR_HIDEINACTIVESELECTION
+{
+ Text [ en-US ] = "Hide selection";
+};
+
+String RID_STR_VISUALEFFECT
+{
+ Text [ en-US ] = "Style";
+};
+
+Resource RID_RSC_ENUM_VISUALEFFECT
+{
+ String 1
+ {
+ Text [ en-US ] = "3D";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Flat";
+ };
+};
+
+String RID_STR_BORDERCOLOR
+{
+ Text [ en-US ] = "Border color";
+};
+
+Resource RID_RSC_ENUM_IMAGE_POSITION
+{
+ String 1
+ {
+ Text [ en-US ] = "Left top";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Left centered";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Left bottom";
+ };
+ String 4
+ {
+ Text [ en-US ] = "Right top";
+ };
+ String 5
+ {
+ Text [ en-US ] = "Right centered";
+ };
+ String 6
+ {
+ Text [ en-US ] = "Right bottom";
+ };
+ String 7
+ {
+ Text [ en-US ] = "Above left";
+ };
+ String 8
+ {
+ Text [ en-US ] = "Above centered";
+ };
+ String 9
+ {
+ Text [ en-US ] = "Above right";
+ };
+ String 10
+ {
+ Text [ en-US ] = "Below left";
+ };
+ String 11
+ {
+ Text [ en-US ] = "Below centered";
+ };
+ String 12
+ {
+ Text [ en-US ] = "Below right";
+ };
+ String 13
+ {
+ Text [ en-US ] = "Centered";
+ };
+};
+
+String RID_STR_AUTOLINEBREAK
+{
+ Text [ en-US ] = "Wrap text automatically";
+};
+
+String RID_STR_TEXTTYPE
+{
+ Text [ en-US ] = "Text type";
+};
+
+Resource RID_RSC_ENUM_SHOWHIDE
+{
+ String 1
+ {
+ Text [ en-US ] = "Hide" ;
+ };
+ String 2
+ {
+ Text [ en-US ] = "Show" ;
+ };
+};
+String RID_STR_XML_DATA_MODEL
+{
+ Text [ en-US ] = "XML data model";
+};
+
+String RID_STR_BIND_EXPRESSION
+{
+ Text [ en-US ] = "Binding expression";
+};
+
+String RID_STR_XSD_REQUIRED
+{
+ Text [ en-US ] = "Required";
+};
+
+String RID_STR_LIST_BINDING
+{
+ Text [ en-US ] = "List entry source";
+};
+
+String RID_STR_XSD_RELEVANT
+{
+ Text [ en-US ] = "Relevant";
+};
+
+String RID_STR_XSD_READONLY
+{
+ Text [ en-US ] = "Read-only";
+};
+
+String RID_STR_XSD_CONSTRAINT
+{
+ Text [ en-US ] = "Constraint";
+};
+
+String RID_STR_XSD_CALCULATION
+{
+ Text [ en-US ] = "Calculation";
+};
+
+String RID_STR_XSD_DATA_TYPE
+{
+ Text [ en-US ] = "Data type";
+};
+
+String RID_STR_XSD_WHITESPACES
+{
+ Text [ en-US ] = "Whitespaces";
+};
+
+Resource RID_RSC_ENUM_WHITESPACE_HANDLING
+{
+ String 1
+ {
+ Text [ en-US ] = "Preserve";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Replace";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Collapse";
+ };
+};
+
+String RID_STR_XSD_PATTERN
+{
+ Text [ en-US ] = "Pattern";
+};
+
+String RID_STR_XSD_LENGTH
+{
+ Text [ en-US ] = "Length";
+};
+
+String RID_STR_XSD_MIN_LENGTH
+{
+ Text [ en-US ] = "Length (at least)";
+};
+
+String RID_STR_XSD_MAX_LENGTH
+{
+ Text [ en-US ] = "Length (at most)";
+};
+
+String RID_STR_XSD_TOTAL_DIGITS
+{
+ Text [ en-US ] = "Digits (total)";
+};
+
+String RID_STR_XSD_FRACTION_DIGITS
+{
+ Text [ en-US ] = "Digits (fraction)";
+};
+
+String RID_STR_XSD_MAX_INCLUSIVE
+{
+ Text [ en-US ] = "Max. (inclusive)";
+};
+
+String RID_STR_XSD_MAX_EXCLUSIVE
+{
+ Text [ en-US ] = "Max. (exclusive)";
+};
+
+String RID_STR_XSD_MIN_INCLUSIVE
+{
+ Text [ en-US ] = "Min. (inclusive)";
+};
+
+String RID_STR_XSD_MIN_EXCLUSIVE
+{
+ Text [ en-US ] = "Min. (exclusive)";
+};
+
+String RID_STR_SUBMISSION_ID
+{
+ Text [ en-US ] = "Submission";
+};
+
+String RID_STR_BINDING_UI_NAME
+{
+ Text [ en-US ] = "Binding" ;
+};
+
+String RID_STR_SELECTION_TYPE
+{
+ Text [ en-US ] = "Selection type" ;
+};
+
+String RID_STR_ROOT_DISPLAYED
+{
+ Text [ en-US ] = "Root displayed" ;
+};
+
+String RID_STR_SHOWS_HANDLES
+{
+ Text [ en-US ] = "Show handles" ;
+};
+
+String RID_STR_SHOWS_ROOT_HANDLES
+{
+ Text [ en-US ] = "Show root handles" ;
+};
+
+String RID_STR_EDITABLE
+{
+ Text [ en-US ] = "Editable" ;
+};
+
+String RID_STR_INVOKES_STOP_NOT_EDITING
+{
+ Text [ en-US ] = "Invokes stop node editing" ;
+};
+
+String RID_STR_DECORATION
+{
+ Text [ en-US ] = "With title bar" ;
+};
+
+String RID_STR_NOLABEL
+{
+ Text [ en-US ] = "No Label" ;
+};
+
+Resource RID_RSC_ENUM_SCALE_MODE
+{
+ String 1
+ {
+ Text [ en-US ] = "No";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Keep Ratio";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Fit to Size";
+ };
+};
+String RID_STR_INPUT_REQUIRED
+{
+ Text [ en-US ] = "Input required";
+};
+
+String RID_STR_WRITING_MODE
+{
+ Text [ en-US ] = "Text direction";
+};
+
+Resource RID_RSC_ENUM_WRITING_MODE
+{
+ String 1
+ {
+ Text [ en-US ] = "Left-to-right";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Right-to-left";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Use superordinate object settings";
+ };
+};
+
+Resource RID_RSC_ENUM_WHEEL_BEHAVIOR
+{
+ String 1
+ {
+ Text [ en-US ] = "Never";
+ };
+ String 2
+ {
+ Text [ en-US ] = "When focused";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Always";
+ };
+};
+
+String RID_STR_ANCHOR_TYPE
+{
+ Text [ en-US ] = "Anchor";
+};
+
+Resource RID_RSC_ENUM_TEXT_ANCHOR_TYPE
+{
+ String 1
+ {
+ Text [ en-US ] = "To Paragraph";
+ };
+ String 2
+ {
+ Text [ en-US ] = "As Character";
+ };
+ String 3
+ {
+ Text [ en-US ] = "To Page";
+ };
+ String 4
+ {
+ Text [ en-US ] = "To Frame";
+ };
+ String 5
+ {
+ Text [ en-US ] = "To Character";
+ };
+};
+
+Resource RID_RSC_ENUM_SHEET_ANCHOR_TYPE
+{
+ String 1
+ {
+ Text [ en-US ] = "To Page";
+ };
+ String 2
+ {
+ Text [ en-US ] = "To Cell";
+ };
+};
+
+String RID_STR_FONTSTYLE_REGULAR
+{
+ Text [ en-US ] = "Regular";
+ Text [ x-comment ] = "That's the 'Regular' as used for a font style (as opposed to 'italic' and 'bold'), so please use a consistent translation.";
+};
+
+String RID_STR_FONTSTYLE_BOLD_ITALIC
+{
+ Text [ en-US ] = "Bold Italic";
+ Text [ x-comment ] = "That's the 'Bold Italic' as used for a font style, so please use a consistent translation.";
+};
+
+String RID_STR_FONTSTYLE_ITALIC
+{
+ Text [ en-US ] = "Italic";
+ Text [ x-comment ] = "That's the 'Italic' as used for a font style, so please use a consistent translation.";
+};
+
+String RID_STR_FONTSTYLE_BOLD
+{
+ Text [ en-US ] = "Bold";
+ Text [ x-comment ] = "That's the 'Bold' as used for a font style, so please use a consistent translation.";
+};
+
+String RID_STR_FONT_DEFAULT
+{
+ Text [ en-US ] = "(Default)";
+};
diff --git a/extensions/source/propctrlr/formresid.hrc b/extensions/source/propctrlr/formresid.hrc
new file mode 100644
index 000000000000..f2de0c252d8b
--- /dev/null
+++ b/extensions/source/propctrlr/formresid.hrc
@@ -0,0 +1,389 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
+#define _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
+
+#ifndef EXTENSIONS_PROPRESID_HRC
+#include "propresid.hrc"
+#endif
+
+// -----------------------------------------------------------------------
+// - Strings
+
+#define RID_STR_FORMS ( RID_FORMBROWSER_START + 1 )
+#define RID_STR_PROPTITLE_DBGRID ( RID_FORMBROWSER_START + 2 )
+#define RID_STR_PROPTITLE_PATTERNFIELD ( RID_FORMBROWSER_START + 3 )
+#define RID_STR_PROPTITLE_CURRENCYFIELD ( RID_FORMBROWSER_START + 4 )
+#define RID_STR_PROPTITLE_NUMERICFIELD ( RID_FORMBROWSER_START + 5 )
+#define RID_STR_PROPTITLE_TIMEFIELD ( RID_FORMBROWSER_START + 6 )
+#define RID_STR_PROPTITLE_DATEFIELD ( RID_FORMBROWSER_START + 7 )
+#define RID_STR_PROPTITLE_FILECONTROL ( RID_FORMBROWSER_START + 8 )
+#define RID_STR_PROPTITLE_IMAGECONTROL ( RID_FORMBROWSER_START + 9 )
+#define RID_STR_PROPTITLE_IMAGEBUTTON ( RID_FORMBROWSER_START + 10 )
+#define RID_STR_PROPTITLE_COMBOBOX ( RID_FORMBROWSER_START + 11 )
+#define RID_STR_PROPTITLE_LISTBOX ( RID_FORMBROWSER_START + 12 )
+#define RID_STR_PROPTITLE_FORMATTED ( RID_FORMBROWSER_START + 13 )
+#define RID_STR_PROPTITLE_EDIT ( RID_FORMBROWSER_START + 14 )
+#define RID_STR_PROPTITLE_GROUPBOX ( RID_FORMBROWSER_START + 15 )
+#define RID_STR_PROPTITLE_FIXEDTEXT ( RID_FORMBROWSER_START + 16 )
+#define RID_STR_PROPTITLE_CHECKBOX ( RID_FORMBROWSER_START + 17 )
+#define RID_STR_PROPTITLE_RADIOBUTTON ( RID_FORMBROWSER_START + 18 )
+#define RID_STR_PROPTITLE_PUSHBUTTON ( RID_FORMBROWSER_START + 19 )
+#define RID_STR_PROPTITLE_HIDDENCONTROL ( RID_FORMBROWSER_START + 30 )
+#define RID_STR_PROPTITLE_UNKNOWNCONTROL ( RID_FORMBROWSER_START + 31 )
+
+#define RID_STR_NAME ( RID_FORMBROWSER_START + 32 )
+#define RID_STR_LABEL ( RID_FORMBROWSER_START + 33 )
+#define RID_STR_LABELCONTROL ( RID_FORMBROWSER_START + 34 )
+#define RID_STR_MAXTEXTLEN ( RID_FORMBROWSER_START + 35 )
+#define RID_STR_EDITMASK ( RID_FORMBROWSER_START + 36 )
+#define RID_STR_LITERALMASK ( RID_FORMBROWSER_START + 37 )
+#define RID_STR_STRICTFORMAT ( RID_FORMBROWSER_START + 38 )
+#define RID_STR_ENABLED ( RID_FORMBROWSER_START + 39 )
+#define RID_STR_READONLY ( RID_FORMBROWSER_START + 40 )
+#define RID_STR_PRINTABLE ( RID_FORMBROWSER_START + 41 )
+#define RID_STR_CONTROLSOURCE ( RID_FORMBROWSER_START + 42 )
+#define RID_STR_TABSTOP ( RID_FORMBROWSER_START + 43 )
+#define RID_STR_TABINDEX ( RID_FORMBROWSER_START + 44 )
+#define RID_STR_DATASOURCE ( RID_FORMBROWSER_START + 45 )
+#define RID_STR_CURSORSOURCE ( RID_FORMBROWSER_START + 46 )
+#define RID_STR_CURSORSOURCETYPE ( RID_FORMBROWSER_START + 47 )
+#define RID_STR_FILTER ( RID_FORMBROWSER_START + 48 )
+#define RID_STR_SORT_CRITERIA ( RID_FORMBROWSER_START + 49 )
+#define RID_STR_ALLOW_ADDITIONS ( RID_FORMBROWSER_START + 50 )
+#define RID_STR_ALLOW_EDITS ( RID_FORMBROWSER_START + 51 )
+#define RID_STR_ALLOW_DELETIONS ( RID_FORMBROWSER_START + 52 )
+#define RID_STR_DATAENTRY ( RID_FORMBROWSER_START + 53 )
+#define RID_STR_CYCLE ( RID_FORMBROWSER_START + 54 )
+#define RID_STR_VALUE ( RID_FORMBROWSER_START + 55 )
+#define RID_STR_VALUESTEP ( RID_FORMBROWSER_START + 56 )
+#define RID_STR_DECIMAL_ACCURACY ( RID_FORMBROWSER_START + 57 )
+#define RID_STR_SHOWTHOUSANDSEP ( RID_FORMBROWSER_START + 58 )
+#define RID_STR_REFVALUE ( RID_FORMBROWSER_START + 59 )
+#define RID_STR_CURRENCYSYMBOL ( RID_FORMBROWSER_START + 60 )
+#define RID_STR_CURRSYM_POSITION ( RID_FORMBROWSER_START + 61 )
+#define RID_STR_DATEMIN ( RID_FORMBROWSER_START + 62 )
+#define RID_STR_DATEMAX ( RID_FORMBROWSER_START + 63 )
+#define RID_STR_DATEFORMAT ( RID_FORMBROWSER_START + 64 )
+#define RID_STR_SELECTEDITEMS ( RID_FORMBROWSER_START + 65 )
+#define RID_STR_TIMEMIN ( RID_FORMBROWSER_START + 66 )
+#define RID_STR_TIMEMAX ( RID_FORMBROWSER_START + 67 )
+#define RID_STR_TIMEFORMAT ( RID_FORMBROWSER_START + 68 )
+#define RID_STR_VALUEMIN ( RID_FORMBROWSER_START + 69 )
+#define RID_STR_VALUEMAX ( RID_FORMBROWSER_START + 70 )
+#define RID_STR_FORMATKEY ( RID_FORMBROWSER_START + 71 )
+#define RID_STR_CLASSID ( RID_FORMBROWSER_START + 72 )
+#define RID_STR_HEIGHT ( RID_FORMBROWSER_START + 73 )
+#define RID_STR_WIDTH ( RID_FORMBROWSER_START + 74 )
+#define RID_STR_BOUNDCOLUMN ( RID_FORMBROWSER_START + 75 )
+#define RID_STR_LISTSOURCETYPE ( RID_FORMBROWSER_START + 76 )
+#define RID_STR_LISTSOURCE ( RID_FORMBROWSER_START + 77 )
+#define RID_STR_LISTINDEX ( RID_FORMBROWSER_START + 78 )
+#define RID_STR_STRINGITEMLIST ( RID_FORMBROWSER_START + 79 )
+#define RID_STR_DEFAULTVALUE ( RID_FORMBROWSER_START + 80 )
+#define RID_STR_FONT ( RID_FORMBROWSER_START + 81 )
+#define RID_STR_ALIGN ( RID_FORMBROWSER_START + 82 )
+#define RID_STR_ROWHEIGHT ( RID_FORMBROWSER_START + 83 )
+#define RID_STR_BACKGROUNDCOLOR ( RID_FORMBROWSER_START + 84 )
+#define RID_STR_FILLCOLOR ( RID_FORMBROWSER_START + 85 )
+#define RID_STR_LINECOLOR ( RID_FORMBROWSER_START + 86 )
+#define RID_STR_BORDER ( RID_FORMBROWSER_START + 87 )
+#define RID_STR_DROPDOWN ( RID_FORMBROWSER_START + 88 )
+#define RID_STR_AUTOCOMPLETE ( RID_FORMBROWSER_START + 89 )
+#define RID_STR_LINECOUNT ( RID_FORMBROWSER_START + 90 )
+#define RID_STR_MULTILINE ( RID_FORMBROWSER_START + 91 )
+#define RID_STR_MULTISELECTION ( RID_FORMBROWSER_START + 92 )
+#define RID_STR_BUTTONTYPE ( RID_FORMBROWSER_START + 93 )
+#define RID_STR_HSCROLL ( RID_FORMBROWSER_START + 94 )
+#define RID_STR_VSCROLL ( RID_FORMBROWSER_START + 95 )
+#define RID_STR_SPIN ( RID_FORMBROWSER_START + 96 )
+#define RID_STR_AUTOLINEBREAK ( RID_FORMBROWSER_START + 97 )
+#define RID_STR_TARGET_URL ( RID_FORMBROWSER_START + 98 )
+#define RID_STR_TARGET_FRAME ( RID_FORMBROWSER_START + 99 )
+#define RID_STR_SUBMIT_ACTION ( RID_FORMBROWSER_START + 100 )
+#define RID_STR_SUBMIT_TARGET ( RID_FORMBROWSER_START + 101 )
+#define RID_STR_SUBMIT_METHOD ( RID_FORMBROWSER_START + 102 )
+#define RID_STR_SUBMIT_ENCODING ( RID_FORMBROWSER_START + 103 )
+#define RID_STR_DEFAULT_STATE ( RID_FORMBROWSER_START + 104 )
+#define RID_STR_DEFAULT_BUTTON ( RID_FORMBROWSER_START + 105 )
+#define RID_STR_IMAGE_URL ( RID_FORMBROWSER_START + 106 )
+#define RID_STR_DEFAULT_SELECT_SEQ ( RID_FORMBROWSER_START + 107 )
+#define RID_STR_ECHO_CHAR ( RID_FORMBROWSER_START + 108 )
+#define RID_STR_EMPTY_IS_NULL ( RID_FORMBROWSER_START + 109 )
+#define RID_STR_TRISTATE ( RID_FORMBROWSER_START + 110 )
+#define RID_STR_MASTERFIELDS ( RID_FORMBROWSER_START + 111 )
+#define RID_STR_SLAVEFIELDS ( RID_FORMBROWSER_START + 112 )
+#define RID_STR_NAVIGATION ( RID_FORMBROWSER_START + 113 )
+#define RID_STR_RECORDMARKER ( RID_FORMBROWSER_START + 114 )
+#define RID_STR_FILTERPROPOSAL ( RID_FORMBROWSER_START + 115 )
+#define RID_STR_TAG ( RID_FORMBROWSER_START + 116 )
+#define RID_STR_HELPTEXT ( RID_FORMBROWSER_START + 117 )
+#define RID_STR_HELPURL ( RID_FORMBROWSER_START + 118 )
+#define RID_STR_INPUT_REQUIRED ( RID_FORMBROWSER_START + 119 )
+#define RID_STR_UNCHECKEDREFVALUE ( RID_FORMBROWSER_START + 120 )
+#define RID_STR_CURSOR_TYPE ( RID_FORMBROWSER_START + 121 )
+#define RID_STR_ENABLE_VISIBLE ( RID_FORMBROWSER_START + 122 )
+#define RID_STR_WHEEL_BEHAVIOR ( RID_FORMBROWSER_START + 123 )
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+#define RID_STR_ENUM_NAVIGATION ( RID_FORMBROWSER_START + 131 )
+#define RID_STR_EVT_APPROVEACTIONPERFORMED ( RID_FORMBROWSER_START + 132 )
+#define RID_STR_EVT_ACTIONPERFORMED ( RID_FORMBROWSER_START + 133 )
+#define RID_STR_EVT_CHANGED ( RID_FORMBROWSER_START + 134 )
+#define RID_STR_EVT_TEXTCHANGED ( RID_FORMBROWSER_START + 135 )
+#define RID_STR_EVT_ITEMSTATECHANGED ( RID_FORMBROWSER_START + 136 )
+#define RID_STR_EVT_FOCUSGAINED ( RID_FORMBROWSER_START + 137 )
+#define RID_STR_EVT_FOCUSLOST ( RID_FORMBROWSER_START + 138 )
+#define RID_STR_EVT_KEYTYPED ( RID_FORMBROWSER_START + 139 )
+#define RID_STR_EVT_KEYUP ( RID_FORMBROWSER_START + 140 )
+#define RID_STR_EVT_MOUSEENTERED ( RID_FORMBROWSER_START + 141 )
+#define RID_STR_EVT_MOUSEDRAGGED ( RID_FORMBROWSER_START + 142 )
+#define RID_STR_EVT_MOUSEMOVED ( RID_FORMBROWSER_START + 143 )
+#define RID_STR_EVT_MOUSEPRESSED ( RID_FORMBROWSER_START + 144 )
+#define RID_STR_EVT_MOUSERELEASED ( RID_FORMBROWSER_START + 145 )
+#define RID_STR_EVT_MOUSEEXITED ( RID_FORMBROWSER_START + 146 )
+#define RID_STR_EVT_APPROVERESETTED ( RID_FORMBROWSER_START + 147 )
+#define RID_STR_EVT_RESETTED ( RID_FORMBROWSER_START + 148 )
+#define RID_STR_EVT_SUBMITTED ( RID_FORMBROWSER_START + 149 )
+#define RID_STR_EVT_BEFOREUPDATE ( RID_FORMBROWSER_START + 150 )
+#define RID_STR_EVT_AFTERUPDATE ( RID_FORMBROWSER_START + 151 )
+#define RID_STR_EVT_LOADED ( RID_FORMBROWSER_START + 152 )
+#define RID_STR_EVT_RELOADING ( RID_FORMBROWSER_START + 153 )
+#define RID_STR_EVT_RELOADED ( RID_FORMBROWSER_START + 154 )
+#define RID_STR_EVT_UNLOADING ( RID_FORMBROWSER_START + 155 )
+#define RID_STR_EVT_UNLOADED ( RID_FORMBROWSER_START + 156 )
+#define RID_STR_EVT_CONFIRMDELETE ( RID_FORMBROWSER_START + 157 )
+#define RID_STR_EVT_APPROVEROWCHANGE ( RID_FORMBROWSER_START + 158 )
+#define RID_STR_EVT_ROWCHANGE ( RID_FORMBROWSER_START + 159 )
+#define RID_STR_EVT_POSITIONING ( RID_FORMBROWSER_START + 160 )
+#define RID_STR_EVT_POSITIONED ( RID_FORMBROWSER_START + 161 )
+#define RID_STR_EVT_APPROVEPARAMETER ( RID_FORMBROWSER_START + 162 )
+#define RID_STR_EVT_ERROROCCURED ( RID_FORMBROWSER_START + 163 )
+#define RID_STR_EVENTS ( RID_FORMBROWSER_START + 164 )
+#define RID_STR_ESCAPE_PROCESSING ( RID_FORMBROWSER_START + 165 )
+ // FREE
+#define RID_STR_POSITIONX ( RID_FORMBROWSER_START + 167 )
+#define RID_STR_POSITIONY ( RID_FORMBROWSER_START + 168 )
+#define RID_STR_TITLE ( RID_FORMBROWSER_START + 169 )
+#define RID_STR_STEP ( RID_FORMBROWSER_START + 170 )
+#define RID_STR_PROGRESSVALUE ( RID_FORMBROWSER_START + 171 )
+#define RID_STR_PROGRESSVALUE_MIN ( RID_FORMBROWSER_START + 172 )
+#define RID_STR_PROGRESSVALUE_MAX ( RID_FORMBROWSER_START + 173 )
+#define RID_STR_SCROLLVALUE ( RID_FORMBROWSER_START + 174 )
+#define RID_STR_SCROLLVALUE_MAX ( RID_FORMBROWSER_START + 175 )
+#define RID_STR_LINEINCREMENT ( RID_FORMBROWSER_START + 176 )
+#define RID_STR_BLOCKINCREMENT ( RID_FORMBROWSER_START + 177 )
+#define RID_STR_VISIBLESIZE ( RID_FORMBROWSER_START + 178 )
+#define RID_STR_ORIENTATION ( RID_FORMBROWSER_START + 179 )
+ // FREE
+#define RID_STR_VERTICAL_ALIGN ( RID_FORMBROWSER_START + 181 )
+#define RID_STR_EVT_ADJUSTMENTVALUECHANGED ( RID_FORMBROWSER_START + 182 )
+#define RID_STR_DATE ( RID_FORMBROWSER_START + 183 )
+#define RID_STR_STATE ( RID_FORMBROWSER_START + 184 )
+#define RID_STR_TIME ( RID_FORMBROWSER_START + 185 )
+#define RID_STR_SCALEIMAGE ( RID_FORMBROWSER_START + 186 )
+#define RID_STR_PUSHBUTTONTYPE ( RID_FORMBROWSER_START + 187 )
+#define RID_STR_ENUM_PUSHBUTTONTYPE ( RID_FORMBROWSER_START + 188 )
+#define RID_STR_UNABLETOCONNECT ( RID_FORMBROWSER_START + 189 )
+#define RID_STR_TEXT ( RID_FORMBROWSER_START + 190 )
+#define RID_STR_BOUND_CELL ( RID_FORMBROWSER_START + 191 )
+#define RID_STR_LIST_CELL_RANGE ( RID_FORMBROWSER_START + 192 )
+#define RID_STR_CELL_EXCHANGE_TYPE ( RID_FORMBROWSER_START + 193 )
+#define RID_STR_ANCHOR_TYPE ( RID_FORMBROWSER_START + 194 )
+#define RID_STR_SCROLLVALUE_MIN ( RID_FORMBROWSER_START + 195 )
+#define RID_STR_DEFAULT_SCROLLVALUE ( RID_FORMBROWSER_START + 196 )
+#define RID_STR_REPEAT_DELAY ( RID_FORMBROWSER_START + 197 )
+#define RID_STR_SYMBOLCOLOR ( RID_FORMBROWSER_START + 198 )
+#define RID_STR_REPEAT ( RID_FORMBROWSER_START + 199 )
+#define RID_STR_IMAGEPOSITION ( RID_FORMBROWSER_START + 200 )
+#define RID_STR_DEFAULTTEXT ( RID_FORMBROWSER_START + 201 )
+#define RID_STR_DEFAULTDATE ( RID_FORMBROWSER_START + 202 )
+#define RID_STR_DEFAULTTIME ( RID_FORMBROWSER_START + 203 )
+#define RID_STR_WORDBREAK ( RID_FORMBROWSER_START + 204 )
+#define RID_STR_SHOW_SCROLLBARS ( RID_FORMBROWSER_START + 205 )
+#define RID_STR_QUERYDESIGN_TITLE ( RID_FORMBROWSER_START + 206 )
+#define RID_STR_ICONSIZE ( RID_FORMBROWSER_START + 207 )
+#define RID_STR_WRITING_MODE ( RID_FORMBROWSER_START + 208 )
+#define RID_STR_SHOW_POSITION ( RID_FORMBROWSER_START + 209 )
+#define RID_STR_SHOW_NAVIGATION ( RID_FORMBROWSER_START + 210 )
+#define RID_STR_SHOW_RECORDACTIONS ( RID_FORMBROWSER_START + 211 )
+#define RID_STR_SHOW_FILTERSORT ( RID_FORMBROWSER_START + 212 )
+#define RID_STR_TEXTTYPE ( RID_FORMBROWSER_START + 213 )
+#define RID_STR_LINEEND_FORMAT ( RID_FORMBROWSER_START + 214 )
+#define RID_STR_TOGGLE ( RID_FORMBROWSER_START + 215 )
+#define RID_STR_FOCUSONCLICK ( RID_FORMBROWSER_START + 216 )
+#define RID_STR_HIDEINACTIVESELECTION ( RID_FORMBROWSER_START + 217 )
+#define RID_STR_VISUALEFFECT ( RID_FORMBROWSER_START + 218 )
+#define RID_STR_BORDERCOLOR ( RID_FORMBROWSER_START + 219 )
+ // FREE
+#define RID_STR_XML_DATA_MODEL ( RID_FORMBROWSER_START + 221 )
+#define RID_STR_BIND_EXPRESSION ( RID_FORMBROWSER_START + 222 )
+#define RID_STR_XSD_REQUIRED ( RID_FORMBROWSER_START + 223 )
+#define RID_STR_XSD_RELEVANT ( RID_FORMBROWSER_START + 224 )
+#define RID_STR_XSD_READONLY ( RID_FORMBROWSER_START + 225 )
+#define RID_STR_XSD_CONSTRAINT ( RID_FORMBROWSER_START + 226 )
+#define RID_STR_XSD_CALCULATION ( RID_FORMBROWSER_START + 227 )
+#define RID_STR_XSD_DATA_TYPE ( RID_FORMBROWSER_START + 228 )
+#define RID_STR_XSD_WHITESPACES ( RID_FORMBROWSER_START + 229 )
+#define RID_STR_XSD_PATTERN ( RID_FORMBROWSER_START + 230 )
+#define RID_STR_XSD_LENGTH ( RID_FORMBROWSER_START + 231 )
+#define RID_STR_XSD_MIN_LENGTH ( RID_FORMBROWSER_START + 232 )
+#define RID_STR_XSD_MAX_LENGTH ( RID_FORMBROWSER_START + 233 )
+#define RID_STR_XSD_TOTAL_DIGITS ( RID_FORMBROWSER_START + 234 )
+#define RID_STR_XSD_FRACTION_DIGITS ( RID_FORMBROWSER_START + 235 )
+#define RID_STR_XSD_MAX_INCLUSIVE ( RID_FORMBROWSER_START + 236 )
+#define RID_STR_XSD_MAX_EXCLUSIVE ( RID_FORMBROWSER_START + 237 )
+#define RID_STR_XSD_MIN_INCLUSIVE ( RID_FORMBROWSER_START + 238 )
+#define RID_STR_XSD_MIN_EXCLUSIVE ( RID_FORMBROWSER_START + 239 )
+#define RID_STR_SUBMISSION_ID ( RID_FORMBROWSER_START + 240 )
+#define RID_STR_LIST_BINDING ( RID_FORMBROWSER_START + 241 )
+#define RID_STR_BINDING_UI_NAME ( RID_FORMBROWSER_START + 242 )
+#define RID_STR_BINDING_NAME RID_STR_BINDING_UI_NAME
+#define RID_STR_DECORATION ( RID_FORMBROWSER_START + 243 )
+#define RID_STR_SELECTION_TYPE ( RID_FORMBROWSER_START + 244 )
+#define RID_STR_ROOT_DISPLAYED ( RID_FORMBROWSER_START + 245 )
+#define RID_STR_SHOWS_HANDLES ( RID_FORMBROWSER_START + 246 )
+#define RID_STR_SHOWS_ROOT_HANDLES ( RID_FORMBROWSER_START + 247 )
+#define RID_STR_EDITABLE ( RID_FORMBROWSER_START + 248 )
+#define RID_STR_INVOKES_STOP_NOT_EDITING ( RID_FORMBROWSER_START + 249 )
+#define RID_STR_NOLABEL ( RID_FORMBROWSER_START + 250 )
+#define RID_STR_FONTSTYLE_REGULAR ( RID_FORMBROWSER_START + 251 )
+#define RID_STR_FONTSTYLE_BOLD_ITALIC ( RID_FORMBROWSER_START + 252 )
+#define RID_STR_FONTSTYLE_ITALIC ( RID_FORMBROWSER_START + 253 )
+#define RID_STR_FONTSTYLE_BOLD ( RID_FORMBROWSER_START + 254 )
+#define RID_STR_FONT_DEFAULT ( RID_FORMBROWSER_START + 255 )
+
+
+// -----------------------------------------------------------------------
+// - message strings
+
+#define RID_STR_CONFIRM_DELETE_DATA_TYPE ( RID_FORMBROWSER_START + 500 )
+
+// -----------------------------------------------------------------------
+// - dialogs
+
+#define RID_DLG_SELECTLABELCONTROL ( RID_PROPCONTROLLER_START + 0 )
+#define RID_DLG_TABORDER ( RID_PROPCONTROLLER_START + 1 )
+#define RID_DLG_FORMLINKS ( RID_PROPCONTROLLER_START + 2 )
+#define RID_DLG_SELECTION ( RID_PROPCONTROLLER_START + 3 )
+#define RID_DLG_NEW_DATA_TYPE ( RID_PROPCONTROLLER_START + 4 )
+
+// -----------------------------------------------------------------------
+// - tab dialogs
+
+#define RID_TABDLG_FONTDIALOG ( RID_PROPCONTROLLER_START + 0 )
+
+// -----------------------------------------------------------------------
+// - ImageLists
+
+#define RID_IL_FORMEXPLORER ( RID_PROPCONTROLLER_START + 0 )
+#define RID_IL_FORMEXPLORER_HC ( RID_PROPCONTROLLER_START + 1 )
+
+// -----------------------------------------------------------------------
+// - untyped resources
+
+#define RID_RSC_ENUM_SCROLLBARS ( RID_PROPCONTROLLER_START + 0 )
+#define RID_RSC_ENUM_COMMAND_TYPE ( RID_PROPCONTROLLER_START + 1 )
+#define RID_RSC_ENUM_LINEEND_FORMAT ( RID_PROPCONTROLLER_START + 2 )
+#define RID_RSC_ENUM_TEXTTYPE ( RID_PROPCONTROLLER_START + 3 )
+#define RID_RSC_ENUM_VISUALEFFECT ( RID_PROPCONTROLLER_START + 4 )
+#define RID_RSC_ENUM_IMAGE_POSITION ( RID_PROPCONTROLLER_START + 5 )
+#define RID_RSC_BUTTON_IMAGES ( RID_PROPCONTROLLER_START + 6 )
+#define RID_RSC_ENUM_WHITESPACE_HANDLING ( RID_PROPCONTROLLER_START + 7 )
+#define RID_RSC_ENUM_VERTICAL_ALIGN ( RID_PROPCONTROLLER_START + 8 )
+#define RID_RSC_ENUM_BORDER_TYPE ( RID_PROPCONTROLLER_START + 9 )
+#define RID_RSC_ENUM_ICONSIZE_TYPE ( RID_PROPCONTROLLER_START + 10 )
+#define RID_RSC_ENUM_LISTSOURCE_TYPE ( RID_PROPCONTROLLER_START + 11 )
+#define RID_RSC_ENUM_ALIGNMENT ( RID_PROPCONTROLLER_START + 12 )
+#define RID_RSC_ENUM_BUTTONTYPE ( RID_PROPCONTROLLER_START + 13 )
+#define RID_RSC_ENUM_PUSHBUTTONTYPE ( RID_PROPCONTROLLER_START + 14 )
+#define RID_RSC_ENUM_SUBMIT_METHOD ( RID_PROPCONTROLLER_START + 15 )
+#define RID_RSC_ENUM_SUBMIT_ENCODING ( RID_PROPCONTROLLER_START + 16 )
+#define RID_RSC_ENUM_DATEFORMAT_LIST ( RID_PROPCONTROLLER_START + 17 )
+#define RID_RSC_ENUM_TIMEFORMAT_LIST ( RID_PROPCONTROLLER_START + 18 )
+#define RID_RSC_ENUM_CHECKED ( RID_PROPCONTROLLER_START + 19 )
+#define RID_RSC_ENUM_CYCLE ( RID_PROPCONTROLLER_START + 20 )
+#define RID_RSC_ENUM_NAVIGATION ( RID_PROPCONTROLLER_START + 21 )
+#define RID_RSC_ENUM_ORIENTATION ( RID_PROPCONTROLLER_START + 22 )
+#define RID_RSC_ENUM_CELL_EXCHANGE_TYPE ( RID_PROPCONTROLLER_START + 23 )
+#define RID_RSC_ENUM_SUBMIT_TARGET ( RID_PROPCONTROLLER_START + 24 )
+#define RID_RSC_ENUM_SELECTION_TYPE ( RID_PROPCONTROLLER_START + 25 )
+#define RID_RSC_ENUM_SCALE_MODE ( RID_PROPCONTROLLER_START + 26 )
+#define RID_RSC_ENUM_YESNO ( RID_PROPCONTROLLER_START + 27 )
+#define RID_RSC_ENUM_SHOWHIDE ( RID_PROPCONTROLLER_START + 28 )
+#define RID_RSC_ENUM_WRITING_MODE ( RID_PROPCONTROLLER_START + 29 )
+#define RID_RSC_ENUM_WHEEL_BEHAVIOR ( RID_PROPCONTROLLER_START + 30 )
+#define RID_RSC_ENUM_TEXT_ANCHOR_TYPE ( RID_PROPCONTROLLER_START + 31 )
+#define RID_RSC_ENUM_SHEET_ANCHOR_TYPE ( RID_PROPCONTROLLER_START + 32 )
+
+// -----------------------------------------------------------------------
+// - ImageList - local ids
+// -----------------------------------------------------------------------
+// HACK HACK HACK
+// as long as we have no real property browser, but this outsourcing only,
+// we do not duplicate images. Instead we do some hard coding for the image ids
+
+
+#define RID_SVXIMG_CONTROL 10144
+#define RID_SVXIMG_BUTTON 10594
+#define RID_SVXIMG_RADIOBUTTON 10595
+#define RID_SVXIMG_CHECKBOX 10596
+#define RID_SVXIMG_FIXEDTEXT 10597
+#define RID_SVXIMG_GROUPBOX 10598
+#define RID_SVXIMG_EDIT 10599
+#define RID_SVXIMG_LISTBOX 10600
+#define RID_SVXIMG_COMBOBOX 10601
+#define RID_SVXIMG_URLBUTTON 10602
+#define RID_SVXIMG_GRID 10603
+#define RID_SVXIMG_IMAGEBUTTON 10604
+#define RID_SVXIMG_FILECONTROL 10605
+#define RID_SVXIMG_DATEFIELD 10704
+#define RID_SVXIMG_TIMEFIELD 10705
+#define RID_SVXIMG_NUMERICFIELD 10706
+#define RID_SVXIMG_CURRENCYFIELD 10707
+#define RID_SVXIMG_PATTERNFIELD 10708
+#define RID_SVXIMG_IMAGECONTROL 10710
+#define RID_SVXIMG_HIDDEN 18022
+#define RID_SVXIMG_FORMATTEDFIELD 10728
+#define RID_SVXIMG_FILTER 10715
+#define RID_SVXIMG_FORMS 18013
+#define RID_SVXIMG_FORM 10593
+#define RID_SVXIMG_COLLAPSEDNODE 18002
+#define RID_SVXIMG_EXPANDEDNODE 18003
+#define RID_SVXIMG_SCROLLBAR 10768
+#define RID_SVXIMG_SPINBUTTON 10769
+#define RID_SVXIMG_NAVIGATIONBAR 10607
+
+
+#endif // _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
+
diff --git a/extensions/source/propctrlr/formstrings.cxx b/extensions/source/propctrlr/formstrings.cxx
new file mode 100644
index 000000000000..57aff105567b
--- /dev/null
+++ b/extensions/source/propctrlr/formstrings.cxx
@@ -0,0 +1,36 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#ifndef _EXTENSIONS_FORMSCTRLR_FORMSTRINGS_HXX_
+#define PCR_IMPLEMENT_STRINGS
+#include "formstrings.hxx"
+#undef PCR_IMPLEMENT_STRINGS
+#endif
+
diff --git a/extensions/source/propctrlr/formstrings.hxx b/extensions/source/propctrlr/formstrings.hxx
new file mode 100644
index 000000000000..20b0dd34b2cd
--- /dev/null
+++ b/extensions/source/propctrlr/formstrings.hxx
@@ -0,0 +1,307 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_FORMSCTRLR_FORMSTRINGS_HXX_
+#define _EXTENSIONS_FORMSCTRLR_FORMSTRINGS_HXX_
+
+#include "stringdefine.hxx"
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ PCR_CONSTASCII_STRING( PROPERTY_DEFAULTCONTROL, "DefaultControl" );
+ PCR_CONSTASCII_STRING( PROPERTY_INTROSPECTEDOBJECT, "IntrospectedObject" );
+ PCR_CONSTASCII_STRING( PROPERTY_CURRENTPAGE, "CurrentPage" );
+ PCR_CONSTASCII_STRING( PROPERTY_CONTROLCONTEXT, "ControlContext" );
+
+ // properties
+ PCR_CONSTASCII_STRING( PROPERTY_CLASSID, "ClassId" );
+ PCR_CONSTASCII_STRING( PROPERTY_CONTROLLABEL, "LabelControl");
+ PCR_CONSTASCII_STRING( PROPERTY_LABEL, "Label");
+ PCR_CONSTASCII_STRING( PROPERTY_TABINDEX, "TabIndex");
+ PCR_CONSTASCII_STRING( PROPERTY_WHEEL_BEHAVIOR, "MouseWheelBehavior");
+ PCR_CONSTASCII_STRING( PROPERTY_TAG, "Tag");
+ PCR_CONSTASCII_STRING( PROPERTY_NAME, "Name");
+ PCR_CONSTASCII_STRING( PROPERTY_VALUE, "Value");
+ PCR_CONSTASCII_STRING( PROPERTY_TEXT, "Text");
+ PCR_CONSTASCII_STRING( PROPERTY_NAVIGATION, "NavigationBarMode");
+ PCR_CONSTASCII_STRING( PROPERTY_CYCLE, "Cycle");
+ PCR_CONSTASCII_STRING( PROPERTY_CONTROLSOURCE, "DataField");
+ PCR_CONSTASCII_STRING( PROPERTY_INPUT_REQUIRED, "InputRequired");
+ PCR_CONSTASCII_STRING( PROPERTY_ENABLED, "Enabled");
+ PCR_CONSTASCII_STRING( PROPERTY_ENABLE_VISIBLE, "EnableVisible" );
+ PCR_CONSTASCII_STRING( PROPERTY_READONLY, "ReadOnly");
+ PCR_CONSTASCII_STRING( PROPERTY_ISREADONLY, "IsReadOnly");
+ PCR_CONSTASCII_STRING( PROPERTY_FILTER, "Filter");
+ PCR_CONSTASCII_STRING( PROPERTY_WIDTH, "Width");
+ PCR_CONSTASCII_STRING( PROPERTY_MULTILINE, "MultiLine");
+ PCR_CONSTASCII_STRING( PROPERTY_WORDBREAK, "WordBreak");
+ PCR_CONSTASCII_STRING( PROPERTY_TARGET_URL, "TargetURL");
+ PCR_CONSTASCII_STRING( PROPERTY_TARGET_FRAME, "TargetFrame");
+ PCR_CONSTASCII_STRING( PROPERTY_MAXTEXTLEN, "MaxTextLen");
+ PCR_CONSTASCII_STRING( PROPERTY_EDITMASK, "EditMask");
+ PCR_CONSTASCII_STRING( PROPERTY_SPIN, "Spin");
+ PCR_CONSTASCII_STRING( PROPERTY_TRISTATE, "TriState");
+ PCR_CONSTASCII_STRING( PROPERTY_HIDDEN_VALUE, "HiddenValue");
+ PCR_CONSTASCII_STRING( PROPERTY_BUTTONTYPE, "ButtonType");
+ PCR_CONSTASCII_STRING( PROPERTY_XFORMS_BUTTONTYPE, "XFormsButtonType");
+ PCR_CONSTASCII_STRING( PROPERTY_STRINGITEMLIST, "StringItemList");
+ PCR_CONSTASCII_STRING( PROPERTY_DEFAULT_TEXT, "DefaultText");
+ PCR_CONSTASCII_STRING( PROPERTY_DEFAULT_STATE, "DefaultState");
+ PCR_CONSTASCII_STRING( PROPERTY_FORMATKEY, "FormatKey");
+ PCR_CONSTASCII_STRING( PROPERTY_FORMATSSUPPLIER, "FormatsSupplier");
+ PCR_CONSTASCII_STRING( PROPERTY_SUBMIT_ACTION, "SubmitAction");
+ PCR_CONSTASCII_STRING( PROPERTY_SUBMIT_TARGET, "SubmitTarget");
+ PCR_CONSTASCII_STRING( PROPERTY_SUBMIT_METHOD, "SubmitMethod");
+ PCR_CONSTASCII_STRING( PROPERTY_SUBMIT_ENCODING, "SubmitEncoding");
+ PCR_CONSTASCII_STRING( PROPERTY_IMAGE_URL, "ImageURL");
+ PCR_CONSTASCII_STRING( PROPERTY_EMPTY_IS_NULL, "ConvertEmptyToNull");
+ PCR_CONSTASCII_STRING( PROPERTY_LISTSOURCETYPE, "ListSourceType");
+ PCR_CONSTASCII_STRING( PROPERTY_LISTSOURCE, "ListSource");
+ PCR_CONSTASCII_STRING( PROPERTY_DEFAULT_SELECT_SEQ, "DefaultSelection");
+ PCR_CONSTASCII_STRING( PROPERTY_MULTISELECTION, "MultiSelection");
+ PCR_CONSTASCII_STRING( PROPERTY_ALIGN, "Align");
+ PCR_CONSTASCII_STRING( PROPERTY_VERTICAL_ALIGN, "VerticalAlign");
+ PCR_CONSTASCII_STRING( PROPERTY_DEFAULT_DATE, "DefaultDate");
+ PCR_CONSTASCII_STRING( PROPERTY_DEFAULT_TIME, "DefaultTime");
+ PCR_CONSTASCII_STRING( PROPERTY_DEFAULT_VALUE, "DefaultValue");
+ PCR_CONSTASCII_STRING( PROPERTY_DECIMAL_ACCURACY, "DecimalAccuracy");
+ PCR_CONSTASCII_STRING( PROPERTY_REFVALUE, "RefValue");
+ PCR_CONSTASCII_STRING( PROPERTY_UNCHECKEDREFVALUE, "SecondaryRefValue");
+ PCR_CONSTASCII_STRING( PROPERTY_VALUEMIN, "ValueMin");
+ PCR_CONSTASCII_STRING( PROPERTY_VALUEMAX, "ValueMax");
+ PCR_CONSTASCII_STRING( PROPERTY_STRICTFORMAT, "StrictFormat");
+ PCR_CONSTASCII_STRING( PROPERTY_ALLOWADDITIONS, "AllowInserts");
+ PCR_CONSTASCII_STRING( PROPERTY_ALLOWEDITS, "AllowUpdates");
+ PCR_CONSTASCII_STRING( PROPERTY_ALLOWDELETIONS, "AllowDeletes");
+ PCR_CONSTASCII_STRING( PROPERTY_MASTERFIELDS, "MasterFields");
+ PCR_CONSTASCII_STRING( PROPERTY_LITERALMASK, "LiteralMask");
+ PCR_CONSTASCII_STRING( PROPERTY_VALUESTEP, "ValueStep");
+ PCR_CONSTASCII_STRING( PROPERTY_SHOWTHOUSANDSEP, "ShowThousandsSeparator");
+ PCR_CONSTASCII_STRING( PROPERTY_CURRENCYSYMBOL, "CurrencySymbol");
+ PCR_CONSTASCII_STRING( PROPERTY_DATEFORMAT, "DateFormat");
+ PCR_CONSTASCII_STRING( PROPERTY_DATEMIN, "DateMin");
+ PCR_CONSTASCII_STRING( PROPERTY_DATEMAX, "DateMax");
+ PCR_CONSTASCII_STRING( PROPERTY_TIMEFORMAT, "TimeFormat");
+ PCR_CONSTASCII_STRING( PROPERTY_TIMEMIN, "TimeMin");
+ PCR_CONSTASCII_STRING( PROPERTY_TIMEMAX, "TimeMax");
+ PCR_CONSTASCII_STRING( PROPERTY_LINECOUNT, "LineCount");
+ PCR_CONSTASCII_STRING( PROPERTY_BOUNDCOLUMN, "BoundColumn");
+ PCR_CONSTASCII_STRING( PROPERTY_BACKGROUNDCOLOR, "BackgroundColor");
+ PCR_CONSTASCII_STRING( PROPERTY_FILLCOLOR, "FillColor");
+ PCR_CONSTASCII_STRING( PROPERTY_TEXTCOLOR, "TextColor");
+ PCR_CONSTASCII_STRING( PROPERTY_LINECOLOR, "LineColor");
+ PCR_CONSTASCII_STRING( PROPERTY_BORDER, "Border");
+ PCR_CONSTASCII_STRING( PROPERTY_ICONSIZE, "IconSize");
+ PCR_CONSTASCII_STRING( PROPERTY_DROPDOWN, "Dropdown");
+ PCR_CONSTASCII_STRING( PROPERTY_HSCROLL, "HScroll");
+ PCR_CONSTASCII_STRING( PROPERTY_VSCROLL, "VScroll");
+ PCR_CONSTASCII_STRING( PROPERTY_SHOW_SCROLLBARS, "ShowScrollbars");
+ PCR_CONSTASCII_STRING( PROPERTY_TABSTOP, "Tabstop");
+ PCR_CONSTASCII_STRING( PROPERTY_AUTOCOMPLETE, "Autocomplete");
+ PCR_CONSTASCII_STRING( PROPERTY_PRINTABLE, "Printable");
+ PCR_CONSTASCII_STRING( PROPERTY_ECHO_CHAR, "EchoChar");
+ PCR_CONSTASCII_STRING( PROPERTY_ROWHEIGHT, "RowHeight");
+ PCR_CONSTASCII_STRING( PROPERTY_HELPTEXT, "HelpText");
+ PCR_CONSTASCII_STRING( PROPERTY_FONT, "FontDescriptor");
+ PCR_CONSTASCII_STRING( PROPERTY_FONT_NAME, "FontName");
+ PCR_CONSTASCII_STRING( PROPERTY_FONT_STYLENAME, "FontStyleName");
+ PCR_CONSTASCII_STRING( PROPERTY_FONT_FAMILY, "FontFamily");
+ PCR_CONSTASCII_STRING( PROPERTY_FONT_CHARSET, "FontCharset");
+ PCR_CONSTASCII_STRING( PROPERTY_FONT_HEIGHT, "FontHeight");
+ PCR_CONSTASCII_STRING( PROPERTY_FONT_WEIGHT, "FontWeight");
+ PCR_CONSTASCII_STRING( PROPERTY_FONT_SLANT, "FontSlant");
+ PCR_CONSTASCII_STRING( PROPERTY_FONT_UNDERLINE, "FontUnderline");
+ PCR_CONSTASCII_STRING( PROPERTY_FONT_STRIKEOUT, "FontStrikeout");
+ PCR_CONSTASCII_STRING( PROPERTY_FONT_RELIEF, "FontRelief");
+ PCR_CONSTASCII_STRING( PROPERTY_FONT_EMPHASIS_MARK, "FontEmphasisMark");
+ PCR_CONSTASCII_STRING( PROPERTY_TEXTLINECOLOR, "TextLineColor");
+ PCR_CONSTASCII_STRING( PROPERTY_HELPURL, "HelpURL");
+ PCR_CONSTASCII_STRING( PROPERTY_RECORDMARKER, "HasRecordMarker");
+ PCR_CONSTASCII_STRING( PROPERTY_EFFECTIVE_DEFAULT, "EffectiveDefault");
+ PCR_CONSTASCII_STRING( PROPERTY_EFFECTIVE_MIN, "EffectiveMin");
+ PCR_CONSTASCII_STRING( PROPERTY_EFFECTIVE_MAX, "EffectiveMax");
+ PCR_CONSTASCII_STRING( PROPERTY_FILTERPROPOSAL, "UseFilterValueProposal");
+ PCR_CONSTASCII_STRING( PROPERTY_CURRSYM_POSITION, "PrependCurrencySymbol");
+ PCR_CONSTASCII_STRING( PROPERTY_COMMAND, "Command");
+ PCR_CONSTASCII_STRING( PROPERTY_COMMANDTYPE, "CommandType");
+ PCR_CONSTASCII_STRING( PROPERTY_INSERTONLY, "IgnoreResult");
+ PCR_CONSTASCII_STRING( PROPERTY_ESCAPE_PROCESSING, "EscapeProcessing");
+ PCR_CONSTASCII_STRING( PROPERTY_TITLE, "Title");
+ PCR_CONSTASCII_STRING( PROPERTY_SORT, "Order");
+ PCR_CONSTASCII_STRING( PROPERTY_DATASOURCE, "DataSourceName");
+ PCR_CONSTASCII_STRING( PROPERTY_DETAILFIELDS, "DetailFields");
+ PCR_CONSTASCII_STRING( PROPERTY_DEFAULTBUTTON, "DefaultButton");
+ PCR_CONSTASCII_STRING( PROPERTY_LISTINDEX, "ListIndex");
+ PCR_CONSTASCII_STRING( PROPERTY_HEIGHT, "Height");
+ PCR_CONSTASCII_STRING( PROPERTY_HASNAVIGATION, "HasNavigationBar");
+ PCR_CONSTASCII_STRING( PROPERTY_POSITIONX, "PositionX");
+ PCR_CONSTASCII_STRING( PROPERTY_POSITIONY, "PositionY");
+ PCR_CONSTASCII_STRING( PROPERTY_STEP, "Step");
+ PCR_CONSTASCII_STRING( PROPERTY_WORDLINEMODE, "FontWordLineMode");
+ PCR_CONSTASCII_STRING( PROPERTY_PROGRESSVALUE, "ProgressValue");
+ PCR_CONSTASCII_STRING( PROPERTY_PROGRESSVALUE_MIN, "ProgressValueMin");
+ PCR_CONSTASCII_STRING( PROPERTY_PROGRESSVALUE_MAX, "ProgressValueMax");
+ PCR_CONSTASCII_STRING( PROPERTY_SCROLLVALUE, "ScrollValue");
+ PCR_CONSTASCII_STRING( PROPERTY_DEFAULT_SCROLLVALUE, "DefaultScrollValue");
+ PCR_CONSTASCII_STRING( PROPERTY_SCROLLVALUE_MIN, "ScrollValueMin");
+ PCR_CONSTASCII_STRING( PROPERTY_SCROLLVALUE_MAX, "ScrollValueMax");
+ PCR_CONSTASCII_STRING( PROPERTY_LINEINCREMENT, "LineIncrement");
+ PCR_CONSTASCII_STRING( PROPERTY_BLOCKINCREMENT, "BlockIncrement");
+ PCR_CONSTASCII_STRING( PROPERTY_VISIBLESIZE, "VisibleSize");
+ PCR_CONSTASCII_STRING( PROPERTY_ORIENTATION, "Orientation");
+ PCR_CONSTASCII_STRING( PROPERTY_IMAGEPOSITION, "ImagePosition");
+ PCR_CONSTASCII_STRING( PROPERTY_ACTIVE_CONNECTION, "ActiveConnection");
+ PCR_CONSTASCII_STRING( PROPERTY_ACTIVECOMMAND, "ActiveCommand");
+ PCR_CONSTASCII_STRING( PROPERTY_DATE, "Date");
+ PCR_CONSTASCII_STRING( PROPERTY_STATE, "State");
+ PCR_CONSTASCII_STRING( PROPERTY_TIME, "Time");
+ PCR_CONSTASCII_STRING( PROPERTY_SCALEIMAGE, "ScaleImage");
+ PCR_CONSTASCII_STRING( PROPERTY_SCALE_MODE, "ScaleMode");
+ PCR_CONSTASCII_STRING( PROPERTY_PUSHBUTTONTYPE, "PushButtonType");
+ PCR_CONSTASCII_STRING( PROPERTY_EFFECTIVE_VALUE, "EffectiveValue");
+ PCR_CONSTASCII_STRING( PROPERTY_SELECTEDITEMS, "SelectedItems");
+ PCR_CONSTASCII_STRING( PROPERTY_REPEAT, "Repeat");
+ PCR_CONSTASCII_STRING( PROPERTY_REPEAT_DELAY, "RepeatDelay");
+ PCR_CONSTASCII_STRING( PROPERTY_SYMBOLCOLOR, "SymbolColor");
+ PCR_CONSTASCII_STRING( PROPERTY_SPINVALUE, "SpinValue");
+ PCR_CONSTASCII_STRING( PROPERTY_SPINVALUE_MIN, "SpinValueMin");
+ PCR_CONSTASCII_STRING( PROPERTY_SPINVALUE_MAX, "SpinValueMax");
+ PCR_CONSTASCII_STRING( PROPERTY_DEFAULT_SPINVALUE, "DefaultSpinValue");
+ PCR_CONSTASCII_STRING( PROPERTY_SPININCREMENT, "SpinIncrement");
+ PCR_CONSTASCII_STRING( PROPERTY_SHOW_POSITION, "ShowPosition" );
+ PCR_CONSTASCII_STRING( PROPERTY_SHOW_NAVIGATION, "ShowNavigation" );
+ PCR_CONSTASCII_STRING( PROPERTY_SHOW_RECORDACTIONS, "ShowRecordActions" );
+ PCR_CONSTASCII_STRING( PROPERTY_SHOW_FILTERSORT, "ShowFilterSort" );
+ PCR_CONSTASCII_STRING( PROPERTY_LINEEND_FORMAT, "LineEndFormat");
+ PCR_CONSTASCII_STRING( PROPERTY_DECORATION, "Decoration" );
+ PCR_CONSTASCII_STRING( PROPERTY_NOLABEL, "NoLabel" );
+
+ PCR_CONSTASCII_STRING( PROPERTY_SELECTION_TYPE, "SelectionType");
+ PCR_CONSTASCII_STRING( PROPERTY_ROOT_DISPLAYED, "RootDisplayed");
+ PCR_CONSTASCII_STRING( PROPERTY_SHOWS_HANDLES, "ShowsHandles");
+ PCR_CONSTASCII_STRING( PROPERTY_SHOWS_ROOT_HANDLES, "ShowsRootHandles");
+ PCR_CONSTASCII_STRING( PROPERTY_EDITABLE, "Editable");
+ PCR_CONSTASCII_STRING( PROPERTY_INVOKES_STOP_NOT_EDITING, "InvokesStopNodeEditing");
+
+ PCR_CONSTASCII_STRING( PROPERTY_HARDLINEBREAKS, "HardLineBreaks");
+
+ PCR_CONSTASCII_STRING( PROPERTY_TOGGLE, "Toggle" );
+ PCR_CONSTASCII_STRING( PROPERTY_FOCUSONCLICK, "FocusOnClick" );
+ PCR_CONSTASCII_STRING( PROPERTY_HIDEINACTIVESELECTION, "HideInactiveSelection" );
+ PCR_CONSTASCII_STRING( PROPERTY_VISUALEFFECT, "VisualEffect" );
+ PCR_CONSTASCII_STRING( PROPERTY_BORDERCOLOR, "BorderColor" );
+
+ PCR_CONSTASCII_STRING( PROPERTY_ADDRESS, "Address");
+ PCR_CONSTASCII_STRING( PROPERTY_REFERENCE_SHEET, "ReferenceSheet");
+ PCR_CONSTASCII_STRING( PROPERTY_UI_REPRESENTATION, "UserInterfaceRepresentation");
+
+ PCR_CONSTASCII_STRING( PROPERTY_XML_DATA_MODEL, "XMLDataModel" );
+ PCR_CONSTASCII_STRING( PROPERTY_BINDING_NAME, "BindingName" );
+ PCR_CONSTASCII_STRING( PROPERTY_BIND_EXPRESSION, "BindingExpression" );
+ PCR_CONSTASCII_STRING( PROPERTY_LIST_BINDING, "ListBinding" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_REQUIRED, "RequiredExpression" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_RELEVANT, "RelevantExpression" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_READONLY, "ReadonlyExpression" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_CONSTRAINT, "ConstraintExpression" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_CALCULATION, "CalculateExpression" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_DATA_TYPE, "Type" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_WHITESPACES, "WhiteSpace" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_PATTERN, "Pattern" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_LENGTH, "Length" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MIN_LENGTH, "MinLength" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MAX_LENGTH, "MaxLength" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_TOTAL_DIGITS, "TotalDigits" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_FRACTION_DIGITS, "FractionDigits" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MAX_INCLUSIVE_INT, "MaxInclusiveInt" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MAX_EXCLUSIVE_INT, "MaxExclusiveInt" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MIN_INCLUSIVE_INT, "MinInclusiveInt" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MIN_EXCLUSIVE_INT, "MinExclusiveInt" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MAX_INCLUSIVE_DOUBLE, "MaxInclusiveDouble" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MAX_EXCLUSIVE_DOUBLE, "MaxExclusiveDouble" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MIN_INCLUSIVE_DOUBLE, "MinInclusiveDouble" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MIN_EXCLUSIVE_DOUBLE, "MinExclusiveDouble" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MAX_INCLUSIVE_DATE, "MaxInclusiveDate" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MAX_EXCLUSIVE_DATE, "MaxExclusiveDate" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MIN_INCLUSIVE_DATE, "MinInclusiveDate" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MIN_EXCLUSIVE_DATE, "MinExclusiveDate" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MAX_INCLUSIVE_TIME, "MaxInclusiveTime" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MAX_EXCLUSIVE_TIME, "MaxExclusiveTime" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MIN_INCLUSIVE_TIME, "MinInclusiveTime" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MIN_EXCLUSIVE_TIME, "MinExclusiveTime" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MAX_INCLUSIVE_DATE_TIME, "MaxInclusiveDateTime" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MAX_EXCLUSIVE_DATE_TIME, "MaxExclusiveDateTime" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MIN_INCLUSIVE_DATE_TIME, "MinInclusiveDateTime" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MIN_EXCLUSIVE_DATE_TIME, "MinExclusiveDateTime" );
+ PCR_CONSTASCII_STRING( PROPERTY_SUBMISSION_ID, "SubmissionID" );
+ PCR_CONSTASCII_STRING( PROPERTY_BINDING_ID, "BindingID" );
+ PCR_CONSTASCII_STRING( PROPERTY_ID, "ID" );
+ PCR_CONSTASCII_STRING( PROPERTY_WRITING_MODE, "WritingMode" );
+ PCR_CONSTASCII_STRING( PROPERTY_TEXT_ANCHOR_TYPE, "TextAnchorType" );
+ PCR_CONSTASCII_STRING( PROPERTY_SHEET_ANCHOR_TYPE, "SheetAnchorType" );
+ PCR_CONSTASCII_STRING( PROPERTY_ANCHOR_TYPE, "AnchorType" );
+ PCR_CONSTASCII_STRING( PROPERTY_ANCHOR, "Anchor" );
+ PCR_CONSTASCII_STRING( PROPERTY_IS_VISIBLE, "IsVisible" );
+
+ PCR_CONSTASCII_STRING( PROPERTY_MODEL, "Model" );
+
+ PCR_CONSTASCII_STRING( PROPERTY_CELL_EXCHANGE_TYPE, "ExchangeSelectionIndex");
+ PCR_CONSTASCII_STRING( PROPERTY_BOUND_CELL, "BoundCell");
+ PCR_CONSTASCII_STRING( PROPERTY_LIST_CELL_RANGE, "CellRange");
+ PCR_CONSTASCII_STRING( PROPERTY_AUTOLINEBREAK, "AutomaticLineBreak");
+ PCR_CONSTASCII_STRING( PROPERTY_TEXTTYPE, "TextType");
+ PCR_CONSTASCII_STRING( PROPERTY_RICHTEXT, "RichText");
+ PCR_CONSTASCII_STRING( PROPERTY_ROWSET, "RowSet");
+
+ // services
+ PCR_CONSTASCII_STRING( SERVICE_COMPONENT_GROUPBOX, "com.sun.star.form.component.GroupBox" );
+ PCR_CONSTASCII_STRING( SERVICE_COMPONENT_FIXEDTEXT, "com.sun.star.form.component.FixedText" );
+ PCR_CONSTASCII_STRING( SERVICE_COMPONENT_FORMATTEDFIELD,"com.sun.star.form.component.FormattedField" );
+ PCR_CONSTASCII_STRING( SERVICE_DATABASE_CONTEXT, "com.sun.star.sdb.DatabaseContext" );
+
+ PCR_CONSTASCII_STRING( SERVICE_TEXT_DOCUMENT, "com.sun.star.text.TextDocument" );
+ PCR_CONSTASCII_STRING( SERVICE_WEB_DOCUMENT, "com.sun.star.text.WebDocument" );
+ PCR_CONSTASCII_STRING( SERVICE_SPREADSHEET_DOCUMENT, "com.sun.star.sheet.SpreadsheetDocument" );
+ PCR_CONSTASCII_STRING( SERVICE_DRAWING_DOCUMENT, "com.sun.star.drawing.DrawingDocument" );
+ PCR_CONSTASCII_STRING( SERVICE_PRESENTATION_DOCUMENT, "com.sun.star.presentation.PresentationDocument" );
+
+ PCR_CONSTASCII_STRING( SERVICE_SHEET_CELL_BINDING, "com.sun.star.table.CellValueBinding" );
+ PCR_CONSTASCII_STRING( SERVICE_SHEET_CELL_INT_BINDING, "com.sun.star.table.ListPositionCellBinding" );
+ PCR_CONSTASCII_STRING( SERVICE_SHEET_CELLRANGE_LISTSOURCE, "com.sun.star.table.CellRangeListSource" );
+ PCR_CONSTASCII_STRING( SERVICE_ADDRESS_CONVERSION, "com.sun.star.table.CellAddressConversion" );
+ PCR_CONSTASCII_STRING( SERVICE_RANGEADDRESS_CONVERSION, "com.sun.star.table.CellRangeAddressConversion" );
+
+ PCR_CONSTASCII_STRING( SERVICE_DESKTOP, "com.sun.star.frame.Desktop" );
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_FORMSCTRLR_FORMSTRINGS_HXX_
+
diff --git a/extensions/source/propctrlr/genericpropertyhandler.cxx b/extensions/source/propctrlr/genericpropertyhandler.cxx
new file mode 100644
index 000000000000..65514038181d
--- /dev/null
+++ b/extensions/source/propctrlr/genericpropertyhandler.cxx
@@ -0,0 +1,726 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "genericpropertyhandler.hxx"
+#include "formmetadata.hxx"
+#include "handlerhelper.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/reflection/XEnumTypeDescription.hpp>
+#include <com/sun/star/beans/XIntrospection.hpp>
+#include <com/sun/star/inspection/PropertyControlType.hpp>
+#include <com/sun/star/inspection/XHyperlinkControl.hpp>
+#include <com/sun/star/awt/XActionListener.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+/** === end UNO includes === **/
+#include <tools/debug.hxx>
+#include <comphelper/extract.hxx>
+
+#include <algorithm>
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_GenericPropertyHandler()
+{
+ ::pcr::OAutoRegistration< ::pcr::GenericPropertyHandler > aAutoRegistration;
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::script;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::reflection;
+ using namespace ::com::sun::star::inspection;
+ using ::com::sun::star::awt::XActionListener;
+ using ::com::sun::star::awt::ActionEvent;
+
+ //====================================================================
+ //= EnumRepresentation
+ //====================================================================
+ class EnumRepresentation : public IPropertyEnumRepresentation
+ {
+ private:
+ oslInterlockedCount m_refCount;
+ Reference< XEnumTypeDescription > m_xTypeDescription;
+ Type m_aEnumType;
+
+ public:
+ EnumRepresentation( const Reference< XComponentContext >& _rxContext, const Type& _rEnumType );
+
+ // IPropertyEnumRepresentation implementqation
+ virtual ::std::vector< ::rtl::OUString >
+ SAL_CALL getDescriptions() const;
+ virtual void SAL_CALL getValueFromDescription( const ::rtl::OUString& _rDescription, ::com::sun::star::uno::Any& _out_rValue ) const;
+ virtual ::rtl::OUString SAL_CALL getDescriptionForValue( const ::com::sun::star::uno::Any& _rEnumValue ) const;
+
+ // IReference implementqation
+ virtual oslInterlockedCount SAL_CALL acquire();
+ virtual oslInterlockedCount SAL_CALL release();
+
+ private:
+ void impl_getValues( Sequence< sal_Int32 >& _out_rValues ) const;
+
+ private:
+ EnumRepresentation(); // never implemented
+ EnumRepresentation( const EnumRepresentation& ); // never implemented
+ EnumRepresentation& operator=( const EnumRepresentation& ); // never implemented
+ };
+
+ //--------------------------------------------------------------------
+ EnumRepresentation::EnumRepresentation( const Reference< XComponentContext >& _rxContext, const Type& _rEnumType )
+ :m_refCount( 0 )
+ ,m_aEnumType( _rEnumType )
+ {
+ try
+ {
+ if ( _rxContext.is() )
+ {
+ Reference< XHierarchicalNameAccess > xTypeDescProv(
+ _rxContext->getValueByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/singletons/com.sun.star.reflection.theTypeDescriptionManager" ) ) ),
+ UNO_QUERY_THROW );
+
+ m_xTypeDescription = Reference< XEnumTypeDescription >( xTypeDescProv->getByHierarchicalName( m_aEnumType.getTypeName() ), UNO_QUERY_THROW );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EnumRepresentation::EnumRepresentation: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ ::std::vector< ::rtl::OUString > EnumRepresentation::getDescriptions() const
+ {
+ Sequence< ::rtl::OUString > aNames;
+ try
+ {
+ if ( m_xTypeDescription.is() )
+ aNames = m_xTypeDescription->getEnumNames();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EnumRepresentation::getDescriptions: caught an exception!" );
+ }
+
+ return ::std::vector< ::rtl::OUString >( aNames.getConstArray(), aNames.getConstArray() + aNames.getLength() );
+ }
+
+ //--------------------------------------------------------------------
+ void EnumRepresentation::impl_getValues( Sequence< sal_Int32 >& _out_rValues ) const
+ {
+ _out_rValues.realloc( 0 );
+ try
+ {
+ if ( m_xTypeDescription.is() )
+ _out_rValues = m_xTypeDescription->getEnumValues();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EnumRepresentation::impl_getValues: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void EnumRepresentation::getValueFromDescription( const ::rtl::OUString& _rDescription, Any& _out_rValue ) const
+ {
+ ::std::vector< ::rtl::OUString > aDescriptions( getDescriptions() );
+
+ sal_Int32 index = ::std::find( aDescriptions.begin(), aDescriptions.end(),
+ _rDescription ) - aDescriptions.begin();
+
+ Sequence< sal_Int32 > aValues;
+ impl_getValues( aValues );
+
+ if ( ( index >= 0 ) && ( index < aValues.getLength() ) )
+ _out_rValue = ::cppu::int2enum( aValues[ index ], m_aEnumType );
+ else
+ {
+ DBG_ERROR( "EnumRepresentation::getValueFromDescription: cannot convert!" );
+ _out_rValue.clear();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString EnumRepresentation::getDescriptionForValue( const Any& _rEnumValue ) const
+ {
+ ::rtl::OUString sDescription;
+
+ sal_Int32 nAsInt = 0;
+ OSL_VERIFY( ::cppu::enum2int( nAsInt, _rEnumValue ) );
+
+ Sequence< sal_Int32 > aValues;
+ impl_getValues( aValues );
+
+ sal_Int32 index = ::std::find( aValues.getConstArray(), aValues.getConstArray() + aValues.getLength(),
+ nAsInt ) - aValues.getConstArray();
+
+ ::std::vector< ::rtl::OUString > aDescriptions( getDescriptions() );
+ if ( ( index >= 0 ) && ( index < (sal_Int32)aDescriptions.size() ) )
+ sDescription = aDescriptions[ index ];
+ else
+ {
+ DBG_ERROR( "EnumRepresentation::getDescriptionForValue: cannot convert!" );
+ }
+ return sDescription;
+ }
+
+ //--------------------------------------------------------------------
+ oslInterlockedCount SAL_CALL EnumRepresentation::acquire()
+ {
+ return osl_incrementInterlockedCount( &m_refCount );
+ }
+
+ //--------------------------------------------------------------------
+ oslInterlockedCount SAL_CALL EnumRepresentation::release()
+ {
+ if ( 0 == osl_decrementInterlockedCount( &m_refCount ) )
+ {
+ delete this;
+ return 0;
+ }
+ return m_refCount;
+ }
+
+ //====================================================================
+ //= UrlClickHandler
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < XActionListener
+ > UrlClickHandler_Base;
+ class UrlClickHandler : public UrlClickHandler_Base
+ {
+ ComponentContext m_aContext;
+ public:
+ UrlClickHandler( const ComponentContext& _rContext, const Reference< XHyperlinkControl >& _rxControl );
+
+ protected:
+ ~UrlClickHandler();
+
+ // XActionListener
+ virtual void SAL_CALL actionPerformed( const ActionEvent& rEvent ) throw (RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException);
+
+ protected:
+ void impl_dispatch_throw( const ::rtl::OUString& _rURL );
+ };
+
+ //--------------------------------------------------------------------
+ DBG_NAME( UrlClickHandler )
+ //--------------------------------------------------------------------
+ UrlClickHandler::UrlClickHandler( const ComponentContext& _rContext, const Reference< XHyperlinkControl >& _rxControl )
+ :m_aContext( _rContext )
+ {
+ if ( !_rxControl.is() )
+ throw NullPointerException();
+
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ _rxControl->addActionListener( this );
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ OSL_ENSURE( m_refCount > 0, "UrlClickHandler::UrlClickHandler: leaking!" );
+
+ DBG_CTOR( UrlClickHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ UrlClickHandler::~UrlClickHandler()
+ {
+ DBG_DTOR( UrlClickHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL UrlClickHandler::actionPerformed( const ActionEvent& rEvent ) throw (RuntimeException)
+ {
+ Reference< XPropertyControl > xControl( rEvent.Source, UNO_QUERY_THROW );
+ Any aControlValue( xControl->getValue() );
+
+ ::rtl::OUString sURL;
+ if ( aControlValue.hasValue() && !( aControlValue >>= sURL ) )
+ throw RuntimeException( ::rtl::OUString(), *this );
+
+ if ( !sURL.getLength() )
+ return;
+
+ impl_dispatch_throw( sURL );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL UrlClickHandler::disposing( const EventObject& /*Source*/ ) throw (RuntimeException)
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void UrlClickHandler::impl_dispatch_throw( const ::rtl::OUString& _rURL )
+ {
+ Reference< XURLTransformer > xTransformer( m_aContext.createComponent( "com.sun.star.util.URLTransformer" ), UNO_QUERY_THROW );
+ URL aURL; aURL.Complete = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:OpenHyperlink" ) );
+ xTransformer->parseStrict( aURL );
+
+ Reference< XDispatchProvider > xDispProv( m_aContext.createComponent( "com.sun.star.frame.Desktop" ), UNO_QUERY_THROW );
+ Reference< XDispatch > xDispatch( xDispProv->queryDispatch( aURL, ::rtl::OUString(), 0 ), UNO_QUERY_THROW );
+
+ Sequence< PropertyValue > aDispatchArgs(1);
+ aDispatchArgs[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL"));
+ aDispatchArgs[0].Value <<= _rURL;
+
+ xDispatch->dispatch( aURL, aDispatchArgs );
+ }
+
+ //====================================================================
+ //= GenericPropertyHandler
+ //====================================================================
+ DBG_NAME( GenericPropertyHandler )
+ //--------------------------------------------------------------------
+ GenericPropertyHandler::GenericPropertyHandler( const Reference< XComponentContext >& _rxContext )
+ :GenericPropertyHandler_Base( m_aMutex )
+ ,m_aContext( _rxContext )
+ ,m_aPropertyListeners( m_aMutex )
+ ,m_bPropertyMapInitialized( false )
+ {
+ DBG_CTOR( GenericPropertyHandler, NULL );
+
+ m_xTypeConverter = Reference< XTypeConverter >(
+ m_aContext.createComponent( "com.sun.star.script.Converter" ),
+ UNO_QUERY_THROW
+ );
+ }
+
+ //--------------------------------------------------------------------
+ GenericPropertyHandler::~GenericPropertyHandler()
+ {
+ DBG_DTOR( GenericPropertyHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL GenericPropertyHandler::getImplementationName( ) throw (RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL GenericPropertyHandler::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException)
+ {
+ StlSyntaxSequence< ::rtl::OUString > aAllServices( getSupportedServiceNames() );
+ return ::std::find( aAllServices.begin(), aAllServices.end(), ServiceName ) != aAllServices.end();
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL GenericPropertyHandler::getSupportedServiceNames( ) throw (RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL GenericPropertyHandler::getImplementationName_static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.GenericPropertyHandler" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL GenericPropertyHandler::getSupportedServiceNames_static( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported( 1 );
+ aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.inspection.GenericPropertyHandler" ) );
+ return aSupported;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL GenericPropertyHandler::Create( const Reference< XComponentContext >& _rxContext )
+ {
+ return *( new GenericPropertyHandler( _rxContext ) );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL GenericPropertyHandler::inspect( const Reference< XInterface >& _rxIntrospectee ) throw (RuntimeException, NullPointerException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !_rxIntrospectee.is() )
+ throw NullPointerException();
+
+ // revoke old property change listeners
+ ::cppu::OInterfaceIteratorHelper iterRemove( m_aPropertyListeners );
+ ::cppu::OInterfaceIteratorHelper iterReAdd( m_aPropertyListeners ); // this holds a copy of the container ...
+ while ( iterRemove.hasMoreElements() )
+ m_xComponent->removePropertyChangeListener( ::rtl::OUString(), static_cast< XPropertyChangeListener* >( iterRemove.next() ) );
+
+ m_xComponentIntrospectionAccess.clear();
+ m_xComponent.clear();
+ m_xPropertyState.clear();
+
+ // create an introspection adapter for the component
+ Reference< XIntrospection > xIntrospection;
+ if ( !m_aContext.createComponent( "com.sun.star.beans.Introspection", xIntrospection ) )
+ throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Could not create an instance of the service com.sun.star.beans.Introspection." ) ), *this );
+
+ Reference< XIntrospectionAccess > xIntrospectionAccess( xIntrospection->inspect( makeAny( _rxIntrospectee ) ) );
+ if ( !xIntrospectionAccess.is() )
+ throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "The introspection service could not handle the given component." ) ), *this );
+
+ m_xComponent = Reference< XPropertySet >( xIntrospectionAccess->queryAdapter( XPropertySet::static_type() ), UNO_QUERY_THROW );
+ // now that we survived so far, remember m_xComponentIntrospectionAccess
+ m_xComponentIntrospectionAccess = xIntrospectionAccess;
+ m_xPropertyState = m_xPropertyState.query( m_xComponent );
+
+ m_bPropertyMapInitialized = false;
+ m_aProperties.clear();
+
+ // re-add the property change listeners
+ while ( iterReAdd.hasMoreElements() )
+ m_xComponent->addPropertyChangeListener( ::rtl::OUString(), static_cast< XPropertyChangeListener* >( iterReAdd.next() ) );
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL GenericPropertyHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_xComponent.is() )
+ throw UnknownPropertyException();
+
+ return m_xComponent->getPropertyValue( _rPropertyName );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL GenericPropertyHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_xComponent.is() )
+ throw UnknownPropertyException();
+
+ m_xComponent->setPropertyValue( _rPropertyName, _rValue );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::Reference< IPropertyEnumRepresentation > GenericPropertyHandler::impl_getEnumConverter( const Type& _rEnumType )
+ {
+ ::rtl::Reference< IPropertyEnumRepresentation >& rConverter = m_aEnumConverters[ _rEnumType ];
+ if ( !rConverter.is() )
+ rConverter = new EnumRepresentation( m_aContext.getUNOContext(), _rEnumType );
+ return rConverter;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL GenericPropertyHandler::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ const_cast< GenericPropertyHandler* >( this )->impl_ensurePropertyMap();
+
+ PropertyMap::const_iterator pos = m_aProperties.find( _rPropertyName );
+ if ( pos == m_aProperties.end() )
+ throw UnknownPropertyException();
+
+ Any aPropertyValue;
+ if ( !_rControlValue.hasValue() )
+ // NULL is converted to NULL
+ return aPropertyValue;
+
+ if ( pos->second.Type.getTypeClass() == TypeClass_ENUM )
+ {
+ ::rtl::OUString sControlValue;
+ OSL_VERIFY( _rControlValue >>= sControlValue );
+ impl_getEnumConverter( pos->second.Type )->getValueFromDescription( sControlValue, aPropertyValue );
+ }
+ else
+ aPropertyValue = PropertyHandlerHelper::convertToPropertyValue( m_aContext.getContext(),m_xTypeConverter, pos->second, _rControlValue );
+
+ return aPropertyValue;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL GenericPropertyHandler::convertToControlValue( const ::rtl::OUString& _rPropertyName, const Any& _rPropertyValue, const Type& _rControlValueType ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ const_cast< GenericPropertyHandler* >( this )->impl_ensurePropertyMap();
+
+ PropertyMap::const_iterator pos = m_aProperties.find( _rPropertyName );
+ if ( pos == m_aProperties.end() )
+ throw UnknownPropertyException();
+
+ Any aControlValue;
+ if ( !_rPropertyValue.hasValue() )
+ // NULL is converted to NULL
+ return aControlValue;
+
+ if ( pos->second.Type.getTypeClass() == TypeClass_ENUM )
+ {
+ aControlValue <<= impl_getEnumConverter( pos->second.Type )->getDescriptionForValue( _rPropertyValue );
+ }
+ else
+ aControlValue = PropertyHandlerHelper::convertToControlValue( m_aContext.getContext(),m_xTypeConverter, _rPropertyValue, _rControlValueType );
+ return aControlValue;
+ }
+
+ //--------------------------------------------------------------------
+ PropertyState SAL_CALL GenericPropertyHandler::getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyState eState = PropertyState_DIRECT_VALUE;
+ if ( m_xPropertyState.is() )
+ eState = m_xPropertyState->getPropertyState( _rPropertyName );
+ return eState;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL GenericPropertyHandler::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ if ( !_rxListener.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_aPropertyListeners.addInterface( _rxListener );
+ if ( m_xComponent.is() )
+ {
+ try
+ {
+ m_xComponent->addPropertyChangeListener( ::rtl::OUString(), _rxListener );
+ }
+ catch( const UnknownPropertyException& )
+ {
+ OSL_ENSURE( false, "GenericPropertyHandler::addPropertyChangeListener:\nThe inspected component does not allow registering for all properties at once! This violates the interface contract!" );
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL GenericPropertyHandler::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_xComponent.is() )
+ {
+ try
+ {
+ m_xComponent->removePropertyChangeListener( ::rtl::OUString(), _rxListener );
+ }
+ catch( const UnknownPropertyException& )
+ {
+ OSL_ENSURE( false, "GenericPropertyHandler::removePropertyChangeListener:\nThe inspected component does not allow de-registering for all properties at once! This violates the interface contract!" );
+ }
+ }
+ m_aPropertyListeners.removeInterface( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void GenericPropertyHandler::impl_ensurePropertyMap()
+ {
+ if ( !m_bPropertyMapInitialized )
+ {
+ m_bPropertyMapInitialized = true;
+ try
+ {
+ Reference< XPropertySetInfo > xPSI;
+ if ( m_xComponent.is() )
+ xPSI = m_xComponent->getPropertySetInfo();
+ Sequence< Property > aProperties;
+ if ( xPSI.is() )
+ aProperties = xPSI->getProperties();
+ DBG_ASSERT( aProperties.getLength(), "GenericPropertyHandler::getSupportedProperties: no properties!" );
+
+ for ( const Property* pProperties = aProperties.getConstArray();
+ pProperties != aProperties.getConstArray() + aProperties.getLength();
+ ++pProperties
+ )
+ {
+ switch ( pProperties->Type.getTypeClass() )
+ {
+ case TypeClass_BOOLEAN:
+ case TypeClass_BYTE:
+ case TypeClass_SHORT:
+ case TypeClass_UNSIGNED_SHORT:
+ case TypeClass_LONG:
+ case TypeClass_UNSIGNED_LONG:
+ case TypeClass_HYPER:
+ case TypeClass_UNSIGNED_HYPER:
+ case TypeClass_FLOAT:
+ case TypeClass_DOUBLE:
+ case TypeClass_ENUM:
+ case TypeClass_STRING:
+ // allowed, we can handle this type
+ break;
+
+ case TypeClass_SEQUENCE:
+ {
+ TypeClass eElementTypeClass = ::comphelper::getSequenceElementType( pProperties->Type ).getTypeClass();
+ if ( ( eElementTypeClass != TypeClass_STRING )
+ && ( eElementTypeClass != TypeClass_BYTE )
+ && ( eElementTypeClass != TypeClass_SHORT )
+ && ( eElementTypeClass != TypeClass_UNSIGNED_SHORT )
+ && ( eElementTypeClass != TypeClass_LONG )
+ && ( eElementTypeClass != TypeClass_UNSIGNED_LONG )
+ )
+ // can only handle the above
+ continue;
+ }
+ break;
+
+ default:
+ // next property, we don't support this type
+ continue;
+ }
+
+ m_aProperties.insert( PropertyMap::value_type( pProperties->Name, *pProperties ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "GenericPropertyHandler::impl_ensurePropertyMap: caught an exception!" );
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Property > SAL_CALL GenericPropertyHandler::getSupportedProperties() throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ const_cast< GenericPropertyHandler* >( this )->impl_ensurePropertyMap();
+
+ Sequence< Property > aReturn( m_aProperties.size() );
+ ::std::transform( m_aProperties.begin(), m_aProperties.end(),
+ aReturn.getArray(), ::std::select2nd< PropertyMap::value_type >() );
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL GenericPropertyHandler::getSupersededProperties( ) throw (RuntimeException)
+ {
+ // no superseded properties at all. This handler offers the very basic PropertyHandler
+ // functionality, so it's much more likely that other handlers want to supersede
+ // *our* properties ....
+ return Sequence< ::rtl::OUString >( );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL GenericPropertyHandler::getActuatingProperties( ) throw (RuntimeException)
+ {
+ // This basic PropertyHandler implementation is too dumb^Wgeneric to know
+ // anything about property dependencies
+ return Sequence< ::rtl::OUString >( );
+ }
+
+ //--------------------------------------------------------------------
+ LineDescriptor SAL_CALL GenericPropertyHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName,
+ const Reference< XPropertyControlFactory >& _rxControlFactory )
+ throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ if ( !_rxControlFactory.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ const_cast< GenericPropertyHandler* >( this )->impl_ensurePropertyMap();
+
+ PropertyMap::const_iterator pos = m_aProperties.find( _rPropertyName );
+ if ( pos == m_aProperties.end() )
+ throw UnknownPropertyException();
+
+ LineDescriptor aDescriptor;
+ aDescriptor.DisplayName = _rPropertyName;
+ switch ( pos->second.Type.getTypeClass() )
+ {
+ case TypeClass_ENUM:
+ aDescriptor.Control = PropertyHandlerHelper::createListBoxControl( _rxControlFactory,
+ impl_getEnumConverter( pos->second.Type )->getDescriptions(),
+ PropertyHandlerHelper::requiresReadOnlyControl( pos->second.Attributes ),
+ sal_False );
+ break;
+ case TypeClass_STRING:
+ {
+ // some special handling for URL properties
+ bool bIsURLProperty = ( _rPropertyName.getLength() >= 3 ) && _rPropertyName.matchAsciiL( "URL", 3, _rPropertyName.getLength() - 3 );
+ if ( bIsURLProperty )
+ {
+ aDescriptor.Control = _rxControlFactory->createPropertyControl(
+ PropertyControlType::HyperlinkField, PropertyHandlerHelper::requiresReadOnlyControl( pos->second.Attributes ) );
+
+ Reference< XHyperlinkControl > xControl( aDescriptor.Control, UNO_QUERY_THROW );
+ Reference< XActionListener > xEnsureDelete( new UrlClickHandler( m_aContext, xControl ) );
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ // fallback
+ if ( !aDescriptor.Control.is() )
+ PropertyHandlerHelper::describePropertyLine( pos->second, aDescriptor, _rxControlFactory );
+
+ aDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "General" ) );
+ return aDescriptor;
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL GenericPropertyHandler::isComposable( const ::rtl::OUString& /*_rPropertyName*/ ) throw (UnknownPropertyException, RuntimeException)
+ {
+ return sal_False;
+ }
+
+ //--------------------------------------------------------------------
+ InteractiveSelectionResult SAL_CALL GenericPropertyHandler::onInteractivePropertySelection( const ::rtl::OUString& /*_rPropertyName*/, sal_Bool /*_bPrimary*/, Any& /*_rData*/, const Reference< XObjectInspectorUI >& /*_rxInspectorUI*/ ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ DBG_ERROR( "GenericPropertyHandler::onInteractivePropertySelection: I'm too dumb to know anything about property browse buttons!" );
+ return InteractiveSelectionResult_Cancelled;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL GenericPropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& /*_rActuatingPropertyName*/, const Any& /*_rNewValue*/, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& /*_rxInspectorUI*/, sal_Bool /*_bFirstTimeInit*/ ) throw (NullPointerException, RuntimeException)
+ {
+ DBG_ERROR( "GenericPropertyHandler::actuatingPropertyChanged: no no no, I did not register for any actuating properties!" );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL GenericPropertyHandler::suspend( sal_Bool /*_bSuspend*/ ) throw (RuntimeException)
+ {
+ return sal_True;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL GenericPropertyHandler::disposing()
+ {
+ m_aPropertyListeners.clear();
+ // not disposeAndClear: the listeners are (virtually) listeners at our introspectee, not
+ // at this handler instance
+ }
+
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XCOMPONENT( GenericPropertyHandler, GenericPropertyHandler_Base );
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
diff --git a/extensions/source/propctrlr/genericpropertyhandler.hxx b/extensions/source/propctrlr/genericpropertyhandler.hxx
new file mode 100644
index 000000000000..6e5e5acc575c
--- /dev/null
+++ b/extensions/source/propctrlr/genericpropertyhandler.hxx
@@ -0,0 +1,161 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_GENERICPROPERTYHANDLER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_GENERICPROPERTYHANDLER_HXX
+
+#include "propertyhandler.hxx"
+#include "pcrcommontypes.hxx"
+#include "pcrcommon.hxx"
+#include "pcrcomponentcontext.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/beans/XIntrospectionAccess.hpp>
+/** === end UNO includes === **/
+#include <cppuhelper/compbase2.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
+#include <rtl/ref.hxx>
+
+#include <map>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ struct TypeLess : ::std::binary_function< ::com::sun::star::uno::Type, ::com::sun::star::uno::Type, bool >
+ {
+ bool operator()( const ::com::sun::star::uno::Type& _rLHS, const ::com::sun::star::uno::Type& _rRHS ) const
+ {
+ return _rLHS.getTypeName() < _rRHS.getTypeName();
+ }
+ };
+
+ class IPropertyInfoService;
+ class IPropertyEnumRepresentation;
+ //====================================================================
+ //= GenericPropertyHandler
+ //====================================================================
+ typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::inspection::XPropertyHandler
+ , ::com::sun::star::lang::XServiceInfo
+ > GenericPropertyHandler_Base;
+ class GenericPropertyHandler : public GenericPropertyHandler_Base
+ {
+ private:
+ mutable ::osl::Mutex m_aMutex;
+
+ private:
+ /// the service factory for creating services
+ ComponentContext m_aContext;
+ /// need this to keep alive as long as m_xComponent lives
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess > m_xComponentIntrospectionAccess;
+ /// the properties of the object we're handling
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xComponent;
+ /// cached interface of ->m_xComponent
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState > m_xPropertyState;
+ /// type converter, needed on various occasions
+ ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter > m_xTypeConverter;
+ /// cache of our supported properties
+ PropertyMap m_aProperties;
+ /// property change listeners
+ ::cppu::OInterfaceContainerHelper m_aPropertyListeners;
+ ::std::map< ::com::sun::star::uno::Type, ::rtl::Reference< IPropertyEnumRepresentation >, TypeLess >
+ m_aEnumConverters;
+
+ /// has ->m_aProperties been initialized?
+ bool m_bPropertyMapInitialized : 1;
+
+ public:
+ // XServiceInfo - static versions
+ static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
+
+ protected:
+ GenericPropertyHandler(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
+ );
+
+ ~GenericPropertyHandler();
+
+ protected:
+ // XPropertyHandler overridables
+ virtual void SAL_CALL inspect( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxIntrospectee ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rControlValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToControlValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rPropertyValue, const ::com::sun::star::uno::Type& _rControlValueType ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
+ SAL_CALL getSupportedProperties() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getSupersededProperties() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getActuatingProperties() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::LineDescriptor SAL_CALL describePropertyLine( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isComposable( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::InteractiveSelectionResult
+ SAL_CALL onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, ::com::sun::star::uno::Any& _rData, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL suspend( sal_Bool _bSuspend ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XComponent
+ DECLARE_XCOMPONENT()
+ virtual void SAL_CALL disposing();
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ /** ensures that ->m_aProperties is initialized
+ @precond
+ our mutex is locked
+ */
+ void impl_ensurePropertyMap();
+
+ /** retrieves the enum converter for the given ENUM type
+ */
+ ::rtl::Reference< IPropertyEnumRepresentation >
+ impl_getEnumConverter( const ::com::sun::star::uno::Type& _rEnumType );
+
+ private:
+ GenericPropertyHandler(); // never implemented
+ GenericPropertyHandler( const GenericPropertyHandler& ); // never implemented
+ GenericPropertyHandler& operator=( const GenericPropertyHandler& ); // never implemented
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_GENERICPROPERTYHANDLER_HXX
+
diff --git a/extensions/source/propctrlr/handlerhelper.cxx b/extensions/source/propctrlr/handlerhelper.cxx
new file mode 100644
index 000000000000..ae87a85a3722
--- /dev/null
+++ b/extensions/source/propctrlr/handlerhelper.cxx
@@ -0,0 +1,291 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "handlerhelper.hxx"
+#ifndef EXTENSIONS_PROPRESID_HRC
+#include "propresid.hrc"
+#endif
+#include "formresid.hrc"
+#include <comphelper/extract.hxx>
+#ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
+#include "modulepcr.hxx"
+#endif
+#include "enumrepresentation.hxx"
+#include "formmetadata.hxx"
+#include "pcrcomponentcontext.hxx"
+
+/** === begin UNO includes === **/
+#include "com/sun/star/inspection/StringRepresentation.hpp"
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/inspection/LineDescriptor.hpp>
+#include <com/sun/star/inspection/PropertyControlType.hpp>
+#include <com/sun/star/inspection/XStringListControl.hpp>
+#include <com/sun/star/inspection/XNumericControl.hpp>
+/** === end UNO includes === **/
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/StringListResource.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
+#include <algorithm>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::awt;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::script;
+ using namespace ::com::sun::star::inspection;
+
+ //====================================================================
+ //= PropertyHandlerHelper
+ //====================================================================
+ //--------------------------------------------------------------------
+ void PropertyHandlerHelper::describePropertyLine( const Property& _rProperty,
+ LineDescriptor& /* [out] */ _out_rDescriptor, const Reference< XPropertyControlFactory >& _rxControlFactory )
+ {
+ // display the pure property name - no L10N
+ _out_rDescriptor.DisplayName = _rProperty.Name;
+
+ OSL_PRECOND( _rxControlFactory.is(), "PropertyHandlerHelper::describePropertyLine: no factory -> no control!" );
+ if ( !_rxControlFactory.is() )
+ return;
+
+ sal_Bool bReadOnlyControl = requiresReadOnlyControl( _rProperty.Attributes );
+
+ // special handling for booleans (this will become a list)
+ if ( _rProperty.Type.getTypeClass() == TypeClass_BOOLEAN )
+ {
+ ::std::vector< ::rtl::OUString > aListEntries;
+ tools::StringListResource aRes(PcrRes(RID_RSC_ENUM_YESNO),aListEntries);
+ _out_rDescriptor.Control = createListBoxControl( _rxControlFactory, aListEntries, bReadOnlyControl, sal_False );
+ return;
+ }
+
+ sal_Int16 nControlType = PropertyControlType::TextField;
+ switch ( _rProperty.Type.getTypeClass() )
+ {
+ case TypeClass_BYTE:
+ case TypeClass_SHORT:
+ case TypeClass_UNSIGNED_SHORT:
+ case TypeClass_LONG:
+ case TypeClass_UNSIGNED_LONG:
+ case TypeClass_HYPER:
+ case TypeClass_UNSIGNED_HYPER:
+ case TypeClass_FLOAT:
+ case TypeClass_DOUBLE:
+ nControlType = PropertyControlType::NumericField;
+ break;
+
+ case TypeClass_SEQUENCE:
+ nControlType = PropertyControlType::StringListField;
+ break;
+
+ default:
+ DBG_ERROR( "PropertyHandlerHelper::describePropertyLine: don't know how to represent this at the UI!" );
+ // NO break!
+
+ case TypeClass_STRING:
+ nControlType = PropertyControlType::TextField;
+ break;
+ }
+
+ // create a control
+ _out_rDescriptor.Control = _rxControlFactory->createPropertyControl( nControlType, bReadOnlyControl );
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ Reference< XPropertyControl > lcl_implCreateListLikeControl(
+ const Reference< XPropertyControlFactory >& _rxControlFactory,
+ const ::std::vector< ::rtl::OUString >& _rInitialListEntries,
+ sal_Bool _bReadOnlyControl,
+ sal_Bool _bSorted,
+ sal_Bool _bTrueIfListBoxFalseIfComboBox
+ )
+ {
+ Reference< XStringListControl > xListControl(
+ _rxControlFactory->createPropertyControl(
+ _bTrueIfListBoxFalseIfComboBox ? PropertyControlType::ListBox : PropertyControlType::ComboBox, _bReadOnlyControl
+ ),
+ UNO_QUERY_THROW
+ );
+
+ ::std::vector< ::rtl::OUString > aInitialEntries( _rInitialListEntries );
+ if ( _bSorted )
+ ::std::sort( aInitialEntries.begin(), aInitialEntries.end() );
+
+ for ( ::std::vector< ::rtl::OUString >::const_iterator loop = aInitialEntries.begin();
+ loop != aInitialEntries.end();
+ ++loop
+ )
+ xListControl->appendListEntry( *loop );
+ return xListControl.get();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertyControl > PropertyHandlerHelper::createListBoxControl( const Reference< XPropertyControlFactory >& _rxControlFactory,
+ const ::std::vector< ::rtl::OUString >& _rInitialListEntries, sal_Bool _bReadOnlyControl, sal_Bool _bSorted )
+ {
+ return lcl_implCreateListLikeControl( _rxControlFactory, _rInitialListEntries, _bReadOnlyControl, _bSorted, sal_True );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertyControl > PropertyHandlerHelper::createComboBoxControl( const Reference< XPropertyControlFactory >& _rxControlFactory,
+ const ::std::vector< ::rtl::OUString >& _rInitialListEntries, sal_Bool _bReadOnlyControl, sal_Bool _bSorted )
+ {
+ return lcl_implCreateListLikeControl( _rxControlFactory, _rInitialListEntries, _bReadOnlyControl, _bSorted, sal_False );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertyControl > PropertyHandlerHelper::createNumericControl( const Reference< XPropertyControlFactory >& _rxControlFactory,
+ sal_Int16 _nDigits, const Optional< double >& _rMinValue, const Optional< double >& _rMaxValue, sal_Bool _bReadOnlyControl )
+ {
+ Reference< XNumericControl > xNumericControl(
+ _rxControlFactory->createPropertyControl( PropertyControlType::NumericField, _bReadOnlyControl ),
+ UNO_QUERY_THROW
+ );
+
+ xNumericControl->setDecimalDigits( _nDigits );
+ xNumericControl->setMinValue( _rMinValue );
+ xNumericControl->setMaxValue( _rMaxValue );
+
+ return xNumericControl.get();
+ }
+
+ //--------------------------------------------------------------------
+ Any PropertyHandlerHelper::convertToPropertyValue( const Reference< XComponentContext >& _rxContext,const Reference< XTypeConverter >& _rxTypeConverter,
+ const Property& _rProperty, const Any& _rControlValue )
+ {
+ Any aPropertyValue( _rControlValue );
+ if ( !aPropertyValue.hasValue() )
+ // NULL is converted to NULL
+ return aPropertyValue;
+
+ if ( aPropertyValue.getValueType().equals( _rProperty.Type ) )
+ // nothing to do, type is already as desired
+ return aPropertyValue;
+
+ if ( _rControlValue.getValueType().getTypeClass() == TypeClass_STRING )
+ {
+ ::rtl::OUString sControlValue;
+ _rControlValue >>= sControlValue;
+
+ Reference< XStringRepresentation > xConversionHelper = StringRepresentation::create( _rxContext,_rxTypeConverter );
+ aPropertyValue = xConversionHelper->convertToPropertyValue( sControlValue, _rProperty.Type );
+ }
+ else
+ {
+ try
+ {
+ if ( _rxTypeConverter.is() )
+ aPropertyValue = _rxTypeConverter->convertTo( _rControlValue, _rProperty.Type );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "PropertyHandlerHelper::convertToPropertyValue: caught an exception while converting via TypeConverter!" );
+ }
+ }
+
+ return aPropertyValue;
+ }
+
+ //--------------------------------------------------------------------
+ Any PropertyHandlerHelper::convertToControlValue( const Reference< XComponentContext >& _rxContext,const Reference< XTypeConverter >& _rxTypeConverter,
+ const Any& _rPropertyValue, const Type& _rControlValueType )
+ {
+ Any aControlValue( _rPropertyValue );
+ if ( !aControlValue.hasValue() )
+ // NULL is converted to NULL
+ return aControlValue;
+
+ if ( _rControlValueType.getTypeClass() == TypeClass_STRING )
+ {
+ Reference< XStringRepresentation > xConversionHelper = StringRepresentation::create( _rxContext,_rxTypeConverter );
+ aControlValue <<= xConversionHelper->convertToControlValue( _rPropertyValue );
+ }
+ else
+ {
+ try
+ {
+ if ( _rxTypeConverter.is() )
+ aControlValue = _rxTypeConverter->convertTo( _rPropertyValue, _rControlValueType );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "PropertyHandlerHelper::convertToControlValue: caught an exception while converting via TypeConverter!" );
+ }
+ }
+
+ return aControlValue;
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyHandlerHelper::setContextDocumentModified( const ComponentContext& _rContext )
+ {
+ try
+ {
+ Reference< XModifiable > xDocumentModifiable( _rContext.getContextValueByAsciiName( "ContextDocument" ), UNO_QUERY_THROW );
+ xDocumentModifiable->setModified( sal_True );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Window* PropertyHandlerHelper::getDialogParentWindow( const ComponentContext& _rContext )
+ {
+ Window* pInspectorWindow = NULL;
+ try
+ {
+ Reference< XWindow > xInspectorWindow( _rContext.getContextValueByAsciiName( "DialogParentWindow" ), UNO_QUERY_THROW );
+ pInspectorWindow = VCLUnoHelper::GetWindow( xInspectorWindow );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return pInspectorWindow;
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
diff --git a/extensions/source/propctrlr/handlerhelper.hxx b/extensions/source/propctrlr/handlerhelper.hxx
new file mode 100644
index 000000000000..e55cbf207526
--- /dev/null
+++ b/extensions/source/propctrlr/handlerhelper.hxx
@@ -0,0 +1,217 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/Property.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/script/XTypeConverter.hpp>
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/inspection/XPropertyControlFactory.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/Optional.hpp>
+/** === end UNO includes === **/
+
+#include <vector>
+
+class Window;
+namespace com { namespace sun { namespace star {
+ namespace inspection {
+ struct LineDescriptor;
+ }
+} } }
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ class ComponentContext;
+
+ //====================================================================
+ //= PropertyHandlerHelper
+ //====================================================================
+ class PropertyHandlerHelper
+ {
+ public:
+ /** helper for implementing XPropertyHandler::describePropertyLine in a generic way
+ */
+ static void describePropertyLine(
+ const ::com::sun::star::beans::Property& _rProperty,
+ ::com::sun::star::inspection::LineDescriptor& /* [out] */ _out_rDescriptor,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory
+ );
+
+ /** helper for implementing XPropertyHandler::convertToPropertyValue
+ */
+ static ::com::sun::star::uno::Any convertToPropertyValue(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter >& _rxTypeConverter,
+ const ::com::sun::star::beans::Property& _rProperty,
+ const ::com::sun::star::uno::Any& _rControlValue
+ );
+
+ /// helper for implementing XPropertyHandler::convertToControlValue
+ static ::com::sun::star::uno::Any convertToControlValue(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter >& _rxTypeConverter,
+ const ::com::sun::star::uno::Any& _rPropertyValue,
+ const ::com::sun::star::uno::Type& _rControlValueType
+ );
+
+ /** creates an <member scope="com::sun::star::inspection">PropertyControlType::ListBox</member>-type control
+ and fills it with initial values
+
+ @param _rxControlFactory
+ A control factory. Must not be <NULL/>.
+
+ @param _rInitialListEntries
+ the initial values of the control
+
+ @param _bReadOnlyControl
+ determines whether the control should be read-only
+
+ @param _bSorted
+ determines whether the list entries should be sorted
+
+ @return
+ the newly created control
+ */
+ static ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
+ createListBoxControl(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory,
+ const ::std::vector< ::rtl::OUString >& _rInitialListEntries,
+ sal_Bool _bReadOnlyControl,
+ sal_Bool _bSorted
+ );
+
+ /** creates an <member scope="com::sun::star::inspection">PropertyControlType::ComboBox</member>-type control
+ and fills it with initial values
+
+ @param _rxControlFactory
+ A control factory. Must not be <NULL/>.
+
+ @param _rInitialListEntries
+ the initial values of the control
+
+ @param _bReadOnlyControl
+ determines whether the control should be read-only
+
+ @param _bSorted
+ determines whether the list entries should be sorted
+
+ @return
+ the newly created control
+ */
+ static ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
+ createComboBoxControl(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory,
+ const ::std::vector< ::rtl::OUString >& _rInitialListEntries,
+ sal_Bool _bReadOnlyControl,
+ sal_Bool _bSorted
+ );
+
+ /** creates an <member scope="com::sun::star::inspection">PropertyControlType::NumericField</member>-type control
+ and initializes it
+
+ @param _rxControlFactory
+ A control factory. Must not be <NULL/>.
+ @param _nDigits
+ number of decimal digits for the control
+ (<member scope="com::sun::star::inspection">XNumericControl::DecimalDigits</member>)
+ @param _rMinValue
+ minimum value which can be entered in the control
+ (<member scope="com::sun::star::inspection">XNumericControl::MinValue</member>)
+ @param _rMaxValue
+ maximum value which can be entered in the control
+ (<member scope="com::sun::star::inspection">XNumericControl::MaxValue</member>)
+ @param _bReadOnlyControl
+ determines whether the control should be read-only
+
+ @return
+ the newly created control
+ */
+ static ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
+ createNumericControl(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory,
+ sal_Int16 _nDigits,
+ const ::com::sun::star::beans::Optional< double >& _rMinValue,
+ const ::com::sun::star::beans::Optional< double >& _rMaxValue,
+ sal_Bool _bReadOnlyControl
+ );
+
+ /** marks the document passed in our UNO context as modified
+
+ The method looks up a value called "ContextDocument" in the given UNO component context,
+ queries it for the ->com::sun::star::util::XModifiable interface, and calls its
+ setModified method. If either of those steps fails, this is asserted in a non-product
+ version, and silently ignore otherwise.
+
+ @param _rContext
+ the component context which was used to create the component calling this method
+ */
+ static void setContextDocumentModified(
+ const ComponentContext& _rContext
+ );
+
+ /** gets the window of the ObjectInspector in which an property handler lives
+
+ The method looks up a value called "DialogParentWindow" in the given UNO copmonent context,
+ queries it for XWindow, and returns the respective Window*. If either of those steps fails,
+ this is asserted in a non-product version, and silently ignore otherwise.
+
+ @param _rContext
+ the component context which was used to create the component calling this method
+ */
+ static Window* getDialogParentWindow( const ComponentContext& _rContext );
+
+
+ /** determines whether given PropertyAttributes require a to-be-created
+ <type scope="com::sun::star::inspection">XPropertyControl</type> to be read-only
+
+ @param _nPropertyAttributes
+ the attributes of the property which should be reflected by a to-be-created
+ <type scope="com::sun::star::inspection">XPropertyControl</type>
+ */
+ inline static sal_Bool requiresReadOnlyControl( sal_Int16 _nPropertyAttributes )
+ {
+ return ( _nPropertyAttributes & ::com::sun::star::beans::PropertyAttribute::READONLY ) != 0;
+ }
+
+ private:
+ PropertyHandlerHelper(); // never implemented
+ PropertyHandlerHelper( const PropertyHandlerHelper& ); // never implemented
+ PropertyHandlerHelper& operator=( const PropertyHandlerHelper& ); // never implemented
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX
+
diff --git a/extensions/source/propctrlr/inspectorhelpwindow.cxx b/extensions/source/propctrlr/inspectorhelpwindow.cxx
new file mode 100644
index 000000000000..dbf562a7536c
--- /dev/null
+++ b/extensions/source/propctrlr/inspectorhelpwindow.cxx
@@ -0,0 +1,153 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "inspectorhelpwindow.hxx"
+#include "modulepcr.hxx"
+#ifndef EXTENSIONS_PROPRESID_HRC
+#include "propresid.hrc"
+#endif
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= InspectorHelpWindow
+ //====================================================================
+ //--------------------------------------------------------------------
+ InspectorHelpWindow::InspectorHelpWindow( Window* _pParent )
+ :Window( _pParent, WB_DIALOGCONTROL )
+ ,m_aSeparator( this )
+ ,m_aHelpText( this, WB_LEFT | WB_READONLY | WB_AUTOVSCROLL )
+ ,m_nMinLines( 3 )
+ ,m_nMaxLines( 8 )
+ {
+ SetBackground();
+ SetPaintTransparent(sal_True);
+ m_aSeparator.SetText( String( PcrRes( RID_STR_HELP_SECTION_LABEL ) ) );
+ m_aSeparator.SetBackground();
+ m_aSeparator.Show();
+
+ m_aHelpText.SetControlBackground( /*m_aSeparator.GetBackground().GetColor() */);
+ m_aHelpText.SetBackground();
+ m_aHelpText.SetPaintTransparent(sal_True);
+ m_aHelpText.Show();
+ }
+
+ //--------------------------------------------------------------------
+ void InspectorHelpWindow::SetText( const XubString& _rStr )
+ {
+ m_aHelpText.SetText( _rStr );
+ }
+
+ //--------------------------------------------------------------------
+ void InspectorHelpWindow::SetLimits( sal_Int32 _nMinLines, sal_Int32 _nMaxLines )
+ {
+ m_nMinLines = _nMinLines;
+ m_nMaxLines = _nMaxLines;
+ }
+
+ //--------------------------------------------------------------------
+ long InspectorHelpWindow::impl_getHelpTextBorderHeight()
+ {
+ sal_Int32 nTop(0), nBottom(0), nDummy(0);
+ m_aHelpText.GetBorder( nDummy, nTop, nDummy, nBottom );
+ return nTop + nBottom;
+ }
+
+ //--------------------------------------------------------------------
+ long InspectorHelpWindow::impl_getSpaceAboveTextWindow()
+ {
+ Size aSeparatorSize( LogicToPixel( Size( 0, 8 ), MAP_APPFONT ) );
+ Size a3AppFontSize( LogicToPixel( Size( 3, 3 ), MAP_APPFONT ) );
+ return aSeparatorSize.Height() + a3AppFontSize.Height();
+ }
+
+ //--------------------------------------------------------------------
+ long InspectorHelpWindow::GetMinimalHeightPixel()
+ {
+ return impl_getMinimalTextWindowHeight() + impl_getSpaceAboveTextWindow();
+ }
+
+ //--------------------------------------------------------------------
+ long InspectorHelpWindow::impl_getMinimalTextWindowHeight()
+ {
+ return impl_getHelpTextBorderHeight() + m_aHelpText.GetTextHeight() * m_nMinLines;
+ }
+
+ //--------------------------------------------------------------------
+ long InspectorHelpWindow::impl_getMaximalTextWindowHeight()
+ {
+ return impl_getHelpTextBorderHeight() + m_aHelpText.GetTextHeight() * m_nMaxLines;
+ }
+
+ //--------------------------------------------------------------------
+ long InspectorHelpWindow::GetOptimalHeightPixel()
+ {
+ // --- calc the height as needed for the mere text window
+ long nMinTextWindowHeight = impl_getMinimalTextWindowHeight();
+ long nMaxTextWindowHeight = impl_getMaximalTextWindowHeight();
+
+ Rectangle aTextRect( Point( 0, 0 ), m_aHelpText.GetOutputSizePixel() );
+ aTextRect = m_aHelpText.GetTextRect( aTextRect, m_aHelpText.GetText(),
+ TEXT_DRAW_LEFT | TEXT_DRAW_TOP | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK );
+ long nActTextWindowHeight = impl_getHelpTextBorderHeight() + aTextRect.GetHeight();
+
+ long nOptTextWindowHeight = ::std::max( nMinTextWindowHeight, ::std::min( nMaxTextWindowHeight, nActTextWindowHeight ) );
+
+ // --- then add the space above the text window
+ return nOptTextWindowHeight + impl_getSpaceAboveTextWindow();
+ }
+
+ //--------------------------------------------------------------------
+ void InspectorHelpWindow::Resize()
+ {
+ Size a3AppFont( LogicToPixel( Size( 3, 3 ), MAP_APPFONT ) );
+
+ Rectangle aPlayground( Point( 0, 0 ), GetOutputSizePixel() );
+
+ Rectangle aSeparatorArea( aPlayground );
+ aSeparatorArea.Bottom() = aSeparatorArea.Top() + LogicToPixel( Size( 0, 8 ), MAP_APPFONT ).Height();
+ m_aSeparator.SetPosSizePixel( aSeparatorArea.TopLeft(), aSeparatorArea.GetSize() );
+
+ Rectangle aTextArea( aPlayground );
+ aTextArea.Top() = aSeparatorArea.Bottom() + a3AppFont.Height();
+ m_aHelpText.SetPosSizePixel( aTextArea.TopLeft(), aTextArea.GetSize() );
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
diff --git a/extensions/source/propctrlr/inspectorhelpwindow.hxx b/extensions/source/propctrlr/inspectorhelpwindow.hxx
new file mode 100644
index 000000000000..910948b9b563
--- /dev/null
+++ b/extensions/source/propctrlr/inspectorhelpwindow.hxx
@@ -0,0 +1,78 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef INSPECTORHELPWINDOW_HXX
+#define INSPECTORHELPWINDOW_HXX
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <vcl/fixed.hxx>
+#include <svtools/svmedit.hxx>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= InspectorHelpWindow
+ //====================================================================
+ class InspectorHelpWindow : public Window
+ {
+ private:
+ FixedLine m_aSeparator;
+ MultiLineEdit m_aHelpText;
+
+ sal_Int32 m_nMinLines;
+ sal_Int32 m_nMaxLines;
+
+ public:
+ InspectorHelpWindow( Window* _pParent );
+
+ virtual void SetText( const XubString& rStr );
+
+ void SetLimits( sal_Int32 _nMinLines, sal_Int32 _nMaxLines );
+ long GetMinimalHeightPixel();
+ long GetOptimalHeightPixel();
+
+ protected:
+ // Window overridables
+ virtual void Resize();
+
+ private:
+ long impl_getMinimalTextWindowHeight();
+ long impl_getMaximalTextWindowHeight();
+ long impl_getHelpTextBorderHeight();
+ long impl_getSpaceAboveTextWindow();
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // HELPWINDOW_HXX
+
diff --git a/extensions/source/propctrlr/inspectormodelbase.cxx b/extensions/source/propctrlr/inspectormodelbase.cxx
new file mode 100644
index 000000000000..8695695d4530
--- /dev/null
+++ b/extensions/source/propctrlr/inspectormodelbase.cxx
@@ -0,0 +1,272 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "inspectormodelbase.hxx"
+#include "pcrcommon.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/propertycontainerhelper.hxx>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+#define MODEL_PROPERTY_ID_HAS_HELP_SECTION 2000
+#define MODEL_PROPERTY_ID_MIN_HELP_TEXT_LINES 2001
+#define MODEL_PROPERTY_ID_MAX_HELP_TEXT_LINES 2002
+#define MODEL_PROPERTY_ID_IS_READ_ONLY 2003
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::inspection::PropertyCategoryDescriptor;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::beans::Property;
+ /** === end UNO using === **/
+ namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
+
+ //====================================================================
+ //= InspectorModelProperties
+ //====================================================================
+ /** helper class for implementing the property set related functionality
+ of an ImplInspectorModel
+ */
+ class InspectorModelProperties : public ::comphelper::OPropertyContainerHelper
+ {
+ private:
+ ::osl::Mutex& m_rMutex;
+ sal_Bool m_bHasHelpSection;
+ sal_Int32 m_nMinHelpTextLines;
+ sal_Int32 m_nMaxHelpTextLines;
+ sal_Bool m_bIsReadOnly;
+ ::std::auto_ptr< ::cppu::IPropertyArrayHelper >
+ m_pPropertyInfo;
+
+ public:
+ InspectorModelProperties( ::osl::Mutex& _rMutex );
+
+ using ::comphelper::OPropertyContainerHelper::convertFastPropertyValue;
+ using ::comphelper::OPropertyContainerHelper::setFastPropertyValue;
+ using ::comphelper::OPropertyContainerHelper::getFastPropertyValue;
+
+ public:
+ inline sal_Bool hasHelpSection() const { return m_bHasHelpSection; }
+ inline sal_Bool isReadOnly() const { return m_bIsReadOnly; }
+ inline sal_Int32 getMinHelpTextLines() const { return m_nMinHelpTextLines; }
+ inline sal_Int32 getMaxHelpTextLines() const { return m_nMaxHelpTextLines; }
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
+ getPropertySetInfo();
+ ::cppu::IPropertyArrayHelper&
+ getInfoHelper();
+
+ void constructWithHelpSection( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines );
+ };
+
+ //====================================================================
+ //= InspectorModelProperties
+ //====================================================================
+ //--------------------------------------------------------------------
+ InspectorModelProperties::InspectorModelProperties( ::osl::Mutex& _rMutex )
+ :m_rMutex( _rMutex )
+ ,m_bHasHelpSection( sal_False )
+ ,m_nMinHelpTextLines( 3 )
+ ,m_nMaxHelpTextLines( 8 )
+ ,m_bIsReadOnly( sal_False )
+ {
+ registerProperty(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HasHelpSection" ) ),
+ MODEL_PROPERTY_ID_HAS_HELP_SECTION,
+ PropertyAttribute::READONLY,
+ &m_bHasHelpSection, ::getCppuType( &m_bHasHelpSection )
+ );
+ registerProperty(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MinHelpTextLines" ) ),
+ MODEL_PROPERTY_ID_MIN_HELP_TEXT_LINES,
+ PropertyAttribute::READONLY,
+ &m_nMinHelpTextLines, ::getCppuType( &m_nMinHelpTextLines )
+ );
+ registerProperty(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxHelpTextLines" ) ),
+ MODEL_PROPERTY_ID_MAX_HELP_TEXT_LINES,
+ PropertyAttribute::READONLY,
+ &m_nMaxHelpTextLines, ::getCppuType( &m_nMaxHelpTextLines )
+ );
+ registerProperty(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsReadOnly" ) ),
+ MODEL_PROPERTY_ID_IS_READ_ONLY,
+ PropertyAttribute::BOUND,
+ &m_bIsReadOnly, ::getCppuType( &m_bIsReadOnly )
+ );
+ }
+
+ //--------------------------------------------------------------------
+ void InspectorModelProperties::constructWithHelpSection( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines )
+ {
+ m_bHasHelpSection = sal_True;
+ m_nMinHelpTextLines = _nMinHelpTextLines;
+ m_nMaxHelpTextLines = _nMaxHelpTextLines;
+ // no need to notify this, those properties are not bound. Also, the method should
+ // only be used during construction phase, where we don't expect to have any listeners.
+ }
+
+ //--------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper& InspectorModelProperties::getInfoHelper()
+ {
+ ::osl::MutexGuard aGuard( m_rMutex );
+ if ( m_pPropertyInfo.get() == NULL )
+ {
+ Sequence< Property > aProperties;
+ describeProperties( aProperties );
+
+ m_pPropertyInfo.reset( new ::cppu::OPropertyArrayHelper( aProperties ) );
+ }
+ return *m_pPropertyInfo;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertySetInfo > InspectorModelProperties::getPropertySetInfo()
+ {
+ return ::cppu::OPropertySetHelper::createPropertySetInfo( getInfoHelper() );
+ }
+
+ //====================================================================
+ //= ImplInspectorModel
+ //====================================================================
+ ImplInspectorModel::ImplInspectorModel( const Reference< XComponentContext >& _rxContext )
+ :ImplInspectorModel_PBase( GetBroadcastHelper() )
+ ,m_aContext( _rxContext )
+ ,m_pProperties( new InspectorModelProperties( m_aMutex ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ImplInspectorModel::~ImplInspectorModel()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XINTERFACE2( ImplInspectorModel, ImplInspectorModel_Base, ImplInspectorModel_PBase )
+
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XTYPEPROVIDER2( ImplInspectorModel, ImplInspectorModel_Base, ImplInspectorModel_PBase )
+
+ //--------------------------------------------------------------------
+ Reference< XPropertySetInfo > SAL_CALL ImplInspectorModel::getPropertySetInfo( ) throw (RuntimeException)
+ {
+ return m_pProperties->getPropertySetInfo();
+ }
+
+ //--------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper& SAL_CALL ImplInspectorModel::getInfoHelper()
+ {
+ return m_pProperties->getInfoHelper();
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL ImplInspectorModel::convertFastPropertyValue( Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue ) throw (IllegalArgumentException)
+ {
+ return m_pProperties->convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ImplInspectorModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (Exception)
+ {
+ m_pProperties->setFastPropertyValue( nHandle, rValue );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ImplInspectorModel::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
+ {
+ m_pProperties->getFastPropertyValue( rValue, nHandle );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL ImplInspectorModel::getHasHelpSection() throw (RuntimeException)
+ {
+ return m_pProperties->hasHelpSection();
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Int32 SAL_CALL ImplInspectorModel::getMinHelpTextLines() throw (RuntimeException)
+ {
+ return m_pProperties->getMinHelpTextLines();
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Int32 SAL_CALL ImplInspectorModel::getMaxHelpTextLines() throw (RuntimeException)
+ {
+ return m_pProperties->getMaxHelpTextLines();
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL ImplInspectorModel::getIsReadOnly() throw (::com::sun::star::uno::RuntimeException)
+ {
+ return m_pProperties->isReadOnly();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ImplInspectorModel::setIsReadOnly( ::sal_Bool _IsReadOnly ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ setFastPropertyValue( MODEL_PROPERTY_ID_IS_READ_ONLY, makeAny( _IsReadOnly ) );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL ImplInspectorModel::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException)
+ {
+ StlSyntaxSequence< ::rtl::OUString > aSupported( getSupportedServiceNames() );
+ for ( StlSyntaxSequence< ::rtl::OUString >::const_iterator check = aSupported.begin();
+ check != aSupported.end();
+ ++check
+ )
+ if ( check->equals( ServiceName ) )
+ return sal_True;
+
+ return sal_False;
+ }
+
+ //--------------------------------------------------------------------
+ void ImplInspectorModel::enableHelpSectionProperties( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines )
+ {
+ m_pProperties->constructWithHelpSection( _nMinHelpTextLines, _nMaxHelpTextLines );
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
diff --git a/extensions/source/propctrlr/inspectormodelbase.hxx b/extensions/source/propctrlr/inspectormodelbase.hxx
new file mode 100644
index 000000000000..9f06515b5d2d
--- /dev/null
+++ b/extensions/source/propctrlr/inspectormodelbase.hxx
@@ -0,0 +1,108 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INSPECTORMODELBASE_HXX
+#define INSPECTORMODELBASE_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/XObjectInspectorModel.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/implbase3.hxx>
+#include <cppuhelper/propshlp.hxx>
+
+#include <comphelper/broadcasthelper.hxx>
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/uno3.hxx>
+
+#include <memory>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ class InspectorModelProperties;
+ //====================================================================
+ //= ImplInspectorModel
+ //====================================================================
+ typedef ::cppu::WeakImplHelper3 < ::com::sun::star::inspection::XObjectInspectorModel
+ , ::com::sun::star::lang::XInitialization
+ , ::com::sun::star::lang::XServiceInfo
+ > ImplInspectorModel_Base;
+ typedef ::cppu::OPropertySetHelper ImplInspectorModel_PBase;
+
+ class ImplInspectorModel
+ :public ::comphelper::OMutexAndBroadcastHelper
+ ,public ImplInspectorModel_Base
+ ,public ImplInspectorModel_PBase
+ {
+ protected:
+ ::comphelper::ComponentContext m_aContext;
+ ::std::auto_ptr< InspectorModelProperties > m_pProperties;
+
+ protected:
+ ~ImplInspectorModel();
+
+ public:
+ ImplInspectorModel( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
+
+ DECLARE_XINTERFACE()
+ DECLARE_XTYPEPROVIDER()
+
+ // ::com::sun::star::beans::XPropertySet and friends
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+ virtual sal_Bool SAL_CALL convertFastPropertyValue( ::com::sun::star::uno::Any & rConvertedValue, ::com::sun::star::uno::Any & rOldValue, sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::lang::IllegalArgumentException);
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception);
+ virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
+
+ // ::com::sun::star::inspection::XObjectInspectorModel
+ virtual ::sal_Bool SAL_CALL getHasHelpSection() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getMinHelpTextLines() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getMaxHelpTextLines() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getIsReadOnly() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setIsReadOnly( ::sal_Bool _IsReadOnly ) throw (::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::lang::XServiceInfo
+ virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ void enableHelpSectionProperties( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines );
+
+ private:
+ using ImplInspectorModel_PBase::getFastPropertyValue;
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // INSPECTORMODELBASE_HXX
+
diff --git a/extensions/source/propctrlr/linedescriptor.hxx b/extensions/source/propctrlr/linedescriptor.hxx
new file mode 100644
index 000000000000..d85655c1d5f2
--- /dev/null
+++ b/extensions/source/propctrlr/linedescriptor.hxx
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _EXTENSIONS_PROPCTRLR_LINEDESCRIPTOR_HXX_
+#define _EXTENSIONS_PROPCTRLR_LINEDESCRIPTOR_HXX_
+
+#include <vcl/image.hxx>
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/LineDescriptor.hpp>
+/** === end UNO includes === **/
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ //========================================================================
+ //= OLineDescriptor
+ //========================================================================
+ struct OLineDescriptor : public ::com::sun::star::inspection::LineDescriptor
+ {
+ ::rtl::OUString sName; // the name of the property
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler >
+ xPropertyHandler; // the handler for this property
+ ::com::sun::star::uno::Any aValue; // the current value of the property
+
+ bool bUnknownValue : 1; // is the property value currently "unknown"? (PropertyState_AMBIGUOUS)
+ bool bReadOnly : 1;
+
+ OLineDescriptor()
+ :bUnknownValue( false )
+ ,bReadOnly( false )
+ {
+ }
+
+ void assignFrom( const ::com::sun::star::inspection::LineDescriptor& _rhs )
+ {
+ ::com::sun::star::inspection::LineDescriptor::operator=( _rhs );
+ }
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_LINEDESCRIPTOR_HXX_
+
diff --git a/extensions/source/propctrlr/listselectiondlg.cxx b/extensions/source/propctrlr/listselectiondlg.cxx
new file mode 100644
index 000000000000..14e4ce7de68e
--- /dev/null
+++ b/extensions/source/propctrlr/listselectiondlg.cxx
@@ -0,0 +1,173 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "listselectiondlg.hxx"
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_LISTSELECTIONDLG_HRC
+#include "listselectiondlg.hrc"
+#endif
+
+#ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
+#include "modulepcr.hxx"
+#endif
+#ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
+#include "formresid.hrc"
+#endif
+#include "formstrings.hxx"
+#include <vcl/msgbox.hxx>
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+
+ //====================================================================
+ //= ListSelectionDialog
+ //====================================================================
+ //--------------------------------------------------------------------
+ ListSelectionDialog::ListSelectionDialog( Window* _pParent, const Reference< XPropertySet >& _rxListBox,
+ const ::rtl::OUString& _rPropertyName, const String& _rPropertyUIName )
+ :ModalDialog( _pParent, PcrRes( RID_DLG_SELECTION ) )
+ ,m_aLabel ( this, PcrRes( FT_ENTRIES ) )
+ ,m_aEntries ( this, PcrRes( LB_ENTRIES ) )
+ ,m_aOK ( this, PcrRes( PB_OK ) )
+ ,m_aCancel ( this, PcrRes( PB_CANCEL ) )
+ ,m_aHelp ( this, PcrRes( PB_HELP ) )
+ ,m_xListBox ( _rxListBox )
+ ,m_sPropertyName( _rPropertyName )
+ {
+ FreeResource();
+
+ OSL_PRECOND( m_xListBox.is(), "ListSelectionDialog::ListSelectionDialog: invalid list box!" );
+
+ SetText( _rPropertyUIName );
+ m_aLabel.SetText( _rPropertyUIName );
+
+ initialize( );
+ }
+
+ //------------------------------------------------------------------------
+ short ListSelectionDialog::Execute()
+ {
+ short nResult = ModalDialog::Execute();
+
+ if ( RET_OK == nResult )
+ commitSelection();
+
+ return nResult;
+ }
+
+ //--------------------------------------------------------------------
+ void ListSelectionDialog::initialize( )
+ {
+ if ( !m_xListBox.is() )
+ return;
+
+ m_aEntries.SetStyle( GetStyle() | WB_SIMPLEMODE );
+
+ try
+ {
+ // initialize the multi-selection flag
+ sal_Bool bMultiSelection = sal_False;
+ OSL_VERIFY( m_xListBox->getPropertyValue( PROPERTY_MULTISELECTION ) >>= bMultiSelection );
+ m_aEntries.EnableMultiSelection( bMultiSelection );
+
+ // fill the list box with all entries
+ Sequence< ::rtl::OUString > aListEntries;
+ OSL_VERIFY( m_xListBox->getPropertyValue( PROPERTY_STRINGITEMLIST ) >>= aListEntries );
+ fillEntryList( aListEntries );
+
+ // select entries according to the property
+ Sequence< sal_Int16 > aSelection;
+ OSL_VERIFY( m_xListBox->getPropertyValue( m_sPropertyName ) >>= aSelection );
+ selectEntries( aSelection );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "ListSelectionDialog::initialize: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void ListSelectionDialog::commitSelection()
+ {
+ if ( !m_xListBox.is() )
+ return;
+
+ Sequence< sal_Int16 > aSelection;
+ collectSelection( aSelection );
+
+ try
+ {
+ m_xListBox->setPropertyValue( m_sPropertyName, makeAny( aSelection ) );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "ListSelectionDialog::commitSelection: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void ListSelectionDialog::fillEntryList( const Sequence< ::rtl::OUString >& _rListEntries )
+ {
+ m_aEntries.Clear();
+ const ::rtl::OUString* _pListEntries = _rListEntries.getConstArray();
+ const ::rtl::OUString* _pListEntriesEnd = _rListEntries.getConstArray() + _rListEntries.getLength();
+ for ( ; _pListEntries < _pListEntriesEnd; ++_pListEntries )
+ m_aEntries.InsertEntry( *_pListEntries );
+ }
+
+ //--------------------------------------------------------------------
+ void ListSelectionDialog::collectSelection( Sequence< sal_Int16 >& /* [out] */ _rSelection )
+ {
+ sal_uInt16 nSelectedCount = m_aEntries.GetSelectEntryCount( );
+ _rSelection.realloc( nSelectedCount );
+ sal_Int16* pSelection = _rSelection.getArray();
+ for ( sal_uInt16 selected = 0; selected < nSelectedCount; ++selected, ++pSelection )
+ *pSelection = static_cast< sal_Int16 >( m_aEntries.GetSelectEntryPos( selected ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ListSelectionDialog::selectEntries( const Sequence< sal_Int16 >& /* [in ] */ _rSelection )
+ {
+ m_aEntries.SetNoSelection();
+ const sal_Int16* pSelection = _rSelection.getConstArray();
+ const sal_Int16* pSelectionEnd = _rSelection.getConstArray() + _rSelection.getLength();
+ for ( ; pSelection != pSelectionEnd; ++pSelection )
+ m_aEntries.SelectEntryPos( *pSelection );
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
diff --git a/extensions/source/propctrlr/listselectiondlg.hrc b/extensions/source/propctrlr/listselectiondlg.hrc
new file mode 100644
index 000000000000..cfd85be0a1aa
--- /dev/null
+++ b/extensions/source/propctrlr/listselectiondlg.hrc
@@ -0,0 +1,39 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_LISTSELECTIONDLG_HRC
+#define EXTENSIONS_SOURCE_PROPCTRLR_LISTSELECTIONDLG_HRC
+
+#define FT_ENTRIES 1
+
+#define LB_ENTRIES 1
+
+#define PB_OK 1
+#define PB_CANCEL 2
+#define PB_HELP 3
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_LISTSELECTIONDLG_HRC
diff --git a/extensions/source/propctrlr/listselectiondlg.hxx b/extensions/source/propctrlr/listselectiondlg.hxx
new file mode 100644
index 000000000000..c741f1e08945
--- /dev/null
+++ b/extensions/source/propctrlr/listselectiondlg.hxx
@@ -0,0 +1,89 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_LISTSELECTIONDLG_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_LISTSELECTIONDLG_HXX
+
+#include <vcl/dialog.hxx>
+#include <vcl/fixed.hxx>
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#include <vcl/lstbox.hxx>
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/XPropertySet.hpp>
+/** === end UNO includes === **/
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= ListSelectionDialog
+ //====================================================================
+ class ListSelectionDialog : public ModalDialog
+ {
+ private:
+ FixedText m_aLabel;
+ ListBox m_aEntries;
+ OKButton m_aOK;
+ CancelButton m_aCancel;
+ HelpButton m_aHelp;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xListBox;
+ ::rtl::OUString m_sPropertyName;
+
+ public:
+ ListSelectionDialog(
+ Window* _pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxListBox,
+ const ::rtl::OUString& _rPropertyName,
+ const String& _rPropertyUIName
+ );
+
+ // Dialog overridables
+ virtual short Execute();
+
+ private:
+ void initialize( );
+ void commitSelection();
+
+ void fillEntryList ( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rListEntries );
+
+ void selectEntries ( const ::com::sun::star::uno::Sequence< sal_Int16 >& /* [in ] */ _rSelection );
+ void collectSelection( ::com::sun::star::uno::Sequence< sal_Int16 >& /* [out] */ _rSelection );
+ };
+
+//........................................................................
+} // namespacepcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_LISTSELECTIONDLG_HXX
+
diff --git a/extensions/source/propctrlr/listselectiondlg.src b/extensions/source/propctrlr/listselectiondlg.src
new file mode 100644
index 000000000000..84cad0d9c0a9
--- /dev/null
+++ b/extensions/source/propctrlr/listselectiondlg.src
@@ -0,0 +1,82 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
+#include "formresid.hrc"
+#endif
+#include "propctrlr.hrc"
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_LISTSELECTIONDLG_HRC
+#include "listselectiondlg.hrc"
+#endif
+
+ModalDialog RID_DLG_SELECTION
+{
+ HelpID = "extensions:ModalDialog:RID_DLG_SELECTION";
+ OutputSize = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 150, 120 ) ;
+
+ FixedText FT_ENTRIES
+ {
+ Pos = MAP_APPFONT( 6, 6 );
+ Size = MAP_APPFONT( 85, 8 );
+ };
+
+ ListBox LB_ENTRIES
+ {
+ HelpID = "extensions:ListBox:RID_DLG_SELECTION:LB_ENTRIES";
+ Pos = MAP_APPFONT( 6, 17 );
+ Size = MAP_APPFONT( 85, 97 );
+
+ Border = TRUE;
+ DropDown = FALSE;
+ };
+
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT( 97, 6 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ DefButton = TRUE;
+ };
+
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT( 97, 23 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ };
+
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT( 97, 43 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ };
+};
diff --git a/extensions/source/propctrlr/makefile.mk b/extensions/source/propctrlr/makefile.mk
new file mode 100644
index 000000000000..ebb629ae39c9
--- /dev/null
+++ b/extensions/source/propctrlr/makefile.mk
@@ -0,0 +1,154 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+PRJINC=..$/inc
+
+PRJNAME=extensions
+TARGET=pcr
+USE_DEFFILE=TRUE
+
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= $(SLO)$/controlfontdialog.obj \
+ $(SLO)$/fontdialog.obj \
+ $(SLO)$/pcrservices.obj \
+ $(SLO)$/selectlabeldialog.obj \
+ $(SLO)$/propcontroller.obj \
+ $(SLO)$/formcontroller.obj \
+ $(SLO)$/modulepcr.obj \
+ $(SLO)$/cellbindinghelper.obj \
+ $(SLO)$/taborder.obj \
+ $(SLO)$/pcrunodialogs.obj \
+ $(SLO)$/unourl.obj \
+ $(SLO)$/formlinkdialog.obj \
+ $(SLO)$/listselectiondlg.obj \
+ $(SLO)$/browserlistbox.obj \
+ $(SLO)$/stringrepresentation.obj \
+ $(SLO)$/eformshelper.obj \
+ $(SLO)$/xsddatatypes.obj \
+ $(SLO)$/xsdvalidationhelper.obj \
+ $(SLO)$/pushbuttonnavigation.obj \
+ $(SLO)$/sqlcommanddesign.obj \
+ $(SLO)$/composeduiupdate.obj \
+ $(SLO)$/propertycomposer.obj \
+ $(SLO)$/pcrcomponentcontext.obj \
+ $(SLO)$/commoncontrol.obj \
+ $(SLO)$/standardcontrol.obj \
+ $(SLO)$/usercontrol.obj \
+ $(SLO)$/browserline.obj \
+ $(SLO)$/genericpropertyhandler.obj \
+ $(SLO)$/buttonnavigationhandler.obj \
+ $(SLO)$/handlerhelper.obj \
+ $(SLO)$/propertyhandler.obj \
+ $(SLO)$/eventhandler.obj \
+ $(SLO)$/editpropertyhandler.obj \
+ $(SLO)$/eformspropertyhandler.obj \
+ $(SLO)$/cellbindinghandler.obj \
+ $(SLO)$/submissionhandler.obj \
+ $(SLO)$/xsdvalidationpropertyhandler.obj \
+ $(SLO)$/formcomponenthandler.obj \
+ $(SLO)$/formmetadata.obj \
+ $(SLO)$/defaultforminspection.obj \
+ $(SLO)$/formbrowsertools.obj \
+ $(SLO)$/browserpage.obj \
+ $(SLO)$/propertyeditor.obj \
+ $(SLO)$/formstrings.obj \
+ $(SLO)$/pcrstrings.obj \
+ $(SLO)$/browserview.obj \
+ $(SLO)$/pcrcommon.obj \
+ $(SLO)$/newdatatype.obj \
+ $(SLO)$/propeventtranslation.obj \
+ $(SLO)$/objectinspectormodel.obj \
+ $(SLO)$/inspectorhelpwindow.obj \
+ $(SLO)$/defaulthelpprovider.obj \
+ $(SLO)$/MasterDetailLinkDialog.obj \
+ $(SLO)$/inspectormodelbase.obj \
+ $(SLO)$/propertycontrolextender.obj \
+ $(SLO)$/formgeometryhandler.obj
+
+SRS1NAME=$(TARGET)
+SRC1FILES= propres.src \
+ formres.src \
+ pcrmiscres.src \
+ taborder.src \
+ fontdialog.src \
+ selectlabeldialog.src \
+ formlinkdialog.src \
+ listselectiondlg.src \
+ newdatatype.src
+
+RESLIB1NAME=$(TARGET)
+RESLIB1IMAGES=$(PRJ)$/res
+RESLIB1SRSFILES= $(SRS)$/$(TARGET).srs
+
+SHL1TARGET= $(TARGET)$(DLLPOSTFIX)
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+SHL1STDLIBS= \
+ $(EDITENGLIB) \
+ $(SVXCORELIB) \
+ $(SVXLIB) \
+ $(SFXLIB) \
+ $(SVTOOLLIB)\
+ $(TKLIB) \
+ $(VCLLIB) \
+ $(SVLLIB) \
+ $(TOOLSLIB) \
+ $(I18NISOLANGLIB) \
+ $(DBTOOLSLIB) \
+ $(COMPHELPERLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(UNOTOOLSLIB) \
+ $(SALLIB)
+
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1IMPLIB= i$(TARGET)
+SHL1DEPN= $(SHL1LIBS)
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
+ALLTAR : $(MISC)/pcr.component
+
+$(MISC)/pcr.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \
+ pcr.component
+ $(XSLTPROC) --nonet --stringparam uri \
+ '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \
+ $(SOLARENV)/bin/createcomponent.xslt pcr.component
diff --git a/extensions/source/propctrlr/modulepcr.cxx b/extensions/source/propctrlr/modulepcr.cxx
new file mode 100644
index 000000000000..4b81c740ad79
--- /dev/null
+++ b/extensions/source/propctrlr/modulepcr.cxx
@@ -0,0 +1,48 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "modulepcr.hxx"
+
+#ifndef INCLUDED_OSL_DOUBLECHECKEDLOCKING_H
+#include <rtl/instance.hxx>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/getglobalmutex.hxx>
+#endif
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ IMPLEMENT_MODULE( PcrModule, "pcr" )
+
+//........................................................................
+} // namespace pcr
+//........................................................................
diff --git a/extensions/source/propctrlr/modulepcr.hxx b/extensions/source/propctrlr/modulepcr.hxx
new file mode 100644
index 000000000000..90ece54e29cf
--- /dev/null
+++ b/extensions/source/propctrlr/modulepcr.hxx
@@ -0,0 +1,45 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_PROPCTRLR_MODULEPRC_HXX
+#define EXTENSIONS_PROPCTRLR_MODULEPRC_HXX
+
+#include <unotools/componentresmodule.hxx>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ DEFINE_MODULE( PcrModule, PcrClient, PcrRes )
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
+
diff --git a/extensions/source/propctrlr/newdatatype.cxx b/extensions/source/propctrlr/newdatatype.cxx
new file mode 100644
index 000000000000..412048a9e7b2
--- /dev/null
+++ b/extensions/source/propctrlr/newdatatype.cxx
@@ -0,0 +1,109 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "newdatatype.hxx"
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_NEWDATATYPE_HRC
+#include "newdatatype.hrc"
+#endif
+
+#ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
+#include "modulepcr.hxx"
+#endif
+#ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
+#include "formresid.hrc"
+#endif
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= NewDataTypeDialog
+ //====================================================================
+ //--------------------------------------------------------------------
+ NewDataTypeDialog::NewDataTypeDialog( Window* _pParent, const ::rtl::OUString& _rNameBase, const ::std::vector< ::rtl::OUString >& _rProhibitedNames )
+ :ModalDialog( _pParent, PcrRes( RID_DLG_NEW_DATA_TYPE ) )
+ ,m_aLabel ( this, PcrRes( FT_LABEL ) )
+ ,m_aName ( this, PcrRes( ED_NAME ) )
+ ,m_aOK ( this, PcrRes( PB_OK ) )
+ ,m_aCancel ( this, PcrRes( PB_CANCEL ) )
+ ,m_aProhibitedNames( _rProhibitedNames.begin(), _rProhibitedNames.end() )
+ {
+ FreeResource();
+
+ m_aName.SetModifyHdl( LINK( this, NewDataTypeDialog, OnNameModified ) );
+
+ // find an initial name
+ // for this, first remove trailing digits
+ sal_Int32 nStripUntil = _rNameBase.getLength();
+ while ( nStripUntil > 0 )
+ {
+ sal_Unicode nChar = _rNameBase[ --nStripUntil ];
+ if ( ( nChar < '0' ) || ( nChar > '9' ) )
+ {
+ if ( nChar == ' ' )
+ --nStripUntil; // strip the space, too
+ break;
+ }
+ }
+
+ String sNameBase( _rNameBase.copy( 0, nStripUntil ? nStripUntil + 1 : 0 ) );
+ sNameBase.Append( ' ' );
+ String sInitialName;
+ sal_Int32 nPostfixNumber = 1;
+ do
+ {
+ ( sInitialName = sNameBase ) += String::CreateFromInt32( nPostfixNumber++ );
+ }
+ while ( m_aProhibitedNames.find( sInitialName ) != m_aProhibitedNames.end() );
+
+ m_aName.SetText( sInitialName );
+ OnNameModified( NULL );
+ }
+
+ //--------------------------------------------------------------------
+ IMPL_LINK( NewDataTypeDialog, OnNameModified, void*, /*_pNotInterestedIn*/ )
+ {
+ String sCurrentName = GetName();
+ bool bNameIsOK = ( sCurrentName.Len() > 0 )
+ && ( m_aProhibitedNames.find( sCurrentName ) == m_aProhibitedNames.end() );
+
+ m_aOK.Enable( bNameIsOK );
+
+ return 0L;
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
diff --git a/extensions/source/propctrlr/newdatatype.hrc b/extensions/source/propctrlr/newdatatype.hrc
new file mode 100644
index 000000000000..3dc8635b05f7
--- /dev/null
+++ b/extensions/source/propctrlr/newdatatype.hrc
@@ -0,0 +1,38 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_NEWDATATYPE_HRC
+#define EXTENSIONS_SOURCE_PROPCTRLR_NEWDATATYPE_HRC
+
+#define FT_LABEL 1
+
+#define ED_NAME 2
+
+#define PB_OK 1
+#define PB_CANCEL 2
+
+#endif
diff --git a/extensions/source/propctrlr/newdatatype.hxx b/extensions/source/propctrlr/newdatatype.hxx
new file mode 100644
index 000000000000..501354c3fcf2
--- /dev/null
+++ b/extensions/source/propctrlr/newdatatype.hxx
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_NEWDATATYPE_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_NEWDATATYPE_HXX
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <vcl/dialog.hxx>
+#include <vcl/fixed.hxx>
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#include <vcl/edit.hxx>
+
+#include <set>
+#include <vector>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= NewDataTypeDialog
+ //====================================================================
+ class NewDataTypeDialog : public ModalDialog
+ {
+ private:
+ FixedText m_aLabel;
+ Edit m_aName;
+ OKButton m_aOK;
+ CancelButton m_aCancel;
+
+ ::std::set< ::rtl::OUString >
+ m_aProhibitedNames;
+
+ public:
+ NewDataTypeDialog( Window* _pParent, const ::rtl::OUString& _rNameBase, const ::std::vector< ::rtl::OUString >& _rProhibitedNames );
+
+ inline String GetName() const { return m_aName.GetText(); }
+
+ private:
+ DECL_LINK( OnNameModified, void* );
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_NEWDATATYPE_HXX
+
diff --git a/extensions/source/propctrlr/newdatatype.src b/extensions/source/propctrlr/newdatatype.src
new file mode 100644
index 000000000000..c732013141e7
--- /dev/null
+++ b/extensions/source/propctrlr/newdatatype.src
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_PROPRESID_HRC
+#include "formresid.hrc"
+#endif
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_NEWDATATYPE_HRC
+#include "newdatatype.hrc"
+#endif
+
+#define DIALOG_WIDTH 150
+#define DIALOG_HEIGHT 55
+#define BUTTON_WIDTH 50
+#define BUTTON_HEIGHT 14
+
+ModalDialog RID_DLG_NEW_DATA_TYPE
+{
+ HelpID = "extensions:ModalDialog:RID_DLG_NEW_DATA_TYPE";
+ OutputSize = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( DIALOG_WIDTH, DIALOG_HEIGHT ) ;
+
+ Text [ en-US ] = "New Data Type";
+
+ FixedText FT_LABEL
+ {
+ Pos = MAP_APPFONT( 6, 6 );
+ Size = MAP_APPFONT( DIALOG_WIDTH - 2 * 6, 8 );
+
+ Text [ en-US ] = "Type a name for the new data type:";
+ };
+
+ Edit ED_NAME
+ {
+ HelpID = "extensions:Edit:RID_DLG_NEW_DATA_TYPE:ED_NAME";
+ Pos = MAP_APPFONT( 6, 17 );
+ Size = MAP_APPFONT( DIALOG_WIDTH - 2 * 6, 12 );
+ Border = TRUE;
+ };
+
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT( DIALOG_WIDTH - 6 - BUTTON_WIDTH - 3 - BUTTON_WIDTH, 35 );
+ Size = MAP_APPFONT( BUTTON_WIDTH, BUTTON_HEIGHT );
+ DefButton = TRUE;
+ };
+
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT( DIALOG_WIDTH - 6 - BUTTON_WIDTH, 35 );
+ Size = MAP_APPFONT( BUTTON_WIDTH, BUTTON_HEIGHT );
+ };
+};
diff --git a/extensions/source/propctrlr/objectinspectormodel.cxx b/extensions/source/propctrlr/objectinspectormodel.cxx
new file mode 100644
index 000000000000..fdffb69632b5
--- /dev/null
+++ b/extensions/source/propctrlr/objectinspectormodel.cxx
@@ -0,0 +1,242 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "modulepcr.hxx"
+#include "pcrcommon.hxx"
+#include "inspectormodelbase.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/ucb/AlreadyInitializedException.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/implbase3.hxx>
+
+#include <comphelper/broadcasthelper.hxx>
+#include <comphelper/uno3.hxx>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::inspection::XObjectInspectorModel;
+ using ::com::sun::star::lang::XInitialization;
+ using ::com::sun::star::lang::XServiceInfo;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::inspection::PropertyCategoryDescriptor;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::ucb::AlreadyInitializedException;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::uno::makeAny;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= ObjectInspectorModel
+ //====================================================================
+ class ObjectInspectorModel : public ImplInspectorModel
+ {
+ private:
+ Sequence< Any > m_aFactories;
+
+ public:
+ ObjectInspectorModel( const Reference< XComponentContext >& _rxContext );
+
+ // XObjectInspectorModel
+ virtual Sequence< Any > SAL_CALL getHandlerFactories() throw (RuntimeException);
+ virtual Sequence< PropertyCategoryDescriptor > SAL_CALL describeCategories( ) throw (RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getPropertyOrderIndex( const ::rtl::OUString& PropertyName ) throw (RuntimeException);
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (RuntimeException);
+ virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException);
+
+ // XServiceInfo - static versions
+ static ::rtl::OUString getImplementationName_static( ) throw(RuntimeException);
+ static Sequence< ::rtl::OUString > getSupportedServiceNames_static( ) throw(RuntimeException);
+ static Reference< XInterface > SAL_CALL
+ Create(const Reference< XComponentContext >&);
+
+ protected:
+ void createDefault();
+ void createWithHandlerFactories( const Sequence< Any >& _rFactories );
+ void createWithHandlerFactoriesAndHelpSection( const Sequence< Any >& _rFactories, sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines );
+
+ private:
+ /** checks a given condition to be <TRUE/>, and throws an IllegalArgumentException if not
+ */
+ void impl_verifyArgument_throw( bool _bCondition, sal_Int16 _nArgumentPosition );
+ };
+
+ //====================================================================
+ //= ObjectInspectorModel
+ //====================================================================
+ ObjectInspectorModel::ObjectInspectorModel( const Reference< XComponentContext >& _rxContext )
+ :ImplInspectorModel( _rxContext )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Any > SAL_CALL ObjectInspectorModel::getHandlerFactories() throw (RuntimeException)
+ {
+ return m_aFactories;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< PropertyCategoryDescriptor > SAL_CALL ObjectInspectorModel::describeCategories( ) throw (RuntimeException)
+ {
+ // no category info provided by this default implementation
+ return Sequence< PropertyCategoryDescriptor >( );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Int32 SAL_CALL ObjectInspectorModel::getPropertyOrderIndex( const ::rtl::OUString& /*PropertyName*/ ) throw (RuntimeException)
+ {
+ // no ordering provided by this default implementation
+ return 0;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ObjectInspectorModel::initialize( const Sequence< Any >& _arguments ) throw (Exception, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_aFactories.getLength() )
+ throw AlreadyInitializedException();
+
+ StlSyntaxSequence< Any > arguments( _arguments );
+ if ( arguments.empty() )
+ { // constructor: "createDefault()"
+ createDefault();
+ return;
+ }
+
+ Sequence< Any > factories;
+ impl_verifyArgument_throw( arguments[0] >>= factories, 1 );
+
+ if ( arguments.size() == 1 )
+ { // constructor: "createWithHandlerFactories( any[] )"
+ createWithHandlerFactories( factories );
+ return;
+ }
+
+ sal_Int32 nMinHelpTextLines( 0 ), nMaxHelpTextLines( 0 );
+ if ( arguments.size() == 3 )
+ { // constructor: "createWithHandlerFactoriesAndHelpSection( any[], long, long )"
+ impl_verifyArgument_throw( arguments[1] >>= nMinHelpTextLines, 2 );
+ impl_verifyArgument_throw( arguments[2] >>= nMaxHelpTextLines, 3 );
+ createWithHandlerFactoriesAndHelpSection( factories, nMinHelpTextLines, nMaxHelpTextLines );
+ return;
+ }
+
+ impl_verifyArgument_throw( false, 2 );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ObjectInspectorModel::getImplementationName( ) throw (RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL ObjectInspectorModel::getSupportedServiceNames( ) throw (RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString ObjectInspectorModel::getImplementationName_static( ) throw(RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.extensions.ObjectInspectorModel" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > ObjectInspectorModel::getSupportedServiceNames_static( ) throw(RuntimeException)
+ {
+ ::rtl::OUString sService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.inspection.ObjectInspectorModel" ) );
+ return Sequence< ::rtl::OUString >( &sService, 1 );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL ObjectInspectorModel::Create(const Reference< XComponentContext >& _rxContext )
+ {
+ return *( new ObjectInspectorModel( _rxContext ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ObjectInspectorModel::createDefault()
+ {
+ m_aFactories.realloc( 1 );
+ m_aFactories[0] <<= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.inspection.GenericPropertyHandler" ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ObjectInspectorModel::createWithHandlerFactories( const Sequence< Any >& _rFactories )
+ {
+ impl_verifyArgument_throw( _rFactories.getLength() > 0, 1 );
+ m_aFactories = _rFactories;
+ }
+
+ //--------------------------------------------------------------------
+ void ObjectInspectorModel::createWithHandlerFactoriesAndHelpSection( const Sequence< Any >& _rFactories, sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines )
+ {
+ impl_verifyArgument_throw( _rFactories.getLength() > 0, 1 );
+ impl_verifyArgument_throw( _nMinHelpTextLines >= 1, 2 );
+ impl_verifyArgument_throw( _nMaxHelpTextLines >= 1, 3 );
+ impl_verifyArgument_throw( _nMinHelpTextLines <= _nMaxHelpTextLines, 2 );
+
+ m_aFactories = _rFactories;
+ enableHelpSectionProperties( _nMinHelpTextLines, _nMaxHelpTextLines );
+ }
+
+ //--------------------------------------------------------------------
+ void ObjectInspectorModel::impl_verifyArgument_throw( bool _bCondition, sal_Int16 _nArgumentPosition )
+ {
+ if ( !_bCondition )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, _nArgumentPosition );
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_ObjectInspectorModel()
+{
+ ::pcr::OAutoRegistration< ::pcr::ObjectInspectorModel > aObjectInspectorModelRegistration;
+}
diff --git a/extensions/source/propctrlr/pcr.component b/extensions/source/propctrlr/pcr.component
new file mode 100644
index 000000000000..2b606cc01c11
--- /dev/null
+++ b/extensions/source/propctrlr/pcr.component
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--**********************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org 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 version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+**********************************************************************-->
+
+<component loader="com.sun.star.loader.SharedLibrary"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="StringRepresentation">
+ <service name="com.sun.star.inspection.StringRepresentation"/>
+ </implementation>
+ <implementation name="com.sun.star.comp.extensions.ButtonNavigationHandler">
+ <service name="com.sun.star.form.inspection.ButtonNavigationHandler"/>
+ </implementation>
+ <implementation name="com.sun.star.comp.extensions.CellBindingPropertyHandler">
+ <service name="com.sun.star.form.inspection.CellBindingPropertyHandler"/>
+ </implementation>
+ <implementation name="com.sun.star.comp.extensions.EFormsPropertyHandler">
+ <service name="com.sun.star.form.inspection.XMLFormsPropertyHandler"/>
+ </implementation>
+ <implementation name="com.sun.star.comp.extensions.EditPropertyHandler">
+ <service name="com.sun.star.form.inspection.EditPropertyHandler"/>
+ </implementation>
+ <implementation name="com.sun.star.comp.extensions.EventHandler">
+ <service name="com.sun.star.form.inspection.EventHandler"/>
+ </implementation>
+ <implementation name="com.sun.star.comp.extensions.FormComponentPropertyHandler">
+ <service name="com.sun.star.form.inspection.FormComponentPropertyHandler"/>
+ </implementation>
+ <implementation name="com.sun.star.comp.extensions.FormGeometryHandler">
+ <service name="com.sun.star.form.inspection.FormGeometryHandler"/>
+ </implementation>
+ <implementation name="com.sun.star.comp.extensions.GenericPropertyHandler">
+ <service name="com.sun.star.inspection.GenericPropertyHandler"/>
+ </implementation>
+ <implementation name="com.sun.star.comp.extensions.SubmissionPropertyHandler">
+ <service name="com.sun.star.form.inspection.SubmissionPropertyHandler"/>
+ </implementation>
+ <implementation name="com.sun.star.comp.extensions.XSDValidationPropertyHandler">
+ <service name="com.sun.star.form.inspection.XSDValidationPropertyHandler"/>
+ </implementation>
+ <implementation name="org.openoffice.comp.extensions.DefaultFormComponentInspectorModel">
+ <service name="com.sun.star.form.inspection.DefaultFormComponentInspectorModel"/>
+ </implementation>
+ <implementation name="org.openoffice.comp.extensions.DefaultHelpProvider">
+ <service name="com.sun.star.inspection.DefaultHelpProvider"/>
+ </implementation>
+ <implementation name="org.openoffice.comp.extensions.DialogController">
+ <service name="com.sun.star.awt.PropertyBrowserController"/>
+ </implementation>
+ <implementation name="org.openoffice.comp.extensions.FormController">
+ <service name="com.sun.star.form.PropertyBrowserController"/>
+ </implementation>
+ <implementation name="org.openoffice.comp.extensions.ObjectInspector">
+ <service name="com.sun.star.inspection.ObjectInspector"/>
+ </implementation>
+ <implementation name="org.openoffice.comp.extensions.ObjectInspectorModel">
+ <service name="com.sun.star.inspection.ObjectInspectorModel"/>
+ </implementation>
+ <implementation name="org.openoffice.comp.form.ui.MasterDetailLinkDialog">
+ <service name="com.sun.star.form.MasterDetailLinkDialog"/>
+ </implementation>
+ <implementation name="org.openoffice.comp.form.ui.OControlFontDialog">
+ <service name="com.sun.star.form.ControlFontDialog"/>
+ </implementation>
+ <implementation name="org.openoffice.comp.form.ui.OTabOrderDialog">
+ <service name="com.sun.star.form.ui.TabOrderDialog"/>
+ </implementation>
+</component>
diff --git a/extensions/source/propctrlr/pcr.xml b/extensions/source/propctrlr/pcr.xml
new file mode 100644
index 000000000000..3507a452d056
--- /dev/null
+++ b/extensions/source/propctrlr/pcr.xml
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description SYSTEM "module-description.dtd">
+<module-description>
+ <module-name>pcr</module-name>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>org.openoffice.comp.form.ui.OTabOrderDialog</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="non-published"/>
+ <supported-service>com.sun.star.form.ui.TabOrderDialog</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>org.openoffice.comp.form.ControlFontDialog</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="non-published"/>
+ <supported-service>com.sun.star.form.ui.TabOrderDialog</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>com.sun.star.comp.extensions.FormComponentPropertyHandler</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="non-published"/>
+ <supported-service>com.sun.star.form.inspection.FormComponentPropertyHandler</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>com.sun.star.comp.extensions.EFormsPropertyHandler</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.form.inspection.XMLFormsPropertyHandler</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>com.sun.star.comp.extensions.EditPropertyHandler</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.form.inspection.EditPropertyHandler</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>org.openoffice.comp.extensions.ObjectInspector</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.inspection.ObjectInspector</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>org.openoffice.comp.extensions.ObjectInspectorModel</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.inspection.ObjectInspectorModel</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>org.openoffice.comp.extensions.FormController</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.form.PropertyBrowserController</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>com.sun.star.comp.extensions.GenericPropertyHandler</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.inspection.GenericPropertyHandler</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>com.sun.star.comp.extensions.EventHandler</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.form.inspection.EventHandler</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>com.sun.star.comp.extensions.XSDValidationPropertyHandler</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.form.inspection.XSDValidationPropertyHandler</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>com.sun.star.comp.extensions.CellBindingPropertyHandler</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.form.inspection.CellBindingPropertyHandler</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>com.sun.star.comp.extensions.ButtonNavigationHandler</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.form.inspection.ButtonNavigationHandler</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>com.sun.star.comp.extensions.DefaultFormComponentInspectorModel</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.form.inspection.DefaultFormComponentInspectorModel</supported-service>
+ </component-description>
+
+</module-description>
diff --git a/extensions/source/propctrlr/pcrcommon.cxx b/extensions/source/propctrlr/pcrcommon.cxx
new file mode 100644
index 000000000000..d04ece5dc06f
--- /dev/null
+++ b/extensions/source/propctrlr/pcrcommon.cxx
@@ -0,0 +1,78 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "pcrcommon.hxx"
+#ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
+#include "modulepcr.hxx"
+#endif
+#ifndef EXTENSIONS_PROPRESID_HRC
+#include "propresid.hrc"
+#endif
+
+/** === begin UNO includes === **/
+#include <com/sun/star/util/MeasureUnit.hpp>
+/** === end UNO includes === **/
+#include <rtl/ustrbuf.hxx>
+#include <tools/urlobj.hxx>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star::util;
+
+ //========================================================================
+ //= HelpIdUrl
+ //========================================================================
+ //------------------------------------------------------------------------
+ rtl::OString HelpIdUrl::getHelpId( const ::rtl::OUString& _rHelpURL )
+ {
+ INetURLObject aHID( _rHelpURL );
+ if ( aHID.GetProtocol() == INET_PROT_HID )
+ return rtl::OUStringToOString( aHID.GetURLPath(), RTL_TEXTENCODING_UTF8 );
+ else
+ return rtl::OUStringToOString( _rHelpURL, RTL_TEXTENCODING_UTF8 );
+ }
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString HelpIdUrl::getHelpURL( const rtl::OString& sHelpId )
+ {
+ ::rtl::OUStringBuffer aBuffer;
+ ::rtl::OUString aTmp( sHelpId, sHelpId.getLength(), RTL_TEXTENCODING_UTF8 );
+ INetURLObject aHID( aTmp );
+ if ( aHID.GetProtocol() == INET_PROT_NOT_VALID )
+ aBuffer.appendAscii( INET_HID_SCHEME );
+ aBuffer.append( aTmp.getStr() );
+ return aBuffer.makeStringAndClear();
+ }
+//............................................................................
+} // namespace pcr
+//............................................................................
+
diff --git a/extensions/source/propctrlr/pcrcommon.hxx b/extensions/source/propctrlr/pcrcommon.hxx
new file mode 100644
index 000000000000..69e508ca8d87
--- /dev/null
+++ b/extensions/source/propctrlr/pcrcommon.hxx
@@ -0,0 +1,152 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_PCRCOMMON_HXX_
+#define _EXTENSIONS_PROPCTRLR_PCRCOMMON_HXX_
+
+#define EDITOR_LIST_APPEND (sal_uInt16)-1
+#define EDITOR_LIST_REPLACE_EXISTING (sal_uInt16)-1
+
+/** === begin UNO includes === **/
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/beans/PropertyChangeEvent.hpp>
+/** === end UNO includes === **/
+
+#include <tools/string.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <comphelper/listenernotification.hxx>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ #define OWN_PROPERTY_ID_INTROSPECTEDOBJECT 0x0010
+ #define OWN_PROPERTY_ID_CURRENTPAGE 0x0011
+ #define OWN_PROPERTY_ID_CONTROLCONTEXT 0x0012
+ #define OWN_PROPERTY_ID_TABBINGMODEL 0x0013
+
+ //========================================================================
+ //= types
+ //========================================================================
+ typedef ::comphelper::OSimpleListenerContainer < ::com::sun::star::beans::XPropertyChangeListener
+ , ::com::sun::star::beans::PropertyChangeEvent
+ > PropertyChangeListeners;
+
+ //========================================================================
+ //= helper
+ //========================================================================
+ // small helper to make the "swap" call on an STL container a single-line call, which
+ // in it's canonic form "aFoo.swap( Container() )" doesn't compile with GCC
+ template< class CONTAINER >
+ void clearContainer( CONTAINER& _rContainer )
+ {
+ CONTAINER aEmpty;
+ _rContainer.swap( aEmpty );
+ }
+
+ //========================================================================
+ //= HelpIdUrl
+ //========================================================================
+ /// small helper to translate help ids into help urls
+ class HelpIdUrl
+ {
+ public:
+ static rtl::OString getHelpId( const ::rtl::OUString& _rHelpURL );
+ static ::rtl::OUString getHelpURL( const rtl::OString& );
+ };
+
+ //====================================================================
+ //= StlSyntaxSequence
+ //====================================================================
+ template< class ELEMENT >
+ class StlSyntaxSequence : public ::com::sun::star::uno::Sequence< ELEMENT >
+ {
+ private:
+ typedef ::com::sun::star::uno::Sequence< ELEMENT > UnoBase;
+
+ public:
+ inline StlSyntaxSequence() : UnoBase() { }
+ inline StlSyntaxSequence( const UnoBase& rSeq ) : UnoBase( rSeq ) { }
+ inline StlSyntaxSequence( const ELEMENT* pElements, sal_Int32 len ) : UnoBase( pElements, len ) { }
+ inline StlSyntaxSequence( sal_Int32 len ) : UnoBase( len ) { }
+
+ operator const UnoBase&() const { return *this; }
+ operator UnoBase&() { return *this; }
+
+ typedef const ELEMENT* const_iterator;
+ typedef ELEMENT* iterator;
+
+ inline const_iterator begin() const { return UnoBase::getConstArray(); }
+ inline const_iterator end() const { return UnoBase::getConstArray() + UnoBase::getLength(); }
+
+ inline iterator begin() { return UnoBase::getArray(); }
+ inline iterator end() { return UnoBase::getArray() + UnoBase::getLength(); }
+
+ inline sal_Int32 size() const { return UnoBase::getLength(); }
+ inline bool empty() const { return UnoBase::getLength() == 0; }
+
+ inline void resize( size_t _newSize ) { UnoBase::realloc( _newSize ); }
+
+ inline iterator erase( iterator _pos )
+ {
+ iterator loop = end();
+ while ( --loop != _pos )
+ *( loop - 1 ) = *loop;
+ resize( size() - 1 );
+ }
+ };
+
+ //========================================================================
+ //= UNO helpers
+ //========================================================================
+#define DECLARE_XCOMPONENT() \
+ virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException); \
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); \
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+
+#define IMPLEMENT_FORWARD_XCOMPONENT( classname, baseclass ) \
+ void SAL_CALL classname::dispose( ) throw (::com::sun::star::uno::RuntimeException) \
+ { \
+ baseclass::WeakComponentImplHelperBase::dispose(); \
+ } \
+ void SAL_CALL classname::addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException) \
+ { \
+ baseclass::WeakComponentImplHelperBase::addEventListener( _Listener ); \
+ } \
+ void SAL_CALL classname::removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException) \
+ { \
+ baseclass::WeakComponentImplHelperBase::removeEventListener( _Listener ); \
+ } \
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_PCRCOMMON_HXX_
+
diff --git a/extensions/source/propctrlr/pcrcommontypes.hxx b/extensions/source/propctrlr/pcrcommontypes.hxx
new file mode 100644
index 000000000000..230580259617
--- /dev/null
+++ b/extensions/source/propctrlr/pcrcommontypes.hxx
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_PCRCOMMONTYPES_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_PCRCOMMONTYPES_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/Property.hpp>
+/** === end UNO includes === **/
+#include <rtl/ustring.hxx>
+
+#include <hash_map>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ typedef ::std::hash_map< ::rtl::OUString, ::com::sun::star::beans::Property, ::rtl::OUStringHash >
+ PropertyMap;
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_PCRCOMMONTYPES_HXX
+
diff --git a/extensions/source/propctrlr/pcrcomponentcontext.cxx b/extensions/source/propctrlr/pcrcomponentcontext.cxx
new file mode 100644
index 000000000000..c998872864b2
--- /dev/null
+++ b/extensions/source/propctrlr/pcrcomponentcontext.cxx
@@ -0,0 +1,106 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "pcrcomponentcontext.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/NullPointerException.hpp>
+#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+/** === end UNO includes === **/
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::lang::NullPointerException;
+ using ::com::sun::star::lang::ServiceNotRegisteredException;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::RuntimeException;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= ComponentContext
+ //====================================================================
+ //--------------------------------------------------------------------
+ ComponentContext::ComponentContext( const Reference< XComponentContext >& _rxContext )
+ :m_xContext( _rxContext )
+ {
+ if ( m_xContext.is() )
+ m_xORB = m_xContext->getServiceManager();
+ if ( !m_xORB.is() )
+ throw NullPointerException();
+ }
+
+ //------------------------------------------------------------------------
+ Any ComponentContext::getContextValueByName( const ::rtl::OUString& _rName ) const
+ {
+ Any aReturn;
+ try
+ {
+ aReturn = m_xContext->getValueByName( _rName );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "PropertyHandler::getContextValueByName: caught an exception!" );
+ }
+ return aReturn;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XInterface > ComponentContext::createComponent( const ::rtl::OUString& _rServiceName ) const
+ {
+ Reference< XInterface > xComponent(
+ m_xORB->createInstanceWithContext( _rServiceName, m_xContext )
+ );
+ if ( !xComponent.is() )
+ throw ServiceNotRegisteredException( _rServiceName, NULL );
+ return xComponent;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XMultiServiceFactory > ComponentContext::getLegacyServiceFactory() const
+ {
+ return Reference< XMultiServiceFactory >( m_xORB, UNO_QUERY_THROW );
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
diff --git a/extensions/source/propctrlr/pcrcomponentcontext.hxx b/extensions/source/propctrlr/pcrcomponentcontext.hxx
new file mode 100644
index 000000000000..ddec56886137
--- /dev/null
+++ b/extensions/source/propctrlr/pcrcomponentcontext.hxx
@@ -0,0 +1,168 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_PCROMPONENTCONTEXT_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_PCROMPONENTCONTEXT_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+/** === end UNO includes === **/
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= ComponentContext
+ //====================================================================
+ /** a helper class for working with a component context
+ */
+ class ComponentContext
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiComponentFactory > m_xORB;
+
+ public:
+ /** constructs an instance
+ @param _rxContext
+ the component context to manage
+ @throws ::com::sun::star::lang::NullPointerException
+ if the given context, or its component factory, are <NULL/>
+ */
+ ComponentContext( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
+
+ /** returns the ->XComponentContext interface
+ */
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
+ getUNOContext() const { return m_xContext; }
+
+ /** determines whether the context is not <NULL/>
+ */
+ inline sal_Bool is() const
+ {
+ return m_xContext.is();
+ }
+
+ /** creates a component using our component factory/context
+ @throws ::com::sun::star::uno::Exception
+ @return
+ <TRUE/> if and only if the component could be successfully created
+ */
+ template < class INTERFACE >
+ bool createComponent( const ::rtl::OUString& _rServiceName, ::com::sun::star::uno::Reference< INTERFACE >& _out_rxComponent ) const
+ {
+ _out_rxComponent.clear();
+ _out_rxComponent = _out_rxComponent.query(
+ m_xORB->createInstanceWithContext( _rServiceName, m_xContext )
+ );
+ return _out_rxComponent.is();
+ }
+
+ /** creates a component using our component factory/context
+ @throws ::com::sun::star::uno::Exception
+ @return
+ <TRUE/> if and only if the component could be successfully created
+ */
+ template < class INTERFACE >
+ bool createComponent( const sal_Char* _pAsciiServiceName, ::com::sun::star::uno::Reference< INTERFACE >& _out_rxComponent ) const
+ {
+ return createComponent( ::rtl::OUString::createFromAscii( _pAsciiServiceName ), _out_rxComponent );
+ }
+
+ /** creates a component using our component factory/context
+
+ @throws ::com::sun::star::lang::ServiceNotRegisteredException
+ if the given service is not registered
+ @throws Exception
+ if an exception occured during creating the component
+ @return
+ the newly created component. Is never <NULL/>.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createComponent( const ::rtl::OUString& _rServiceName ) const;
+
+ /** creates a component using our component factory/context
+
+ @throws ::com::sun::star::lang::ServiceNotRegisteredException
+ if the given service is not registered
+ @throws Exception
+ if an exception occured during creating the component
+ @return
+ the newly created component. Is never <NULL/>.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createComponent( const sal_Char* _pAsciiServiceName ) const
+ {
+ return createComponent( ::rtl::OUString::createFromAscii( _pAsciiServiceName ) );
+ }
+
+ /** returns the ->XMultiServiceFactory interface of ->m_xORB, for passing to
+ older code which does not yet support ->XMultiComponentFactory
+ @throws ::com::sun::star::uno::RuntimeException
+ if our our component factory does not support this interface
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ getLegacyServiceFactory() const;
+
+ /** retrieves a value from our component context
+ @param _rName
+ the name of the value to retrieve
+ @return
+ the context value with the given name
+ @seealso XComponentContext::getValueByName
+ @seealso getContextValueByAsciiName
+ */
+ ::com::sun::star::uno::Any
+ getContextValueByName( const ::rtl::OUString& _rName ) const;
+
+ /** retrieves a value from our component context, specified by 8-bit ASCII string
+ @param _rName
+ the name of the value to retrieve, as ASCII character string
+ @return
+ the context value with the given name
+ @seealso XComponentContext::getValueByName
+ @seealso getContextValueByName
+ */
+ inline ::com::sun::star::uno::Any
+ getContextValueByAsciiName( const sal_Char* _pAsciiName ) const
+ {
+ return getContextValueByName( ::rtl::OUString::createFromAscii( _pAsciiName ) );
+ }
+
+ /** retrieve context to create interfaces by the ctors
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > getContext() const { return m_xContext;}
+
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_PCROMPONENTCONTEXT_HXX
+
diff --git a/extensions/source/propctrlr/pcrmiscres.src b/extensions/source/propctrlr/pcrmiscres.src
new file mode 100644
index 000000000000..d547b52ed5ea
--- /dev/null
+++ b/extensions/source/propctrlr/pcrmiscres.src
@@ -0,0 +1,189 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_PROPRESID_HRC
+#include "formresid.hrc"
+#endif
+#ifndef _EXTENSIONS_PROPCTRLR_FORMLOCALID_HRC_
+#include "formlocalid.hrc"
+#endif
+
+String RID_STR_CONFIRM_DELETE_DATA_TYPE
+{
+ Text [ en-US ] = "Do you want to delete the data type '#type#' from the model?\n"
+ "Please note that this will affect all controls which are bound to this data type.";
+};
+
+Resource RID_RSC_BUTTON_IMAGES
+{
+ Image IMG_PLUS
+ {
+ ImageBitmap = Bitmap{ file = "buttonplus.png"; };
+ };
+ Image IMG_MINUS
+ {
+ ImageBitmap = Bitmap{ file = "buttonminus.png"; };
+ };
+ Image IMG_PLUS_HC
+ {
+ ImageBitmap = Bitmap{ file = "buttonplus_hc.png"; };
+ };
+ Image IMG_MINUS_HC
+ {
+ ImageBitmap = Bitmap{ file = "buttonminus_hc.png"; };
+ };
+};
+
+#define IMAGE_IDS \
+ IdList = \
+ { \
+ RID_SVXIMG_CONTROL; \
+ RID_SVXIMG_BUTTON; \
+ RID_SVXIMG_RADIOBUTTON; \
+ RID_SVXIMG_CHECKBOX; \
+ RID_SVXIMG_FIXEDTEXT; \
+ RID_SVXIMG_GROUPBOX; \
+ RID_SVXIMG_EDIT; \
+ RID_SVXIMG_LISTBOX; \
+ RID_SVXIMG_COMBOBOX; \
+ RID_SVXIMG_URLBUTTON; \
+ RID_SVXIMG_GRID; \
+ RID_SVXIMG_IMAGEBUTTON; \
+ RID_SVXIMG_FILECONTROL; \
+ RID_SVXIMG_DATEFIELD; \
+ RID_SVXIMG_TIMEFIELD; \
+ RID_SVXIMG_NUMERICFIELD; \
+ RID_SVXIMG_CURRENCYFIELD; \
+ RID_SVXIMG_PATTERNFIELD; \
+ RID_SVXIMG_IMAGECONTROL; \
+ RID_SVXIMG_HIDDEN; \
+ RID_SVXIMG_FORMATTEDFIELD; \
+ RID_SVXIMG_FILTER; \
+ RID_SVXIMG_FORMS; \
+ RID_SVXIMG_FORM; \
+ RID_SVXIMG_COLLAPSEDNODE; \
+ RID_SVXIMG_EXPANDEDNODE; \
+ RID_SVXIMG_SCROLLBAR; \
+ RID_SVXIMG_SPINBUTTON; \
+ RID_SVXIMG_NAVIGATIONBAR; \
+ }; \
+ IdCount = 29
+
+ImageList RID_IL_FORMEXPLORER
+{
+ Prefix = "sx";
+ MaskColor = Color { Red = 0xff00 ; Green = 0x0000 ; Blue = 0xff00 ; };
+ IMAGE_IDS;
+};
+
+ImageList RID_IL_FORMEXPLORER_HC
+{
+ Prefix = "sxh";
+ MaskColor = Color { Red = 0xff00 ; Green = 0x0000 ; Blue = 0xff00 ; };
+ IMAGE_IDS;
+};
+
+String RID_STR_PROPTITLE_PUSHBUTTON
+{
+ Text [ en-US ] = "Button" ;
+};
+String RID_STR_PROPTITLE_RADIOBUTTON
+{
+ Text [ en-US ] = "Option Button" ;
+};
+String RID_STR_PROPTITLE_CHECKBOX
+{
+ Text [ en-US ] = "Check Box" ;
+};
+String RID_STR_PROPTITLE_FIXEDTEXT
+{
+ Text [ en-US ] = "Label Field" ;
+};
+String RID_STR_PROPTITLE_GROUPBOX
+{
+ Text [ en-US ] = "Group Box" ;
+};
+String RID_STR_PROPTITLE_EDIT
+{
+ Text [ en-US ] = "Text Box" ;
+};
+String RID_STR_PROPTITLE_FORMATTED
+{
+ Text [ en-US ] = "Formatted Field";
+};
+String RID_STR_PROPTITLE_LISTBOX
+{
+ Text [ en-US ] = "List Box" ;
+};
+String RID_STR_PROPTITLE_COMBOBOX
+{
+ Text [ en-US ] = "Combo Box" ;
+};
+String RID_STR_PROPTITLE_IMAGEBUTTON
+{
+ Text [ en-US ] = "Image Button" ;
+};
+String RID_STR_PROPTITLE_HIDDENCONTROL
+{
+ Text [ en-US ] = "Hidden Control" ;
+};
+String RID_STR_PROPTITLE_UNKNOWNCONTROL
+{
+ Text [ en-US ] = "Control (unknown type)" ;
+};
+String RID_STR_PROPTITLE_IMAGECONTROL
+{
+ Text [ en-US ] = "Image Control" ;
+};
+String RID_STR_PROPTITLE_FILECONTROL
+{
+ Text [ en-US ] = "File Selection" ;
+};
+String RID_STR_PROPTITLE_DATEFIELD
+{
+ Text [ en-US ] = "Date Field" ;
+};
+String RID_STR_PROPTITLE_TIMEFIELD
+{
+ Text [ en-US ] = "Time Field" ;
+};
+String RID_STR_PROPTITLE_NUMERICFIELD
+{
+ Text [ en-US ] = "Numeric Field" ;
+};
+String RID_STR_PROPTITLE_CURRENCYFIELD
+{
+ Text [ en-US ] = "Currency Field" ;
+};
+String RID_STR_PROPTITLE_PATTERNFIELD
+{
+ Text [ en-US ] = "Pattern Field" ;
+};
+String RID_STR_PROPTITLE_DBGRID
+{
+ Text [ en-US ] = "Table Control " ;
+};
diff --git a/extensions/source/propctrlr/pcrservices.cxx b/extensions/source/propctrlr/pcrservices.cxx
new file mode 100644
index 000000000000..e515a87c1b16
--- /dev/null
+++ b/extensions/source/propctrlr/pcrservices.cxx
@@ -0,0 +1,124 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
+#include "modulepcr.hxx"
+#endif
+
+//---------------------------------------------------------------------------------------
+
+using namespace ::rtl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+
+//---------------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL createRegistryInfo_OPropertyBrowserController();
+extern "C" void SAL_CALL createRegistryInfo_FormController();
+extern "C" void SAL_CALL createRegistryInfo_DefaultFormComponentInspectorModel();
+extern "C" void SAL_CALL createRegistryInfo_DefaultHelpProvider();
+extern "C" void SAL_CALL createRegistryInfo_OControlFontDialog();
+extern "C" void SAL_CALL createRegistryInfo_OTabOrderDialog();
+extern "C" void SAL_CALL createRegistryInfo_CellBindingPropertyHandler();
+extern "C" void SAL_CALL createRegistryInfo_ButtonNavigationHandler();
+extern "C" void SAL_CALL createRegistryInfo_EditPropertyHandler();
+extern "C" void SAL_CALL createRegistryInfo_FormComponentPropertyHandler();
+extern "C" void SAL_CALL createRegistryInfo_EFormsPropertyHandler();
+extern "C" void SAL_CALL createRegistryInfo_XSDValidationPropertyHandler();
+extern "C" void SAL_CALL createRegistryInfo_EventHandler();
+extern "C" void SAL_CALL createRegistryInfo_GenericPropertyHandler();
+extern "C" void SAL_CALL createRegistryInfo_ObjectInspectorModel();
+extern "C" void SAL_CALL createRegistryInfo_SubmissionPropertyHandler();
+extern "C" void SAL_CALL createRegistryInfo_StringRepresentation();
+extern "C" void SAL_CALL createRegistryInfo_MasterDetailLinkDialog();
+extern "C" void SAL_CALL createRegistryInfo_FormGeometryHandler();
+
+//---------------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL pcr_initializeModule()
+{
+ static sal_Bool s_bInit = sal_False;
+ if (!s_bInit)
+ {
+ createRegistryInfo_OPropertyBrowserController();
+ createRegistryInfo_FormController();
+ createRegistryInfo_DefaultFormComponentInspectorModel();
+ createRegistryInfo_DefaultHelpProvider();
+ createRegistryInfo_OControlFontDialog();
+ createRegistryInfo_OTabOrderDialog();
+ createRegistryInfo_CellBindingPropertyHandler();
+ createRegistryInfo_ButtonNavigationHandler();
+ createRegistryInfo_EditPropertyHandler();
+ createRegistryInfo_FormComponentPropertyHandler();
+ createRegistryInfo_EFormsPropertyHandler();
+ createRegistryInfo_XSDValidationPropertyHandler();
+ createRegistryInfo_EventHandler();
+ createRegistryInfo_GenericPropertyHandler();
+ createRegistryInfo_ObjectInspectorModel();
+ createRegistryInfo_SubmissionPropertyHandler();
+ createRegistryInfo_StringRepresentation();
+ createRegistryInfo_MasterDetailLinkDialog();
+ createRegistryInfo_FormGeometryHandler();
+ s_bInit = sal_True;
+ }
+}
+
+//---------------------------------------------------------------------------------------
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment ** /*ppEnv*/
+ )
+{
+ pcr_initializeModule();
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ Reference< XInterface > xRet;
+ if (pServiceManager && pImplementationName)
+ {
+ xRet = ::pcr::PcrModule::getInstance().getComponentFactory(
+ ::rtl::OUString::createFromAscii(pImplementationName),
+ static_cast< XMultiServiceFactory* >(pServiceManager));
+ }
+
+ if (xRet.is())
+ xRet->acquire();
+ return xRet.get();
+};
+
diff --git a/extensions/source/propctrlr/pcrstrings.cxx b/extensions/source/propctrlr/pcrstrings.cxx
new file mode 100644
index 000000000000..ff7a1138e4fc
--- /dev/null
+++ b/extensions/source/propctrlr/pcrstrings.cxx
@@ -0,0 +1,36 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#ifndef _EXTENSIONS_FORMSCTRLR_PCRSTRINGS_HXX_
+#define PCR_IMPLEMENT_STRINGS
+#include "pcrstrings.hxx"
+#undef PCR_IMPLEMENT_STRINGS
+#endif
+
diff --git a/extensions/source/propctrlr/pcrstrings.hxx b/extensions/source/propctrlr/pcrstrings.hxx
new file mode 100644
index 000000000000..e2a81c9920ca
--- /dev/null
+++ b/extensions/source/propctrlr/pcrstrings.hxx
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_FORMSCTRLR_PCRSTRINGS_HXX_
+#define _EXTENSIONS_FORMSCTRLR_PCRSTRINGS_HXX_
+
+#include "stringdefine.hxx"
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ // properties
+ PCR_CONSTASCII_STRING( PROPERTY_TABBINGMODEL, "TabbingModel" );
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_FORMSCTRLR_PCRSTRINGS_HXX_
+
diff --git a/extensions/source/propctrlr/pcrunodialogs.cxx b/extensions/source/propctrlr/pcrunodialogs.cxx
new file mode 100644
index 000000000000..e870510c7cc2
--- /dev/null
+++ b/extensions/source/propctrlr/pcrunodialogs.cxx
@@ -0,0 +1,146 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "pcrunodialogs.hxx"
+#include "formstrings.hxx"
+#include "pcrstrings.hxx"
+#include "taborder.hxx"
+#include "pcrcommon.hxx"
+
+extern "C" void SAL_CALL createRegistryInfo_OTabOrderDialog()
+{
+ ::pcr::OAutoRegistration< ::pcr::OTabOrderDialog > aAutoRegistration;
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+
+ //====================================================================
+ //= OTabOrderDialog
+ //====================================================================
+ //---------------------------------------------------------------------
+ OTabOrderDialog::OTabOrderDialog( const Reference< XComponentContext >& _rxContext )
+ :OGenericUnoDialog( _rxContext )
+ {
+ registerProperty( PROPERTY_CONTROLCONTEXT, OWN_PROPERTY_ID_CONTROLCONTEXT,
+ PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT,
+ &m_xControlContext, ::getCppuType( &m_xControlContext ) );
+
+ registerProperty( PROPERTY_TABBINGMODEL, OWN_PROPERTY_ID_TABBINGMODEL,
+ PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT,
+ &m_xTabbingModel, ::getCppuType( &m_xTabbingModel ) );
+ }
+
+ //---------------------------------------------------------------------
+ OTabOrderDialog::~OTabOrderDialog()
+ {
+ if ( m_pDialog )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_pDialog )
+ destroyDialog();
+ }
+ }
+
+ //---------------------------------------------------------------------
+ Sequence<sal_Int8> SAL_CALL OTabOrderDialog::getImplementationId( ) throw(RuntimeException)
+ {
+ static ::cppu::OImplementationId aId;
+ return aId.getImplementationId();
+ }
+
+ //---------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL OTabOrderDialog::Create( const Reference< XComponentContext >& _rxContext )
+ {
+ return *( new OTabOrderDialog( _rxContext ) );
+ }
+
+ //---------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL OTabOrderDialog::getImplementationName() throw(RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //---------------------------------------------------------------------
+ ::rtl::OUString OTabOrderDialog::getImplementationName_static() throw(RuntimeException)
+ {
+ return ::rtl::OUString::createFromAscii( "org.openoffice.comp.form.ui.OTabOrderDialog" );
+ }
+
+ //---------------------------------------------------------------------
+ ::comphelper::StringSequence SAL_CALL OTabOrderDialog::getSupportedServiceNames() throw(RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //---------------------------------------------------------------------
+ ::comphelper::StringSequence OTabOrderDialog::getSupportedServiceNames_static() throw(RuntimeException)
+ {
+ ::comphelper::StringSequence aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.ui.TabOrderDialog" ) );
+ return aSupported;
+ }
+
+ //---------------------------------------------------------------------
+ Reference<XPropertySetInfo> SAL_CALL OTabOrderDialog::getPropertySetInfo() throw(RuntimeException)
+ {
+ Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+ }
+
+ //---------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper& OTabOrderDialog::getInfoHelper()
+ {
+ return *const_cast< OTabOrderDialog* >( this )->getArrayHelper();
+ }
+
+ //--------------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper* OTabOrderDialog::createArrayHelper( ) const
+ {
+ Sequence< Property > aProps;
+ describeProperties( aProps );
+ return new ::cppu::OPropertyArrayHelper( aProps );
+ }
+
+ //--------------------------------------------------------------------------
+ Dialog* OTabOrderDialog::createDialog( Window* _pParent )
+ {
+ return new TabOrderDialog( _pParent, m_xTabbingModel, m_xControlContext, m_aContext.getLegacyServiceFactory() );
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
diff --git a/extensions/source/propctrlr/pcrunodialogs.hxx b/extensions/source/propctrlr/pcrunodialogs.hxx
new file mode 100644
index 000000000000..929b52a5dd67
--- /dev/null
+++ b/extensions/source/propctrlr/pcrunodialogs.hxx
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_PCRUNODIALOGS_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_PCRUNODIALOGS_HXX
+
+#include <svtools/genericunodialog.hxx>
+#include "modulepcr.hxx"
+#include <com/sun/star/awt/XTabControllerModel.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= OTabOrderDialog
+ //====================================================================
+ class OTabOrderDialog;
+ typedef ::svt::OGenericUnoDialog OTabOrderDialog_DBase;
+ typedef ::comphelper::OPropertyArrayUsageHelper< OTabOrderDialog > OTabOrderDialog_PBase;
+
+ class OTabOrderDialog
+ :public OTabOrderDialog_DBase
+ ,public OTabOrderDialog_PBase
+ ,public PcrClient
+ {
+ protected:
+ // <properties>
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel >
+ m_xTabbingModel;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >
+ m_xControlContext;
+ // </properties>
+
+ public:
+ OTabOrderDialog( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& _rxContext );
+ ~OTabOrderDialog();
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo - static methods
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::rtl::OUString getImplementationName_static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >&);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ protected:
+ // OGenericUnoDialog overridables
+ virtual Dialog* createDialog(Window* _pParent);
+ };
+
+//........................................................................
+} // namespacepcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_PCRUNODIALOGS_HXX
+
diff --git a/extensions/source/propctrlr/propcontroller.cxx b/extensions/source/propctrlr/propcontroller.cxx
new file mode 100644
index 000000000000..814b7475fbae
--- /dev/null
+++ b/extensions/source/propctrlr/propcontroller.cxx
@@ -0,0 +1,1778 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "propcontroller.hxx"
+#include "pcrstrings.hxx"
+#include "standardcontrol.hxx"
+#include "linedescriptor.hxx"
+#ifndef EXTENSIONS_PROPRESID_HRC
+#include "propresid.hrc"
+#endif
+#ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
+#include "formresid.hrc"
+#endif
+#include "propertyeditor.hxx"
+#ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
+#include "modulepcr.hxx"
+#endif
+#include "formstrings.hxx"
+#include "formmetadata.hxx"
+#include "formbrowsertools.hxx"
+#include "propertycomposer.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/inspection/PropertyControlType.hpp>
+#include <com/sun/star/ucb/AlreadyInitializedException.hpp>
+/** === end UNO includes === **/
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <comphelper/types.hxx>
+#include <comphelper/extract.hxx>
+#include <toolkit/awt/vclxwindow.hxx>
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/unohlp.hxx>
+#endif
+#include <comphelper/property.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+#include <vos/mutex.hxx>
+#include <cppuhelper/component_context.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+
+#include <algorithm>
+#include <functional>
+
+//------------------------------------------------------------------------
+// !!! outside the namespace !!!
+extern "C" void SAL_CALL createRegistryInfo_OPropertyBrowserController()
+{
+ ::pcr::OAutoRegistration< ::pcr::OPropertyBrowserController > aAutoRegistration;
+}
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::awt;
+ using namespace ::com::sun::star::form;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::script;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::inspection;
+ using namespace ::com::sun::star::ucb;
+ using namespace ::comphelper;
+
+#define THISREF() static_cast< XController* >(this)
+
+ //========================================================================
+ //= OPropertyBrowserController
+ //========================================================================
+ DBG_NAME(OPropertyBrowserController)
+ //------------------------------------------------------------------------
+ OPropertyBrowserController::OPropertyBrowserController( const Reference< XComponentContext >& _rxContext )
+ :m_aContext(_rxContext)
+ ,m_aDisposeListeners( m_aMutex )
+ ,m_aControlObservers( m_aMutex )
+ ,m_pView(NULL)
+ ,m_bContainerFocusListening( false )
+ ,m_bSuspendingPropertyHandlers( false )
+ ,m_bConstructed( false )
+ ,m_bBindingIntrospectee( false )
+ {
+ DBG_CTOR(OPropertyBrowserController,NULL);
+ }
+
+ //------------------------------------------------------------------------
+ OPropertyBrowserController::~OPropertyBrowserController()
+ {
+ // stop listening for property changes
+ acquire();
+ stopInspection( true );
+ DBG_DTOR(OPropertyBrowserController,NULL);
+ }
+
+ //------------------------------------------------------------------------
+ IMPLEMENT_FORWARD_REFCOUNT( OPropertyBrowserController, OPropertyBrowserController_Base )
+
+ //------------------------------------------------------------------------
+ Any SAL_CALL OPropertyBrowserController::queryInterface( const Type& _rType ) throw (RuntimeException)
+ {
+ Any aReturn = OPropertyBrowserController_Base::queryInterface( _rType );
+ if ( !aReturn.hasValue() )
+ aReturn = ::cppu::queryInterface(
+ _rType,
+ static_cast< XObjectInspectorUI* >( this )
+ );
+ return aReturn;
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::startContainerWindowListening()
+ {
+ if (m_bContainerFocusListening)
+ return;
+
+ if (m_xFrame.is())
+ {
+ Reference< XWindow > xContainerWindow = m_xFrame->getContainerWindow();
+ if (xContainerWindow.is())
+ {
+ xContainerWindow->addFocusListener(this);
+ m_bContainerFocusListening = sal_True;
+ }
+ }
+
+ DBG_ASSERT(m_bContainerFocusListening, "OPropertyBrowserController::startContainerWindowListening: unable to start listening (inconsistence)!");
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::stopContainerWindowListening()
+ {
+ if (!m_bContainerFocusListening)
+ return;
+
+ if (m_xFrame.is())
+ {
+ Reference< XWindow > xContainerWindow = m_xFrame->getContainerWindow();
+ if (xContainerWindow.is())
+ {
+ xContainerWindow->removeFocusListener(this);
+ m_bContainerFocusListening = sal_False;
+ }
+ }
+
+ DBG_ASSERT(!m_bContainerFocusListening, "OPropertyBrowserController::stopContainerWindowListening: unable to stop listening (inconsistence)!");
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XObjectInspectorModel > SAL_CALL OPropertyBrowserController::getInspectorModel() throw (RuntimeException)
+ {
+ return m_xModel;
+ }
+
+ //--------------------------------------------------------------------
+ void OPropertyBrowserController::impl_initializeView_nothrow()
+ {
+ OSL_PRECOND( haveView(), "OPropertyBrowserController::impl_initializeView_nothrow: not to be called when we have no view!" );
+ if ( !haveView() )
+ return;
+
+ if ( !m_xModel.is() )
+ // allowed
+ return;
+
+ try
+ {
+ getPropertyBox().EnableHelpSection( m_xModel->getHasHelpSection() );
+ getPropertyBox().SetHelpLineLimites( m_xModel->getMinHelpTextLines(), m_xModel->getMaxHelpTextLines() );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void OPropertyBrowserController::impl_updateReadOnlyView_nothrow()
+ {
+ // this is a huge cudgel, admitted.
+ // The problem is that in case we were previously read-only, all our controls
+ // were created read-only, too. We cannot simply switch them to not-read-only.
+ // Even if they had an API for this, we do not know whether they were
+ // originally created read-only, or if they are read-only just because
+ // the model was.
+ impl_rebindToInspectee_nothrow( m_aInspectedObjects );
+ }
+
+ //--------------------------------------------------------------------
+ bool OPropertyBrowserController::impl_isReadOnlyModel_throw() const
+ {
+ if ( !m_xModel.is() )
+ return false;
+
+ return m_xModel->getIsReadOnly();
+ }
+
+ //--------------------------------------------------------------------
+ void OPropertyBrowserController::impl_startOrStopModelListening_nothrow( bool _bDoListen ) const
+ {
+ try
+ {
+ Reference< XPropertySet > xModelProperties( m_xModel, UNO_QUERY );
+ if ( !xModelProperties.is() )
+ // okay, so the model doesn't want to change its properties
+ // dynamically - fine with us
+ return;
+
+ void (SAL_CALL XPropertySet::*pListenerOperation)( const ::rtl::OUString&, const Reference< XPropertyChangeListener >& )
+ = _bDoListen ? &XPropertySet::addPropertyChangeListener : &XPropertySet::removePropertyChangeListener;
+
+ (xModelProperties.get()->*pListenerOperation)(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsReadOnly" ) ),
+ const_cast< OPropertyBrowserController* >( this )
+ );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void OPropertyBrowserController::impl_bindToNewModel_nothrow( const Reference< XObjectInspectorModel >& _rxInspectorModel )
+ {
+ impl_startOrStopModelListening_nothrow( false );
+ m_xModel = _rxInspectorModel;
+ impl_startOrStopModelListening_nothrow( true );
+
+ // initialize the view, if we already have one
+ if ( haveView() )
+ impl_initializeView_nothrow();
+
+ // inspect again, if we already have inspectees
+ if ( !m_aInspectedObjects.empty() )
+ impl_rebindToInspectee_nothrow( m_aInspectedObjects );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::setInspectorModel( const Reference< XObjectInspectorModel >& _inspectorModel ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_xModel == _inspectorModel )
+ return;
+
+ impl_bindToNewModel_nothrow( _inspectorModel );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XObjectInspectorUI > SAL_CALL OPropertyBrowserController::getInspectorUI() throw (RuntimeException)
+ {
+ // we're derived from this interface, though we do not expose it in queryInterface and getTypes.
+ return this;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::inspect( const Sequence< Reference< XInterface > >& _rObjects ) throw (com::sun::star::util::VetoException, RuntimeException)
+ {
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bSuspendingPropertyHandlers || !suspendAll_nothrow() )
+ { // we already are trying to suspend the component (this is somewhere up the stack)
+ // OR one of our property handlers raised a veto against closing. Well, we *need* to close
+ // it in order to inspect another object.
+ throw VetoException();
+ }
+ if ( m_bBindingIntrospectee )
+ throw VetoException();
+
+ m_bBindingIntrospectee = true;
+ impl_rebindToInspectee_nothrow( InterfaceArray( _rObjects.getConstArray(), _rObjects.getConstArray() + _rObjects.getLength() ) );
+ m_bBindingIntrospectee = false;
+
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XDispatch > SAL_CALL OPropertyBrowserController::queryDispatch( const URL& /*URL*/, const ::rtl::OUString& /*TargetFrameName*/, ::sal_Int32 /*SearchFlags*/ ) throw (RuntimeException)
+ {
+ // we don't have any dispatches at all, right now
+ return Reference< XDispatch >();
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Reference< XDispatch > > SAL_CALL OPropertyBrowserController::queryDispatches( const Sequence< DispatchDescriptor >& Requests ) throw (RuntimeException)
+ {
+ Sequence< Reference< XDispatch > > aReturn;
+ sal_Int32 nLen = Requests.getLength();
+ aReturn.realloc( nLen );
+
+ Reference< XDispatch >* pReturn = aReturn.getArray();
+ const Reference< XDispatch >* pReturnEnd = aReturn.getArray() + nLen;
+ const DispatchDescriptor* pDescripts = Requests.getConstArray();
+
+ for ( ; pReturn != pReturnEnd; ++ pReturn, ++pDescripts )
+ *pReturn = queryDispatch( pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags );
+
+ return aReturn;
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::initialize( const Sequence< Any >& _arguments ) throw (Exception, RuntimeException)
+ {
+ if ( m_bConstructed )
+ throw AlreadyInitializedException();
+
+ StlSyntaxSequence< Any > arguments( _arguments );
+ if ( arguments.empty() )
+ { // constructor: "createDefault()"
+ createDefault();
+ return;
+ }
+
+ Reference< XObjectInspectorModel > xModel;
+ if ( arguments.size() == 1 )
+ { // constructor: "createWithModel( XObjectInspectorModel )"
+ if ( !( arguments[0] >>= xModel ) )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
+ createWithModel( xModel );
+ return;
+ }
+
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::createDefault()
+ {
+ m_bConstructed = true;
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::createWithModel( const Reference< XObjectInspectorModel >& _rxModel )
+ {
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ setInspectorModel( _rxModel );
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+
+ m_bConstructed = true;
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::attachFrame( const Reference< XFrame >& _rxFrame ) throw(RuntimeException)
+ {
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if (_rxFrame.is() && haveView())
+ throw RuntimeException(::rtl::OUString::createFromAscii("Unable to attach to a second frame."),*this);
+
+ // revoke as focus listener from the old container window
+ stopContainerWindowListening();
+
+ m_xFrame = _rxFrame;
+ if (!m_xFrame.is())
+ return;
+
+ // TODO: this construction perhaps should be done outside. Don't know the exact meaning of attachFrame.
+ // Maybe it is intended to only announce the frame to the controller, and the instance doing this
+ // announcement is responsible for calling setComponent, too.
+ Reference< XWindow > xContainerWindow = m_xFrame->getContainerWindow();
+ VCLXWindow* pContainerWindow = VCLXWindow::GetImplementation(xContainerWindow);
+ Window* pParentWin = pContainerWindow ? pContainerWindow->GetWindow() : NULL;
+ if (!pParentWin)
+ throw RuntimeException(::rtl::OUString::createFromAscii("The frame is invalid. Unable to extract the container window."),*this);
+
+ if ( Construct( pParentWin ) )
+ {
+ try
+ {
+ m_xFrame->setComponent( VCLUnoHelper::GetInterface( m_pView ), this );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "OPropertyBrowserController::attachFrame: caught an exception!" );
+ }
+ }
+
+ startContainerWindowListening();
+
+ UpdateUI();
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool SAL_CALL OPropertyBrowserController::attachModel( const Reference< XModel >& _rxModel ) throw(RuntimeException)
+ {
+ Reference< XObjectInspectorModel > xModel( _rxModel, UNO_QUERY );
+ if ( !xModel.is() )
+ return false;
+
+ setInspectorModel( xModel );
+ return getInspectorModel() == _rxModel;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool OPropertyBrowserController::suspendAll_nothrow()
+ {
+ // if there is a handle inside its "onInteractivePropertySelection" method,
+ // then veto
+ // Normally, we could expect every handler to do this itself, but being
+ // realistic, it's safer to handle this here in general.
+ if ( m_xInteractiveHandler.is() )
+ return sal_False;
+
+ m_bSuspendingPropertyHandlers = true;
+ sal_Bool bHandlerVeto = !suspendPropertyHandlers_nothrow( sal_True );
+ m_bSuspendingPropertyHandlers = false;
+ if ( bHandlerVeto )
+ return sal_False;
+
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool OPropertyBrowserController::suspendPropertyHandlers_nothrow( sal_Bool _bSuspend )
+ {
+ PropertyHandlerArray aAllHandlers; // will contain every handler exactly once
+ for ( PropertyHandlerRepository::const_iterator handler = m_aPropertyHandlers.begin();
+ handler != m_aPropertyHandlers.end();
+ ++handler
+ )
+ {
+ if ( ::std::find( aAllHandlers.begin(), aAllHandlers.end(), handler->second ) != aAllHandlers.end() )
+ // already visited this particular handler (m_aPropertyHandlers usually contains
+ // the same handler more than once)
+ continue;
+ aAllHandlers.push_back( handler->second );
+ }
+
+ for ( PropertyHandlerArray::iterator loop = aAllHandlers.begin();
+ loop != aAllHandlers.end();
+ ++loop
+ )
+ {
+ try
+ {
+ if ( !(*loop)->suspend( _bSuspend ) )
+ if ( _bSuspend )
+ // if we're not suspending, but reactivating, ignore the error
+ return sal_False;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "OPropertyBrowserController::suspendPropertyHandlers_nothrow: caught an exception!" );
+ }
+ }
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool SAL_CALL OPropertyBrowserController::suspend( sal_Bool _bSuspend ) throw(RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ OSL_ENSURE( haveView(), "OPropertyBrowserController::suspend: don't have a view anymore!" );
+
+ if ( !_bSuspend )
+ { // this means a "suspend" is to be "revoked"
+ suspendPropertyHandlers_nothrow( sal_False );
+ // we ourself cannot revoke our suspend
+ return sal_False;
+ }
+
+ if ( !suspendAll_nothrow() )
+ return sal_False;
+
+ // commit the editor's content
+ if ( haveView() )
+ getPropertyBox().CommitModified();
+
+ // stop listening
+ stopContainerWindowListening();
+
+ // outtahere
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------------
+ Any SAL_CALL OPropertyBrowserController::getViewData( ) throw(RuntimeException)
+ {
+ return makeAny( m_sPageSelection );
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::restoreViewData( const Any& Data ) throw(RuntimeException)
+ {
+ ::rtl::OUString sPageSelection;
+ if ( ( Data >>= sPageSelection ) && sPageSelection.getLength() )
+ {
+ m_sPageSelection = sPageSelection;
+ selectPageFromViewData();
+ }
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XModel > SAL_CALL OPropertyBrowserController::getModel( ) throw(RuntimeException)
+ {
+ // have no model
+ return Reference< XModel >();
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XFrame > SAL_CALL OPropertyBrowserController::getFrame( ) throw(RuntimeException)
+ {
+ return m_xFrame;
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::dispose( ) throw(RuntimeException)
+ {
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+
+ // stop inspecting the current object
+ stopInspection( false );
+
+ // say our dispose listeners goodbye
+ ::com::sun::star::lang::EventObject aEvt;
+ aEvt.Source = static_cast< ::cppu::OWeakObject* >(this);
+ m_aDisposeListeners.disposeAndClear(aEvt);
+ m_aControlObservers.disposeAndClear(aEvt);
+
+ // don't delete explicitly (this is done by the frame we reside in)
+ m_pView = NULL;
+
+ Reference< XComponent > xViewAsComp( m_xView, UNO_QUERY );
+ if ( xViewAsComp.is() )
+ xViewAsComp->removeEventListener( static_cast< XPropertyChangeListener* >( this ) );
+ m_xView.clear( );
+
+ m_aInspectedObjects.clear();
+ impl_bindToNewModel_nothrow( NULL );
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::addEventListener( const Reference< XEventListener >& _rxListener ) throw(RuntimeException)
+ {
+ m_aDisposeListeners.addInterface(_rxListener);
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::removeEventListener( const Reference< XEventListener >& _rxListener ) throw(RuntimeException)
+ {
+ m_aDisposeListeners.removeInterface(_rxListener);
+ }
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL OPropertyBrowserController::getImplementationName( ) throw(RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool SAL_CALL OPropertyBrowserController::supportsService( const ::rtl::OUString& ServiceName ) throw(RuntimeException)
+ {
+ Sequence< ::rtl::OUString > 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;
+ }
+
+ //------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL OPropertyBrowserController::getSupportedServiceNames( ) throw(RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString OPropertyBrowserController::getImplementationName_static( ) throw(RuntimeException)
+ {
+ return ::rtl::OUString::createFromAscii("org.openoffice.comp.extensions.ObjectInspector");
+ }
+
+ //------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > OPropertyBrowserController::getSupportedServiceNames_static( ) throw(RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported(1);
+ aSupported[0] = ::rtl::OUString::createFromAscii( "com.sun.star.inspection.ObjectInspector" );
+ return aSupported;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL OPropertyBrowserController::Create(const Reference< XComponentContext >& _rxContext)
+ {
+ return *(new OPropertyBrowserController( _rxContext ) );
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::focusGained( const FocusEvent& _rSource ) throw (RuntimeException)
+ {
+ Reference< XWindow > xSourceWindow(_rSource.Source, UNO_QUERY);
+ Reference< XWindow > xContainerWindow;
+ if (m_xFrame.is())
+ xContainerWindow = m_xFrame->getContainerWindow();
+
+ if ( xContainerWindow.get() == xSourceWindow.get() )
+ { // our container window got the focus
+ if ( haveView() )
+ getPropertyBox().GrabFocus();
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::focusLost( const FocusEvent& /*_rSource*/ ) throw (RuntimeException)
+ {
+ // not interested in
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::disposing( const EventObject& _rSource ) throw(RuntimeException)
+ {
+ if ( m_xView.is() && ( m_xView == _rSource.Source ) )
+ {
+ m_xView = NULL;
+ m_pView = NULL;
+ }
+
+ for ( InterfaceArray::iterator loop = m_aInspectedObjects.begin();
+ loop != m_aInspectedObjects.end();
+ ++loop
+ )
+ {
+ if ( *loop == _rSource.Source )
+ {
+ m_aInspectedObjects.erase( loop );
+ break;
+ }
+ }
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK(OPropertyBrowserController, OnPageActivation, void*, EMPTYARG)
+ {
+ updateViewDataFromActivePage();
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::updateViewDataFromActivePage()
+ {
+ if (!haveView())
+ return;
+
+ ::rtl::OUString sOldSelection = m_sPageSelection;
+ m_sPageSelection = ::rtl::OUString();
+
+ const sal_uInt16 nCurrentPage = m_pView->getActivaPage();
+ if ( (sal_uInt16)-1 != nCurrentPage )
+ {
+ for ( HashString2Int16::const_iterator pageId = m_aPageIds.begin();
+ pageId != m_aPageIds.end();
+ ++pageId
+ )
+ {
+ if ( nCurrentPage == pageId->second )
+ {
+ m_sPageSelection = pageId->first;
+ break;
+ }
+ }
+ }
+
+ if ( m_sPageSelection.getLength() )
+ m_sLastValidPageSelection = m_sPageSelection;
+ else if ( sOldSelection.getLength() )
+ m_sLastValidPageSelection = sOldSelection;
+ }
+
+ //------------------------------------------------------------------------
+ sal_uInt16 OPropertyBrowserController::impl_getPageIdForCategory_nothrow( const ::rtl::OUString& _rCategoryName ) const
+ {
+ sal_uInt16 nPageId = (sal_uInt16)-1;
+ HashString2Int16::const_iterator pagePos = m_aPageIds.find( _rCategoryName );
+ if ( pagePos != m_aPageIds.end() )
+ nPageId = pagePos->second;
+ return nPageId;
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::selectPageFromViewData()
+ {
+ sal_uInt16 nNewPage = impl_getPageIdForCategory_nothrow( m_sPageSelection );
+
+ if ( haveView() && ( nNewPage != (sal_uInt16)-1 ) )
+ m_pView->activatePage( nNewPage );
+
+ // just in case ...
+ updateViewDataFromActivePage();
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool OPropertyBrowserController::Construct(Window* _pParentWin)
+ {
+ DBG_ASSERT(!haveView(), "OPropertyBrowserController::Construct: already have a view!");
+ DBG_ASSERT(_pParentWin, "OPropertyBrowserController::Construct: invalid parent window!");
+
+ m_pView = new OPropertyBrowserView(m_aContext.getLegacyServiceFactory(), _pParentWin);
+ m_pView->setPageActivationHandler(LINK(this, OPropertyBrowserController, OnPageActivation));
+
+ // add as dispose listener for our view. The view is disposed by the frame we're plugged into,
+ // and this disposal _deletes_ the view, so it would be deadly if we use our m_pView member
+ // after that
+ m_xView = VCLUnoHelper::GetInterface(m_pView);
+ Reference< XComponent > xViewAsComp(m_xView, UNO_QUERY);
+ if (xViewAsComp.is())
+ xViewAsComp->addEventListener( static_cast< XPropertyChangeListener* >( this ) );
+
+ getPropertyBox().SetLineListener(this);
+ getPropertyBox().SetControlObserver(this);
+ impl_initializeView_nothrow();
+
+ m_pView->Show();
+
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::propertyChange( const PropertyChangeEvent& _rEvent ) throw (RuntimeException)
+ {
+ if ( _rEvent.Source == m_xModel )
+ {
+ if ( _rEvent.PropertyName.equalsAscii( "IsReadOnly" ) )
+ impl_updateReadOnlyView_nothrow();
+ return;
+ }
+
+ if ( m_sCommittingProperty == _rEvent.PropertyName )
+ return;
+
+ if ( !haveView() )
+ return;
+
+ Any aNewValue( _rEvent.NewValue );
+ if ( impl_hasPropertyHandlerFor_nothrow( _rEvent.PropertyName ) )
+ {
+ // forward the new value to the property box, to reflect the change in the UI
+ aNewValue = impl_getPropertyValue_throw( _rEvent.PropertyName );
+
+ // check whether the state is ambiguous. This is interesting in case we display the properties
+ // for multiple objects at once: In this case, we'll get a notification from one of the objects,
+ // but need to care for the "composed" value, which can be "ambiguous".
+ PropertyHandlerRef xHandler( impl_getHandlerForProperty_throw( _rEvent.PropertyName ), UNO_SET_THROW );
+ PropertyState ePropertyState( xHandler->getPropertyState( _rEvent.PropertyName ) );
+ bool bAmbiguousValue = ( PropertyState_AMBIGUOUS_VALUE == ePropertyState );
+
+ getPropertyBox().SetPropertyValue( _rEvent.PropertyName, aNewValue, bAmbiguousValue );
+ }
+
+ // if it's a actuating property, then update the UI for any dependent
+ // properties
+ if ( impl_isActuatingProperty_nothrow( _rEvent.PropertyName ) )
+ impl_broadcastPropertyChange_nothrow( _rEvent.PropertyName, aNewValue, _rEvent.OldValue, false );
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XPropertyControl > SAL_CALL OPropertyBrowserController::createPropertyControl( ::sal_Int16 ControlType, ::sal_Bool _CreateReadOnly ) throw (IllegalArgumentException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Reference< XPropertyControl > xControl;
+
+ // default winbits: a border only
+ WinBits nWinBits = WB_BORDER;
+
+ // read-only-ness
+ _CreateReadOnly |= (sal_Bool)impl_isReadOnlyModel_throw();
+ if ( _CreateReadOnly )
+ nWinBits |= WB_READONLY;
+
+ switch ( ControlType )
+ {
+ case PropertyControlType::StringListField:
+ xControl = new OMultilineEditControl( &getPropertyBox(), eStringList, nWinBits | WB_DROPDOWN | WB_TABSTOP );
+ break;
+
+ case PropertyControlType::MultiLineTextField:
+ xControl = new OMultilineEditControl( &getPropertyBox(), eMultiLineText, nWinBits | WB_DROPDOWN | WB_TABSTOP );
+ break;
+
+ case PropertyControlType::ListBox:
+ xControl = new OListboxControl( &getPropertyBox(), nWinBits | WB_TABSTOP | WB_DROPDOWN);
+ break;
+
+ case PropertyControlType::ComboBox:
+ xControl = new OComboboxControl( &getPropertyBox(), nWinBits | WB_TABSTOP | WB_DROPDOWN);
+ break;
+
+ case PropertyControlType::TextField:
+ xControl = new OEditControl( &getPropertyBox(), sal_False, nWinBits | WB_TABSTOP );
+ break;
+
+ case PropertyControlType::CharacterField:
+ xControl = new OEditControl( &getPropertyBox(), sal_True, nWinBits | WB_TABSTOP );
+ break;
+
+ case PropertyControlType::NumericField:
+ xControl = new ONumericControl( &getPropertyBox(), nWinBits | WB_TABSTOP | WB_SPIN | WB_REPEAT );
+ break;
+
+ case PropertyControlType::DateTimeField:
+ xControl = new ODateTimeControl( &getPropertyBox(), nWinBits | WB_TABSTOP );
+ break;
+
+ case PropertyControlType::DateField:
+ xControl = new ODateControl( &getPropertyBox(), nWinBits | WB_TABSTOP | WB_SPIN | WB_REPEAT );
+ break;
+
+ case PropertyControlType::TimeField:
+ xControl = new OTimeControl( &getPropertyBox(), nWinBits | WB_TABSTOP | WB_SPIN | WB_REPEAT );
+ break;
+
+ case PropertyControlType::ColorListBox:
+ xControl = new OColorControl( &getPropertyBox(), nWinBits | WB_TABSTOP | WB_DROPDOWN );
+ break;
+
+ case PropertyControlType::HyperlinkField:
+ xControl = new OHyperlinkControl( &getPropertyBox(), nWinBits | WB_TABSTOP | WB_DROPDOWN );
+ break;
+
+ default:
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
+ }
+
+ return xControl;
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::impl_toggleInspecteeListening_nothrow( bool _bOn )
+ {
+ for ( InterfaceArray::const_iterator loop = m_aInspectedObjects.begin();
+ loop != m_aInspectedObjects.end();
+ ++loop
+ )
+ {
+ try
+ {
+ Reference< XComponent > xComp( *loop, UNO_QUERY );
+ if ( xComp.is() )
+ {
+ if ( _bOn )
+ xComp->addEventListener( static_cast< XPropertyChangeListener* >( this ) );
+ else
+ xComp->removeEventListener( static_cast< XPropertyChangeListener* >( this ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::stopInspection( bool _bCommitModified )
+ {
+ if ( haveView() )
+ {
+ if ( _bCommitModified )
+ // commit the editor's content
+ getPropertyBox().CommitModified();
+
+ // hide the property box so that it does not flicker
+ getPropertyBox().Hide();
+
+ // clear the property box
+ getPropertyBox().ClearAll();
+ }
+
+ // destroy the view first
+ if ( haveView() )
+ {
+ // remove the pages
+ for ( HashString2Int16::const_iterator erase = m_aPageIds.begin();
+ erase != m_aPageIds.end();
+ ++erase
+ )
+ getPropertyBox().RemovePage( erase->second );
+ clearContainer( m_aPageIds );
+ }
+
+ clearContainer( m_aProperties );
+
+ // de-register as dispose-listener from our inspected objects
+ impl_toggleInspecteeListening_nothrow( false );
+
+ // handlers are obsolete, so is our "composer" for their UI requests
+ if ( m_pUIRequestComposer.get() )
+ m_pUIRequestComposer->dispose();
+ m_pUIRequestComposer.reset( NULL );
+
+ // clean up the property handlers
+ PropertyHandlerArray aAllHandlers; // will contain every handler exactly once
+ for ( PropertyHandlerRepository::const_iterator aHandler = m_aPropertyHandlers.begin();
+ aHandler != m_aPropertyHandlers.end();
+ ++aHandler
+ )
+ if ( ::std::find( aAllHandlers.begin(), aAllHandlers.end(), aHandler->second ) == aAllHandlers.end() )
+ aAllHandlers.push_back( aHandler->second );
+
+ for ( PropertyHandlerArray::iterator loop = aAllHandlers.begin();
+ loop != aAllHandlers.end();
+ ++loop
+ )
+ {
+ try
+ {
+ (*loop)->removePropertyChangeListener( this );
+ (*loop)->dispose();
+ }
+ catch( const DisposedException& )
+ {
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ clearContainer( m_aPropertyHandlers );
+ clearContainer( m_aDependencyHandlers );
+ }
+
+ //------------------------------------------------------------------------
+ bool OPropertyBrowserController::impl_hasPropertyHandlerFor_nothrow( const ::rtl::OUString& _rPropertyName ) const
+ {
+ PropertyHandlerRepository::const_iterator handlerPos = m_aPropertyHandlers.find( _rPropertyName );
+ return ( handlerPos != m_aPropertyHandlers.end() );
+ }
+
+ //------------------------------------------------------------------------
+ OPropertyBrowserController::PropertyHandlerRef OPropertyBrowserController::impl_getHandlerForProperty_throw( const ::rtl::OUString& _rPropertyName ) const
+ {
+ PropertyHandlerRepository::const_iterator handlerPos = m_aPropertyHandlers.find( _rPropertyName );
+ if ( handlerPos == m_aPropertyHandlers.end() )
+ throw RuntimeException();
+ return handlerPos->second;
+ }
+
+ //------------------------------------------------------------------------
+ Any OPropertyBrowserController::impl_getPropertyValue_throw( const ::rtl::OUString& _rPropertyName )
+ {
+ PropertyHandlerRef handler = impl_getHandlerForProperty_throw( _rPropertyName );
+ return handler->getPropertyValue( _rPropertyName );
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::impl_rebindToInspectee_nothrow( const InterfaceArray& _rObjects )
+ {
+ try
+ {
+ // stop inspecting the old object(s)
+ stopInspection( true );
+
+ // inspect the new object(s)
+ m_aInspectedObjects = _rObjects;
+ doInspection();
+
+ // update the user interface
+ UpdateUI();
+ }
+
+ catch(Exception&)
+ {
+ DBG_ERROR("OPropertyBrowserController::impl_rebindToInspectee_nothrow: caught an exception !");
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::doInspection()
+ {
+ try
+ {
+ //////////////////////////////////////////////////////////////////////
+ // obtain the properties of the object
+ ::std::vector< Property > aProperties;
+
+ PropertyHandlerArray aPropertyHandlers;
+ getPropertyHandlers( m_aInspectedObjects, aPropertyHandlers );
+
+ PropertyHandlerArray::iterator aHandler( aPropertyHandlers.begin() );
+ while ( aHandler != aPropertyHandlers.end() )
+ {
+ DBG_ASSERT( aHandler->get(), "OPropertyBrowserController::doInspection: invalid handler!" );
+
+ StlSyntaxSequence< Property > aThisHandlersProperties = (*aHandler)->getSupportedProperties();
+
+ if ( aThisHandlersProperties.empty() )
+ {
+ // this handler doesn't know anything about the current inspectee -> ignore it
+ (*aHandler)->dispose();
+ aHandler = aPropertyHandlers.erase( aHandler );
+ continue;
+ }
+
+ // append these properties to our "all properties" array
+ aProperties.reserve( aProperties.size() + aThisHandlersProperties.size() );
+ for ( StlSyntaxSequence< Property >::const_iterator copyProperty = aThisHandlersProperties.begin();
+ copyProperty != aThisHandlersProperties.end();
+ ++copyProperty
+ )
+ {
+ ::std::vector< Property >::const_iterator previous = ::std::find_if(
+ aProperties.begin(),
+ aProperties.end(),
+ FindPropertyByName( copyProperty->Name )
+ );
+ if ( previous == aProperties.end() )
+ {
+ aProperties.push_back( *copyProperty );
+ continue;
+ }
+
+ // there already was another (previous) handler which supported this property.
+ // Don't add it to aProperties, again.
+
+ // Also, ensure that handlers which previously expressed interest in *changes*
+ // of this property are not notified.
+ // This is 'cause we have a new handler which is responsible for this property,
+ // which means it can give it a completely different meaning than the previous
+ // handler for this property is prepared for.
+ ::std::pair< PropertyHandlerMultiRepository::iterator, PropertyHandlerMultiRepository::iterator >
+ aDepHandlers = m_aDependencyHandlers.equal_range( copyProperty->Name );
+ m_aDependencyHandlers.erase( aDepHandlers.first, aDepHandlers.second );
+ }
+
+ // determine the superseded properties
+ StlSyntaxSequence< ::rtl::OUString > aSupersededByThisHandler = (*aHandler)->getSupersededProperties();
+ for ( StlSyntaxSequence< ::rtl::OUString >::const_iterator superseded = aSupersededByThisHandler.begin();
+ superseded != aSupersededByThisHandler.end();
+ ++superseded
+ )
+ {
+ ::std::vector< Property >::iterator existent = ::std::find_if(
+ aProperties.begin(),
+ aProperties.end(),
+ FindPropertyByName( *superseded )
+ );
+ if ( existent != aProperties.end() )
+ // one of the properties superseded by this handler was supported by a previous
+ // one -> erase
+ aProperties.erase( existent );
+ }
+
+ // be notified of changes which this handler is responsible for
+ (*aHandler)->addPropertyChangeListener( this );
+
+ // remember this handler for every of the properties which it is responsible
+ // for
+ for ( StlSyntaxSequence< Property >::const_iterator remember = aThisHandlersProperties.begin();
+ remember != aThisHandlersProperties.end();
+ ++remember
+ )
+ {
+ m_aPropertyHandlers[ remember->Name ] = *aHandler;
+ // note that this implies that if two handlers support the same property,
+ // the latter wins
+ }
+
+ // see if the handler expresses interest in any actuating properties
+ StlSyntaxSequence< ::rtl::OUString > aInterestingActuations = (*aHandler)->getActuatingProperties();
+ for ( StlSyntaxSequence< ::rtl::OUString >::const_iterator aLoop = aInterestingActuations.begin();
+ aLoop != aInterestingActuations.end();
+ ++aLoop
+ )
+ {
+ m_aDependencyHandlers.insert( PropertyHandlerMultiRepository::value_type(
+ *aLoop, *aHandler ) );
+ }
+
+ ++aHandler;
+ }
+
+ // create a new composer for UI requests coming from the handlers
+ m_pUIRequestComposer.reset( new ComposedPropertyUIUpdate( getInspectorUI(), this ) );
+
+ // sort the properties by relative position, as indicated by the model
+ for ( ::std::vector< Property >::const_iterator sourceProps = aProperties.begin();
+ sourceProps != aProperties.end();
+ ++sourceProps
+ )
+ {
+ sal_Int32 nRelativePropertyOrder = sourceProps - aProperties.begin();
+ if ( m_xModel.is() )
+ nRelativePropertyOrder = m_xModel->getPropertyOrderIndex( sourceProps->Name );
+ while ( m_aProperties.find( nRelativePropertyOrder ) != m_aProperties.end() )
+ ++nRelativePropertyOrder;
+ m_aProperties[ nRelativePropertyOrder ] = *sourceProps;
+ }
+
+ // be notified when one of our inspectees dies
+ impl_toggleInspecteeListening_nothrow( true );
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("OPropertyBrowserController::doInspection : caught an exception !");
+ }
+ }
+
+ //------------------------------------------------------------------------
+ ::com::sun::star::awt::Size SAL_CALL OPropertyBrowserController::getMinimumSize() throw (::com::sun::star::uno::RuntimeException)
+ {
+ ::com::sun::star::awt::Size aSize;
+ if( m_pView )
+ return m_pView->getMinimumSize();
+ else
+ return aSize;
+ }
+
+ //------------------------------------------------------------------------
+ ::com::sun::star::awt::Size SAL_CALL OPropertyBrowserController::getPreferredSize() throw (::com::sun::star::uno::RuntimeException)
+ {
+ return getMinimumSize();
+ }
+
+ //------------------------------------------------------------------------
+ ::com::sun::star::awt::Size SAL_CALL OPropertyBrowserController::calcAdjustedSize( const ::com::sun::star::awt::Size& _rNewSize ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ awt::Size aMinSize = getMinimumSize( );
+ awt::Size aAdjustedSize( _rNewSize );
+ if ( aAdjustedSize.Width < aMinSize.Width )
+ aAdjustedSize.Width = aMinSize.Width;
+ if ( aAdjustedSize.Height < aMinSize.Height )
+ aAdjustedSize.Height = aMinSize.Height;
+ return aAdjustedSize;
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::describePropertyLine( const Property& _rProperty, OLineDescriptor& _rDescriptor ) SAL_THROW((Exception))
+ {
+ try
+ {
+ PropertyHandlerRepository::const_iterator handler = m_aPropertyHandlers.find( _rProperty.Name );
+ if ( handler == m_aPropertyHandlers.end() )
+ throw RuntimeException(); // caught below
+
+ _rDescriptor.assignFrom( handler->second->describePropertyLine( _rProperty.Name, this ) );
+
+ //////////////////////////////////////////////////////////////////////
+
+ _rDescriptor.xPropertyHandler = handler->second;
+ _rDescriptor.sName = _rProperty.Name;
+ _rDescriptor.aValue = _rDescriptor.xPropertyHandler->getPropertyValue( _rProperty.Name );
+
+ if ( !_rDescriptor.DisplayName.getLength() )
+ {
+ #ifdef DBG_UTIL
+ ::rtl::OString sMessage( "OPropertyBrowserController::describePropertyLine: handler did not provide a display name for '" );
+ sMessage += ::rtl::OString( _rProperty.Name.getStr(), _rProperty.Name.getLength(), RTL_TEXTENCODING_ASCII_US );
+ sMessage += ::rtl::OString( "'!" );
+ DBG_ASSERT( _rDescriptor.DisplayName.getLength(), sMessage );
+ #endif
+ _rDescriptor.DisplayName = _rProperty.Name;
+ }
+
+ PropertyState ePropertyState( _rDescriptor.xPropertyHandler->getPropertyState( _rProperty.Name ) );
+ if ( PropertyState_AMBIGUOUS_VALUE == ePropertyState )
+ {
+ _rDescriptor.bUnknownValue = true;
+ _rDescriptor.aValue.clear();
+ }
+
+ _rDescriptor.bReadOnly = impl_isReadOnlyModel_throw();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "OPropertyBrowserController::describePropertyLine: caught an exception!" );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::impl_buildCategories_throw()
+ {
+ OSL_PRECOND( m_aPageIds.empty(), "OPropertyBrowserController::impl_buildCategories_throw: duplicate call!" );
+
+ StlSyntaxSequence< PropertyCategoryDescriptor > aCategories;
+ if ( m_xModel.is() )
+ aCategories = m_xModel->describeCategories();
+
+ for ( StlSyntaxSequence< PropertyCategoryDescriptor >::const_iterator category = aCategories.begin();
+ category != aCategories.end();
+ ++category
+ )
+ {
+ OSL_ENSURE( m_aPageIds.find( category->ProgrammaticName ) == m_aPageIds.end(),
+ "OPropertyBrowserController::impl_buildCategories_throw: duplicate programmatic name!" );
+
+ m_aPageIds[ category->ProgrammaticName ] =
+ getPropertyBox().AppendPage( category->UIName, HelpIdUrl::getHelpId( category->HelpURL ) );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::UpdateUI()
+ {
+ try
+ {
+ if ( !haveView() )
+ // too early, will return later
+ return;
+
+ getPropertyBox().DisableUpdate();
+
+ sal_Bool bHaveFocus = getPropertyBox().HasChildPathFocus();
+
+ // create our tab pages
+ impl_buildCategories_throw();
+ // (and allow for pages to be actually unused)
+ ::std::set< sal_uInt16 > aUsedPages;
+
+ // when building the UI below, remember which properties are actuating,
+ // to allow for a initial actuatinPropertyChanged call
+ ::std::vector< ::rtl::OUString > aActuatingProperties;
+ ::std::vector< Any > aActuatingPropertyValues;
+
+ // ask the handlers to describe the property UI, and insert the resulting
+ // entries into our list boxes
+ OrderedPropertyMap::const_iterator property( m_aProperties.begin() );
+ for ( ; property != m_aProperties.end(); ++property )
+ {
+ OLineDescriptor aDescriptor;
+ describePropertyLine( property->second, aDescriptor );
+
+ bool bIsActuatingProperty = impl_isActuatingProperty_nothrow( property->second.Name );
+
+ #if OSL_DEBUG_LEVEL > 0
+ if ( !aDescriptor.Category.getLength() )
+ {
+ ::rtl::OString sMessage( "OPropertyBrowserController::UpdateUI: empty category provided for property '" );
+ sMessage += ::rtl::OString( property->second.Name.getStr(), property->second.Name.getLength(), osl_getThreadTextEncoding() );
+ sMessage += "'!";
+ OSL_ENSURE( false, sMessage );
+ }
+ #endif
+ // finally insert this property control
+ sal_uInt16 nTargetPageId = impl_getPageIdForCategory_nothrow( aDescriptor.Category );
+ if ( nTargetPageId == (sal_uInt16)-1 )
+ {
+ // this category does not yet exist. This is allowed, as an inspector model might be lazy, and not provide
+ // any category information of its own. In this case, we have a fallback ...
+ m_aPageIds[ aDescriptor.Category ] =
+ getPropertyBox().AppendPage( aDescriptor.Category, rtl::OString() );
+ nTargetPageId = impl_getPageIdForCategory_nothrow( aDescriptor.Category );
+ }
+
+ getPropertyBox().InsertEntry( aDescriptor, nTargetPageId );
+ aUsedPages.insert( nTargetPageId );
+
+ // if it's an actuating property, remember it
+ if ( bIsActuatingProperty )
+ {
+ aActuatingProperties.push_back( property->second.Name );
+ aActuatingPropertyValues.push_back( impl_getPropertyValue_throw( property->second.Name ) );
+ }
+ }
+
+ // update any dependencies for the actuating properties which we encountered
+ {
+ ::std::vector< ::rtl::OUString >::const_iterator aProperty = aActuatingProperties.begin();
+ ::std::vector< Any >::const_iterator aPropertyValue = aActuatingPropertyValues.begin();
+ for ( ; aProperty != aActuatingProperties.end(); ++aProperty, ++aPropertyValue )
+ impl_broadcastPropertyChange_nothrow( *aProperty, *aPropertyValue, *aPropertyValue, true );
+ }
+
+ // remove any unused pages (which we did not encounter properties for)
+ HashString2Int16 aSurvivingPageIds;
+ for ( HashString2Int16::iterator pageId = m_aPageIds.begin();
+ pageId != m_aPageIds.end();
+ ++pageId
+ )
+ {
+ if ( aUsedPages.find( pageId->second ) == aUsedPages.end() )
+ getPropertyBox().RemovePage( pageId->second );
+ else
+ aSurvivingPageIds.insert( *pageId );
+ }
+ m_aPageIds.swap( aSurvivingPageIds );
+
+
+ getPropertyBox().Show();
+ getPropertyBox().EnableUpdate();
+ if ( bHaveFocus )
+ getPropertyBox().GrabFocus();
+
+ // activate the first page
+ if ( !m_aPageIds.empty() )
+ {
+ Sequence< PropertyCategoryDescriptor > aCategories( m_xModel->describeCategories() );
+ if ( aCategories.getLength() )
+ m_pView->activatePage( m_aPageIds[ aCategories[0].ProgrammaticName ] );
+ else
+ // allowed: if we default-created the pages ...
+ m_pView->activatePage( m_aPageIds.begin()->second );
+ }
+
+ // activate the previously active page (if possible)
+ if ( m_sLastValidPageSelection.getLength() )
+ m_sPageSelection = m_sLastValidPageSelection;
+ selectPageFromViewData();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::Clicked( const ::rtl::OUString& _rName, sal_Bool _bPrimary )
+ {
+ try
+ {
+ // since the browse buttons do not get the focus when clicked with the mouse,
+ // we need to commit the changes in the current property field
+ getPropertyBox().CommitModified();
+
+ PropertyHandlerRepository::const_iterator handler = m_aPropertyHandlers.find( _rName );
+ DBG_ASSERT( handler != m_aPropertyHandlers.end(), "OPropertyBrowserController::Clicked: a property without handler? This will crash!" );
+
+ ComposedUIAutoFireGuard aAutoFireGuard( *m_pUIRequestComposer );
+
+ Any aData;
+ m_xInteractiveHandler = handler->second;
+ InteractiveSelectionResult eResult =
+ handler->second->onInteractivePropertySelection( _rName, _bPrimary, aData,
+ m_pUIRequestComposer->getUIForPropertyHandler( handler->second ) );
+
+ switch ( eResult )
+ {
+ case InteractiveSelectionResult_Cancelled:
+ case InteractiveSelectionResult_Success:
+ // okay, nothing to do
+ break;
+ case InteractiveSelectionResult_ObtainedValue:
+ handler->second->setPropertyValue( _rName, aData );
+ break;
+ case InteractiveSelectionResult_Pending:
+ // also okay, we expect that the handler has disabled the UI as necessary
+ break;
+ default:
+ OSL_ENSURE( false, "OPropertyBrowserController::Clicked: unknown result value!" );
+ break;
+ }
+ }
+ catch (Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ m_xInteractiveHandler = NULL;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool SAL_CALL OPropertyBrowserController::hasPropertyByName( const ::rtl::OUString& _rName ) throw (RuntimeException)
+ {
+ for ( OrderedPropertyMap::const_iterator search = m_aProperties.begin();
+ search != m_aProperties.end();
+ ++search
+ )
+ if ( search->second.Name == _rName )
+ return true;
+ return false;
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::Commit( const ::rtl::OUString& rName, const Any& _rValue )
+ {
+ try
+ {
+ rtl::OUString sPlcHolder = String( PcrRes( RID_EMBED_IMAGE_PLACEHOLDER ) );
+ bool bIsPlaceHolderValue = false;
+
+ if ( rName.equals( PROPERTY_IMAGE_URL ) )
+ {
+ // if the prop value is the PlaceHolder
+ // can ignore it
+ rtl::OUString sVal;
+ _rValue >>= sVal;
+ if ( sVal.equals( sPlcHolder ) )
+ bIsPlaceHolderValue = true;
+ }
+ m_sCommittingProperty = rName;
+
+ bool bIsActuatingProperty = impl_isActuatingProperty_nothrow( rName );
+
+ Any aOldValue;
+ if ( bIsActuatingProperty )
+ aOldValue = impl_getPropertyValue_throw( rName );
+
+ // do we have a dedicated handler for this property, which we can delegate some tasks to?
+ PropertyHandlerRef handler = impl_getHandlerForProperty_throw( rName );
+
+ //////////////////////////////////////////////////////////////////////
+ // set the value ( only if it's not a placeholder )
+ if ( !bIsPlaceHolderValue )
+ handler->setPropertyValue( rName, _rValue );
+
+ //////////////////////////////////////////////////////////////////////
+ // re-retrieve the value
+ Any aNormalizedValue = handler->getPropertyValue( rName );
+
+ // care for any inter-property dependencies
+ if ( bIsActuatingProperty )
+ impl_broadcastPropertyChange_nothrow( rName, aNormalizedValue, aOldValue, false );
+
+ // and display it again. This ensures proper formatting
+ getPropertyBox().SetPropertyValue( rName, aNormalizedValue, false );
+ }
+ catch(PropertyVetoException& eVetoException)
+ {
+ InfoBox(m_pView, eVetoException.Message).Execute();
+ PropertyHandlerRef handler = impl_getHandlerForProperty_throw( rName );
+ Any aNormalizedValue = handler->getPropertyValue( rName );
+ getPropertyBox().SetPropertyValue( rName, aNormalizedValue, false );
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("OPropertyBrowserController::Commit : caught an exception !");
+ }
+
+ m_sCommittingProperty = ::rtl::OUString();
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void OPropertyBrowserController::focusGained( const Reference< XPropertyControl >& _Control )
+ {
+ m_aControlObservers.notifyEach( &XPropertyControlObserver::focusGained, _Control );
+ }
+
+ //--------------------------------------------------------------------
+ void OPropertyBrowserController::valueChanged( const Reference< XPropertyControl >& _Control )
+ {
+ m_aControlObservers.notifyEach( &XPropertyControlObserver::valueChanged, _Control );
+ }
+
+ //------------------------------------------------------------------------
+ namespace
+ {
+ Reference< XPropertyHandler > lcl_createHandler( const ComponentContext& _rContext, const Any& _rFactoryDescriptor )
+ {
+ Reference< XPropertyHandler > xHandler;
+
+ ::rtl::OUString sServiceName;
+ Reference< XSingleServiceFactory > xServiceFac;
+ Reference< XSingleComponentFactory > xComponentFac;
+
+ if ( _rFactoryDescriptor >>= sServiceName )
+ _rContext.createComponent( sServiceName, xHandler );
+ else if ( _rFactoryDescriptor >>= xServiceFac )
+ xHandler = xHandler.query( xServiceFac->createInstance() );
+ else if ( _rFactoryDescriptor >>= xComponentFac )
+ xHandler = xHandler.query( xComponentFac->createInstanceWithContext( _rContext.getUNOContext() ) );
+ OSL_ENSURE(xHandler.is(),"lcl_createHandler: Can not create handler");
+ return xHandler;
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::getPropertyHandlers( const InterfaceArray& _rObjects, PropertyHandlerArray& _rHandlers )
+ {
+ _rHandlers.resize( 0 );
+ if ( _rObjects.empty() )
+ return;
+
+ // create a component context for the handlers, containing some information about where
+ // they live
+ Reference< XComponentContext > xHandlerContext( m_aContext.getUNOContext() );
+
+ // if our own creator did not pass a dialog parent window, use our own view for this
+ Reference< XWindow > xParentWindow( m_aContext.getContextValueByAsciiName( "DialogParentWindow" ), UNO_QUERY );
+ if ( !xParentWindow.is() )
+ {
+ ::cppu::ContextEntry_Init aHandlerContextInfo[] =
+ {
+ ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogParentWindow" ) ), makeAny( VCLUnoHelper::GetInterface( m_pView ) ) )
+ };
+ xHandlerContext = ::cppu::createComponentContext(
+ aHandlerContextInfo, sizeof( aHandlerContextInfo ) / sizeof( aHandlerContextInfo[0] ),
+ m_aContext.getUNOContext() );
+ }
+
+ Sequence< Any > aHandlerFactories;
+ if ( m_xModel.is() )
+ aHandlerFactories = m_xModel->getHandlerFactories();
+
+ const Any* pHandlerFactory = aHandlerFactories.getConstArray();
+ const Any* pHandlerFactoryEnd = aHandlerFactories.getConstArray() + aHandlerFactories.getLength();
+
+ while ( pHandlerFactory != pHandlerFactoryEnd )
+ {
+ if ( _rObjects.size() == 1 )
+ { // we're inspecting only one object -> one handler
+ Reference< XPropertyHandler > xHandler( lcl_createHandler( m_aContext, *pHandlerFactory ) );
+ if ( xHandler.is() )
+ {
+ xHandler->inspect( _rObjects[0] );
+ _rHandlers.push_back( xHandler );
+ }
+ }
+ else
+ {
+ // create a single handler for every single object
+ ::std::vector< Reference< XPropertyHandler > > aSingleHandlers( _rObjects.size() );
+ ::std::vector< Reference< XPropertyHandler > >::iterator pHandler = aSingleHandlers.begin();
+
+ InterfaceArray::const_iterator pObject = _rObjects.begin();
+ InterfaceArray::const_iterator pObjectEnd = _rObjects.end();
+
+ for ( ; pObject != pObjectEnd; ++pObject )
+ {
+ *pHandler = lcl_createHandler( m_aContext, *pHandlerFactory );
+ if ( pHandler->is() )
+ {
+ (*pHandler)->inspect( *pObject );
+ ++pHandler;
+ }
+ }
+ aSingleHandlers.resize( pHandler - aSingleHandlers.begin() );
+
+ // then create a handler which composes information out of those single handlers
+ if ( !aSingleHandlers.empty() )
+ _rHandlers.push_back( new PropertyComposer( aSingleHandlers ) );
+ }
+
+ ++pHandlerFactory;
+ }
+
+ // note that the handlers will not be used by our caller, if they indicate that there are no
+ // properties they feel responsible for
+ }
+
+ //------------------------------------------------------------------------
+ bool OPropertyBrowserController::impl_findObjectProperty_nothrow( const ::rtl::OUString& _rName, OrderedPropertyMap::const_iterator* _pProperty )
+ {
+ OrderedPropertyMap::const_iterator search = m_aProperties.begin();
+ for ( ; search != m_aProperties.end(); ++search )
+ if ( search->second.Name == _rName )
+ break;
+ if ( _pProperty )
+ *_pProperty = search;
+ return ( search != m_aProperties.end() );
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::rebuildPropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !haveView() )
+ throw RuntimeException();
+
+ OrderedPropertyMap::const_iterator propertyPos;
+ if ( !impl_findObjectProperty_nothrow( _rPropertyName, &propertyPos ) )
+ return;
+
+ OLineDescriptor aDescriptor;
+ try
+ {
+ describePropertyLine( propertyPos->second, aDescriptor );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "OPropertyBrowserController::rebuildPropertyUI: caught an exception!" );
+ }
+
+ getPropertyBox().ChangeEntry( aDescriptor );
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::enablePropertyUI( const ::rtl::OUString& _rPropertyName, sal_Bool _bEnable ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !haveView() )
+ throw RuntimeException();
+
+ if ( !impl_findObjectProperty_nothrow( _rPropertyName ) )
+ return;
+
+ getPropertyBox().EnablePropertyLine( _rPropertyName, _bEnable );
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::enablePropertyUIElements( const ::rtl::OUString& _rPropertyName, sal_Int16 _nElements, sal_Bool _bEnable ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !haveView() )
+ throw RuntimeException();
+
+ if ( !impl_findObjectProperty_nothrow( _rPropertyName ) )
+ return;
+
+ getPropertyBox().EnablePropertyControls( _rPropertyName, _nElements, _bEnable );
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::showPropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !haveView() )
+ throw RuntimeException();
+
+ // look up the property in our object properties
+ OrderedPropertyMap::const_iterator propertyPos;
+ if ( !impl_findObjectProperty_nothrow( _rPropertyName, &propertyPos ) )
+ return;
+
+ if ( getPropertyBox().GetPropertyPos( _rPropertyName ) != LISTBOX_ENTRY_NOTFOUND )
+ {
+ rebuildPropertyUI( _rPropertyName );
+ return;
+ }
+
+ OLineDescriptor aDescriptor;
+ describePropertyLine( propertyPos->second, aDescriptor );
+
+ // look for the position to insert the property
+
+ // side note: The methods GetPropertyPos and InsertEntry of the OPropertyEditor work
+ // only on the current page. This implies that it's impossible to use this method here
+ // to show property lines which are *not* on the current page.
+ // This is sufficient for now, but should be changed in the future.
+
+ // by definition, the properties in m_aProperties are in the order in which they appear in the UI
+ // So all we need is a predecessor of pProperty in m_aProperties
+ sal_uInt16 nUIPos = LISTBOX_ENTRY_NOTFOUND;
+ do
+ {
+ if ( propertyPos != m_aProperties.begin() )
+ --propertyPos;
+ nUIPos = getPropertyBox().GetPropertyPos( propertyPos->second.Name );
+ }
+ while ( ( nUIPos == LISTBOX_ENTRY_NOTFOUND ) && ( propertyPos != m_aProperties.begin() ) );
+
+ if ( nUIPos == LISTBOX_ENTRY_NOTFOUND )
+ // insert at the very top
+ nUIPos = 0;
+ else
+ // insert right after the predecessor we found
+ ++nUIPos;
+
+ getPropertyBox().InsertEntry(
+ aDescriptor, impl_getPageIdForCategory_nothrow( aDescriptor.Category ), nUIPos );
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::hidePropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !haveView() )
+ throw RuntimeException();
+
+ if ( !impl_findObjectProperty_nothrow( _rPropertyName ) )
+ return;
+
+ getPropertyBox().RemoveEntry( _rPropertyName );
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::showCategory( const ::rtl::OUString& _rCategory, sal_Bool _bShow ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !haveView() )
+ throw RuntimeException();
+
+ sal_uInt16 nPageId = impl_getPageIdForCategory_nothrow( _rCategory );
+ OSL_ENSURE( nPageId != (sal_uInt16)-1, "OPropertyBrowserController::showCategory: invalid category!" );
+
+ getPropertyBox().ShowPropertyPage( nPageId, _bShow );
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XPropertyControl > SAL_CALL OPropertyBrowserController::getPropertyControl( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !haveView() )
+ throw RuntimeException();
+
+ Reference< XPropertyControl > xControl( getPropertyBox().GetPropertyControl( _rPropertyName ) );
+ return xControl;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::registerControlObserver( const Reference< XPropertyControlObserver >& _Observer ) throw (RuntimeException)
+ {
+ m_aControlObservers.addInterface( _Observer );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::revokeControlObserver( const Reference< XPropertyControlObserver >& _Observer ) throw (RuntimeException)
+ {
+ m_aControlObservers.removeInterface( _Observer );
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::setHelpSectionText( const ::rtl::OUString& _rHelpText ) throw (NoSupportException, RuntimeException)
+ {
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !haveView() )
+ throw DisposedException();
+
+ if ( !getPropertyBox().HasHelpSection() )
+ throw NoSupportException();
+
+ getPropertyBox().SetHelpText( _rHelpText );
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::impl_broadcastPropertyChange_nothrow( const ::rtl::OUString& _rPropertyName, const Any& _rNewValue, const Any& _rOldValue, bool _bFirstTimeInit ) const
+ {
+ // are there one or more handlers which are interested in the actuation?
+ ::std::pair< PropertyHandlerMultiRepository::const_iterator, PropertyHandlerMultiRepository::const_iterator > aInterestedHandlers =
+ m_aDependencyHandlers.equal_range( _rPropertyName );
+ if ( aInterestedHandlers.first == aInterestedHandlers.second )
+ // none of our handlers is interested in this
+ return;
+
+ ComposedUIAutoFireGuard aAutoFireGuard( *m_pUIRequestComposer );
+ try
+ {
+ // collect the responses from all interested handlers
+ PropertyHandlerMultiRepository::const_iterator handler = aInterestedHandlers.first;
+ while ( handler != aInterestedHandlers.second )
+ {
+ handler->second->actuatingPropertyChanged( _rPropertyName, _rNewValue, _rOldValue,
+ m_pUIRequestComposer->getUIForPropertyHandler( handler->second ),
+ _bFirstTimeInit );
+ ++handler;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+
diff --git a/extensions/source/propctrlr/propcontroller.hxx b/extensions/source/propctrlr/propcontroller.hxx
new file mode 100644
index 000000000000..4cc77e88c78e
--- /dev/null
+++ b/extensions/source/propctrlr/propcontroller.hxx
@@ -0,0 +1,430 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_PROPCONTROLLER_HXX_
+#define _EXTENSIONS_PROPCTRLR_PROPCONTROLLER_HXX_
+
+#include "composeduiupdate.hxx"
+#include "formbrowsertools.hxx"
+#include "formmetadata.hxx"
+#include "proplinelistener.hxx"
+#include "propcontrolobserver.hxx"
+#include "browserview.hxx"
+#ifndef _EXTENSIONS_PROPCTRLR_MODULEPCR_HXX_
+#include "modulepcr.hxx"
+#endif
+#include "propertyinfo.hxx"
+#include "pcrcomponentcontext.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/XFocusListener.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/script/XEventAttacherManager.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/awt/XLayoutConstrains.hpp>
+#include <com/sun/star/awt/XLayoutConstrains.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/inspection/XPropertyControlFactory.hpp>
+#include <com/sun/star/inspection/XObjectInspector.hpp>
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+#include <com/sun/star/inspection/XPropertyHandler.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+/** === end UNO includes === **/
+#include <connectivity/dbtools.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
+#include <cppuhelper/implbase7.hxx>
+#include <comphelper/broadcasthelper.hxx>
+
+#include <map>
+#include <hash_map>
+#include <vector>
+#include <memory>
+
+class SvNumberFormatsSupplierObj;
+class Font;
+class Window;
+class SfxItemSet;
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ class OPropertyEditor;
+ struct OLineDescriptor;
+
+#if OSL_DEBUG_LEVEL > 0
+ const char* CheckPropertyBrowserInvariants( const void* pVoid );
+ // for dignostics with DBG_CHKTHIS
+#endif
+ DBG_NAMEEX( OPropertyBrowserController )
+
+ //========================================================================
+ //= OPropertyBrowserController
+ //========================================================================
+ // #95343#------------------------------------------------------------------------------------
+ typedef ::cppu::WeakImplHelper7 < ::com::sun::star::lang::XServiceInfo
+ , ::com::sun::star::awt::XFocusListener
+ , ::com::sun::star::awt::XLayoutConstrains
+ , ::com::sun::star::beans::XPropertyChangeListener
+ , ::com::sun::star::inspection::XPropertyControlFactory
+ , ::com::sun::star::inspection::XObjectInspector
+ , ::com::sun::star::lang::XInitialization
+ > OPropertyBrowserController_Base;
+
+ class OPropertyBrowserController
+ :public ::comphelper::OMutexAndBroadcastHelper
+ ,public OPropertyBrowserController_Base
+ ,public ::com::sun::star::inspection::XObjectInspectorUI
+ // that's intentionally *not* part of the OPropertyBrowserController_Base
+ // We do not want this to be available in queryInterface, getTypes, and the like.
+ ,public IPropertyLineListener
+ ,public IPropertyControlObserver
+ ,public IPropertyExistenceCheck
+ {
+ private:
+ typedef ::std::map< sal_Int32, ::com::sun::star::beans::Property > OrderedPropertyMap;
+ typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >
+ InterfaceArray;
+
+ protected:
+ ComponentContext m_aContext;
+
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xView;
+
+ ::cppu::OInterfaceContainerHelper m_aDisposeListeners;
+ ::cppu::OInterfaceContainerHelper m_aControlObservers;
+ // meta data about the properties
+ OPropertyBrowserView* m_pView;
+
+ ::rtl::OUString m_sPageSelection;
+ ::rtl::OUString m_sLastValidPageSelection;
+
+ typedef ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler >
+ PropertyHandlerRef;
+ typedef ::std::vector< PropertyHandlerRef > PropertyHandlerArray;
+ typedef ::std::hash_map< ::rtl::OUString, PropertyHandlerRef, ::rtl::OUStringHash >
+ PropertyHandlerRepository;
+ typedef ::std::hash_multimap< ::rtl::OUString, PropertyHandlerRef, ::rtl::OUStringHash >
+ PropertyHandlerMultiRepository;
+ PropertyHandlerRepository m_aPropertyHandlers;
+ PropertyHandlerMultiRepository m_aDependencyHandlers;
+ PropertyHandlerRef m_xInteractiveHandler;
+
+ ::std::auto_ptr< ComposedPropertyUIUpdate > m_pUIRequestComposer;
+
+ /// our InspectorModel
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorModel >
+ m_xModel;
+ /// the object(s) we're currently inspecting
+ InterfaceArray m_aInspectedObjects;
+ /// the properties of the currently inspected object(s)
+ OrderedPropertyMap m_aProperties;
+ /// the property we're just committing
+ ::rtl::OUString m_sCommittingProperty;
+
+ typedef ::std::hash_map< ::rtl::OUString, sal_uInt16, ::rtl::OUStringHash > HashString2Int16;
+ HashString2Int16 m_aPageIds;
+
+ bool m_bContainerFocusListening;
+ bool m_bSuspendingPropertyHandlers;
+ bool m_bConstructed;
+ bool m_bBindingIntrospectee;
+
+ protected:
+ DECLARE_XINTERFACE()
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XController
+ virtual void SAL_CALL attachFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL attachModel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL suspend( sal_Bool bSuspend ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getViewData( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL restoreViewData( const ::com::sun::star::uno::Any& Data ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > SAL_CALL getModel( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > SAL_CALL getFrame( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XComponent
+ virtual void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XFocusListener
+ virtual void SAL_CALL focusGained( const ::com::sun::star::awt::FocusEvent& _rSource ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL focusLost( const ::com::sun::star::awt::FocusEvent& _rSource ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XLayoutConstrains #95343# ----------------
+ virtual ::com::sun::star::awt::Size SAL_CALL getMinimumSize( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Size SAL_CALL getPreferredSize( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Size SAL_CALL calcAdjustedSize( const ::com::sun::star::awt::Size& aNewSize ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XPropertyChangeListener
+ virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException);
+
+ /** XPropertyControlFactory
+ */
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl > SAL_CALL createPropertyControl( ::sal_Int16 ControlType, ::sal_Bool CreateReadOnly ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+ public:
+ OPropertyBrowserController(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext);
+
+ protected:
+ virtual ~OPropertyBrowserController();
+
+ public:
+ // XServiceInfo - static versions
+ static ::rtl::OUString getImplementationName_static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+ Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
+
+ protected:
+ // IPropertyLineListener
+ virtual void Clicked( const ::rtl::OUString& _rName, sal_Bool _bPrimary );
+ virtual void Commit( const ::rtl::OUString& _rName, const ::com::sun::star::uno::Any& _rVal );
+
+ // IPropertyControlObserver
+ virtual void focusGained( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& _Control );
+ virtual void valueChanged( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& _Control );
+
+ // IPropertyExistenceCheck
+ virtual ::sal_Bool SAL_CALL hasPropertyByName( const ::rtl::OUString& _rName ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XObjectInspectorUI
+ virtual void SAL_CALL enablePropertyUI( const ::rtl::OUString& _rPropertyName, ::sal_Bool _bEnable ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL enablePropertyUIElements( const ::rtl::OUString& _rPropertyName, ::sal_Int16 _nElements, ::sal_Bool _bEnable ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL rebuildPropertyUI( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL showPropertyUI( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL hidePropertyUI( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL showCategory( const ::rtl::OUString& _rCategory, ::sal_Bool _bShow ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl > SAL_CALL getPropertyControl( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL registerControlObserver( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlObserver >& _Observer ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL revokeControlObserver( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlObserver >& _Observer ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setHelpSectionText( const ::rtl::OUString& HelpText ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
+
+ // XObjectInspector
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorModel > SAL_CALL getInspectorModel() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setInspectorModel( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorModel >& _inspectormodel ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI > SAL_CALL getInspectorUI() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL inspect( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& Objects ) throw (::com::sun::star::util::VetoException, ::com::sun::star::uno::RuntimeException);
+
+ // XDispatchProvider
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( const ::com::sun::star::util::URL& URL, const ::rtl::OUString& TargetFrameName, ::sal_Int32 SearchFlags ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& Requests ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ private:
+ void UpdateUI();
+
+ void startContainerWindowListening();
+ void stopContainerWindowListening();
+
+ // stop the inspection
+ void stopInspection( bool _bCommitModified );
+
+ sal_Bool haveView() const { return NULL != m_pView; }
+ OPropertyEditor& getPropertyBox() { return m_pView->getPropertyBox(); }
+
+ // does the inspection of the objects as indicated by our model
+ void doInspection();
+
+ // bind the browser to m_xIntrospecteeAsProperty
+ void impl_rebindToInspectee_nothrow( const InterfaceArray& _rObjects );
+
+ /** retrieves special property handlers for our introspectee
+ */
+ void getPropertyHandlers( const InterfaceArray& _rObjects, PropertyHandlerArray& _rHandlers );
+
+ /** called when a property changed, to broadcast any handlers which might have
+ registered for this property
+
+ @param _bFirstTimeInit
+ if set to <FALSE/>, this is a real change in the property value, not just a call
+ for purposes of initialization.
+ */
+ void impl_broadcastPropertyChange_nothrow( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, bool _bFirstTimeInit ) const;
+
+ /** determines whether the given property is an actuating property, that is, at least one
+ handler expressed interest in changes to this property's value.
+ */
+ inline bool impl_isActuatingProperty_nothrow( const ::rtl::OUString& _rPropertyName ) const
+ {
+ return ( m_aDependencyHandlers.find( _rPropertyName ) != m_aDependencyHandlers.end() );
+ }
+
+ sal_uInt32 GetPropertyPos(const ::rtl::OUString& _rPropName);
+
+ /** retrieves the value of the given property, by asking the appropriate XPropertyHandler
+ @param _rPropertyName
+ the name whose handler is to be obtained. Must be the name of a property
+ for which a handler is registered.
+ @throws
+ RuntimeException if there is no handler for the given property
+ @return
+ the value of this property
+ */
+ ::com::sun::star::uno::Any
+ impl_getPropertyValue_throw( const ::rtl::OUString& _rPropertyName );
+
+ /// calls XPropertyHandler::suspend for all our property handlers
+ sal_Bool suspendPropertyHandlers_nothrow( sal_Bool _bSuspend );
+
+ /// suspends the complete inspector
+ sal_Bool suspendAll_nothrow();
+
+ /** selects a page according to our current view data
+ */
+ void selectPageFromViewData();
+
+ /** updates our view data from the currently active page
+ */
+ void updateViewDataFromActivePage();
+
+ /// describes the UI for the given property
+ void describePropertyLine( const ::com::sun::star::beans::Property& _rPropertyName, OLineDescriptor& _rDescriptor )
+ SAL_THROW((::com::sun::star::uno::Exception));
+
+ /** retrieves the position of the property given by name in m_aProperties
+ @return
+ <TRUE/> if and only if the property could be found. In this case, <arg>_pProperty</arg> (if
+ not <NULL/> contains the iterator pointing to this property.
+ */
+ bool impl_findObjectProperty_nothrow( const ::rtl::OUString& _rName, OrderedPropertyMap::const_iterator* _pProperty = NULL );
+
+ sal_Bool Construct(Window* _pParentWin);
+
+ /** retrieves the property handler for a given property name
+ @param _rPropertyName
+ the name whose handler is to be obtained. Must be the name of a property
+ for which a handler is registered.
+ @throws
+ RuntimeException if there is no handler for the given property
+ @return
+ the handler which is responsible for the given property
+ */
+ PropertyHandlerRef
+ impl_getHandlerForProperty_throw( const ::rtl::OUString& _rPropertyName ) const;
+
+ /** determines whether we have a handler for the given property
+ @param _rPropertyName
+ the name of the property for which the existence of a handler should be checked
+ */
+ bool
+ impl_hasPropertyHandlerFor_nothrow( const ::rtl::OUString& _rPropertyName ) const;
+
+ /** builds up m_aPageIds from InspectorModel::describeCategories, and insert all the
+ respective tab pages into our view
+ @precond
+ m_aPageIds is empty
+ @throws ::com::sun::star::uno::RuntimeException
+ if one of the callees of this method throws this exception
+ */
+ void
+ impl_buildCategories_throw();
+
+ /** retrieves the id of the tab page which represents a given category.
+ @param _rCategoryName
+ the programmatic name of a category.
+ @return
+ the id of the tab page, or <code>(sal_uInt16)-1</code> if there
+ is no tab page for the given category
+ */
+ sal_uInt16
+ impl_getPageIdForCategory_nothrow( const ::rtl::OUString& _rCategoryName ) const;
+
+ /** adds or removes ourself as XEventListener to/from all our inspectees
+ */
+ void impl_toggleInspecteeListening_nothrow( bool _bOn );
+
+ /** binds the instance to a new model
+ */
+ void impl_bindToNewModel_nothrow( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorModel >& _rxInspectorModel );
+
+ /** initializes our view, as indicated by the model's view-relevant properties
+
+ It's allowed to call this method when no model exists, yet. In this case, nothing
+ happens.
+ */
+ void impl_initializeView_nothrow();
+
+ /** determines whether the view should be readonly.
+
+ Effectively, this means that the method simply checks the IsReadOnly attribute of the model.
+ If there is no model, <FALSE/> is returned.
+
+ @throws ::com::sun::star::uno::RuntimeException
+ in case asking the model for its IsReadOnly attribute throws a ::com::sun::star::uno::RuntimeException
+ itself.
+ */
+ bool impl_isReadOnlyModel_throw() const;
+
+ /** updates our view so that it is read-only, as indicated by the model property
+ @see impl_isReadOnlyModel_throw
+ */
+ void impl_updateReadOnlyView_nothrow();
+
+ /** starts or stops listening at the model
+ */
+ void impl_startOrStopModelListening_nothrow( bool _bDoListen ) const;
+
+ private:
+ DECL_LINK(OnPageActivation, void*);
+
+ private:
+ // constructors
+ void createDefault();
+ void createWithModel( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorModel >& _rxModel );
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_PROPCONTROLLER_HXX_
+
diff --git a/extensions/source/propctrlr/propcontrolobserver.hxx b/extensions/source/propctrlr/propcontrolobserver.hxx
new file mode 100644
index 000000000000..65bfe7ee0233
--- /dev/null
+++ b/extensions/source/propctrlr/propcontrolobserver.hxx
@@ -0,0 +1,56 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef PROPCONTROLOBSERVER_HXX
+#define PROPCONTROLOBSERVER_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/XPropertyControl.hpp>
+/** === end UNO includes === **/
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= IPropertyControlObserver
+ //====================================================================
+ /** non-UNO version of the XPropertyControlObserver
+ */
+ class IPropertyControlObserver
+ {
+ public:
+ virtual void focusGained( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& _Control ) = 0;
+ virtual void valueChanged( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& _Control ) = 0;
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // PROPCONTROLOBSERVER_HXX
+
diff --git a/extensions/source/propctrlr/propertycomposer.cxx b/extensions/source/propctrlr/propertycomposer.cxx
new file mode 100644
index 000000000000..3cca2b1553d3
--- /dev/null
+++ b/extensions/source/propctrlr/propertycomposer.cxx
@@ -0,0 +1,516 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "propertycomposer.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/NullPointerException.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+/** === end UNO includes === **/
+#include <osl/diagnose.h>
+#include <tools/diagnose_ex.h>
+
+#include <functional>
+#include <algorithm>
+#include <map>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::inspection;
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ namespace
+ {
+ //----------------------------------------------------------------
+ struct SetPropertyValue : public ::std::unary_function< Reference< XPropertyHandler >, void >
+ {
+ ::rtl::OUString sPropertyName;
+ const Any& rValue;
+ SetPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) : sPropertyName( _rPropertyName ), rValue( _rValue ) { }
+ void operator()( const Reference< XPropertyHandler >& _rHandler )
+ {
+ _rHandler->setPropertyValue( sPropertyName, rValue );
+ }
+ };
+
+ //----------------------------------------------------------------
+ template < class BagType >
+ void putIntoBag( const Sequence< typename BagType::value_type >& _rArray, BagType& /* [out] */ _rBag )
+ {
+ ::std::copy( _rArray.getConstArray(), _rArray.getConstArray() + _rArray.getLength(),
+ ::std::insert_iterator< BagType >( _rBag, _rBag.begin() ) );
+ }
+
+ //----------------------------------------------------------------
+ template < class BagType >
+ void copyBagToArray( const BagType& /* [out] */ _rBag, Sequence< typename BagType::value_type >& _rArray )
+ {
+ _rArray.realloc( _rBag.size() );
+ ::std::copy( _rBag.begin(), _rBag.end(), _rArray.getArray() );
+ }
+ }
+
+ //====================================================================
+ //= PropertyComposer
+ //====================================================================
+
+ // TODO: there are various places where we determine the first handler in our array which
+ // supports a given property id. This is, at the moment, done with searching all handlers,
+ // which is O( n * k ) at worst (n being the number of handlers, k being the maximum number
+ // of supported properties per handler). Shouldn't we cache this? So that it is O( log k )?
+
+ //--------------------------------------------------------------------
+ PropertyComposer::PropertyComposer( const ::std::vector< Reference< XPropertyHandler > >& _rSlaveHandlers )
+ :PropertyComposer_Base ( m_aMutex )
+ ,m_aSlaveHandlers ( _rSlaveHandlers )
+ ,m_aPropertyListeners ( m_aMutex )
+ ,m_bSupportedPropertiesAreKnown ( false )
+ {
+ if ( m_aSlaveHandlers.empty() )
+ throw IllegalArgumentException();
+
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ Reference< XPropertyChangeListener > xMeMyselfAndI( this );
+ for ( HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
+ loop != m_aSlaveHandlers.end();
+ ++loop
+ )
+ {
+ if ( !loop->is() )
+ throw NullPointerException();
+ (*loop)->addPropertyChangeListener( xMeMyselfAndI );
+ }
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyComposer::inspect( const Reference< XInterface >& _rxIntrospectee ) throw (RuntimeException, NullPointerException)
+ {
+ MethodGuard aGuard( *this );
+
+ for ( HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
+ loop != m_aSlaveHandlers.end();
+ ++loop
+ )
+ {
+ (*loop)->inspect( _rxIntrospectee );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL PropertyComposer::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ return m_aSlaveHandlers[0]->getPropertyValue( _rPropertyName );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyComposer::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ ::std::for_each( m_aSlaveHandlers.begin(), m_aSlaveHandlers.end(), SetPropertyValue( _rPropertyName, _rValue ) );
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL PropertyComposer::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ return m_aSlaveHandlers[0]->convertToPropertyValue( _rPropertyName, _rControlValue );
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL PropertyComposer::convertToControlValue( const ::rtl::OUString& _rPropertyName, const Any& _rPropertyValue, const Type& _rControlValueType ) throw (UnknownPropertyException, RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ return m_aSlaveHandlers[0]->convertToControlValue( _rPropertyName, _rPropertyValue, _rControlValueType );
+ }
+
+ //--------------------------------------------------------------------
+ PropertyState SAL_CALL PropertyComposer::getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+
+ // assume DIRECT for the moment. This will stay this way if *all* slaves
+ // tell the property has DIRECT state, and if *all* values equal
+ PropertyState eState = PropertyState_DIRECT_VALUE;
+
+ // check the master state
+ Reference< XPropertyHandler > xPrimary( *m_aSlaveHandlers.begin() );
+ Any aPrimaryValue = xPrimary->getPropertyValue( _rPropertyName );
+ eState = xPrimary->getPropertyState( _rPropertyName );
+
+ // loop through the secondary sets
+ PropertyState eSecondaryState = PropertyState_DIRECT_VALUE;
+ for ( HandlerArray::const_iterator loop = ( m_aSlaveHandlers.begin() + 1 );
+ loop != m_aSlaveHandlers.end();
+ ++loop
+ )
+ {
+ // the secondary state
+ eSecondaryState = (*loop)->getPropertyState( _rPropertyName );
+
+ // the secondary value
+ Any aSecondaryValue( (*loop)->getPropertyValue( _rPropertyName ) );
+
+ if ( ( PropertyState_AMBIGUOUS_VALUE == eSecondaryState ) // secondary is ambiguous
+ || ( aPrimaryValue != aSecondaryValue ) // unequal values
+ )
+ {
+ eState = PropertyState_AMBIGUOUS_VALUE;
+ break;
+ }
+ }
+
+ return eState;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyComposer::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ m_aPropertyListeners.addListener( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyComposer::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ m_aPropertyListeners.removeListener( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Property > SAL_CALL PropertyComposer::getSupportedProperties() throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+
+ if ( !m_bSupportedPropertiesAreKnown )
+ {
+ // we support a property if and only if all of our slaves support it
+
+ // initially, use all the properties of an arbitrary handler (we take the first one)
+ putIntoBag( (*m_aSlaveHandlers.begin())->getSupportedProperties(), m_aSupportedProperties );
+
+ // now intersect with the properties of *all* other handlers
+ for ( HandlerArray::const_iterator loop = ( m_aSlaveHandlers.begin() + 1 );
+ loop != m_aSlaveHandlers.end();
+ ++loop
+ )
+ {
+ // the properties supported by the current handler
+ PropertyBag aThisRound;
+ putIntoBag( (*loop)->getSupportedProperties(), aThisRound );
+
+ // the intersection of those properties with all we already have
+ PropertyBag aIntersection;
+ ::std::set_intersection( aThisRound.begin(), aThisRound.end(), m_aSupportedProperties.begin(), m_aSupportedProperties.end(),
+ ::std::insert_iterator< PropertyBag >( aIntersection, aIntersection.begin() ), PropertyLessByName() );
+
+ m_aSupportedProperties.swap( aIntersection );
+ if ( m_aSupportedProperties.empty() )
+ break;
+ }
+
+ // remove those properties which are not composable
+ for ( PropertyBag::iterator check = m_aSupportedProperties.begin();
+ check != m_aSupportedProperties.end();
+ )
+ {
+ sal_Bool bIsComposable = isComposable( check->Name );
+ if ( !bIsComposable )
+ {
+ PropertyBag::iterator next = check; ++next;
+ m_aSupportedProperties.erase( check );
+ check = next;
+ }
+ else
+ ++check;
+ }
+
+ m_bSupportedPropertiesAreKnown = true;
+ }
+
+ Sequence< Property > aSurvived;
+ copyBagToArray( m_aSupportedProperties, aSurvived );
+ return aSurvived;
+ }
+
+ //--------------------------------------------------------------------
+ void uniteStringArrays( const PropertyComposer::HandlerArray& _rHandlers, Sequence< ::rtl::OUString > (SAL_CALL XPropertyHandler::*pGetter)( void ),
+ Sequence< ::rtl::OUString >& /* [out] */ _rUnion )
+ {
+ ::std::set< ::rtl::OUString > aUnitedBag;
+
+ Sequence< ::rtl::OUString > aThisRound;
+ for ( PropertyComposer::HandlerArray::const_iterator loop = _rHandlers.begin();
+ loop != _rHandlers.end();
+ ++loop
+ )
+ {
+ aThisRound = (loop->get()->*pGetter)();
+ putIntoBag( aThisRound, aUnitedBag );
+ }
+
+ copyBagToArray( aUnitedBag, _rUnion );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL PropertyComposer::getSupersededProperties( ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+
+ // we supersede those properties which are superseded by at least one of our slaves
+ Sequence< ::rtl::OUString > aSuperseded;
+ uniteStringArrays( m_aSlaveHandlers, &XPropertyHandler::getSupersededProperties, aSuperseded );
+ return aSuperseded;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL PropertyComposer::getActuatingProperties( ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+
+ // we're interested in those properties which at least one handler wants to have
+ Sequence< ::rtl::OUString > aActuating;
+ uniteStringArrays( m_aSlaveHandlers, &XPropertyHandler::getActuatingProperties, aActuating );
+ return aActuating;
+ }
+
+ //--------------------------------------------------------------------
+ LineDescriptor SAL_CALL PropertyComposer::describePropertyLine( const ::rtl::OUString& _rPropertyName,
+ const Reference< XPropertyControlFactory >& _rxControlFactory )
+ throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ return m_aSlaveHandlers[0]->describePropertyLine( _rPropertyName, _rxControlFactory );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL PropertyComposer::isComposable( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ return m_aSlaveHandlers[0]->isComposable( _rPropertyName );
+ }
+
+ //--------------------------------------------------------------------
+ InteractiveSelectionResult SAL_CALL PropertyComposer::onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, Any& _rData, const Reference< XObjectInspectorUI >& _rxInspectorUI ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ MethodGuard aGuard( *this );
+
+ impl_ensureUIRequestComposer( _rxInspectorUI );
+ ComposedUIAutoFireGuard aAutoFireGuard( *m_pUIRequestComposer );
+
+ // ask the first of the handlers
+ InteractiveSelectionResult eResult = (*m_aSlaveHandlers.begin())->onInteractivePropertySelection(
+ _rPropertyName,
+ _bPrimary,
+ _rData,
+ m_pUIRequestComposer->getUIForPropertyHandler( *m_aSlaveHandlers.begin() )
+ );
+
+ switch ( eResult )
+ {
+ case InteractiveSelectionResult_Cancelled:
+ // fine
+ break;
+
+ case InteractiveSelectionResult_Success:
+ case InteractiveSelectionResult_Pending:
+ OSL_ENSURE( false, "PropertyComposer::onInteractivePropertySelection: no chance to forward the new value to the other handlers!" );
+ // This means that we cannot know the new property value, which either has already been set
+ // at the first component ("Success"), or will be set later on once the asynchronous input
+ // is finished ("Pending"). So, we also cannot forward this new property value to the other
+ // handlers.
+ // We would need to be a listener at the property at the first component, but even this wouldn't
+ // be sufficient, since the property handler is free to change *any* property during a dedicated
+ // property UI.
+ eResult = InteractiveSelectionResult_Cancelled;
+ break;
+
+ case InteractiveSelectionResult_ObtainedValue:
+ // OK. Our own caller will pass this as setPropertyValue, and we will then pass it to
+ // all slave handlers
+ break;
+
+ default:
+ OSL_ENSURE( false, "OPropertyBrowserController::onInteractivePropertySelection: unknown result value!" );
+ break;
+ }
+
+ return eResult;
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyComposer::impl_ensureUIRequestComposer( const Reference< XObjectInspectorUI >& _rxInspectorUI )
+ {
+ OSL_ENSURE( !m_pUIRequestComposer.get() || m_pUIRequestComposer->getDelegatorUI().get() == _rxInspectorUI.get(),
+ "PropertyComposer::impl_ensureUIRequestComposer: somebody's changing the horse in the mid of the race!" );
+
+ if ( !m_pUIRequestComposer.get() )
+ m_pUIRequestComposer.reset( new ComposedPropertyUIUpdate( _rxInspectorUI, this ) );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyComposer::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& _rOldValue, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ MethodGuard aGuard( *this );
+
+ impl_ensureUIRequestComposer( _rxInspectorUI );
+ ComposedUIAutoFireGuard aAutoFireGuard( *m_pUIRequestComposer );
+
+ // ask all handlers which expressed interest in this particular property, and "compose" their
+ // commands for the UIUpdater
+ for ( HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
+ loop != m_aSlaveHandlers.end();
+ ++loop
+ )
+ {
+ // TODO: make this cheaper (cache it?)
+ const StlSyntaxSequence< ::rtl::OUString > aThisHandlersActuatingProps = (*loop)->getActuatingProperties();
+ for ( StlSyntaxSequence< ::rtl::OUString >::const_iterator loopProps = aThisHandlersActuatingProps.begin();
+ loopProps != aThisHandlersActuatingProps.end();
+ ++loopProps
+ )
+ {
+ if ( *loopProps == _rActuatingPropertyName )
+ {
+ (*loop)->actuatingPropertyChanged( _rActuatingPropertyName, _rNewValue, _rOldValue,
+ m_pUIRequestComposer->getUIForPropertyHandler( *loop ),
+ _bFirstTimeInit );
+ break;
+ }
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XCOMPONENT( PropertyComposer, PropertyComposer_Base )
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyComposer::disposing()
+ {
+ MethodGuard aGuard( *this );
+
+ // dispose our slave handlers
+ for ( PropertyComposer::HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
+ loop != m_aSlaveHandlers.end();
+ ++loop
+ )
+ {
+ (*loop)->removePropertyChangeListener( this );
+ (*loop)->dispose();
+ }
+
+ clearContainer( m_aSlaveHandlers );
+
+ if ( m_pUIRequestComposer.get() )
+ m_pUIRequestComposer->dispose();
+ m_pUIRequestComposer.reset( NULL );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyComposer::propertyChange( const PropertyChangeEvent& evt ) throw (RuntimeException)
+ {
+ if ( !impl_isSupportedProperty_nothrow( evt.PropertyName ) )
+ // A slave handler might fire events for more properties than we support. Ignore those.
+ return;
+
+ PropertyChangeEvent aTranslatedEvent( evt );
+ try
+ {
+ aTranslatedEvent.NewValue = getPropertyValue( evt.PropertyName );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ m_aPropertyListeners.notify( aTranslatedEvent, &XPropertyChangeListener::propertyChange );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyComposer::disposing( const EventObject& Source ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ m_aPropertyListeners.disposing( Source );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL PropertyComposer::suspend( sal_Bool _bSuspend ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ for ( PropertyComposer::HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
+ loop != m_aSlaveHandlers.end();
+ ++loop
+ )
+ {
+ if ( !(*loop)->suspend( _bSuspend ) )
+ {
+ if ( _bSuspend && ( loop != m_aSlaveHandlers.begin() ) )
+ {
+ // if we tried to suspend, but one of the slave handlers vetoed,
+ // re-activate the handlers which actually did *not* veto
+ // the suspension
+ do
+ {
+ --loop;
+ (*loop)->suspend( sal_False );
+ }
+ while ( loop != m_aSlaveHandlers.begin() );
+ }
+ return false;
+ }
+ }
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL PropertyComposer::hasPropertyByName( const ::rtl::OUString& _rName ) throw (RuntimeException)
+ {
+ return impl_isSupportedProperty_nothrow( _rName );
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
diff --git a/extensions/source/propctrlr/propertycomposer.hxx b/extensions/source/propctrlr/propertycomposer.hxx
new file mode 100644
index 000000000000..4a67c1da9e6d
--- /dev/null
+++ b/extensions/source/propctrlr/propertycomposer.hxx
@@ -0,0 +1,157 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYCOMPOSER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYCOMPOSER_HXX
+
+#include "pcrcommon.hxx"
+#include "formbrowsertools.hxx"
+#include "composeduiupdate.hxx"
+#include "formbrowsertools.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/inspection/XPropertyHandler.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+/** === end UNO includes === **/
+#include <cppuhelper/compbase2.hxx>
+#include <comphelper/broadcasthelper.hxx>
+#include <comphelper/listenernotification.hxx>
+
+#include <vector>
+#include <set>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= PropertyComposer
+ //====================================================================
+ typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::inspection::XPropertyHandler
+ , ::com::sun::star::beans::XPropertyChangeListener
+ > PropertyComposer_Base;
+ /** implements an <type>XPropertyHandler</type> which composes it's information
+ from a set of other property handlers
+ */
+ class PropertyComposer :public PropertyComposer_Base
+ ,public ::comphelper::OBaseMutex
+ ,public IPropertyExistenceCheck
+ {
+ public:
+ typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler > >
+ HandlerArray;
+
+ private:
+ HandlerArray m_aSlaveHandlers;
+ ::std::auto_ptr< ComposedPropertyUIUpdate > m_pUIRequestComposer;
+ PropertyChangeListeners m_aPropertyListeners;
+ bool m_bSupportedPropertiesAreKnown;
+ PropertyBag m_aSupportedProperties;
+
+ public:
+ /** constructs an <type>XPropertyHandler</type> which composes it's information from a set
+ of other property handlers
+
+ @param _rSlaveHandlers
+ the set of slave handlers to invoke. Must not be <NULL/>
+ */
+ PropertyComposer( const ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler > >& _rSlaveHandlers );
+
+ public:
+ // XPropertyHandler overridables
+ virtual void SAL_CALL inspect( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxIntrospectee ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rControlValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToControlValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rPropertyValue, const ::com::sun::star::uno::Type& _rControlValueType ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::beans::PropertyState
+ SAL_CALL getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
+ SAL_CALL getSupportedProperties() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getSupersededProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::LineDescriptor
+ SAL_CALL describePropertyLine( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isComposable( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::InteractiveSelectionResult
+ SAL_CALL onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, ::com::sun::star::uno::Any& _rData, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL suspend( sal_Bool _bSuspend ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XComponent
+ DECLARE_XCOMPONENT()
+ virtual void SAL_CALL disposing();
+
+ // XPropertyChangeListener
+ virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ // IPropertyExistenceCheck
+ virtual ::sal_Bool SAL_CALL hasPropertyByName( const ::rtl::OUString& _rName ) throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ /** ensures that m_pUIRequestComposer exists
+ */
+ void impl_ensureUIRequestComposer( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI );
+
+ /** checks whether a given property exists in <member>m_aSupportedProperties</member>
+ */
+ bool impl_isSupportedProperty_nothrow( const ::rtl::OUString& _rPropertyName )
+ {
+ ::com::sun::star::beans::Property aDummy; aDummy.Name = _rPropertyName;
+ return m_aSupportedProperties.find( aDummy ) != m_aSupportedProperties.end();
+ }
+
+ private:
+ class MethodGuard;
+ friend class MethodGuard;
+ class MethodGuard : public ::osl::MutexGuard
+ {
+ public:
+ MethodGuard( PropertyComposer& _rInstance )
+ : ::osl::MutexGuard( _rInstance.m_aMutex )
+ {
+ if ( _rInstance.m_aSlaveHandlers.empty() )
+ throw ::com::sun::star::lang::DisposedException( ::rtl::OUString(), *(&_rInstance) );
+ }
+ };
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYCOMPOSER_HXX
+
diff --git a/extensions/source/propctrlr/propertycontrolextender.cxx b/extensions/source/propctrlr/propertycontrolextender.cxx
new file mode 100644
index 000000000000..d06ab54e0a79
--- /dev/null
+++ b/extensions/source/propctrlr/propertycontrolextender.cxx
@@ -0,0 +1,145 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#ifndef EXTENSIONS_PROPERTYCONTROLEXTENDER_HXX
+#include "propertycontrolextender.hxx"
+#endif
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/KeyFunction.hpp>
+/** === end UNO includes === **/
+
+#include <tools/diagnose_ex.h>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::awt::XWindow;
+ using ::com::sun::star::awt::KeyEvent;
+ using ::com::sun::star::inspection::XPropertyControl;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::inspection::XPropertyControlContext;
+ /** === end UNO using === **/
+ namespace KeyFunction = ::com::sun::star::awt::KeyFunction;
+
+ //====================================================================
+ //= PropertyControlExtender_Data
+ //====================================================================
+ struct PropertyControlExtender_Data
+ {
+ Reference< XPropertyControl > xControl;
+ Reference< XWindow > xControlWindow;
+ };
+
+ //====================================================================
+ //= PropertyControlExtender
+ //====================================================================
+ //--------------------------------------------------------------------
+ PropertyControlExtender::PropertyControlExtender( const Reference< XPropertyControl >& _rxObservedControl )
+ :m_pData( new PropertyControlExtender_Data )
+ {
+ try
+ {
+ m_pData->xControl.set( _rxObservedControl, UNO_SET_THROW );
+ m_pData->xControlWindow.set( m_pData->xControl->getControlWindow(), UNO_SET_THROW );
+ m_pData->xControlWindow->addKeyListener( this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ PropertyControlExtender::~PropertyControlExtender()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyControlExtender::keyPressed( const KeyEvent& _event ) throw (RuntimeException)
+ {
+ OSL_ENSURE( _event.Source == m_pData->xControlWindow, "PropertyControlExtender::keyPressed: where does this come from?" );
+ if ( ( _event.KeyFunc == KeyFunction::DELETE )
+ && ( _event.Modifiers == 0 )
+ )
+ {
+ try
+ {
+ Reference< XPropertyControl > xControl( m_pData->xControl, UNO_SET_THROW );
+
+ // reset the value
+ xControl->setValue( Any() );
+
+ // and notify the change
+ // don't use XPropertyControl::notifyModifiedValue. It only notifies when the control content
+ // is recognized as being modified by the user, which is not the case, since we just modified
+ // it programmatically.
+ Reference< XPropertyControlContext > xControlContext( xControl->getControlContext(), UNO_SET_THROW );
+ xControlContext->valueChanged( xControl );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyControlExtender::keyReleased( const KeyEvent& /*_event*/ ) throw (RuntimeException)
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyControlExtender::disposing( const EventObject& Source ) throw (RuntimeException)
+ {
+ OSL_ENSURE( Source.Source == m_pData->xControlWindow, "PropertyControlExtender::disposing: where does this come from?" );
+ (void)Source.Source;
+ m_pData->xControlWindow.clear();
+ m_pData->xControl.clear();
+ }
+
+
+//........................................................................
+} // namespace pcr
+//........................................................................
diff --git a/extensions/source/propctrlr/propertycontrolextender.hxx b/extensions/source/propctrlr/propertycontrolextender.hxx
new file mode 100644
index 000000000000..0e74284c6f9b
--- /dev/null
+++ b/extensions/source/propctrlr/propertycontrolextender.hxx
@@ -0,0 +1,74 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+#ifndef EXTENSIONS_PROPERTYCONTROLEXTENDER_HXX
+#define EXTENSIONS_PROPERTYCONTROLEXTENDER_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/XKeyListener.hpp>
+#include <com/sun/star/inspection/XPropertyControl.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/implbase1.hxx>
+
+#include <memory>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= PropertyControlExtender
+ //====================================================================
+ struct PropertyControlExtender_Data;
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::awt::XKeyListener
+ > PropertyControlExtender_Base;
+ class PropertyControlExtender : public PropertyControlExtender_Base
+ {
+ public:
+ PropertyControlExtender(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& _rxObservedControl
+ );
+
+ // XKeyListener
+ virtual void SAL_CALL keyPressed( const ::com::sun::star::awt::KeyEvent& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL keyReleased( const ::com::sun::star::awt::KeyEvent& e ) throw (::com::sun::star::uno::RuntimeException);
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ virtual ~PropertyControlExtender();
+
+ private:
+ ::std::auto_ptr< PropertyControlExtender_Data > m_pData;
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_PROPERTYCONTROLEXTENDER_HXX
diff --git a/extensions/source/propctrlr/propertyeditor.cxx b/extensions/source/propctrlr/propertyeditor.cxx
new file mode 100644
index 000000000000..64be3ae20e9f
--- /dev/null
+++ b/extensions/source/propctrlr/propertyeditor.cxx
@@ -0,0 +1,542 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "propertyeditor.hxx"
+#include "browserpage.hxx"
+#include "linedescriptor.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+#include <tools/debug.hxx>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ #define LAYOUT_BORDER_LEFT 3
+ #define LAYOUT_BORDER_TOP 3
+ #define LAYOUT_BORDER_RIGHT 3
+ #define LAYOUT_BORDER_BOTTOM 3
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::inspection::XPropertyControl;
+ using ::com::sun::star::uno::Reference;
+ /** === end UNO using === **/
+
+ //==================================================================
+ // class OPropertyEditor
+ //==================================================================
+ DBG_NAME(OPropertyEditor)
+ //------------------------------------------------------------------
+ OPropertyEditor::OPropertyEditor( Window* pParent, WinBits nWinStyle)
+ :Control(pParent, nWinStyle)
+ ,m_aTabControl( this )
+ ,m_nNextId(1)
+ ,m_bHasHelpSection( false )
+ ,m_nMinHelpLines( 0 )
+ ,m_nMaxHelpLines( 0 )
+ {
+ DBG_CTOR(OPropertyEditor,NULL);
+
+ m_aTabControl.Show();
+ m_aTabControl.SetDeactivatePageHdl(LINK(this, OPropertyEditor, OnPageDeactivate));
+ m_aTabControl.SetActivatePageHdl(LINK(this, OPropertyEditor, OnPageActivate));
+ m_aTabControl.SetBackground(GetBackground());
+ m_aTabControl.SetPaintTransparent(sal_True);
+ }
+
+ //------------------------------------------------------------------
+ OPropertyEditor::~OPropertyEditor()
+ {
+ Hide();
+ ClearAll();
+ DBG_DTOR(OPropertyEditor,NULL);
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::ClearAll()
+ {
+ m_nNextId=1;
+ sal_uInt16 nCount = m_aTabControl.GetPageCount();
+ for(long i = nCount-1; i >= 0; --i)
+ {
+ sal_uInt16 nID = m_aTabControl.GetPageId((sal_uInt16)i);
+ OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(nID));
+ if (pPage)
+ {
+ pPage->EnableInput(sal_False);
+ m_aTabControl.RemovePage(nID);
+ delete pPage;
+ }
+ }
+ m_aTabControl.Clear();
+
+ {
+ MapStringToPageId aEmpty;
+ m_aPropertyPageIds.swap( aEmpty );
+ }
+
+ while ( !m_aHiddenPages.empty() )
+ {
+ delete m_aHiddenPages.begin()->second.pPage;
+ m_aHiddenPages.erase( m_aHiddenPages.begin() );
+ }
+ }
+
+ //------------------------------------------------------------------
+ sal_Int32 OPropertyEditor::getMinimumHeight()
+ {
+ sal_Int32 nMinHeight( LAYOUT_BORDER_TOP + LAYOUT_BORDER_BOTTOM );
+
+ if ( m_aTabControl.GetPageCount() > 0 )
+ {
+ sal_uInt16 nFirstID = m_aTabControl.GetPageId( 0 );
+
+ // reserve space for the tabs themself
+ Rectangle aTabArea( m_aTabControl.GetTabBounds( nFirstID ) );
+ nMinHeight += aTabArea.GetHeight();
+
+ // ask the page how much it requires
+ OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( nFirstID ) );
+ if ( pPage )
+ nMinHeight += pPage->getMinimumHeight();
+ }
+ else
+ nMinHeight += 250; // arbitrary ...
+
+ return nMinHeight;
+ }
+
+ //------------------------------------------------------------------
+ sal_Int32 OPropertyEditor::getMinimumWidth()
+ {
+ sal_uInt16 nCount = m_aTabControl.GetPageCount();
+ sal_Int32 nPageMinWidth = 0;
+ for(long i = nCount-1; i >= 0; --i)
+ {
+ sal_uInt16 nID = m_aTabControl.GetPageId((sal_uInt16)i);
+ OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(nID));
+ if (pPage)
+ {
+ sal_Int32 nCurPageMinWidth = pPage->getMinimumWidth();
+ if( nCurPageMinWidth > nPageMinWidth )
+ nPageMinWidth = nCurPageMinWidth;
+ }
+ }
+ return nPageMinWidth+6;
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::CommitModified()
+ {
+ // commit all of my pages, if necessary
+
+ sal_uInt16 nCount = m_aTabControl.GetPageCount();
+ for ( sal_uInt16 i=0; i<nCount; ++i )
+ {
+ sal_uInt16 nID = m_aTabControl.GetPageId( i );
+ OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( nID ) );
+
+ if ( pPage && pPage->getListBox().IsModified() )
+ pPage->getListBox().CommitModified();
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::GetFocus()
+ {
+ m_aTabControl.GrabFocus();
+ }
+
+ //------------------------------------------------------------------
+ OBrowserPage* OPropertyEditor::getPage( const ::rtl::OUString& _rPropertyName )
+ {
+ OBrowserPage* pPage = NULL;
+ MapStringToPageId::const_iterator aPropertyPageIdPos = m_aPropertyPageIds.find( _rPropertyName );
+ if ( aPropertyPageIdPos != m_aPropertyPageIds.end() )
+ pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( aPropertyPageIdPos->second ) );
+ return pPage;
+ }
+
+ //------------------------------------------------------------------
+ const OBrowserPage* OPropertyEditor::getPage( const ::rtl::OUString& _rPropertyName ) const
+ {
+ return const_cast< OPropertyEditor* >( this )->getPage( _rPropertyName );
+ }
+
+ //------------------------------------------------------------------
+ OBrowserPage* OPropertyEditor::getPage( sal_uInt16& _rPageId )
+ {
+ return static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( _rPageId ) );
+ }
+
+ //------------------------------------------------------------------
+ const OBrowserPage* OPropertyEditor::getPage( sal_uInt16& _rPageId ) const
+ {
+ return const_cast< OPropertyEditor* >( this )->getPage( _rPageId );
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::Resize()
+ {
+ Rectangle aPlayground(
+ Point( LAYOUT_BORDER_LEFT, LAYOUT_BORDER_TOP ),
+ Size(
+ GetOutputSizePixel().Width() - LAYOUT_BORDER_LEFT - LAYOUT_BORDER_RIGHT,
+ GetOutputSizePixel().Height() - LAYOUT_BORDER_TOP - LAYOUT_BORDER_BOTTOM
+ )
+ );
+
+ Rectangle aTabArea( aPlayground );
+ m_aTabControl.SetPosSizePixel( aTabArea.TopLeft(), aTabArea.GetSize() );
+ }
+
+ //------------------------------------------------------------------
+ sal_uInt16 OPropertyEditor::AppendPage( const String & _rText, const rtl::OString& _rHelpId )
+ {
+ // obtain a new id
+ sal_uInt16 nId = m_nNextId++;
+ // insert the id
+ m_aTabControl.InsertPage(nId, _rText);
+
+ // create a new page
+ OBrowserPage* pPage = new OBrowserPage(&m_aTabControl);
+ pPage->SetText( _rText );
+ // some knittings
+ pPage->SetSizePixel(m_aTabControl.GetTabPageSizePixel());
+ pPage->getListBox().SetListener(m_pListener);
+ pPage->getListBox().SetObserver(m_pObserver);
+ pPage->getListBox().EnableHelpSection( m_bHasHelpSection );
+ pPage->getListBox().SetHelpLineLimites( m_nMinHelpLines, m_nMaxHelpLines );
+ pPage->SetHelpId( _rHelpId );
+
+ // immediately activate the page
+ m_aTabControl.SetTabPage(nId, pPage);
+ m_aTabControl.SetCurPageId(nId);
+
+ return nId;
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::SetHelpId( const rtl::OString& rHelpId )
+ {
+ Control::SetHelpId("");
+ m_aTabControl.SetHelpId(rHelpId);
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::RemovePage(sal_uInt16 nID)
+ {
+ OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(nID));
+
+ if (pPage)
+ pPage->EnableInput(sal_False);
+ m_aTabControl.RemovePage(nID);
+ if (pPage)
+ delete pPage;
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::SetPage(sal_uInt16 nId)
+ {
+ m_aTabControl.SetCurPageId(nId);
+ }
+
+ //------------------------------------------------------------------
+ sal_uInt16 OPropertyEditor::GetCurPage()
+ {
+ if(m_aTabControl.GetPageCount()>0)
+ return m_aTabControl.GetCurPageId();
+ else
+ return 0;
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::Update(const ::std::mem_fun_t<void,OBrowserListBox>& _aUpdateFunction)
+ {
+ // forward this to all our pages
+ sal_uInt16 nCount = m_aTabControl.GetPageCount();
+ for (sal_uInt16 i=0;i<nCount;++i)
+ {
+ sal_uInt16 nID = m_aTabControl.GetPageId(i);
+ OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(nID));
+ if (pPage)
+ _aUpdateFunction(&pPage->getListBox());
+ }
+ }
+ //------------------------------------------------------------------
+ void OPropertyEditor::EnableUpdate()
+ {
+ Update(::std::mem_fun(&OBrowserListBox::EnableUpdate));
+ }
+ //------------------------------------------------------------------
+ void OPropertyEditor::DisableUpdate()
+ {
+ Update(::std::mem_fun(&OBrowserListBox::DisableUpdate));
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::forEachPage( PageOperation _pOperation, const void* _pArgument )
+ {
+ sal_uInt16 nCount = m_aTabControl.GetPageCount();
+ for ( sal_uInt16 i=0; i<nCount; ++i )
+ {
+ sal_uInt16 nID = m_aTabControl.GetPageId(i);
+ OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( nID ) );
+ if ( !pPage )
+ continue;
+ (this->*_pOperation)( *pPage, _pArgument );
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::setPageLineListener( OBrowserPage& _rPage, const void* )
+ {
+ _rPage.getListBox().SetListener( m_pListener );
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::SetLineListener(IPropertyLineListener* _pListener)
+ {
+ m_pListener = _pListener;
+ forEachPage( &OPropertyEditor::setPageLineListener );
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::setPageControlObserver( OBrowserPage& _rPage, const void* )
+ {
+ _rPage.getListBox().SetObserver( m_pObserver );
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::SetControlObserver( IPropertyControlObserver* _pObserver )
+ {
+ m_pObserver = _pObserver;
+ forEachPage( &OPropertyEditor::setPageControlObserver );
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::EnableHelpSection( bool _bEnable )
+ {
+ m_bHasHelpSection = _bEnable;
+ forEachPage( &OPropertyEditor::enableHelpSection );
+ }
+
+ //------------------------------------------------------------------
+ bool OPropertyEditor::HasHelpSection() const
+ {
+ return m_bHasHelpSection;
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::SetHelpText( const ::rtl::OUString& _rHelpText )
+ {
+ forEachPage( &OPropertyEditor::setHelpSectionText, &_rHelpText );
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::SetHelpLineLimites( sal_Int32 _nMinLines, sal_Int32 _nMaxLines )
+ {
+ m_nMinHelpLines = _nMinLines;
+ m_nMaxHelpLines = _nMaxLines;
+ forEachPage( &OPropertyEditor::setHelpLineLimits );
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::enableHelpSection( OBrowserPage& _rPage, const void* )
+ {
+ _rPage.getListBox().EnableHelpSection( m_bHasHelpSection );
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::setHelpSectionText( OBrowserPage& _rPage, const void* _pPointerToOUString )
+ {
+ OSL_ENSURE( _pPointerToOUString, "OPropertyEditor::setHelpSectionText: invalid argument!" );
+ if ( !_pPointerToOUString )
+ return;
+
+ const ::rtl::OUString& rText( *(const ::rtl::OUString*)_pPointerToOUString );
+ _rPage.getListBox().SetHelpText( rText );
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::setHelpLineLimits( OBrowserPage& _rPage, const void* )
+ {
+ _rPage.getListBox().SetHelpLineLimites( m_nMinHelpLines, m_nMaxHelpLines );
+ }
+
+ //------------------------------------------------------------------
+ sal_uInt16 OPropertyEditor::InsertEntry( const OLineDescriptor& rData, sal_uInt16 _nPageId, sal_uInt16 nPos )
+ {
+ // let the current page handle this
+ OBrowserPage* pPage = getPage( _nPageId );
+ DBG_ASSERT( pPage, "OPropertyEditor::InsertEntry: don't have such a page!" );
+ if ( !pPage )
+ return LISTBOX_ENTRY_NOTFOUND;
+
+ sal_uInt16 nEntry = pPage->getListBox().InsertEntry( rData, nPos );
+
+ OSL_ENSURE( m_aPropertyPageIds.find( rData.sName ) == m_aPropertyPageIds.end(),
+ "OPropertyEditor::InsertEntry: property already present in the map!" );
+ m_aPropertyPageIds.insert( MapStringToPageId::value_type( rData.sName, _nPageId ) );
+
+ return nEntry;
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::RemoveEntry( const ::rtl::OUString& _rName )
+ {
+ OBrowserPage* pPage = getPage( _rName );
+ if ( pPage )
+ {
+ OSL_VERIFY( pPage->getListBox().RemoveEntry( _rName ) );
+
+ OSL_ENSURE( m_aPropertyPageIds.find( _rName ) != m_aPropertyPageIds.end(),
+ "OPropertyEditor::RemoveEntry: property not present in the map!" );
+ m_aPropertyPageIds.erase( _rName );
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::ChangeEntry( const OLineDescriptor& rData )
+ {
+ OBrowserPage* pPage = getPage( rData.sName );
+ if ( pPage )
+ pPage->getListBox().ChangeEntry( rData, EDITOR_LIST_REPLACE_EXISTING );
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::SetPropertyValue( const ::rtl::OUString& rEntryName, const Any& _rValue, bool _bUnknownValue )
+ {
+ OBrowserPage* pPage = getPage( rEntryName );
+ if ( pPage )
+ pPage->getListBox().SetPropertyValue( rEntryName, _rValue, _bUnknownValue );
+ }
+
+ //------------------------------------------------------------------
+ sal_uInt16 OPropertyEditor::GetPropertyPos( const ::rtl::OUString& rEntryName ) const
+ {
+ sal_uInt16 nVal=LISTBOX_ENTRY_NOTFOUND;
+ const OBrowserPage* pPage = getPage( rEntryName );
+ if ( pPage )
+ nVal = pPage->getListBox().GetPropertyPos( rEntryName );
+ return nVal;
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::ShowPropertyPage( sal_uInt16 _nPageId, bool _bShow )
+ {
+ if ( !_bShow )
+ {
+ sal_uInt16 nPagePos = m_aTabControl.GetPagePos( _nPageId );
+ if ( TAB_PAGE_NOTFOUND == nPagePos )
+ return;
+ DBG_ASSERT( m_aHiddenPages.find( _nPageId ) == m_aHiddenPages.end(), "OPropertyEditor::ShowPropertyPage: page already hidden!" );
+
+ m_aHiddenPages[ _nPageId ] = HiddenPage( nPagePos, m_aTabControl.GetTabPage( _nPageId ) );
+ m_aTabControl.RemovePage( _nPageId );
+ }
+ else
+ {
+ ::std::map< sal_uInt16, HiddenPage >::iterator aPagePos = m_aHiddenPages.find( _nPageId );
+ if ( aPagePos == m_aHiddenPages.end() )
+ return;
+
+ aPagePos->second.pPage->SetSizePixel( m_aTabControl.GetTabPageSizePixel() );
+ m_aTabControl.InsertPage( aPagePos->first, aPagePos->second.pPage->GetText(), aPagePos->second.nPos );
+ m_aTabControl.SetTabPage( aPagePos->first, aPagePos->second.pPage );
+
+ m_aHiddenPages.erase( aPagePos );
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::EnablePropertyControls( const ::rtl::OUString& _rEntryName, sal_Int16 _nControls, bool _bEnable )
+ {
+ for ( sal_uInt16 i = 0; i < m_aTabControl.GetPageCount(); ++i )
+ {
+ OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( m_aTabControl.GetPageId( i ) ) );
+ if ( pPage )
+ pPage->getListBox().EnablePropertyControls( _rEntryName, _nControls, _bEnable );
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::EnablePropertyLine( const ::rtl::OUString& _rEntryName, bool _bEnable )
+ {
+ for ( sal_uInt16 i = 0; i < m_aTabControl.GetPageCount(); ++i )
+ {
+ OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( m_aTabControl.GetPageId( i ) ) );
+ if ( pPage )
+ pPage->getListBox().EnablePropertyLine( _rEntryName, _bEnable );
+ }
+ }
+
+ //------------------------------------------------------------------
+ Reference< XPropertyControl > OPropertyEditor::GetPropertyControl(const ::rtl::OUString& rEntryName)
+ {
+ Reference< XPropertyControl > xControl;
+ // let the current page handle this
+ OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(m_aTabControl.GetCurPageId()));
+ if (pPage)
+ xControl = pPage->getListBox().GetPropertyControl(rEntryName);
+ return xControl;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK(OPropertyEditor, OnPageActivate, TabControl*, EMPTYARG)
+ {
+ if (m_aPageActivationHandler.IsSet())
+ m_aPageActivationHandler.Call(NULL);
+ return 0L;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK(OPropertyEditor, OnPageDeactivate, TabControl*, EMPTYARG)
+ {
+ // commit the data on the current (to-be-decativated) tab page
+ // (79404)
+ sal_Int32 nCurrentId = m_aTabControl.GetCurPageId();
+ OBrowserPage* pCurrentPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage((sal_uInt16)nCurrentId));
+ if ( !pCurrentPage )
+ return 1L;
+
+ if ( pCurrentPage->getListBox().IsModified() )
+ pCurrentPage->getListBox().CommitModified();
+
+ return 1L;
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+
diff --git a/extensions/source/propctrlr/propertyeditor.hxx b/extensions/source/propctrlr/propertyeditor.hxx
new file mode 100644
index 000000000000..6affea7376d3
--- /dev/null
+++ b/extensions/source/propctrlr/propertyeditor.hxx
@@ -0,0 +1,163 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_PROPERTYEDITOR_HXX_
+#define _EXTENSIONS_PROPCTRLR_PROPERTYEDITOR_HXX_
+
+#include "pcrcommon.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/XPropertyControl.hpp>
+/** === end UNO includes === **/
+#include <vcl/tabctrl.hxx>
+#include <comphelper/stl_types.hxx>
+#include <boost/mem_fn.hpp>
+#include <map>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ class IPropertyLineListener;
+ class IPropertyControlObserver;
+ class OBrowserPage;
+ struct OLineDescriptor;
+ class OBrowserListBox;
+
+ //========================================================================
+ //= OPropertyEditor
+ //========================================================================
+ class OPropertyEditor : public Control
+ {
+ private:
+ typedef ::std::map< ::rtl::OUString, sal_uInt16 > MapStringToPageId;
+ struct HiddenPage
+ {
+ sal_uInt16 nPos;
+ TabPage* pPage;
+ HiddenPage() : nPos( 0 ), pPage( NULL ) { }
+ HiddenPage( sal_uInt16 _nPos, TabPage* _pPage ) : nPos( _nPos ), pPage( _pPage ) { }
+ };
+
+ private:
+ TabControl m_aTabControl;
+ IPropertyLineListener* m_pListener;
+ IPropertyControlObserver* m_pObserver;
+ sal_uInt16 m_nNextId;
+ Link m_aPageActivationHandler;
+ bool m_bHasHelpSection;
+ sal_Int32 m_nMinHelpLines;
+ sal_Int32 m_nMaxHelpLines;
+
+ MapStringToPageId m_aPropertyPageIds;
+ ::std::map< sal_uInt16, HiddenPage > m_aHiddenPages;
+
+ protected:
+ void Resize();
+ void GetFocus();
+
+ public:
+ OPropertyEditor (Window* pParent, WinBits nWinStyle = WB_DIALOGCONTROL);
+
+ ~OPropertyEditor();
+
+ void EnableUpdate();
+ void DisableUpdate();
+
+ void SetLineListener( IPropertyLineListener* );
+ void SetControlObserver( IPropertyControlObserver* );
+
+ void EnableHelpSection( bool _bEnable );
+ bool HasHelpSection() const;
+ void SetHelpText( const ::rtl::OUString& _rHelpText );
+ void SetHelpLineLimites( sal_Int32 _nMinLines, sal_Int32 _nMaxLines );
+
+ void SetHelpId( const rtl::OString& sHelpId );
+ sal_uInt16 AppendPage( const String& r, const rtl::OString& _rHelpId );
+ void SetPage( sal_uInt16 );
+ void RemovePage(sal_uInt16 nID);
+ sal_uInt16 GetCurPage();
+ void ClearAll();
+
+ void SetPropertyValue(const ::rtl::OUString& _rEntryName, const ::com::sun::star::uno::Any& _rValue, bool _bUnknownValue );
+ ::com::sun::star::uno::Any GetPropertyValue(const ::rtl::OUString& rEntryName ) const;
+ sal_uInt16 GetPropertyPos(const ::rtl::OUString& rEntryName ) const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
+ GetPropertyControl( const ::rtl::OUString& rEntryName );
+ void EnablePropertyLine( const ::rtl::OUString& _rEntryName, bool _bEnable );
+ void EnablePropertyControls( const ::rtl::OUString& _rEntryName, sal_Int16 _nControls, bool _bEnable );
+
+ void ShowPropertyPage( sal_uInt16 _nPageId, bool _bShow );
+
+ sal_uInt16 InsertEntry( const OLineDescriptor&, sal_uInt16 _nPageId, sal_uInt16 nPos = EDITOR_LIST_APPEND );
+ void RemoveEntry( const ::rtl::OUString& _rName );
+ void ChangeEntry( const OLineDescriptor& );
+
+ void setPageActivationHandler(const Link& _rHdl) { m_aPageActivationHandler = _rHdl; }
+ Link getPageActivationHandler() const { return m_aPageActivationHandler; }
+
+ // #95343# -------------------------------
+ sal_Int32 getMinimumWidth();
+ sal_Int32 getMinimumHeight();
+
+ void CommitModified();
+
+ protected:
+ using Window::SetHelpText;
+ using Window::Update;
+
+ private:
+ OBrowserPage* getPage( sal_uInt16& _rPageId );
+ const OBrowserPage* getPage( sal_uInt16& _rPageId ) const;
+
+ OBrowserPage* getPage( const ::rtl::OUString& _rPropertyName );
+ const OBrowserPage* getPage( const ::rtl::OUString& _rPropertyName ) const;
+
+ void Update(const ::std::mem_fun_t<void,OBrowserListBox>& _aUpdateFunction);
+
+ typedef void (OPropertyEditor::*PageOperation)( OBrowserPage&, const void* );
+ void forEachPage( PageOperation _pOperation, const void* _pArgument = NULL );
+
+ void setPageLineListener( OBrowserPage& _rPage, const void* );
+ void setPageControlObserver( OBrowserPage& _rPage, const void* );
+ void enableHelpSection( OBrowserPage& _rPage, const void* );
+ void setHelpSectionText( OBrowserPage& _rPage, const void* _pPointerToOUString );
+ void setHelpLineLimits( OBrowserPage& _rPage, const void* );
+
+ protected:
+ DECL_LINK(OnPageDeactivate, TabControl*);
+ DECL_LINK(OnPageActivate, TabControl*);
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_PROPERTYEDITOR_HXX_
+
+
diff --git a/extensions/source/propctrlr/propertyhandler.cxx b/extensions/source/propctrlr/propertyhandler.cxx
new file mode 100644
index 000000000000..ba40fabdcd17
--- /dev/null
+++ b/extensions/source/propctrlr/propertyhandler.cxx
@@ -0,0 +1,464 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "propertyhandler.hxx"
+#include "formmetadata.hxx"
+#include "formbrowsertools.hxx"
+#include "handlerhelper.hxx"
+#include "formstrings.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/lang/NullPointerException.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+/** === end UNO includes === **/
+
+#include <tools/debug.hxx>
+#include <unotools/confignode.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <unotools/syslocale.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
+#include <algorithm>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::awt;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::script;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::inspection;
+ using namespace ::comphelper;
+
+ //====================================================================
+ //= PropertyHandler
+ //====================================================================
+ DBG_NAME( PropertyHandler )
+ //--------------------------------------------------------------------
+ PropertyHandler::PropertyHandler( const Reference< XComponentContext >& _rxContext )
+ :PropertyHandler_Base( m_aMutex )
+ ,m_bSupportedPropertiesAreKnown( false )
+ ,m_aPropertyListeners( m_aMutex )
+ ,m_aContext( _rxContext )
+ ,m_pInfoService ( new OPropertyInfoService )
+ {
+ DBG_CTOR( PropertyHandler, NULL );
+
+ m_xTypeConverter = Reference< XTypeConverter >(
+ m_aContext.createComponent( "com.sun.star.script.Converter" ),
+ UNO_QUERY_THROW
+ );
+ }
+
+ //--------------------------------------------------------------------
+ PropertyHandler::~PropertyHandler()
+ {
+ DBG_DTOR( PropertyHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyHandler::inspect( const Reference< XInterface >& _rxIntrospectee ) throw (RuntimeException, NullPointerException)
+ {
+ if ( !_rxIntrospectee.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Reference< XPropertySet > xNewComponent( _rxIntrospectee, UNO_QUERY );
+ if ( xNewComponent == m_xComponent )
+ return;
+
+ // remove all old property change listeners
+ ::std::auto_ptr< ::cppu::OInterfaceIteratorHelper > removeListener = m_aPropertyListeners.createIterator();
+ ::std::auto_ptr< ::cppu::OInterfaceIteratorHelper > readdListener = m_aPropertyListeners.createIterator(); // will copy the container as needed
+ while ( removeListener->hasMoreElements() )
+ removePropertyChangeListener( static_cast< XPropertyChangeListener* >( removeListener->next() ) );
+ OSL_ENSURE( m_aPropertyListeners.empty(), "PropertyHandler::inspect: derived classes are expected to forward the removePropertyChangeListener call to their base class (me)!" );
+
+ // remember the new component, and give derived classes the chance to react on it
+ m_xComponent = xNewComponent;
+ onNewComponent();
+
+ // add the listeners, again
+ while ( readdListener->hasMoreElements() )
+ addPropertyChangeListener( static_cast< XPropertyChangeListener* >( readdListener->next() ) );
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyHandler::onNewComponent()
+ {
+ if ( m_xComponent.is() )
+ m_xComponentPropertyInfo = m_xComponent->getPropertySetInfo();
+ else
+ m_xComponentPropertyInfo.clear();
+
+ m_bSupportedPropertiesAreKnown = false;
+ m_aSupportedProperties.realloc( 0 );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Property > SAL_CALL PropertyHandler::getSupportedProperties() throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_bSupportedPropertiesAreKnown )
+ {
+ m_aSupportedProperties = doDescribeSupportedProperties();
+ m_bSupportedPropertiesAreKnown = true;
+ }
+ return (Sequence< Property >)m_aSupportedProperties;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL PropertyHandler::getSupersededProperties( ) throw (RuntimeException)
+ {
+ return Sequence< ::rtl::OUString >();
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL PropertyHandler::getActuatingProperties( ) throw (RuntimeException)
+ {
+ return Sequence< ::rtl::OUString >();
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL PropertyHandler::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId = m_pInfoService->getPropertyId( _rPropertyName );
+ Property aProperty( impl_getPropertyFromName_throw( _rPropertyName ) );
+
+ Any aPropertyValue;
+ if ( !_rControlValue.hasValue() )
+ // NULL is converted to NULL
+ return aPropertyValue;
+
+ if ( ( m_pInfoService->getPropertyUIFlags( nPropId ) & PROP_FLAG_ENUM ) != 0 )
+ {
+ ::rtl::OUString sControlValue;
+ OSL_VERIFY( _rControlValue >>= sControlValue );
+ ::rtl::Reference< IPropertyEnumRepresentation > aEnumConversion(
+ new DefaultEnumRepresentation( *m_pInfoService, aProperty.Type, nPropId ) );
+ // TODO/UNOize: cache those converters?
+ aEnumConversion->getValueFromDescription( sControlValue, aPropertyValue );
+ }
+ else
+ aPropertyValue = PropertyHandlerHelper::convertToPropertyValue(
+ m_aContext.getContext(),m_xTypeConverter, aProperty, _rControlValue );
+ return aPropertyValue;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL PropertyHandler::convertToControlValue( const ::rtl::OUString& _rPropertyName, const Any& _rPropertyValue, const Type& _rControlValueType ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId = m_pInfoService->getPropertyId( _rPropertyName );
+
+ if ( ( m_pInfoService->getPropertyUIFlags( nPropId ) & PROP_FLAG_ENUM ) != 0 )
+ {
+ DBG_ASSERT( _rControlValueType.getTypeClass() == TypeClass_STRING, "PropertyHandler::convertToControlValue: ENUM, but not STRING?" );
+
+ ::rtl::Reference< IPropertyEnumRepresentation > aEnumConversion(
+ new DefaultEnumRepresentation( *m_pInfoService, _rPropertyValue.getValueType(), nPropId ) );
+ // TODO/UNOize: cache those converters?
+ return makeAny( aEnumConversion->getDescriptionForValue( _rPropertyValue ) );
+ }
+
+ return PropertyHandlerHelper::convertToControlValue(
+ m_aContext.getContext(),m_xTypeConverter, _rPropertyValue, _rControlValueType );
+ }
+
+ //--------------------------------------------------------------------
+ PropertyState SAL_CALL PropertyHandler::getPropertyState( const ::rtl::OUString& /*_rPropertyName*/ ) throw (UnknownPropertyException, RuntimeException)
+ {
+ return PropertyState_DIRECT_VALUE;
+ }
+
+ //--------------------------------------------------------------------
+ LineDescriptor SAL_CALL PropertyHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName,
+ const Reference< XPropertyControlFactory >& _rxControlFactory )
+ throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ if ( !_rxControlFactory.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+ const Property& rProperty( impl_getPropertyFromId_throw( nPropId ) );
+
+ LineDescriptor aDescriptor;
+ if ( ( m_pInfoService->getPropertyUIFlags( nPropId ) & PROP_FLAG_ENUM ) != 0 )
+ {
+ aDescriptor.Control = PropertyHandlerHelper::createListBoxControl(
+ _rxControlFactory, m_pInfoService->getPropertyEnumRepresentations( nPropId ),
+ PropertyHandlerHelper::requiresReadOnlyControl( rProperty.Attributes ), sal_False );
+ }
+ else
+ PropertyHandlerHelper::describePropertyLine( rProperty, aDescriptor, _rxControlFactory );
+
+ aDescriptor.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( nPropId ) );
+ aDescriptor.DisplayName = m_pInfoService->getPropertyTranslation( nPropId );
+
+ if ( ( m_pInfoService->getPropertyUIFlags( nPropId ) & PROP_FLAG_DATA_PROPERTY ) != 0 )
+ aDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Data" ) );
+ else
+ aDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "General" ) );
+ return aDescriptor;
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL PropertyHandler::isComposable( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return m_pInfoService->isComposeable( _rPropertyName );
+ }
+
+ //--------------------------------------------------------------------
+ InteractiveSelectionResult SAL_CALL PropertyHandler::onInteractivePropertySelection( const ::rtl::OUString& /*_rPropertyName*/, sal_Bool /*_bPrimary*/, Any& /*_rData*/, const Reference< XObjectInspectorUI >& /*_rxInspectorUI*/ ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ DBG_ERROR( "PropertyHandler::onInteractivePropertySelection: not implemented!" );
+ return InteractiveSelectionResult_Cancelled;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& /*_rActuatingPropertyName*/, const Any& /*_rNewValue*/, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& /*_rxInspectorUI*/, sal_Bool /*_bFirstTimeInit*/ ) throw (NullPointerException, RuntimeException)
+ {
+ DBG_ERROR( "PropertyHandler::actuatingPropertyChanged: not implemented!" );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyHandler::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !_rxListener.is() )
+ throw NullPointerException();
+ m_aPropertyListeners.addListener( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyHandler::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_aPropertyListeners.removeListener( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL PropertyHandler::suspend( sal_Bool /*_bSuspend*/ ) throw (RuntimeException)
+ {
+ return sal_True;
+ }
+
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XCOMPONENT( PropertyHandler, PropertyHandler_Base )
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyHandler::disposing()
+ {
+ m_xComponent.clear();
+ m_aPropertyListeners.clear();
+ m_xTypeConverter.clear();
+ m_aSupportedProperties.realloc( 0 );
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyHandler::firePropertyChange( const ::rtl::OUString& _rPropName, PropertyId _nPropId, const Any& _rOldValue, const Any& _rNewValue ) SAL_THROW(())
+ {
+ PropertyChangeEvent aEvent;
+ aEvent.Source = m_xComponent;
+ aEvent.PropertyHandle = _nPropId;
+ aEvent.PropertyName = _rPropName;
+ aEvent.OldValue = _rOldValue;
+ aEvent.NewValue = _rNewValue;
+ m_aPropertyListeners.notify( aEvent, &XPropertyChangeListener::propertyChange );
+ }
+
+ //--------------------------------------------------------------------
+ const Property* PropertyHandler::impl_getPropertyFromId_nothrow( PropertyId _nPropId ) const
+ {
+ const_cast< PropertyHandler* >( this )->getSupportedProperties();
+ const Property* pFound = ::std::find_if( m_aSupportedProperties.begin(), m_aSupportedProperties.end(),
+ FindPropertyByHandle( _nPropId )
+ );
+ if ( pFound != m_aSupportedProperties.end() )
+ return &(*pFound);
+ return NULL;
+ }
+
+ //--------------------------------------------------------------------
+ const Property& PropertyHandler::impl_getPropertyFromId_throw( PropertyId _nPropId ) const
+ {
+ const Property* pProperty = impl_getPropertyFromId_nothrow( _nPropId );
+ if ( !pProperty )
+ throw UnknownPropertyException();
+
+ return *pProperty;
+ }
+
+ //--------------------------------------------------------------------
+ const Property& PropertyHandler::impl_getPropertyFromName_throw( const ::rtl::OUString& _rPropertyName ) const
+ {
+ const_cast< PropertyHandler* >( this )->getSupportedProperties();
+ StlSyntaxSequence< Property >::const_iterator pFound = ::std::find_if( m_aSupportedProperties.begin(), m_aSupportedProperties.end(),
+ FindPropertyByName( _rPropertyName )
+ );
+ if ( pFound == m_aSupportedProperties.end() )
+ throw UnknownPropertyException();
+
+ return *pFound;
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyHandler::implAddPropertyDescription( ::std::vector< Property >& _rProperties, const ::rtl::OUString& _rPropertyName, const Type& _rType, sal_Int16 _nAttribs ) const
+ {
+ _rProperties.push_back( Property(
+ _rPropertyName,
+ m_pInfoService->getPropertyId( _rPropertyName ),
+ _rType,
+ _nAttribs
+ ) );
+ }
+
+ //------------------------------------------------------------------------
+ Window* PropertyHandler::impl_getDefaultDialogParent_nothrow() const
+ {
+ return PropertyHandlerHelper::getDialogParentWindow( m_aContext );
+ }
+
+ //------------------------------------------------------------------------
+ PropertyId PropertyHandler::impl_getPropertyId_throw( const ::rtl::OUString& _rPropertyName ) const
+ {
+ PropertyId nPropId = m_pInfoService->getPropertyId( _rPropertyName );
+ if ( nPropId == -1 )
+ throw UnknownPropertyException();
+ return nPropId;
+ }
+
+ //------------------------------------------------------------------------
+ void PropertyHandler::impl_setContextDocumentModified_nothrow() const
+ {
+ Reference< XModifiable > xModifiable( impl_getContextDocument_nothrow(), UNO_QUERY );
+ if ( xModifiable.is() )
+ xModifiable->setModified( sal_True );
+ }
+
+ //------------------------------------------------------------------------
+ bool PropertyHandler::impl_componentHasProperty_throw( const ::rtl::OUString& _rPropName ) const
+ {
+ return m_xComponentPropertyInfo.is() && m_xComponentPropertyInfo->hasPropertyByName( _rPropName );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int16 PropertyHandler::impl_getDocumentMeasurementUnit_throw() const
+ {
+ FieldUnit eUnit = FUNIT_NONE;
+
+ Reference< XServiceInfo > xDocumentSI( impl_getContextDocument_nothrow(), UNO_QUERY );
+ OSL_ENSURE( xDocumentSI.is(), "PropertyHandlerHelper::impl_getDocumentMeasurementUnit_throw: No context document - where do I live?" );
+ if ( xDocumentSI.is() )
+ {
+ // determine the application type we live in
+ ::rtl::OUString sConfigurationLocation;
+ ::rtl::OUString sConfigurationProperty;
+ if ( xDocumentSI->supportsService( SERVICE_WEB_DOCUMENT ) )
+ { // writer
+ sConfigurationLocation = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.WriterWeb/Layout/Other" ) );
+ sConfigurationProperty = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MeasureUnit" ) );
+ }
+ else if ( xDocumentSI->supportsService( SERVICE_TEXT_DOCUMENT ) )
+ { // writer
+ sConfigurationLocation = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Writer/Layout/Other" ) );
+ sConfigurationProperty = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MeasureUnit" ) );
+ }
+ else if ( xDocumentSI->supportsService( SERVICE_SPREADSHEET_DOCUMENT ) )
+ { // calc
+ sConfigurationLocation = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Calc/Layout/Other/MeasureUnit" ) );
+ sConfigurationProperty = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Metric" ) );
+ }
+ else if ( xDocumentSI->supportsService( SERVICE_DRAWING_DOCUMENT ) )
+ {
+ sConfigurationLocation = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Draw/Layout/Other/MeasureUnit" ) );
+ sConfigurationProperty = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Metric" ) );
+ }
+ else if ( xDocumentSI->supportsService( SERVICE_PRESENTATION_DOCUMENT ) )
+ {
+ sConfigurationLocation = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Impress/Layout/Other/MeasureUnit" ) );
+ sConfigurationProperty = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Metric" ) );
+ }
+
+ // read the measurement unit from the configuration
+ if ( sConfigurationLocation.getLength() && sConfigurationProperty.getLength() )
+ {
+ ::utl::OConfigurationTreeRoot aConfigTree( ::utl::OConfigurationTreeRoot::createWithServiceFactory(
+ m_aContext.getLegacyServiceFactory(), sConfigurationLocation, -1, ::utl::OConfigurationTreeRoot::CM_READONLY ) );
+ sal_Int32 nUnitAsInt = (sal_Int32)FUNIT_NONE;
+ aConfigTree.getNodeValue( sConfigurationProperty ) >>= nUnitAsInt;
+
+ // if this denotes a valid (and accepted) unit, then use it
+ if ( ( nUnitAsInt > FUNIT_NONE ) && ( nUnitAsInt <= FUNIT_100TH_MM ) )
+ eUnit = static_cast< FieldUnit >( nUnitAsInt );
+ }
+ }
+
+ if ( FUNIT_NONE == eUnit )
+ {
+ MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum();
+ eUnit = MEASURE_METRIC == eSystem ? FUNIT_CM : FUNIT_INCH;
+ }
+
+ return VCLUnoHelper::ConvertToMeasurementUnit( eUnit, 1 );
+ }
+
+ //====================================================================
+ //= PropertyHandlerComponent
+ //====================================================================
+ //------------------------------------------------------------------------
+ PropertyHandlerComponent::PropertyHandlerComponent( const Reference< XComponentContext >& _rxContext )
+ :PropertyHandler( _rxContext )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XINTERFACE2( PropertyHandlerComponent, PropertyHandler, PropertyHandlerComponent_Base )
+ IMPLEMENT_FORWARD_XTYPEPROVIDER2( PropertyHandlerComponent, PropertyHandler, PropertyHandlerComponent_Base )
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL PropertyHandlerComponent::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException)
+ {
+ StlSyntaxSequence< ::rtl::OUString > aAllServices( getSupportedServiceNames() );
+ return ::std::find( aAllServices.begin(), aAllServices.end(), ServiceName ) != aAllServices.end();
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
diff --git a/extensions/source/propctrlr/propertyhandler.hxx b/extensions/source/propctrlr/propertyhandler.hxx
new file mode 100644
index 000000000000..073debdccda5
--- /dev/null
+++ b/extensions/source/propctrlr/propertyhandler.hxx
@@ -0,0 +1,457 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYHANDLER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYHANDLER_HXX
+
+#include "pcrcomponentcontext.hxx"
+#include "pcrcommon.hxx"
+#ifndef _EXTENSIONS_PROPCTRLR_MODULEPCR_HXX_
+#include "modulepcr.hxx"
+#endif
+
+/** === begin UNO includes === **/
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/beans/PropertyState.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/Property.hpp>
+#include <com/sun/star/script/XTypeConverter.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/inspection/XPropertyHandler.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+/** === end UNO includes === **/
+#include <osl/interlck.h>
+#include <cppuhelper/compbase1.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <comphelper/uno3.hxx>
+
+#include <memory>
+#include <vector>
+
+namespace com { namespace sun { namespace star {
+ namespace inspection {
+ struct LineDescriptor;
+ class XPropertyControlFactory;
+ }
+} } }
+
+class Window;
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ typedef sal_Int32 PropertyId;
+
+ //====================================================================
+ //= PropertyHandler
+ //====================================================================
+ class OPropertyInfoService;
+ typedef ::cppu::WeakComponentImplHelper1 < ::com::sun::star::inspection::XPropertyHandler
+ > PropertyHandler_Base;
+ /** the base class for property handlers
+ */
+ class PropertyHandler : public PropertyHandler_Base
+ {
+ private:
+ /// cache for getSupportedProperties
+ mutable StlSyntaxSequence< ::com::sun::star::beans::Property >
+ m_aSupportedProperties;
+ mutable bool m_bSupportedPropertiesAreKnown;
+
+ /// helper which ensures that we can access resources as long as the instance lives
+ PcrClient m_aEnsureResAccess;
+
+ private:
+ /// the property listener which has been registered
+ PropertyChangeListeners m_aPropertyListeners;
+
+ protected:
+ mutable ::osl::Mutex m_aMutex;
+ /// the context in which the instance was created
+ ComponentContext m_aContext;
+ /// the component we're inspecting
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xComponent;
+ /// info about our component's properties
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > m_xComponentPropertyInfo;
+ /// type converter, needed on various occasions
+ ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter > m_xTypeConverter;
+ /// access to property meta data
+ ::std::auto_ptr< OPropertyInfoService > m_pInfoService;
+
+ protected:
+ PropertyHandler(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
+ );
+ ~PropertyHandler();
+
+ // default implementations for XPropertyHandler
+ virtual void SAL_CALL inspect( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxIntrospectee ) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::NullPointerException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL getSupportedProperties() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupersededProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rControlValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToControlValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rPropertyValue, const ::com::sun::star::uno::Type& _rControlValueType ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::LineDescriptor SAL_CALL describePropertyLine( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isComposable( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::InteractiveSelectionResult SAL_CALL onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, ::com::sun::star::uno::Any& _rData, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL suspend( sal_Bool _bSuspend ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XComponent
+ DECLARE_XCOMPONENT()
+ virtual void SAL_CALL disposing();
+
+ // own overridables
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
+ SAL_CALL doDescribeSupportedProperties() const = 0;
+
+ /// called when XPropertyHandler::inspect has been called, and we thus have a new component to inspect
+ virtual void onNewComponent();
+
+ protected:
+ /** fires the change in a property value to our listener (if any)
+ @see addPropertyChangeListener
+ */
+ void firePropertyChange( const ::rtl::OUString& _rPropName, PropertyId _nPropId,
+ const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Any& _rNewValue ) SAL_THROW(());
+
+ /** retrieves a window which can be used as parent for dialogs
+ */
+ Window* impl_getDefaultDialogParent_nothrow() const;
+
+ /** retrieves the property id for a given property name
+ @throw com::sun::star::beans::UnknownPropertyException
+ if the property name is not known to our ->m_pInfoService
+ */
+ PropertyId impl_getPropertyId_throw( const ::rtl::OUString& _rPropertyName ) const;
+
+ //-------------------------------------------------------------------------------
+ // helper for implementing doDescribeSupportedProperties
+ /** adds a description for the given string property to the given property vector
+ Most probably to be called from within getSupportedProperties
+ */
+ inline void addStringPropertyDescription(
+ ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
+ const ::rtl::OUString& _rPropertyName,
+ sal_Int16 _nAttribs = 0
+ ) const;
+
+ /** adds a description for the given int32 property to the given property vector
+ */
+ inline void addInt32PropertyDescription(
+ ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
+ const ::rtl::OUString& _rPropertyName,
+ sal_Int16 _nAttribs = 0
+ ) const;
+
+ /** adds a description for the given int16 property to the given property vector
+ */
+ inline void addInt16PropertyDescription(
+ ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
+ const ::rtl::OUString& _rPropertyName,
+ sal_Int16 _nAttribs = 0
+ ) const;
+
+ /** adds a description for the given double property to the given property vector
+ */
+ inline void addDoublePropertyDescription(
+ ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
+ const ::rtl::OUString& _rPropertyName,
+ sal_Int16 _nAttribs = 0
+ ) const;
+
+ /** adds a description for the given date property to the given property vector
+ */
+ inline void addDatePropertyDescription(
+ ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
+ const ::rtl::OUString& _rPropertyName,
+ sal_Int16 _nAttribs = 0
+ ) const;
+
+ /** adds a description for the given time property to the given property vector
+ */
+ inline void addTimePropertyDescription(
+ ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
+ const ::rtl::OUString& _rPropertyName,
+ sal_Int16 _nAttribs = 0
+ ) const;
+
+ /** adds a description for the given DateTime property to the given property vector
+ */
+ inline void addDateTimePropertyDescription(
+ ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
+ const ::rtl::OUString& _rPropertyName,
+ sal_Int16 _nAttribs = 0
+ ) const;
+
+ /// adds a Property, given by name only, to a given vector of Properties
+ void implAddPropertyDescription(
+ ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
+ const ::rtl::OUString& _rPropertyName,
+ const ::com::sun::star::uno::Type& _rType,
+ sal_Int16 _nAttribs = 0
+ ) const;
+
+ //-------------------------------------------------------------------------------
+ // helper for accessing and maintaining meta data about our supported properties
+
+ /** retrieves a property given by handle
+
+ @return
+ a pointer to the descriptor for the given properties, if it is one of our
+ supported properties, <NULL/> else.
+
+ @see doDescribeSupportedProperties
+ @see impl_getPropertyFromId_throw
+ */
+ const ::com::sun::star::beans::Property*
+ impl_getPropertyFromId_nothrow( PropertyId _nPropId ) const;
+
+ /** retrieves a property given by handle
+
+ @throws UnknownPropertyException
+ if the handler does not support a property with the given handle
+
+ @seealso doDescribeSupportedProperties
+ @see impl_getPropertyFromId_nothrow
+ */
+ const ::com::sun::star::beans::Property&
+ impl_getPropertyFromId_throw( PropertyId _nPropId ) const;
+
+ /** determines whether a given property id is part of our supported properties
+ @see getSupportedProperties
+ @see doDescribeSupportedProperties
+ */
+ inline bool impl_isSupportedProperty_nothrow( PropertyId _nPropId ) const
+ {
+ return impl_getPropertyFromId_nothrow( _nPropId ) != NULL;
+ }
+
+ /** retrieves a property given by name
+
+ @throws UnknownPropertyException
+ if the handler does not support a property with the given name
+
+ @seealso doDescribeSupportedProperties
+ */
+ const ::com::sun::star::beans::Property&
+ impl_getPropertyFromName_throw( const ::rtl::OUString& _rPropertyName ) const;
+
+ /** get the name of a property given by handle
+ */
+ inline ::rtl::OUString
+ impl_getPropertyNameFromId_nothrow( PropertyId _nPropId ) const;
+
+ /** returns the value of the ContextDocument property in the ComponentContext which was used to create
+ this handler.
+ */
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
+ impl_getContextDocument_nothrow() const
+ {
+ return ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >(
+ m_aContext.getContextValueByAsciiName( "ContextDocument" ), ::com::sun::star::uno::UNO_QUERY );
+ }
+
+ /** marks the context document as modified
+
+ @see impl_getContextDocument_nothrow
+ */
+ void impl_setContextDocumentModified_nothrow() const;
+
+ /// determines whether our component has a given property
+ bool impl_componentHasProperty_throw( const ::rtl::OUString& _rPropName ) const;
+
+ /** determines the default measure unit for the document in which our component lives
+ */
+ sal_Int16 impl_getDocumentMeasurementUnit_throw() const;
+
+ private:
+ PropertyHandler(); // never implemented
+ PropertyHandler( const PropertyHandler& ); // never implemented
+ PropertyHandler& operator=( const PropertyHandler& ); // never implemented
+ };
+
+ //--------------------------------------------------------------------
+ inline void PropertyHandler::addStringPropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
+ {
+ implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ), _nAttribs );
+ }
+
+ inline void PropertyHandler::addInt32PropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
+ {
+ implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< sal_Int32* >( NULL ) ), _nAttribs );
+ }
+
+ inline void PropertyHandler::addInt16PropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
+ {
+ implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< sal_Int16* >( NULL ) ), _nAttribs );
+ }
+
+ inline void PropertyHandler::addDoublePropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
+ {
+ implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< double* >( NULL ) ), _nAttribs );
+ }
+
+ inline void PropertyHandler::addDatePropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
+ {
+ implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< com::sun::star::util::Date* >( NULL ) ), _nAttribs );
+ }
+
+ inline void PropertyHandler::addTimePropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
+ {
+ implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< com::sun::star::util::Time* >( NULL ) ), _nAttribs );
+ }
+
+ inline void PropertyHandler::addDateTimePropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
+ {
+ implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< com::sun::star::util::DateTime* >( NULL ) ), _nAttribs );
+ }
+
+ inline ::rtl::OUString PropertyHandler::impl_getPropertyNameFromId_nothrow( PropertyId _nPropId ) const
+ {
+ const ::com::sun::star::beans::Property* pProp = impl_getPropertyFromId_nothrow( _nPropId );
+ return pProp ? pProp->Name : ::rtl::OUString();
+ }
+
+ //====================================================================
+ //= PropertyHandlerComponent
+ //====================================================================
+ typedef ::cppu::ImplHelper1 < ::com::sun::star::lang::XServiceInfo
+ > PropertyHandlerComponent_Base;
+ /** PropertyHandler implementation which additionally supports XServiceInfo
+ */
+ class PropertyHandlerComponent :public PropertyHandler
+ ,public PropertyHandlerComponent_Base
+ {
+ protected:
+ PropertyHandlerComponent(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
+ );
+
+ DECLARE_XINTERFACE()
+ DECLARE_XTYPEPROVIDER()
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException) = 0;
+ virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException) = 0;
+ };
+
+ //====================================================================
+ //= HandlerComponentBase
+ //====================================================================
+ /** a PropertyHandlerComponent implementation which routes XServiceInfo::getImplementationName and
+ XServiceInfo::getSupportedServiceNames to static versions of those methods, which are part of
+ the derived class.
+
+ Additionally, a method <member>Create</member> is provided which takes a component context, and returns a new
+ instance of the derived class. This <member>Create</member> is used to register the implementation
+ of the derived class at the <type>PcrModule</type>.
+
+ Well, every time we're talking about derived class, we in fact mean the template argument of
+ <type>HandlerComponentBase</type>. But usually this equals your derived class:
+ <pre>
+ class MyHandler;
+ typedef HandlerComponentBase< MyHandler > MyHandler_Base;
+ class MyHandler : MyHandler_Base
+ {
+ ...
+ public:
+ static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException);
+ };
+ </pre>
+ */
+ template < class HANDLER >
+ class HandlerComponentBase : public PropertyHandlerComponent
+ {
+ protected:
+ HandlerComponentBase( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext )
+ :PropertyHandlerComponent( _rxContext )
+ {
+ }
+
+ protected:
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
+
+ public:
+ /** registers the implementation of HANDLER at the <type>PcrModule</type>
+ */
+ static void registerImplementation();
+ };
+
+ //--------------------------------------------------------------------
+ template < class HANDLER >
+ ::rtl::OUString SAL_CALL HandlerComponentBase< HANDLER >::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ return HANDLER::getImplementationName_static();
+ }
+
+ //--------------------------------------------------------------------
+ template < class HANDLER >
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL HandlerComponentBase< HANDLER >::getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ return HANDLER::getSupportedServiceNames_static();
+ }
+
+ //--------------------------------------------------------------------
+ template < class HANDLER >
+ void HandlerComponentBase< HANDLER >::registerImplementation()
+ {
+ PcrModule::getInstance().registerImplementation(
+ HANDLER::getImplementationName_static(),
+ HANDLER::getSupportedServiceNames_static(),
+ HANDLER::Create
+ );
+ }
+
+ //--------------------------------------------------------------------
+ template < class HANDLER >
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL HandlerComponentBase< HANDLER >::Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext )
+ {
+ return *( new HANDLER( _rxContext ) );
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYHANDLER_HXX
+
diff --git a/extensions/source/propctrlr/propertyinfo.hxx b/extensions/source/propctrlr/propertyinfo.hxx
new file mode 100644
index 000000000000..3e188c25fe06
--- /dev/null
+++ b/extensions/source/propctrlr/propertyinfo.hxx
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_PROPERTYINFO_HXX_
+#define _EXTENSIONS_PROPCTRLR_PROPERTYINFO_HXX_
+
+#include <sal/types.h>
+#include <tools/string.hxx>
+#include <rtl/ustring.hxx>
+#include <rtl/string.hxx>
+#include <vector>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ //========================================================================
+ //= IPropertyInfoService
+ //========================================================================
+ class SAL_NO_VTABLE IPropertyInfoService
+ {
+ public:
+ virtual sal_Int32 getPropertyId(const String& _rName) const = 0;
+ virtual String getPropertyTranslation(sal_Int32 _nId) const = 0;
+ virtual rtl::OString getPropertyHelpId(sal_Int32 _nId) const = 0;
+ virtual sal_Int16 getPropertyPos(sal_Int32 _nId) const = 0;
+ virtual sal_uInt32 getPropertyUIFlags(sal_Int32 _nId) const = 0;
+ virtual ::std::vector< ::rtl::OUString > getPropertyEnumRepresentations(sal_Int32 _nId) const = 0;
+
+ // this is only temporary, until the UNOization of the property browser is completed
+ virtual String getPropertyName( sal_Int32 _nPropId ) = 0;
+
+ virtual ~IPropertyInfoService() { }
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_PROPERTYINFO_HXX_
+
diff --git a/extensions/source/propctrlr/propeventtranslation.cxx b/extensions/source/propctrlr/propeventtranslation.cxx
new file mode 100644
index 000000000000..f82d81e75172
--- /dev/null
+++ b/extensions/source/propctrlr/propeventtranslation.cxx
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "propeventtranslation.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/lang/NullPointerException.hpp>
+/** === end UNO includes === **/
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::beans::PropertyChangeEvent;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::beans::XPropertyChangeListener;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::beans::PropertyChangeEvent;
+ using ::com::sun::star::lang::DisposedException;
+ using ::com::sun::star::lang::NullPointerException;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= PropertyEventTranslation
+ //====================================================================
+ //--------------------------------------------------------------------
+ PropertyEventTranslation::PropertyEventTranslation( const Reference< XPropertyChangeListener >& _rxDelegator,
+ const Reference< XInterface >& _rxTranslatedEventSource )
+ :m_xDelegator( _rxDelegator )
+ ,m_xTranslatedEventSource( _rxTranslatedEventSource )
+ {
+ if ( !m_xDelegator.is() )
+ throw NullPointerException();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyEventTranslation::propertyChange( const PropertyChangeEvent& evt ) throw (RuntimeException)
+ {
+ if ( !m_xDelegator.is() )
+ throw DisposedException();
+
+ if ( !m_xTranslatedEventSource.is() )
+ m_xDelegator->propertyChange( evt );
+ else
+ {
+ PropertyChangeEvent aTranslatedEvent( evt );
+ aTranslatedEvent.Source = m_xTranslatedEventSource;
+ m_xDelegator->propertyChange( aTranslatedEvent );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyEventTranslation::disposing( const EventObject& Source ) throw (RuntimeException)
+ {
+ if ( !m_xDelegator.is() )
+ throw DisposedException();
+
+ if ( !m_xTranslatedEventSource.is() )
+ m_xDelegator->disposing( Source );
+ else
+ {
+ EventObject aTranslatedEvent( Source );
+ aTranslatedEvent.Source = m_xTranslatedEventSource;
+ m_xDelegator->disposing( aTranslatedEvent );
+ }
+
+ m_xDelegator.clear();
+ m_xTranslatedEventSource.clear();
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
diff --git a/extensions/source/propctrlr/propeventtranslation.hxx b/extensions/source/propctrlr/propeventtranslation.hxx
new file mode 100644
index 000000000000..e10ab99d2e2b
--- /dev/null
+++ b/extensions/source/propctrlr/propeventtranslation.hxx
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_PROPEVENTTRANSLATION_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_PROPEVENTTRANSLATION_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+/** === end UNO includes === **/
+#include <cppuhelper/implbase1.hxx>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= PropertyEventTranslation
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::beans::XPropertyChangeListener
+ > PropertyEventTranslation_Base;
+
+ class PropertyEventTranslation : public PropertyEventTranslation_Base
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >
+ m_xDelegator;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ m_xTranslatedEventSource;
+
+ public:
+ /** constructs the object
+ @throws NullPointerException
+ if <arg>_rxDelegator</arg> is <NULL/>
+ */
+ PropertyEventTranslation(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxDelegator,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxTranslatedEventSource
+ );
+
+ inline const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >&
+ getDelegator() const { return m_xDelegator; }
+
+ protected:
+ // XPropertyChangeListener
+ virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException);
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ PropertyEventTranslation(); // never implemented
+ PropertyEventTranslation( const PropertyEventTranslation& ); // never implemented
+ PropertyEventTranslation& operator=( const PropertyEventTranslation& ); // never implemented
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_PROPEVENTTRANSLATION_HXX
+
diff --git a/extensions/source/propctrlr/proplinelistener.hxx b/extensions/source/propctrlr/proplinelistener.hxx
new file mode 100644
index 000000000000..143483a6b9fd
--- /dev/null
+++ b/extensions/source/propctrlr/proplinelistener.hxx
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_PROPLINELISTENER_HXX_
+#define _EXTENSIONS_PROPCTRLR_PROPLINELISTENER_HXX_
+
+#include <tools/string.hxx>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ class IPropertyLineListener
+ {
+ public:
+ virtual void Clicked( const ::rtl::OUString& _rName, sal_Bool _bPrimary ) = 0;
+ virtual void Commit( const ::rtl::OUString& _rName, const ::com::sun::star::uno::Any& _rVal ) = 0;
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_PROPLINELISTENER_HXX_
+
diff --git a/extensions/source/propctrlr/propres.src b/extensions/source/propctrlr/propres.src
new file mode 100644
index 000000000000..23b11a932e34
--- /dev/null
+++ b/extensions/source/propctrlr/propres.src
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_PROPRESID_HRC
+#include "propresid.hrc"
+#endif
+#include "formresid.hrc"
+
+String RID_STR_STANDARD
+{
+ Text [ en-US ] = "Default" ;
+};
+String RID_STR_PROPPAGE_DEFAULT
+{
+ Text [ en-US ] = "General" ;
+};
+String RID_STR_PROPPAGE_DATA
+{
+ Text [ en-US ] = "Data" ;
+};
+Resource RID_RSC_ENUM_YESNO
+{
+ String 1
+ {
+ Text [ en-US ] = "No" ;
+ };
+ String 2
+ {
+ Text [ en-US ] = "Yes" ;
+ };
+};
+String RID_STR_HELP_SECTION_LABEL
+{
+ Text [ en-US ] = "Help";
+};
+String RID_EMBED_IMAGE_PLACEHOLDER
+{
+ Text [ en-US ] = "<Embedded-Image>";
+};
+
+String RID_STR_TEXT_FORMAT
+{
+ Text [ en-US ] = "Text";
+};
diff --git a/extensions/source/propctrlr/propresid.hrc b/extensions/source/propctrlr/propresid.hrc
new file mode 100644
index 000000000000..5328617735a9
--- /dev/null
+++ b/extensions/source/propctrlr/propresid.hrc
@@ -0,0 +1,48 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_PROPRESID_HRC
+#define EXTENSIONS_PROPRESID_HRC
+
+// TODO: create a new resource range in <svl/solar.hrc>
+
+#define RID_PROPCONTROLLER_START 1000
+ // arbitrary at the moment
+#define RID_FORMBROWSER_START RID_PROPCONTROLLER_START + 2000
+
+// -----------------------------------------------------------------------
+// - Strings
+// -----------------------------------------------------------------------
+
+#define RID_STR_STANDARD ( RID_PROPCONTROLLER_START + 0 )
+#define RID_STR_PROPPAGE_DEFAULT ( RID_PROPCONTROLLER_START + 1 )
+#define RID_STR_PROPPAGE_DATA ( RID_PROPCONTROLLER_START + 2 )
+#define RID_STR_HELP_SECTION_LABEL ( RID_PROPCONTROLLER_START + 3 )
+#define RID_EMBED_IMAGE_PLACEHOLDER ( RID_PROPCONTROLLER_START + 4 )
+#define RID_STR_TEXT_FORMAT ( RID_PROPCONTROLLER_START + 5 )
+
+#endif // EXTENSIONS_PROPRESID_HRC
diff --git a/extensions/source/propctrlr/pushbuttonnavigation.cxx b/extensions/source/propctrlr/pushbuttonnavigation.cxx
new file mode 100644
index 000000000000..3894825d603d
--- /dev/null
+++ b/extensions/source/propctrlr/pushbuttonnavigation.cxx
@@ -0,0 +1,306 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "pushbuttonnavigation.hxx"
+#include <com/sun/star/form/FormButtonType.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include "formstrings.hxx"
+#include <comphelper/extract.hxx>
+#include <comphelper/property.hxx>
+#include <osl/diagnose.h>
+#include <tools/diagnose_ex.h>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::form;
+
+ //------------------------------------------------------------------------
+ namespace
+ {
+ static const sal_Int32 s_nFirstVirtualButtonType = 1 + (sal_Int32)FormButtonType_URL;
+
+ static const sal_Char* pNavigationURLs[] =
+ {
+ ".uno:FormController/moveToFirst",
+ ".uno:FormController/moveToPrev",
+ ".uno:FormController/moveToNext",
+ ".uno:FormController/moveToLast",
+ ".uno:FormController/saveRecord",
+ ".uno:FormController/undoRecord",
+ ".uno:FormController/moveToNew",
+ ".uno:FormController/deleteRecord",
+ ".uno:FormController/refreshForm",
+ NULL
+ };
+
+ static sal_Int32 lcl_getNavigationURLIndex( const ::rtl::OUString& _rNavURL )
+ {
+ const sal_Char** pLookup = pNavigationURLs;
+ while ( *pLookup )
+ {
+ if ( _rNavURL.equalsAscii( *pLookup ) )
+ return pLookup - pNavigationURLs;
+ ++pLookup;
+ }
+ return -1;
+ }
+
+ static const sal_Char* lcl_getNavigationURL( sal_Int32 _nButtonTypeIndex )
+ {
+ const sal_Char** pLookup = pNavigationURLs;
+ while ( _nButtonTypeIndex-- && *pLookup++ )
+ ;
+ OSL_ENSURE( *pLookup, "lcl_getNavigationURL: invalid index!" );
+ return *pLookup;
+ }
+ }
+
+ //========================================================================
+ //= PushButtonNavigation
+ //========================================================================
+ //------------------------------------------------------------------------
+ PushButtonNavigation::PushButtonNavigation( const Reference< XPropertySet >& _rxControlModel )
+ :m_xControlModel( _rxControlModel )
+ ,m_bIsPushButton( sal_False )
+ {
+ OSL_ENSURE( m_xControlModel.is(), "PushButtonNavigation::PushButtonNavigation: invalid control model!" );
+
+ try
+ {
+ m_bIsPushButton = ::comphelper::hasProperty( PROPERTY_BUTTONTYPE, m_xControlModel );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "PushButtonNavigation::PushButtonNavigation: caught an exception!" );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ sal_Int32 PushButtonNavigation::implGetCurrentButtonType() const SAL_THROW((Exception))
+ {
+ sal_Int32 nButtonType = FormButtonType_PUSH;
+ if ( !m_xControlModel.is() )
+ return nButtonType;
+ OSL_VERIFY( ::cppu::enum2int( nButtonType, m_xControlModel->getPropertyValue( PROPERTY_BUTTONTYPE ) ) );
+
+ if ( nButtonType == FormButtonType_URL )
+ {
+ // there's a chance that this is a "virtual" button type
+ // (which are realized by special URLs)
+ ::rtl::OUString sTargetURL;
+ m_xControlModel->getPropertyValue( PROPERTY_TARGET_URL ) >>= sTargetURL;
+
+ sal_Int32 nNavigationURLIndex = lcl_getNavigationURLIndex( sTargetURL );
+ if ( nNavigationURLIndex >= 0)
+ // it actually *is* a virtual button type
+ nButtonType = s_nFirstVirtualButtonType + nNavigationURLIndex;
+ }
+ return nButtonType;
+ }
+
+ //------------------------------------------------------------------------
+ Any PushButtonNavigation::getCurrentButtonType() const SAL_THROW(())
+ {
+ OSL_ENSURE( m_bIsPushButton, "PushButtonNavigation::getCurrentButtonType: not expected to be called for forms!" );
+ Any aReturn;
+
+ try
+ {
+ aReturn <<= implGetCurrentButtonType();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "PushButtonNavigation::getCurrentButtonType: caught an exception!" );
+ }
+ return aReturn;
+ }
+
+ //------------------------------------------------------------------------
+ void PushButtonNavigation::setCurrentButtonType( const Any& _rValue ) const SAL_THROW(())
+ {
+ OSL_ENSURE( m_bIsPushButton, "PushButtonNavigation::setCurrentButtonType: not expected to be called for forms!" );
+ if ( !m_xControlModel.is() )
+ return;
+
+ try
+ {
+ sal_Int32 nButtonType = FormButtonType_PUSH;
+ OSL_VERIFY( ::cppu::enum2int( nButtonType, _rValue ) );
+ ::rtl::OUString sTargetURL;
+
+ bool bIsVirtualButtonType = nButtonType >= s_nFirstVirtualButtonType;
+ if ( bIsVirtualButtonType )
+ {
+ const sal_Char* pURL = lcl_getNavigationURL( nButtonType - s_nFirstVirtualButtonType );
+ sTargetURL = ::rtl::OUString::createFromAscii( pURL );
+
+ nButtonType = FormButtonType_URL;
+ }
+
+ m_xControlModel->setPropertyValue( PROPERTY_BUTTONTYPE, makeAny( static_cast< FormButtonType >( nButtonType ) ) );
+ m_xControlModel->setPropertyValue( PROPERTY_TARGET_URL, makeAny( sTargetURL ) );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "PushButtonNavigation::setCurrentButtonType: caught an exception!" );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ PropertyState PushButtonNavigation::getCurrentButtonTypeState( ) const SAL_THROW(())
+ {
+ OSL_ENSURE( m_bIsPushButton, "PushButtonNavigation::getCurrentButtonTypeState: not expected to be called for forms!" );
+ PropertyState eState = PropertyState_DIRECT_VALUE;
+
+ try
+ {
+ Reference< XPropertyState > xStateAccess( m_xControlModel, UNO_QUERY );
+ if ( xStateAccess.is() )
+ {
+ // let's see what the model says about the ButtonType property
+ eState = xStateAccess->getPropertyState( PROPERTY_BUTTONTYPE );
+ if ( eState == PropertyState_DIRECT_VALUE )
+ {
+ sal_Int32 nRealButtonType = FormButtonType_PUSH;
+ OSL_VERIFY( ::cppu::enum2int( nRealButtonType, m_xControlModel->getPropertyValue( PROPERTY_BUTTONTYPE ) ) );
+ // perhaps it's one of the virtual button types?
+ if ( FormButtonType_URL == nRealButtonType )
+ {
+ // yes, it is -> rely on the state of the URL property
+ eState = xStateAccess->getPropertyState( PROPERTY_TARGET_URL );
+ }
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "PushButtonNavigation::getCurrentButtonTypeState: caught an exception!" );
+ }
+
+ return eState;
+ }
+
+ //------------------------------------------------------------------------
+ Any PushButtonNavigation::getCurrentTargetURL() const SAL_THROW(())
+ {
+ Any aReturn;
+ if ( !m_xControlModel.is() )
+ return aReturn;
+
+ try
+ {
+ aReturn = m_xControlModel->getPropertyValue( PROPERTY_TARGET_URL );
+ if ( m_bIsPushButton )
+ {
+ sal_Int32 nCurrentButtonType = implGetCurrentButtonType();
+ bool bIsVirtualButtonType = nCurrentButtonType >= s_nFirstVirtualButtonType;
+ if ( bIsVirtualButtonType )
+ {
+ // pretend (to the user) that there's no URL set - since
+ // virtual button types imply a special (technical) URL which
+ // the user should not see
+ aReturn <<= ::rtl::OUString();
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "PushButtonNavigation::getCurrentTargetURL: caught an exception!" );
+ }
+ return aReturn;
+ }
+
+ //------------------------------------------------------------------------
+ void PushButtonNavigation::setCurrentTargetURL( const Any& _rValue ) const SAL_THROW(())
+ {
+ if ( !m_xControlModel.is() )
+ return;
+
+ try
+ {
+ m_xControlModel->setPropertyValue( PROPERTY_TARGET_URL, _rValue );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "PushButtonNavigation::setCurrentTargetURL: caught an exception!" );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ PropertyState PushButtonNavigation::getCurrentTargetURLState( ) const SAL_THROW(())
+ {
+ PropertyState eState = PropertyState_DIRECT_VALUE;
+
+ try
+ {
+ Reference< XPropertyState > xStateAccess( m_xControlModel, UNO_QUERY );
+ if ( xStateAccess.is() )
+ {
+ eState = xStateAccess->getPropertyState( PROPERTY_TARGET_URL );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "PushButtonNavigation::setCurrentTargetURL: caught an exception!" );
+ }
+
+ return eState;
+ }
+
+ //------------------------------------------------------------------------
+ bool PushButtonNavigation::currentButtonTypeIsOpenURL() const
+ {
+ sal_Int32 nButtonType( FormButtonType_PUSH );
+ try
+ {
+ nButtonType = implGetCurrentButtonType();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return nButtonType == FormButtonType_URL;
+ }
+
+ //------------------------------------------------------------------------
+ bool PushButtonNavigation::hasNonEmptyCurrentTargetURL() const
+ {
+ ::rtl::OUString sTargetURL;
+ OSL_VERIFY( getCurrentTargetURL() >>= sTargetURL );
+ return sTargetURL.getLength() != 0;
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
diff --git a/extensions/source/propctrlr/pushbuttonnavigation.hxx b/extensions/source/propctrlr/pushbuttonnavigation.hxx
new file mode 100644
index 000000000000..e53de6fb2139
--- /dev/null
+++ b/extensions/source/propctrlr/pushbuttonnavigation.hxx
@@ -0,0 +1,108 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_PROPCTRLR_PUSHBUTTONNAVIGATION_HXX
+#define EXTENSIONS_PROPCTRLR_PUSHBUTTONNAVIGATION_HXX
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyState.hpp>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ //========================================================================
+ //= PushButtonNavigation
+ //========================================================================
+ class PushButtonNavigation
+ {
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xControlModel;
+ sal_Bool m_bIsPushButton;
+
+ public:
+ /** ctor
+ @param _rxControlModel
+ the control model which is or will be bound
+ */
+ PushButtonNavigation(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel
+ );
+
+ /** returns the current value of the "ButtonType" property, taking into account
+ the "virtual" button types such as "move-to-next-record button".
+ */
+ ::com::sun::star::uno::Any
+ getCurrentButtonType() const SAL_THROW(());
+
+ /** sets the current value of the "ButtonType" property, taking into account
+ the "virtual" button types such as "move-to-next-record button".
+ */
+ void setCurrentButtonType( const ::com::sun::star::uno::Any& _rValue ) const SAL_THROW(());
+
+ /** retrieves the current state of the "ButtonType" property, taking into account
+ the "virtual" button types such as "move-to-next-record button".
+ */
+ ::com::sun::star::beans::PropertyState
+ getCurrentButtonTypeState( ) const SAL_THROW(());
+
+ /** returns the current value of the "TargetURL" property, taking into account
+ that some URLs are special values caused by "virtual" ButtonTypes
+ */
+ ::com::sun::star::uno::Any
+ getCurrentTargetURL() const SAL_THROW(());
+
+ /** sets the current value of the "TargetURL" property, taking into account
+ that some URLs are special values caused by "virtual" ButtonTypes
+ */
+ void setCurrentTargetURL( const ::com::sun::star::uno::Any& _rValue ) const SAL_THROW(());
+
+ /** retrieves the current state of the "TargetURL" property, taking into account
+ that some URLs are special values caused by "virtual" ButtonTypes
+ */
+ ::com::sun::star::beans::PropertyState
+ getCurrentTargetURLState( ) const SAL_THROW(());
+
+ /** determines whether the current button tpye is FormButtonType_URL
+ */
+ bool currentButtonTypeIsOpenURL() const;
+
+ /** determines whether the TargetURL property does currently denote a non-empty string
+ */
+ bool hasNonEmptyCurrentTargetURL() const;
+
+ private:
+ sal_Int32 implGetCurrentButtonType() const SAL_THROW(( ::com::sun::star::uno::Exception ));
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // EXTENSIONS_PROPCTRLR_PUSHBUTTONNAVIGATION_HXX
diff --git a/extensions/source/propctrlr/selectlabeldialog.cxx b/extensions/source/propctrlr/selectlabeldialog.cxx
new file mode 100644
index 000000000000..5fbbe57dc11b
--- /dev/null
+++ b/extensions/source/propctrlr/selectlabeldialog.cxx
@@ -0,0 +1,313 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "selectlabeldialog.hxx"
+#ifndef _EXTENSIONS_PROPCTRLR_FORMRESID_HRC_
+#include "formresid.hrc"
+#endif
+#include "formbrowsertools.hxx"
+#include "formstrings.hxx"
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <comphelper/property.hxx>
+#include <comphelper/types.hxx>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::form;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::lang;
+
+ //========================================================================
+ // OSelectLabelDialog
+ //========================================================================
+ DBG_NAME(OSelectLabelDialog)
+ //------------------------------------------------------------------------
+ OSelectLabelDialog::OSelectLabelDialog( Window* pParent, Reference< XPropertySet > _xControlModel )
+ :ModalDialog(pParent, PcrRes(RID_DLG_SELECTLABELCONTROL))
+ ,m_aMainDesc(this, PcrRes(1))
+ ,m_aControlTree(this, PcrRes(1))
+ ,m_aNoAssignment(this, PcrRes(1))
+ ,m_aSeparator(this, PcrRes(1))
+ ,m_aOk(this, PcrRes(1))
+ ,m_aCancel(this, PcrRes(1))
+ ,m_aModelImages(PcrRes(RID_IL_FORMEXPLORER))
+ ,m_xControlModel(_xControlModel)
+ ,m_pInitialSelection(NULL)
+ ,m_pLastSelected(NULL)
+ ,m_bHaveAssignableControl(sal_False)
+ {
+ DBG_CTOR(OSelectLabelDialog,NULL);
+
+ // initialize the TreeListBox
+ m_aControlTree.SetSelectionMode( SINGLE_SELECTION );
+ m_aControlTree.SetDragDropMode( 0 );
+ m_aControlTree.EnableInplaceEditing( sal_False );
+ m_aControlTree.SetStyle(m_aControlTree.GetStyle() | WB_BORDER | WB_HASLINES | WB_HASLINESATROOT | WB_HASBUTTONS | WB_HASBUTTONSATROOT | WB_HSCROLL);
+
+ m_aControlTree.SetNodeBitmaps( m_aModelImages.GetImage( RID_SVXIMG_COLLAPSEDNODE ), m_aModelImages.GetImage( RID_SVXIMG_EXPANDEDNODE ) );
+ m_aControlTree.SetSelectHdl(LINK(this, OSelectLabelDialog, OnEntrySelected));
+ m_aControlTree.SetDeselectHdl(LINK(this, OSelectLabelDialog, OnEntrySelected));
+
+ // fill the description
+ UniString sDescription = m_aMainDesc.GetText();
+ sal_Int16 nClassID = FormComponentType::CONTROL;
+ if (::comphelper::hasProperty(PROPERTY_CLASSID, m_xControlModel))
+ nClassID = ::comphelper::getINT16(m_xControlModel->getPropertyValue(PROPERTY_CLASSID));
+
+ sDescription.SearchAndReplace(String::CreateFromAscii("$control_class$"), GetUIHeadlineName(nClassID, makeAny(m_xControlModel)));
+ UniString sName = ::comphelper::getString(m_xControlModel->getPropertyValue(PROPERTY_NAME)).getStr();
+ sDescription.SearchAndReplace(String::CreateFromAscii("$control_name$"), sName);
+ m_aMainDesc.SetText(sDescription);
+
+ // search for the root of the form hierarchy
+ Reference< XChild > xCont(m_xControlModel, UNO_QUERY);
+ Reference< XInterface > xSearch( xCont.is() ? xCont->getParent() : Reference< XInterface > ());
+ Reference< XResultSet > xParentAsResultSet(xSearch, UNO_QUERY);
+ while (xParentAsResultSet.is())
+ {
+ xCont = Reference< XChild > (xSearch, UNO_QUERY);
+ xSearch = xCont.is() ? xCont->getParent() : Reference< XInterface > ();
+ xParentAsResultSet = Reference< XResultSet > (xSearch, UNO_QUERY);
+ }
+
+ // and insert all entries below this root into the listbox
+ if (xSearch.is())
+ {
+ // check wich service the allowed components must suppport
+ sal_Int16 nClassId = 0;
+ try { nClassId = ::comphelper::getINT16(m_xControlModel->getPropertyValue(PROPERTY_CLASSID)); } catch(...) { }
+ m_sRequiredService = (FormComponentType::RADIOBUTTON == nClassId) ? SERVICE_COMPONENT_GROUPBOX : SERVICE_COMPONENT_FIXEDTEXT;
+ m_aRequiredControlImage = m_aModelImages.GetImage((FormComponentType::RADIOBUTTON == nClassId) ? RID_SVXIMG_GROUPBOX : RID_SVXIMG_FIXEDTEXT);
+
+ // calc the currently set label control (so InsertEntries can calc m_pInitialSelection)
+ Any aCurrentLabelControl( m_xControlModel->getPropertyValue(PROPERTY_CONTROLLABEL) );
+ DBG_ASSERT((aCurrentLabelControl.getValueTypeClass() == TypeClass_INTERFACE) || !aCurrentLabelControl.hasValue(),
+
+ "OSelectLabelDialog::OSelectLabelDialog : invalid ControlLabel property !");
+ if (aCurrentLabelControl.hasValue())
+ aCurrentLabelControl >>= m_xInitialLabelControl;
+
+ // insert the root
+ Image aRootImage = m_aModelImages.GetImage(RID_SVXIMG_FORMS);
+ SvLBoxEntry* pRoot = m_aControlTree.InsertEntry(PcrRes(RID_STR_FORMS), aRootImage, aRootImage);
+
+ // build the tree
+ m_pInitialSelection = NULL;
+ m_bHaveAssignableControl = sal_False;
+ InsertEntries(xSearch, pRoot);
+ m_aControlTree.Expand(pRoot);
+ }
+
+ if (m_pInitialSelection)
+ {
+ m_aControlTree.MakeVisible(m_pInitialSelection, sal_True);
+ m_aControlTree.Select(m_pInitialSelection, sal_True);
+ }
+ else
+ {
+ m_aControlTree.MakeVisible(m_aControlTree.First(), sal_True);
+ if (m_aControlTree.FirstSelected())
+ m_aControlTree.Select(m_aControlTree.FirstSelected(), sal_False);
+ m_aNoAssignment.Check(sal_True);
+ }
+
+ if (!m_bHaveAssignableControl)
+ { // no controls which can be assigned
+ m_aNoAssignment.Check(sal_True);
+ m_aNoAssignment.Enable(sal_False);
+ }
+
+ m_aNoAssignment.SetClickHdl(LINK(this, OSelectLabelDialog, OnNoAssignmentClicked));
+ m_aNoAssignment.GetClickHdl().Call(&m_aNoAssignment);
+
+ FreeResource();
+ }
+
+ //------------------------------------------------------------------------
+ OSelectLabelDialog::~OSelectLabelDialog()
+ {
+ // delete the entry datas of the listbox entries
+ SvLBoxEntry* pLoop = m_aControlTree.First();
+ while (pLoop)
+ {
+ void* pData = pLoop->GetUserData();
+ if (pData)
+ delete (Reference< XPropertySet > *)pData;
+ pLoop = m_aControlTree.Next(pLoop);
+ }
+
+ DBG_DTOR(OSelectLabelDialog,NULL);
+ }
+
+ //------------------------------------------------------------------------
+ sal_Int32 OSelectLabelDialog::InsertEntries(const Reference< XInterface > & _xContainer, SvLBoxEntry* pContainerEntry)
+ {
+ Reference< XIndexAccess > xContainer(_xContainer, UNO_QUERY);
+ if (!xContainer.is())
+ return 0;
+
+ sal_Int32 nChildren = 0;
+ UniString sName,sDisplayName;
+ Reference< XPropertySet > xAsSet;
+ for (sal_Int32 i=0; i<xContainer->getCount(); ++i)
+ {
+ xContainer->getByIndex(i) >>= xAsSet;
+ if (!xAsSet.is())
+ {
+ DBG_WARNING("OSelectLabelDialog::InsertEntries : strange : a form component which isn't a property set !");
+ continue;
+ }
+
+ if (!::comphelper::hasProperty(PROPERTY_NAME, xAsSet))
+ // we need at least a name for displaying ...
+ continue;
+ sName = ::comphelper::getString(xAsSet->getPropertyValue(PROPERTY_NAME)).getStr();
+
+ // we need to check if the control model supports the required service
+ Reference< XServiceInfo > xInfo(xAsSet, UNO_QUERY);
+ if (!xInfo.is())
+ continue;
+
+ if (!xInfo->supportsService(m_sRequiredService))
+ { // perhaps it is a container
+ Reference< XIndexAccess > xCont(xAsSet, UNO_QUERY);
+ if (xCont.is() && xCont->getCount())
+ { // yes -> step down
+ Image aFormImage = m_aModelImages.GetImage( RID_SVXIMG_FORM );
+ SvLBoxEntry* pCont = m_aControlTree.InsertEntry(sName, aFormImage, aFormImage, pContainerEntry);
+ sal_Int32 nContChildren = InsertEntries(xCont, pCont);
+ if (nContChildren)
+ {
+ m_aControlTree.Expand(pCont);
+ ++nChildren;
+ }
+ else
+ { // oops, no valid childs -> remove the entry
+ m_aControlTree.ModelIsRemoving(pCont);
+ m_aControlTree.GetModel()->Remove(pCont);
+ m_aControlTree.ModelHasRemoved(pCont);
+ }
+ }
+ continue;
+ }
+
+ // get the label
+ if (!::comphelper::hasProperty(PROPERTY_LABEL, xAsSet))
+ continue;
+ sDisplayName = ::comphelper::getString(xAsSet->getPropertyValue(PROPERTY_LABEL)).getStr();
+ sDisplayName += String::CreateFromAscii(" (");
+ sDisplayName += sName;
+ sDisplayName += ')';
+
+ // all requirements met -> insert
+ SvLBoxEntry* pCurrent = m_aControlTree.InsertEntry(sDisplayName, m_aRequiredControlImage, m_aRequiredControlImage, pContainerEntry);
+ pCurrent->SetUserData(new Reference< XPropertySet > (xAsSet));
+ ++nChildren;
+
+ if (m_xInitialLabelControl == xAsSet)
+ m_pInitialSelection = pCurrent;
+
+ m_bHaveAssignableControl = sal_True;
+ }
+
+ return nChildren;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK(OSelectLabelDialog, OnEntrySelected, SvTreeListBox*, pLB)
+ {
+ DBG_ASSERT(pLB == &m_aControlTree, "OSelectLabelDialog::OnEntrySelected : where did this come from ?");
+ (void)pLB;
+ SvLBoxEntry* pSelected = m_aControlTree.FirstSelected();
+ void* pData = pSelected ? pSelected->GetUserData() : NULL;
+
+ if (pData)
+ m_xSelectedControl = Reference< XPropertySet > (*(Reference< XPropertySet > *)pData);
+
+ m_aNoAssignment.SetClickHdl(Link());
+ m_aNoAssignment.Check(pData == NULL);
+ m_aNoAssignment.SetClickHdl(LINK(this, OSelectLabelDialog, OnNoAssignmentClicked));
+
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK(OSelectLabelDialog, OnNoAssignmentClicked, Button*, pButton)
+ {
+ DBG_ASSERT(pButton == &m_aNoAssignment, "OSelectLabelDialog::OnNoAssignmentClicked : where did this come from ?");
+ (void)pButton;
+
+ if (m_aNoAssignment.IsChecked())
+ m_pLastSelected = m_aControlTree.FirstSelected();
+ else
+ {
+ DBG_ASSERT(m_bHaveAssignableControl, "OSelectLabelDialog::OnNoAssignmentClicked");
+ // search the first assignable entry
+ SvLBoxEntry* pSearch = m_aControlTree.First();
+ while (pSearch)
+ {
+ if (pSearch->GetUserData())
+ break;
+ pSearch = m_aControlTree.Next(pSearch);
+ }
+ // and select it
+ if (pSearch)
+ {
+ m_aControlTree.Select(pSearch);
+ m_pLastSelected = pSearch;
+ }
+ }
+
+ if (m_pLastSelected)
+ {
+ m_aControlTree.SetSelectHdl(Link());
+ m_aControlTree.SetDeselectHdl(Link());
+ m_aControlTree.Select(m_pLastSelected, !m_aNoAssignment.IsChecked());
+ m_aControlTree.SetSelectHdl(LINK(this, OSelectLabelDialog, OnEntrySelected));
+ m_aControlTree.SetDeselectHdl(LINK(this, OSelectLabelDialog, OnEntrySelected));
+ }
+
+ return 0L;
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
diff --git a/extensions/source/propctrlr/selectlabeldialog.hxx b/extensions/source/propctrlr/selectlabeldialog.hxx
new file mode 100644
index 000000000000..27294a0f9977
--- /dev/null
+++ b/extensions/source/propctrlr/selectlabeldialog.hxx
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_SELECTLABELDIALOG_HXX_
+#define _EXTENSIONS_PROPCTRLR_SELECTLABELDIALOG_HXX_
+
+#include <vcl/fixed.hxx>
+#include <svtools/svtreebx.hxx>
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#include <vcl/image.hxx>
+#include <vcl/dialog.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
+#include "modulepcr.hxx"
+#endif
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ //========================================================================
+ // OSelectLabelDialog
+ //========================================================================
+ class OSelectLabelDialog
+ :public ModalDialog
+ ,public PcrClient
+ {
+ FixedText m_aMainDesc;
+ SvTreeListBox m_aControlTree;
+ CheckBox m_aNoAssignment;
+ FixedLine m_aSeparator;
+ OKButton m_aOk;
+ CancelButton m_aCancel;
+
+ ImageList m_aModelImages;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xControlModel;
+ ::rtl::OUString m_sRequiredService;
+ Image m_aRequiredControlImage;
+ SvLBoxEntry* m_pInitialSelection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xInitialLabelControl;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xSelectedControl;
+ SvLBoxEntry* m_pLastSelected;
+ sal_Bool m_bHaveAssignableControl;
+
+ public:
+ OSelectLabelDialog(Window* pParent, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _xControlModel);
+ ~OSelectLabelDialog();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > GetSelected() const { return m_aNoAssignment.IsChecked() ? ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > () : m_xSelectedControl; }
+
+ protected:
+ sal_Int32 InsertEntries(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xContainer, SvLBoxEntry* pContainerEntry);
+
+ DECL_LINK(OnEntrySelected, SvTreeListBox*);
+ DECL_LINK(OnNoAssignmentClicked, Button*);
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_SELECTLABELDIALOG_HXX_
+
diff --git a/extensions/source/propctrlr/selectlabeldialog.src b/extensions/source/propctrlr/selectlabeldialog.src
new file mode 100644
index 000000000000..357a223bf2b8
--- /dev/null
+++ b/extensions/source/propctrlr/selectlabeldialog.src
@@ -0,0 +1,85 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_PROPRESID_HRC
+#include "formresid.hrc"
+#endif
+
+ModalDialog RID_DLG_SELECTLABELCONTROL
+{
+ HelpID = "extensions:ModalDialog:RID_DLG_SELECTLABELCONTROL";
+ OutputSize = TRUE;
+ Size = MAP_APPFONT( 200, 151 );
+ Moveable = TRUE;
+ Closeable = TRUE;
+ FixedText 1
+ {
+ Pos = MAP_APPFONT( 6, 6 );
+ Size = MAP_APPFONT( 188, 20 );
+ WordBreak = TRUE;
+ Text [ en-US ] = "These are control fields that can be used as label fields for the $control_class$ $control_name$.";
+ };
+ Control 1
+ {
+ Pos = MAP_APPFONT( 6, 29 );
+ Size = MAP_APPFONT( 188, 83 );
+ TabStop = TRUE;
+ Border = TRUE ;
+ };
+ CheckBox 1
+ {
+ HelpID = "extensions:CheckBox:RID_DLG_SELECTLABELCONTROL:1";
+ Pos = MAP_APPFONT( 6, 115 );
+ Size = MAP_APPFONT( 188, 8 );
+ Text [ en-US ] = "~No assignment";
+ };
+ FixedLine 1
+ {
+ Pos = MAP_APPFONT( 3, 126 );
+ Size = MAP_APPFONT( 194, 2 );
+ };
+ OKButton 1
+ {
+ Pos = MAP_APPFONT ( 91 , 131 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton 1
+ {
+ Pos = MAP_APPFONT ( 144 , 131 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ Text [ en-US ] = "Label Field Selection";
+};
+
+String RID_STR_FORMS
+{
+ Text [ en-US ] = "Forms" ;
+};
+
diff --git a/extensions/source/propctrlr/sqlcommanddesign.cxx b/extensions/source/propctrlr/sqlcommanddesign.cxx
new file mode 100644
index 000000000000..294945f77f2d
--- /dev/null
+++ b/extensions/source/propctrlr/sqlcommanddesign.cxx
@@ -0,0 +1,393 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "sqlcommanddesign.hxx"
+#include "formstrings.hxx"
+#ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
+#include "formresid.hrc"
+#endif
+#ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
+#include "modulepcr.hxx"
+#endif
+#include "unourl.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/awt/XTopWindow.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/frame/XTitle.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/lang/NullPointerException.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/frame/XFramesSupplier.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+/** === end UNO includes === **/
+
+#include <svtools/localresaccess.hxx>
+#include <tools/diagnose_ex.h>
+#include <osl/diagnose.h>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::lang::XMultiComponentFactory;
+ using ::com::sun::star::beans::PropertyChangeEvent;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::frame::XFrame;
+ using ::com::sun::star::awt::XTopWindow;
+ using ::com::sun::star::awt::XWindow;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::lang::XComponent;
+ using ::com::sun::star::frame::XComponentLoader;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::frame::XController;
+ using ::com::sun::star::frame::XTitle;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::lang::NullPointerException;
+ using ::com::sun::star::lang::DisposedException;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::frame::XFramesSupplier;
+ using ::com::sun::star::frame::XFrames;
+ using ::com::sun::star::util::XCloseable;
+ using ::com::sun::star::uno::TypeClass_STRING;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::frame::XDispatchProvider;
+ using ::com::sun::star::frame::XDispatch;
+ using ::com::sun::star::uno::Any;
+ /** === end UNO using === **/
+ namespace FrameSearchFlag = ::com::sun::star::frame::FrameSearchFlag;
+ namespace CommandType = ::com::sun::star::sdb::CommandType;
+
+ //====================================================================
+ //= ISQLCommandAdapter
+ //====================================================================
+ //--------------------------------------------------------------------
+ ISQLCommandAdapter::~ISQLCommandAdapter()
+ {
+ }
+
+ //====================================================================
+ //= SQLCommandDesigner
+ //====================================================================
+ //--------------------------------------------------------------------
+ SQLCommandDesigner::SQLCommandDesigner( const Reference< XComponentContext >& _rxContext,
+ const ::rtl::Reference< ISQLCommandAdapter >& _rxPropertyAdapter,
+ const ::dbtools::SharedConnection& _rConnection, const Link& _rCloseLink )
+ :m_xContext( _rxContext )
+ ,m_xConnection( _rConnection )
+ ,m_xObjectAdapter( _rxPropertyAdapter )
+ ,m_aCloseLink( _rCloseLink )
+ {
+ if ( m_xContext.is() )
+ m_xORB = m_xContext->getServiceManager();
+ if ( !m_xORB.is() || !_rxPropertyAdapter.is() || !m_xConnection.is() )
+ throw NullPointerException();
+
+ impl_doOpenDesignerFrame_nothrow();
+ }
+
+ //--------------------------------------------------------------------
+ SQLCommandDesigner::~SQLCommandDesigner()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SQLCommandDesigner::propertyChange( const PropertyChangeEvent& Event ) throw (RuntimeException)
+ {
+ OSL_ENSURE( m_xDesigner.is() && ( Event.Source == m_xDesigner ), "SQLCommandDesigner::propertyChange: where did this come from?" );
+
+ if ( m_xDesigner.is() && ( Event.Source == m_xDesigner ) )
+ {
+ try
+ {
+ if ( PROPERTY_ACTIVECOMMAND == Event.PropertyName )
+ {
+ ::rtl::OUString sCommand;
+ OSL_VERIFY( Event.NewValue >>= sCommand );
+ m_xObjectAdapter->setSQLCommand( sCommand );
+ }
+ else if ( PROPERTY_ESCAPE_PROCESSING == Event.PropertyName )
+ {
+ sal_Bool bEscapeProcessing( sal_False );
+ OSL_VERIFY( Event.NewValue >>= bEscapeProcessing );
+ m_xObjectAdapter->setEscapeProcessing( bEscapeProcessing );
+ }
+ }
+ catch( const RuntimeException& ) { throw; }
+ catch( const Exception& )
+ {
+ // not allowed to leave, so silence it
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SQLCommandDesigner::disposing( const EventObject& Source ) throw (RuntimeException)
+ {
+ if ( m_xDesigner.is() && ( Source.Source == m_xDesigner ) )
+ {
+ impl_designerClosed_nothrow();
+ m_xDesigner.clear();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SQLCommandDesigner::dispose()
+ {
+ if ( impl_isDisposed() )
+ return;
+
+ if ( isActive() )
+ impl_closeDesigner_nothrow();
+
+ m_xConnection.clear();
+ m_xContext.clear();
+ m_xORB.clear();
+ }
+
+ //--------------------------------------------------------------------
+ void SQLCommandDesigner::impl_checkDisposed_throw() const
+ {
+ if ( impl_isDisposed() )
+ throw DisposedException();
+ }
+
+ //--------------------------------------------------------------------
+ void SQLCommandDesigner::raise() const
+ {
+ impl_checkDisposed_throw();
+ impl_raise_nothrow();
+ }
+
+ //------------------------------------------------------------------------
+ bool SQLCommandDesigner::suspend() const
+ {
+ impl_checkDisposed_throw();
+ return impl_trySuspendDesigner_nothrow();
+ }
+
+ //--------------------------------------------------------------------
+ void SQLCommandDesigner::impl_raise_nothrow() const
+ {
+ OSL_PRECOND( isActive(), "SQLCommandDesigner::impl_raise_nothrow: not active!" );
+ if ( !isActive() )
+ return;
+
+ try
+ {
+ // activate the frame for this component
+ Reference< XFrame > xFrame( m_xDesigner->getFrame(), UNO_QUERY_THROW );
+ Reference< XWindow > xWindow( xFrame->getContainerWindow(), UNO_QUERY_THROW );
+ Reference< XTopWindow > xTopWindow( xWindow, UNO_QUERY_THROW );
+
+ xTopWindow->toFront();
+ xWindow->setFocus();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow()
+ {
+ OSL_PRECOND( !isActive(),
+ "SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow: already active!" );
+ OSL_PRECOND( m_xConnection.is(), "SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow: this will crash!" );
+ osl_incrementInterlockedCount(&m_refCount);
+
+ try
+ {
+ // for various reasons, we don't want the new frame to appear in the desktop's frame list
+ // thus, we create a blank frame at the desktop, remove it from the desktop's frame list
+ // immediately, and then load the component into this blank (and now parent-less) frame
+ Reference< XComponentLoader > xLoader( impl_createEmptyParentlessTask_nothrow(), UNO_QUERY_THROW );
+ Sequence< PropertyValue > aArgs( 5 );
+ aArgs[0].Name = PROPERTY_ACTIVE_CONNECTION;
+ aArgs[0].Value <<= m_xConnection.getTyped();
+
+ aArgs[1].Name = PROPERTY_COMMAND;
+ aArgs[1].Value <<= m_xObjectAdapter->getSQLCommand();
+ aArgs[2].Name = PROPERTY_COMMANDTYPE;
+ aArgs[2].Value <<= (sal_Int32)CommandType::COMMAND;
+ aArgs[3].Name = PROPERTY_ESCAPE_PROCESSING;
+ aArgs[3].Value <<= m_xObjectAdapter->getEscapeProcessing();
+
+ aArgs[4].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GraphicalDesign" ) );
+ aArgs[4].Value <<= m_xObjectAdapter->getEscapeProcessing();
+
+ Reference< XComponent > xQueryDesign = xLoader->loadComponentFromURL(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".component:DB/QueryDesign" ) ),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_self" ) ),
+ FrameSearchFlag::TASKS | FrameSearchFlag::CREATE,
+ aArgs
+ );
+
+ // remember this newly loaded component - we need to care for it e.g. when we're suspended
+ m_xDesigner = m_xDesigner.query( xQueryDesign );
+ OSL_ENSURE( m_xDesigner.is() || !xQueryDesign.is(), "SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow: the component is expected to be a controller!" );
+ if ( m_xDesigner.is() )
+ {
+ Reference< XPropertySet > xQueryDesignProps( m_xDesigner, UNO_QUERY );
+ OSL_ENSURE( xQueryDesignProps.is(), "SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow: the controller should have properties!" );
+ if ( xQueryDesignProps.is() )
+ {
+ xQueryDesignProps->addPropertyChangeListener( PROPERTY_ACTIVECOMMAND, this );
+ xQueryDesignProps->addPropertyChangeListener( PROPERTY_ESCAPE_PROCESSING, this );
+ }
+ }
+
+ // get the frame which we just opened and set it's title
+ Reference< XTitle> xTitle(xQueryDesign,UNO_QUERY);
+ if ( xTitle.is() )
+ {
+ ::svt::OLocalResourceAccess aEnumStrings( PcrRes( RID_RSC_ENUM_COMMAND_TYPE ), RSC_RESOURCE );
+ ::rtl::OUString sDisplayName = String( PcrRes( CommandType::COMMAND + 1 ) );
+ xTitle->setTitle( sDisplayName );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ m_xDesigner.clear();
+ }
+ osl_decrementInterlockedCount(&m_refCount);
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XFrame > SQLCommandDesigner::impl_createEmptyParentlessTask_nothrow( ) const
+ {
+ OSL_PRECOND( m_xORB.is(), "SQLCommandDesigner::impl_createEmptyParentlessTask_nothrow: this will crash!" );
+
+ Reference< XFrame > xFrame;
+ try
+ {
+ Reference< XInterface > xDesktop ( m_xORB->createInstanceWithContext( SERVICE_DESKTOP, m_xContext ) );
+ Reference< XFrame > xDesktopFrame ( xDesktop, UNO_QUERY_THROW );
+ Reference< XFramesSupplier > xSuppDesktopFrames( xDesktopFrame, UNO_QUERY_THROW );
+
+ Reference< XFrames > xDesktopFramesCollection( xSuppDesktopFrames->getFrames(), UNO_QUERY_THROW );
+ xFrame = xDesktopFrame->findFrame( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_blank" ) ), FrameSearchFlag::CREATE );
+ OSL_ENSURE( xFrame.is(), "SQLCommandDesigner::impl_createEmptyParentlessTask_nothrow: could not create an empty frame!" );
+ xDesktopFramesCollection->remove( xFrame );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xFrame;
+ }
+
+ //------------------------------------------------------------------------
+ void SQLCommandDesigner::impl_designerClosed_nothrow()
+ {
+ if ( m_aCloseLink.IsSet() )
+ m_aCloseLink.Call( this );
+ }
+
+ //------------------------------------------------------------------------
+ void SQLCommandDesigner::impl_closeDesigner_nothrow()
+ {
+ OSL_PRECOND( isActive(), "SQLCommandDesigner::impl_closeDesigner_nothrow: invalid calle!" );
+ // close it
+ try
+ {
+ // do not listen anymore ....
+ Reference< XPropertySet > xProps( m_xDesigner, UNO_QUERY );
+ if ( xProps.is() )
+ xProps->removePropertyChangeListener( PROPERTY_ACTIVECOMMAND, this );
+
+ // we need to close the frame via the "user interface", by dispatching a close command,
+ // instead of calling XCloseable::close directly. The latter method would also close
+ // the frame, but not care for things like shutting down the office when the last
+ // frame is gone ...
+ const UnoURL aCloseURL( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CloseDoc" ) ),
+ Reference< XMultiServiceFactory >( m_xORB, UNO_QUERY ) );
+
+ Reference< XDispatchProvider > xProvider( m_xDesigner->getFrame(), UNO_QUERY_THROW );
+ Reference< XDispatch > xDispatch( xProvider->queryDispatch( aCloseURL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_top" ) ), FrameSearchFlag::SELF ) );
+ OSL_ENSURE( xDispatch.is(), "SQLCommandDesigner::impl_closeDesigner_nothrow: no dispatcher for the CloseDoc command!" );
+ if ( xDispatch.is() )
+ {
+ xDispatch->dispatch( aCloseURL, Sequence< PropertyValue >( ) );
+ }
+ else
+ {
+ // fallback: use the XCloseable::close (with all possible disadvantages)
+ Reference< XCloseable > xClose( m_xDesigner->getFrame(), UNO_QUERY );
+ if ( xClose.is() )
+ xClose->close( sal_True );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ m_xDesigner.clear();
+ }
+
+ //------------------------------------------------------------------------
+ bool SQLCommandDesigner::impl_trySuspendDesigner_nothrow() const
+ {
+ OSL_PRECOND( isActive(), "SQLCommandDesigner::impl_trySuspendDesigner_nothrow: no active designer, this will crash!" );
+ sal_Bool bAllow = sal_True;
+ try
+ {
+ bAllow = m_xDesigner->suspend( sal_True );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bAllow;
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
diff --git a/extensions/source/propctrlr/sqlcommanddesign.hxx b/extensions/source/propctrlr/sqlcommanddesign.hxx
new file mode 100644
index 000000000000..72dea2b20f74
--- /dev/null
+++ b/extensions/source/propctrlr/sqlcommanddesign.hxx
@@ -0,0 +1,223 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_SQLCOMMANDDESIGN_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_SQLCOMMANDDESIGN_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+/** === end UNO includes === **/
+
+#include <connectivity/dbtools.hxx>
+#include <tools/link.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <rtl/ref.hxx>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ class ISQLCommandAdapter;
+ //====================================================================
+ //= SQLCommandDesigner
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::beans::XPropertyChangeListener
+ > SQLCommandDesigner_Base;
+ /** encapsulates the code for calling and managing a query design frame, used
+ for interactively designing the Command property of a ->RowSet
+ */
+ class SQLCommandDesigner : public SQLCommandDesigner_Base
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiComponentFactory > m_xORB;
+ ::dbtools::SharedConnection m_xConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > m_xDesigner;
+ ::rtl::Reference< ISQLCommandAdapter > m_xObjectAdapter;
+ Link m_aCloseLink;
+
+ public:
+ /** creates the instance, and immediately opens the SQL command design frame
+
+ @param _rxContext
+ our component context. Must not be <NULL/>, and must provide a non-<NULL/> XMultiComponentFactory
+ @param _rxPropertyAdapter
+ an adapter to the object's SQL command related properties
+ @param _rConnection
+ the current connection of ->_rxRowSet. Must not be <NULL/>.
+ @param _rCloseLink
+ link to call when the component has been closed
+ @throws ::com::sun::star::lang::NullPointerException
+ if any of the arguments (except ->_rCloseLink) is <NULL/>, or if the component context
+ does not provide a valid component factory.
+ */
+ SQLCommandDesigner(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
+ const ::rtl::Reference< ISQLCommandAdapter >& _rxPropertyAdapter,
+ const ::dbtools::SharedConnection& _rConnection,
+ const Link& _rCloseLink
+ );
+
+ /** determines whether the SQL Command designer is currently active, i.e.
+ if there currently exists a frame which allows the user entering the SQL command
+ */
+ inline bool isActive() const { return m_xDesigner.is(); }
+
+ /** returns the property adapter used by the instance
+ */
+ inline const ::rtl::Reference< ISQLCommandAdapter >& getPropertyAdapter() const { return m_xObjectAdapter; }
+
+ /** raises the designer window to top
+ @precond
+ the designer is active (->isActive)
+ @precond
+ the instance is not disposed
+ */
+ void raise() const;
+
+ /** suspends the designer
+ @precond
+ the designer is active (->isActive)
+ @precond
+ the instance is not disposed
+ */
+ bool suspend() const;
+
+ /** disposes the instance so that it becomes non-functional
+ */
+ void dispose();
+
+ protected:
+ // XPropertyChangeListener
+ virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ ~SQLCommandDesigner();
+
+ /** opens a new frame for interactively designing an SQL command
+ @precond
+ the designer is not currently active (see ->isActive)
+ @precond
+ ->m_xConnection is not <NULL/>
+ */
+ void impl_doOpenDesignerFrame_nothrow();
+
+ /** impl-version of ->raise
+ */
+ void impl_raise_nothrow() const;
+
+ /** determines whether we are already disposed
+ */
+ bool impl_isDisposed() const
+ {
+ return !m_xContext.is();
+ }
+ /** checks whether we are already disposed
+ @throws ::com::sun::star::lang::DisposedException
+ if we in fact are disposed
+ */
+ void impl_checkDisposed_throw() const;
+
+ /** create an empty top-level frame, which does not belong to the desktop's frame list
+ @precond
+ ->m_xORB is not <NULL/>
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >
+ impl_createEmptyParentlessTask_nothrow() const;
+
+ /** called whenever the component denoted by m_xDesigner has been closed
+ <em>by an external instance</em>
+ */
+ void impl_designerClosed_nothrow();
+
+ /** closes the component denoted by m_xDesigner
+ @precond
+ our designer component is actually active (->isActive)
+ @precond
+ we're not disposed already
+ */
+ void impl_closeDesigner_nothrow();
+
+ /** suspends our designer component
+ @precond
+ the designer component is actually active (->isActive)
+ @return
+ <TRUE/> if the suspension was successful, <FALSE/> if it was vetoed
+ */
+ bool impl_trySuspendDesigner_nothrow() const;
+
+ /** gets the current value of the command property
+ */
+ ::rtl::OUString
+ impl_getCommandPropertyValue_nothrow();
+
+ /** sets anew value for the command property
+ */
+ void impl_setCommandPropertyValue_nothrow( const ::rtl::OUString& _rCommand ) const;
+
+ private:
+ SQLCommandDesigner(); // never implemented
+ SQLCommandDesigner( const SQLCommandDesigner& ); // never implemented
+ SQLCommandDesigner& operator=( const SQLCommandDesigner& ); // never implemented
+ };
+
+ //====================================================================
+ //= ISQLCommandAdapter
+ //====================================================================
+ /** an adapter to forward changed SQL command property values to a component
+ */
+ class ISQLCommandAdapter : public ::rtl::IReference
+ {
+ public:
+ /// retrieves the current SQL command of the component
+ virtual ::rtl::OUString getSQLCommand() const = 0;
+ /// retrieves the current value of the EscapeProcessing property of the component
+ virtual sal_Bool getEscapeProcessing() const = 0;
+
+ /// sets a new SQL command
+ virtual void setSQLCommand( const ::rtl::OUString& _rCommand ) const = 0;
+ /// sets a new EscapeProcessing property value
+ virtual void setEscapeProcessing( const sal_Bool _bEscapeProcessing ) const = 0;
+
+ virtual ~ISQLCommandAdapter();
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_SQLCOMMANDDESIGN_HXX
+
diff --git a/extensions/source/propctrlr/standardcontrol.cxx b/extensions/source/propctrlr/standardcontrol.cxx
new file mode 100644
index 000000000000..cd38db9c9944
--- /dev/null
+++ b/extensions/source/propctrlr/standardcontrol.cxx
@@ -0,0 +1,1442 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "standardcontrol.hxx"
+#include "pcrcommon.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include <com/sun/star/util/Color.hpp>
+#include <com/sun/star/util/MeasureUnit.hpp>
+#include <com/sun/star/inspection/PropertyControlType.hpp>
+/** === end UNO includes === **/
+#include <rtl/math.hxx>
+#include <sfx2/objsh.hxx>
+
+//==================================================================
+// ugly dependencies for the OColorControl
+#ifndef _SVX_SVXIDS_HRC
+#include <svx/svxids.hrc>
+#endif
+#include <svx/drawitem.hxx>
+#include <svx/xtable.hxx>
+//==================================================================
+#include <vcl/floatwin.hxx>
+#include <svtools/svmedit.hxx>
+#include <svtools/colorcfg.hxx>
+#include <unotools/syslocale.hxx>
+#include <unotools/datetime.hxx>
+#include <i18npool/mslangid.hxx>
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#include <vcl/svapp.hxx>
+//==================================================================
+
+#include <memory>
+#include <limits>
+#include <boost/bind.hpp>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::awt;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::inspection;
+
+ //==================================================================
+ //= OTimeControl
+ //==================================================================
+ //------------------------------------------------------------------
+ OTimeControl::OTimeControl( Window* pParent, WinBits nWinStyle )
+ :OTimeControl_Base( PropertyControlType::TimeField, pParent, nWinStyle )
+ {
+ getTypedControlWindow()->SetStrictFormat( sal_True );
+ getTypedControlWindow()->SetFormat( TIMEF_SEC );
+ getTypedControlWindow()->EnableEmptyFieldValue( sal_True );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OTimeControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
+ {
+ util::Time aUNOTime;
+ if ( !( _rValue >>= aUNOTime ) )
+ {
+ getTypedControlWindow()->SetText( String() );
+ getTypedControlWindow()->SetEmptyTime();
+ }
+ else
+ {
+ ::Time aTime( aUNOTime.Hours, aUNOTime.Minutes, aUNOTime.Seconds, aUNOTime.HundredthSeconds );
+ getTypedControlWindow()->SetTime( aTime );
+ }
+ }
+
+ //------------------------------------------------------------------
+ Any SAL_CALL OTimeControl::getValue() throw (RuntimeException)
+ {
+ Any aPropValue;
+ if ( getTypedControlWindow()->GetText().Len()>0 )
+ {
+ ::Time aTime( getTypedControlWindow()->GetTime() );
+ util::Time aUNOTime( aTime.Get100Sec(), aTime.GetSec(), aTime.GetMin(), aTime.GetHour() );
+ aPropValue <<= aUNOTime;
+ }
+ return aPropValue;
+ }
+
+ //------------------------------------------------------------------
+ Type SAL_CALL OTimeControl::getValueType() throw (RuntimeException)
+ {
+ return ::getCppuType( static_cast< util::Time* >( NULL ) );
+ }
+
+ //==================================================================
+ //= ODateControl
+ //==================================================================
+ //------------------------------------------------------------------
+ ODateControl::ODateControl( Window* pParent, WinBits nWinStyle )
+ :ODateControl_Base( PropertyControlType::DateField, pParent, nWinStyle | WB_DROPDOWN )
+ {
+ WindowType* pControlWindow = getTypedControlWindow();
+ pControlWindow->SetStrictFormat(sal_True);
+
+ pControlWindow->SetMin( ::Date( 1,1,1600 ) );
+ pControlWindow->SetFirst( ::Date( 1,1,1600 ) );
+ pControlWindow->SetLast( ::Date( 1, 1, 9999 ) );
+ pControlWindow->SetMax( ::Date( 1, 1, 9999 ) );
+
+ pControlWindow->SetExtDateFormat( XTDATEF_SYSTEM_SHORT_YYYY );
+ pControlWindow->EnableEmptyFieldValue( sal_True );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL ODateControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
+ {
+ util::Date aUNODate;
+ if ( !( _rValue >>= aUNODate ) )
+ {
+ getTypedControlWindow()->SetText( String() );
+ getTypedControlWindow()->SetEmptyDate();
+ }
+ else
+ {
+ ::Date aDate( aUNODate.Day, aUNODate.Month, aUNODate.Year );
+ getTypedControlWindow()->SetDate( aDate );
+ }
+ }
+
+ //------------------------------------------------------------------
+ Any SAL_CALL ODateControl::getValue() throw (RuntimeException)
+ {
+ Any aPropValue;
+ if ( getTypedControlWindow()->GetText().Len() > 0 )
+ {
+ ::Date aDate( getTypedControlWindow()->GetDate() );
+ util::Date aUNODate( aDate.GetDay(), aDate.GetMonth(), aDate.GetYear() );
+ aPropValue <<= aUNODate;
+ }
+ return aPropValue;
+ }
+
+ //------------------------------------------------------------------
+ Type SAL_CALL ODateControl::getValueType() throw (RuntimeException)
+ {
+ return ::getCppuType( static_cast< util::Date* >( NULL ) );
+ }
+
+ //==================================================================
+ //= OEditControl
+ //==================================================================
+ //------------------------------------------------------------------
+ OEditControl::OEditControl(Window* _pParent, sal_Bool _bPW, WinBits _nWinStyle)
+ :OEditControl_Base( _bPW ? PropertyControlType::CharacterField : PropertyControlType::TextField, _pParent, _nWinStyle )
+ {
+ m_bIsPassword = _bPW;
+
+ if ( m_bIsPassword )
+ getTypedControlWindow()->SetMaxTextLen( 1 );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OEditControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
+ {
+ ::rtl::OUString sText;
+ if ( m_bIsPassword )
+ {
+ sal_Int16 nValue = 0;
+ _rValue >>= nValue;
+ if ( nValue )
+ {
+ sal_Unicode nCharacter = nValue;
+ sText = String( &nCharacter, 1 );
+ }
+ }
+ else
+ _rValue >>= sText;
+
+ getTypedControlWindow()->SetText( sText );
+ }
+
+ //------------------------------------------------------------------
+ Any SAL_CALL OEditControl::getValue() throw (RuntimeException)
+ {
+ Any aPropValue;
+
+ ::rtl::OUString sText( getTypedControlWindow()->GetText() );
+ if ( m_bIsPassword )
+ {
+ if ( sText.getLength() )
+ aPropValue <<= (sal_Int16)sText.getStr()[0];
+ }
+ else
+ aPropValue <<= sText;
+
+ return aPropValue;
+ }
+
+ //------------------------------------------------------------------
+ Type SAL_CALL OEditControl::getValueType() throw (RuntimeException)
+ {
+ return m_bIsPassword ? ::getCppuType( static_cast< sal_Int16* >( NULL ) ) : ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) );
+ }
+
+ //------------------------------------------------------------------
+ void OEditControl::modified()
+ {
+ OEditControl_Base::modified();
+
+ // for pasword controls, we fire a commit for every single change
+ if ( m_bIsPassword )
+ m_aImplControl.notifyModifiedValue();
+ }
+
+ //------------------------------------------------------------------
+ static long ImplCalcLongValue( double nValue, sal_uInt16 nDigits )
+ {
+ double n = nValue;
+ for ( sal_uInt16 d = 0; d < nDigits; ++d )
+ n *= 10;
+
+ if ( n > ::std::numeric_limits< long >::max() )
+ return ::std::numeric_limits< long >::max();
+ return (long)n;
+ }
+
+ //------------------------------------------------------------------
+ static double ImplCalcDoubleValue( long nValue, sal_uInt16 nDigits )
+ {
+ double n = nValue;
+ for ( sal_uInt16 d = 0; d < nDigits; ++d )
+ n /= 10;
+ return n;
+ }
+
+ //==================================================================
+ // class ODateTimeControl
+ //==================================================================
+ //------------------------------------------------------------------
+ ODateTimeControl::ODateTimeControl( Window* _pParent, WinBits _nWinStyle)
+ :ODateTimeControl_Base( PropertyControlType::DateTimeField, _pParent, _nWinStyle )
+ {
+ getTypedControlWindow()->EnableEmptyField( sal_True );
+
+ // determine a default format
+ Locale aSysLocale = SvtSysLocale().GetLocaleData().getLocale();
+ LanguageType eSysLanguage = MsLangId::convertLocaleToLanguage( aSysLocale );
+
+ getTypedControlWindow()->SetFormatter( getTypedControlWindow()->StandardFormatter() );
+ SvNumberFormatter* pFormatter = getTypedControlWindow()->GetFormatter();
+ sal_uLong nStandardDateTimeFormat = pFormatter->GetStandardFormat( NUMBERFORMAT_DATETIME, eSysLanguage );
+
+ getTypedControlWindow()->SetFormatKey( nStandardDateTimeFormat );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL ODateTimeControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
+ {
+ if ( !_rValue.hasValue() )
+ {
+ getTypedControlWindow()->SetText( String() );
+ }
+ else
+ {
+ util::DateTime aUNODateTime;
+ OSL_VERIFY( _rValue >>= aUNODateTime );
+
+ ::DateTime aDateTime;
+ ::utl::typeConvert( aUNODateTime, aDateTime );
+
+ double nValue = aDateTime - ::DateTime( *getTypedControlWindow()->GetFormatter()->GetNullDate() );
+ getTypedControlWindow()->SetValue( nValue );
+ }
+ }
+
+ //------------------------------------------------------------------
+ Any SAL_CALL ODateTimeControl::getValue() throw (RuntimeException)
+ {
+ Any aPropValue;
+ if ( getTypedControlWindow()->GetText().Len() )
+ {
+ double nValue = getTypedControlWindow()->GetValue();
+
+ ::DateTime aDateTime( *getTypedControlWindow()->GetFormatter()->GetNullDate() );
+
+ // add the "days" part
+ double nDays = floor( nValue );
+ aDateTime += nDays;
+
+ // add the "time" part
+ double nTime = nValue - nDays;
+ nTime = ::rtl::math::round( nTime * 86400.0 ) / 86400.0;
+ // we're not interested in 100th seconds, and this here prevents rounding errors
+ aDateTime += nTime;
+
+ util::DateTime aUNODateTime;
+ ::utl::typeConvert( aDateTime, aUNODateTime );
+
+ aPropValue <<= aUNODateTime;
+ }
+ return aPropValue;
+ }
+
+ //------------------------------------------------------------------
+ Type SAL_CALL ODateTimeControl::getValueType() throw (RuntimeException)
+ {
+ return ::getCppuType( static_cast< util::DateTime* >( NULL ) );
+ }
+
+ //========================================================================
+ //= HyperlinkInput
+ //========================================================================
+ //--------------------------------------------------------------------
+ HyperlinkInput::HyperlinkInput( Window* _pParent, WinBits _nWinStyle )
+ :Edit( _pParent, _nWinStyle )
+ {
+ ::svtools::ColorConfig aColorConfig;
+ ::svtools::ColorConfigValue aLinkColor( aColorConfig.GetColorValue( ::svtools::LINKS ) );
+
+ AllSettings aAllSettings( GetSettings() );
+ StyleSettings aStyleSettings( aAllSettings.GetStyleSettings() );
+
+ Font aFieldFont( aStyleSettings.GetFieldFont() );
+ aFieldFont.SetUnderline( UNDERLINE_SINGLE );
+ aFieldFont.SetColor( aLinkColor.nColor );
+ aStyleSettings.SetFieldFont( aFieldFont );
+
+ aStyleSettings.SetFieldTextColor( aLinkColor.nColor );
+
+ aAllSettings.SetStyleSettings( aStyleSettings );
+ SetSettings( aAllSettings );
+ }
+
+ //--------------------------------------------------------------------
+ void HyperlinkInput::MouseMove( const ::MouseEvent& rMEvt )
+ {
+ Edit::MouseMove( rMEvt );
+
+ PointerStyle ePointerStyle( POINTER_TEXT );
+
+ if ( !rMEvt.IsLeaveWindow() )
+ {
+ if ( impl_textHitTest( rMEvt.GetPosPixel() ) )
+ ePointerStyle = POINTER_REFHAND;
+ }
+
+ SetPointer( Pointer( ePointerStyle ) );
+ }
+
+ //--------------------------------------------------------------------
+ void HyperlinkInput::MouseButtonDown( const ::MouseEvent& rMEvt )
+ {
+ Edit::MouseButtonDown( rMEvt );
+
+ if ( impl_textHitTest( rMEvt.GetPosPixel() ) )
+ m_aMouseButtonDownPos = rMEvt.GetPosPixel();
+ else
+ m_aMouseButtonDownPos.X() = m_aMouseButtonDownPos.Y() = -1;
+ }
+
+ //--------------------------------------------------------------------
+ void HyperlinkInput::MouseButtonUp( const ::MouseEvent& rMEvt )
+ {
+ Edit::MouseButtonUp( rMEvt );
+
+ impl_checkEndClick( rMEvt );
+ }
+
+ //--------------------------------------------------------------------
+ bool HyperlinkInput::impl_textHitTest( const ::Point& _rWindowPos )
+ {
+ xub_StrLen nPos = GetCharPos( _rWindowPos );
+ return ( ( nPos != STRING_LEN ) && ( nPos < GetText().Len() ) );
+ }
+
+ //--------------------------------------------------------------------
+ void HyperlinkInput::impl_checkEndClick( const ::MouseEvent rMEvt )
+ {
+ const MouseSettings& rMouseSettings( GetSettings().GetMouseSettings() );
+ if ( ( abs( rMEvt.GetPosPixel().X() - m_aMouseButtonDownPos.X() ) < rMouseSettings.GetStartDragWidth() )
+ && ( abs( rMEvt.GetPosPixel().Y() - m_aMouseButtonDownPos.Y() ) < rMouseSettings.GetStartDragHeight() )
+ )
+ Application::PostUserEvent( m_aClickHandler );
+ }
+
+ //--------------------------------------------------------------------
+ void HyperlinkInput::Tracking( const TrackingEvent& rTEvt )
+ {
+ Edit::Tracking( rTEvt );
+
+ if ( rTEvt.IsTrackingEnded() )
+ impl_checkEndClick( rTEvt.GetMouseEvent() );
+ }
+
+ //========================================================================
+ //= OHyperlinkControl
+ //========================================================================
+ //--------------------------------------------------------------------
+ OHyperlinkControl::OHyperlinkControl( Window* _pParent, WinBits _nWinStyle )
+ :OHyperlinkControl_Base( PropertyControlType::HyperlinkField, _pParent, _nWinStyle )
+ ,m_aActionListeners( m_aMutex )
+ {
+ getTypedControlWindow()->SetClickHdl( LINK( this, OHyperlinkControl, OnHyperlinkClicked ) );
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL OHyperlinkControl::getValue() throw (RuntimeException)
+ {
+ ::rtl::OUString sText = getTypedControlWindow()->GetText();
+ return makeAny( sText );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OHyperlinkControl::setValue( const Any& _value ) throw (IllegalTypeException, RuntimeException)
+ {
+ ::rtl::OUString sText;
+ _value >>= sText;
+ getTypedControlWindow()->SetText( sText );
+ }
+
+ //--------------------------------------------------------------------
+ Type SAL_CALL OHyperlinkControl::getValueType() throw (RuntimeException)
+ {
+ return ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OHyperlinkControl::addActionListener( const Reference< XActionListener >& listener ) throw (RuntimeException)
+ {
+ if ( listener.is() )
+ m_aActionListeners.addInterface( listener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OHyperlinkControl::removeActionListener( const Reference< XActionListener >& listener ) throw (RuntimeException)
+ {
+ m_aActionListeners.removeInterface( listener );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OHyperlinkControl::disposing()
+ {
+ OHyperlinkControl_Base::disposing();
+
+ EventObject aEvent( *this );
+ m_aActionListeners.disposeAndClear( aEvent );
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( OHyperlinkControl, OnHyperlinkClicked, void*, /*_NotInterestedIn*/ )
+ {
+ ActionEvent aEvent( *this, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "clicked" ) ) );
+ m_aActionListeners.forEach< XActionListener >(
+ boost::bind(
+ &XActionListener::actionPerformed,
+ _1, boost::cref(aEvent) ) );
+
+ return 0;
+ }
+
+ //==================================================================
+ //= ONumericControl
+ //==================================================================
+ //------------------------------------------------------------------
+ ONumericControl::ONumericControl( Window* _pParent, WinBits _nWinStyle )
+ :ONumericControl_Base( PropertyControlType::NumericField, _pParent, _nWinStyle )
+ ,m_eValueUnit( FUNIT_NONE )
+ ,m_nFieldToUNOValueFactor( 1 )
+ {
+ getTypedControlWindow()->SetDefaultUnit( FUNIT_NONE );
+
+ getTypedControlWindow()->EnableEmptyFieldValue( sal_True );
+ getTypedControlWindow()->SetStrictFormat( sal_True );
+ Optional< double > value( getMaxValue() );
+ value.Value = -value.Value;
+ setMinValue( value );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Int16 SAL_CALL ONumericControl::getDecimalDigits() throw (RuntimeException)
+ {
+ return getTypedControlWindow()->GetDecimalDigits();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ONumericControl::setDecimalDigits( ::sal_Int16 _decimaldigits ) throw (RuntimeException)
+ {
+ getTypedControlWindow()->SetDecimalDigits( _decimaldigits );
+ }
+
+ //--------------------------------------------------------------------
+ Optional< double > SAL_CALL ONumericControl::getMinValue() throw (RuntimeException)
+ {
+ Optional< double > aReturn( sal_True, 0 );
+
+ sal_Int64 minValue = getTypedControlWindow()->GetMin();
+ if ( minValue == ::std::numeric_limits< sal_Int64 >::min() )
+ aReturn.IsPresent = sal_False;
+ else
+ aReturn.Value = (double)minValue;
+
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ONumericControl::setMinValue( const Optional< double >& _minvalue ) throw (RuntimeException)
+ {
+ if ( !_minvalue.IsPresent )
+ getTypedControlWindow()->SetMin( ::std::numeric_limits< sal_Int64 >::min() );
+ else
+ getTypedControlWindow()->SetMin( impl_apiValueToFieldValue_nothrow( _minvalue.Value ) , m_eValueUnit);
+ }
+
+ //--------------------------------------------------------------------
+ Optional< double > SAL_CALL ONumericControl::getMaxValue() throw (RuntimeException)
+ {
+ Optional< double > aReturn( sal_True, 0 );
+
+ sal_Int64 maxValue = getTypedControlWindow()->GetMax();
+ if ( maxValue == ::std::numeric_limits< sal_Int64 >::max() )
+ aReturn.IsPresent = sal_False;
+ else
+ aReturn.Value = (double)maxValue;
+
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ONumericControl::setMaxValue( const Optional< double >& _maxvalue ) throw (RuntimeException)
+ {
+ if ( !_maxvalue.IsPresent )
+ getTypedControlWindow()->SetMax( ::std::numeric_limits< sal_Int64 >::max() );
+ else
+ getTypedControlWindow()->SetMax( impl_apiValueToFieldValue_nothrow( _maxvalue.Value ), m_eValueUnit );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Int16 SAL_CALL ONumericControl::getDisplayUnit() throw (RuntimeException)
+ {
+ return VCLUnoHelper::ConvertToMeasurementUnit( getTypedControlWindow()->GetUnit(), 1 );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ONumericControl::setDisplayUnit( ::sal_Int16 _displayunit ) throw (IllegalArgumentException, RuntimeException)
+ {
+ if ( ( _displayunit < MeasureUnit::MM_100TH ) || ( _displayunit > MeasureUnit::PERCENT ) )
+ throw IllegalArgumentException();
+ if ( ( _displayunit == MeasureUnit::MM_100TH )
+ || ( _displayunit == MeasureUnit::MM_10TH )
+ || ( _displayunit == MeasureUnit::INCH_1000TH )
+ || ( _displayunit == MeasureUnit::INCH_100TH )
+ || ( _displayunit == MeasureUnit::INCH_10TH )
+ || ( _displayunit == MeasureUnit::PERCENT )
+ )
+ throw IllegalArgumentException();
+
+ sal_Int16 nDummyFactor = 1;
+ FieldUnit eFieldUnit = VCLUnoHelper::ConvertToFieldUnit( _displayunit, nDummyFactor );
+ if ( nDummyFactor != 1 )
+ // everything which survived the checks above should result in a factor of 1, i.e.,
+ // it should have a direct counterpart as FieldUnit
+ throw RuntimeException();
+ getTypedControlWindow()->SetUnit( eFieldUnit );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Int16 SAL_CALL ONumericControl::getValueUnit() throw (RuntimeException)
+ {
+ return VCLUnoHelper::ConvertToMeasurementUnit( m_eValueUnit, m_nFieldToUNOValueFactor );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ONumericControl::setValueUnit( ::sal_Int16 _valueunit ) throw (RuntimeException)
+ {
+ if ( ( _valueunit < MeasureUnit::MM_100TH ) || ( _valueunit > MeasureUnit::PERCENT ) )
+ throw IllegalArgumentException();
+ m_eValueUnit = VCLUnoHelper::ConvertToFieldUnit( _valueunit, m_nFieldToUNOValueFactor );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ONumericControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
+ {
+ if ( !_rValue.hasValue() )
+ {
+ getTypedControlWindow()->SetText( String() );
+ getTypedControlWindow()->SetEmptyFieldValue();
+ }
+ else
+ {
+ double nValue( 0 );
+ OSL_VERIFY( _rValue >>= nValue );
+ long nControlValue = impl_apiValueToFieldValue_nothrow( nValue );
+ getTypedControlWindow()->SetValue( nControlValue, m_eValueUnit );
+ }
+ }
+
+ //------------------------------------------------------------------
+ long ONumericControl::impl_apiValueToFieldValue_nothrow( double _nApiValue ) const
+ {
+ long nControlValue = ImplCalcLongValue( _nApiValue, getTypedControlWindow()->GetDecimalDigits() );
+ nControlValue /= m_nFieldToUNOValueFactor;
+ return nControlValue;
+ }
+
+ //------------------------------------------------------------------
+ double ONumericControl::impl_fieldValueToApiValue_nothrow( sal_Int64 _nFieldValue ) const
+ {
+ double nApiValue = ImplCalcDoubleValue( (long)_nFieldValue, getTypedControlWindow()->GetDecimalDigits() );
+ nApiValue *= m_nFieldToUNOValueFactor;
+ return nApiValue;
+ }
+
+ //------------------------------------------------------------------
+ Any SAL_CALL ONumericControl::getValue() throw (RuntimeException)
+ {
+ Any aPropValue;
+ if ( getTypedControlWindow()->GetText().Len() )
+ {
+ double nValue = impl_fieldValueToApiValue_nothrow( getTypedControlWindow()->GetValue( m_eValueUnit ) );
+ aPropValue <<= nValue;
+ }
+ return aPropValue;
+ }
+
+ //------------------------------------------------------------------
+ Type SAL_CALL ONumericControl::getValueType() throw (RuntimeException)
+ {
+ return ::getCppuType( static_cast< double* >( NULL ) );
+ }
+
+ //==================================================================
+ //= OColorControl
+ //==================================================================
+ #define LB_DEFAULT_COUNT 20
+ //------------------------------------------------------------------
+ String MakeHexStr(sal_uInt32 nVal, sal_uInt32 nLength)
+ {
+ String aStr;
+ while (nVal>0)
+ {
+ char c=char(nVal & 0x000F);
+ nVal>>=4;
+ if (c<=9) c+='0';
+ else c+='A'-10;
+ aStr.Insert(c,0);
+ }
+ while (aStr.Len() < nLength) aStr.Insert('0',0);
+ return aStr;
+ }
+
+ //------------------------------------------------------------------
+ OColorControl::OColorControl(Window* pParent, WinBits nWinStyle)
+ :OColorControl_Base( PropertyControlType::ColorListBox, pParent, nWinStyle )
+ {
+ // initialize the color listbox
+ XColorTable* pColorTable = NULL;
+ SfxObjectShell* pDocSh = SfxObjectShell::Current();
+ const SfxPoolItem* pItem = pDocSh ? pDocSh->GetItem( SID_COLOR_TABLE ) : NULL;
+ if ( pItem )
+ {
+ DBG_ASSERT(pItem->ISA(SvxColorTableItem), "OColorControl::OColorControl: invalid color item!");
+ pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable();
+ }
+
+ if ( !pColorTable )
+ {
+ pColorTable = XColorTable::GetStdColorTable();
+ }
+
+
+ DBG_ASSERT(pColorTable, "OColorControl::OColorControl: no color table!");
+
+ if (pColorTable)
+ {
+ for (sal_uInt16 i = 0; i < pColorTable->Count(); ++i)
+ {
+ XColorEntry* pEntry = pColorTable->GetColor( i );
+ getTypedControlWindow()->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
+ }
+ }
+
+ getTypedControlWindow()->SetDropDownLineCount( LB_DEFAULT_COUNT );
+ if ( ( nWinStyle & WB_READONLY ) != 0 )
+ {
+ getTypedControlWindow()->SetReadOnly( sal_True );
+ getTypedControlWindow()->Enable( sal_True );
+ }
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OColorControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
+ {
+ if ( _rValue.hasValue() )
+ {
+ ::com::sun::star::util::Color nColor = COL_TRANSPARENT;
+ if ( _rValue >>= nColor )
+ {
+ ::Color aRgbCol((ColorData)nColor);
+
+ getTypedControlWindow()->SelectEntry( aRgbCol );
+ if ( !getTypedControlWindow()->IsEntrySelected( aRgbCol ) )
+ { // the given color is not part of the list -> insert a new entry with the hex code of the color
+ String aStr = String::CreateFromAscii("0x");
+ aStr += MakeHexStr(nColor,8);
+ getTypedControlWindow()->InsertEntry( aRgbCol, aStr );
+ getTypedControlWindow()->SelectEntry( aRgbCol );
+ }
+ }
+ else
+ {
+ ::rtl::OUString sNonColorValue;
+ if ( !( _rValue >>= sNonColorValue ) )
+ throw IllegalTypeException();
+ getTypedControlWindow()->SelectEntry( sNonColorValue );
+ if ( !getTypedControlWindow()->IsEntrySelected( sNonColorValue ) )
+ getTypedControlWindow()->SetNoSelection();
+ }
+ }
+ else
+ getTypedControlWindow()->SetNoSelection();
+ }
+
+ //------------------------------------------------------------------
+ Any SAL_CALL OColorControl::getValue() throw (RuntimeException)
+ {
+ Any aPropValue;
+ if ( getTypedControlWindow()->GetSelectEntryCount() > 0 )
+ {
+ ::rtl::OUString sSelectedEntry = getTypedControlWindow()->GetSelectEntry();
+ if ( m_aNonColorEntries.find( sSelectedEntry ) != m_aNonColorEntries.end() )
+ aPropValue <<= sSelectedEntry;
+ else
+ {
+ ::Color aRgbCol = getTypedControlWindow()->GetSelectEntryColor();
+ aPropValue <<= (::com::sun::star::util::Color)aRgbCol.GetColor();
+ }
+ }
+ return aPropValue;
+ }
+
+ //------------------------------------------------------------------
+ Type SAL_CALL OColorControl::getValueType() throw (RuntimeException)
+ {
+ return ::getCppuType( static_cast< sal_Int32* >( NULL ) );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OColorControl::clearList() throw (RuntimeException)
+ {
+ getTypedControlWindow()->Clear();
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OColorControl::prependListEntry( const ::rtl::OUString& NewEntry ) throw (RuntimeException)
+ {
+ getTypedControlWindow()->InsertEntry( NewEntry, 0 );
+ m_aNonColorEntries.insert( NewEntry );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OColorControl::appendListEntry( const ::rtl::OUString& NewEntry ) throw (RuntimeException)
+ {
+ getTypedControlWindow()->InsertEntry( NewEntry );
+ m_aNonColorEntries.insert( NewEntry );
+ }
+ //------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL OColorControl::getListEntries( ) throw (RuntimeException)
+ {
+ if ( !m_aNonColorEntries.empty() )
+ return Sequence< ::rtl::OUString >(&(*m_aNonColorEntries.begin()),m_aNonColorEntries.size());
+ return Sequence< ::rtl::OUString >();
+ }
+
+ //------------------------------------------------------------------
+ void OColorControl::modified()
+ {
+ OColorControl_Base::modified();
+
+ if ( !getTypedControlWindow()->IsTravelSelect() )
+ // fire a commit
+ m_aImplControl.notifyModifiedValue();
+ }
+
+ //==================================================================
+ //= OListboxControl
+ //==================================================================
+ //------------------------------------------------------------------
+ OListboxControl::OListboxControl( Window* pParent, WinBits nWinStyle)
+ :OListboxControl_Base( PropertyControlType::ListBox, pParent, nWinStyle )
+ {
+ getTypedControlWindow()->SetDropDownLineCount( LB_DEFAULT_COUNT );
+ if ( ( nWinStyle & WB_READONLY ) != 0 )
+ {
+ getTypedControlWindow()->SetReadOnly( sal_True );
+ getTypedControlWindow()->Enable( sal_True );
+ }
+ }
+
+ //------------------------------------------------------------------
+ Any SAL_CALL OListboxControl::getValue() throw (RuntimeException)
+ {
+ ::rtl::OUString sControlValue( getTypedControlWindow()->GetSelectEntry() );
+
+ Any aPropValue;
+ if ( sControlValue.getLength() )
+ aPropValue <<= sControlValue;
+ return aPropValue;
+ }
+
+ //------------------------------------------------------------------
+ Type SAL_CALL OListboxControl::getValueType() throw (RuntimeException)
+ {
+ return ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OListboxControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
+ {
+ if ( !_rValue.hasValue() )
+ getTypedControlWindow()->SetNoSelection();
+ else
+ {
+ ::rtl::OUString sSelection;
+ _rValue >>= sSelection;
+
+ if ( !sSelection.equals( getTypedControlWindow()->GetSelectEntry() ) )
+ getTypedControlWindow()->SelectEntry( sSelection );
+
+ if ( !getTypedControlWindow()->IsEntrySelected( sSelection ) )
+ {
+ getTypedControlWindow()->InsertEntry( sSelection, 0 );
+ getTypedControlWindow()->SelectEntry( sSelection );
+ }
+ }
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OListboxControl::clearList() throw (RuntimeException)
+ {
+ getTypedControlWindow()->Clear();
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OListboxControl::prependListEntry( const ::rtl::OUString& NewEntry ) throw (RuntimeException)
+ {
+ getTypedControlWindow()->InsertEntry( NewEntry, 0 );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OListboxControl::appendListEntry( const ::rtl::OUString& NewEntry ) throw (RuntimeException)
+ {
+ getTypedControlWindow()->InsertEntry( NewEntry );
+ }
+ //------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL OListboxControl::getListEntries( ) throw (RuntimeException)
+ {
+ const sal_uInt16 nCount = getTypedControlWindow()->GetEntryCount();
+ Sequence< ::rtl::OUString > aRet(nCount);
+ ::rtl::OUString* pIter = aRet.getArray();
+ for (sal_uInt16 i = 0; i < nCount ; ++i,++pIter)
+ *pIter = getTypedControlWindow()->GetEntry(i);
+
+ return aRet;
+ }
+
+ //------------------------------------------------------------------
+ void OListboxControl::modified()
+ {
+ OListboxControl_Base::modified();
+
+ if ( !getTypedControlWindow()->IsTravelSelect() )
+ // fire a commit
+ m_aImplControl.notifyModifiedValue();
+ }
+
+ //==================================================================
+ //= OComboboxControl
+ //==================================================================
+ //------------------------------------------------------------------
+ OComboboxControl::OComboboxControl( Window* pParent, WinBits nWinStyle)
+ :OComboboxControl_Base( PropertyControlType::ComboBox, pParent, nWinStyle )
+ {
+ getTypedControlWindow()->SetDropDownLineCount( LB_DEFAULT_COUNT );
+ getTypedControlWindow()->SetSelectHdl( LINK( this, OComboboxControl, OnEntrySelected ) );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OComboboxControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
+ {
+ ::rtl::OUString sText;
+ _rValue >>= sText;
+ getTypedControlWindow()->SetText( sText );
+ }
+
+ //------------------------------------------------------------------
+ Any SAL_CALL OComboboxControl::getValue() throw (RuntimeException)
+ {
+ return makeAny( ::rtl::OUString( getTypedControlWindow()->GetText() ) );
+ }
+
+ //------------------------------------------------------------------
+ Type SAL_CALL OComboboxControl::getValueType() throw (RuntimeException)
+ {
+ return ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OComboboxControl::clearList() throw (RuntimeException)
+ {
+ getTypedControlWindow()->Clear();
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OComboboxControl::prependListEntry( const ::rtl::OUString& NewEntry ) throw (RuntimeException)
+ {
+ getTypedControlWindow()->InsertEntry( NewEntry, 0 );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OComboboxControl::appendListEntry( const ::rtl::OUString& NewEntry ) throw (RuntimeException)
+ {
+ getTypedControlWindow()->InsertEntry( NewEntry );
+ }
+ //------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL OComboboxControl::getListEntries( ) throw (RuntimeException)
+ {
+ const sal_uInt16 nCount = getTypedControlWindow()->GetEntryCount();
+ Sequence< ::rtl::OUString > aRet(nCount);
+ ::rtl::OUString* pIter = aRet.getArray();
+ for (sal_uInt16 i = 0; i < nCount ; ++i,++pIter)
+ *pIter = getTypedControlWindow()->GetEntry(i);
+
+ return aRet;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( OComboboxControl, OnEntrySelected, void*, /*_pNothing*/ )
+ {
+ if ( !getTypedControlWindow()->IsTravelSelect() )
+ // fire a commit
+ m_aImplControl.notifyModifiedValue();
+ return 0L;
+ }
+
+ //==================================================================
+ //= OMultilineFloatingEdit
+ //==================================================================
+ class OMultilineFloatingEdit : public FloatingWindow
+ {
+ private:
+ MultiLineEdit m_aImplEdit;
+
+ protected:
+ virtual void Resize();
+
+ public:
+ OMultilineFloatingEdit(Window* _pParen);
+ MultiLineEdit* getEdit() { return &m_aImplEdit; }
+
+ protected:
+ virtual long PreNotify(NotifyEvent& _rNEvt);
+ };
+
+ //------------------------------------------------------------------
+ OMultilineFloatingEdit::OMultilineFloatingEdit(Window* _pParent)
+ :FloatingWindow(_pParent, WB_BORDER)
+ ,m_aImplEdit(this, WB_VSCROLL|WB_IGNORETAB|WB_NOBORDER)
+ {
+ m_aImplEdit.Show();
+ }
+
+ //------------------------------------------------------------------
+ void OMultilineFloatingEdit::Resize()
+ {
+ m_aImplEdit.SetSizePixel(GetOutputSizePixel());
+ }
+
+ //------------------------------------------------------------------
+ long OMultilineFloatingEdit::PreNotify(NotifyEvent& _rNEvt)
+ {
+ long nResult = sal_True;
+
+ sal_uInt16 nSwitch = _rNEvt.GetType();
+ if (EVENT_KEYINPUT == nSwitch)
+ {
+ const KeyCode& aKeyCode = _rNEvt.GetKeyEvent()->GetKeyCode();
+ sal_uInt16 nKey = aKeyCode.GetCode();
+
+ if ( ( (KEY_RETURN == nKey)
+ && !aKeyCode.IsShift()
+ )
+ || ( (KEY_UP == nKey)
+ && aKeyCode.IsMod2()
+ )
+ )
+ {
+ EndPopupMode();
+ }
+ else
+ nResult=FloatingWindow::PreNotify(_rNEvt);
+ }
+ else
+ nResult=FloatingWindow::PreNotify(_rNEvt);
+
+ return nResult;
+ }
+
+ //==================================================================
+ //= DropDownEditControl_Base
+ //==================================================================
+ //------------------------------------------------------------------
+ DropDownEditControl::DropDownEditControl( Window* _pParent, WinBits _nStyle )
+ :DropDownEditControl_Base( _pParent, _nStyle )
+ ,m_pFloatingEdit( NULL )
+ ,m_pImplEdit( NULL )
+ ,m_pDropdownButton( NULL )
+ ,m_nOperationMode( eStringList )
+ ,m_bDropdown( sal_False )
+ {
+ SetCompoundControl( sal_True );
+
+ m_pImplEdit = new MultiLineEdit( this, WB_TABSTOP | WB_IGNORETAB | WB_NOBORDER | (_nStyle & WB_READONLY) );
+ SetSubEdit( m_pImplEdit );
+ m_pImplEdit->Show();
+
+ if ( _nStyle & WB_DROPDOWN )
+ {
+ m_pDropdownButton = new PushButton( this, WB_NOLIGHTBORDER | WB_RECTSTYLE | WB_NOTABSTOP);
+ m_pDropdownButton->SetSymbol(SYMBOL_SPIN_DOWN);
+ m_pDropdownButton->SetClickHdl( LINK( this, DropDownEditControl, DropDownHdl ) );
+ m_pDropdownButton->Show();
+ }
+
+ m_pFloatingEdit = new OMultilineFloatingEdit(this); //FloatingWindow
+
+ m_pFloatingEdit->SetPopupModeEndHdl( LINK( this, DropDownEditControl, ReturnHdl ) );
+ m_pFloatingEdit->getEdit()->SetReadOnly( ( _nStyle & WB_READONLY ) != 0 );
+ }
+
+ //------------------------------------------------------------------
+ void DropDownEditControl::setControlHelper( ControlHelper& _rControlHelper )
+ {
+ DropDownEditControl_Base::setControlHelper( _rControlHelper );
+ m_pFloatingEdit->getEdit()->SetModifyHdl( LINK( &_rControlHelper, ControlHelper, ModifiedHdl ) );
+ m_pImplEdit->SetGetFocusHdl( LINK( &_rControlHelper, ControlHelper, GetFocusHdl ) );
+ m_pImplEdit->SetModifyHdl( LINK( &_rControlHelper, ControlHelper, ModifiedHdl ) );
+ m_pImplEdit->SetLoseFocusHdl( LINK( &_rControlHelper, ControlHelper, LoseFocusHdl ) );
+ }
+
+ //------------------------------------------------------------------
+ DropDownEditControl::~DropDownEditControl()
+ {
+ {
+ ::std::auto_ptr<Window> aTemp(m_pFloatingEdit);
+ m_pFloatingEdit = NULL;
+ }
+ {
+ ::std::auto_ptr<Window> aTemp(m_pImplEdit);
+ SetSubEdit( NULL );
+ m_pImplEdit = NULL;
+ }
+ {
+ ::std::auto_ptr<Window> aTemp(m_pDropdownButton);
+ m_pDropdownButton = NULL;
+ }
+ }
+
+ //------------------------------------------------------------------
+ void DropDownEditControl::Resize()
+ {
+ ::Size aOutSz = GetOutputSizePixel();
+
+ if (m_pDropdownButton!=NULL)
+ {
+ long nSBWidth = GetSettings().GetStyleSettings().GetScrollBarSize();
+ nSBWidth = CalcZoom( nSBWidth );
+ m_pImplEdit->SetPosSizePixel( 0, 1, aOutSz.Width() - nSBWidth, aOutSz.Height()-2 );
+ m_pDropdownButton->SetPosSizePixel( aOutSz.Width() - nSBWidth, 0, nSBWidth, aOutSz.Height() );
+ }
+ else
+ m_pImplEdit->SetPosSizePixel( 0, 1, aOutSz.Width(), aOutSz.Height()-2 );
+ }
+
+ //------------------------------------------------------------------
+ long DropDownEditControl::PreNotify( NotifyEvent& rNEvt )
+ {
+ long nResult = 1;
+
+ if (rNEvt.GetType() == EVENT_KEYINPUT)
+ {
+ const KeyCode& aKeyCode = rNEvt.GetKeyEvent()->GetKeyCode();
+ sal_uInt16 nKey = aKeyCode.GetCode();
+
+ if ( nKey == KEY_RETURN && !aKeyCode.IsShift() )
+ {
+ if ( m_pHelper )
+ {
+ m_pHelper->LoseFocusHdl( m_pImplEdit );
+ m_pHelper->activateNextControl();
+ }
+ }
+ else if ( nKey == KEY_DOWN && aKeyCode.IsMod2() )
+ {
+ Invalidate();
+ ShowDropDown( sal_True );
+ }
+ else if ( KEYGROUP_CURSOR == aKeyCode.GetGroup()
+ || nKey == KEY_HELP
+ || KEYGROUP_FKEYS == aKeyCode.GetGroup()
+ || m_nOperationMode == eMultiLineText
+ )
+ {
+ nResult = DropDownEditControl_Base::PreNotify( rNEvt );
+ }
+ else if ( m_nOperationMode == eStringList )
+ {
+ Selection aSel = m_pImplEdit->GetSelection();
+ if ( aSel.Min() != aSel.Max() )
+ {
+ aSel.Min() = FindPos( aSel.Min() );
+ aSel.Max() = FindPos( aSel.Max() );
+ }
+ else
+ {
+ aSel.Min() = FindPos( aSel.Min() );
+ aSel.Max() = aSel.Min();
+ }
+ Invalidate();
+ ShowDropDown( sal_True );
+ m_pFloatingEdit->getEdit()->GrabFocus();
+ m_pFloatingEdit->getEdit()->SetSelection( aSel );
+ Window* pFocusWin = Application::GetFocusWindow();
+ pFocusWin->KeyInput( *rNEvt.GetKeyEvent() );
+ }
+ }
+ else
+ nResult = DropDownEditControl_Base::PreNotify(rNEvt);
+
+ return nResult;
+ }
+
+ //------------------------------------------------------------------
+ namespace
+ {
+ //..............................................................
+ StlSyntaxSequence< ::rtl::OUString > lcl_convertMultiLineToList( const String& _rCompsedTextWithLineBreaks )
+ {
+ xub_StrLen nLines( _rCompsedTextWithLineBreaks.GetTokenCount( '\n' ) );
+ StlSyntaxSequence< ::rtl::OUString > aStrings( nLines );
+ StlSyntaxSequence< ::rtl::OUString >::iterator stringItem = aStrings.begin();
+ for ( xub_StrLen token = 0; token < nLines; ++token, ++stringItem )
+ *stringItem = _rCompsedTextWithLineBreaks.GetToken( token, '\n' );
+ return aStrings;
+ }
+
+ String lcl_convertListToMultiLine( const StlSyntaxSequence< ::rtl::OUString >& _rStrings )
+ {
+ String sMultiLineText;
+ for ( StlSyntaxSequence< ::rtl::OUString >::const_iterator item = _rStrings.begin();
+ item != _rStrings.end();
+ )
+ {
+ sMultiLineText += String( *item );
+ if ( ++item != _rStrings.end() )
+ sMultiLineText += '\n';
+ }
+ return sMultiLineText;
+ }
+
+ //..............................................................
+ String lcl_convertListToDisplayText( const StlSyntaxSequence< ::rtl::OUString >& _rStrings )
+ {
+ ::rtl::OUStringBuffer aComposed;
+ for ( StlSyntaxSequence< ::rtl::OUString >::const_iterator strings = _rStrings.begin();
+ strings != _rStrings.end();
+ ++strings
+ )
+ {
+ if ( strings != _rStrings.begin() )
+ aComposed.append( (sal_Unicode)';' );
+ aComposed.append( (sal_Unicode)'\"' );
+ aComposed.append( *strings );
+ aComposed.append( (sal_Unicode)'\"' );
+ }
+ return aComposed.makeStringAndClear();
+ }
+ }
+
+ //------------------------------------------------------------------
+ #define STD_HEIGHT 100
+ sal_Bool DropDownEditControl::ShowDropDown( sal_Bool bShow )
+ {
+ if (bShow)
+ {
+ ::Point aMePos= GetPosPixel();
+ aMePos = GetParent()->OutputToScreenPixel( aMePos );
+ ::Size aSize=GetSizePixel();
+ ::Rectangle aRect(aMePos,aSize);
+ aSize.Height() = STD_HEIGHT;
+ m_pFloatingEdit->SetOutputSizePixel(aSize);
+ m_pFloatingEdit->StartPopupMode( aRect, FLOATWIN_POPUPMODE_DOWN );
+
+ m_pFloatingEdit->Show();
+ m_pFloatingEdit->getEdit()->GrabFocus();
+ m_pFloatingEdit->getEdit()->SetSelection(Selection(m_pFloatingEdit->getEdit()->GetText().Len()));
+ m_bDropdown=sal_True;
+ if ( m_nOperationMode == eMultiLineText )
+ m_pFloatingEdit->getEdit()->SetText( m_pImplEdit->GetText() );
+ m_pImplEdit->SetText(String());
+ }
+ else
+ {
+ m_pFloatingEdit->Hide();
+ m_pFloatingEdit->Invalidate();
+ m_pFloatingEdit->Update();
+
+ // transfer the text from the floating edit to our own edit
+ String sDisplayText( m_pFloatingEdit->getEdit()->GetText() );
+ if ( m_nOperationMode == eStringList )
+ sDisplayText = lcl_convertListToDisplayText( lcl_convertMultiLineToList( sDisplayText ) );
+
+ m_pImplEdit->SetText( sDisplayText );
+ GetParent()->Invalidate( INVALIDATE_CHILDREN );
+ m_bDropdown = sal_False;
+ m_pImplEdit->GrabFocus();
+ }
+ return m_bDropdown;
+
+ }
+
+ //------------------------------------------------------------------
+ long DropDownEditControl::FindPos(long nSinglePos)
+ {
+ long nPos=0;
+ long nDiff=0;
+ String aOutput;
+ String aStr=m_pFloatingEdit->getEdit()->GetText();
+ String aStr1 = GetText();
+
+ if ((nSinglePos == 0) || (nSinglePos == aStr1.Len()))
+ {
+ return nSinglePos;
+ }
+
+ if (aStr.Len()>0)
+ {
+ sal_Int32 nCount = aStr.GetTokenCount('\n');
+
+ String aInput = aStr.GetToken(0,'\n' );
+
+ if (aInput.Len()>0)
+ {
+ aOutput+='\"';
+ nDiff++;
+ aOutput+=aInput;
+ aOutput+='\"';
+ }
+
+ if (nSinglePos <= aOutput.Len())
+ {
+ nPos=nSinglePos-nDiff;
+ }
+ else
+ {
+ for (sal_Int32 i=1; i<nCount; ++i)
+ {
+ aInput=aStr.GetToken((sal_uInt16)i, '\n');
+ if (aInput.Len()>0)
+ {
+ aOutput += ';';
+ aOutput += '\"';
+ nDiff += 2;
+ aOutput += aInput;
+ aOutput += '\"';
+
+ if (nSinglePos <= aOutput.Len())
+ {
+ nPos=nSinglePos-nDiff;
+ break;
+ }
+ }
+ }
+ }
+ }
+ return nPos;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( DropDownEditControl, ReturnHdl, OMultilineFloatingEdit*, /*pMEd*/)
+ {
+
+ String aStr = m_pFloatingEdit->getEdit()->GetText();
+ String aStr2 = GetText();
+ ShowDropDown(sal_False);
+
+ if (aStr!=aStr2 || ( m_nOperationMode == eStringList ) )
+ {
+ if ( m_pHelper )
+ m_pHelper->notifyModifiedValue();
+ }
+
+ return 0;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( DropDownEditControl, DropDownHdl, PushButton*, /*pPb*/ )
+ {
+ ShowDropDown(!m_bDropdown);
+ return 0;
+ }
+
+ //------------------------------------------------------------------
+ void DropDownEditControl::SetStringListValue( const StlSyntaxSequence< ::rtl::OUString >& _rStrings )
+ {
+ SetText( lcl_convertListToDisplayText( _rStrings ) );
+ m_pFloatingEdit->getEdit()->SetText( lcl_convertListToMultiLine( _rStrings ) );
+ }
+
+ //------------------------------------------------------------------
+ StlSyntaxSequence< ::rtl::OUString > DropDownEditControl::GetStringListValue() const
+ {
+ return lcl_convertMultiLineToList( m_pFloatingEdit->getEdit()->GetText() );
+ }
+
+ //------------------------------------------------------------------
+ void DropDownEditControl::SetTextValue( const ::rtl::OUString& _rText )
+ {
+ OSL_PRECOND( m_nOperationMode == eMultiLineText, "DropDownEditControl::SetTextValue: illegal call!" );
+
+ m_pFloatingEdit->getEdit()->SetText( _rText );
+ SetText( _rText );
+ }
+
+ //------------------------------------------------------------------
+ ::rtl::OUString DropDownEditControl::GetTextValue() const
+ {
+ OSL_PRECOND( m_nOperationMode == eMultiLineText, "DropDownEditControl::GetTextValue: illegal call!" );
+ return GetText();
+ }
+
+ //==================================================================
+ //= OMultilineEditControl
+ //==================================================================
+ //------------------------------------------------------------------
+ OMultilineEditControl::OMultilineEditControl( Window* pParent, MultiLineOperationMode _eMode, WinBits nWinStyle )
+ :OMultilineEditControl_Base( _eMode == eMultiLineText ? PropertyControlType::MultiLineTextField : PropertyControlType::StringListField
+ , pParent
+ , ( nWinStyle | WB_DIALOGCONTROL ) & ( ~WB_READONLY | ~WB_DROPDOWN )
+ , false )
+ {
+ getTypedControlWindow()->setOperationMode( _eMode );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OMultilineEditControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
+ {
+ impl_checkDisposed_throw();
+
+ switch ( getTypedControlWindow()->getOperationMode() )
+ {
+ case eMultiLineText:
+ {
+ ::rtl::OUString sText;
+ if ( !( _rValue >>= sText ) && _rValue.hasValue() )
+ throw IllegalTypeException();
+ getTypedControlWindow()->SetTextValue( sText );
+ }
+ break;
+ case eStringList:
+ {
+ Sequence< ::rtl::OUString > aStringLines;
+ if ( !( _rValue >>= aStringLines ) && _rValue.hasValue() )
+ throw IllegalTypeException();
+ getTypedControlWindow()->SetStringListValue( aStringLines );
+ }
+ break;
+ }
+ }
+
+ //------------------------------------------------------------------
+ Any SAL_CALL OMultilineEditControl::getValue() throw (RuntimeException)
+ {
+ impl_checkDisposed_throw();
+
+ Any aValue;
+ switch ( getTypedControlWindow()->getOperationMode() )
+ {
+ case eMultiLineText:
+ aValue <<= getTypedControlWindow()->GetTextValue();
+ break;
+ case eStringList:
+ aValue <<= getTypedControlWindow()->GetStringListValue();
+ break;
+ }
+ return aValue;
+ }
+
+ //------------------------------------------------------------------
+ Type SAL_CALL OMultilineEditControl::getValueType() throw (RuntimeException)
+ {
+ if ( getTypedControlWindow()->getOperationMode() == eMultiLineText )
+ return ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) );
+ return ::getCppuType( static_cast< Sequence< ::rtl::OUString >* >( NULL ) );
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
diff --git a/extensions/source/propctrlr/standardcontrol.hxx b/extensions/source/propctrlr/standardcontrol.hxx
new file mode 100644
index 000000000000..9ee46e110bc6
--- /dev/null
+++ b/extensions/source/propctrlr/standardcontrol.hxx
@@ -0,0 +1,445 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_STANDARDCONTROL_HXX_
+#define _EXTENSIONS_PROPCTRLR_STANDARDCONTROL_HXX_
+
+#include "commoncontrol.hxx"
+#include "pcrcommon.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/XNumericControl.hpp>
+#include <com/sun/star/inspection/XStringListControl.hpp>
+#include <com/sun/star/inspection/XHyperlinkControl.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+/** === end UNO includes === **/
+#include <vcl/field.hxx>
+#include <vcl/longcurr.hxx>
+#include <svtools/ctrlbox.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/combobox.hxx>
+#include <svtools/calendar.hxx>
+#include <svtools/fmtfield.hxx>
+
+#include <set>
+
+class PushButton;
+class MultiLineEdit;
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ //========================================================================
+ //= ListLikeControlWithModifyHandler
+ //========================================================================
+ /** Very small helper class which adds a SetModifyHdl to a ListBox-derived class,
+ thus giving this class the same API (as far as the CommonBehaviourControl is concerned)
+ as all other windows.
+ */
+ template< class LISTBOX_WINDOW >
+ class ListLikeControlWithModifyHandler : public ControlWindow< LISTBOX_WINDOW >
+ {
+ protected:
+ typedef ControlWindow< LISTBOX_WINDOW > ListBoxType;
+
+ public:
+ ListLikeControlWithModifyHandler( Window* _pParent, WinBits _nStyle )
+ :ListBoxType( _pParent, _nStyle )
+ {
+ }
+
+ void SetModifyHdl( const Link& _rLink ) { ListBoxType::SetSelectHdl( _rLink ); }
+
+ protected:
+ long PreNotify( NotifyEvent& _rNEvt );
+ };
+
+ //------------------------------------------------------------------------
+ template< class LISTBOX_WINDOW >
+ long ListLikeControlWithModifyHandler< LISTBOX_WINDOW >::PreNotify( NotifyEvent& _rNEvt )
+ {
+ if ( _rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ const ::KeyEvent* pKeyEvent = _rNEvt.GetKeyEvent();
+ if ( ( pKeyEvent->GetKeyCode().GetModifier() == 0 )
+ && ( ( pKeyEvent->GetKeyCode().GetCode() == KEY_PAGEUP )
+ || ( pKeyEvent->GetKeyCode().GetCode() == KEY_PAGEDOWN )
+ )
+ )
+ {
+ if ( !ListBoxType::IsInDropDown() )
+ {
+ // don't give the base class a chance to consume the event, in the property browser, it is
+ // intended to scroll the complete property page
+ return ListBoxType::GetParent()->PreNotify( _rNEvt );
+ }
+ }
+ }
+ return ListBoxType::PreNotify( _rNEvt );
+ }
+
+ //========================================================================
+ //= OTimeControl
+ //========================================================================
+ typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< TimeField > > OTimeControl_Base;
+ class OTimeControl : public OTimeControl_Base
+ {
+ public:
+ OTimeControl( Window* pParent, WinBits nWinStyle );
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+ };
+
+ //========================================================================
+ //= ODateControl
+ //========================================================================
+ typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< CalendarField > > ODateControl_Base;
+ class ODateControl : public ODateControl_Base
+ {
+ public:
+ ODateControl( Window* pParent, WinBits nWinStyle );
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+ };
+
+ //========================================================================
+ //= OEditControl
+ //========================================================================
+ typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< Edit > > OEditControl_Base;
+ class OEditControl : public OEditControl_Base
+ {
+ protected:
+ sal_Bool m_bIsPassword : 1;
+
+ public:
+ OEditControl( Window* _pParent, sal_Bool _bPassWord, WinBits nWinStyle );
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ virtual void modified();
+ };
+
+ //========================================================================
+ //= ODateTimeControl
+ //========================================================================
+ typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< FormattedField > > ODateTimeControl_Base;
+ class ODateTimeControl : public ODateTimeControl_Base
+ {
+ public:
+ ODateTimeControl( Window* pParent,WinBits nWinStyle );
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+ };
+
+ //========================================================================
+ //= HyperlinkInput
+ //========================================================================
+ class HyperlinkInput : public Edit
+ {
+ private:
+ Point m_aMouseButtonDownPos;
+ Link m_aClickHandler;
+
+ public:
+ HyperlinkInput( Window* _pParent, WinBits _nWinStyle );
+
+ /** sets the handler which will (asynchronously, with locked SolarMutex) be called
+ when the hyperlink has been clicked by the user
+ */
+ void SetClickHdl( const Link& _rHdl ) { m_aClickHandler = _rHdl; }
+ const Link& GetClickHdl( ) const { return m_aClickHandler; }
+
+ protected:
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+ virtual void Tracking( const TrackingEvent& rTEvt );
+
+ private:
+ void impl_checkEndClick( const MouseEvent rMEvt );
+ bool impl_textHitTest( const Point& _rWindowPos );
+ };
+
+ //========================================================================
+ //= OHyperlinkControl
+ //========================================================================
+ typedef CommonBehaviourControl< ::com::sun::star::inspection::XHyperlinkControl, ControlWindow< HyperlinkInput > > OHyperlinkControl_Base;
+ class OHyperlinkControl : public OHyperlinkControl_Base
+ {
+ private:
+ ::cppu::OInterfaceContainerHelper m_aActionListeners;
+
+ public:
+ OHyperlinkControl( Window* _pParent, WinBits _nWinStyle );
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+
+ // XHyperlinkControl
+ virtual void SAL_CALL addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& listener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& listener ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ // XComponent
+ virtual void SAL_CALL disposing();
+
+ protected:
+ DECL_LINK( OnHyperlinkClicked, void* );
+ };
+
+ //========================================================================
+ //= CustomConvertibleNumericField
+ //========================================================================
+ class CustomConvertibleNumericField : public ControlWindow< MetricField >
+ {
+ typedef ControlWindow< MetricField > BaseClass;
+
+ public:
+ CustomConvertibleNumericField( Window* _pParent, WinBits _nStyle )
+ :BaseClass( _pParent, _nStyle )
+ {
+ }
+
+ sal_Int64 GetLastValue() const { return mnLastValue; }
+ };
+
+ //========================================================================
+ //= ONumericControl
+ //========================================================================
+ typedef CommonBehaviourControl< ::com::sun::star::inspection::XNumericControl, CustomConvertibleNumericField > ONumericControl_Base;
+ class ONumericControl : public ONumericControl_Base
+ {
+ private:
+ FieldUnit m_eValueUnit;
+ sal_Int16 m_nFieldToUNOValueFactor;
+
+ public:
+ ONumericControl( Window* pParent, WinBits nWinStyle );
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+
+ // XNumericControl
+ virtual ::sal_Int16 SAL_CALL getDecimalDigits() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDecimalDigits( ::sal_Int16 _decimaldigits ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::beans::Optional< double > SAL_CALL getMinValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setMinValue( const ::com::sun::star::beans::Optional< double >& _minvalue ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::beans::Optional< double > SAL_CALL getMaxValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setMaxValue( const ::com::sun::star::beans::Optional< double >& _maxvalue ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int16 SAL_CALL getDisplayUnit() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDisplayUnit( ::sal_Int16 _displayunit ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int16 SAL_CALL getValueUnit() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValueUnit( ::sal_Int16 _valueunit ) throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ /** converts an API value (<code>double</code>, as passed into <code>set[Max|Min|]Value) into
+ a <code>long</code> value which can be passed to our NumericField.
+
+ The conversion respects our decimal digits as well as our value factor (<member>m_nFieldToUNOValueFactor</member>).
+ */
+ long impl_apiValueToFieldValue_nothrow( double _nApiValue ) const;
+
+ /** converts a control value, as obtained from our Numeric field, into a value which can passed
+ to outer callers via our UNO API.
+ */
+ double impl_fieldValueToApiValue_nothrow( sal_Int64 _nFieldValue ) const;
+ };
+
+ //========================================================================
+ //= OColorControl
+ //========================================================================
+ typedef CommonBehaviourControl < ::com::sun::star::inspection::XStringListControl
+ , ListLikeControlWithModifyHandler< ColorListBox >
+ > OColorControl_Base;
+ class OColorControl : public OColorControl_Base
+ {
+ private:
+ ::std::set< ::rtl::OUString > m_aNonColorEntries;
+
+ public:
+ OColorControl( Window* pParent, WinBits nWinStyle );
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+
+ // XStringListControl
+ virtual void SAL_CALL clearList( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL prependListEntry( const ::rtl::OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL appendListEntry( const ::rtl::OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getListEntries( ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ virtual void modified();
+ };
+
+ //========================================================================
+ //= OListboxControl
+ //========================================================================
+ typedef CommonBehaviourControl < ::com::sun::star::inspection::XStringListControl
+ , ListLikeControlWithModifyHandler< ListBox >
+ > OListboxControl_Base;
+ class OListboxControl : public OListboxControl_Base
+ {
+ public:
+ OListboxControl( Window* pParent, WinBits nWinStyle );
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+
+ // XStringListControl
+ virtual void SAL_CALL clearList( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL prependListEntry( const ::rtl::OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL appendListEntry( const ::rtl::OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getListEntries( ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ virtual void modified();
+ };
+
+ //========================================================================
+ //= OComboboxControl
+ //========================================================================
+ typedef CommonBehaviourControl< ::com::sun::star::inspection::XStringListControl, ControlWindow< ComboBox > > OComboboxControl_Base;
+ class OComboboxControl : public OComboboxControl_Base
+ {
+ public:
+ OComboboxControl( Window* pParent, WinBits nWinStyle );
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+
+ // XStringListControl
+ virtual void SAL_CALL clearList( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL prependListEntry( const ::rtl::OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL appendListEntry( const ::rtl::OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getListEntries( ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ DECL_LINK( OnEntrySelected, void* );
+ };
+
+ //========================================================================
+ //= DropDownEditControl
+ //========================================================================
+ enum MultiLineOperationMode
+ {
+ eStringList,
+ eMultiLineText
+ };
+ //========================================================================
+ //= DropDownEditControl
+ //========================================================================
+ class OMultilineFloatingEdit;
+ typedef ControlWindow< Edit > DropDownEditControl_Base;
+ /** an Edit field which can be used as ControlWindow, and has a drop-down button
+ */
+ class DropDownEditControl : public DropDownEditControl_Base
+ {
+ private:
+ OMultilineFloatingEdit* m_pFloatingEdit;
+ MultiLineEdit* m_pImplEdit;
+ PushButton* m_pDropdownButton;
+ MultiLineOperationMode m_nOperationMode;
+ sal_Bool m_bDropdown : 1;
+
+ public:
+ DropDownEditControl( Window* _pParent, WinBits _nStyle );
+ ~DropDownEditControl();
+
+ void setOperationMode( MultiLineOperationMode _eMode ) { m_nOperationMode = _eMode; }
+ MultiLineOperationMode getOperationMode() const { return m_nOperationMode; }
+
+ void SetTextValue( const ::rtl::OUString& _rText );
+ ::rtl::OUString GetTextValue() const;
+
+ void SetStringListValue( const StlSyntaxSequence< ::rtl::OUString >& _rStrings );
+ StlSyntaxSequence< ::rtl::OUString >
+ GetStringListValue() const;
+
+ // ControlWindow overridables
+ virtual void setControlHelper( ControlHelper& _rControlHelper );
+
+ protected:
+ // Window overridables
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ virtual void Resize();
+
+ protected:
+ long FindPos(long nSinglePos);
+
+ private:
+ DECL_LINK( ReturnHdl, OMultilineFloatingEdit* );
+ DECL_LINK( DropDownHdl, PushButton* );
+
+ sal_Bool ShowDropDown( sal_Bool bShow );
+ };
+
+ //========================================================================
+ //= OMultilineEditControl
+ //========================================================================
+ typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, DropDownEditControl > OMultilineEditControl_Base;
+ class OMultilineEditControl : public OMultilineEditControl_Base
+ {
+ public:
+ OMultilineEditControl( Window* pParent, MultiLineOperationMode _eMode, WinBits nWinStyle );
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_STANDARDCONTROL_HXX_
+
diff --git a/extensions/source/propctrlr/stlops.hxx b/extensions/source/propctrlr/stlops.hxx
new file mode 100644
index 000000000000..36511582618b
--- /dev/null
+++ b/extensions/source/propctrlr/stlops.hxx
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_STLOPS_HXX_
+#define _EXTENSIONS_PROPCTRLR_STLOPS_HXX_
+
+#include <comphelper/stl_types.hxx>
+#include <com/sun/star/beans/Property.hpp>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ //========================================================================
+ struct PropertyLessByName
+ :public ::std::binary_function < ::com::sun::star::beans::Property,
+ ::com::sun::star::beans::Property,
+ bool
+ >
+ {
+ bool operator() (::com::sun::star::beans::Property _rLhs, ::com::sun::star::beans::Property _rRhs) const
+ {
+ return _rLhs.Name < _rRhs.Name ? true : false;
+ }
+ };
+
+ //========================================================================
+ struct TypeLessByName
+ :public ::std::binary_function < ::com::sun::star::uno::Type,
+ ::com::sun::star::uno::Type,
+ bool
+ >
+ {
+ bool operator() (::com::sun::star::uno::Type _rLhs, ::com::sun::star::uno::Type _rRhs) const
+ {
+ return _rLhs.getTypeName() < _rRhs.getTypeName() ? true : false;
+ }
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_STLOPS_HXX_
+
diff --git a/extensions/source/propctrlr/stringdefine.hxx b/extensions/source/propctrlr/stringdefine.hxx
new file mode 100644
index 000000000000..3d31011d13b0
--- /dev/null
+++ b/extensions/source/propctrlr/stringdefine.hxx
@@ -0,0 +1,99 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_FORMSCTRLR_STRINGDEFINE_HXX_
+#define _EXTENSIONS_FORMSCTRLR_STRINGDEFINE_HXX_
+
+#include <rtl/ustring.hxx>
+#include <tools/string.hxx>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ //============================================================
+ //= a helper for static ascii pseudo-unicode strings
+ //============================================================
+ struct ConstAsciiString
+ {
+ const sal_Char* ascii;
+ sal_Int32 length;
+
+ inline operator const ::rtl::OUString& () const;
+ inline operator const sal_Char* () const { return ascii; }
+
+ inline ConstAsciiString(const sal_Char* _pAsciiZeroTerminated, const sal_Int32 _nLength);
+ inline ~ConstAsciiString();
+
+ private:
+ mutable ::rtl::OUString* ustring;
+ };
+
+ //------------------------------------------------------------
+ inline ConstAsciiString::ConstAsciiString(const sal_Char* _pAsciiZeroTerminated, const sal_Int32 _nLength)
+ :ascii(_pAsciiZeroTerminated)
+ ,length(_nLength)
+ ,ustring(NULL)
+ {
+ }
+
+ //------------------------------------------------------------
+ inline ConstAsciiString::~ConstAsciiString()
+ {
+ delete ustring;
+ ustring = NULL;
+ }
+
+ //------------------------------------------------------------
+ inline ConstAsciiString::operator const ::rtl::OUString& () const
+ {
+ if (!ustring)
+ ustring = new ::rtl::OUString(ascii, length, RTL_TEXTENCODING_ASCII_US);
+ return *ustring;
+ }
+
+ //============================================================
+
+#define CONST_ASCII_LENGTH(c) \
+ (const sal_Char*)c, c.length()
+
+ //============================================================
+ //= concrete strings
+ //============================================================
+ #ifndef PCR_IMPLEMENT_STRINGS
+ #define PCR_CONSTASCII_STRING(ident, string) extern const ConstAsciiString ident
+ #else
+ #define PCR_CONSTASCII_STRING(ident, string) extern const ConstAsciiString ident(string, sizeof(string)-1)
+ #endif
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_FORMSCTRLR_STRINGDEFINE_HXX_
+
diff --git a/extensions/source/propctrlr/stringrepresentation.cxx b/extensions/source/propctrlr/stringrepresentation.cxx
new file mode 100644
index 000000000000..2897ba57d9e6
--- /dev/null
+++ b/extensions/source/propctrlr/stringrepresentation.cxx
@@ -0,0 +1,650 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "sal/config.h"
+#include "cppuhelper/factory.hxx"
+#include "cppuhelper/implementationentry.hxx"
+#include "cppuhelper/implbase3.hxx"
+#include "com/sun/star/lang/XServiceInfo.hpp"
+#include "com/sun/star/inspection/XStringRepresentation.hpp"
+#include "com/sun/star/lang/XInitialization.hpp"
+#include "com/sun/star/script/XTypeConverter.hpp"
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/reflection/XConstantsTypeDescription.hpp>
+#include <com/sun/star/beans/XIntrospection.hpp>
+#include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include <comphelper/sequence.hxx>
+#include <connectivity/dbconversion.hxx>
+#ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
+#include "modulepcr.hxx"
+#endif
+#ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
+#include "formresid.hrc"
+#endif
+#include <tools/debug.hxx>
+#include <tools/string.hxx>
+#include <tools/StringListResource.hxx>
+#include <comphelper/types.hxx>
+#ifndef _EXTENSIONS_PROPCTRLR_MODULEPCR_HXX_
+#include "modulepcr.hxx"
+#endif
+
+#include <functional>
+#include <algorithm>
+
+// component helper namespace
+namespace comp_StringRepresentation {
+
+using namespace ::com::sun::star;
+
+// component and service helper functions:
+::rtl::OUString SAL_CALL _getImplementationName();
+uno::Sequence< ::rtl::OUString > SAL_CALL _getSupportedServiceNames();
+uno::Reference< uno::XInterface > SAL_CALL _create( uno::Reference< uno::XComponentContext > const & context );
+
+} // closing component helper namespace
+
+
+namespace pcr{
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+class StringRepresentation:
+ public ::cppu::WeakImplHelper3<
+ lang::XServiceInfo,
+ inspection::XStringRepresentation,
+ lang::XInitialization>
+{
+public:
+ explicit StringRepresentation(uno::Reference< uno::XComponentContext > const & context);
+
+ // lang::XServiceInfo:
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw (uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsService(const ::rtl::OUString & ServiceName) throw (uno::RuntimeException);
+ virtual uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (uno::RuntimeException);
+
+ // inspection::XStringRepresentation:
+ virtual ::rtl::OUString SAL_CALL convertToControlValue(const uno::Any & PropertyValue) throw (uno::RuntimeException, uno::Exception);
+ virtual uno::Any SAL_CALL convertToPropertyValue(const ::rtl::OUString & ControlValue, const uno::Type & ControlValueType) throw (uno::RuntimeException, uno::Exception);
+
+ // lang::XInitialization:
+ virtual void SAL_CALL initialize(const uno::Sequence< uno::Any > & aArguments) throw (uno::RuntimeException, uno::Exception);
+
+private:
+ StringRepresentation(StringRepresentation &); // not defined
+ void operator =(StringRepresentation &); // not defined
+
+ virtual ~StringRepresentation() {}
+
+ /** converts a generic value into a string representation
+
+ If you want to convert values whose string representation does not depend
+ on a concrete property, use this version
+
+ @return <TRUE/>
+ if and only if the value could be converted
+ */
+ bool convertGenericValueToString(
+ const uno::Any& _rValue,
+ ::rtl::OUString& _rStringRep
+ );
+
+ /** converts string representation into generic value
+
+ If you want to convert values whose string representation does not depend
+ on a concrete property, use this version
+
+ @return <TRUE/>
+ if and only if the value could be converted
+ */
+ bool convertStringToGenericValue(
+ const ::rtl::OUString& _rStringRep,
+ uno::Any& _rValue,
+ const uno::Type& _rTargetType
+ );
+
+ /** uses the simple convert method from the type converter
+ *
+ * \param _rValue the value to be converted
+ * \return the converted string.
+ */
+ ::rtl::OUString convertSimpleToString( const uno::Any& _rValue );
+
+ /** converts a string into his constant value if it exists, otherwise the type converter is used.
+ * \param _rValue the value to be converted
+ * \param _ePropertyType teh type of the propery to be converted into
+ * \return the converted value
+ */
+ uno::Any convertStringToSimple( const ::rtl::OUString& _rValue,const uno::TypeClass& _ePropertyType );
+
+ uno::Reference< uno::XComponentContext > m_xContext;
+ uno::Reference< script::XTypeConverter > m_xTypeConverter;
+ uno::Reference< reflection::XConstantsTypeDescription > m_xTypeDescription;
+ uno::Sequence< ::rtl::OUString > m_aValues;
+ uno::Sequence< uno::Reference< reflection::XConstantTypeDescription> > m_aConstants;
+
+};
+
+StringRepresentation::StringRepresentation(uno::Reference< uno::XComponentContext > const & context) :
+ m_xContext(context)
+{}
+
+// com.sun.star.uno.XServiceInfo:
+::rtl::OUString SAL_CALL StringRepresentation::getImplementationName() throw (uno::RuntimeException)
+{
+ return comp_StringRepresentation::_getImplementationName();
+}
+
+::sal_Bool SAL_CALL StringRepresentation::supportsService(::rtl::OUString const & serviceName) throw (uno::RuntimeException)
+{
+ return ::comphelper::existsValue(serviceName,comp_StringRepresentation::_getSupportedServiceNames());
+}
+
+uno::Sequence< ::rtl::OUString > SAL_CALL StringRepresentation::getSupportedServiceNames() throw (uno::RuntimeException)
+{
+ return comp_StringRepresentation::_getSupportedServiceNames();
+}
+
+// inspection::XStringRepresentation:
+::rtl::OUString SAL_CALL StringRepresentation::convertToControlValue(const uno::Any & PropertyValue) throw (uno::RuntimeException, uno::Exception)
+{
+ ::rtl::OUString sReturn;
+ if ( !convertGenericValueToString( PropertyValue, sReturn ) )
+ {
+ sReturn = convertSimpleToString( PropertyValue );
+#ifdef DBG_UTIL
+ if ( !sReturn.getLength() && PropertyValue.hasValue() )
+ {
+ ::rtl::OString sMessage( "StringRepresentation::convertPropertyValueToStringRepresentation: cannot convert values of type '" );
+ sMessage += ::rtl::OString( PropertyValue.getValueType().getTypeName().getStr(), PropertyValue.getValueType().getTypeName().getLength(), RTL_TEXTENCODING_ASCII_US );
+ sMessage += ::rtl::OString( "'!" );
+ DBG_ERROR( sMessage.getStr() );
+ }
+#endif
+ }
+
+ return sReturn;
+}
+
+uno::Any SAL_CALL StringRepresentation::convertToPropertyValue(const ::rtl::OUString & ControlValue, const uno::Type & ControlValueType) throw (uno::RuntimeException, uno::Exception)
+{
+ uno::Any aReturn;
+
+ uno::TypeClass ePropertyType = ControlValueType.getTypeClass();
+ switch ( ePropertyType )
+ {
+ case uno::TypeClass_FLOAT:
+ case uno::TypeClass_DOUBLE:
+ case uno::TypeClass_BYTE:
+ case uno::TypeClass_SHORT:
+ case uno::TypeClass_LONG:
+ case uno::TypeClass_HYPER:
+ case uno::TypeClass_UNSIGNED_SHORT:
+ case uno::TypeClass_UNSIGNED_LONG:
+ case uno::TypeClass_UNSIGNED_HYPER:
+ try
+ {
+ aReturn = convertStringToSimple(ControlValue, ePropertyType);
+ }
+ catch( const script::CannotConvertException& ) { }
+ catch( const lang::IllegalArgumentException& ) { }
+ break;
+
+ default:
+ #if OSL_DEBUG_LEVEL > 0
+ bool bCanConvert =
+ #endif
+ convertStringToGenericValue( ControlValue, aReturn, ControlValueType );
+
+ #if OSL_DEBUG_LEVEL > 0
+ // could not convert ...
+ if ( !bCanConvert && ControlValue.getLength() )
+ {
+ ::rtl::OString sMessage( "StringRepresentation::convertStringRepresentationToPropertyValue: cannot convert into values of type '" );
+ sMessage += ::rtl::OString( ControlValueType.getTypeName().getStr(), ControlValueType.getTypeName().getLength(), RTL_TEXTENCODING_ASCII_US );
+ sMessage += ::rtl::OString( "'!" );
+ DBG_ERROR( sMessage.getStr() );
+ }
+ #endif
+ }
+
+ return aReturn;
+}
+
+// lang::XInitialization:
+void SAL_CALL StringRepresentation::initialize(const uno::Sequence< uno::Any > & aArguments) throw (uno::RuntimeException, uno::Exception)
+{
+ sal_Int32 nLength = aArguments.getLength();
+ if ( nLength )
+ {
+ const uno::Any* pIter = aArguments.getConstArray();
+ m_xTypeConverter.set(*pIter++,uno::UNO_QUERY);
+ if ( nLength == 3 )
+ {
+ ::rtl::OUString sConstantName;
+ *pIter++ >>= sConstantName;
+ *pIter >>= m_aValues;
+
+ if ( m_xContext.is() )
+ {
+ uno::Reference< container::XHierarchicalNameAccess > xTypeDescProv(
+ m_xContext->getValueByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/singletons/com.sun.star.reflection.theTypeDescriptionManager" ) ) ),
+ uno::UNO_QUERY_THROW );
+
+ m_xTypeDescription.set( xTypeDescProv->getByHierarchicalName( sConstantName ), uno::UNO_QUERY_THROW );
+ m_aConstants = m_xTypeDescription->getConstants();
+ }
+ }
+ }
+}
+//------------------------------------------------------------------------
+::rtl::OUString StringRepresentation::convertSimpleToString( const uno::Any& _rValue )
+{
+ ::rtl::OUString sReturn;
+ if ( m_xTypeConverter.is() && _rValue.hasValue() )
+ {
+ try
+ {
+ if ( m_aConstants.getLength() )
+ {
+ sal_Int16 nConstantValue = 0;
+ if ( _rValue >>= nConstantValue )
+ {
+ const uno::Reference< reflection::XConstantTypeDescription>* pIter = m_aConstants.getConstArray();
+ const uno::Reference< reflection::XConstantTypeDescription>* pEnd = pIter + m_aConstants.getLength();
+ for(sal_Int32 i = 0;pIter != pEnd;++pIter,++i)
+ {
+ if ( (*pIter)->getConstantValue() == _rValue )
+ {
+ OSL_ENSURE(i < m_aValues.getLength() ,"StringRepresentation::convertSimpleToString: Index is not in range of m_aValues");
+ sReturn = m_aValues[i];
+ break;
+ }
+ }
+ }
+ }
+
+ if ( !sReturn.getLength() )
+ m_xTypeConverter->convertToSimpleType( _rValue, uno::TypeClass_STRING ) >>= sReturn;
+ }
+ catch( script::CannotConvertException& ) { }
+ catch( lang::IllegalArgumentException& ) { }
+ }
+ return sReturn;
+}
+
+//--------------------------------------------------------------------
+namespace
+{
+ struct ConvertIntegerFromAndToString
+ {
+ ::rtl::OUString operator()( sal_Int32 _rIntValue ) const
+ {
+ return ::rtl::OUString::valueOf( (sal_Int32)_rIntValue );
+ }
+ sal_Int32 operator()( const ::rtl::OUString& _rStringValue ) const
+ {
+ return _rStringValue.toInt32();
+ }
+ };
+
+ struct StringIdentity
+ {
+ ::rtl::OUString operator()( const ::rtl::OUString& _rValue ) const
+ {
+ return _rValue;
+ }
+ };
+
+ template < class ElementType, class Transformer >
+ ::rtl::OUString composeSequenceElements( const Sequence< ElementType >& _rElements, const Transformer& _rTransformer )
+ {
+ String sCompose;
+
+ // loop through the elements and concatenate the string representations of the integers
+ // (separated by a line break)
+ const ElementType* pElements = _rElements.getConstArray();
+ const ElementType* pElementsEnd = pElements + _rElements.getLength();
+ for ( ; pElements != pElementsEnd; ++pElements )
+ {
+ sCompose += String( _rTransformer( *pElements ) );
+ if ( pElements != pElementsEnd )
+ sCompose += '\n';
+ }
+
+ return sCompose;
+ }
+
+ template < class ElementType, class Transformer >
+ void splitComposedStringToSequence( const ::rtl::OUString& _rComposed, Sequence< ElementType >& _out_SplitUp, const Transformer& _rTransformer )
+ {
+ _out_SplitUp.realloc( 0 );
+ if ( !_rComposed.getLength() )
+ return;
+ sal_Int32 tokenPos = 0;
+ do
+ {
+ _out_SplitUp.realloc( _out_SplitUp.getLength() + 1 );
+ _out_SplitUp[ _out_SplitUp.getLength() - 1 ] = (ElementType)_rTransformer( _rComposed.getToken( 0, '\n', tokenPos ) );
+ }
+ while ( tokenPos != -1 );
+ }
+}
+
+//--------------------------------------------------------------------
+bool StringRepresentation::convertGenericValueToString( const uno::Any& _rValue, ::rtl::OUString& _rStringRep )
+{
+ bool bCanConvert = true;
+
+ switch ( _rValue.getValueTypeClass() )
+ {
+ case uno::TypeClass_STRING:
+ _rValue >>= _rStringRep;
+ break;
+
+ case uno::TypeClass_BOOLEAN:
+ {
+ ::std::vector< ::rtl::OUString > aListEntries;
+ tools::StringListResource aRes(PcrRes(RID_RSC_ENUM_YESNO),aListEntries);
+ sal_Bool bValue = sal_False;
+ _rValue >>= bValue;
+ _rStringRep = bValue ? aListEntries[1] : aListEntries[0];
+ }
+ break;
+
+ // some sequence types
+ case uno::TypeClass_SEQUENCE:
+ {
+ Sequence< ::rtl::OUString > aStringValues;
+ Sequence< sal_Int8 > aInt8Values;
+ Sequence< sal_uInt16 > aUInt16Values;
+ Sequence< sal_Int16 > aInt16Values;
+ Sequence< sal_uInt32 > aUInt32Values;
+ Sequence< sal_Int32 > aInt32Values;
+
+ // string sequences
+ if ( _rValue >>= aStringValues )
+ {
+ _rStringRep = composeSequenceElements( aStringValues, StringIdentity() );
+ }
+ // byte sequences
+ else if ( _rValue >>= aInt8Values )
+ {
+ _rStringRep = composeSequenceElements( aInt8Values, ConvertIntegerFromAndToString() );
+ }
+ // uInt16 sequences
+ else if ( _rValue >>= aUInt16Values )
+ {
+ _rStringRep = composeSequenceElements( aUInt16Values, ConvertIntegerFromAndToString() );
+ }
+ // Int16 sequences
+ else if ( _rValue >>= aInt16Values )
+ {
+ _rStringRep = composeSequenceElements( aInt16Values, ConvertIntegerFromAndToString() );
+ }
+ // uInt32 sequences
+ else if ( _rValue >>= aUInt32Values )
+ {
+ _rStringRep = composeSequenceElements( aUInt32Values, ConvertIntegerFromAndToString() );
+ }
+ // Int32 sequences
+ else if ( _rValue >>= aInt32Values )
+ {
+ _rStringRep = composeSequenceElements( aInt32Values, ConvertIntegerFromAndToString() );
+ }
+ else
+ bCanConvert = false;
+ }
+ break;
+ case uno::TypeClass_CONSTANT:
+ {
+ int i = 0;
+ ++i;
+ }
+ break;
+
+ // some structs
+ case uno::TypeClass_STRUCT:
+ OSL_ENSURE( false, "StringRepresentation::convertGenericValueToString(STRUCT): this is dead code - isn't it?" );
+ if ( _rValue.getValueType().equals( ::getCppuType( static_cast< util::Date* >( NULL ) ) ) )
+ {
+ // weird enough, the string representation of dates, as used
+ // by the control displaying dates, and thus as passed through the layers,
+ // is YYYYMMDD.
+ util::Date aUnoDate;
+ _rValue >>= aUnoDate;
+ _rStringRep = ::dbtools::DBTypeConversion::toDateString(aUnoDate);
+ }
+ else if ( _rValue.getValueType().equals( ::getCppuType( static_cast< util::Time* >( NULL ) ) ) )
+ {
+ // similar for time (HHMMSSHH)
+ util::Time aUnoTime;
+ _rValue >>= aUnoTime;
+ _rStringRep = ::dbtools::DBTypeConversion::toTimeString(aUnoTime);
+ }
+ else if ( _rValue.getValueType().equals( ::getCppuType( static_cast< util::DateTime* >( NULL ) ) ) )
+ {
+ util::DateTime aUnoDateTime;
+ _rValue >>= aUnoDateTime;
+ _rStringRep = ::dbtools::DBTypeConversion::toDateTimeString(aUnoDateTime);
+ }
+ else
+ bCanConvert = false;
+ break;
+
+ default:
+ bCanConvert = false;
+ break;
+ }
+
+ return bCanConvert;
+}
+//------------------------------------------------------------------------
+uno::Any StringRepresentation::convertStringToSimple( const ::rtl::OUString& _rValue,const uno::TypeClass& _ePropertyType )
+{
+ uno::Any aReturn;
+ if ( m_xTypeConverter.is() && _rValue.getLength() )
+ {
+ try
+ {
+ if ( m_aConstants.getLength() && m_aValues.getLength() )
+ {
+ const ::rtl::OUString* pIter = m_aValues.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + m_aValues.getLength();
+ for(sal_Int32 i = 0;pIter != pEnd;++pIter,++i)
+ {
+ if ( *pIter == _rValue )
+ {
+ OSL_ENSURE(i < m_aConstants.getLength() ,"StringRepresentation::convertSimpleToString: Index is not in range of m_aValues");
+ aReturn <<= m_aConstants[i]->getConstantValue();
+ break;
+ }
+ }
+ }
+
+ if ( !aReturn.hasValue() )
+ aReturn = m_xTypeConverter->convertToSimpleType( makeAny( _rValue ), _ePropertyType );
+ }
+ catch( script::CannotConvertException& ) { }
+ catch( lang::IllegalArgumentException& ) { }
+ }
+ return aReturn;
+}
+//--------------------------------------------------------------------
+bool StringRepresentation::convertStringToGenericValue( const ::rtl::OUString& _rStringRep, uno::Any& _rValue, const uno::Type& _rTargetType )
+{
+ bool bCanConvert = true;
+
+ switch ( _rTargetType.getTypeClass() )
+ {
+ case uno::TypeClass_STRING:
+ _rValue <<= _rStringRep;
+ break;
+
+ case uno::TypeClass_BOOLEAN:
+ {
+ ::std::vector< ::rtl::OUString > aListEntries;
+ tools::StringListResource aRes(PcrRes(RID_RSC_ENUM_YESNO),aListEntries);
+ if ( aListEntries[0] == _rStringRep )
+ _rValue <<= (sal_Bool)sal_False;
+ else
+ _rValue <<= (sal_Bool)sal_True;
+ }
+ break;
+
+ case uno::TypeClass_SEQUENCE:
+ {
+ uno::Type aElementType = ::comphelper::getSequenceElementType( _rTargetType );
+
+ String aStr( _rStringRep );
+ switch ( aElementType.getTypeClass() )
+ {
+ case uno::TypeClass_STRING:
+ {
+ Sequence< ::rtl::OUString > aElements;
+ splitComposedStringToSequence( aStr, aElements, StringIdentity() );
+ _rValue <<= aElements;
+ }
+ break;
+ case uno::TypeClass_SHORT:
+ {
+ Sequence< sal_Int16 > aElements;
+ splitComposedStringToSequence( aStr, aElements, ConvertIntegerFromAndToString() );
+ _rValue <<= aElements;
+ }
+ break;
+ case uno::TypeClass_UNSIGNED_SHORT:
+ {
+ Sequence< sal_uInt16 > aElements;
+ splitComposedStringToSequence( aStr, aElements, ConvertIntegerFromAndToString() );
+ _rValue <<= aElements;
+ }
+ break;
+ case uno::TypeClass_LONG:
+ {
+ Sequence< sal_Int32 > aElements;
+ splitComposedStringToSequence( aStr, aElements, ConvertIntegerFromAndToString() );
+ _rValue <<= aElements;
+ }
+ break;
+ case uno::TypeClass_UNSIGNED_LONG:
+ {
+ Sequence< sal_uInt32 > aElements;
+ splitComposedStringToSequence( aStr, aElements, ConvertIntegerFromAndToString() );
+ _rValue <<= aElements;
+ }
+ break;
+ case uno::TypeClass_BYTE:
+ {
+ Sequence< sal_Int8 > aElements;
+ splitComposedStringToSequence( aStr, aElements, ConvertIntegerFromAndToString() );
+ _rValue <<= aElements;
+ }
+ break;
+ default:
+ bCanConvert = false;
+ break;
+ }
+ }
+ break;
+
+ case uno::TypeClass_STRUCT:
+ OSL_ENSURE( false, "StringRepresentation::convertStringToGenericValue(STRUCT): this is dead code - isn't it?" );
+ if ( _rTargetType.equals( ::getCppuType( static_cast< util::Date* >( NULL ) ) ) )
+ {
+ // weird enough, the string representation of dates, as used
+ // by the control displaying dates, and thus as passed through the layers,
+ // is YYYYMMDD.
+
+ _rValue <<= ::dbtools::DBTypeConversion::toDate(_rStringRep);
+ }
+ else if ( _rTargetType.equals( ::getCppuType( static_cast< util::Time* >( NULL ) ) ) )
+ {
+ // similar for time (HHMMSSHH)
+ _rValue <<= ::dbtools::DBTypeConversion::toTime(_rStringRep);
+ }
+ else if ( _rTargetType.equals( ::getCppuType( static_cast< util::DateTime* >( NULL ) ) ) )
+ {
+ _rValue <<= ::dbtools::DBTypeConversion::toDateTime(_rStringRep);
+ }
+ else
+ bCanConvert = false;
+ break;
+
+ default:
+ bCanConvert = false;
+ break;
+ }
+
+ return bCanConvert;
+}
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+} // pcr
+//------------------------------------------------------------------------
+
+
+// component helper namespace
+namespace comp_StringRepresentation {
+
+::rtl::OUString SAL_CALL _getImplementationName() {
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "StringRepresentation"));
+}
+
+uno::Sequence< ::rtl::OUString > SAL_CALL _getSupportedServiceNames()
+{
+ uno::Sequence< ::rtl::OUString > s(1);
+ s[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.inspection.StringRepresentation"));
+ return s;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL _create(
+ const uno::Reference< uno::XComponentContext > & context)
+ SAL_THROW((uno::Exception))
+{
+ return static_cast< ::cppu::OWeakObject * >(new pcr::StringRepresentation(context));
+}
+
+} // closing component helper namespace
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_StringRepresentation()
+{
+ ::pcr::PcrModule::getInstance().registerImplementation(
+ comp_StringRepresentation::_getImplementationName(),
+ comp_StringRepresentation::_getSupportedServiceNames(),
+ comp_StringRepresentation::_create
+ );
+}
+
diff --git a/extensions/source/propctrlr/submissionhandler.cxx b/extensions/source/propctrlr/submissionhandler.cxx
new file mode 100644
index 000000000000..c2c56a6d2ad6
--- /dev/null
+++ b/extensions/source/propctrlr/submissionhandler.cxx
@@ -0,0 +1,448 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "submissionhandler.hxx"
+#include "formmetadata.hxx"
+#include "formstrings.hxx"
+#include "handlerhelper.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/form/FormButtonType.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/form/submission/XSubmissionSupplier.hpp>
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+/** === end UNO includes === **/
+#include <tools/debug.hxx>
+#include <rtl/ustrbuf.hxx>
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_SubmissionPropertyHandler()
+{
+ ::pcr::SubmissionPropertyHandler::registerImplementation();
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::comphelper;
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::script;
+ using namespace ::com::sun::star::form;
+ using namespace ::com::sun::star::xforms;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::inspection;
+
+ //====================================================================
+ //= SubmissionHelper
+ //====================================================================
+ //--------------------------------------------------------------------
+ SubmissionHelper::SubmissionHelper( ::osl::Mutex& _rMutex, const Reference< XPropertySet >& _rxIntrospectee, const Reference< frame::XModel >& _rxContextDocument )
+ :EFormsHelper( _rMutex, _rxIntrospectee, _rxContextDocument )
+ {
+ OSL_ENSURE( canTriggerSubmissions( _rxIntrospectee, _rxContextDocument ),
+ "SubmissionHelper::SubmissionHelper: you should not have instantiated me!" );
+ }
+
+ //--------------------------------------------------------------------
+ bool SubmissionHelper::canTriggerSubmissions( const Reference< XPropertySet >& _rxControlModel,
+ const Reference< frame::XModel >& _rxContextDocument ) SAL_THROW(())
+ {
+ if ( !EFormsHelper::isEForm( _rxContextDocument ) )
+ return false;
+
+ try
+ {
+ Reference< submission::XSubmissionSupplier > xSubmissionSupp( _rxControlModel, UNO_QUERY );
+ if ( xSubmissionSupp.is() )
+ return true;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "SubmissionHelper::canTriggerSubmissions: caught an exception!" );
+ }
+ return false;
+ }
+
+ //====================================================================
+ //= SubmissionPropertyHandler
+ //====================================================================
+ DBG_NAME( SubmissionPropertyHandler )
+ //--------------------------------------------------------------------
+ SubmissionPropertyHandler::SubmissionPropertyHandler( const Reference< XComponentContext >& _rxContext )
+ :EditPropertyHandler_Base( _rxContext )
+ ,OPropertyChangeListener( m_aMutex )
+ ,m_pPropChangeMultiplexer( NULL )
+ {
+ DBG_CTOR( SubmissionPropertyHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ SubmissionPropertyHandler::~SubmissionPropertyHandler( )
+ {
+ disposeAdapter();
+ DBG_DTOR( SubmissionPropertyHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL SubmissionPropertyHandler::getImplementationName_static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.SubmissionPropertyHandler" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL SubmissionPropertyHandler::getSupportedServiceNames_static( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported( 1 );
+ aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.SubmissionPropertyHandler" ) );
+ return aSupported;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL SubmissionPropertyHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::getPropertyValue: inconsistency!" );
+ // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
+
+ Any aReturn;
+ try
+ {
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_SUBMISSION_ID:
+ {
+ Reference< submission::XSubmissionSupplier > xSubmissionSupp( m_xComponent, UNO_QUERY );
+ OSL_ENSURE( xSubmissionSupp.is(), "SubmissionPropertyHandler::getPropertyValue: this should never happen ..." );
+ // this handler is not intended for components which are no XSubmissionSupplier
+ Reference< submission::XSubmission > xSubmission;
+ if ( xSubmissionSupp.is() )
+ xSubmission = xSubmissionSupp->getSubmission( );
+ aReturn <<= xSubmission;
+ }
+ break;
+
+ case PROPERTY_ID_XFORMS_BUTTONTYPE:
+ {
+ FormButtonType eType = FormButtonType_PUSH;
+ OSL_VERIFY( m_xComponent->getPropertyValue( PROPERTY_BUTTONTYPE ) >>= eType );
+ if ( ( eType != FormButtonType_PUSH ) && ( eType != FormButtonType_SUBMIT ) )
+ eType = FormButtonType_PUSH;
+ aReturn <<= eType;
+ }
+ break;
+
+ default:
+ DBG_ERROR( "SubmissionPropertyHandler::getPropertyValue: cannot handle this property!" );
+ break;
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "SubmissionPropertyHandler::getPropertyValue: caught an exception!" );
+ }
+
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SubmissionPropertyHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::setPropertyValue: inconsistency!" );
+ // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
+
+ try
+ {
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_SUBMISSION_ID:
+ {
+ Reference< submission::XSubmission > xSubmission;
+ OSL_VERIFY( _rValue >>= xSubmission );
+
+ Reference< submission::XSubmissionSupplier > xSubmissionSupp( m_xComponent, UNO_QUERY );
+ OSL_ENSURE( xSubmissionSupp.is(), "SubmissionPropertyHandler::setPropertyValue: this should never happen ..." );
+ // this handler is not intended for components which are no XSubmissionSupplier
+ if ( xSubmissionSupp.is() )
+ {
+ xSubmissionSupp->setSubmission( xSubmission );
+ impl_setContextDocumentModified_nothrow();
+ }
+ }
+ break;
+
+ case PROPERTY_ID_XFORMS_BUTTONTYPE:
+ m_xComponent->setPropertyValue( PROPERTY_BUTTONTYPE, _rValue );
+ break;
+
+ default:
+ OSL_ENSURE( sal_False, "SubmissionPropertyHandler::setPropertyValue: cannot handle this id!" );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "SubmissionPropertyHandler::setPropertyValue: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL SubmissionPropertyHandler::getActuatingProperties( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_pHelper.get() )
+ return Sequence< ::rtl::OUString >();
+
+ Sequence< ::rtl::OUString > aReturn( 1 );
+ aReturn[ 0 ] = PROPERTY_XFORMS_BUTTONTYPE;
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL SubmissionPropertyHandler::getSupersededProperties( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_pHelper.get() )
+ return Sequence< ::rtl::OUString >();
+
+ Sequence< ::rtl::OUString > aReturn( 3 );
+ aReturn[ 0 ] = PROPERTY_TARGET_URL;
+ aReturn[ 1 ] = PROPERTY_TARGET_FRAME;
+ aReturn[ 2 ] = PROPERTY_BUTTONTYPE;
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void SubmissionPropertyHandler::onNewComponent()
+ {
+ if ( m_pPropChangeMultiplexer )
+ {
+ m_pPropChangeMultiplexer->dispose();
+ m_pPropChangeMultiplexer->release();
+ m_pPropChangeMultiplexer = NULL;
+ }
+
+ EditPropertyHandler_Base::onNewComponent();
+
+ Reference< frame::XModel > xDocument( impl_getContextDocument_nothrow() );
+ DBG_ASSERT( xDocument.is(), "SubmissionPropertyHandler::onNewComponent: no document!" );
+
+ m_pHelper.reset( NULL );
+
+ if ( SubmissionHelper::canTriggerSubmissions( m_xComponent, xDocument ) )
+ {
+ m_pHelper.reset( new SubmissionHelper( m_aMutex, m_xComponent, xDocument ) );
+
+ m_pPropChangeMultiplexer = new OPropertyChangeMultiplexer( this, m_xComponent );
+ m_pPropChangeMultiplexer->acquire();
+ m_pPropChangeMultiplexer->addProperty( PROPERTY_BUTTONTYPE );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Property > SAL_CALL SubmissionPropertyHandler::doDescribeSupportedProperties() const
+ {
+ ::std::vector< Property > aProperties;
+ if ( m_pHelper.get() )
+ {
+ implAddPropertyDescription( aProperties, PROPERTY_SUBMISSION_ID, ::getCppuType( static_cast< Reference< submission::XSubmission > * >( NULL ) ) );
+ implAddPropertyDescription( aProperties, PROPERTY_XFORMS_BUTTONTYPE, ::getCppuType( static_cast< FormButtonType* >( NULL ) ) );
+ }
+ if ( aProperties.empty() )
+ return Sequence< Property >();
+ return Sequence< Property >( &(*aProperties.begin()), aProperties.size() );
+ }
+
+ //--------------------------------------------------------------------
+ LineDescriptor SAL_CALL SubmissionPropertyHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName,
+ const Reference< XPropertyControlFactory >& _rxControlFactory )
+ throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !_rxControlFactory.is() )
+ throw NullPointerException();
+ if ( !m_pHelper.get() )
+ RuntimeException();
+
+ ::std::vector< ::rtl::OUString > aListEntries;
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_SUBMISSION_ID:
+ const_cast< SubmissionHelper* >( m_pHelper.get() )->getAllElementUINames( EFormsHelper::Submission, aListEntries, false );
+ break;
+
+ case PROPERTY_ID_XFORMS_BUTTONTYPE:
+ {
+ // available options are nearly the same as for the "normal" button type, but only the
+ // first two options
+ aListEntries = m_pInfoService->getPropertyEnumRepresentations( PROPERTY_ID_BUTTONTYPE );
+ aListEntries.resize( 2 );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( sal_False, "SubmissionPropertyHandler::describePropertyLine: cannot handle this id!" );
+ return LineDescriptor();
+ }
+
+ LineDescriptor aDescriptor;
+ aDescriptor.Control = PropertyHandlerHelper::createListBoxControl( _rxControlFactory, aListEntries, sal_False, sal_True );
+ aDescriptor.DisplayName = m_pInfoService->getPropertyTranslation( nPropId );
+ aDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "General" ) );
+ aDescriptor.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( nPropId ) );
+ return aDescriptor;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SubmissionPropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool ) throw (NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nActuatingPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) );
+ OSL_PRECOND( m_pHelper.get(), "SubmissionPropertyHandler::actuatingPropertyChanged: inconsistentcy!" );
+ // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
+
+ switch ( nActuatingPropId )
+ {
+ case PROPERTY_ID_XFORMS_BUTTONTYPE:
+ {
+ FormButtonType eType = FormButtonType_PUSH;
+ OSL_VERIFY( _rNewValue >>= eType );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_SUBMISSION_ID, eType == FormButtonType_SUBMIT );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( sal_False, "SubmissionPropertyHandler::actuatingPropertyChanged: cannot handle this id!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL SubmissionPropertyHandler::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Any aPropertyValue;
+
+ OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::convertToPropertyValue: we have no SupportedProperties!" );
+ if ( !m_pHelper.get() )
+ return aPropertyValue;
+
+ ::rtl::OUString sControlValue;
+ OSL_VERIFY( _rControlValue >>= sControlValue );
+
+ PropertyId nPropId( m_pInfoService->getPropertyId( _rPropertyName ) );
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_SUBMISSION_ID:
+ {
+ Reference< XSubmission > xSubmission( m_pHelper->getModelElementFromUIName( EFormsHelper::Submission, sControlValue ), UNO_QUERY );
+ aPropertyValue <<= xSubmission;
+ }
+ break;
+
+ case PROPERTY_ID_XFORMS_BUTTONTYPE:
+ {
+ ::rtl::Reference< IPropertyEnumRepresentation > aEnumConversion(
+ new DefaultEnumRepresentation( *m_pInfoService, ::getCppuType( static_cast< FormButtonType* >( NULL ) ), PROPERTY_ID_BUTTONTYPE ) );
+ // TODO/UNOize: make aEnumConversion a member?
+ aEnumConversion->getValueFromDescription( sControlValue, aPropertyValue );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( sal_False, "SubmissionPropertyHandler::convertToPropertyValue: cannot handle this id!" );
+ }
+
+ return aPropertyValue;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL SubmissionPropertyHandler::convertToControlValue( const ::rtl::OUString& _rPropertyName, const Any& _rPropertyValue, const Type& _rControlValueType ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Any aControlValue;
+
+ OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::convertToControlValue: we have no SupportedProperties!" );
+ if ( !m_pHelper.get() )
+ return aControlValue;
+
+ OSL_ENSURE( _rControlValueType.getTypeClass() == TypeClass_STRING,
+ "SubmissionPropertyHandler::convertToControlValue: all our controls should use strings for value exchange!" );
+ (void)_rControlValueType;
+
+ PropertyId nPropId( m_pInfoService->getPropertyId( _rPropertyName ) );
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_SUBMISSION_ID:
+ {
+ Reference< XPropertySet > xSubmission( _rPropertyValue, UNO_QUERY );
+ if ( xSubmission.is() )
+ aControlValue <<= m_pHelper->getModelElementUIName( EFormsHelper::Submission, xSubmission );
+ }
+ break;
+
+ case PROPERTY_ID_XFORMS_BUTTONTYPE:
+ {
+ ::rtl::Reference< IPropertyEnumRepresentation > aEnumConversion(
+ new DefaultEnumRepresentation( *m_pInfoService, _rPropertyValue.getValueType(), PROPERTY_ID_BUTTONTYPE ) );
+ // TODO/UNOize: make aEnumConversion a member?
+ aControlValue <<= aEnumConversion->getDescriptionForValue( _rPropertyValue );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( sal_False, "SubmissionPropertyHandler::convertToControlValue: cannot handle this id!" );
+ }
+
+ return aControlValue;
+ }
+
+ //--------------------------------------------------------------------
+ void SubmissionPropertyHandler::_propertyChanged( const PropertyChangeEvent& _rEvent ) throw(RuntimeException)
+ {
+ if ( _rEvent.PropertyName == PROPERTY_BUTTONTYPE )
+ firePropertyChange( PROPERTY_XFORMS_BUTTONTYPE, PROPERTY_ID_XFORMS_BUTTONTYPE, _rEvent.OldValue, _rEvent.NewValue );
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
diff --git a/extensions/source/propctrlr/submissionhandler.hxx b/extensions/source/propctrlr/submissionhandler.hxx
new file mode 100644
index 000000000000..c2c19ecfb4d9
--- /dev/null
+++ b/extensions/source/propctrlr/submissionhandler.hxx
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_SUBMISSIONHANDLER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_SUBMISSIONHANDLER_HXX
+
+#include "propertyhandler.hxx"
+#include "eformshelper.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/xforms/XSubmission.hpp>
+/** === end UNO includes === **/
+#include <comphelper/propmultiplex.hxx>
+
+namespace comphelper
+{
+ class OPropertyChangeMultiplexer;
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= SubmissionHelper
+ //====================================================================
+ class SubmissionHelper : public EFormsHelper
+ {
+ public:
+ SubmissionHelper(
+ osl::Mutex& _rMutex,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxIntrospectee,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxContextDocument
+ );
+
+ /** determines whether the given control model is able to trigger submissions
+
+ Instances of the <type>SubmissionHelper</type> class should not be instantiated
+ for components where this method returned <FALSE/>
+ */
+ static bool canTriggerSubmissions(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxContextDocument
+ ) SAL_THROW(());
+ };
+
+ //====================================================================
+ //= SubmissionPropertyHandler
+ //====================================================================
+ class SubmissionPropertyHandler;
+ typedef HandlerComponentBase< SubmissionPropertyHandler > EditPropertyHandler_Base;
+ /** a property handler for any virtual string properties
+ */
+ class SubmissionPropertyHandler : public EditPropertyHandler_Base, public ::comphelper::OPropertyChangeListener
+ {
+ private:
+ ::osl::Mutex m_aMutex;
+ ::std::auto_ptr< SubmissionHelper > m_pHelper;
+ ::comphelper::OPropertyChangeMultiplexer* m_pPropChangeMultiplexer;
+
+ public:
+ SubmissionPropertyHandler(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
+ );
+
+ static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException);
+
+ ~SubmissionPropertyHandler();
+
+ protected:
+ // XPropertyHandler overriables
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getSupersededProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::LineDescriptor
+ SAL_CALL describePropertyLine( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rControlValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToControlValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rPropertyValue, const ::com::sun::star::uno::Type& _rControlValueType ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+
+ // PropertyHandler overridables
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
+ SAL_CALL doDescribeSupportedProperties() const;
+ virtual void onNewComponent();
+
+ private:
+ // OPropertyChangeListener
+ virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& _rEvent) throw( ::com::sun::star::uno::RuntimeException);
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_SUBMISSIONHANDLER_HXX
+
diff --git a/extensions/source/propctrlr/taborder.cxx b/extensions/source/propctrlr/taborder.cxx
new file mode 100644
index 000000000000..c3e0268bbc7a
--- /dev/null
+++ b/extensions/source/propctrlr/taborder.cxx
@@ -0,0 +1,424 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "taborder.hxx"
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_TABORDER_HRC
+#include "taborder.hrc"
+#endif
+
+#ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
+#include "modulepcr.hxx"
+#endif
+#ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
+#include "formresid.hrc"
+#endif
+#include "formstrings.hxx"
+#include <comphelper/types.hxx>
+#include <comphelper/property.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/awt/XTabController.hpp>
+#include <vcl/scrbar.hxx>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::awt;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::form;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::datatransfer;
+
+ //========================================================================
+ //= OSimpleTabModel
+ //========================================================================
+ class OSimpleTabModel : public ::cppu::WeakImplHelper1< XTabControllerModel>
+ {
+ Sequence< Reference< XControlModel > > m_aModels;
+
+ public:
+ OSimpleTabModel( const Sequence< Reference< XControlModel > >& _rModels )
+ :m_aModels( _rModels )
+ {
+ }
+
+ // XTabControllerModel
+ virtual void SAL_CALL setControlModels(const Sequence< Reference< XControlModel > >& rModels) throw( RuntimeException ) {m_aModels = rModels;}
+ virtual Sequence< Reference< XControlModel > > SAL_CALL getControlModels(void) throw( RuntimeException ) {return m_aModels;}
+ virtual void SAL_CALL setGroup(const Sequence< Reference< XControlModel > >& /*Group*/, const ::rtl::OUString& /*GroupName*/) throw( RuntimeException ) {}
+ virtual sal_Int32 SAL_CALL getGroupCount(void) throw( RuntimeException ) {return 0;}
+ virtual void SAL_CALL getGroup(sal_Int32 /*nGroup*/, Sequence< Reference< XControlModel > >& /*Group*/, ::rtl::OUString& /*Name*/) throw( RuntimeException ) {}
+ virtual void SAL_CALL getGroupByName(const ::rtl::OUString& /*Name*/, Sequence< Reference< XControlModel > >& /*Group*/) throw( RuntimeException ) {}
+ virtual sal_Bool SAL_CALL getGroupControl(void) throw( RuntimeException ){return sal_False;} ;
+ virtual void SAL_CALL setGroupControl(sal_Bool /*GroupControl*/) throw( RuntimeException ){};
+ };
+
+ //========================================================================
+ //= TabOrderDialog
+ //========================================================================
+ DBG_NAME(TabOrderDialog)
+ //------------------------------------------------------------------------
+ TabOrderDialog::TabOrderDialog( Window* _pParent, const Reference< XTabControllerModel >& _rxTabModel,
+ const Reference< XControlContainer >& _rxControlCont, const Reference< XMultiServiceFactory >& _rxORB )
+ :ModalDialog( _pParent, PcrRes( RID_DLG_TABORDER ) )
+ ,m_xModel( _rxTabModel )
+ ,m_xControlContainer( _rxControlCont )
+ ,m_xORB( _rxORB )
+ ,aFT_Controls( this, PcrRes( FT_CONTROLS ) )
+ ,aLB_Controls( this, PcrRes( CTRL_TREE ) )
+ ,aPB_OK( this, PcrRes( PB_OK ) )
+ ,aPB_CANCEL( this, PcrRes( PB_CANCEL ) )
+ ,aPB_HELP( this, PcrRes( PB_HELP ) )
+ ,aPB_MoveUp( this, PcrRes( PB_MOVE_UP ) )
+ ,aPB_MoveDown( this, PcrRes( PB_MOVE_DOWN ) )
+ ,aPB_AutoOrder( this, PcrRes( PB_AUTO_ORDER ) )
+ ,pImageList( NULL )
+ {
+ DBG_CTOR(TabOrderDialog,NULL);
+
+ aPB_MoveUp.SetClickHdl( LINK( this, TabOrderDialog, MoveUpClickHdl ) );
+ aPB_MoveDown.SetClickHdl( LINK( this, TabOrderDialog, MoveDownClickHdl ) );
+ aPB_AutoOrder.SetClickHdl( LINK( this, TabOrderDialog, AutoOrderClickHdl ) );
+ aPB_OK.SetClickHdl( LINK( this, TabOrderDialog, OKClickHdl ) );
+ aPB_OK.Disable();
+
+ sal_Bool bIsHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
+ pImageList = new ImageList( PcrRes( bIsHighContrast ? RID_IL_FORMEXPLORER_HC : RID_IL_FORMEXPLORER ) );
+
+
+ if ( m_xModel.is() )
+ m_xTempModel = new OSimpleTabModel( m_xModel->getControlModels() );
+
+ if ( m_xTempModel.is() && m_xControlContainer.is() )
+ FillList();
+
+ if ( aLB_Controls.GetEntryCount() < 2 )
+ {
+ aPB_MoveUp.Disable();
+ aPB_MoveDown.Disable();
+ aPB_AutoOrder.Disable();
+ }
+
+ FreeResource();
+ }
+
+ //------------------------------------------------------------------------
+ void TabOrderDialog::SetModified()
+ {
+ aPB_OK.Enable();
+ }
+
+ //------------------------------------------------------------------------
+ TabOrderDialog::~TabOrderDialog()
+ {
+ aLB_Controls.Hide();
+ // delete pLB_Controls;
+ delete pImageList;
+
+ DBG_DTOR(TabOrderDialog,NULL);
+ }
+
+ //------------------------------------------------------------------------
+ Image TabOrderDialog::GetImage( const Reference< XPropertySet >& _rxSet ) const
+ {
+ sal_uInt16 nImageId = RID_SVXIMG_CONTROL;
+ // TODO: classify controls also in Basic propbrw
+ if ( _rxSet.is() && ::comphelper::hasProperty( PROPERTY_CLASSID, _rxSet ) )
+ {
+ switch( ::comphelper::getINT16( _rxSet->getPropertyValue( PROPERTY_CLASSID ) ) )
+ {
+ case FormComponentType::COMMANDBUTTON: nImageId = RID_SVXIMG_BUTTON; break;
+ case FormComponentType::FIXEDTEXT: nImageId = RID_SVXIMG_FIXEDTEXT; break;
+ case FormComponentType::TEXTFIELD: nImageId = RID_SVXIMG_EDIT; break;
+ case FormComponentType::RADIOBUTTON: nImageId = RID_SVXIMG_RADIOBUTTON; break;
+ case FormComponentType::CHECKBOX: nImageId = RID_SVXIMG_CHECKBOX; break;
+ case FormComponentType::LISTBOX: nImageId = RID_SVXIMG_LISTBOX; break;
+ case FormComponentType::COMBOBOX: nImageId = RID_SVXIMG_COMBOBOX; break;
+ case FormComponentType::GROUPBOX: nImageId = RID_SVXIMG_GROUPBOX; break;
+ case FormComponentType::IMAGEBUTTON: nImageId = RID_SVXIMG_IMAGEBUTTON; break;
+ case FormComponentType::FILECONTROL: nImageId = RID_SVXIMG_FILECONTROL; break;
+ case FormComponentType::HIDDENCONTROL: nImageId = RID_SVXIMG_HIDDEN; break;
+ case FormComponentType::DATEFIELD: nImageId = RID_SVXIMG_DATEFIELD; break;
+ case FormComponentType::TIMEFIELD: nImageId = RID_SVXIMG_TIMEFIELD; break;
+ case FormComponentType::NUMERICFIELD: nImageId = RID_SVXIMG_NUMERICFIELD; break;
+ case FormComponentType::CURRENCYFIELD: nImageId = RID_SVXIMG_CURRENCYFIELD; break;
+ case FormComponentType::PATTERNFIELD: nImageId = RID_SVXIMG_PATTERNFIELD; break;
+ case FormComponentType::IMAGECONTROL: nImageId = RID_SVXIMG_IMAGECONTROL; break;
+ case FormComponentType::GRIDCONTROL: nImageId = RID_SVXIMG_GRID; break;
+ case FormComponentType::SCROLLBAR: nImageId = RID_SVXIMG_SCROLLBAR; break;
+ case FormComponentType::SPINBUTTON: nImageId = RID_SVXIMG_SPINBUTTON; break;
+ case FormComponentType::NAVIGATIONBAR: nImageId = RID_SVXIMG_NAVIGATIONBAR; break;
+ default:
+ DBG_ERROR( "TabOrderDialog::GetImage: unknown control type" );
+ }
+ }
+
+ return pImageList->GetImage( nImageId );
+ }
+
+ //------------------------------------------------------------------------
+ void TabOrderDialog::FillList()
+ {
+ DBG_ASSERT( m_xTempModel.is() && m_xControlContainer.is(), "TabOrderDialog::FillList: invalid call!" );
+ if ( !m_xTempModel.is() || !m_xControlContainer.is() )
+ return;
+
+ aLB_Controls.Clear();
+
+ try
+ {
+ Sequence< Reference< XControlModel > > aControlModels( m_xTempModel->getControlModels() );
+ const Reference< XControlModel >* pControlModels = aControlModels.getConstArray();
+
+ ::rtl::OUString aName;
+ Image aImage;
+
+ for ( sal_Int32 i=0; i < aControlModels.getLength(); ++i, ++pControlModels )
+ {
+ Reference< XPropertySet > xControl( *pControlModels, UNO_QUERY );
+ Reference< XPropertySetInfo > xPI;
+ if ( xControl.is() )
+ xPI = xControl->getPropertySetInfo();
+
+ if ( xPI.is() )
+ {
+ if ( xPI->hasPropertyByName( PROPERTY_TABSTOP ) )
+ {
+ aName = ::comphelper::getString( xControl->getPropertyValue( PROPERTY_NAME ) );
+ // TODO: do Basic controls have a name?
+ aImage = GetImage( xControl );
+ aLB_Controls.InsertEntry( aName, aImage, aImage, 0, sal_False, LIST_APPEND, xControl.get() );
+ }
+ }
+ else
+ {
+ // no property set -> no tab order
+ DBG_ERROR( "TabOrderDialog::FillList: invalid control encountered!" );
+ aLB_Controls.Clear();
+ break;
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_ERROR( "TabOrderDialog::FillList: caught an exception!" );
+ }
+
+ // select first entry
+ SvLBoxEntry* pFirstEntry = aLB_Controls.GetEntry( 0 );
+ if ( pFirstEntry )
+ aLB_Controls.Select( pFirstEntry );
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( TabOrderDialog, MoveUpClickHdl, Button*, /*pButton*/ )
+ {
+ aLB_Controls.MoveSelection( -1 );
+ return 0;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( TabOrderDialog, MoveDownClickHdl, Button*, /*pButton*/ )
+ {
+ aLB_Controls.MoveSelection( 1 );
+ return 0;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( TabOrderDialog, AutoOrderClickHdl, Button*, /*pButton*/ )
+ {
+ try
+ {
+ Reference< XTabController > xTabController;
+ if ( m_xORB.is() )
+ xTabController = xTabController.query( m_xORB->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.FormController" ) ) ) );
+ DBG_ASSERT( xTabController.is(), "TabOrderDialog::AutoOrderClickHdl: could not instantiate a tab controller!" );
+ if ( !xTabController.is() )
+ return 0;
+
+ xTabController->setModel( m_xTempModel );
+ xTabController->setContainer( m_xControlContainer );
+ xTabController->autoTabOrder();
+
+ SetModified();
+ FillList();
+
+ ::comphelper::disposeComponent( xTabController );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "TabOrderDialog::AutoOrderClickHdl: caught an exception!" );
+ }
+
+ return 0;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( TabOrderDialog, OKClickHdl, Button*, /*pButton*/ )
+ {
+ sal_uLong nEntryCount = aLB_Controls.GetEntryCount();
+ Sequence< Reference< XControlModel > > aSortedControlModelSeq( nEntryCount );
+ Sequence< Reference< XControlModel > > aControlModels( m_xTempModel->getControlModels());
+ Reference< XControlModel > * pSortedControlModels = aSortedControlModelSeq.getArray();
+ const Reference< XControlModel > * pControlModels = aControlModels.getConstArray();
+
+ for (sal_uLong i=0; i < nEntryCount; i++)
+ {
+ SvLBoxEntry* pEntry = aLB_Controls.GetEntry(i);
+
+ for( sal_Int32 j=0; j<aControlModels.getLength(); j++ )
+ {
+ Reference< XPropertySet > xSet(pControlModels[j], UNO_QUERY);
+ if ((XPropertySet*)xSet.get() == ((XPropertySet*)pEntry->GetUserData()))
+ {
+ pSortedControlModels[i] = pControlModels[j];
+ break;
+ }
+ }
+ }
+
+ // TODO: UNO action (to bracket all the single actions which are being created)
+// pDrawModel->BegUndo(PcrRes(RID_STR_UNDO_TABORDER));
+ m_xModel->setControlModels( aSortedControlModelSeq );
+// pDrawModel->EndUndo();
+
+ EndDialog( sal_True );
+ return 0;
+ }
+
+ //========================================================================
+ //= TabOrderListBox
+ //========================================================================
+ DBG_NAME(TabOrderListBox);
+ //------------------------------------------------------------------------
+ TabOrderListBox::TabOrderListBox( Window* pParent, const ResId& rResId )
+ :SvTreeListBox( pParent, rResId )
+ {
+ DBG_CTOR(TabOrderListBox,NULL);
+ SetDragDropMode(0xFFFF/*SV_DRAGDROP_CTRL_MOVE*/);
+ // Hmm. The flag alone is not enough, so to be on the safe side ...
+
+ SetSelectionMode( MULTIPLE_SELECTION );
+ }
+
+ //------------------------------------------------------------------------
+ TabOrderListBox::~TabOrderListBox()
+ {
+ DBG_DTOR(TabOrderListBox,NULL);
+ }
+
+ //------------------------------------------------------------------------
+ void TabOrderListBox::ModelHasMoved( SvListEntry* _pSource )
+ {
+ SvTreeListBox::ModelHasMoved( _pSource );
+
+ ((TabOrderDialog*)Window::GetParent())->SetModified();
+ }
+
+ //------------------------------------------------------------------------
+ void TabOrderListBox::MoveSelection( long nRelPos )
+ {
+ UniString aSelEntryPrevText,aSelEntryNextText;
+ Image aImage;
+ for (long i=0; i<labs(nRelPos); i++)
+ {
+ ((TabOrderDialog*)Window::GetParent())->SetModified();
+
+ //////////////////////////////////////////////////////////////////////
+ // move entries
+ if( nRelPos < 0 )
+ {
+ SvLBoxEntry* pFirstSelected = FirstSelected();
+ if( !pFirstSelected ) return;
+ sal_uLong nFirstSelPos = GetModel()->GetAbsPos( pFirstSelected );
+ if( nFirstSelPos == 0 ) return;
+
+ SvLBoxEntry* pSelEntry = pFirstSelected;
+ while( pSelEntry )
+ {
+ sal_uLong nSelEntryPos = GetModel()->GetAbsPos( pSelEntry );
+ SvLBoxEntry* pSelEntryPrev = GetEntry( nSelEntryPos-1 );
+ aSelEntryPrevText = GetEntryText( pSelEntryPrev );
+ aImage = GetExpandedEntryBmp(pSelEntryPrev);
+ void* pData = pSelEntryPrev->GetUserData();
+
+ GetModel()->Remove( pSelEntryPrev );
+ InsertEntry( aSelEntryPrevText, aImage, aImage, 0, sal_False, nSelEntryPos, pData );
+
+ pSelEntry = NextSelected( pSelEntry );
+ }
+ }
+
+ else if( nRelPos > 0 )
+ {
+ SvLBoxEntry* pLastSelected = LastSelected();
+ if( !pLastSelected ) return;
+ sal_uLong nLastSelPos = GetModel()->GetAbsPos( pLastSelected );
+
+ if( (nLastSelPos + nRelPos - i) > (GetEntryCount()-1) ) return;
+
+#if OSL_DEBUG_LEVEL > 0
+ sal_uLong nSelCount = GetSelectionCount();
+ (void)nSelCount;
+#endif
+
+
+ SvLBoxEntry* pSelEntry = pLastSelected;
+ while( pSelEntry )
+ {
+ sal_uLong nSelEntryPos = GetModel()->GetAbsPos( pSelEntry );
+ SvLBoxEntry* pSelEntryNext = GetEntry( nSelEntryPos+1 );
+ void* pData = pSelEntryNext->GetUserData();
+
+ aSelEntryNextText = GetEntryText( pSelEntryNext );
+ aImage = GetExpandedEntryBmp(pSelEntryNext);
+
+ GetModel()->Remove( pSelEntryNext );
+ InsertEntry( aSelEntryNextText, aImage, aImage, 0, sal_False, nSelEntryPos, pData );
+
+ pSelEntry = PrevSelected( pSelEntry );
+ }
+ long nThumbPos = GetVScroll()->GetThumbPos();
+ long nVisibleSize = GetVScroll()->GetVisibleSize();
+ long nFirstVisible = GetModel()->GetAbsPos( FirstVisible());
+
+ if ( ( nThumbPos + nVisibleSize + 1 ) < (long)( nLastSelPos + 3 ) )
+ GetVScroll()->DoScrollAction(SCROLL_LINEDOWN);
+ else if((nThumbPos+nVisibleSize+1) >= (nFirstVisible))
+ GetVScroll()->DoScrollAction(SCROLL_LINEUP);
+ }
+ }
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
diff --git a/extensions/source/propctrlr/taborder.hrc b/extensions/source/propctrlr/taborder.hrc
new file mode 100644
index 000000000000..00a6341d13a8
--- /dev/null
+++ b/extensions/source/propctrlr/taborder.hrc
@@ -0,0 +1,45 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_TABORDER_HRC
+#define EXTENSIONS_SOURCE_PROPCTRLR_TABORDER_HRC
+
+#define FT_CONTROLS 1
+
+#define LB_CONTROLS 1
+
+#define PB_MOVE_UP 1
+#define PB_MOVE_DOWN 2
+#define PB_AUTO_ORDER 3
+
+#define PB_OK 4
+#define PB_CANCEL 5
+#define PB_HELP 6
+
+#define CTRL_TREE 1
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_TABORDER_HRC
+
diff --git a/extensions/source/propctrlr/taborder.hxx b/extensions/source/propctrlr/taborder.hxx
new file mode 100644
index 000000000000..392df3f682eb
--- /dev/null
+++ b/extensions/source/propctrlr/taborder.hxx
@@ -0,0 +1,132 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_TABORDER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_TABORDER_HXX
+
+#include <svtools/svtreebx.hxx>
+#include <com/sun/star/awt/XTabControllerModel.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#ifndef _DIALOG_HXX //autogen
+#include <vcl/dialog.hxx>
+#endif
+
+#ifndef _BUTTON_HXX //autogen
+#include <vcl/button.hxx>
+#endif
+#include <vcl/lstbox.hxx>
+
+#ifndef _FIXED_HXX //autogen
+#include <vcl/fixed.hxx>
+#endif
+
+#ifndef _TOOLS_LIST_HXX
+#include <tools/list.hxx>
+#endif
+#include <comphelper/uno3.hxx>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ //========================================================================
+ //= TabOrderListBox
+ //========================================================================
+ class TabOrderListBox : public SvTreeListBox
+ {
+ public:
+ TabOrderListBox( Window* pParent, const ResId& rResId );
+ virtual ~TabOrderListBox();
+
+ void MoveSelection( long nRelPos );
+
+ protected:
+ virtual void ModelHasMoved(SvListEntry* pSource );
+
+ private:
+ using SvTreeListBox::MoveSelection;
+ };
+
+
+ //========================================================================
+ //= TabOrderDialog
+ //========================================================================
+ class TabOrderDialog : public ModalDialog
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel >
+ m_xTempModel;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel >
+ m_xModel;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >
+ m_xControlContainer;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB;
+
+ FixedText aFT_Controls;
+ TabOrderListBox aLB_Controls;
+
+ OKButton aPB_OK;
+ CancelButton aPB_CANCEL;
+ HelpButton aPB_HELP;
+
+ PushButton aPB_MoveUp;
+ PushButton aPB_MoveDown;
+ PushButton aPB_AutoOrder;
+
+ ImageList* pImageList;
+
+ DECL_LINK( MoveUpClickHdl, Button* );
+ DECL_LINK( MoveDownClickHdl, Button* );
+ DECL_LINK( AutoOrderClickHdl, Button* );
+ DECL_LINK( OKClickHdl, Button* );
+
+ void FillList();
+ Image GetImage(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & _rxSet
+ ) const;
+
+ public:
+ TabOrderDialog(
+ Window* _pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel >& _rxTabModel,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >& _rxControlCont,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ );
+
+ virtual ~TabOrderDialog();
+
+ void SetModified();
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_TABORDER_HXX
diff --git a/extensions/source/propctrlr/taborder.src b/extensions/source/propctrlr/taborder.src
new file mode 100644
index 000000000000..a1458f4d4016
--- /dev/null
+++ b/extensions/source/propctrlr/taborder.src
@@ -0,0 +1,107 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
+#include "formresid.hrc"
+#endif
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_TABORDER_HRC
+#include "taborder.hrc"
+#endif
+#include "propctrlr.hrc"
+
+ModalDialog RID_DLG_TABORDER
+{
+ HelpID = "extensions:ModalDialog:RID_DLG_TABORDER";
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 168 , 158 ) ;
+ Text [ en-US ] = "Tab Order" ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+
+ FixedText FT_CONTROLS
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 90 , 8 ) ;
+ Text [ en-US ] = "Controls" ;
+ };
+
+ Control CTRL_TREE
+ {
+ Border = TRUE;
+ Pos = MAP_APPFONT ( 6, 14) ;
+ Size = MAP_APPFONT ( 90, 136 ) ;
+ TabStop = TRUE;
+ HelpId = HID_PROP_TABORDER_CONTROLS;
+ };
+
+ PushButton PB_MOVE_UP
+ {
+ HelpID = "extensions:PushButton:RID_DLG_TABORDER:PB_MOVE_UP";
+ Pos = MAP_APPFONT ( 102 , 14 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "Move Up" ;
+ };
+
+ PushButton PB_MOVE_DOWN
+ {
+ HelpID = "extensions:PushButton:RID_DLG_TABORDER:PB_MOVE_DOWN";
+ Pos = MAP_APPFONT ( 102 , 32 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "Move Down" ;
+ };
+
+ PushButton PB_AUTO_ORDER
+ {
+ HelpID = "extensions:PushButton:RID_DLG_TABORDER:PB_AUTO_ORDER";
+ Pos = MAP_APPFONT ( 102 , 50 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "Automatic Sort" ;
+ };
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 102 , 100 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE;
+ };
+
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 102 , 118 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ TabStop = TRUE ;
+ };
+
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( 102 , 136 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ TabStop = TRUE ;
+ };
+};
+
diff --git a/extensions/source/propctrlr/unourl.cxx b/extensions/source/propctrlr/unourl.cxx
new file mode 100644
index 000000000000..09e124d6593b
--- /dev/null
+++ b/extensions/source/propctrlr/unourl.cxx
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "unourl.hxx"
+#include <com/sun/star/util/XURLTransformer.hpp>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::util;
+
+ //====================================================================
+ //= UnoURL
+ //====================================================================
+ UnoURL::UnoURL( const ::rtl::OUString& _rCompleteURL, const Reference< XMultiServiceFactory >& _rxORB )
+ {
+ m_aURL.Complete = _rCompleteURL;
+
+ OSL_ENSURE( _rxORB.is(), "UnoURL::UnoURL: invalid ORB!" );
+ Reference< XURLTransformer > xTransform;
+ try
+ {
+ if ( _rxORB.is() )
+ {
+ xTransform = xTransform.query( _rxORB->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ) ) ) );
+ OSL_ENSURE( xTransform.is(), "UnoURL::UnoURL: could not create an URL transformer!" );
+ if ( xTransform.is() )
+ xTransform->parseStrict( m_aURL );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "UnoURL::UnoURL: caught an exception!" );
+ }
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
diff --git a/extensions/source/propctrlr/unourl.hxx b/extensions/source/propctrlr/unourl.hxx
new file mode 100644
index 000000000000..86298ca3a42f
--- /dev/null
+++ b/extensions/source/propctrlr/unourl.hxx
@@ -0,0 +1,65 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_UNOURL_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_UNOURL_HXX
+
+#include <rtl/ustring.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/util/URL.hpp>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= UnoURL
+ //====================================================================
+ class UnoURL
+ {
+ private:
+ ::com::sun::star::util::URL m_aURL;
+
+ public:
+ UnoURL(
+ const ::rtl::OUString& _rCompleteURL,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ );
+
+ inline operator const ::rtl::OUString& () const { return m_aURL.Complete; }
+ inline operator const ::com::sun::star::util::URL& () const { return m_aURL; }
+
+ private:
+ UnoURL(); // never implemented
+ };
+
+//........................................................................
+} // namespacepcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_UNOURL_HXX
+
diff --git a/extensions/source/propctrlr/usercontrol.cxx b/extensions/source/propctrlr/usercontrol.cxx
new file mode 100644
index 000000000000..e168fd0da830
--- /dev/null
+++ b/extensions/source/propctrlr/usercontrol.cxx
@@ -0,0 +1,370 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "usercontrol.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/PropertyControlType.hpp>
+#include <com/sun/star/inspection/PropertyControlType.hpp>
+/** === end UNO includes === **/
+#include <svl/numuno.hxx>
+#include <rtl/math.hxx>
+#include <tools/debug.hxx>
+#include <svl/zformat.hxx>
+#include <connectivity/dbconversion.hxx>
+#include <com/sun/star/util/Time.hpp>
+#include "modulepcr.hxx"
+#include "propresid.hrc"
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::beans::IllegalTypeException;
+ using ::com::sun::star::uno::RuntimeException;
+ /** === end UNO using === **/
+ namespace PropertyControlType = ::com::sun::star::inspection::PropertyControlType;
+
+ //==================================================================
+ // NumberFormatSampleField
+ //==================================================================
+ //------------------------------------------------------------------
+ long NumberFormatSampleField::PreNotify( NotifyEvent& rNEvt )
+ {
+ // want to handle two keys myself : Del/Backspace should empty the window (setting my prop to "standard" this way)
+ if (EVENT_KEYINPUT == rNEvt.GetType())
+ {
+ sal_uInt16 nKey = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
+
+ if ((KEY_DELETE == nKey) || (KEY_BACKSPACE == nKey))
+ {
+ SetText( String() );
+ if ( m_pHelper )
+ m_pHelper->ModifiedHdl( this );
+ return 1;
+ }
+ }
+
+ return BaseClass::PreNotify( rNEvt );
+ }
+
+ //------------------------------------------------------------------
+ void NumberFormatSampleField::SetFormatSupplier( const SvNumberFormatsSupplierObj* pSupplier )
+ {
+ if ( pSupplier )
+ {
+ TreatAsNumber( sal_True );
+
+ SvNumberFormatter* pFormatter = pSupplier->GetNumberFormatter();
+ SetFormatter( pFormatter, sal_True );
+ SetValue( 1234.56789 );
+ }
+ else
+ {
+ TreatAsNumber( sal_False );
+ SetFormatter( NULL, sal_True );
+ SetText( String() );
+ }
+ }
+
+ //==================================================================
+ // OFormatSampleControl
+ //==================================================================
+ //------------------------------------------------------------------
+ OFormatSampleControl::OFormatSampleControl( Window* pParent, WinBits nWinStyle )
+ :OFormatSampleControl_Base( PropertyControlType::Unknown, pParent, nWinStyle )
+ {
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OFormatSampleControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
+ {
+ sal_Int32 nFormatKey = 0;
+ if ( _rValue >>= nFormatKey )
+ {
+ // else set the new format key, the text will be reformatted
+ getTypedControlWindow()->SetFormatKey( nFormatKey );
+
+ SvNumberFormatter* pNF = getTypedControlWindow()->GetFormatter();
+ const SvNumberformat* pEntry = pNF->GetEntry( nFormatKey );
+ OSL_ENSURE( pEntry, "OFormatSampleControl::setValue: invalid format entry!" );
+
+ const bool bIsTextFormat = ( pEntry && pEntry->IsTextFormat() );
+ if ( bIsTextFormat )
+ getTypedControlWindow()->SetText( String( PcrRes( RID_STR_TEXT_FORMAT ) ) );
+ else
+ getTypedControlWindow()->SetValue( pEntry ? getPreviewValue( *pEntry ) : 1234.56789 );
+ }
+ else
+ getTypedControlWindow()->SetText( String() );
+ }
+ //------------------------------------------------------------------
+ double OFormatSampleControl::getPreviewValue( const SvNumberformat& i_rEntry )
+ {
+ double nValue = 1234.56789;
+ switch ( i_rEntry.GetType() & ~NUMBERFORMAT_DEFINED )
+ {
+ case NUMBERFORMAT_DATE:
+ {
+ Date aCurrentDate;
+ static ::com::sun::star::util::Date STANDARD_DB_DATE(30,12,1899);
+ nValue = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(static_cast<sal_Int32>(aCurrentDate.GetDate())),STANDARD_DB_DATE);
+ }
+ break;
+ case NUMBERFORMAT_TIME:
+ case NUMBERFORMAT_DATETIME:
+ {
+ Time aCurrentTime;
+ nValue = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(aCurrentTime.GetTime()));
+ }
+ break;
+ default:
+ break;
+ }
+ return nValue;
+ }
+
+ //------------------------------------------------------------------
+ double OFormatSampleControl::getPreviewValue(SvNumberFormatter* _pNF,sal_Int32 _nFormatKey)
+ {
+ const SvNumberformat* pEntry = _pNF->GetEntry(_nFormatKey);
+ DBG_ASSERT( pEntry, "OFormattedNumericControl::SetFormatDescription: invalid format key!" );
+ double nValue = 1234.56789;
+ if ( pEntry )
+ nValue = getPreviewValue( *pEntry );
+ return nValue;
+ }
+ //------------------------------------------------------------------
+ Any SAL_CALL OFormatSampleControl::getValue() throw (RuntimeException)
+ {
+ Any aPropValue;
+ if ( getTypedControlWindow()->GetText().Len() )
+ aPropValue <<= (sal_Int32)getTypedControlWindow()->GetFormatKey();
+ return aPropValue;
+ }
+
+ //------------------------------------------------------------------
+ Type SAL_CALL OFormatSampleControl::getValueType() throw (RuntimeException)
+ {
+ return ::getCppuType( static_cast< sal_Int32* >( NULL ) );
+ }
+
+ //==================================================================
+ // class OFormattedNumericControl
+ //==================================================================
+ DBG_NAME(OFormattedNumericControl);
+ //------------------------------------------------------------------
+ OFormattedNumericControl::OFormattedNumericControl( Window* pParent, WinBits nWinStyle )
+ :OFormattedNumericControl_Base( PropertyControlType::Unknown, pParent, nWinStyle )
+ {
+ DBG_CTOR(OFormattedNumericControl,NULL);
+
+ getTypedControlWindow()->TreatAsNumber(sal_True);
+
+ m_nLastDecimalDigits = getTypedControlWindow()->GetDecimalDigits();
+ }
+
+ //------------------------------------------------------------------
+ OFormattedNumericControl::~OFormattedNumericControl()
+ {
+ DBG_DTOR(OFormattedNumericControl,NULL);
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OFormattedNumericControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
+ {
+ double nValue( 0 );
+ if ( _rValue >>= nValue )
+ getTypedControlWindow()->SetValue( nValue );
+ else
+ getTypedControlWindow()->SetText(String());
+ }
+
+ //------------------------------------------------------------------
+ Any SAL_CALL OFormattedNumericControl::getValue() throw (RuntimeException)
+ {
+ Any aPropValue;
+ if ( getTypedControlWindow()->GetText().Len() )
+ aPropValue <<= (double)getTypedControlWindow()->GetValue();
+ return aPropValue;
+ }
+
+ //------------------------------------------------------------------
+ Type SAL_CALL OFormattedNumericControl::getValueType() throw (RuntimeException)
+ {
+ return ::getCppuType( static_cast< double* >( NULL ) );
+ }
+
+ //------------------------------------------------------------------
+ void OFormattedNumericControl::SetFormatDescription(const FormatDescription& rDesc)
+ {
+ sal_Bool bFallback = sal_True;
+
+ if (rDesc.pSupplier)
+ {
+ getTypedControlWindow()->TreatAsNumber(sal_True);
+
+ SvNumberFormatter* pFormatter = rDesc.pSupplier->GetNumberFormatter();
+ if (pFormatter != getTypedControlWindow()->GetFormatter())
+ getTypedControlWindow()->SetFormatter(pFormatter, sal_True);
+ getTypedControlWindow()->SetFormatKey(rDesc.nKey);
+
+ const SvNumberformat* pEntry = getTypedControlWindow()->GetFormatter()->GetEntry(getTypedControlWindow()->GetFormatKey());
+ DBG_ASSERT( pEntry, "OFormattedNumericControl::SetFormatDescription: invalid format key!" );
+ if ( pEntry )
+ {
+ switch (pEntry->GetType() & ~NUMBERFORMAT_DEFINED)
+ {
+ case NUMBERFORMAT_NUMBER:
+ case NUMBERFORMAT_CURRENCY:
+ case NUMBERFORMAT_SCIENTIFIC:
+ case NUMBERFORMAT_FRACTION:
+ case NUMBERFORMAT_PERCENT:
+ m_nLastDecimalDigits = getTypedControlWindow()->GetDecimalDigits();
+ break;
+ case NUMBERFORMAT_DATETIME:
+ case NUMBERFORMAT_DATE:
+ case NUMBERFORMAT_TIME:
+ m_nLastDecimalDigits = 7;
+ break;
+ default:
+ m_nLastDecimalDigits = 0;
+ break;
+ }
+ bFallback = sal_False;
+ }
+
+ }
+
+ if ( bFallback )
+ {
+ getTypedControlWindow()->TreatAsNumber(sal_False);
+ getTypedControlWindow()->SetFormatter(NULL, sal_True);
+ getTypedControlWindow()->SetText(String());
+ m_nLastDecimalDigits = 0;
+ }
+ }
+
+ //========================================================================
+ //= OFileUrlControl
+ //========================================================================
+ //------------------------------------------------------------------
+ OFileUrlControl::OFileUrlControl( Window* pParent, WinBits nWinStyle )
+ :OFileUrlControl_Base( PropertyControlType::Unknown, pParent, nWinStyle | WB_DROPDOWN )
+ {
+ getTypedControlWindow()->SetDropDownLineCount( 10 );
+ getTypedControlWindow()->SetPlaceHolder( String( PcrRes( RID_EMBED_IMAGE_PLACEHOLDER ) ) ) ;
+ }
+
+ //------------------------------------------------------------------
+ OFileUrlControl::~OFileUrlControl()
+ {
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OFileUrlControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
+ {
+ ::rtl::OUString sURL;
+ if ( ( _rValue >>= sURL ) )
+ {
+ if ( sURL.indexOf( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.GraphicObject:" ) ) ) == 0 )
+ getTypedControlWindow()->DisplayURL( getTypedControlWindow()->GetPlaceHolder() );
+ else
+ getTypedControlWindow()->DisplayURL( sURL );
+ }
+ else
+ getTypedControlWindow()->SetText( String() );
+ }
+
+ //------------------------------------------------------------------
+ Any SAL_CALL OFileUrlControl::getValue() throw (RuntimeException)
+ {
+ Any aPropValue;
+ if ( getTypedControlWindow()->GetText().Len() )
+ aPropValue <<= (::rtl::OUString)getTypedControlWindow()->GetURL();
+ return aPropValue;
+ }
+
+ //------------------------------------------------------------------
+ Type SAL_CALL OFileUrlControl::getValueType() throw (RuntimeException)
+ {
+ return ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) );
+ }
+
+ //========================================================================
+ //= OTimeDurationControl
+ //========================================================================
+ //------------------------------------------------------------------
+ OTimeDurationControl::OTimeDurationControl( ::Window* pParent, WinBits nWinStyle )
+ :ONumericControl( pParent, nWinStyle )
+ {
+ getTypedControlWindow()->SetUnit( FUNIT_CUSTOM );
+ getTypedControlWindow()->SetCustomUnitText( String::CreateFromAscii( " ms" ) );
+ getTypedControlWindow()->SetCustomConvertHdl( LINK( this, OTimeDurationControl, OnCustomConvert ) );
+ }
+
+ //------------------------------------------------------------------
+ OTimeDurationControl::~OTimeDurationControl()
+ {
+ }
+
+ //------------------------------------------------------------------
+ ::sal_Int16 SAL_CALL OTimeDurationControl::getControlType() throw (::com::sun::star::uno::RuntimeException)
+ {
+ // don't use the base class'es method, it would claim we're a standard control, which
+ // we in fact aren't
+ return PropertyControlType::Unknown;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( OTimeDurationControl, OnCustomConvert, MetricField*, /*pField*/ )
+ {
+ long nMultiplier = 1;
+ if ( getTypedControlWindow()->GetCurUnitText().EqualsIgnoreCaseAscii( "ms" ) )
+ nMultiplier = 1;
+ if ( getTypedControlWindow()->GetCurUnitText().EqualsIgnoreCaseAscii( "s" ) )
+ nMultiplier = 1000;
+ else if ( getTypedControlWindow()->GetCurUnitText().EqualsIgnoreCaseAscii( "m" ) )
+ nMultiplier = 1000 * 60;
+ else if ( getTypedControlWindow()->GetCurUnitText().EqualsIgnoreCaseAscii( "h" ) )
+ nMultiplier = 1000 * 60 * 60;
+
+ getTypedControlWindow()->SetValue( getTypedControlWindow()->GetLastValue() * nMultiplier );
+
+ return 0L;
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
diff --git a/extensions/source/propctrlr/usercontrol.hxx b/extensions/source/propctrlr/usercontrol.hxx
new file mode 100644
index 000000000000..82835d1df16e
--- /dev/null
+++ b/extensions/source/propctrlr/usercontrol.hxx
@@ -0,0 +1,172 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_USERCONTROL_HXX_
+#define _EXTENSIONS_PROPCTRLR_USERCONTROL_HXX_
+
+#include "commoncontrol.hxx"
+#define _ZFORLIST_DECLARE_TABLE
+#include <svtools/fmtfield.hxx>
+#include <svtools/fileurlbox.hxx>
+#include "standardcontrol.hxx"
+
+class SvNumberFormatsSupplierObj;
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ //========================================================================
+ //= NumberFormatSampleField
+ //========================================================================
+ class NumberFormatSampleField : public ControlWindow< FormattedField >
+ {
+ private:
+ typedef ControlWindow< FormattedField > BaseClass;
+
+ public:
+ NumberFormatSampleField( Window* _pParent, WinBits _nStyle )
+ :BaseClass( _pParent, _nStyle )
+ {
+ }
+
+ void SetFormatSupplier( const SvNumberFormatsSupplierObj* pSupplier );
+
+ protected:
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ };
+
+ //========================================================================
+ //= OFormatSampleControl
+ //========================================================================
+ typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, NumberFormatSampleField > OFormatSampleControl_Base;
+ class OFormatSampleControl : public OFormatSampleControl_Base
+ {
+ public:
+ OFormatSampleControl( Window* pParent, WinBits nWinStyle );
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+
+ inline void SetFormatSupplier( const SvNumberFormatsSupplierObj* _pSupplier )
+ {
+ getTypedControlWindow()->SetFormatSupplier( _pSupplier );
+ }
+
+ /** returns the default preview value for the given format key
+ *
+ * \param _pNF the number formatter
+ * \param _nFormatKey the format key
+ * \return current date or time or the value 1234.56789
+ */
+ static double getPreviewValue(SvNumberFormatter* _pNF,sal_Int32 _nFormatKey);
+
+ private:
+ static double getPreviewValue( const SvNumberformat& i_rEntry );
+ };
+
+ //========================================================================
+ //= FormatDescription
+ //========================================================================
+ struct FormatDescription
+ {
+ SvNumberFormatsSupplierObj* pSupplier;
+ sal_Int32 nKey;
+ };
+
+ //========================================================================
+ //= OFormattedNumericControl
+ //========================================================================
+ typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< FormattedField > > OFormattedNumericControl_Base;
+ class OFormattedNumericControl : public OFormattedNumericControl_Base
+ {
+ private:
+ sal_Int32 m_nLastDecimalDigits;
+
+ public:
+ OFormattedNumericControl( Window* pParent, WinBits nWinStyle = WB_TABSTOP);
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+
+ void SetFormatDescription( const FormatDescription& rDesc );
+
+ // make some FormattedField methods available
+ void SetDecimalDigits(sal_uInt16 nPrecision) { getTypedControlWindow()->SetDecimalDigits(nPrecision); m_nLastDecimalDigits = nPrecision; }
+ void SetDefaultValue(double dDef) { getTypedControlWindow()->SetDefaultValue(dDef); }
+ void EnableEmptyField(sal_Bool bEnable) { getTypedControlWindow()->EnableEmptyField(bEnable); }
+ void SetThousandsSep(sal_Bool bEnable) { getTypedControlWindow()->SetThousandsSep(bEnable); }
+
+ protected:
+ ~OFormattedNumericControl();
+ };
+
+ //========================================================================
+ //= OFileUrlControl
+ //========================================================================
+ typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< ::svt::FileURLBox > > OFileUrlControl_Base;
+ class OFileUrlControl : public OFileUrlControl_Base
+ {
+ public:
+ OFileUrlControl( Window* pParent, WinBits nWinStyle );
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ ~OFileUrlControl();
+ };
+
+ //========================================================================
+ //= OTimeDurationControl
+ //========================================================================
+ class OTimeDurationControl : public ONumericControl
+ {
+ public:
+ OTimeDurationControl( ::Window* pParent, WinBits nWinStyle );
+ ~OTimeDurationControl();
+
+ // XPropertyControl
+ ::sal_Int16 SAL_CALL getControlType() throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ DECL_LINK( OnCustomConvert, MetricField* );
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_USERCONTROL_HXX_
+
diff --git a/extensions/source/propctrlr/xsddatatypes.cxx b/extensions/source/propctrlr/xsddatatypes.cxx
new file mode 100644
index 000000000000..25a77840c6a7
--- /dev/null
+++ b/extensions/source/propctrlr/xsddatatypes.cxx
@@ -0,0 +1,250 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "xsddatatypes.hxx"
+#include "formstrings.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/xsd/DataTypeClass.hpp>
+#include <com/sun/star/xsd/XDataType.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+/** === end UNO includes === **/
+#include <tools/debug.hxx>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::xsd;
+ using namespace ::com::sun::star::beans;
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ //--------------------------------------------------------------------
+ template< typename INTERFACE, typename ARGUMENT >
+ void setSave( INTERFACE* pObject, void ( SAL_CALL INTERFACE::*pSetter )( ARGUMENT ), ARGUMENT _rArg )
+ {
+ try
+ {
+ (pObject->*pSetter)( _rArg );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDDataType: setSave: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ template< typename INTERFACE, typename ARGUMENT >
+ ARGUMENT getSave( INTERFACE* pObject, ARGUMENT ( SAL_CALL INTERFACE::*pGetter )( ) )
+ {
+ ARGUMENT aReturn = ARGUMENT();
+ try
+ {
+ aReturn = (pObject->*pGetter)( );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDDataType: getSave: caught an exception!" );
+ }
+ return aReturn;
+ }
+
+ template< typename FACETTYPE >
+ FACETTYPE getFacet( const Reference< XPropertySet >& _rxFacets, const ::rtl::OUString& _rFacetName ) SAL_THROW(())
+ {
+ FACETTYPE aReturn;
+ try
+ {
+ OSL_VERIFY( _rxFacets->getPropertyValue( _rFacetName ) >>= aReturn );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDDataType: getFacet: caught an exception!" );
+ }
+ return aReturn;
+ }
+
+ //====================================================================
+ //= XSDDataType
+ //====================================================================
+ //--------------------------------------------------------------------
+ XSDDataType::XSDDataType( const Reference< XDataType >& _rxDataType )
+ :m_xDataType( _rxDataType )
+ ,m_refCount( 0 )
+ {
+ DBG_ASSERT( m_xDataType.is(), "XSDDataType::XSDDataType: invalid UNO object!" );
+ if ( m_xDataType.is() )
+ m_xFacetInfo = m_xDataType->getPropertySetInfo();
+ }
+
+ //--------------------------------------------------------------------
+ oslInterlockedCount SAL_CALL XSDDataType::acquire()
+ {
+ return osl_incrementInterlockedCount( &m_refCount );
+ }
+
+ //--------------------------------------------------------------------
+ oslInterlockedCount SAL_CALL XSDDataType::release()
+ {
+ if ( 0 == osl_decrementInterlockedCount( &m_refCount ) )
+ {
+ delete this;
+ return 0;
+ }
+ return m_refCount;
+ }
+
+ //--------------------------------------------------------------------
+ XSDDataType::~XSDDataType()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int16 XSDDataType::classify() const SAL_THROW(())
+ {
+ sal_Int16 nTypeClass = DataTypeClass::STRING;
+ try
+ {
+ if ( m_xDataType.is() )
+ nTypeClass = m_xDataType->getTypeClass();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDDataType::classify: caught an exception!" );
+ }
+ return nTypeClass;
+ }
+
+ //--------------------------------------------------------------------
+ bool XSDDataType::isBasicType() const SAL_THROW(())
+ {
+ return getSave( m_xDataType.get(), &XDataType::getIsBasic );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString XSDDataType::getName() const SAL_THROW(())
+ {
+ return getSave( m_xDataType.get(), &XDataType::getName );
+ }
+
+ //--------------------------------------------------------------------
+ void XSDDataType::setFacet( const ::rtl::OUString& _rFacetName, const Any& _rValue ) SAL_THROW(())
+ {
+ try
+ {
+ m_xDataType->setPropertyValue( _rFacetName, _rValue );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDDataType::setFacet: caught an exception - sure this is the right data type class for this property?" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool XSDDataType::hasFacet( const ::rtl::OUString& _rFacetName ) const SAL_THROW(())
+ {
+ bool bReturn = false;
+ try
+ {
+ bReturn = m_xFacetInfo.is() && m_xFacetInfo->hasPropertyByName( _rFacetName );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDDataType::hasFacet: caught an exception!" );
+ }
+ return bReturn;
+ }
+ //--------------------------------------------------------------------
+ Any XSDDataType::getFacet( const ::rtl::OUString& _rFacetName ) SAL_THROW(())
+ {
+ Any aReturn;
+ try
+ {
+ aReturn = m_xDataType->getPropertyValue( _rFacetName );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDDataType::getFacet: caught an exception - sure this is the right data type class for this property?" );
+ }
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ void lcl_copyProperties( const Reference< XPropertySet >& _rxSource, const Reference< XPropertySet >& _rxDest )
+ {
+ Reference< XPropertySetInfo > xSourceInfo;
+ if ( _rxSource.is() )
+ xSourceInfo = _rxSource->getPropertySetInfo();
+ Reference< XPropertySetInfo > xDestInfo;
+ if ( _rxDest.is() )
+ xDestInfo = _rxDest->getPropertySetInfo();
+ OSL_ENSURE( xSourceInfo.is() && xDestInfo.is(), "lcl_copyProperties: invalid property set( info)s!" );
+ if ( !xSourceInfo.is() || !xDestInfo.is() )
+ return;
+
+ Sequence< Property > aProperties( xSourceInfo->getProperties() );
+ const Property* pProperties = aProperties.getConstArray();
+ const Property* pPropertiesEnd = pProperties + aProperties.getLength();
+ for ( ; pProperties != pPropertiesEnd; ++pProperties )
+ {
+ if ( xDestInfo->hasPropertyByName( pProperties->Name ) )
+ _rxDest->setPropertyValue( pProperties->Name, _rxSource->getPropertyValue( pProperties->Name ) );
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void XSDDataType::copyFacetsFrom( const ::rtl::Reference< XSDDataType >& _pSourceType )
+ {
+ OSL_ENSURE( _pSourceType.is(), "XSDDataType::copyFacetsFrom: invalid source type!" );
+ if ( !_pSourceType.is() )
+ return;
+
+ try
+ {
+ Reference< XPropertySet > xSource( _pSourceType->getUnoDataType(), UNO_QUERY );
+ Reference< XPropertySet > xDest( getUnoDataType(), UNO_QUERY );
+ lcl_copyProperties( xSource, xDest );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDDataType::copyFacetsFrom: caught an exception!" );
+ }
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
diff --git a/extensions/source/propctrlr/xsddatatypes.hxx b/extensions/source/propctrlr/xsddatatypes.hxx
new file mode 100644
index 000000000000..8bb722d3990a
--- /dev/null
+++ b/extensions/source/propctrlr/xsddatatypes.hxx
@@ -0,0 +1,114 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_XSDDATATYPES_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_XSDDATATYPES_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/uno/Reference.hxx>
+/** === end UNO includes === **/
+#include <rtl/ref.hxx>
+
+namespace com { namespace sun { namespace star {
+ namespace xsd {
+ class XDataType;
+ }
+ namespace beans {
+ class XPropertySet;
+ class XPropertySetInfo;
+ }
+} } }
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= XSDDataType
+ //====================================================================
+ class XSDDataType : public ::rtl::IReference
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::xsd::XDataType >
+ m_xDataType;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
+ m_xFacetInfo;
+
+ protected:
+ oslInterlockedCount m_refCount;
+
+ protected:
+ inline ::com::sun::star::xsd::XDataType* getDataTypeInterface() const { return m_xDataType.get(); }
+
+ public:
+ XSDDataType(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xsd::XDataType >& _rxDataType
+ );
+
+ // IReference
+ virtual oslInterlockedCount SAL_CALL acquire();
+ virtual oslInterlockedCount SAL_CALL release();
+
+ /// retrieves the underlying UNO component
+ inline const ::com::sun::star::uno::Reference< ::com::sun::star::xsd::XDataType >&
+ getUnoDataType() const { return m_xDataType; }
+
+ /// classifies the data typ
+ sal_Int16 classify() const SAL_THROW(());
+
+ // attribute access
+ ::rtl::OUString getName() const SAL_THROW(());
+ bool isBasicType() const SAL_THROW(());
+
+ /// determines whether a given facet exists at the type
+ bool hasFacet( const ::rtl::OUString& _rFacetName ) const SAL_THROW(());
+ /// retrieves a facet value
+ ::com::sun::star::uno::Any
+ getFacet( const ::rtl::OUString& _rFacetName ) SAL_THROW(());
+ /// sets a facet value
+ void setFacet( const ::rtl::OUString& _rFacetName, const ::com::sun::star::uno::Any& _rFacetValue ) SAL_THROW(());
+
+ /** copies as much facets (values, respectively) from a give data type instance
+ */
+ void copyFacetsFrom( const ::rtl::Reference< XSDDataType >& _pSourceType );
+
+ protected:
+ virtual ~XSDDataType();
+
+ private:
+ XSDDataType(); // never implemented
+ XSDDataType( const XSDDataType& ); // never implemented
+ XSDDataType& operator=( const XSDDataType& ); // never implemented
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_XSDDATATYPES_HXX
+
diff --git a/extensions/source/propctrlr/xsdvalidationhelper.cxx b/extensions/source/propctrlr/xsdvalidationhelper.cxx
new file mode 100644
index 000000000000..f203b36bcffa
--- /dev/null
+++ b/extensions/source/propctrlr/xsdvalidationhelper.cxx
@@ -0,0 +1,412 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "xsdvalidationhelper.hxx"
+#include "xsddatatypes.hxx"
+#include "formstrings.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/xsd/DataTypeClass.hpp>
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/xforms/XDataTypeRepository.hpp>
+/** === end UNO includes === **/
+#include <unotools/syslocale.hxx>
+#include <tools/diagnose_ex.h>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::xsd;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::xforms;
+
+ namespace NumberFormat = ::com::sun::star::util::NumberFormat;
+
+ //====================================================================
+ //= XSDValidationHelper
+ //====================================================================
+ //--------------------------------------------------------------------
+ XSDValidationHelper::XSDValidationHelper( ::osl::Mutex& _rMutex, const Reference< XPropertySet >& _rxIntrospectee, const Reference< frame::XModel >& _rxContextDocument )
+ :EFormsHelper( _rMutex, _rxIntrospectee, _rxContextDocument )
+ ,m_bInspectingFormattedField( false )
+ {
+ try
+ {
+ Reference< XPropertySetInfo > xPSI;
+ Reference< XServiceInfo > xSI( _rxIntrospectee, UNO_QUERY );
+ if ( m_xControlModel.is() )
+ xPSI = m_xControlModel->getPropertySetInfo();
+ if ( xPSI.is()
+ && xPSI->hasPropertyByName( PROPERTY_FORMATKEY )
+ && xPSI->hasPropertyByName( PROPERTY_FORMATSSUPPLIER )
+ && xSI.is()
+ && xSI->supportsService( SERVICE_COMPONENT_FORMATTEDFIELD )
+ )
+ m_bInspectingFormattedField = true;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDValidationHelper::XSDValidationHelper: caught an exception while examining the introspectee!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void XSDValidationHelper::getAvailableDataTypeNames( ::std::vector< ::rtl::OUString >& /* [out] */ _rNames ) const SAL_THROW(())
+ {
+ _rNames.resize( 0 );
+
+ try
+ {
+ Reference< XDataTypeRepository > xRepository = getDataTypeRepository();
+ Sequence< ::rtl::OUString > aElements;
+ if ( xRepository.is() )
+ aElements = xRepository->getElementNames();
+
+ _rNames.resize( aElements.getLength() );
+ ::std::copy( aElements.getConstArray(), aElements.getConstArray() + aElements.getLength(), _rNames.begin() );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDValidationHelper::getAvailableDataTypeNames: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XDataTypeRepository > XSDValidationHelper::getDataTypeRepository() const SAL_THROW((Exception))
+ {
+ Reference< XDataTypeRepository > xRepository;
+
+ Reference< xforms::XModel > xModel( getCurrentFormModel( ) );
+ if ( xModel.is() )
+ xRepository = xModel->getDataTypeRepository();
+
+ return xRepository;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XDataTypeRepository > XSDValidationHelper::getDataTypeRepository( const ::rtl::OUString& _rModelName ) const SAL_THROW((Exception))
+ {
+ Reference< XDataTypeRepository > xRepository;
+
+ Reference< xforms::XModel > xModel( getFormModelByName( _rModelName ) );
+ if ( xModel.is() )
+ xRepository = xModel->getDataTypeRepository();
+
+ return xRepository;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XDataType > XSDValidationHelper::getDataType( const ::rtl::OUString& _rName ) const SAL_THROW((Exception))
+ {
+ Reference< XDataType > xDataType;
+
+ if ( _rName.getLength() )
+ {
+ Reference< XDataTypeRepository > xRepository = getDataTypeRepository();
+ if ( xRepository.is() )
+ xDataType = xRepository->getDataType( _rName );
+ }
+ return xDataType;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString XSDValidationHelper::getValidatingDataTypeName( ) const SAL_THROW(())
+ {
+ ::rtl::OUString sDataTypeName;
+ try
+ {
+ Reference< XPropertySet > xBinding( getCurrentBinding() );
+ // it's allowed here to not (yet) have a binding
+ if ( xBinding.is() )
+ {
+ OSL_VERIFY( xBinding->getPropertyValue( PROPERTY_XSD_DATA_TYPE ) >>= sDataTypeName );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDValidationHelper::getValidatingDataTypeName: caught an exception!" );
+ }
+ return sDataTypeName;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::Reference< XSDDataType > XSDValidationHelper::getDataTypeByName( const ::rtl::OUString& _rName ) const SAL_THROW(())
+ {
+ ::rtl::Reference< XSDDataType > pReturn;
+
+ try
+ {
+ Reference< XDataType > xValidatedAgainst;
+
+ if ( _rName.getLength() )
+ xValidatedAgainst = getDataType( _rName );
+
+ if ( xValidatedAgainst.is() )
+ pReturn = new XSDDataType( xValidatedAgainst );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDValidationHelper::getDataTypeByName: caught an exception!" );
+ }
+
+ return pReturn;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::Reference< XSDDataType > XSDValidationHelper::getValidatingDataType( ) const SAL_THROW(())
+ {
+ return getDataTypeByName( getValidatingDataTypeName() );
+ }
+
+ //--------------------------------------------------------------------
+ bool XSDValidationHelper::cloneDataType( const ::rtl::Reference< XSDDataType >& _pDataType, const ::rtl::OUString& _rNewName ) const SAL_THROW(())
+ {
+ OSL_ENSURE( _pDataType.is(), "XSDValidationHelper::removeDataTypeFromRepository: invalid data type!" );
+ if ( !_pDataType.is() )
+ return false;
+
+ try
+ {
+ Reference< XDataTypeRepository > xRepository( getDataTypeRepository() );
+ OSL_ENSURE( xRepository.is(), "XSDValidationHelper::removeDataTypeFromRepository: invalid data type repository!" );
+ if ( !xRepository.is() )
+ return false;
+
+ Reference< XDataType > xDataType( _pDataType->getUnoDataType() );
+ OSL_ENSURE( xDataType.is(), "XSDValidationHelper::removeDataTypeFromRepository: invalid data type (II)!" );
+ if ( !xDataType.is() )
+ return false;
+
+ xRepository->cloneDataType( xDataType->getName(), _rNewName );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDValidationHelper::cloneDataType: caught an exception!" );
+ }
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ bool XSDValidationHelper::removeDataTypeFromRepository( const ::rtl::OUString& _rName ) const SAL_THROW(())
+ {
+ try
+ {
+ Reference< XDataTypeRepository > xRepository( getDataTypeRepository() );
+ OSL_ENSURE( xRepository.is(), "XSDValidationHelper::removeDataTypeFromRepository: invalid data type repository!" );
+ if ( !xRepository.is() )
+ return false;
+
+ if ( !xRepository->hasByName( _rName ) )
+ {
+ OSL_ENSURE( sal_False, "XSDValidationHelper::removeDataTypeFromRepository: invalid repository and/or data type!" );
+ return false;
+ }
+
+ xRepository->revokeDataType( _rName );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDValidationHelper::removeDataTypeFromRepository: caught an exception!" );
+ return false;
+ }
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ void XSDValidationHelper::setValidatingDataTypeByName( const ::rtl::OUString& _rName ) const SAL_THROW(())
+ {
+ try
+ {
+ Reference< XPropertySet > xBinding( getCurrentBinding() );
+ OSL_ENSURE( xBinding.is(), "XSDValidationHelper::setValidatingDataTypeByName: no active binding - how this?" );
+
+ if ( xBinding.is() )
+ {
+ // get the old data type - this is necessary for notifying property changes
+ ::rtl::OUString sOldDataTypeName;
+ OSL_VERIFY( xBinding->getPropertyValue( PROPERTY_XSD_DATA_TYPE ) >>= sOldDataTypeName );
+ Reference< XPropertySet > xOldType;
+ try { xOldType = xOldType.query( getDataType( sOldDataTypeName ) ); } catch( const Exception& ) { }
+
+ // set the new data type name
+ xBinding->setPropertyValue( PROPERTY_XSD_DATA_TYPE, makeAny( _rName ) );
+
+ // retrieve the new data type object
+ Reference< XPropertySet > xNewType( getDataType( _rName ), UNO_QUERY );
+
+ // fire any changes in the properties which result from this new type
+ std::set< ::rtl::OUString > aFilter; aFilter.insert( PROPERTY_NAME );
+ firePropertyChanges( xOldType, xNewType, aFilter );
+
+ // fire the change in the Data Type property
+ ::rtl::OUString sNewDataTypeName;
+ OSL_VERIFY( xBinding->getPropertyValue( PROPERTY_XSD_DATA_TYPE ) >>= sNewDataTypeName );
+ firePropertyChange( PROPERTY_XSD_DATA_TYPE, makeAny( sOldDataTypeName ), makeAny( sNewDataTypeName ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void XSDValidationHelper::copyDataType( const ::rtl::OUString& _rFromModel, const ::rtl::OUString& _rToModel,
+ const ::rtl::OUString& _rDataTypeName ) const SAL_THROW(())
+ {
+ if ( _rFromModel == _rToModel )
+ // nothing to do (me thinks)
+ return;
+
+ try
+ {
+ Reference< XDataTypeRepository > xFromRepository, xToRepository;
+ if ( _rFromModel.getLength() )
+ xFromRepository = getDataTypeRepository( _rFromModel );
+ if ( _rToModel.getLength() )
+ xToRepository = getDataTypeRepository( _rToModel );
+
+ if ( !xFromRepository.is() || !xToRepository.is() )
+ return;
+
+ if ( !xFromRepository->hasByName( _rDataTypeName ) || xToRepository->hasByName( _rDataTypeName ) )
+ // not existent in the source, or already existent (by name) in the destination
+ return;
+
+ // determine the built-in type belonging to the source type
+ ::rtl::Reference< XSDDataType > pSourceType = new XSDDataType( xFromRepository->getDataType( _rDataTypeName ) );
+ ::rtl::OUString sTargetBaseType = getBasicTypeNameForClass( pSourceType->classify(), xToRepository );
+
+ // create the target type
+ Reference< XDataType > xTargetType = xToRepository->cloneDataType( sTargetBaseType, _rDataTypeName );
+ ::rtl::Reference< XSDDataType > pTargetType = new XSDDataType( xTargetType );
+
+ // copy the facets
+ pTargetType->copyFacetsFrom( pSourceType );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDValidationHelper::copyDataType: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void XSDValidationHelper::findDefaultFormatForIntrospectee() SAL_THROW(())
+ {
+ try
+ {
+ ::rtl::Reference< XSDDataType > xDataType = getValidatingDataType();
+ if ( xDataType.is() )
+ {
+ // find a NumberFormat type corresponding to the DataTypeClass
+ sal_Int16 nNumberFormatType = NumberFormat::NUMBER;
+ switch ( xDataType->classify() )
+ {
+ case DataTypeClass::DATETIME:
+ nNumberFormatType = NumberFormat::DATETIME;
+ break;
+ case DataTypeClass::DATE:
+ nNumberFormatType = NumberFormat::DATE;
+ break;
+ case DataTypeClass::TIME:
+ nNumberFormatType = NumberFormat::TIME;
+ break;
+ case DataTypeClass::STRING:
+ case DataTypeClass::anyURI:
+ case DataTypeClass::QName:
+ case DataTypeClass::NOTATION:
+ nNumberFormatType = NumberFormat::TEXT;
+ break;
+ }
+
+ // get the number formatter from the introspectee
+ Reference< XNumberFormatsSupplier > xSupplier;
+ Reference< XNumberFormatTypes > xFormatTypes;
+ OSL_VERIFY( m_xControlModel->getPropertyValue( PROPERTY_FORMATSSUPPLIER ) >>= xSupplier );
+ if ( xSupplier.is() )
+ xFormatTypes = xFormatTypes.query( xSupplier->getNumberFormats() );
+ OSL_ENSURE( xFormatTypes.is(), "XSDValidationHelper::findDefaultFormatForIntrospectee: no number formats for the introspectee!" );
+ if ( !xFormatTypes.is() )
+ return;
+
+ // and the standard format for the given NumberFormat type
+ sal_Int32 nDesiredFormat = xFormatTypes->getStandardFormat( nNumberFormatType, SvtSysLocale().GetLocaleData().getLocale() );
+
+ // set this at the introspectee
+ m_xControlModel->setPropertyValue( PROPERTY_FORMATKEY, makeAny( nDesiredFormat ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDValidationHelper::findDefaultFormatForIntrospectee: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString XSDValidationHelper::getBasicTypeNameForClass( sal_Int16 _nClass ) const SAL_THROW(())
+ {
+ return getBasicTypeNameForClass( _nClass, getDataTypeRepository() );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString XSDValidationHelper::getBasicTypeNameForClass( sal_Int16 _nClass, Reference< XDataTypeRepository > _rxRepository ) const SAL_THROW(())
+ {
+ ::rtl::OUString sReturn;
+ OSL_ENSURE( _rxRepository.is(), "XSDValidationHelper::getBasicTypeNameForClass: invalid repository!" );
+ if ( !_rxRepository.is() )
+ return sReturn;
+
+ try
+ {
+ Reference< XDataType > xDataType = _rxRepository->getBasicDataType( _nClass );
+ OSL_ENSURE( xDataType.is(), "XSDValidationHelper::getBasicTypeNameForClass: invalid data type returned!" );
+ if ( xDataType.is() )
+ sReturn = xDataType->getName();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDValidationHelper::getBasicTypeNameForClass: caught an exception!" );
+ }
+
+ return sReturn;
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
diff --git a/extensions/source/propctrlr/xsdvalidationhelper.hxx b/extensions/source/propctrlr/xsdvalidationhelper.hxx
new file mode 100644
index 000000000000..6eb7d8caae61
--- /dev/null
+++ b/extensions/source/propctrlr/xsdvalidationhelper.hxx
@@ -0,0 +1,150 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_XSDVALIDATIONHELPER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_XSDVALIDATIONHELPER_HXX
+
+#include "eformshelper.hxx"
+#include "xsddatatypes.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/xsd/XDataType.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+/** === end UNO includes === **/
+#include <rtl/ref.hxx>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ class XSDDataType;
+ //====================================================================
+ //= XSDValidationHelper
+ //====================================================================
+ class XSDValidationHelper : public EFormsHelper
+ {
+ private:
+ bool m_bInspectingFormattedField;
+ public:
+ bool isInspectingFormattedField() const { return m_bInspectingFormattedField; }
+
+ public:
+ XSDValidationHelper(
+ ::osl::Mutex& _rMutex,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxIntrospectee,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxContextDocument
+ );
+
+ /** retrieves the names of all XForms models in the document the control lives in
+ */
+ void getAvailableDataTypeNames( ::std::vector< ::rtl::OUString >& /* [out] */ _rNames ) const SAL_THROW(());
+
+ /** retrieves a particular data type given by name
+ */
+ ::rtl::Reference< XSDDataType >
+ getDataTypeByName( const ::rtl::OUString& _rName ) const SAL_THROW(());
+
+ /** retrieves the DataType instance which the control model is currently validated against
+
+ If there is a binding set at our control model, which at the same time acts as validator,
+ and if this validator is bound to an XDataType, then this data type is retrieved here.
+ */
+ ::rtl::Reference< XSDDataType >
+ getValidatingDataType( ) const SAL_THROW(());
+
+ /** retrieves the name of the data type which the control model is currently validated against
+
+ @seealso getValidatingDataType
+ */
+ ::rtl::OUString
+ getValidatingDataTypeName( ) const SAL_THROW(());
+
+ /** binds the validator to a new data type
+
+ To be called with an active binding only.
+ */
+ void setValidatingDataTypeByName( const ::rtl::OUString& _rName ) const SAL_THROW(());
+
+ /** removes the data type given by name from the data type repository
+ */
+ bool removeDataTypeFromRepository( const ::rtl::OUString& _rName ) const SAL_THROW(());
+
+ /** creates a new data type, which is a clone of an existing data type
+ */
+ bool cloneDataType( const ::rtl::Reference< XSDDataType >& _pDataType, const ::rtl::OUString& _rNewName ) const SAL_THROW(());
+
+ /** retrieves the name of the basic data type which has the given class
+ */
+ ::rtl::OUString
+ getBasicTypeNameForClass( sal_Int16 _eClass ) const SAL_THROW(());
+
+ /** copy a data type from one model to another
+
+ If a data type with the given name already exists in the target model, then nothing
+ happens. In particular, the facets of the data type are not copied.
+ */
+ void copyDataType( const ::rtl::OUString& _rFromModel, const ::rtl::OUString& _rToModel,
+ const ::rtl::OUString& _rDataTypeName ) const SAL_THROW(());
+
+ /** finds (and sets) a default format for the formatted field we're inspecting,
+ according to the current data type the control value is evaluated against
+ */
+ void findDefaultFormatForIntrospectee() SAL_THROW(());
+
+ private:
+ /** retrieves the data type repository associated with the current model
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::xforms::XDataTypeRepository >
+ getDataTypeRepository() const SAL_THROW((::com::sun::star::uno::Exception));
+
+ /** retrieves the data type repository associated with any model
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::xforms::XDataTypeRepository >
+ getDataTypeRepository( const ::rtl::OUString& _rModelName ) const SAL_THROW((::com::sun::star::uno::Exception));
+
+ /** retrieves the data type object for the given name
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::xsd::XDataType >
+ getDataType( const ::rtl::OUString& _rName ) const
+ SAL_THROW((::com::sun::star::uno::Exception));
+
+ /** retrieves the name of the basic data type which has the given class, in the given repository
+ */
+ ::rtl::OUString
+ getBasicTypeNameForClass(
+ sal_Int16 _nClass,
+ ::com::sun::star::uno::Reference< ::com::sun::star::xforms::XDataTypeRepository > _rxRepository
+ ) const SAL_THROW(());
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_XSDVALIDATIONHELPER_HXX
+
diff --git a/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx b/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx
new file mode 100644
index 000000000000..a7a6844973ea
--- /dev/null
+++ b/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx
@@ -0,0 +1,692 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "xsdvalidationpropertyhandler.hxx"
+#include "formstrings.hxx"
+#include "formmetadata.hxx"
+#include "xsddatatypes.hxx"
+#include "modulepcr.hxx"
+#include "formresid.hrc"
+#include "formlocalid.hrc"
+#include "propctrlr.hrc"
+#include "newdatatype.hxx"
+#include "xsdvalidationhelper.hxx"
+#include "pcrcommon.hxx"
+#include "handlerhelper.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/xsd/WhiteSpaceTreatment.hpp>
+#include <com/sun/star/xsd/DataTypeClass.hpp>
+#include <com/sun/star/inspection/PropertyControlType.hpp>
+#include <com/sun/star/beans/Optional.hpp>
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+#include <com/sun/star/inspection/PropertyLineElement.hpp>
+/** === end UNO includes === **/
+#include <vcl/msgbox.hxx>
+#include <tools/debug.hxx>
+#include <svtools/localresaccess.hxx>
+
+#include <algorithm>
+#include <functional>
+#include <limits>
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_XSDValidationPropertyHandler()
+{
+ ::pcr::XSDValidationPropertyHandler::registerImplementation();
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::xforms;
+ using namespace ::com::sun::star::xsd;
+ using namespace ::com::sun::star::script;
+ using namespace ::com::sun::star::inspection;
+
+ using ::com::sun::star::beans::PropertyAttribute::MAYBEVOID;
+
+ //====================================================================
+ //= XSDValidationPropertyHandler
+ //====================================================================
+ DBG_NAME( XSDValidationPropertyHandler )
+ //--------------------------------------------------------------------
+ XSDValidationPropertyHandler::XSDValidationPropertyHandler( const Reference< XComponentContext >& _rxContext )
+ :XSDValidationPropertyHandler_Base( _rxContext )
+ {
+ DBG_CTOR( XSDValidationPropertyHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ XSDValidationPropertyHandler::~XSDValidationPropertyHandler()
+ {
+ DBG_DTOR( XSDValidationPropertyHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL XSDValidationPropertyHandler::getImplementationName_static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.XSDValidationPropertyHandler" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL XSDValidationPropertyHandler::getSupportedServiceNames_static( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported( 1 );
+ aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.XSDValidationPropertyHandler" ) );
+ return aSupported;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL XSDValidationPropertyHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ OSL_ENSURE( m_pHelper.get(), "XSDValidationPropertyHandler::getPropertyValue: inconsistency!" );
+ // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
+
+ Any aReturn;
+ ::rtl::Reference< XSDDataType > pType = m_pHelper->getValidatingDataType();
+ switch ( nPropId )
+ {
+ // common facets
+ case PROPERTY_ID_XSD_DATA_TYPE: aReturn = pType.is() ? pType->getFacet( PROPERTY_NAME ) : makeAny( ::rtl::OUString() ); break;
+ case PROPERTY_ID_XSD_WHITESPACES:aReturn = pType.is() ? pType->getFacet( PROPERTY_XSD_WHITESPACES ) : makeAny( WhiteSpaceTreatment::Preserve ); break;
+ case PROPERTY_ID_XSD_PATTERN: aReturn = pType.is() ? pType->getFacet( PROPERTY_XSD_PATTERN ) : makeAny( ::rtl::OUString() ); break;
+
+ // all other properties are simply forwarded, if they exist at the given type
+ default:
+ {
+ if ( pType.is() && pType->hasFacet( _rPropertyName ) )
+ aReturn = pType->getFacet( _rPropertyName );
+ }
+ break;
+ }
+
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL XSDValidationPropertyHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ OSL_ENSURE( m_pHelper.get(), "XSDValidationPropertyHandler::getPropertyValue: inconsistency!" );
+ // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
+
+ if ( PROPERTY_ID_XSD_DATA_TYPE == nPropId )
+ {
+ ::rtl::OUString sTypeName;
+ OSL_VERIFY( _rValue >>= sTypeName );
+ m_pHelper->setValidatingDataTypeByName( sTypeName );
+ impl_setContextDocumentModified_nothrow();
+ return;
+ }
+
+ ::rtl::Reference< XSDDataType > pType = m_pHelper->getValidatingDataType();
+ if ( !pType.is() )
+ {
+ DBG_ERROR( "XSDValidationPropertyHandler::setPropertyValue: you're trying to set a type facet, without a current type!" );
+ return;
+ }
+
+ pType->setFacet( _rPropertyName, _rValue );
+ impl_setContextDocumentModified_nothrow();
+ }
+
+ //--------------------------------------------------------------------
+ void XSDValidationPropertyHandler::onNewComponent()
+ {
+ XSDValidationPropertyHandler_Base::onNewComponent();
+
+ Reference< frame::XModel > xDocument( impl_getContextDocument_nothrow() );
+ DBG_ASSERT( xDocument.is(), "XSDValidationPropertyHandler::onNewComponent: no document!" );
+ if ( EFormsHelper::isEForm( xDocument ) )
+ m_pHelper.reset( new XSDValidationHelper( m_aMutex, m_xComponent, xDocument ) );
+ else
+ m_pHelper.reset( NULL );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Property > XSDValidationPropertyHandler::doDescribeSupportedProperties() const
+ {
+ ::std::vector< Property > aProperties;
+
+ if ( m_pHelper.get() )
+ {
+ bool bAllowBinding = m_pHelper->canBindToAnyDataType();
+
+ if ( bAllowBinding )
+ {
+ aProperties.reserve( 12 );
+
+ addStringPropertyDescription( aProperties, PROPERTY_XSD_DATA_TYPE );
+ addInt16PropertyDescription ( aProperties, PROPERTY_XSD_WHITESPACES );
+ addStringPropertyDescription( aProperties, PROPERTY_XSD_PATTERN );
+
+ // string facets
+ addInt32PropertyDescription( aProperties, PROPERTY_XSD_LENGTH, MAYBEVOID );
+ addInt32PropertyDescription( aProperties, PROPERTY_XSD_MIN_LENGTH, MAYBEVOID );
+ addInt32PropertyDescription( aProperties, PROPERTY_XSD_MAX_LENGTH, MAYBEVOID );
+
+ // decimal facets
+ addInt32PropertyDescription( aProperties, PROPERTY_XSD_TOTAL_DIGITS, MAYBEVOID );
+ addInt32PropertyDescription( aProperties, PROPERTY_XSD_FRACTION_DIGITS, MAYBEVOID );
+
+ // facets for different types
+ addInt16PropertyDescription( aProperties, PROPERTY_XSD_MAX_INCLUSIVE_INT, MAYBEVOID );
+ addInt16PropertyDescription( aProperties, PROPERTY_XSD_MAX_EXCLUSIVE_INT, MAYBEVOID );
+ addInt16PropertyDescription( aProperties, PROPERTY_XSD_MIN_INCLUSIVE_INT, MAYBEVOID );
+ addInt16PropertyDescription( aProperties, PROPERTY_XSD_MIN_EXCLUSIVE_INT, MAYBEVOID );
+ addDoublePropertyDescription( aProperties, PROPERTY_XSD_MAX_INCLUSIVE_DOUBLE, MAYBEVOID );
+ addDoublePropertyDescription( aProperties, PROPERTY_XSD_MAX_EXCLUSIVE_DOUBLE, MAYBEVOID );
+ addDoublePropertyDescription( aProperties, PROPERTY_XSD_MIN_INCLUSIVE_DOUBLE, MAYBEVOID );
+ addDoublePropertyDescription( aProperties, PROPERTY_XSD_MIN_EXCLUSIVE_DOUBLE, MAYBEVOID );
+ addDatePropertyDescription( aProperties, PROPERTY_XSD_MAX_INCLUSIVE_DATE, MAYBEVOID );
+ addDatePropertyDescription( aProperties, PROPERTY_XSD_MAX_EXCLUSIVE_DATE, MAYBEVOID );
+ addDatePropertyDescription( aProperties, PROPERTY_XSD_MIN_INCLUSIVE_DATE, MAYBEVOID );
+ addDatePropertyDescription( aProperties, PROPERTY_XSD_MIN_EXCLUSIVE_DATE, MAYBEVOID );
+ addTimePropertyDescription( aProperties, PROPERTY_XSD_MAX_INCLUSIVE_TIME, MAYBEVOID );
+ addTimePropertyDescription( aProperties, PROPERTY_XSD_MAX_EXCLUSIVE_TIME, MAYBEVOID );
+ addTimePropertyDescription( aProperties, PROPERTY_XSD_MIN_INCLUSIVE_TIME, MAYBEVOID );
+ addTimePropertyDescription( aProperties, PROPERTY_XSD_MIN_EXCLUSIVE_TIME, MAYBEVOID );
+ addDateTimePropertyDescription( aProperties, PROPERTY_XSD_MAX_INCLUSIVE_DATE_TIME, MAYBEVOID );
+ addDateTimePropertyDescription( aProperties, PROPERTY_XSD_MAX_EXCLUSIVE_DATE_TIME, MAYBEVOID );
+ addDateTimePropertyDescription( aProperties, PROPERTY_XSD_MIN_INCLUSIVE_DATE_TIME, MAYBEVOID );
+ addDateTimePropertyDescription( aProperties, PROPERTY_XSD_MIN_EXCLUSIVE_DATE_TIME, MAYBEVOID );
+ }
+ }
+
+ if ( aProperties.empty() )
+ return Sequence< Property >();
+ return Sequence< Property >( &(*aProperties.begin()), aProperties.size() );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL XSDValidationPropertyHandler::getSupersededProperties( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ::std::vector< ::rtl::OUString > aSuperfluous;
+ if ( m_pHelper.get() )
+ {
+ aSuperfluous.push_back( PROPERTY_CONTROLSOURCE );
+ aSuperfluous.push_back( PROPERTY_EMPTY_IS_NULL );
+ aSuperfluous.push_back( PROPERTY_FILTERPROPOSAL );
+ aSuperfluous.push_back( PROPERTY_LISTSOURCETYPE );
+ aSuperfluous.push_back( PROPERTY_LISTSOURCE );
+ aSuperfluous.push_back( PROPERTY_BOUNDCOLUMN );
+
+ bool bAllowBinding = m_pHelper->canBindToAnyDataType();
+
+ if ( bAllowBinding )
+ {
+ aSuperfluous.push_back( PROPERTY_MAXTEXTLEN );
+ aSuperfluous.push_back( PROPERTY_VALUEMIN );
+ aSuperfluous.push_back( PROPERTY_VALUEMAX );
+ aSuperfluous.push_back( PROPERTY_DECIMAL_ACCURACY );
+ aSuperfluous.push_back( PROPERTY_TIMEMIN );
+ aSuperfluous.push_back( PROPERTY_TIMEMAX );
+ aSuperfluous.push_back( PROPERTY_DATEMIN );
+ aSuperfluous.push_back( PROPERTY_DATEMAX );
+ aSuperfluous.push_back( PROPERTY_EFFECTIVE_MIN );
+ aSuperfluous.push_back( PROPERTY_EFFECTIVE_MAX );
+ }
+ }
+
+ if ( aSuperfluous.empty() )
+ return Sequence< ::rtl::OUString >();
+ return Sequence< ::rtl::OUString >( &(*aSuperfluous.begin()), aSuperfluous.size() );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL XSDValidationPropertyHandler::getActuatingProperties( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ ::std::vector< ::rtl::OUString > aInterestedInActuations( 2 );
+ if ( m_pHelper.get() )
+ {
+ aInterestedInActuations.push_back( PROPERTY_XSD_DATA_TYPE );
+ aInterestedInActuations.push_back( PROPERTY_XML_DATA_MODEL );
+ }
+ if ( aInterestedInActuations.empty() )
+ return Sequence< ::rtl::OUString >();
+ return Sequence< ::rtl::OUString >( &(*aInterestedInActuations.begin()), aInterestedInActuations.size() );
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ void showPropertyUI( const Reference< XObjectInspectorUI >& _rxInspectorUI, const ::rtl::OUString& _rPropertyName, bool _bShow )
+ {
+ if ( _bShow )
+ _rxInspectorUI->showPropertyUI( _rPropertyName );
+ else
+ _rxInspectorUI->hidePropertyUI( _rPropertyName );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ LineDescriptor SAL_CALL XSDValidationPropertyHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName,
+ const Reference< XPropertyControlFactory >& _rxControlFactory )
+ throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !_rxControlFactory.is() )
+ throw NullPointerException();
+ if ( !m_pHelper.get() )
+ throw RuntimeException();
+
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ LineDescriptor aDescriptor;
+ if ( nPropId != PROPERTY_ID_XSD_DATA_TYPE )
+ aDescriptor.IndentLevel = 1;
+
+ // collect some information about the to-be-created control
+ sal_Int16 nControlType = PropertyControlType::TextField;
+ ::std::vector< ::rtl::OUString > aListEntries;
+ Optional< double > aMinValue( sal_False, 0 );
+ Optional< double > aMaxValue( sal_False, 0 );
+
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_XSD_DATA_TYPE:
+ nControlType = PropertyControlType::ListBox;
+
+ implGetAvailableDataTypeNames( aListEntries );
+
+ aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_ADD_DATA_TYPE);
+ aDescriptor.SecondaryButtonId = rtl::OUString::createFromAscii(UID_PROP_REMOVE_DATA_TYPE);;
+ aDescriptor.HasPrimaryButton = aDescriptor.HasSecondaryButton = sal_True;
+ aDescriptor.PrimaryButtonImageURL = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:graphicrepository/extensions/res/buttonplus.png" ) );
+ aDescriptor.SecondaryButtonImageURL = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:graphicrepository/extensions/res/buttonminus.png" ) );
+ break;
+
+ case PROPERTY_ID_XSD_WHITESPACES:
+ {
+ nControlType = PropertyControlType::ListBox;
+ aListEntries = m_pInfoService->getPropertyEnumRepresentations( PROPERTY_ID_XSD_WHITESPACES );
+ }
+ break;
+
+ case PROPERTY_ID_XSD_PATTERN:
+ nControlType = PropertyControlType::TextField;
+ break;
+
+ case PROPERTY_ID_XSD_LENGTH:
+ case PROPERTY_ID_XSD_MIN_LENGTH:
+ case PROPERTY_ID_XSD_MAX_LENGTH:
+ nControlType = PropertyControlType::NumericField;
+ break;
+
+ case PROPERTY_ID_XSD_TOTAL_DIGITS:
+ case PROPERTY_ID_XSD_FRACTION_DIGITS:
+ nControlType = PropertyControlType::NumericField;
+ break;
+
+ case PROPERTY_ID_XSD_MAX_INCLUSIVE_INT:
+ case PROPERTY_ID_XSD_MAX_EXCLUSIVE_INT:
+ case PROPERTY_ID_XSD_MIN_INCLUSIVE_INT:
+ case PROPERTY_ID_XSD_MIN_EXCLUSIVE_INT:
+ {
+ nControlType = PropertyControlType::NumericField;
+
+ // handle limits for various 'INT' types according to
+ // their actual semantics (year, month, day)
+
+ ::rtl::Reference< XSDDataType > xDataType( m_pHelper->getValidatingDataType() );
+ sal_Int16 nTypeClass = xDataType.is() ? xDataType->classify() : DataTypeClass::STRING;
+
+ aMinValue.IsPresent = aMaxValue.IsPresent = sal_True;
+ aMinValue.Value = DataTypeClass::gYear == nTypeClass ? 0 : 1;
+ aMaxValue.Value = ::std::numeric_limits< sal_Int32 >::max();
+ if ( DataTypeClass::gMonth == nTypeClass )
+ aMaxValue.Value = 12;
+ else if ( DataTypeClass::gDay == nTypeClass )
+ aMaxValue.Value = 31;
+ }
+ break;
+
+ case PROPERTY_ID_XSD_MAX_INCLUSIVE_DOUBLE:
+ case PROPERTY_ID_XSD_MAX_EXCLUSIVE_DOUBLE:
+ case PROPERTY_ID_XSD_MIN_INCLUSIVE_DOUBLE:
+ case PROPERTY_ID_XSD_MIN_EXCLUSIVE_DOUBLE:
+ nControlType = PropertyControlType::NumericField;
+ // TODO/eForms: do we have "auto-digits"?
+ break;
+
+ case PROPERTY_ID_XSD_MAX_INCLUSIVE_DATE:
+ case PROPERTY_ID_XSD_MAX_EXCLUSIVE_DATE:
+ case PROPERTY_ID_XSD_MIN_INCLUSIVE_DATE:
+ case PROPERTY_ID_XSD_MIN_EXCLUSIVE_DATE:
+ nControlType = PropertyControlType::DateField;
+ break;
+
+ case PROPERTY_ID_XSD_MAX_INCLUSIVE_TIME:
+ case PROPERTY_ID_XSD_MAX_EXCLUSIVE_TIME:
+ case PROPERTY_ID_XSD_MIN_INCLUSIVE_TIME:
+ case PROPERTY_ID_XSD_MIN_EXCLUSIVE_TIME:
+ nControlType = PropertyControlType::TimeField;
+ break;
+
+ case PROPERTY_ID_XSD_MAX_INCLUSIVE_DATE_TIME:
+ case PROPERTY_ID_XSD_MAX_EXCLUSIVE_DATE_TIME:
+ case PROPERTY_ID_XSD_MIN_INCLUSIVE_DATE_TIME:
+ case PROPERTY_ID_XSD_MIN_EXCLUSIVE_DATE_TIME:
+ nControlType = PropertyControlType::DateTimeField;
+ break;
+
+ default:
+ DBG_ERROR( "XSDValidationPropertyHandler::describePropertyLine: cannot handle this property!" );
+ break;
+ }
+
+ switch ( nControlType )
+ {
+ case PropertyControlType::ListBox:
+ aDescriptor.Control = PropertyHandlerHelper::createListBoxControl( _rxControlFactory, aListEntries, sal_False, sal_False );
+ break;
+ case PropertyControlType::NumericField:
+ aDescriptor.Control = PropertyHandlerHelper::createNumericControl( _rxControlFactory, 0, aMinValue, aMaxValue, sal_False );
+ break;
+ default:
+ aDescriptor.Control = _rxControlFactory->createPropertyControl( nControlType, sal_False );
+ break;
+ }
+
+ aDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Data" ) );
+ aDescriptor.DisplayName = m_pInfoService->getPropertyTranslation( nPropId );
+ aDescriptor.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( nPropId ) );
+
+ return aDescriptor;
+ }
+
+ //--------------------------------------------------------------------
+ InteractiveSelectionResult SAL_CALL XSDValidationPropertyHandler::onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, Any& /*_rData*/, const Reference< XObjectInspectorUI >& _rxInspectorUI ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ OSL_ENSURE( m_pHelper.get(), "XSDValidationPropertyHandler::onInteractivePropertySelection: we don't have any SupportedProperties!" );
+ if ( !m_pHelper.get() )
+ return InteractiveSelectionResult_Cancelled;
+
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_XSD_DATA_TYPE:
+ {
+ if ( _bPrimary )
+ {
+ ::rtl::OUString sNewDataTypeName;
+ if ( implPrepareCloneDataCurrentType( sNewDataTypeName ) )
+ {
+ implDoCloneCurrentDataType( sNewDataTypeName );
+ return InteractiveSelectionResult_Success;
+ }
+ }
+ else
+ return implPrepareRemoveCurrentDataType() && implDoRemoveCurrentDataType() ? InteractiveSelectionResult_Success : InteractiveSelectionResult_Cancelled;
+ }
+ break;
+
+ default:
+ DBG_ERROR( "XSDValidationPropertyHandler::onInteractivePropertySelection: unexpected property to build a dedicated UI!" );
+ break;
+ }
+ return InteractiveSelectionResult_Cancelled;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL XSDValidationPropertyHandler::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ XSDValidationPropertyHandler_Base::addPropertyChangeListener( _rxListener );
+ if ( m_pHelper.get() )
+ m_pHelper->registerBindingListener( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL XSDValidationPropertyHandler::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_pHelper.get() )
+ m_pHelper->revokeBindingListener( _rxListener );
+ XSDValidationPropertyHandler_Base::removePropertyChangeListener( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ bool XSDValidationPropertyHandler::implPrepareCloneDataCurrentType( ::rtl::OUString& _rNewName ) SAL_THROW(())
+ {
+ OSL_PRECOND( m_pHelper.get(), "XSDValidationPropertyHandler::implPrepareCloneDataCurrentType: this will crash!" );
+
+ ::rtl::Reference< XSDDataType > pType = m_pHelper->getValidatingDataType();
+ if ( !pType.is() )
+ {
+ DBG_ERROR( "XSDValidationPropertyHandler::implPrepareCloneDataCurrentType: invalid current data type!" );
+ return false;
+ }
+
+ ::std::vector< ::rtl::OUString > aExistentNames;
+ m_pHelper->getAvailableDataTypeNames( aExistentNames );
+
+ NewDataTypeDialog aDialog( NULL, pType->getName(), aExistentNames ); // TODO/eForms: proper parent
+ if ( aDialog.Execute() != RET_OK )
+ return false;
+
+ _rNewName = aDialog.GetName();
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ bool XSDValidationPropertyHandler::implDoCloneCurrentDataType( const ::rtl::OUString& _rNewName ) SAL_THROW(())
+ {
+ OSL_PRECOND( m_pHelper.get(), "XSDValidationPropertyHandler::implDoCloneCurrentDataType: this will crash!" );
+
+ ::rtl::Reference< XSDDataType > pType = m_pHelper->getValidatingDataType();
+ if ( !pType.is() )
+ return false;
+
+ if ( !m_pHelper->cloneDataType( pType, _rNewName ) )
+ return false;
+
+ m_pHelper->setValidatingDataTypeByName( _rNewName );
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ bool XSDValidationPropertyHandler::implPrepareRemoveCurrentDataType() SAL_THROW(())
+ {
+ OSL_PRECOND( m_pHelper.get(), "XSDValidationPropertyHandler::implPrepareRemoveCurrentDataType: this will crash!" );
+
+ ::rtl::Reference< XSDDataType > pType = m_pHelper->getValidatingDataType();
+ if ( !pType.is() )
+ {
+ DBG_ERROR( "XSDValidationPropertyHandler::implPrepareRemoveCurrentDataType: invalid current data type!" );
+ return false;
+ }
+
+ // confirmation message
+ String sConfirmation( PcrRes( RID_STR_CONFIRM_DELETE_DATA_TYPE ) );
+ sConfirmation.SearchAndReplaceAscii( "#type#", pType->getName() );
+ QueryBox aQuery( NULL, WB_YES_NO, sConfirmation ); // TODO/eForms: proper parent
+ if ( aQuery.Execute() != RET_YES )
+ return false;
+
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ bool XSDValidationPropertyHandler::implDoRemoveCurrentDataType() SAL_THROW(())
+ {
+ OSL_PRECOND( m_pHelper.get(), "XSDValidationPropertyHandler::implDoRemoveCurrentDataType: this will crash!" );
+
+ ::rtl::Reference< XSDDataType > pType = m_pHelper->getValidatingDataType();
+ if ( !pType.is() )
+ return false;
+
+ // set a new data type at the binding, which is the "basic" type for the one
+ // we are going to delete
+ // (do this before the actual deletion, so the old type is still valid for property change
+ // notifications)
+ m_pHelper->setValidatingDataTypeByName( m_pHelper->getBasicTypeNameForClass( pType->classify() ) );
+ // now remove the type
+ m_pHelper->removeDataTypeFromRepository( pType->getName() );
+
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL XSDValidationPropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& _rOldValue, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nActuatingPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) );
+ if ( !m_pHelper.get() )
+ throw RuntimeException();
+ // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
+
+ switch ( nActuatingPropId )
+ {
+ case PROPERTY_ID_XSD_DATA_TYPE:
+ {
+ ::rtl::Reference< XSDDataType > xDataType( m_pHelper->getValidatingDataType() );
+
+ // is removal of this type possible?
+ sal_Bool bIsBasicType = xDataType.is() && xDataType->isBasicType();
+ _rxInspectorUI->enablePropertyUIElements( PROPERTY_XSD_DATA_TYPE, PropertyLineElement::PrimaryButton, xDataType.is() );
+ _rxInspectorUI->enablePropertyUIElements( PROPERTY_XSD_DATA_TYPE, PropertyLineElement::SecondaryButton, xDataType.is() && !bIsBasicType );
+
+ //------------------------------------------------------------
+ // show the facets which are available at the data type
+ ::rtl::OUString aFacets[] = {
+ PROPERTY_XSD_WHITESPACES, PROPERTY_XSD_PATTERN,
+ PROPERTY_XSD_LENGTH, PROPERTY_XSD_MIN_LENGTH, PROPERTY_XSD_MAX_LENGTH, PROPERTY_XSD_TOTAL_DIGITS,
+ PROPERTY_XSD_FRACTION_DIGITS,
+ PROPERTY_XSD_MAX_INCLUSIVE_INT,
+ PROPERTY_XSD_MAX_EXCLUSIVE_INT,
+ PROPERTY_XSD_MIN_INCLUSIVE_INT,
+ PROPERTY_XSD_MIN_EXCLUSIVE_INT,
+ PROPERTY_XSD_MAX_INCLUSIVE_DOUBLE,
+ PROPERTY_XSD_MAX_EXCLUSIVE_DOUBLE,
+ PROPERTY_XSD_MIN_INCLUSIVE_DOUBLE,
+ PROPERTY_XSD_MIN_EXCLUSIVE_DOUBLE,
+ PROPERTY_XSD_MAX_INCLUSIVE_DATE,
+ PROPERTY_XSD_MAX_EXCLUSIVE_DATE,
+ PROPERTY_XSD_MIN_INCLUSIVE_DATE,
+ PROPERTY_XSD_MIN_EXCLUSIVE_DATE,
+ PROPERTY_XSD_MAX_INCLUSIVE_TIME,
+ PROPERTY_XSD_MAX_EXCLUSIVE_TIME,
+ PROPERTY_XSD_MIN_INCLUSIVE_TIME,
+ PROPERTY_XSD_MIN_EXCLUSIVE_TIME,
+ PROPERTY_XSD_MAX_INCLUSIVE_DATE_TIME,
+ PROPERTY_XSD_MAX_EXCLUSIVE_DATE_TIME,
+ PROPERTY_XSD_MIN_INCLUSIVE_DATE_TIME,
+ PROPERTY_XSD_MIN_EXCLUSIVE_DATE_TIME
+ };
+
+ size_t i=0;
+ const ::rtl::OUString* pLoop = NULL;
+ for ( i = 0, pLoop = aFacets;
+ i < sizeof( aFacets ) / sizeof( aFacets[0] );
+ ++i, ++pLoop
+ )
+ {
+ showPropertyUI( _rxInspectorUI, *pLoop, xDataType.is() && xDataType->hasFacet( *pLoop ) );
+ _rxInspectorUI->enablePropertyUI( *pLoop, !bIsBasicType );
+ }
+ }
+ break;
+
+ case PROPERTY_ID_XML_DATA_MODEL:
+ {
+ // The data type which the current binding works with may not be present in the
+ // new model. Thus, transfer it.
+ ::rtl::OUString sOldModelName; _rOldValue >>= sOldModelName;
+ ::rtl::OUString sNewModelName; _rNewValue >>= sNewModelName;
+ ::rtl::OUString sDataType = m_pHelper->getValidatingDataTypeName();
+ m_pHelper->copyDataType( sOldModelName, sNewModelName, sDataType );
+
+ // the list of available data types depends on the chosen model, so update this
+ if ( !_bFirstTimeInit )
+ _rxInspectorUI->rebuildPropertyUI( PROPERTY_XSD_DATA_TYPE );
+ }
+ break;
+
+ default:
+ DBG_ERROR( "XSDValidationPropertyHandler::actuatingPropertyChanged: cannot handle this property!" );
+ return;
+ }
+
+ // in both cases, we need to care for the current value of the XSD_DATA_TYPE property,
+ // and update the FormatKey of the formatted field we're inspecting (if any)
+ if ( !_bFirstTimeInit && m_pHelper->isInspectingFormattedField() )
+ m_pHelper->findDefaultFormatForIntrospectee();
+ }
+
+ //--------------------------------------------------------------------
+ void XSDValidationPropertyHandler::implGetAvailableDataTypeNames( ::std::vector< ::rtl::OUString >& /* [out] */ _rNames ) const SAL_THROW(())
+ {
+ OSL_PRECOND( m_pHelper.get(), "XSDValidationPropertyHandler::implGetAvailableDataTypeNames: this will crash!" );
+ // start with *all* types which are available at the model
+ ::std::vector< ::rtl::OUString > aAllTypes;
+ m_pHelper->getAvailableDataTypeNames( aAllTypes );
+ _rNames.clear();
+ _rNames.reserve( aAllTypes.size() );
+
+ // then allow only those which are "compatible" with our control
+ for ( ::std::vector< ::rtl::OUString >::const_iterator dataType = aAllTypes.begin();
+ dataType != aAllTypes.end();
+ ++dataType
+ )
+ {
+ ::rtl::Reference< XSDDataType > pType = m_pHelper->getDataTypeByName( *dataType );
+ if ( pType.is() && m_pHelper->canBindToDataType( pType->classify() ) )
+ _rNames.push_back( *dataType );
+ }
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
diff --git a/extensions/source/propctrlr/xsdvalidationpropertyhandler.hxx b/extensions/source/propctrlr/xsdvalidationpropertyhandler.hxx
new file mode 100644
index 000000000000..e78a33096b32
--- /dev/null
+++ b/extensions/source/propctrlr/xsdvalidationpropertyhandler.hxx
@@ -0,0 +1,103 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_XSDVALIDATIONPROPERTYHANDLER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_XSDVALIDATIONPROPERTYHANDLER_HXX
+
+#include "propertyhandler.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <memory>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ class XSDValidationHelper;
+ //====================================================================
+ //= XSDValidationPropertyHandler
+ //====================================================================
+ class XSDValidationPropertyHandler;
+ typedef HandlerComponentBase< XSDValidationPropertyHandler > XSDValidationPropertyHandler_Base;
+ class XSDValidationPropertyHandler : public XSDValidationPropertyHandler_Base
+ {
+ private:
+ ::std::auto_ptr< XSDValidationHelper > m_pHelper;
+
+ public:
+ XSDValidationPropertyHandler(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
+ );
+
+ static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ ~XSDValidationPropertyHandler();
+
+ protected:
+ // XPropertyHandler overriables
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getSupersededProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::LineDescriptor
+ SAL_CALL describePropertyLine( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::InteractiveSelectionResult
+ SAL_CALL onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, ::com::sun::star::uno::Any& _rData, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // PropertyHandler overridables
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
+ SAL_CALL doDescribeSupportedProperties() const;
+ virtual void onNewComponent();
+
+ private:
+ bool implPrepareRemoveCurrentDataType() SAL_THROW(());
+ bool implDoRemoveCurrentDataType() SAL_THROW(());
+
+ bool implPrepareCloneDataCurrentType( ::rtl::OUString& _rNewName ) SAL_THROW(());
+ bool implDoCloneCurrentDataType( const ::rtl::OUString& _rNewName ) SAL_THROW(());
+
+ /** retrieves the names of the data types which our introspectee can be validated against
+ */
+ void implGetAvailableDataTypeNames( ::std::vector< ::rtl::OUString >& /* [out] */ _rNames ) const SAL_THROW(());
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_XSDVALIDATIONPROPERTYHANDLER_HXX
+