30#include <svx/strings.hrc>
33#include <svx/svxids.hrc>
34#include <bitmaps.hlst>
36#include <com/sun/star/form/XConfirmDeleteListener.hpp>
37#include <com/sun/star/form/XFormComponent.hpp>
38#include <com/sun/star/form/XGridColumnFactory.hpp>
39#include <com/sun/star/io/XPersistObject.hpp>
40#include <com/sun/star/sdb/CommandType.hpp>
41#include <com/sun/star/sdb/RowChangeAction.hpp>
42#include <com/sun/star/sdb/XQueriesSupplier.hpp>
43#include <com/sun/star/sdbc/DataType.hpp>
44#include <com/sun/star/sdbc/SQLException.hpp>
45#include <com/sun/star/sdbc/XPreparedStatement.hpp>
46#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
47#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
48#include <com/sun/star/sdbcx/XDeleteRows.hpp>
49#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
50#include <com/sun/star/util/XNumberFormats.hpp>
51#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
52#include <com/sun/star/util/URLTransformer.hpp>
53#include <com/sun/star/util/XURLTransformer.hpp>
54#include <com/sun/star/view/XSelectionSupplier.hpp>
85using namespace ::
cppu;
105 :EditBrowserHeader(pParent, nWinBits)
106 ,DropTargetHelper(this)
119 DropTargetHelper::dispose();
131 Reference< XIndexAccess > xColumns =
static_cast<FmGridControl*
>(GetParent())->GetPeer()->getColumns();
132 if ( nPos < xColumns->getCount() )
134 Reference< XSelectionSupplier > xSelSupplier(xColumns, UNO_QUERY);
135 if ( xSelSupplier.is() )
137 Reference< XPropertySet >
xColumn;
146 EditBrowserHeader::Select();
152 sal_uInt16 nItemId = GetItemId( ScreenToOutputPixel( rHEvt.
GetMousePosPixel() ) );
155 if ( rHEvt.
GetMode() & (HelpEventMode::QUICK | HelpEventMode::BALLOON) )
161 aPt = OutputToScreenPixel( aItemRect.
BottomRight() );
166 Reference< css::container::XIndexContainer > xColumns(
static_cast<FmGridControl*
>(GetParent())->GetPeer()->getColumns());
169 Reference< css::beans::XPropertySet >
xColumn(xColumns->getByIndex(
nPos),UNO_QUERY);
172 if ( aHelpText.isEmpty() )
174 if ( !aHelpText.isEmpty() )
176 if ( rHEvt.
GetMode() & HelpEventMode::BALLOON )
189 EditBrowserHeader::RequestHelp( rHEvt );
195 if (!
static_cast<FmGridControl*
>(GetParent())->IsDesignMode())
208 if (!
static_cast<FmGridControl*
>(GetParent())->IsDesignMode())
216 if (!bColumnDescriptor && !bFieldDescriptor)
218 OSL_FAIL(
"FmGridHeader::ExecuteDrop: should never have reached this (no extractable format)!");
223 OUString sDatasource, sCommand, sFieldName,sDatabaseLocation;
224 sal_Int32 nCommandType = CommandType::COMMAND;
225 Reference< XPreparedStatement > xStatement;
226 Reference< XResultSet > xResultSet;
227 Reference< XPropertySet > xField;
228 Reference< XConnection > xConnection;
230 ODataAccessDescriptor aColumn = OColumnTransferable::extractColumnDescriptor(aDroppedData);
231 if (aColumn.has(DataAccessDescriptorProperty::DataSource)) aColumn[DataAccessDescriptorProperty::DataSource] >>= sDatasource;
232 if (aColumn.has(DataAccessDescriptorProperty::DatabaseLocation)) aColumn[DataAccessDescriptorProperty::DatabaseLocation] >>= sDatabaseLocation;
233 if (aColumn.has(DataAccessDescriptorProperty::Command)) aColumn[DataAccessDescriptorProperty::Command] >>= sCommand;
234 if (aColumn.has(DataAccessDescriptorProperty::CommandType)) aColumn[DataAccessDescriptorProperty::CommandType] >>= nCommandType;
235 if (aColumn.has(DataAccessDescriptorProperty::ColumnName)) aColumn[DataAccessDescriptorProperty::ColumnName] >>= sFieldName;
236 if (aColumn.has(DataAccessDescriptorProperty::ColumnObject))aColumn[DataAccessDescriptorProperty::ColumnObject] >>= xField;
237 if (aColumn.has(DataAccessDescriptorProperty::Connection)) aColumn[DataAccessDescriptorProperty::Connection] >>= xConnection;
239 if ( sFieldName.isEmpty()
240 || sCommand.isEmpty()
241 || ( sDatasource.isEmpty()
242 && sDatabaseLocation.isEmpty()
247 OSL_FAIL(
"FmGridHeader::ExecuteDrop: somebody started a nonsense drag operation!!" );
254 if (!xConnection.is())
258 OUString sSignificantSource( sDatasource.isEmpty() ? sDatabaseLocation : sDatasource );
260 static_cast<FmGridControl*
>(GetParent())->getContext(),
nullptr );
262 catch(NoSuchElementException&)
267 OSL_FAIL(
"FmGridHeader::ExecuteDrop: could not retrieve the database access object !");
270 if (!xConnection.is())
272 OSL_FAIL(
"FmGridHeader::ExecuteDrop: could not retrieve the database access object !");
281 Reference< XServiceInfo > xServiceInfo(xConnection, UNO_QUERY);
282 DBG_ASSERT(xServiceInfo.is() && xServiceInfo->supportsService(
SRV_SDB_CONNECTION),
"FmGridHeader::ExecuteDrop: invalid connection (no database access connection !)");
285 Reference< XNameAccess > xFields;
286 switch (nCommandType)
288 case CommandType::TABLE:
290 Reference< XTablesSupplier > xSupplyTables(xConnection, UNO_QUERY);
291 Reference< XColumnsSupplier > xSupplyColumns;
292 xSupplyTables->getTables()->getByName(sCommand) >>= xSupplyColumns;
293 xFields = xSupplyColumns->getColumns();
296 case CommandType::QUERY:
298 Reference< XQueriesSupplier > xSupplyQueries(xConnection, UNO_QUERY);
299 Reference< XColumnsSupplier > xSupplyColumns;
300 xSupplyQueries->getQueries()->getByName(sCommand) >>= xSupplyColumns;
301 xFields = xSupplyColumns->getColumns();
306 xStatement = xConnection->prepareStatement(sCommand);
309 Reference< XPropertySet > xStatProps(xStatement,UNO_QUERY);
310 xStatProps->setPropertyValue(
"MaxRows",
Any(sal_Int32(0)));
312 xResultSet = xStatement->executeQuery();
313 Reference< XColumnsSupplier > xSupplyCols(xResultSet, UNO_QUERY);
314 if (xSupplyCols.is())
315 xFields = xSupplyCols->getColumns();
319 if (xFields.is() && xFields->hasByName(sFieldName))
320 xFields->getByName(sFieldName) >>= xField;
324 ::comphelper::disposeComponent(xStatement);
332 m_pImpl->aDropData[DataAccessDescriptorProperty::Connection] <<= xConnection;
333 m_pImpl->aDropData[DataAccessDescriptorProperty::ColumnObject] <<= xField;
337 m_pImpl->xDroppedStatement = xStatement;
338 m_pImpl->xDroppedResultSet = xResultSet;
345 ::comphelper::disposeComponent(xStatement);
354 OUString sCommand, sFieldName,sURL;
355 sal_Int32 nCommandType = CommandType::COMMAND;
356 Reference< XPropertySet > xField;
357 Reference< XConnection > xConnection;
359 OUString sDatasource =
m_pImpl->aDropData.getDataSource();
360 if ( sDatasource.isEmpty() &&
m_pImpl->aDropData.has(DataAccessDescriptorProperty::ConnectionResource) )
361 m_pImpl->aDropData[DataAccessDescriptorProperty::ConnectionResource] >>= sURL;
362 m_pImpl->aDropData[DataAccessDescriptorProperty::Command] >>= sCommand;
363 m_pImpl->aDropData[DataAccessDescriptorProperty::CommandType] >>= nCommandType;
364 m_pImpl->aDropData[DataAccessDescriptorProperty::ColumnName] >>= sFieldName;
365 m_pImpl->aDropData[DataAccessDescriptorProperty::Connection] >>= xConnection;
366 m_pImpl->aDropData[DataAccessDescriptorProperty::ColumnObject] >>= xField;
371 Reference< XNumberFormatsSupplier > xSupplier =
getNumberFormats(xConnection,
true);
372 Reference< XNumberFormats > xNumberFormats;
374 xNumberFormats = xSupplier->getNumberFormats();
375 if (!xNumberFormats.is())
377 ::comphelper::disposeComponent(
m_pImpl->xDroppedResultSet);
378 ::comphelper::disposeComponent(
m_pImpl->xDroppedStatement);
391 case DataType::LONGVARBINARY:
392 case DataType::BINARY:
393 case DataType::VARBINARY:
394 case DataType::OTHER:
395 ::comphelper::disposeComponent(
m_pImpl->xDroppedResultSet);
396 ::comphelper::disposeComponent(
m_pImpl->xDroppedStatement);
401 Reference< XIndexContainer > xCols(
static_cast<FmGridControl*
>(GetParent())->GetPeer()->getColumns());
402 Reference< XGridColumnFactory >
xFactory(xCols, UNO_QUERY);
404 sal_uInt16 nColId = GetItemId(
m_pImpl->aDropPosPixel);
406 sal_uInt16
nPos = GetModelColumnPos(nColId);
407 Reference< XPropertySet > xCol, xSecondCol;
410 std::vector<OUString> aPossibleTypes;
411 std::vector<OUString> aImgResId;
412 std::vector<TranslateId> aStrResId;
417 case DataType::BOOLEAN:
419 aImgResId.emplace_back(RID_SVXBMP_CHECKBOX);
420 aStrResId.emplace_back(RID_STR_PROPTITLE_CHECKBOX);
422 case DataType::TINYINT:
423 case DataType::SMALLINT:
424 case DataType::INTEGER:
426 aImgResId.emplace_back(RID_SVXBMP_NUMERICFIELD);
427 aStrResId.emplace_back(RID_STR_PROPTITLE_NUMERICFIELD);
429 aImgResId.emplace_back(RID_SVXBMP_FORMATTEDFIELD);
430 aStrResId.emplace_back(RID_STR_PROPTITLE_FORMATTED);
433 case DataType::DOUBLE:
434 case DataType::NUMERIC:
435 case DataType::DECIMAL:
437 aImgResId.emplace_back(RID_SVXBMP_FORMATTEDFIELD);
438 aStrResId.emplace_back(RID_STR_PROPTITLE_FORMATTED);
440 aImgResId.emplace_back(RID_SVXBMP_NUMERICFIELD);
441 aStrResId.emplace_back(RID_STR_PROPTITLE_NUMERICFIELD);
443 case DataType::TIMESTAMP:
444 aPossibleTypes.emplace_back(
"dateandtimefield");
445 aImgResId.emplace_back(RID_SVXBMP_DATE_N_TIME_FIELDS);
446 aStrResId.emplace_back(RID_STR_DATE_AND_TIME);
448 aImgResId.emplace_back(RID_SVXBMP_DATEFIELD);
449 aStrResId.emplace_back(RID_STR_PROPTITLE_DATEFIELD);
451 aImgResId.emplace_back(RID_SVXBMP_TIMEFIELD);
452 aStrResId.emplace_back(RID_STR_PROPTITLE_TIMEFIELD);
454 aImgResId.emplace_back(RID_SVXBMP_FORMATTEDFIELD);
455 aStrResId.emplace_back(RID_STR_PROPTITLE_FORMATTED);
459 aImgResId.emplace_back(RID_SVXBMP_DATEFIELD);
460 aStrResId.emplace_back(RID_STR_PROPTITLE_DATEFIELD);
462 aImgResId.emplace_back(RID_SVXBMP_FORMATTEDFIELD);
463 aStrResId.emplace_back(RID_STR_PROPTITLE_FORMATTED);
467 aImgResId.emplace_back(RID_SVXBMP_TIMEFIELD);
468 aStrResId.emplace_back(RID_STR_PROPTITLE_TIMEFIELD);
470 aImgResId.emplace_back(RID_SVXBMP_FORMATTEDFIELD);
471 aStrResId.emplace_back(RID_STR_PROPTITLE_FORMATTED);
474 case DataType::VARCHAR:
475 case DataType::LONGVARCHAR:
478 aImgResId.emplace_back(RID_SVXBMP_EDITBOX);
479 aStrResId.emplace_back(RID_STR_PROPTITLE_EDIT);
481 aImgResId.emplace_back(RID_SVXBMP_FORMATTEDFIELD);
482 aStrResId.emplace_back(RID_STR_PROPTITLE_FORMATTED);
492 aImgResId.insert(aImgResId.begin(), RID_SVXBMP_CURRENCYFIELD);
493 aStrResId.insert(aStrResId.begin(), RID_STR_PROPTITLE_CURRENCYFIELD);
501 assert(aPossibleTypes.size() == aImgResId.size());
503 bool bDateNTimeCol =
false;
504 if (!aPossibleTypes.empty())
506 OUString sPreferredType = aPossibleTypes[0];
510 std::unique_ptr<weld::Menu> xTypeMenu(xBuilder->weld_menu(
"insertmenu"));
513 std::vector<OUString>::const_iterator iter;
514 std::vector<TranslateId>::const_iterator striter;
515 std::vector<OUString>::const_iterator imgiter;
516 for (iter = aPossibleTypes.begin(), imgiter = aImgResId.begin(), striter = aStrResId.begin();
517 iter != aPossibleTypes.end(); ++iter, ++striter, ++imgiter)
524 OUString sResult = xTypeMenu->popup_at_rect(pParent, aRect);
525 if (!sResult.isEmpty())
526 sPreferredType = sResult;
529 bDateNTimeCol = sPreferredType ==
"dateandtimefield";
530 sal_uInt16 nColCount = bDateNTimeCol ? 2 : 1;
531 OUString sFieldService;
537 sFieldService = sPreferredType;
538 Reference< XPropertySet > xThisRoundCol;
539 if ( !sFieldService.isEmpty() )
540 xThisRoundCol =
xFactory->createColumn(sFieldService);
542 xSecondCol = xThisRoundCol;
544 xCol = xThisRoundCol;
548 if (!xCol.is() || (bDateNTimeCol && !xSecondCol.is()))
550 ::comphelper::disposeComponent(xCol);
551 ::comphelper::disposeComponent(
m_pImpl->xDroppedResultSet);
552 ::comphelper::disposeComponent(
m_pImpl->xDroppedStatement);
558 OUString sTimePostfix(
SvxResId(RID_STR_POSTFIX_TIME));
559 xCol->setPropertyValue(
FM_PROP_LABEL,
Any( OUString( sFieldName + sTimePostfix ) ) );
561 OUString sDatePostfix(
SvxResId( RID_STR_POSTFIX_DATE));
562 xSecondCol->setPropertyValue(
FM_PROP_LABEL,
Any( OUString( sFieldName + sDatePostfix ) ) );
571 xCols->insertByIndex(
nPos, aElement);
573 FormControlFactory aControlFactory;
574 aControlFactory.initializeControlModel( DocumentClassification::classifyHostDocument( xCols ), xCol );
575 FormControlFactory::initializeFieldDependentProperties( xField, xCol, xNumberFormats );
578 if ( xSecondCol.is() )
583 OUString aPostfix[] = {
588 for (
size_t i=0;
i<2; ++
i )
593 OUString sRealName = sFieldName +
"_" + sPurePostfix;
605 aElement <<= xSecondCol;
606 xCols->insertByIndex(
nPos == sal_uInt16(-1) ?
nPos : ++
nPos, aElement);
610 Reference< XFormComponent > xFormCp(xCols, UNO_QUERY);
611 Reference< XPropertySet > xForm(xFormCp->getParent(), UNO_QUERY);
616 if ( !sDatasource.isEmpty() )
622 if (::comphelper::getString(xForm->getPropertyValue(
FM_PROP_COMMAND)).isEmpty())
626 switch (nCommandType)
628 case CommandType::TABLE:
629 aCommandType <<= sal_Int32(CommandType::TABLE);
631 case CommandType::QUERY:
632 aCommandType <<= sal_Int32(CommandType::QUERY);
635 aCommandType <<= sal_Int32(CommandType::COMMAND);
646 ::comphelper::disposeComponent(
m_pImpl->xDroppedResultSet);
647 ::comphelper::disposeComponent(
m_pImpl->xDroppedStatement);
651 ::comphelper::disposeComponent(
m_pImpl->xDroppedResultSet);
652 ::comphelper::disposeComponent(
m_pImpl->xDroppedStatement);
659 bool bDesignMode =
static_cast<FmGridControl*
>(GetParent())->IsDesignMode();
661 Reference< css::container::XIndexContainer > xCols(
static_cast<FmGridControl*
>(GetParent())->GetPeer()->getColumns());
668 Reference< css::container::XIndexContainer > xColumns(
static_cast<FmGridControl*
>(GetParent())->GetPeer()->getColumns());
669 Reference< css::beans::XPropertySet>
xColumn( xColumns->getByIndex(nPos2), css::uno::UNO_QUERY);
670 Reference< css::view::XSelectionSupplier > xSelSupplier(xColumns, UNO_QUERY);
671 if (xSelSupplier.is())
677 bool bMarked = nColId &&
static_cast<FmGridControl*
>(GetParent())->isColumnMarked(nColId);
694 if (xCols.is() && nColId)
696 Reference< css::beans::XPropertySet > xPropSet( xCols->getByIndex(
nPos), css::uno::UNO_QUERY);
698 Reference< css::io::XPersistObject > xServiceQuestion(xPropSet, UNO_QUERY);
706 Reference< css::beans::XPropertySetInfo > xPropsInfo = xPropSet->getPropertySetInfo();
738 rMenu.
set_visible(
"change", bDesignMode && bMarked && xCols.is());
739 rMenu.
set_sensitive(
"change", bDesignMode && bMarked && xCols.is());
747 rMenu.
set_visible(
"insert", bDesignMode && xCols.is());
749 rMenu.
set_visible(
"delete", bDesignMode && bMarked && xCols.is());
750 rMenu.
set_sensitive(
"delete", bDesignMode && bMarked && xCols.is());
751 rMenu.
set_visible(
"column", bDesignMode && bMarked && xCols.is());
752 rMenu.
set_sensitive(
"column", bDesignMode && bMarked && xCols.is());
754 sal_uInt16 nHiddenCols = 0;
758 Reference< css::beans::XPropertySet > xCurCol;
760 for (sal_Int32
i=0;
i<xCols->getCount(); ++
i)
762 xCurCol.set(xCols->getByIndex(
i), css::uno::UNO_QUERY);
763 DBG_ASSERT(xCurCol.is(),
"FmGridHeader::PreExecuteColumnContextMenu : the Peer has invalid columns !");
765 DBG_ASSERT(aHidden.getValueType().getTypeClass() == TypeClass_BOOLEAN,
766 "FmGridHeader::PreExecuteColumnContextMenu : the property 'hidden' should be boolean !");
767 if (::comphelper::getBOOL(aHidden))
770 if (nHiddenCols < 16)
775 rMenu.
insert(nHiddenCols, OUString::number(nHiddenCols + 1), ::comphelper::getString(
aName),
782 rShowMenu.
set_visible(
"more", xCols.is() && (nHiddenCols > 16));
783 rMenu.
set_visible(
"show", xCols.is() && (nHiddenCols > 0));
784 rMenu.
set_sensitive(
"show", xCols.is() && (nHiddenCols > 0));
787 bool bAllowHide = bMarked;
788 bAllowHide = bAllowHide || (!bDesignMode && (
nPos != sal_uInt16(-1)));
789 bAllowHide = bAllowHide && xCols.is();
790 bAllowHide = bAllowHide && (xCols->getCount()-nHiddenCols > 1);
801 std::unique_ptr<SfxBoolItem> pItem;
804 if (eState >= SfxItemState::DEFAULT && pItem !=
nullptr)
806 bool bChecked = pItem && pItem->GetValue();
814enum InspectorAction { eOpenInspector, eCloseInspector, eUpdateInspector, eNone };
820 Reference< css::container::XIndexContainer > xCols(
static_cast<FmGridControl*
>(GetParent())->GetPeer()->getColumns());
824 bool bReplace =
false;
825 InspectorAction eInspectorAction = eNone;
827 if (rExecutionResult ==
"delete")
829 Reference< XInterface > xCol(
830 xCols->getByIndex(
nPos), css::uno::UNO_QUERY);
831 xCols->removeByIndex(
nPos);
832 ::comphelper::disposeComponent(xCol);
834 else if (rExecutionResult ==
"hide")
836 Reference< css::beans::XPropertySet > xCurCol( xCols->getByIndex(
nPos), css::uno::UNO_QUERY);
839 else if (rExecutionResult ==
"column")
841 eInspectorAction = rMenu.
get_active(
"column") ? eOpenInspector : eCloseInspector;
903 else if (rExecutionResult ==
"more")
907 pDlg->SetColumns(xCols);
910 else if (rExecutionResult ==
"all")
913 Reference< css::beans::XPropertySet > xCurCol;
914 for (sal_Int32
i=0;
i<xCols->getCount(); ++
i)
916 xCurCol.
set(xCols->getByIndex(
i), css::uno::UNO_QUERY);
922 else if (!rExecutionResult.isEmpty())
924 sal_Int32 nExecutionResult = rExecutionResult.toInt32();
925 if (nExecutionResult>0 && nExecutionResult<=16)
929 Reference< css::beans::XPropertySet > xCurCol;
930 for (sal_Int32
i=0;
i<xCols->getCount() && nExecutionResult; ++
i)
932 xCurCol.set(xCols->getByIndex(
i), css::uno::UNO_QUERY);
934 if (::comphelper::getBOOL(aHidden))
935 if (!--nExecutionResult)
944 if ( !aFieldType.isEmpty() )
948 Reference< XGridColumnFactory >
xFactory( xCols, UNO_QUERY_THROW );
949 Reference< XPropertySet > xNewCol(
xFactory->createColumn( aFieldType ), UNO_SET_THROW );
954 Reference< XPropertySet > xReplaced( xCols->getByIndex(
nPos ), UNO_QUERY );
959 xCols->replaceByIndex(
nPos,
Any( xNewCol ) );
960 ::comphelper::disposeComponent( xReplaced );
962 eInspectorAction = eUpdateInspector;
966 FormControlFactory factory;
968 OUString sLabel = FormControlFactory::getDefaultUniqueName_ByComponentType(
969 Reference< XNameAccess >( xCols, UNO_QUERY_THROW ), xNewCol );
973 factory.initializeControlModel( DocumentClassification::classifyHostDocument( xCols ), xNewCol );
975 xCols->insertByIndex(
nPos,
Any( xNewCol ) );
985 OSL_ENSURE( pCurrentFrame,
"FmGridHeader::PostExecuteColumnContextMenu: no view frame -> no bindings -> no property browser!" );
986 if ( !pCurrentFrame )
989 if ( eInspectorAction == eUpdateInspector )
992 eInspectorAction = eNone;
995 if ( eInspectorAction != eNone )
997 SfxBoolItem aShowItem( SID_FM_SHOW_PROPERTIES, eInspectorAction != eCloseInspector );
1000 SID_FM_SHOW_PROPERTY_BROWSER, SfxCallMode::ASYNCHRON,
1008 sal_uInt16 nColId = GetItemId( _rPreferredPos );
1012 std::unique_ptr<weld::Menu> xContextMenu(xBuilder->weld_menu(
"menu"));
1013 std::unique_ptr<weld::Menu> xInsertMenu(xBuilder->weld_menu(
"insertmenu"));
1014 std::unique_ptr<weld::Menu> xChangeMenu(xBuilder->weld_menu(
"changemenu"));
1015 std::unique_ptr<weld::Menu> xShowMenu(xBuilder->weld_menu(
"showmenu"));
1023 bEmpty = !xContextMenu->get_sensitive(xContextMenu->get_id(
i));
1033 OUString sResult = xContextMenu->popup_at_rect(pParent, aRect);
1043 case CommandEventId::ContextMenu:
1052 EditBrowserHeader::Command(rEvt);
1057 const Reference< css::uno::XComponentContext >& _rxContext,
1063 ,m_nCurrentSelectedColumn(-1)
1065 ,m_bSelecting(false)
1066 ,m_bInColumnMove(false)
1073 if ( CommandEventId::ContextMenu == _rEvt.
GetCommand() )
1084 Point aRelativePos( pMyHeader->ScreenToOutputPixel( OutputToScreenPixel( aColRect.
TopCenter() ) ) );
1108 Reference<XPropertySet> xSet(evt.Source,UNO_QUERY);
1116 if (eStatus != xRow->GetStatus())
1118 xRow->SetStatus(eStatus);
1129 if (bOldMode == bMode)
1139 Reference< css::container::XIndexContainer > xColumns(
GetPeer()->getColumns());
1140 Reference< css::view::XSelectionSupplier > xSelSupplier(xColumns, UNO_QUERY);
1141 if (xSelSupplier.is())
1143 Any aSelection = xSelSupplier->getSelection();
1144 Reference< css::beans::XPropertySet >
xColumn;
1145 if (aSelection.getValueType().getTypeClass() == TypeClass_INTERFACE)
1146 xColumn.set(aSelection, css::uno::UNO_QUERY);
1147 Reference< XInterface > xCurrent;
1148 for (sal_Int32
i=0;
i<xColumns->getCount(); ++
i)
1150 xCurrent.set(xColumns->getByIndex(
i), css::uno::UNO_QUERY);
1177 if (nSelectedRows <= 0)
1181 Reference< css::frame::XDispatchProvider > xDispatcher =
static_cast<css::frame::XDispatchProvider*
>(
GetPeer());
1182 if (xDispatcher.is())
1184 css::util::URL aUrl;
1186 Reference< css::util::XURLTransformer > xTransformer(
1187 css::util::URLTransformer::create(::comphelper::getProcessComponentContext()) );
1188 xTransformer->parseStrict( aUrl );
1190 Reference< css::frame::XDispatch >
xDispatch = xDispatcher->queryDispatch(aUrl, OUString(), 0);
1191 Reference< css::form::XConfirmDeleteListener > xConfirm(
xDispatch, UNO_QUERY);
1194 css::sdb::RowChangeEvent
aEvent;
1196 aEvent.Rows = nSelectedRows;
1197 aEvent.Action = css::sdb::RowChangeAction::DELETE;
1198 if (!xConfirm->confirmDelete(
aEvent))
1208 Reference< XResultSetUpdate > xUpdateCursor(Reference< XInterface >(*pCursor), UNO_QUERY);
1212 while( pCursor->
next() )
1213 xUpdateCursor->deleteRow();
1218 xUpdateCursor->moveToInsertRow();
1231 Reference< css::sdbcx::XDeleteRows > xDeleteThem(Reference< XInterface >(*
getDataSource()), UNO_QUERY);
1238 bool bNewPos =
false;
1240 OSL_ENSURE(
GetCurrentRow().is(),
"FmGridControl::DeleteSelectedRows: no current row here?" );
1286 Sequence<sal_Int32> aDeletedRows;
1290 aDeletedRows = xDeleteThem->deleteRows(aBookmarks);
1292 catch(SQLException&)
1298 sal_Int32 nDeletedRows =
static_cast<sal_Int32
>(std::count_if(std::cbegin(aDeletedRows), std::cend(aDeletedRows),
1299 [](
const sal_Int32 nRow) {
return nRow != 0; }));
1309 if (nDeletedRows == aDeletedRows.getLength())
1314 if (aBookmark.hasValue())
1319 Reference< XResultSetUpdate > xUpdateCursor(Reference< XInterface >(*
m_pDataCursor), UNO_QUERY);
1320 xUpdateCursor->moveToInsertRow();
1325 Reference< css::beans::XPropertySet > xSet(Reference< XInterface >(*
m_pDataCursor), UNO_QUERY);
1327 sal_Int32 nRecordCount(0);
1335 Reference< XResultSetUpdate > xUpdateCursor(Reference< XInterface >(*
m_pDataCursor), UNO_QUERY);
1336 xUpdateCursor->moveToInsertRow();
1338 else if (nRecordCount)
1346 auto pRow = std::find(std::cbegin(aDeletedRows), std::cend(aDeletedRows), 0);
1347 if (pRow != std::cend(aDeletedRows))
1349 auto i =
static_cast<sal_Int32
>(std::distance(std::cbegin(aDeletedRows), pRow));
1371 if (nDeletedRows < nSelectedRows)
1383 for (
const sal_Int32 nSuccess : std::as_const(aDeletedRows))
1429 SAL_INFO(
"svx.fmcomp",
"FmGridControl::positioned");
1457 xRow->SetNew(
false);
1463 DBG_ASSERT( pParent ==
this,
"FmGridControl::imp_CreateHeaderBar: parent?" );
1496 tools::Long nMinimalPixelHeight = LogicToPixel(
Point(0, nMinimalLogicHeight),
MapMode(MapUnit::Map10thMM)).Y();
1497 return CalcZoom( nMinimalPixelHeight );
1504 Reference< XPropertySet >
xModel(
GetPeer()->getColumns(), UNO_QUERY );
1512 Any aProperty(
static_cast<sal_Int32
>(PixelToLogic(
Point(0, nUnzoomedPixelHeight),
MapMode(MapUnit::Map10thMM)).
Y()) );
1527 const Reference< css::beans::XPropertySet >& xColModel(pCol->
getModel());
1534 aWidth <<= static_cast<sal_Int32>(PixelToLogic(
Point(nColumnWidth, 0),
MapMode(MapUnit::Map10thMM)).
X());
1562 Reference< css::container::XIndexContainer > xColumns(
GetPeer()->getColumns());
1569 Reference< css::beans::XPropertySet > xCol;
1573 Reference< XInterface > xCurrent;
1574 for (
i = 0; !xCol.is() && i < xColumns->getCount();
i++)
1576 xCurrent.set(xColumns->getByIndex(
i), css::uno::UNO_QUERY);
1584 DBG_ASSERT(i < xColumns->getCount(),
"Wrong css::sdbcx::Index");
1585 xColumns->removeByIndex(
i);
1616 for (
i = 0;
i < xColumns->getCount(); ++
i)
1618 Reference< css::beans::XPropertySet > xCol(
1619 xColumns->getByIndex(
i), css::uno::UNO_QUERY);
1625 sal_Int32 nWidth = 0;
1626 if (aWidth >>= nWidth)
1627 nWidth = LogicToPixel(
Point(nWidth, 0),
MapMode(MapUnit::Map10thMM)).X();
1639 for (
i = 0;
i < xColumns->getCount(); ++
i)
1641 Reference< css::beans::XPropertySet > xCol( xColumns->getByIndex(
i), css::uno::UNO_QUERY);
1643 if (::comphelper::getBOOL(aHidden))
1651 DbGridColumn* _pColumn,
const Reference< XPropertySet >& _rxColumnModel,
1652 const Reference< XNameAccess >& _rxFieldsByNames,
const Reference< XIndexAccess >& _rxFieldsByIndex )
1654 DBG_ASSERT( _rxFieldsByNames == _rxFieldsByIndex,
"FmGridControl::InitColumnByField: invalid container interfaces!" );
1657 OUString sFieldName;
1659 Reference< XPropertySet > xField;
1663 if ( !xField.is() && _rxFieldsByNames->hasByName( sFieldName ) )
1664 _rxFieldsByNames->getByName( sFieldName ) >>= xField;
1667 sal_Int32 nFieldPos = -1;
1670 Reference< XPropertySet > xCheck;
1671 sal_Int32 nFieldCount = _rxFieldsByIndex->getCount();
1672 for ( sal_Int32
i = 0;
i < nFieldCount; ++
i)
1674 _rxFieldsByIndex->getByIndex(
i ) >>= xCheck;
1675 if ( xField.get() == xCheck.get() )
1683 if ( xField.is() && ( nFieldPos >= 0 ) )
1689 bool bIllegalType =
false;
1692 case DataType::BLOB:
1693 case DataType::LONGVARBINARY:
1694 case DataType::BINARY:
1695 case DataType::VARBINARY:
1696 case DataType::OTHER:
1697 bIllegalType =
true;
1703 _pColumn->
SetObject(
static_cast<sal_Int16
>(nFieldPos) );
1709 static constexpr OUStringLiteral s_sPropColumnServiceName =
u"ColumnServiceName";
1710 if ( !::comphelper::hasProperty( s_sPropColumnServiceName, _rxColumnModel ) )
1713 _pColumn->
setModel( _rxColumnModel );
1715 OUString sColumnServiceName;
1716 _rxColumnModel->getPropertyValue( s_sPropColumnServiceName ) >>= sColumnServiceName;
1724 if ( !_rxFields.is() )
1728 Reference< XIndexContainer > xColumns(
GetPeer()->getColumns() );
1729 Reference< XNameAccess > xFieldsAsNames( _rxFields, UNO_QUERY );
1732 for (sal_Int32
i = 0;
i < xColumns->getCount();
i++)
1735 OSL_ENSURE(pCol,
"No grid column!");
1738 Reference< XPropertySet > xColumnModel(
1739 xColumns->getByIndex(
i ), css::uno::UNO_QUERY);
1751 if (
nPos == sal_uInt16(-1))
1764 OSL_ENSURE(_pColumn,
"Column can not be null!");
1765 bool bSelected =
false;
1767 Reference< css::view::XSelectionSupplier > xSelSupplier(
GetPeer()->getColumns(), UNO_QUERY);
1768 if ( xSelSupplier.is() )
1770 Reference< css::beans::XPropertySet >
xColumn;
1771 xSelSupplier->getSelection() >>=
xColumn;
1782 if (
nPos == sal_uInt16(-1))
1801 OSL_FAIL(
"FmGridControl::selectBookmarks: no seek cursor!" );
1807 bool bAllSuccessful =
true;
1810 for (
const Any& rBookmark : _rBookmarks)
1816 bAllSuccessful =
false;
1821 OSL_FAIL(
"FmGridControl::selectBookmarks: could not move to one of the bookmarks!");
1825 return bAllSuccessful;
1834 Sequence< Any> aBookmarks(nSelectedRows);
1835 if ( nSelectedRows )
1837 Any* pBookmarks = aBookmarks.getArray();
1858 pBookmarks[
i++] <<=
static_cast<sal_Int32
>(nIdx);
1861 DBG_ASSERT(
i == nSelectedRows,
"FmGridControl::DeleteSelectedRows : could not collect the row indices !");
1863 for (
i=0;
i<nSelectedRows; ++
i)
1865 nIdx = ::comphelper::getINT32(pBookmarks[
i]);
1869 aBookmarks.realloc(--nSelectedRows);
1883 OSL_FAIL(
"FmGridControl::DeleteSelectedRows : a bookmark could not be determined !");
1890 aBookmarks.realloc(
i);
1900 OUString getColumnPropertyFromPeer(
FmXGridPeer* _pPeer,sal_Int32 _nPosition,
const OUString& _sPropName)
1903 if ( _pPeer && _nPosition != -1)
1905 Reference<XIndexContainer> xIndex = _pPeer->
getColumns();
1906 if ( xIndex.is() && xIndex->getCount() > _nPosition )
1908 Reference<XPropertySet> xProp;
1909 xIndex->getByIndex( _nPosition ) >>= xProp;
1913 xProp->getPropertyValue( _sPropName ) >>= sRetText;
1914 }
catch (UnknownPropertyException
const&) {
1930 case AccessibleBrowseBoxObjType::BrowseBox:
1933 Reference<XPropertySet> xProp(
GetPeer()->getColumns(),UNO_QUERY);
1938 case AccessibleBrowseBoxObjType::ColumnHeaderCell:
1939 sRetText = getColumnPropertyFromPeer(
1942 sal::static_int_cast< sal_uInt16 >(_nPosition)),
1956 case AccessibleBrowseBoxObjType::BrowseBox:
1959 Reference<XPropertySet> xProp(
GetPeer()->getColumns(),UNO_QUERY);
1963 if ( sRetText.isEmpty() )
1968 case AccessibleBrowseBoxObjType::ColumnHeaderCell:
1969 sRetText = getColumnPropertyFromPeer(
1972 sal::static_int_cast< sal_uInt16 >(_nPosition)),
1974 if ( sRetText.isEmpty() )
1975 sRetText = getColumnPropertyFromPeer(
1978 sal::static_int_cast< sal_uInt16 >(_nPosition)),
1994 sal_uInt16 nSelectedColumn =
1996 ? sal::static_int_cast< sal_uInt16 >(
2000 switch (nSelectedColumn)
2025 Reference< XSelectionSupplier > xSelSupplier(xColumns, UNO_QUERY);
2026 if (xSelSupplier.is())
2030 Reference< XPropertySet >
xColumn(
2031 xColumns->getByIndex(nSelectedColumn),
2032 css::uno::UNO_QUERY);
2037 xSelSupplier->select(
Any());
2063 GetParent()->GrabFocus();
2069 Reference< css::container::XIndexContainer > xCols(
GetPeer()->getColumns());
2074 if ( m_nCurrentSelectedColumn < xCols->getCount() )
2076 Reference< XInterface > xCol;
2079 ::comphelper::disposeComponent(xCol);
AccessibleBrowseBoxObjType
constexpr sal_Int32 BROWSER_ENDOFSELECTION
#define BROWSER_INVALIDID
static const AllSettings & GetSettings()
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
tools::Long GetDataRowHeight() const
sal_uInt16 GetColumnId(sal_uInt16 nPos) const
void SetUpdateMode(bool bUpdate)
const MultiSelection * GetColumnSelection() const
sal_Int32 FirstSelectedColumn() const
sal_uInt16 GetSelectColumnCount() const
sal_Int32 LastSelectedRow()
virtual OUString GetAccessibleObjectName(AccessibleBrowseBoxObjType eObjType, sal_Int32 _nPosition=-1) const override
const MultiSelection * GetSelection() const
tools::Long CalcReverseZoom(tools::Long nVal) const
sal_Int32 GetSelectRowCount() const
virtual void SelectAll() override
virtual OUString GetAccessibleObjectDescription(AccessibleBrowseBoxObjType eObjType, sal_Int32 _nPosition=-1) const override
tools::Rectangle GetFieldRectPixel(sal_Int32 nRow, sal_uInt16 nColId, bool bRelToBrowser=true) const
sal_Int32 FirstSelectedRow()
virtual sal_Int32 GetRowCount() const override
void EnableInteractiveRowHeight()
virtual void SetNoSelection() override
virtual void SelectRow(sal_Int32 nRow, bool _bSelect=true, bool bExpand=true) override
sal_uLong GetColumnWidth(sal_uInt16 nColumnId) const
sal_Int32 NextSelectedRow()
virtual bool IsRowSelected(sal_Int32 nRow) const override
CommandEventId GetCommand() const
const Point & GetMousePosPixel() const
bool IsMouseEvent() const
bool moveToBookmark(const css::uno::Any &bookmark)
void SetObject(sal_Int16 nPos)
void setModel(const css::uno::Reference< css::beans::XPropertySet > &_xModel)
void CreateControl(sal_Int32 _nFieldPos, const css::uno::Reference< css::beans::XPropertySet > &xField, sal_Int32 nTypeId)
const css::uno::Reference< css::beans::XPropertySet > & getModel() const
CursorWrapper * getDataSource() const
virtual void SetDesignMode(bool bMode)
void SetSeekPos(sal_Int32 nPos, GrantControlAccess)
bool IsDesignMode() const
sal_uInt16 GetColumnIdFromModelPos(sal_uInt16 nPos) const
virtual void ShowColumn(sal_uInt16 nId)
show a column
void AdjustDataSource(bool bFull=false)
const std::vector< std::unique_ptr< DbGridColumn > > & GetColumns() const
bool IsInsertionRow(sal_Int32 nRow) const
sal_uInt16 GetColumnIdFromViewPos(sal_uInt16 nPos) const
virtual void ColumnMoved(sal_uInt16 nId) override
const DbGridRowRef & GetSeekRow() const
virtual void HideColumn(sal_uInt16 nId)
hide a column
void implAdjustInSolarThread(bool _bRows)
const DbGridRowRef & GetCurrentRow() const
std::unique_ptr< CursorWrapper > m_pSeekCursor
sal_Int32 GetSeekPos() const
sal_uInt16 GetModelColumnPos(sal_uInt16 nId) const
sal_uInt16 GetModelColCount() const
virtual void CellModified() override
bool SeekCursor(sal_Int32 nRow, bool bAbsolute=false)
sal_Int32 GetTotalCount() const
bool IsCurrentAppending() const
virtual sal_uInt16 AppendColumn(const OUString &rName, sal_uInt16 nWidth, sal_uInt16 nPos=HEADERBAR_APPEND, sal_uInt16 nId=sal_uInt16(-1)) override
virtual bool SaveModified() override
virtual void KeyInput(const KeyEvent &rEvt) override
void RowModified(sal_Int32 nRow)
std::unique_ptr< CursorWrapper > m_pDataCursor
virtual void Command(const CommandEvent &rEvt) override
const DbGridRowRef & GetEmptyRow() const
virtual void EndCursorAction()
sal_Int32 GetCurrentPos() const
virtual void Select() override
virtual void BeginCursorAction()
void InsertHandleColumn()
virtual void SetDesignMode(bool bMode) override
FmGridControl(const css::uno::Reference< css::uno::XComponentContext > &, vcl::Window *pParent, FmXGridPeer *_pPeer, WinBits nBits)
virtual OUString GetAccessibleObjectName(AccessibleBrowseBoxObjType eObjType, sal_Int32 _nPosition=-1) const override
return the name of the specified object.
virtual void ShowColumn(sal_uInt16 nId) override
show a column
virtual void Select() override
bool isColumnSelected(DbGridColumn const *_pColumn) const
returns if a column is selected
void markColumn(sal_uInt16 nId)
virtual void EndCursorAction() override
bool isColumnMarked(sal_uInt16 nId) const
css::uno::Sequence< css::uno::Any > getSelectionBookmarks()
bool selectBookmarks(const css::uno::Sequence< css::uno::Any > &_rBookmarks)
virtual VclPtr< BrowserHeader > imp_CreateHeaderBar(BrowseBox *pParent) override
void InitColumnsByModels(const css::uno::Reference< css::container::XIndexContainer > &xColumns)
void propertyChange(const css::beans::PropertyChangeEvent &evt)
sal_Int32 m_nCurrentSelectedColumn
virtual void BeginCursorAction() override
virtual void HideColumn(sal_uInt16 nId) override
hide a column
virtual void RowHeightChanged() override
virtual void CellModified() override
virtual OUString GetAccessibleObjectDescription(AccessibleBrowseBoxObjType eObjType, sal_Int32 _nPosition=-1) const override
return the description of the specified object.
virtual tools::Long QueryMinimumRowHeight() override
virtual void ColumnMoved(sal_uInt16 nId) override
virtual void KeyInput(const KeyEvent &rKEvt) override
virtual void InitColumnsByFields(const css::uno::Reference< css::container::XIndexAccess > &xFields) override
FmXGridPeer * GetPeer() const
sal_uInt16 m_nMarkedColumnId
virtual void DeleteSelectedRows() override
static void InitColumnByField(DbGridColumn *_pColumn, const css::uno::Reference< css::beans::XPropertySet > &_rxColumnModel, const css::uno::Reference< css::container::XNameAccess > &_rxFieldsByNames, const css::uno::Reference< css::container::XIndexAccess > &_rxFieldsByIndex)
virtual void Command(const CommandEvent &rEvt) override
virtual void ColumnResized(sal_uInt16 nId) override
virtual css::uno::Reference< css::container::XIndexContainer > SAL_CALL getColumns() override
void columnHidden(DbGridColumn const *pColumn)
void startCursorListening()
void stopCursorListening()
void columnVisible(DbGridColumn const *pColumn)
HelpEventMode GetMode() const
const Point & GetMousePosPixel() const
static void ShowQuickHelp(vcl::Window *pParent, const tools::Rectangle &rScreenRect, const OUString &rHelpText, QuickHelpFlags nStyle=QuickHelpFlags::NONE)
static void ShowBalloon(vcl::Window *pParent, const Point &rScreenPos, const tools::Rectangle &, const OUString &rHelpText)
const vcl::KeyCode & GetKeyCode() const
sal_Int32 GetSelectCount() const
bool IsAllSelected() const
constexpr tools::Long Y() const
constexpr tools::Long X() const
SfxItemState QueryState(sal_uInt16 nSID, std::unique_ptr< SfxPoolItem > &rpState)
SfxDispatcher * GetDispatcher() const
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
SfxBindings & GetBindings()
bool HasChildWindow(sal_uInt16)
virtual VclPtr< AbstractFmShowColsDialog > CreateFmShowColsDialog(weld::Window *pParent)=0
static SvxAbstractDialogFactory * Create()
const DataFlavorExVector & GetDataFlavorExVector() const
void set(reference_type *pBody)
static VclPtr< reference_type > Create(Arg &&... arg)
virtual void ColumnResized(sal_uInt16 nColId) override
BrowserHeader * GetHeaderBar() const
const CellControllerRef & Controller() const
virtual void RowHeightChanged() override
sal_uInt16 GetCode() const
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
OUString SvxResId(TranslateId aId)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Reference< XDispatch > xDispatch
::std::vector< DataFlavorEx > DataFlavorExVector
Reference< XSingleServiceFactory > xFactory
static void InsertMenuItem(weld::Menu &rMenu, int nMenuPos, const OUString &id, const OUString &rText, const OUString &rImgId)
IMPL_LINK_NOARG(FmGridHeader, OnAsyncExecuteDrop, void *, void)
constexpr OUStringLiteral FM_PROP_ROWCOUNT
constexpr OUStringLiteral FM_PROP_FORMATSSUPPLIER
constexpr OUStringLiteral FM_PROP_COMMAND
constexpr OUStringLiteral FM_PROP_WIDTH
constexpr OUStringLiteral FM_PROP_BOUNDFIELD
constexpr OUStringLiteral FM_PROP_ISNEW
constexpr OUStringLiteral FM_PROP_LABEL
constexpr OUStringLiteral FM_PROP_HELPTEXT
constexpr OUStringLiteral FM_PROP_ESCAPE_PROCESSING
constexpr OUStringLiteral FM_PROP_DESCRIPTION
constexpr OUStringLiteral FM_PROP_HIDDEN
constexpr OUStringLiteral FM_PROP_CONTROLSOURCE
constexpr OUStringLiteral FM_PROP_NAME
constexpr OUStringLiteral FM_PROP_URL
constexpr OUStringLiteral FM_PROP_ROWHEIGHT
constexpr OUStringLiteral FM_PROP_COMMANDTYPE
constexpr OUStringLiteral FM_PROP_FIELDTYPE
constexpr OUStringLiteral FM_PROP_ISMODIFIED
constexpr OUStringLiteral FM_PROP_DATASOURCE
constexpr OUStringLiteral FM_PROP_ISCURRENCY
constexpr OUStringLiteral SRV_SDB_CONNECTION
constexpr OUStringLiteral FMURL_CONFIRM_DELETION
sal_Int32 getColumnTypeByModelName(const OUString &aModelName)
#define FM_COL_FORMATTEDFIELD
#define TYPE_FORMATTEDFIELD
#define TYPE_NUMERICFIELD
#define TYPE_PATTERNFIELD
#define FM_COL_PATTERNFIELD
#define TYPE_CURRENCYFIELD
#define FM_COL_NUMERICFIELD
#define FM_COL_CURRENCYFIELD
bool CompareBookmark(const Any &aLeft, const Any &aRight)
constexpr sal_uInt16 KEY_ESCAPE
constexpr sal_uInt16 KEY_DELETE
#define LINK(Instance, Class, Member)
#define SAL_INFO(area, stream)
const LanguageTag & getLocale()
OString stripEnd(const OString &rIn, char c)
OString stripStart(const OString &rIn, char c)
OUString getString(const Any &_rAny)
weld::Window * GetPopupParent(vcl::Window &rOutWin, tools::Rectangle &rRect)
const css::datatransfer::dnd::DropTargetDropEvent maDropEvent
Reference< XModel > xModel