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