LibreOffice Module sw (master)  1
dbtablepreviewdialog.cxx
Go to the documentation of this file.
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"
23 #include <com/sun/star/frame/Frame.hpp>
25 
26 #include <unomid.h>
27 
28 using namespace ::com::sun::star;
29 using namespace ::com::sun::star::uno;
30 using namespace ::com::sun::star::frame;
31 using namespace ::com::sun::star::beans;
32 using namespace ::com::sun::star::lang;
33 using namespace ::com::sun::star::util;
34 
35 SwDBTablePreviewDialog::SwDBTablePreviewDialog(vcl::Window* pParent, uno::Sequence< beans::PropertyValue> const & rValues ) :
36  SfxModalDialog(pParent, "TablePreviewDialog", "modules/swriter/ui/tablepreviewdialog.ui")
37 {
38  get(m_pDescriptionFI, "description");
39  get(m_pBeamerWIN, "beamer");
40  Size aSize(LogicToPixel(Size(338, 150), MapMode(MapUnit::MapAppFont)));
43 
44  auto pValue = std::find_if(rValues.begin(), rValues.end(),
45  [](const beans::PropertyValue& rValue) { return rValue.Name == "Command"; });
46  if (pValue != rValues.end())
47  {
48  OUString sDescription = m_pDescriptionFI->GetText();
49  OUString sTemp;
50  pValue->Value >>= sTemp;
51  m_pDescriptionFI->SetText(sDescription.replaceFirst("%1", sTemp));
52  }
53 
54  try
55  {
56  // create a frame wrapper for myself
57  m_xFrame = frame::Frame::create( comphelper::getProcessComponentContext() );
58  // m_xFrame takes ownership of m_pBeamerWIN
59  m_pUIBuilder->drop_ownership(m_pBeamerWIN);
61  }
62  catch (uno::Exception const &)
63  {
64  m_xFrame.clear();
65  }
66  if(m_xFrame.is())
67  {
68  util::URL aURL;
69  aURL.Complete = ".component:DB/DataSourceBrowser";
70  uno::Reference<frame::XDispatch> xD = m_xFrame->queryDispatch(aURL, "", 0x0C);
71  if(xD.is())
72  {
73  xD->dispatch(aURL, rValues);
74  m_pBeamerWIN->Show();
75  }
76  }
77 }
78 
80 {
81  disposeOnce();
82 }
83 
85 {
86  if(m_xFrame.is())
87  {
88  m_xFrame->setComponent(nullptr, nullptr);
89  m_xFrame->dispose();
90  }
94 }
95 
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
long Width() const
css::uno::Reference< css::frame::XFrame2 > m_xFrame
virtual void dispose() override
long Height() const
void set_height_request(sal_Int32 nHeightRequest)
virtual ~SwDBTablePreviewDialog() override
void set_width_request(sal_Int32 nWidthRequest)
virtual OUString GetText() const
virtual void dispose() override
virtual void SetText(const OUString &rStr) override
VclPtr< vcl::Window > m_pBeamerWIN
VclPtr< FixedText > m_pDescriptionFI
SwDBTablePreviewDialog(vcl::Window *pParent, css::uno::Sequence< css::beans::PropertyValue > const &rValues)
Reference< XComponentContext > getProcessComponentContext()
static css::uno::Reference< css::awt::XWindow > GetInterface(vcl::Window *pWindow)
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)