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>
29 #include <unotxdoc.hxx>
30 
31 #include <swabstdlg.hxx>
32 #include <memory>
33 
34 using namespace ::com::sun::star;
35 using namespace ::com::sun::star::ui::dialogs;
36 using namespace ::com::sun::star::document;
37 using namespace ::com::sun::star::lang;
38 
39 #define FILTER_OPTIONS_NAME "FilterOptions"
40 
42 {
43 }
44 
46 {
47 }
48 
49 uno::Sequence< beans::PropertyValue > SwXFilterOptions::getPropertyValues()
50 {
53  });
54 }
55 
56 void SwXFilterOptions::setPropertyValues( const uno::Sequence<beans::PropertyValue >& aProps )
57 {
58  for (const beans::PropertyValue& rProp : aProps)
59  {
60  OUString aPropName = rProp.Name;
61 
62  if ( aPropName == FILTER_OPTIONS_NAME )
63  rProp.Value >>= sFilterOptions;
64  else if ( aPropName == "InputStream" )
65  rProp.Value >>= xInputStream;
66  }
67 }
68 
69 void SwXFilterOptions::setTitle( const OUString& /*rTitle*/ )
70 {
71 }
72 
74 {
75  sal_Int16 nRet = ui::dialogs::ExecutableDialogResults::CANCEL;
76 
77  std::unique_ptr<SvStream> pInStream;
78  if ( xInputStream.is() )
80 
81  SwDocShell* pDocShell = nullptr;
82  if (auto pXDoc = comphelper::getUnoTunnelImplementation<SwXTextDocument>(xModel); pXDoc)
83  pDocShell = pXDoc->GetDocShell();
84 
85  if(pDocShell)
86  {
89  pInStream.get()));
90  if(RET_OK == pAsciiDlg->Execute())
91  {
92  SwAsciiOptions aOptions;
93  pAsciiDlg->FillOptions( aOptions );
94  aOptions.WriteUserData(sFilterOptions);
95  nRet = ui::dialogs::ExecutableDialogResults::OK;
96  }
97  }
98 
99  return nRet;
100 }
101 
102 void SwXFilterOptions::setTargetDocument( const uno::Reference< XComponent >& xDoc )
103 {
104  xModel = xDoc;
105 }
106 
107 void SwXFilterOptions::setSourceDocument( const uno::Reference<XComponent >& xDoc )
108 {
109  xModel = xDoc;
110 }
111 
112 void SAL_CALL SwXFilterOptions::initialize(const uno::Sequence<uno::Any>& rArguments)
113 {
115  if (aProperties.has("ParentWindow"))
116  aProperties.get("ParentWindow") >>= xDialogParent;
117 }
118 
120 {
121  return "com.sun.star.comp.Writer.FilterOptionsDialog";
122 }
123 
124 sal_Bool SwXFilterOptions::supportsService( const OUString& rServiceName )
125 {
126  return cppu::supportsService(this, rServiceName);
127 }
128 
130 {
131  return { "com.sun.star.ui.dialogs.FilterOptionsDialog" };
132 }
133 
134 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
136  css::uno::Sequence<css::uno::Any> const &)
137 {
138  SolarMutexGuard aGuard;
139 
140  //the module may not be loaded
142  return cppu::acquire(new SwXFilterOptions());
143 
144 }
145 
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::io::XInputStream > xInputStream
virtual short Execute()=0
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
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
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::Reference< css::awt::XWindow > xDialogParent
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)
unsigned char sal_Bool
static SwAbstractDialogFactory * Create()
Definition: swabstdlg.cxx:36
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
void WriteUserData(OUString &)
Definition: fltini.cxx:571
#define FILTER_OPTIONS_NAME
virtual OUString SAL_CALL getImplementationName() override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &rArguments) override
RET_OK
virtual void SAL_CALL setTitle(const OUString &aTitle) override
bool has(const char *_pAsciiValueName) const
const css::uno::Any & get(const char *_pAsciiValueName) const
css::uno::Reference< css::lang::XComponent > xModel
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< css::beans::PropertyValue > &aProps) override