Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <swtypes.hxx>
21 : #include <dbtablepreviewdialog.hxx>
22 : #include <comphelper/processfactory.hxx>
23 : #include <com/sun/star/frame/Frame.hpp>
24 : #include <toolkit/helper/vclunohelper.hxx>
25 :
26 : #include <dbui.hrc>
27 : #include <dbtablepreviewdialog.hrc>
28 : #include <unomid.h>
29 :
30 : using namespace ::com::sun::star;
31 : using namespace ::com::sun::star::uno;
32 : using namespace ::com::sun::star::frame;
33 : using namespace ::com::sun::star::beans;
34 : using namespace ::com::sun::star::lang;
35 : using namespace ::com::sun::star::util;
36 : using namespace ::rtl;
37 :
38 0 : SwDBTablePreviewDialog::SwDBTablePreviewDialog(Window* pParent, uno::Sequence< beans::PropertyValue>& rValues ) :
39 : SfxModalDialog(pParent, SW_RES(DLG_MM_DBTABLEPREVIEWDIALOG)),
40 : #ifdef _MSC_VER
41 : #pragma warning (disable : 4355)
42 : #endif
43 : m_aDescriptionFI( this, SW_RES( FI_DESCRIPTION)),
44 0 : m_pBeamerWIN( new Window(this, SW_RES( WIN_BEAMER ))),
45 0 : m_aOK( this, SW_RES( PB_OK ))
46 : #ifdef _MSC_VER
47 : #pragma warning (default : 4355)
48 : #endif
49 : {
50 0 : FreeResource();
51 0 : const beans::PropertyValue* pValues = rValues.getConstArray();
52 0 : for(sal_Int32 nValue = 0; nValue < rValues.getLength(); ++nValue )
53 : {
54 0 : if ( pValues[nValue].Name == "Command" )
55 : {
56 0 : String sDescription = m_aDescriptionFI.GetText();
57 0 : OUString sTemp;
58 0 : pValues[nValue].Value >>= sTemp;
59 0 : sDescription.SearchAndReplaceAscii("%1", sTemp);
60 0 : m_aDescriptionFI.SetText(sDescription);
61 0 : break;
62 : }
63 : }
64 :
65 : try
66 : {
67 : // create a frame wrapper for myself
68 0 : m_xFrame = frame::Frame::create( comphelper::getProcessComponentContext() );
69 0 : m_xFrame->initialize( VCLUnoHelper::GetInterface( m_pBeamerWIN ) );
70 : }
71 0 : catch (uno::Exception const &)
72 : {
73 0 : m_xFrame.clear();
74 : }
75 0 : if(m_xFrame.is())
76 : {
77 0 : util::URL aURL;
78 0 : aURL.Complete = ".component:DB/DataSourceBrowser";
79 0 : uno::Reference<frame::XDispatch> xD = m_xFrame->queryDispatch(aURL, "", 0x0C);
80 0 : if(xD.is())
81 : {
82 0 : xD->dispatch(aURL, rValues);
83 0 : m_pBeamerWIN->Show();
84 0 : }
85 : }
86 0 : }
87 :
88 0 : SwDBTablePreviewDialog::~SwDBTablePreviewDialog()
89 : {
90 0 : if(m_xFrame.is())
91 : {
92 0 : m_xFrame->setComponent(NULL, NULL);
93 0 : m_xFrame->dispose();
94 : }
95 : else
96 0 : delete m_pBeamerWIN;
97 0 : }
98 :
99 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|