update credits
[LibreOffice.git] / sw / source / ui / dbui / dbtablepreviewdialog.cxx
blobf9d2dafe17c71850f1aa763e9a5024357f791048
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <swtypes.hxx>
21 #include <dbtablepreviewdialog.hxx>
22 #include <comphelper/processfactory.hxx>
23 #include <com/sun/star/frame/Frame.hpp>
24 #include <toolkit/unohlp.hxx>
26 #include <dbui.hrc>
27 #include <dbtablepreviewdialog.hrc>
28 #include <unomid.h>
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;
38 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 m_pBeamerWIN( new Window(this, SW_RES( WIN_BEAMER ))),
45 m_aOK( this, SW_RES( PB_OK ))
46 #ifdef _MSC_VER
47 #pragma warning (default : 4355)
48 #endif
50 FreeResource();
51 const beans::PropertyValue* pValues = rValues.getConstArray();
52 for(sal_Int32 nValue = 0; nValue < rValues.getLength(); ++nValue )
54 if ( pValues[nValue].Name == "Command" )
56 String sDescription = m_aDescriptionFI.GetText();
57 OUString sTemp;
58 pValues[nValue].Value >>= sTemp;
59 sDescription.SearchAndReplaceAscii("%1", sTemp);
60 m_aDescriptionFI.SetText(sDescription);
61 break;
65 try
67 // create a frame wrapper for myself
68 m_xFrame = frame::Frame::create( comphelper::getProcessComponentContext() );
69 m_xFrame->initialize( VCLUnoHelper::GetInterface( m_pBeamerWIN ) );
71 catch (uno::Exception const &)
73 m_xFrame.clear();
75 if(m_xFrame.is())
77 util::URL aURL;
78 aURL.Complete = ".component:DB/DataSourceBrowser";
79 uno::Reference<frame::XDispatch> xD = m_xFrame->queryDispatch(aURL, "", 0x0C);
80 if(xD.is())
82 xD->dispatch(aURL, rValues);
83 m_pBeamerWIN->Show();
88 SwDBTablePreviewDialog::~SwDBTablePreviewDialog()
90 if(m_xFrame.is())
92 m_xFrame->setComponent(NULL, NULL);
93 m_xFrame->dispose();
95 else
96 delete m_pBeamerWIN;
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */