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