001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037 #include "precompiled_sw.hxx"
038
039 #ifndef _SWXFILTEROPTIONS_HXX
040 #include <SwXFilterOptions.hxx>
041 #endif
042
043 #ifndef _SHELLIO_HXX
044 #include <shellio.hxx>
045 #endif
046 #ifndef SW_SWDLL_HXX
047 #include <swdll.hxx>
048 #endif
049 #ifndef _UNOPRNMS_HXX
050 #include <unoprnms.hxx>
051 #endif
052
053 #ifndef _VOS_MUTEX_HXX_
054 #include <vos/mutex.hxx>
055 #endif
056 #ifndef _SV_SVAPP_HXX
057 #include <vcl/svapp.hxx>
058 #endif
059 #ifndef _SV_MSGBOX_HXX
060 #include <vcl/msgbox.hxx>
061 #endif
062
063 #ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
064 #include <com/sun/star/lang/XUnoTunnel.hpp>
065 #endif
066 #ifndef _COM_SUN_STAR_UI_DIALOGS_EXECUTABLEDIALOGRESULTS_HPP_
067 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
068 #endif
069 #ifndef _UNTOOLS_UCBSTREAMHELPER_HXX
070 #include <unotools/ucbstreamhelper.hxx>
071 #endif
072 #ifndef _UNOTXDOC_HXX
073 #include <unotxdoc.hxx>
074 #endif
075
076 #include "swabstdlg.hxx"
077 #include "dialog.hrc"
078
079 using namespace ::com::sun::star;
080 using namespace ::com::sun::star::ui::dialogs;
081 using namespace ::com::sun::star::document;
082 using namespace ::com::sun::star::lang;
083
084 #define SWFILTEROPTIONSOBJ_SERVICE RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ui.dialogs.FilterOptionsDialog")
085 #define SWFILTEROPTIONSOBJ_IMPLNAME RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Writer.FilterOptionsDialog")
086 #define FILTER_OPTIONS_NAME RTL_CONSTASCII_USTRINGPARAM("FilterOptions")
087
088
089
090 SwXFilterOptions::SwXFilterOptions() :
091 bExport( sal_False )
092 {
093 }
094
095
096
097 SwXFilterOptions::~SwXFilterOptions()
098 {
099 }
100
101
102
103 ::rtl::OUString SwXFilterOptions::getImplementationName_Static()
104 {
105 return ::rtl::OUString(SWFILTEROPTIONSOBJ_IMPLNAME);
106 }
107
108
109
110 uno::Sequence< ::rtl::OUString> SwXFilterOptions::getSupportedServiceNames_Static()
111 {
112 ::rtl::OUString sService(SWFILTEROPTIONSOBJ_SERVICE);
113 return uno::Sequence< ::rtl::OUString> (&sService, 1);
114 }
115
116
117
118 uno::Sequence< beans::PropertyValue > SwXFilterOptions::getPropertyValues() throw (uno::RuntimeException)
119 {
120 uno::Sequence<beans::PropertyValue> aRet(1);
121 beans::PropertyValue* pArray = aRet.getArray();
122
123 pArray[0].Name = rtl::OUString( FILTER_OPTIONS_NAME );
124 pArray[0].Value <<= sFilterOptions;
125
126 return aRet;
127 }
128
129
130
131 void SwXFilterOptions::setPropertyValues( const uno::Sequence<beans::PropertyValue >& aProps )
132 throw (beans::UnknownPropertyException, beans::PropertyVetoException,
133 IllegalArgumentException, WrappedTargetException, uno::RuntimeException)
134 {
135 const beans::PropertyValue* pPropArray = aProps.getConstArray();
136 long nPropCount = aProps.getLength();
137 for (long i = 0; i < nPropCount; i++)
138 {
139 const beans::PropertyValue& rProp = pPropArray[i];
140 ::rtl::OUString aPropName = rProp.Name;
141
142 if ( aPropName.equalsAscii( SW_PROP_NAME_STR(UNO_NAME_FILTER_NAME) ) )
143 rProp.Value >>= sFilterName;
144 else if ( aPropName == ::rtl::OUString(FILTER_OPTIONS_NAME) )
145 rProp.Value >>= sFilterOptions;
146 else if ( aPropName.equalsAscii( "InputStream" ) )
147 rProp.Value >>= xInputStream;
148 }
149 }
150
151
152
153 void SwXFilterOptions::setTitle( const ::rtl::OUString& )
154 throw (uno::RuntimeException)
155 {
156 }
157
158
159
160 sal_Int16 SwXFilterOptions::execute() throw (uno::RuntimeException)
161 {
162 sal_Int16 nRet = ui::dialogs::ExecutableDialogResults::CANCEL;
163
164 SvStream* pInStream = NULL;
165 if ( xInputStream.is() )
166 pInStream = utl::UcbStreamHelper::CreateStream( xInputStream );
167
168 uno::Reference< XUnoTunnel > xTunnel(xModel, uno::UNO_QUERY);
169 SwDocShell* pDocShell = 0;
170 if(xTunnel.is())
171 {
172 SwXTextDocument* pXDoc = reinterpret_cast< SwXTextDocument * >(
173 sal::static_int_cast< sal_IntPtr >(xTunnel->getSomething(SwXTextDocument::getUnoTunnelId())));
174 pDocShell = pXDoc ? pXDoc->GetDocShell() : 0;
175 }
176 if(pDocShell)
177 {
178
179 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
180 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
181
182 AbstractSwAsciiFilterDlg* pAsciiDlg = pFact->CreateSwAsciiFilterDlg( NULL, *pDocShell,pInStream, DLG_ASCII_FILTER );
183 DBG_ASSERT(pAsciiDlg, "Dialogdiet fail!");
184 if(RET_OK == pAsciiDlg->Execute())
185 {
186 SwAsciiOptions aOptions;
187 pAsciiDlg->FillOptions( aOptions );
188 String sTmp;
189 aOptions.WriteUserData(sTmp);
190 sFilterOptions = sTmp;
191 nRet = ui::dialogs::ExecutableDialogResults::OK;
192 }
193 delete pAsciiDlg;
194 }
195
196 if( pInStream )
197 delete pInStream;
198
199 return nRet;
200 }
201
202
203
204 void SwXFilterOptions::setTargetDocument( const uno::Reference< XComponent >& xDoc )
205 throw (IllegalArgumentException, uno::RuntimeException)
206 {
207 bExport = sal_False;
208 xModel = xDoc;
209 }
210
211
212
213 void SwXFilterOptions::setSourceDocument( const uno::Reference<XComponent >& xDoc )
214 throw (IllegalArgumentException,uno::RuntimeException)
215 {
216 bExport = sal_True;
217 xModel = xDoc;
218 }
219
220
221
222 ::rtl::OUString SwXFilterOptions::getImplementationName() throw(uno::RuntimeException)
223 {
224 return ::rtl::OUString(SWFILTEROPTIONSOBJ_IMPLNAME);
225 }
226
227
228
229 sal_Bool SwXFilterOptions::supportsService( const ::rtl::OUString& rServiceName )
230 throw(uno::RuntimeException)
231 {
232 return rServiceName == ::rtl::OUString(SWFILTEROPTIONSOBJ_SERVICE);
233 }
234
235
236
237 uno::Sequence< ::rtl::OUString > SwXFilterOptions::getSupportedServiceNames()
238 throw(uno::RuntimeException)
239 {
240 return SwXFilterOptions::getSupportedServiceNames_Static();
241 }
242
243
244 uno::Reference<uno::XInterface> SAL_CALL SwXFilterOptions_createInstance(
245 const uno::Reference<lang::XMultiServiceFactory>& )
246 {
247 ::vos::OGuard aGuard(Application::GetSolarMutex());
248 SwDLL::Init();
249 return (::cppu::OWeakObject*) new SwXFilterOptions;
250 }
251