1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sw.hxx" 26 27 #ifdef SW_DLLIMPLEMENTATION 28 #undef SW_DLLIMPLEMENTATION 29 #endif 30 31 32 #include <swtypes.hxx> 33 #include <dbtablepreviewdialog.hxx> 34 #include <comphelper/processfactory.hxx> 35 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 36 #include <com/sun/star/frame/XDispatchProvider.hpp> 37 #include <com/sun/star/frame/XFrame.hpp> 38 #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ 39 #include <toolkit/unohlp.hxx> 40 #endif 41 42 #include <dbui.hrc> 43 #include <dbtablepreviewdialog.hrc> 44 #include <unomid.h> 45 46 using namespace ::com::sun::star; 47 using namespace ::com::sun::star::uno; 48 using namespace ::com::sun::star::frame; 49 using namespace ::com::sun::star::beans; 50 using namespace ::com::sun::star::lang; 51 using namespace ::com::sun::star::util; 52 using namespace ::rtl; 53 54 /*-- 08.04.2004 15:12:24--------------------------------------------------- 55 56 -----------------------------------------------------------------------*/ 57 SwDBTablePreviewDialog::SwDBTablePreviewDialog(Window* pParent, uno::Sequence< beans::PropertyValue>& rValues ) : 58 SfxModalDialog(pParent, SW_RES(DLG_MM_DBTABLEPREVIEWDIALOG)), 59 #ifdef MSC 60 #pragma warning (disable : 4355) 61 #endif 62 m_aDescriptionFI( this, SW_RES( FI_DESCRIPTION)), 63 m_pBeamerWIN( new Window(this, SW_RES( WIN_BEAMER ))), 64 m_aOK( this, SW_RES( PB_OK )) 65 #ifdef MSC 66 #pragma warning (default : 4355) 67 #endif 68 { 69 FreeResource(); 70 const beans::PropertyValue* pValues = rValues.getConstArray(); 71 for(sal_Int32 nValue = 0; nValue < rValues.getLength(); ++nValue ) 72 { 73 if(pValues[nValue].Name.equalsAscii("Command")) 74 { 75 String sDescription = m_aDescriptionFI.GetText(); 76 OUString sTemp; 77 pValues[nValue].Value >>= sTemp; 78 sDescription.SearchAndReplaceAscii("%1", sTemp); 79 m_aDescriptionFI.SetText(sDescription); 80 break; 81 } 82 } 83 84 try 85 { 86 // create a frame wrapper for myself 87 uno::Reference< lang::XMultiServiceFactory > 88 xMgr = comphelper::getProcessServiceFactory(); 89 m_xFrame = uno::Reference< frame::XFrame >(xMgr->createInstance(C2U("com.sun.star.frame.Frame")), uno::UNO_QUERY); 90 if(m_xFrame.is()) 91 { 92 m_xFrame->initialize( VCLUnoHelper::GetInterface ( m_pBeamerWIN ) ); 93 } 94 } 95 catch (uno::Exception const &) 96 { 97 m_xFrame.clear(); 98 } 99 if(m_xFrame.is()) 100 { 101 uno::Reference<frame::XDispatchProvider> xDP(m_xFrame, uno::UNO_QUERY); 102 util::URL aURL; 103 aURL.Complete = C2U(".component:DB/DataSourceBrowser"); 104 uno::Reference<frame::XDispatch> xD = xDP->queryDispatch(aURL, 105 C2U(""), 106 0x0C); 107 if(xD.is()) 108 { 109 xD->dispatch(aURL, rValues); 110 m_pBeamerWIN->Show(); 111 } 112 /* uno::Reference<???::XController> xController = m_xFrame->getController(); 113 pImpl->xFController = uno::Reference<???::XFormController>(xController, uno::UNO_QUERY); 114 if(pImpl->xFController.is()) 115 { 116 uno::Reference< awt::XControl > xCtrl = pImpl->xFController->getCurrentControl( ); 117 pImpl->xSelSupp = uno::Reference<???::XSelectionSupplier>(xCtrl, uno::UNO_QUERY); 118 if(pImpl->xSelSupp.is()) 119 { 120 pImpl->xChgLstnr = new SwXSelChgLstnr_Impl(*this); 121 pImpl->xSelSupp->addSelectionChangeListener( pImpl->xChgLstnr ); 122 } 123 } 124 */ } 125 126 127 } 128 /*-- 08.04.2004 15:12:24--------------------------------------------------- 129 130 -----------------------------------------------------------------------*/ 131 SwDBTablePreviewDialog::~SwDBTablePreviewDialog() 132 { 133 if(m_xFrame.is()) 134 { 135 m_xFrame->setComponent(NULL, NULL); 136 m_xFrame->dispose(); 137 } 138 else 139 delete m_pBeamerWIN; 140 } 141