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 <unoprnms.hxx>
24 #include <vcl/svapp.hxx>
25 #include <com/sun/star/lang/XUnoTunnel.hpp>
26 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
31 #include <unotxdoc.hxx>
32 
33 #include <swabstdlg.hxx>
34 #include <memory>
35 
36 using namespace ::com::sun::star;
37 using namespace ::com::sun::star::ui::dialogs;
38 using namespace ::com::sun::star::document;
39 using namespace ::com::sun::star::lang;
40 
41 #define FILTER_OPTIONS_NAME "FilterOptions"
42 
44 {
45 }
46 
48 {
49 }
50 
51 uno::Sequence< beans::PropertyValue > SwXFilterOptions::getPropertyValues()
52 {
55  });
56 }
57 
58 void SwXFilterOptions::setPropertyValues( const uno::Sequence<beans::PropertyValue >& aProps )
59 {
60  for (const beans::PropertyValue& rProp : aProps)
61  {
62  OUString aPropName = rProp.Name;
63 
64  if ( aPropName == FILTER_OPTIONS_NAME )
65  rProp.Value >>= sFilterOptions;
66  else if ( aPropName == "InputStream" )
67  rProp.Value >>= xInputStream;
68  }
69 }
70 
71 void SwXFilterOptions::setTitle( const OUString& /*rTitle*/ )
72 {
73 }
74 
76 {
77  sal_Int16 nRet = ui::dialogs::ExecutableDialogResults::CANCEL;
78 
79  std::unique_ptr<SvStream> pInStream;
80  if ( xInputStream.is() )
82 
83  SwDocShell* pDocShell = nullptr;
84  if (auto pXDoc = comphelper::getUnoTunnelImplementation<SwXTextDocument>(xModel); pXDoc)
85  pDocShell = pXDoc->GetDocShell();
86 
87  if(pDocShell)
88  {
91  pInStream.get()));
92  if(RET_OK == pAsciiDlg->Execute())
93  {
94  SwAsciiOptions aOptions;
95  pAsciiDlg->FillOptions( aOptions );
96  aOptions.WriteUserData(sFilterOptions);
97  nRet = ui::dialogs::ExecutableDialogResults::OK;
98  }
99  }
100 
101  return nRet;
102 }
103 
104 void SwXFilterOptions::setTargetDocument( const uno::Reference< XComponent >& xDoc )
105 {
106  xModel = xDoc;
107 }
108 
109 void SwXFilterOptions::setSourceDocument( const uno::Reference<XComponent >& xDoc )
110 {
111  xModel = xDoc;
112 }
113 
114 void SAL_CALL SwXFilterOptions::initialize(const uno::Sequence<uno::Any>& rArguments)
115 {
116  ::comphelper::NamedValueCollection aProperties(rArguments);
117  if (aProperties.has("ParentWindow"))
118  aProperties.get("ParentWindow") >>= xDialogParent;
119 }
120 
122 {
123  return "com.sun.star.comp.Writer.FilterOptionsDialog";
124 }
125 
126 sal_Bool SwXFilterOptions::supportsService( const OUString& rServiceName )
127 {
128  return cppu::supportsService(this, rServiceName);
129 }
130 
132 {
133  return { "com.sun.star.ui.dialogs.FilterOptionsDialog" };
134 }
135 
136 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
138  css::uno::Sequence<css::uno::Any> const &)
139 {
140  SolarMutexGuard aGuard;
141 
142  //the module may not be loaded
144  return cppu::acquire(new SwXFilterOptions());
145 
146 }
147 
148 /* 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)
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:69
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
bool has(const sal_Char *_pAsciiValueName) const
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:603
#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
css::uno::Reference< css::lang::XComponent > xModel
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< css::beans::PropertyValue > &aProps) override
const css::uno::Any & get(const sal_Char *_pAsciiValueName) const