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