26#include <com/sun/star/awt/XWindow.hpp>
27#include <com/sun/star/awt/XTopWindow.hpp>
28#include <com/sun/star/uno/Sequence.hxx>
29#include <com/sun/star/frame/Desktop.hpp>
30#include <com/sun/star/frame/XTitle.hpp>
31#include <com/sun/star/frame/XComponentLoader.hpp>
32#include <com/sun/star/lang/NullPointerException.hpp>
33#include <com/sun/star/lang/DisposedException.hpp>
34#include <com/sun/star/frame/FrameSearchFlag.hpp>
35#include <com/sun/star/sdbc/XConnection.hpp>
36#include <com/sun/star/util/XCloseable.hpp>
37#include <com/sun/star/frame/XDispatchProvider.hpp>
38#include <com/sun/star/sdb/CommandType.hpp>
43#include <osl/diagnose.h>
50 using ::com::sun::star::uno::Reference;
51 using ::com::sun::star::beans::PropertyChangeEvent;
52 using ::com::sun::star::uno::RuntimeException;
53 using ::com::sun::star::frame::XFrame;
54 using ::com::sun::star::awt::XTopWindow;
55 using ::com::sun::star::awt::XWindow;
56 using ::com::sun::star::uno::Exception;
57 using ::com::sun::star::uno::UNO_QUERY_THROW;
58 using ::com::sun::star::uno::UNO_QUERY;
59 using ::com::sun::star::beans::PropertyValue;
60 using ::com::sun::star::uno::Sequence;
61 using ::com::sun::star::lang::XComponent;
62 using ::com::sun::star::frame::XComponentLoader;
63 using ::com::sun::star::beans::XPropertySet;
64 using ::com::sun::star::frame::XTitle;
65 using ::com::sun::star::lang::EventObject;
66 using ::com::sun::star::lang::NullPointerException;
67 using ::com::sun::star::lang::DisposedException;
68 using ::com::sun::star::uno::XComponentContext;
69 using ::com::sun::star::frame::XFrames;
70 using ::com::sun::star::util::XCloseable;
71 using ::com::sun::star::lang::XMultiServiceFactory;
72 using ::com::sun::star::frame::XDispatchProvider;
73 using ::com::sun::star::frame::XDispatch;
74 using ::com::sun::star::frame::Desktop;
75 using ::com::sun::star::frame::XDesktop2;
77 namespace FrameSearchFlag = ::com::sun::star::frame::FrameSearchFlag;
78 namespace CommandType = ::com::sun::star::sdb::CommandType;
93 const ::rtl::Reference< ISQLCommandAdapter >& _rxPropertyAdapter,
97 ,m_xObjectAdapter( _rxPropertyAdapter )
98 ,m_aCloseLink( _rCloseLink )
102 if ( !m_xORB.is() || !_rxPropertyAdapter.is() || !
m_xConnection.is() )
103 throw NullPointerException();
105 impl_doOpenDesignerFrame_nothrow();
116 OSL_ENSURE(
m_xDesigner.is() && ( Event.Source ==
m_xDesigner ),
"SQLCommandDesigner::propertyChange: where did this come from?" );
126 OSL_VERIFY( Event.NewValue >>= sCommand );
131 bool bEscapeProcessing(
false );
132 OSL_VERIFY( Event.NewValue >>= bEscapeProcessing );
172 throw DisposedException();
192 OSL_PRECOND(
isActive(),
"SQLCommandDesigner::impl_raise_nothrow: not active!" );
200 Reference< XWindow > xWindow(
xFrame->getContainerWindow(), css::uno::UNO_SET_THROW );
201 Reference< XTopWindow > xTopWindow( xWindow, UNO_QUERY_THROW );
203 xTopWindow->toFront();
216 "SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow: already active!" );
217 OSL_PRECOND(
m_xConnection.
is(),
"SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow: this will crash!" );
227 Sequence< PropertyValue > aArgs{
235 Reference< XComponent > xQueryDesign = xLoader->loadComponentFromURL(
236 ".component:DB/QueryDesign",
238 FrameSearchFlag::TASKS | FrameSearchFlag::CREATE,
243 m_xDesigner.set(xQueryDesign, css::uno::UNO_QUERY);
244 OSL_ENSURE(
m_xDesigner.is() || !xQueryDesign.is(),
"SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow: the component is expected to be a controller!" );
247 Reference< XPropertySet > xQueryDesignProps(
m_xDesigner, UNO_QUERY );
248 OSL_ENSURE( xQueryDesignProps.is(),
"SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow: the controller should have properties!" );
249 if ( xQueryDesignProps.is() )
257 Reference< XTitle> xTitle(xQueryDesign,UNO_QUERY);
275 OSL_PRECOND(
m_xORB.is(),
"SQLCommandDesigner::impl_createEmptyParentlessTask_nothrow: this will crash!" );
277 Reference< XFrame >
xFrame;
280 Reference< XDesktop2 > xDesktop = Desktop::create(
m_xContext);
282 Reference< XFrames > xDesktopFramesCollection( xDesktop->getFrames(), css::uno::UNO_SET_THROW );
283 xFrame = xDesktop->findFrame(
"_blank", FrameSearchFlag::CREATE );
284 OSL_ENSURE(
xFrame.is(),
"SQLCommandDesigner::impl_createEmptyParentlessTask_nothrow: could not create an empty frame!" );
285 xDesktopFramesCollection->remove(
xFrame );
297 OSL_PRECOND(
isActive(),
"SQLCommandDesigner::impl_closeDesigner_nothrow: invalid call!" );
302 Reference< XPropertySet > xProps(
m_xDesigner, UNO_QUERY );
310 const UnoURL aCloseURL(
".uno:CloseDoc",
313 Reference< XDispatchProvider > xProvider(
m_xDesigner->getFrame(), UNO_QUERY_THROW );
314 Reference< XDispatch >
xDispatch( xProvider->queryDispatch( aCloseURL,
"_top", FrameSearchFlag::SELF ) );
315 OSL_ENSURE(
xDispatch.is(),
"SQLCommandDesigner::impl_closeDesigner_nothrow: no dispatcher for the CloseDoc command!" );
318 xDispatch->dispatch( aCloseURL, Sequence< PropertyValue >( ) );
323 Reference< XCloseable > xClose(
m_xDesigner->getFrame(), UNO_QUERY );
325 xClose->close(
true );
339 OSL_PRECOND(
isActive(),
"SQLCommandDesigner::impl_trySuspendDesigner_nothrow: no active designer, this will crash!" );
virtual ~ISQLCommandAdapter() override
css::uno::Reference< css::frame::XFrame > impl_createEmptyParentlessTask_nothrow() const
create an empty top-level frame, which does not belong to the desktop's frame list @precond ->m_xORB ...
css::uno::Reference< css::frame::XController > m_xDesigner
void impl_checkDisposed_throw() const
checks whether we are already disposed
virtual ~SQLCommandDesigner() override
::dbtools::SharedConnection m_xConnection
void impl_closeDesigner_nothrow()
closes the component denoted by m_xDesigner @precond our designer component is actually active (->isA...
bool impl_trySuspendDesigner_nothrow() const
suspends our designer component @precond the designer component is actually active (->isActive)
css::uno::Reference< css::lang::XMultiComponentFactory > m_xORB
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
void impl_doOpenDesignerFrame_nothrow()
opens a new frame for interactively designing an SQL command @precond the designer is not currently a...
::rtl::Reference< ISQLCommandAdapter > m_xObjectAdapter
Link< SQLCommandDesigner &, void > m_aCloseLink
SQLCommandDesigner(const css::uno::Reference< css::uno::XComponentContext > &_rxContext, const ::rtl::Reference< ISQLCommandAdapter > &_rxPropertyAdapter, ::dbtools::SharedConnection _aConnection, const Link< SQLCommandDesigner &, void > &_rCloseLink)
creates the instance, and immediately opens the SQL command design frame
bool impl_isDisposed() const
determines whether we are already disposed
virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent &evt) override
bool suspend() const
suspends the designer @precond the designer is active (->isActive) @precond the instance is not dispo...
void impl_raise_nothrow() const
impl-version of ->raise
css::uno::Reference< css::uno::XComponentContext > m_xContext
void raise() const
raises the designer window to top @precond the designer is active (->isActive) @precond the instance ...
bool isActive() const
determines whether the SQL Command designer is currently active, i.e.
void dispose()
disposes the instance so that it becomes non-functional
const css::uno::Reference< INTERFACE > & getTyped() const
#define DBG_UNHANDLED_EXCEPTION(...)
Reference< XDispatch > xDispatch
Reference< XComponentContext > m_xContext
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
a property handler for any virtual string properties
OUString PcrRes(TranslateId aId)
Reference< XConnection > m_xConnection
Reference< XFrame > xFrame