1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sw.hxx"
30 
31 #ifdef SW_DLLIMPLEMENTATION
32 #undef SW_DLLIMPLEMENTATION
33 #endif
34 
35 
36 #include <swtypes.hxx>
37 #include <dbtablepreviewdialog.hxx>
38 #include <comphelper/processfactory.hxx>
39 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
40 #include <com/sun/star/frame/XDispatchProvider.hpp>
41 #include <com/sun/star/frame/XFrame.hpp>
42 #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
43 #include <toolkit/unohlp.hxx>
44 #endif
45 
46 #include <dbui.hrc>
47 #include <dbtablepreviewdialog.hrc>
48 #include <unomid.h>
49 
50 using namespace ::com::sun::star;
51 using namespace ::com::sun::star::uno;
52 using namespace ::com::sun::star::frame;
53 using namespace ::com::sun::star::beans;
54 using namespace ::com::sun::star::lang;
55 using namespace ::com::sun::star::util;
56 using namespace ::rtl;
57 
58 /*-- 08.04.2004 15:12:24---------------------------------------------------
59 
60   -----------------------------------------------------------------------*/
61 SwDBTablePreviewDialog::SwDBTablePreviewDialog(Window* pParent, uno::Sequence< beans::PropertyValue>& rValues ) :
62     SfxModalDialog(pParent, SW_RES(DLG_MM_DBTABLEPREVIEWDIALOG)),
63 #ifdef MSC
64 #pragma warning (disable : 4355)
65 #endif
66     m_aDescriptionFI( this, SW_RES(        FI_DESCRIPTION)),
67     m_pBeamerWIN( new Window(this, SW_RES( WIN_BEAMER ))),
68     m_aOK( this, SW_RES(                   PB_OK  ))
69 #ifdef MSC
70 #pragma warning (default : 4355)
71 #endif
72 {
73     FreeResource();
74     const beans::PropertyValue* pValues = rValues.getConstArray();
75     for(sal_Int32 nValue = 0; nValue < rValues.getLength(); ++nValue        )
76     {
77         if(pValues[nValue].Name.equalsAscii("Command"))
78         {
79             String sDescription = m_aDescriptionFI.GetText();
80             OUString sTemp;
81             pValues[nValue].Value >>= sTemp;
82             sDescription.SearchAndReplaceAscii("%1", sTemp);
83             m_aDescriptionFI.SetText(sDescription);
84             break;
85         }
86     }
87 
88     try
89     {
90         // create a frame wrapper for myself
91         uno::Reference< lang::XMultiServiceFactory >
92                                     xMgr = comphelper::getProcessServiceFactory();
93         m_xFrame = uno::Reference< frame::XFrame >(xMgr->createInstance(C2U("com.sun.star.frame.Frame")), uno::UNO_QUERY);
94         if(m_xFrame.is())
95         {
96             m_xFrame->initialize( VCLUnoHelper::GetInterface ( m_pBeamerWIN ) );
97         }
98     }
99     catch (uno::Exception const &)
100     {
101         m_xFrame.clear();
102     }
103     if(m_xFrame.is())
104     {
105         uno::Reference<frame::XDispatchProvider> xDP(m_xFrame, uno::UNO_QUERY);
106         util::URL aURL;
107         aURL.Complete = C2U(".component:DB/DataSourceBrowser");
108         uno::Reference<frame::XDispatch> xD = xDP->queryDispatch(aURL,
109                     C2U(""),
110                     0x0C);
111         if(xD.is())
112         {
113             xD->dispatch(aURL, rValues);
114             m_pBeamerWIN->Show();
115         }
116 /*        uno::Reference<???::XController> xController = m_xFrame->getController();
117         pImpl->xFController = uno::Reference<???::XFormController>(xController, uno::UNO_QUERY);
118         if(pImpl->xFController.is())
119         {
120             uno::Reference< awt::XControl > xCtrl = pImpl->xFController->getCurrentControl(  );
121             pImpl->xSelSupp = uno::Reference<???::XSelectionSupplier>(xCtrl, uno::UNO_QUERY);
122             if(pImpl->xSelSupp.is())
123             {
124                 pImpl->xChgLstnr = new SwXSelChgLstnr_Impl(*this);
125                 pImpl->xSelSupp->addSelectionChangeListener(  pImpl->xChgLstnr );
126             }
127         }
128 */    }
129 
130 
131 }
132 /*-- 08.04.2004 15:12:24---------------------------------------------------
133 
134   -----------------------------------------------------------------------*/
135 SwDBTablePreviewDialog::~SwDBTablePreviewDialog()
136 {
137     if(m_xFrame.is())
138     {
139         m_xFrame->setComponent(NULL, NULL);
140         m_xFrame->dispose();
141     }
142     else
143         delete m_pBeamerWIN;
144 }
145