tdf#122152 set dialog parent

Change-Id: I15f6d577c3584d28f667a04b5571de80effe53fe
Reviewed-on: https://gerrit.libreoffice.org/65274
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <[email protected]>
Tested-by: Caolán McNamara <[email protected]>
diff --git a/dbaccess/source/ui/uno/composerdialogs.cxx b/dbaccess/source/ui/uno/composerdialogs.cxx
index 95186c7..c9b1973 100644
--- a/dbaccess/source/ui/uno/composerdialogs.cxx
+++ b/dbaccess/source/ui/uno/composerdialogs.cxx
@@ -198,7 +198,7 @@

    void SAL_CALL RowsetOrderDialog::initialize( const Sequence< Any >& aArguments )
    {
        if( aArguments.getLength() == 2 )
        if (aArguments.getLength() == 2 || aArguments.getLength() == 3)
        {
            Reference<css::sdb::XSingleSelectQueryComposer> xQueryComposer;
            aArguments[0] >>= xQueryComposer;
@@ -206,6 +206,12 @@
            aArguments[1] >>= xRowSet;
            setPropertyValue( "QueryComposer", makeAny( xQueryComposer ) );
            setPropertyValue( "RowSet",        makeAny( xRowSet ) );
            if (aArguments.getLength() == 3)
            {
                Reference<css::awt::XWindow> xParentWindow;
                aArguments[2] >>= xParentWindow;
                setPropertyValue("ParentWindow",  makeAny(xParentWindow));
            }
        }
        else
            ComposerDialog::initialize(aArguments);
diff --git a/forms/source/runtime/formoperations.cxx b/forms/source/runtime/formoperations.cxx
index 0ff1153..3579828 100644
--- a/forms/source/runtime/formoperations.cxx
+++ b/forms/source/runtime/formoperations.cxx
@@ -28,6 +28,7 @@
#include <com/sun/star/ucb/AlreadyInitializedException.hpp>
#include <com/sun/star/util/XModifyBroadcaster.hpp>
#include <com/sun/star/form/runtime/FormFeature.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/awt/XControl.hpp>
@@ -1685,18 +1686,32 @@
            return;
        try
        {
            css::uno::Reference<css::awt::XWindow> xDialogParent;

            //tdf#122152 extract parent for dialog
            css::uno::Reference<css::awt::XTabController> xTabController(m_xController, css::uno::UNO_QUERY);
            if (xTabController.is())
            {
                css::uno::Reference<css::awt::XControl> xContainerControl(xTabController->getContainer(), css::uno::UNO_QUERY);
                if (xContainerControl.is())
                {
                    css::uno::Reference<css::awt::XWindowPeer> xContainerPeer(xContainerControl->getPeer(), css::uno::UNO_QUERY);
                    xDialogParent = css::uno::Reference<css::awt::XWindow>(xContainerPeer, css::uno::UNO_QUERY);
                }
            }

            Reference< XExecutableDialog> xDialog;
            if ( _bFilter )
            {
                xDialog = css::sdb::FilterDialog::createWithQuery(m_xContext, m_xParser, m_xCursor,
                              Reference<css::awt::XWindow>());
                                                                  xDialogParent);
            }
            else
            {
                xDialog = css::sdb::OrderDialog::createWithQuery(m_xContext, m_xParser, m_xCursorProperties);
                xDialog = css::sdb::OrderDialog::createWithQuery(m_xContext, m_xParser, m_xCursorProperties,
                                                                 xDialogParent);
            }


            if ( RET_OK == xDialog->execute() )
            {
                WaitObject aWO( nullptr );
diff --git a/offapi/com/sun/star/sdb/OrderDialog.idl b/offapi/com/sun/star/sdb/OrderDialog.idl
index 461fef0..456e70f 100644
--- a/offapi/com/sun/star/sdb/OrderDialog.idl
+++ b/offapi/com/sun/star/sdb/OrderDialog.idl
@@ -20,6 +20,7 @@
#ifndef __com_sun_star_sdb_OrderDialog_idl__
#define __com_sun_star_sdb_OrderDialog_idl__

#include <com/sun/star/awt/XWindow.idl>
#include <com/sun/star/beans/XPropertySet.idl>
#include <com/sun/star/sdb/XSingleSelectQueryComposer.idl>
#include <com/sun/star/ui/dialogs/XExecutableDialog.idl>
@@ -37,7 +38,8 @@
    createDefault();

    createWithQuery([in] com::sun::star::sdb::XSingleSelectQueryComposer QueryComposer,
                    [in] com::sun::star::beans::XPropertySet RowSet);
                    [in] com::sun::star::beans::XPropertySet RowSet,
                    [in] com::sun::star::awt::XWindow ParentWindow);
};