LibreOffice Module sw (master)  1
SwXFilterOptions.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 <SwXFilterOptions.hxx>
21 #include <shellio.hxx>
22 #include <swdll.hxx>
23 #include <vcl/svapp.hxx>
24 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
30 #include <unotxdoc.hxx>
31 
32 #include <swabstdlg.hxx>
33 #include <memory>
34 
35 using namespace ::com::sun::star;
36 using namespace ::com::sun::star::ui::dialogs;
37 using namespace ::com::sun::star::document;
38 using namespace ::com::sun::star::lang;
39 
40 constexpr OUStringLiteral FILTER_OPTIONS_NAME = u"FilterOptions";
41 
43 {
44 }
45 
47 {
48 }
49 
50 uno::Sequence< beans::PropertyValue > SwXFilterOptions::getPropertyValues()
51 {
54  });
55 }
56 
57 void SwXFilterOptions::setPropertyValues( const uno::Sequence<beans::PropertyValue >& aProps )
58 {
59  for (const beans::PropertyValue& rProp : aProps)
60  {
61  OUString aPropName = rProp.Name;
62 
63  if ( aPropName == FILTER_OPTIONS_NAME )
64  rProp.Value >>= m_sFilterOptions;
65  else if ( aPropName == "InputStream" )
66  rProp.Value >>= m_xInputStream;
67  }
68 }
69 
70 void SwXFilterOptions::setTitle( const OUString& /*rTitle*/ )
71 {
72 }
73 
75 {
76  sal_Int16 nRet = ui::dialogs::ExecutableDialogResults::CANCEL;
77 
78  std::unique_ptr<SvStream> pInStream;
79  if ( m_xInputStream.is() )
81 
82  SwDocShell* pDocShell = nullptr;
83  if (auto pXDoc = comphelper::getFromUnoTunnel<SwXTextDocument>(m_xModel); pXDoc)
84  pDocShell = pXDoc->GetDocShell();
85 
86  if(pDocShell)
87  {
90  pInStream.get()));
91  if(RET_OK == pAsciiDlg->Execute())
92  {
93  SwAsciiOptions aOptions;
94  pAsciiDlg->FillOptions( aOptions );
96  nRet = ui::dialogs::ExecutableDialogResults::OK;
97  }
98  }
99 
100  return nRet;
101 }
102 
103 void SwXFilterOptions::setTargetDocument( const uno::Reference< XComponent >& xDoc )
104 {
105  m_xModel = xDoc;
106 }
107 
108 void SwXFilterOptions::setSourceDocument( const uno::Reference<XComponent >& xDoc )
109 {
110  m_xModel = xDoc;
111 }
112 
113 void SAL_CALL SwXFilterOptions::initialize(const uno::Sequence<uno::Any>& rArguments)
114 {
116  if (aProperties.has("ParentWindow"))
117  aProperties.get("ParentWindow") >>= m_xDialogParent;
118 }
119 
121 {
122  return "com.sun.star.comp.Writer.FilterOptionsDialog";
123 }
124 
125 sal_Bool SwXFilterOptions::supportsService( const OUString& rServiceName )
126 {
127  return cppu::supportsService(this, rServiceName);
128 }
129 
131 {
132  return { "com.sun.star.ui.dialogs.FilterOptionsDialog" };
133 }
134 
135 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
137  css::uno::Sequence<css::uno::Any> const &)
138 {
139  SolarMutexGuard aGuard;
140 
141  //the module may not be loaded
143  return cppu::acquire(new SwXFilterOptions());
144 
145 }
146 
147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual short Execute()=0
void WriteUserData(OUString &) const
Definition: fltini.cxx:573
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getPropertyValues() override
virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
css::uno::Reference< css::io::XInputStream > m_xInputStream
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
PropertiesInfo aProperties
virtual sal_Int16 SAL_CALL execute() override
virtual void SAL_CALL setSourceDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void FillOptions(SwAsciiOptions &rOptions)=0
constexpr OUStringLiteral FILTER_OPTIONS_NAME
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_Writer_FilterOptionsDialog_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
virtual ~SwXFilterOptions() override
virtual VclPtr< AbstractSwAsciiFilterDlg > CreateSwAsciiFilterDlg(weld::Window *pParent, SwDocShell &rDocSh, SvStream *pStream)=0
void ensure()
Definition: swdll.cxx:67
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
const css::uno::Any & get(const OUString &_rValueName) const
float u
unsigned char sal_Bool
OUString aPropName
static SwAbstractDialogFactory * Create()
Definition: swabstdlg.cxx:36
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
css::uno::Reference< css::awt::XWindow > m_xDialogParent
virtual OUString SAL_CALL getImplementationName() override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &rArguments) override
RET_OK
bool has(const OUString &_rValueName) const
virtual void SAL_CALL setTitle(const OUString &aTitle) override
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< css::beans::PropertyValue > &aProps) override
css::uno::Reference< css::lang::XComponent > m_xModel