21#include <com/sun/star/util/XURLTransformer.hpp>
22#include <com/sun/star/form/XGridColumnFactory.hpp>
23#include <com/sun/star/form/XLoadable.hpp>
24#include <com/sun/star/frame/FrameSearchFlag.hpp>
43extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
45 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const& )
50Any SAL_CALL SbaExternalSourceBrowser::queryInterface(
const Type& _rType)
54 aRet = ::cppu::queryInterface(_rType,
55 static_cast<css::util::XModifyBroadcaster*
>(
this),
56 static_cast<css::form::XLoadListener*
>(
this));
64 ,m_bInQueryDispatch( false )
75 return {
"com.sun.star.sdb.FormGridView" };
80 return "org.openoffice.comp.dbu.OFormGridView";
106 css::lang::EventObject aEvt(*
this);
112 if (
aURL.Complete ==
".uno:FormSlots/AddGridColumn" )
115 OUString sControlType;
116 sal_Int32 nControlPos = -1;
118 for (
const css::beans::PropertyValue& rArgument : aArgs )
120 if ( rArgument.Name ==
"ColumnType" )
122 auto s = o3tl::tryAccess<OUString>(rArgument.Value);
123 OSL_ENSURE(s,
"invalid type for argument \"ColumnType\" !");
127 else if ( rArgument.Name ==
"ColumnPosition" )
130 OSL_ENSURE(
n,
"invalid type for argument \"ColumnPosition\" !");
134 else if ( rArgument.Name ==
"ColumnProperties" )
136 auto s = o3tl::tryAccess<Sequence<css::beans::PropertyValue>>(
138 OSL_ENSURE(s,
"invalid type for argument \"ColumnProperties\" !");
143 SAL_WARN(
"dbaccess.ui",
"SbaExternalSourceBrowser::dispatch(AddGridColumn) : unknown argument (" << rArgument.Name <<
") !");
145 if (sControlType.isEmpty())
147 SAL_WARN(
"dbaccess.ui",
"SbaExternalSourceBrowser::dispatch(AddGridColumn) : missing argument (ColumnType) !");
148 sControlType =
"TextField";
150 OSL_ENSURE(aControlProps.hasElements(),
"SbaExternalSourceBrowser::dispatch(AddGridColumn) : missing argument (ColumnProperties) !");
157 xNewColProperties = xNewCol->getPropertySetInfo();
159 if (xNewColProperties.is())
161 for (
const css::beans::PropertyValue& rControlProp : std::as_const(aControlProps))
165 if (xNewColProperties->hasPropertyByName(rControlProp.Name))
166 xNewCol->setPropertyValue(rControlProp.Name, rControlProp.Value);
170 SAL_WARN(
"dbaccess.ui",
"SbaExternalSourceBrowser::dispatch : could not set a column property (" << rControlProp.Name <<
")!");
178 if (nControlPos > xColContainer->getCount())
179 nControlPos = xColContainer->getCount();
184 xColContainer->insertByIndex(nControlPos,
Any(xNewCol));
186 else if (
aURL.Complete ==
".uno:FormSlots/ClearView" )
190 else if (
aURL.Complete ==
".uno:FormSlots/AttachToForm" )
197 for (
const css::beans::PropertyValue& rArgument : aArgs)
199 if ( (rArgument.Name ==
"MasterForm") && (rArgument.Value.getValueTypeClass() == TypeClass_INTERFACE) )
201 xMasterForm.set(rArgument.Value, UNO_QUERY);
205 if (!xMasterForm.is())
207 SAL_WARN(
"dbaccess.ui",
"SbaExternalSourceBrowser::dispatch(FormSlots/AttachToForm) : please specify a form to attach to as argument !");
214 SbaXDataBrowserController::dispatch(
aURL, aArgs);
225 if ( (
aURL.Complete ==
".uno:FormSlots/AttachToForm" )
227 || (
aURL.Complete ==
".uno:FormSlots/AddGridColumn" )
229 || (
aURL.Complete ==
".uno:FormSlots/ClearView" )
232 xReturn =
static_cast<css::frame::XDispatch*
>(
this);
235 && ( (
aURL.Complete ==
".uno:FormSlots/moveToFirst" ) || (
aURL.Complete ==
".uno:FormSlots/moveToPrev" )
236 || (
aURL.Complete ==
".uno:FormSlots/moveToNext" ) || (
aURL.Complete ==
".uno:FormSlots/moveToLast" )
237 || (
aURL.Complete ==
".uno:FormSlots/moveToNew" ) || (
aURL.Complete ==
".uno:FormSlots/undoRecord" )
241 OSL_ENSURE(
aURL.Mark.isEmpty(),
"SbaExternalSourceBrowser::queryDispatch : the css::util::URL shouldn't have a mark !");
242 css::util::URL aNewUrl =
aURL;
245 OSL_ENSURE( m_xUrlTransformer.is(),
"SbaExternalSourceBrowser::queryDispatch : could not create a URLTransformer !" );
246 if ( m_xUrlTransformer.is() )
247 m_xUrlTransformer->parseStrict( aNewUrl );
250 aNewUrl.Mark =
"DB/FormGridView";
254 if (m_xUrlTransformer.is())
255 m_xUrlTransformer->assemble(aNewUrl);
258 if (xFrameDispatcher.is())
259 xReturn = xFrameDispatcher->queryDispatch(aNewUrl, aTargetFrameName, FrameSearchFlag::PARENT);
264 xReturn = SbaXDataBrowserController::queryDispatch(
aURL, aTargetFrameName, nSearchFlags);
273 css::lang::EventObject aEvt;
274 aEvt.Source =
static_cast<XWeak*
>(
this);
305 bool bWasInsertRow =
false;
306 bool bBeforeFirst =
true;
307 bool bAfterLast =
true;
319 if (xCursor.is() && xMaster.is())
321 bBeforeFirst = xMaster->isBeforeFirst();
322 bAfterLast = xMaster->isAfterLast();
323 if(!bBeforeFirst && !bAfterLast)
324 aOldPos = xCursor->getBookmark();
327 if (xMasterProps.is())
347#if OSL_DEBUG_LEVEL > 0
350 OSL_ENSURE( xLoadable.is() && xLoadable->isLoaded(),
"SbaExternalSourceBrowser::Attach: master is not loaded!" );
359 if (bWasInsertRow && xUpdate.is())
360 xUpdate->moveToInsertRow();
361 else if (xCursor.is() && aOldPos.hasValue())
362 xCursor->moveToBookmark(aOldPos);
363 else if(bBeforeFirst && xMaster.is())
364 xMaster->beforeFirst();
365 else if(bAfterLast && xMaster.is())
366 xMaster->afterLast();
370 SAL_WARN(
"dbaccess.ui",
"SbaExternalSourceBrowser::Attach : couldn't restore the cursor position !");
381 while (xColContainer->getCount() > 0)
382 xColContainer->removeByIndex(0);
400 xLoadable->addLoadListener(
static_cast<css::form::XLoadListener*
>(
this));
409 xLoadable->removeLoadListener(
static_cast<css::form::XLoadListener*
>(
this));
sal_Int32 addInterface(const css::uno::Reference< ListenerT > &rxIFace)
void disposeAndClear(const css::lang::EventObject &rEvt)
sal_Int32 removeInterface(const css::uno::Reference< ListenerT > &rxIFace)
void notifyEach(void(SAL_CALL ListenerT::*NotificationMethod)(const EventT &), const EventT &Event)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL dispatch(const css::util::URL &aURL, const css::uno::Sequence< css::beans::PropertyValue > &aArgs) override
virtual void SAL_CALL unloading(const css::lang::EventObject &aEvent) override
virtual ~SbaExternalSourceBrowser() override
virtual void SAL_CALL modified(const css::lang::EventObject &aEvent) override
void Attach(const css::uno::Reference< css::sdbc::XRowSet > &xMaster)
virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch(const css::util::URL &aURL, const OUString &aTargetFrameName, sal_Int32 nSearchFlags) override
virtual bool InitializeForm(const css::uno::Reference< css::beans::XPropertySet > &i_formProperties) override
virtual void SAL_CALL addModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
virtual void SAL_CALL disposing() override
virtual void SAL_CALL removeModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
virtual css::uno::Reference< css::sdbc::XRowSet > CreateForm() override
SbaExternalSourceBrowser(const css::uno::Reference< css::uno::XComponentContext > &_rM)
virtual OUString SAL_CALL getImplementationName() override
::comphelper::OInterfaceContainerHelper3< css::util::XModifyListener > m_aModifyListeners
rtl::Reference< SbaXFormAdapter > m_pDataSourceImpl
virtual bool LoadForm() override
void onStartLoading(const css::uno::Reference< css::form::XLoadable > &_rxLoadable)
virtual void LoadFinished(bool bWasSynch)
virtual void SAL_CALL disposing() override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &_rType) override
UnoDataBrowserView * getBrowserView() const
virtual void SAL_CALL unloading(const css::lang::EventObject &aEvent) override
css::uno::Reference< css::awt::XControlModel > getControlModel() const
virtual void SAL_CALL modified(const css::lang::EventObject &aEvent) override
const css::uno::Reference< css::awt::XControl > & getGridControl() const
#define DBG_UNHANDLED_EXCEPTION(...)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * org_openoffice_comp_dbu_OFormGridView_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
#define SAL_WARN(area, stream)
::osl::Mutex & getMutex()
detail::Optional< sal_Int16 >::type tryAccess< sal_Int16 >(css::uno::Any const &any)
constexpr OUStringLiteral PROPERTY_ISNEW(u"IsNew")