26 #include <svx/strings.hrc>
47 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
48 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
49 #include <com/sun/star/sdbc/XRowSet.hpp>
50 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
51 #include <com/sun/star/util/XNumberFormats.hpp>
52 #include <com/sun/star/sdb/CommandType.hpp>
53 #include <com/sun/star/sdbc/DataType.hpp>
54 #include <com/sun/star/form/FormComponentType.hpp>
55 #include <com/sun/star/form/FormButtonType.hpp>
56 #include <com/sun/star/form/binding/XBindableValue.hpp>
57 #include <com/sun/star/form/binding/XValueBinding.hpp>
58 #include <com/sun/star/form/runtime/FormController.hpp>
59 #include <com/sun/star/form/submission/XSubmissionSupplier.hpp>
60 #include <com/sun/star/awt/XTabControllerModel.hpp>
61 #include <com/sun/star/awt/XControlContainer.hpp>
62 #include <com/sun/star/awt/XTabController.hpp>
63 #include <com/sun/star/container/XIndexAccess.hpp>
64 #include <com/sun/star/awt/XControl.hpp>
65 #include <com/sun/star/sdbc/SQLException.hpp>
66 #include <com/sun/star/sdb/XQueriesSupplier.hpp>
67 #include <com/sun/star/container/XContainer.hpp>
86 using namespace ::
svx;
91 using ::com::sun::star::uno::Exception;
92 using ::com::sun::star::uno::XInterface;
93 using ::com::sun::star::uno::Sequence;
94 using ::com::sun::star::uno::UNO_QUERY;
95 using ::com::sun::star::uno::UNO_QUERY_THROW;
96 using ::com::sun::star::uno::UNO_SET_THROW;
97 using ::com::sun::star::uno::Type;
98 using ::com::sun::star::uno::Reference;
99 using ::com::sun::star::uno::Any;
100 using ::com::sun::star::uno::XComponentContext;
101 using ::com::sun::star::form::FormButtonType_SUBMIT;
102 using ::com::sun::star::form::binding::XValueBinding;
103 using ::com::sun::star::form::binding::XBindableValue;
104 using ::com::sun::star::lang::XComponent;
105 using ::com::sun::star::container::XIndexAccess;
106 using ::com::sun::star::form::runtime::FormController;
107 using ::com::sun::star::form::runtime::XFormController;
108 using ::com::sun::star::script::XEventAttacherManager;
109 using ::com::sun::star::awt::XTabControllerModel;
110 using ::com::sun::star::container::XChild;
111 using ::com::sun::star::task::XInteractionHandler;
112 using ::com::sun::star::awt::XTabController;
113 using ::com::sun::star::awt::XControlContainer;
114 using ::com::sun::star::awt::XControl;
115 using ::com::sun::star::form::XFormComponent;
116 using ::com::sun::star::form::XForm;
117 using ::com::sun::star::lang::IndexOutOfBoundsException;
118 using ::com::sun::star::container::XContainer;
119 using ::com::sun::star::container::ContainerEvent;
120 using ::com::sun::star::lang::EventObject;
121 using ::com::sun::star::sdb::SQLErrorEvent;
122 using ::com::sun::star::sdbc::XRowSet;
124 using ::com::sun::star::container::XElementAccess;
125 using ::com::sun::star::awt::XWindow;
126 using ::com::sun::star::awt::FocusEvent;
127 using ::com::sun::star::ui::dialogs::XExecutableDialog;
128 using ::com::sun::star::sdbc::XDataSource;
129 using ::com::sun::star::container::XIndexContainer;
130 using ::com::sun::star::sdbc::XConnection;
131 using ::com::sun::star::container::XNameAccess;
132 using ::com::sun::star::sdbc::SQLException;
133 using ::com::sun::star::util::XNumberFormatsSupplier;
134 using ::com::sun::star::util::XNumberFormats;
135 using ::com::sun::star::beans::XPropertySetInfo;
137 namespace FormComponentType = ::com::sun::star::form::FormComponentType;
138 namespace CommandType = ::com::sun::star::sdb::CommandType;
139 namespace DataType = ::com::sun::star::sdbc::DataType;
151 : m_xControlContainer( _rWindow.GetControlContainer() ),
153 m_pViewImpl( _pViewImpl ),
154 m_pWindow( _rWindow.GetPaintWindow().GetOutputDevice().GetOwnerWindow() )
159 DBG_ASSERT( pFormPage,
"FormViewPageWindowAdapter::FormViewPageWindowAdapter: no FmFormPage found!" );
165 Reference< XIndexAccess > xForms( pFormPage->
GetForms(), UNO_QUERY_THROW );
166 sal_uInt32
nLength = xForms->getCount();
167 for (sal_uInt32
i = 0;
i < nLength;
i++)
169 Reference< XForm > xForm( xForms->getByIndex(
i), UNO_QUERY );
186 for ( ::std::vector< Reference< XFormController > >::const_iterator
i =
m_aControllerList.begin();
193 Reference< XFormController >
xController( *
i, UNO_SET_THROW );
196 Reference< XChild > xControllerModel( xController->getModel(), UNO_QUERY );
197 if ( xControllerModel.is() )
199 Reference< XEventAttacherManager > xEventManager( xControllerModel->getParent(), UNO_QUERY_THROW );
200 Reference< XInterface > xControllerNormalized( xController, UNO_QUERY_THROW );
205 xController->dispose();
236 throw IndexOutOfBoundsException();
247 Reference< XWindow > xWindow( Control, UNO_QUERY );
250 awt::Rectangle aRect = xWindow->getPosSize();
251 ::tools::Rectangle aNewRect( aRect.X, aRect.Y, aRect.X + aRect.Width, aRect.Y + aRect.Height );
257 static Reference< XFormController >
getControllerSearchChildren(
const Reference< XIndexAccess > & xIndex,
const Reference< XTabControllerModel > & xModel)
259 if (xIndex.is() && xIndex->getCount())
263 for (sal_Int32
n = xIndex->getCount();
n-- && !xController.is(); )
265 xIndex->getByIndex(
n) >>= xController;
266 if (xModel.get() == xController->getModel().get())
271 if ( xController.is() )
276 return Reference< XFormController > ();
282 Reference< XTabControllerModel >
xModel(xForm, UNO_QUERY);
285 if (rpController->getModel().get() == xModel.get())
289 Reference< XFormController > xChildSearch =
getControllerSearchChildren(Reference< XIndexAccess > (rpController, UNO_QUERY), xModel);
290 if (xChildSearch.is())
293 return Reference< XFormController > ();
299 DBG_ASSERT( xForm.is(),
"FormViewPageWindowAdapter::setController: there should be a form!" );
300 Reference< XIndexAccess > xFormCps(xForm, UNO_QUERY);
304 Reference< XTabControllerModel > xTabOrder(xForm, UNO_QUERY);
310 if ( _rxParentController.is() )
311 xHandler = _rxParentController->getInteractionHandler();
318 xController->setInteractionHandler( xHandler );
320 xController->setContext(
this );
322 xController->setModel( xTabOrder );
324 xController->activateTabOrder();
327 if ( _rxParentController.is() )
328 _rxParentController->addChildController( xController );
333 xController->setParent( *
this );
336 Reference< XEventAttacherManager > xEventManager( xForm->getParent(), UNO_QUERY );
337 xEventManager->attach(
m_aControllerList.size() - 1, Reference<XInterface>( xController, UNO_QUERY ),
Any(xController) );
341 sal_uInt32
nLength = xFormCps->getCount();
342 Reference< XForm > xSubForm;
343 for (sal_uInt32
i = 0;
i < nLength;
i++)
345 if ( xFormCps->getByIndex(
i) >>= xSubForm )
353 OSL_PRECOND( _rxForm.is(),
"FormViewPageWindowAdapter::updateTabOrder: illegal argument!" );
359 Reference< XTabController > xTabCtrl(
getController( _rxForm ) );
362 xTabCtrl->activateTabOrder();
369 Reference< XForm > xParentForm( _rxForm->getParent(), UNO_QUERY );
371 Reference< XFormController > xParentController;
372 if ( xParentForm.is() )
386 :m_pMarkedGrid(nullptr)
388 ,m_nActivationEvent(nullptr)
389 ,m_nErrorMessageEvent( nullptr )
390 ,m_nAutoFocusEvent( nullptr )
391 ,m_nControlWizardEvent( nullptr )
392 ,m_bFirstActivation( true )
393 ,m_isTabOrderUpdateSuspended(
false )
439 rpAdapter->dispose();
481 Reference< XControlContainer > xControlContainer( evt.Source, UNO_QUERY_THROW );
482 Reference< XControl > xControl( evt.Element, UNO_QUERY_THROW );
483 Reference< XFormComponent > xControlModel( xControl->getModel(), UNO_QUERY_THROW );
484 Reference< XForm > xForm( xControlModel->getParent(), UNO_QUERY_THROW );
495 pAdapter->updateTabOrder( xForm );
541 Reference< XContainer > xContainer( xCC, UNO_QUERY );
542 if ( xContainer.is() )
543 xContainer->addContainerListener(
this );
559 Reference< XContainer > xContainer( _rxCC, UNO_QUERY );
560 if ( xContainer.is() )
561 xContainer->removeContainerListener(
this );
579 m_nErrorMessageEvent =
nullptr;
604 if ( !pAdapter.is() )
607 for (
const auto& rForm : rContainer.second)
609 pAdapter->updateTabOrder( rForm );
612 m_aNeedTabOrderUpdate.clear();
617 bool isActivableDatabaseForm(
const Reference< XFormController > &xController)
620 Reference< XRowSet > xForm(xController->getModel(), UNO_QUERY);
625 if ( !xFormSet.is() )
627 SAL_WARN(
"svx.form",
"FmXFormView::OnActivate: a form which does not have properties?" );
631 const OUString aSource = ::comphelper::getString( xFormSet->getPropertyValue(
FM_PROP_COMMAND ) );
633 return !aSource.isEmpty();
636 class find_active_databaseform
638 const Reference< XFormController > xActiveController;
642 explicit find_active_databaseform(
const Reference< XFormController >& _xActiveController )
643 : xActiveController(_xActiveController )
646 Reference < XFormController > operator() (
const Reference< XFormController > &xController)
648 if(xController == xActiveController && isActivableDatabaseForm(xController))
651 if ( !xController.is() )
653 SAL_WARN(
"svx.form",
"FmXFormView::OnActivate: a form controller which does not have children?" );
657 for(sal_Int32 i = 0;
i < xController->getCount(); ++
i)
659 const Any a(xController->getByIndex(i));
660 Reference < XFormController > xI;
661 if ((a >>= xI) && xI.is())
663 Reference < XFormController > xRes(
operator()(xI));
677 m_nActivationEvent =
nullptr;
681 OSL_FAIL(
"FmXFormView::OnActivate: well... seems we have a timing problem (the view already died)!" );
686 if (!(m_pView->GetFormShell() && m_pView->GetActualOutDev() && m_pView->GetActualOutDev()->GetOutDevType() ==
OUTDEV_WINDOW))
689 FmXFormShell*
const pShImpl = m_pView->GetFormShell()->GetImpl();
694 find_active_databaseform fad(pShImpl->getActiveController_Lock());
696 vcl::Window* pWindow = m_pView->GetActualOutDev()->GetOwnerWindow();
698 for (
const auto& rpPageWindowAdapter : m_aPageWindowAdapters)
700 if ( pWindow == rpPageWindowAdapter->getWindow() )
701 pAdapter = rpPageWindowAdapter;
704 if ( !pAdapter.is() )
707 Reference< XFormController > xControllerToActivate;
708 for (
const Reference< XFormController > & xController : pAdapter->GetList())
710 if ( !xController.is() )
714 Reference< XFormController > xActiveController(fad(xController));
715 if (xActiveController.is())
717 xControllerToActivate = xActiveController;
722 if(xControllerToActivate.is() || !isActivableDatabaseForm(xController))
725 xControllerToActivate = xController;
727 pShImpl->setActiveController_Lock(xControllerToActivate);
757 if (pShImpl && bDeactivateController)
758 pShImpl->setActiveController_Lock(
nullptr);
778 if ( !i_rControl.is() )
786 bool bEnabled =
false;
787 OSL_VERIFY( xModelProps->getPropertyValue(
FM_PROP_ENABLED ) >>= bEnabled );
792 sal_Int16 nClassId = FormComponentType::CONTROL;
793 OSL_VERIFY( xModelProps->getPropertyValue(
FM_PROP_CLASSID ) >>= nClassId );
796 if ( ( FormComponentType::CONTROL != nClassId )
797 && ( FormComponentType::IMAGEBUTTON != nClassId )
798 && ( FormComponentType::GROUPBOX != nClassId )
799 && ( FormComponentType::FIXEDTEXT != nClassId )
800 && ( FormComponentType::HIDDENCONTROL != nClassId )
801 && ( FormComponentType::IMAGECONTROL != nClassId )
802 && ( FormComponentType::SCROLLBAR != nClassId )
803 && ( FormComponentType::SPINBUTTON!= nClassId )
819 Reference< XControl > xReturn;
822 for (
auto const &
control : _rControls )
834 if ( !xReturn.is() && _rControls.hasElements() )
835 xReturn = _rControls[0];
844 void lcl_ensureControlsOfFormExist_nothrow(
const SdrPage& _rPage,
const SdrView& _rView,
const vcl::Window& _rWindow,
const Reference< XForm >& _rxForm )
848 Reference< XInterface > xNormalizedForm( _rxForm, UNO_QUERY_THROW );
851 while ( aSdrObjectLoop.IsMore() )
853 FmFormObj* pFormObject = FmFormObj::GetFormObject( aSdrObjectLoop.Next() );
857 Reference< XChild >
xModel( pFormObject->GetUnoControlModel(), UNO_QUERY_THROW );
858 Reference< XInterface > xModelParent(
xModel->getParent(), UNO_QUERY );
860 if ( xNormalizedForm.get() != xModelParent.get() )
863 pFormObject->GetUnoControl( _rView, *_rWindow.
GetOutDev() );
866 catch (
const Exception&)
876 Reference< XFormController > xController;
882 SAL_WARN(
"svx.form",
"FmXFormView::getFormController: invalid page window adapter!" );
890 xController = pAdapter->getController( _rxForm );
891 if ( xController.is() )
900 m_nAutoFocusEvent =
nullptr;
905 SdrPageView *pPageView = m_pView ? m_pView->GetSdrPageView() :
nullptr;
909 Reference< XIndexAccess > xForms( pPage ? Reference< XIndexAccess >( pPage->
GetForms() ) : Reference< XIndexAccess >() );
912 const vcl::Window* pWindow = pAdapter ? pAdapter->getWindow() :
nullptr;
914 ENSURE_OR_RETURN_VOID( xForms.is() && pWindow,
"FmXFormView::OnAutoFocus: could not collect all essentials!" );
919 if ( !xForms->getCount() )
921 Reference< XForm > xForm( xForms->getByIndex( 0 ), UNO_QUERY_THROW );
922 Reference< XTabController > xTabController( pAdapter->getController( xForm ), UNO_QUERY_THROW );
925 Sequence< Reference< XControl > > aControls( xTabController->getControls() );
926 if ( !aControls.hasElements() )
928 Reference< XElementAccess > xFormElementAccess( xForm, UNO_QUERY_THROW );
929 if (xFormElementAccess->hasElements() && pPage && m_pView)
936 lcl_ensureControlsOfFormExist_nothrow( *pPage, *m_pView, *pWindow, xForm );
937 aControls = xTabController->getControls();
938 OSL_ENSURE( aControls.hasElements(),
"FmXFormView::OnAutoFocus: no controls at all!" );
944 if ( !xControlWindow.is() )
947 xControlWindow->setFocus();
953 if ( pCurrentWindow )
955 awt::Rectangle aRect = xControlWindow->getPosSize();
956 ::tools::Rectangle aNonUnoRect( aRect.X, aRect.Y, aRect.X + aRect.Width, aRect.Y + aRect.Height );
957 m_pView->MakeVisible( pCurrentWindow->
PixelToLogic( aNonUnoRect ), *
const_cast< vcl::Window*
>( pCurrentWindow ) );
971 OSL_ENSURE( pShellImpl,
"FmXFormView::onCreatedFormObject: no form shell!" );
976 pShellImpl->UpdateForms_Lock(
true);
983 FormControlFactory aControlFactory;
984 aControlFactory.initializeControlModel(pShellImpl->getDocumentType_Lock(), _rFormObject);
986 if (!pShellImpl->GetWizardUsing_Lock())
990 if (pShellImpl->isEnhancedForm_Lock())
1022 m_nControlWizardEvent =
nullptr;
1023 OSL_PRECOND( m_xLastCreatedControlModel.is(),
"FmXFormView::OnStartControlWizard: illegal call!" );
1024 if ( !m_xLastCreatedControlModel.is() )
1027 sal_Int16 nClassId = FormComponentType::CONTROL;
1030 OSL_VERIFY( m_xLastCreatedControlModel->getPropertyValue(
FM_PROP_CLASSID ) >>= nClassId );
1037 const char* pWizardAsciiName =
nullptr;
1040 case FormComponentType::GRIDCONTROL:
1041 pWizardAsciiName =
"com.sun.star.sdb.GridControlAutoPilot";
1043 case FormComponentType::LISTBOX:
1044 case FormComponentType::COMBOBOX:
1045 pWizardAsciiName =
"com.sun.star.sdb.ListComboBoxAutoPilot";
1047 case FormComponentType::GROUPBOX:
1048 pWizardAsciiName =
"com.sun.star.sdb.GroupBoxAutoPilot";
1052 if ( pWizardAsciiName )
1056 aWizardArgs.
put(
"ObjectModel", m_xLastCreatedControlModel);
1057 aWizardArgs.
put(
"ParentWindow", GetParentWindow());
1060 Reference< XExecutableDialog > xWizard;
1064 xWizard.set( xContext->getServiceManager()->createInstanceWithArgumentsAndContext( OUString::createFromAscii(pWizardAsciiName), aWizardArgs.
getWrappedPropertyValues(), xContext ), UNO_QUERY);
1071 if ( !xWizard.is() )
1089 m_xLastCreatedControlModel.clear();
1095 void lcl_insertIntoFormComponentHierarchy_throw(
const FmFormView& _rView,
const SdrUnoObj& _rSdrObj,
1097 const OUString& _rCommand,
const sal_Int32 _nCommandType )
1101 Reference< XFormComponent > xFormComponent( _rSdrObj.
GetUnoControlModel(), UNO_QUERY_THROW );
1102 Reference< XForm > xTargetForm(
1108 Reference< XIndexContainer > xFormAsContainer( xTargetForm, UNO_QUERY_THROW );
1109 xFormAsContainer->insertByIndex( xFormAsContainer->getCount(),
Any( xFormComponent ) );
1120 OUString sCommand, sFieldName;
1121 sal_Int32 nCommandType = CommandType::COMMAND;
1125 _rColumnDescriptor[ DataAccessDescriptorProperty::Command ] >>= sCommand;
1126 _rColumnDescriptor[ DataAccessDescriptorProperty::ColumnName ] >>= sFieldName;
1127 _rColumnDescriptor[ DataAccessDescriptorProperty::CommandType ] >>= nCommandType;
1130 _rColumnDescriptor[ DataAccessDescriptorProperty::Connection ] >>= xExternalConnection;
1134 if ( sCommand.isEmpty()
1135 || sFieldName.isEmpty()
1136 || ( sDataSource.isEmpty()
1137 && !xConnection.
is()
1141 OSL_FAIL(
"FmXFormView::implCreateFieldControl: nonsense!" );
1145 SQLErrorEvent aError;
1148 if ( xConnection.
is() && !xDataSource.is() && sDataSource.isEmpty() )
1150 Reference< XChild > xChild( xConnection, UNO_QUERY );
1152 xDataSource.set(xChild->getParent(), css::uno::UNO_QUERY);
1156 if ( !xDataSource.is() )
1160 if ( !xConnection.
is() )
1169 catch (
const SQLException&)
1171 aError.Reason = ::cppu::getCaughtException();
1177 if (aError.Reason.hasValue())
1184 if (!xDataSource.is() || !xConnection.
is())
1186 OSL_FAIL(
"FmXFormView::implCreateFieldControl : could not retrieve the data source or the connection!");
1190 Reference< XComponent > xKeepFieldsAlive;
1198 xConnection, nCommandType, sCommand, xKeepFieldsAlive );
1200 if (xFields.is() && xFields->hasByName(sFieldName))
1201 xFields->getByName(sFieldName) >>= xField;
1205 Reference< XNumberFormatsSupplier > xSupplier(
getNumberFormats( xConnection ), UNO_SET_THROW );
1206 Reference< XNumberFormats > xNumberFormats( xSupplier->getNumberFormats(), UNO_SET_THROW );
1208 OUString sLabelPostfix;
1222 for( sal_uInt32
i = 0;
i < pPageView->PageWindowCount();
i++ )
1239 if ((DataType::BINARY == nDataType) || (DataType::VARBINARY == nDataType))
1245 bool bDateNTimeField =
false;
1247 bool bIsCurrency =
false;
1256 case DataType::BLOB:
1257 case DataType::LONGVARBINARY:
1260 case DataType::LONGVARCHAR:
1261 case DataType::CLOB:
1264 case DataType::BINARY:
1265 case DataType::VARBINARY:
1268 case DataType::BOOLEAN:
1271 case DataType::TINYINT:
1272 case DataType::SMALLINT:
1273 case DataType::INTEGER:
1276 case DataType::REAL:
1277 case DataType::DOUBLE:
1278 case DataType::NUMERIC:
1279 case DataType::DECIMAL:
1282 case DataType::TIMESTAMP:
1283 bDateNTimeField =
true;
1284 sLabelPostfix =
SvxResId(RID_STR_POSTFIX_DATE);
1286 case DataType::DATE:
1289 case DataType::TIME:
1292 case DataType::CHAR:
1293 case DataType::VARCHAR:
1301 std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pLabel;
1302 std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pControl;
1304 pLabel, pControl, xDataSource, sDataSource, sCommand, nCommandType )
1313 OSL_ENSURE( !bCheckbox || !pLabel,
"FmXFormView::implCreateFieldControl: why was there a label created for a check box?" );
1322 if ( bDateNTimeField )
1325 SvxResId(RID_STR_POSTFIX_TIME), pLabel, pControl,
1326 xDataSource, sDataSource, sCommand, nCommandType )
1356 Reference< XNumberFormats > xNumberFormats;
1357 OUString sLabelPostfix = _rDesc.
szName;
1371 for( sal_uInt32
i = 0;
i < pPageView->PageWindowCount();
i++ )
1397 Reference< css::form::submission::XSubmission > xSubmission(_rDesc.
xPropSet, UNO_QUERY);
1400 if ( !xSubmission.is() )
1402 std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pLabel;
1403 std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pControl;
1405 pLabel, pControl,
nullptr,
"",
"", -1 )
1413 Reference< XValueBinding > xValueBinding(_rDesc.
xPropSet,UNO_QUERY);
1414 Reference< XBindableValue > xBindableValue(pControl->GetUnoControlModel(),UNO_QUERY);
1416 DBG_ASSERT( xBindableValue.is(),
"FmXFormView::implCreateXFormsControl: control's not bindable!" );
1417 if ( xBindableValue.is() )
1418 xBindableValue->setValueBinding(xValueBinding);
1421 OSL_ENSURE( !bCheckbox || !pLabel,
"FmXFormView::implCreateXFormsControl: why was there a label created for a check box?" );
1438 const MapMode eSourceMode(MapUnit::Map100thMM);
1440 ::Size controlSize(4000, 500);
1441 FmFormObj *pControl =
static_cast<FmFormObj*
>(
1443 getView()->getSdrModelFromSdrView(),
1450 pControl->SetLogicRect(controlRect);
1458 Any( FormButtonType_SUBMIT ) );
1459 Reference< css::form::submission::XSubmissionSupplier > xSubmissionSupplier(pControl->GetUnoControlModel(), UNO_QUERY);
1460 xSubmissionSupplier->setSubmission(xSubmission);
1476 SdrObjKind _nControlObjectID, std::u16string_view _rFieldPostfix,
1477 std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel,
1478 std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpControl,
1480 const OUString& _rCommand,
const sal_Int32 _nCommandType )
1496 getView()->getSdrModelFromSdrView(),
1506 lcl_insertIntoFormComponentHierarchy_throw( *
m_pView, *_rpLabel, _rxDataSource, _rDataSourceName, _rCommand, _nCommandType );
1507 lcl_insertIntoFormComponentHierarchy_throw( *
m_pView, *_rpControl, _rxDataSource, _rDataSourceName, _rCommand, _nCommandType );
1510 FormControlFactory aControlFactory;
1521 const Reference< XNumberFormats >& _rxNumberFormats,
SdrObjKind _nControlObjectID,
1524 std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel, std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpControl)
1527 OUString sFieldName;
1529 if ( _rxField.is() )
1531 nDataType = ::comphelper::getINT32(_rxField->getPropertyValue(
FM_PROP_FIELDTYPE));
1533 aFieldName >>= sFieldName;
1540 eSourceMode( MapUnit::Map100thMM );
1544 ::Size aDefTxtSize(4000, 500);
1545 ::Size aDefSize(4000, 500);
1546 ::Size aDefImageSize(4000, 4000);
1549 aRealSize.
setWidth( std::max(aRealSize.
Width(), aDefTxtSize.Width()) );
1550 aRealSize.
setHeight( aDefSize.Height() );
1560 ::std::unique_ptr< SdrUnoObj, SdrObjectFreeOp > pLabel;
1565 pLabel.reset( dynamic_cast< SdrUnoObj* >(
1571 OSL_ENSURE(pLabel,
"FmXFormView::createControlLabelPair: could not create the label!");
1576 xLabelModel.set( pLabel->GetUnoControlModel(), UNO_QUERY );
1577 if ( xLabelModel.is() )
1580 if ( _rxField.is() && _rxField->getPropertySetInfo()->hasPropertyByName(
FM_PROP_LABEL) )
1582 if ( sLabel.isEmpty() )
1583 sLabel = sFieldName;
1585 xLabelModel->setPropertyValue(
FM_PROP_LABEL,
Any( sLabel + _rFieldPostfix ) );
1586 OUString sObjectLabel(
SvxResId(RID_STR_OBJECT_LABEL).replaceAll(
"#object#", sFieldName));
1597 ::std::unique_ptr< SdrUnoObj, SdrObjectFreeOp > pControl( dynamic_cast< SdrUnoObj* >(
1601 _nControlObjectID)));
1603 OSL_ENSURE(pControl,
"FmXFormView::createControlLabelPair: could not create the control!");
1609 if ( !xControlSet.is() )
1613 ::Size aControlSize( aDefSize );
1614 switch ( nDataType )
1617 case DataType::BOOLEAN:
1618 aControlSize = aDefSize;
1620 case DataType::LONGVARCHAR:
1621 case DataType::CLOB:
1622 case DataType::LONGVARBINARY:
1623 case DataType::BLOB:
1624 aControlSize = aDefImageSize;
1629 aControlSize = aDefImageSize;
1631 aControlSize.setWidth(
tools::Long(
Fraction(aControlSize.Width(), 1) * eTargetMode.GetScaleX()) );
1632 aControlSize.setHeight(
tools::Long(
Fraction(aControlSize.Height(), 1) * eTargetMode.GetScaleY()) );
1640 Reference< XPropertySetInfo > xControlPropInfo = xControlSet->getPropertySetInfo();
1642 if ( aFieldName.hasValue() )
1645 xControlSet->setPropertyValue(
FM_PROP_NAME, aFieldName );
1650 xControlSet->setPropertyValue(
FM_PROP_LABEL,
Any( sFieldName + _rFieldPostfix ) );
1652 OSL_FAIL(
"FmXFormView::createControlLabelPair: can't set a label for the control!" );
1656 if ( (nDataType == DataType::LONGVARCHAR || nDataType == DataType::CLOB) && xControlPropInfo->hasPropertyByName(
FM_PROP_MULTILINE ) )
1668 catch (
const Exception&)
1674 if ( _rxField.is() )
1676 FormControlFactory::initializeFieldDependentProperties( _rxField, xControlSet, _rxNumberFormats );
1679 _rpLabel = std::move(pLabel);
1680 _rpControl = std::move(pControl);
1686 :m_pParent( pParent )
1693 if (rHint.
GetId() != SfxHintId::ThisIsAnSdrHint)
1697 m_pParent->ObjectRemovedInAliveMode(pSdrHint->
GetObject());
1709 for (
size_t i = 0;
i < nCount; ++
i)
1713 if (pObject == pCurrent)
1739 DBG_ASSERT( pModel !=
nullptr,
"FmXFormView::startMarkListWatching: shell has no model!" );
1748 OSL_FAIL(
"FmXFormView::startMarkListWatching: already listening!" );
1758 for (
size_t i = 0;
i < nCount; ++
i )
1768 bool bMixed =
false;
1769 while ( aIter.IsMore() && !bMixed )
1790 OSL_FAIL(
"FmXFormView::saveMarkList: invalid view!" );
1797 bool bFound =
false;
1798 while (rIter.
IsMore() && !bFound)
1799 bFound = pObj == rIter.
Next();
1811 _rRestoredMarkList.
Clear();
1820 bool bMisMatch =
false;
1823 const size_t nCurrentCount = rCurrentList.
GetMarkCount();
1824 for (
size_t i=0;
i<nCurrentCount && !bMisMatch; ++
i )
1829 bool bFound =
false;
1831 for (
size_t j=0; j<nSavedCount && !bFound; ++j )
1845 _rRestoredMarkList = rCurrentList;
1857 for (
size_t i = 0;
i < nCount && bFound; ++
i)
1864 while (aIter.IsMore() && bFound)
1870 bFound = bFound && pCurPageView == pMark->
GetPageView();
1878 for (
size_t i = 0;
i < nCount; ++
i)
#define LINK(Instance, Class, Member)
#define ENSURE_OR_RETURN_VOID(c, m)
OutDevType GetOutDevType() const
Reference< XInterface > getDataSource(const Reference< XInterface > &_rxDependentObject)
css::uno::Reference< css::awt::XControlContainer > m_xControlContainer
virtual ~FormViewPageWindowAdapter() override
css::uno::Sequence< css::uno::Any > getWrappedPropertyValues() const
SdrHintKind GetKind() const
size_t GetMarkCount() const
css::uno::Reference< css::form::runtime::XFormController > getController(const css::uno::Reference< css::form::XForm > &xForm) const
exports com.sun.star.form. control
void setWidth(tools::Long nWidth)
css::uno::Reference< css::form::XForm > findPlaceInFormComponentHierarchy(const css::uno::Reference< css::form::XFormComponent > &rContent, const css::uno::Reference< css::sdbc::XDataSource > &rDatabase=css::uno::Reference< css::sdbc::XDataSource >(), const OUString &rDBTitle=OUString(), const OUString &rCursorSource=OUString(), sal_Int32 nCommandType=0)
finds a place in the form component hierarchy where to insert the given component ...
static OUString setUniqueName(const css::uno::Reference< css::form::XFormComponent > &xFormComponent, const css::uno::Reference< css::form::XForm > &xControls)
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
constexpr OUStringLiteral FM_COMPONENT_COMMANDBUTTON
bool IsModuleInstalled(EModule eModule) const
bool IsDesignMode() const
bool getBOOL(const Any &_rAny)
css::uno::Reference< css::awt::XControlContainer > const & GetControlContainer(bool _bCreateIfNecessary=true) const
static SdrObject * MakeNewObject(SdrModel &rSdrModel, SdrInventor nInventor, SdrObjKind nObjIdentifier, const tools::Rectangle *pSnapRect=nullptr)
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
const MapMode & GetMapMode() const
::std::vector< css::uno::Reference< css::form::runtime::XFormController > > m_aControllerList
void setController(const css::uno::Reference< css::form::XForm > &xForm, const css::uno::Reference< css::form::runtime::XFormController > &_rxParentController)
SdrMark * GetMark(size_t nNum) const
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
void DeleteMark(size_t nNum)
virtual SdrObjList * GetSubList() const
constexpr OUStringLiteral FM_PROP_CLASSID
constexpr tools::Long Width() const
Reference< XController > xController
constexpr OUStringLiteral FM_PROP_CONTROLLABEL
constexpr OUStringLiteral FM_PROP_LABEL
bool OutputToWindow() const
OUString SvxResId(TranslateId aId)
FmFormPageImpl & GetImpl() const
virtual sal_Int32 SAL_CALL getCount() override
constexpr OUStringLiteral FM_PROP_FIELDTYPE
constexpr OUStringLiteral FM_PROP_ISCURRENCY
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
SdrObject * GetMarkedSdrObj() const
Everything a View needs to know about a selected object.
#define DBG_UNHANDLED_EXCEPTION(...)
#define TOOLS_WARN_EXCEPTION(area, stream)
constexpr OUStringLiteral FM_PROP_ENABLED
#define DBG_ASSERT(sCon, aError)
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
virtual void SAL_CALL makeVisible(const css::uno::Reference< css::awt::XControl > &Control) override
class SAL_NO_VTABLE XPropertySet
IMPL_LINK_NOARG(FmXFormView, OnDelayedErrorMessage, void *, void)
constexpr OUStringLiteral FM_SUN_COMPONENT_NUMERICFIELD
virtual void MakeVisible(const tools::Rectangle &rRect, vcl::Window &rWin)
const SdrMarkList & GetMarkedObjectList() const
SdrPageView * GetPageView() const
virtual css::uno::Type SAL_CALL getElementType() override
css::uno::Reference< css::uno::XComponentContext > m_xContext
static Reference< XControl > lcl_firstFocussableControl(const Sequence< Reference< XControl > > &_rControls)
bool IsGroupObject() const
css::uno::Type const & get()
Point PixelToLogic(const Point &rDevicePt) const
virtual SdrInventor GetObjInventor() const
constexpr OUStringLiteral FM_SUN_COMPONENT_CHECKBOX
OUString getDataSource() const
returns either the data source name if given or the database location
class encapsulating the css::sdb::DataAccessDescriptor service.
constexpr OUStringLiteral FM_PROP_MULTILINE
constexpr tools::Long Height() const
SdrPage * GetPage() const
void updateTabOrder(const css::uno::Reference< css::form::XForm > &_rxForm)
tools::Long GetTextHeight() const
::OutputDevice const * GetOutDev() const
SdrPaintWindow & GetPaintWindow() const
bool put(const OUString &_rValueName, const VALUE_TYPE &_rValue)
virtual sal_Bool SAL_CALL hasElements() override
constexpr OUStringLiteral FM_PROP_NAME
Reference< XComponentContext > getProcessComponentContext()
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
constexpr OUStringLiteral FM_PROP_COMMAND
SdrPageView * GetSdrPageView() const
const css::uno::Reference< css::awt::XControlModel > & GetUnoControlModel() const
constexpr OUStringLiteral FM_PROP_BUTTON_TYPE
void setHeight(tools::Long nHeight)
bool hasProperty(const OUString &_rName, const Reference< XPropertySet > &_rxSet)
VclPtr< vcl::Window > m_pWindow
FormViewPageWindowAdapter(const css::uno::Reference< css::uno::XComponentContext > &_rContext, const SdrPageWindow &, FmXFormView *pView)
#define SAL_WARN(area, stream)
Reference< XModel > xModel
constexpr OUStringLiteral FM_PROP_CONTROLSOURCE
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
void reset(const css::uno::Reference< INTERFACE > &_rxComponent, AssignmentMode _eMode=TakeOwnership)
void ShowServiceNotAvailableError(weld::Widget *pParent, std::u16string_view rServiceName, bool bError)
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
const css::uno::Reference< css::form::XForms > & GetForms(bool _bForceCreate=true) const
Reference< XComponentContext > m_xContext
static css::uno::Reference< css::awt::XWindow > GetInterface(vcl::Window *pWindow)
virtual vcl::Window * GetOwnerWindow() const
static Reference< XFormController > getControllerSearchChildren(const Reference< XIndexAccess > &xIndex, const Reference< XTabControllerModel > &xModel)
OutputDevice & GetOutputDevice() const
FmXFormView * m_pViewImpl
static bool lcl_hasObject(SdrObjListIter &rIter, SdrObject const *pObj)
bool m_bDetectedRangeSegmentation false
SdrPageView & GetPageView() const
bool IsObjMarked(SdrObject const *pObj) const
const SdrObject * GetObject() const