20 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
25 #include <osl/diagnose.h>
33 #include <globstr.hrc>
40 #include <com/sun/star/uno/Any.hxx>
41 #include <com/sun/star/uno/Sequence.hxx>
50 #define SCFILTEROPTIONSOBJ_SERVICE "com.sun.star.ui.dialogs.FilterOptionsDialog"
51 #define SCFILTEROPTIONSOBJ_IMPLNAME "com.sun.star.comp.Calc.FilterOptionsDialog"
55 #define SC_UNONAME_FILENAME "URL"
56 #define SC_UNONAME_FILTERNAME "FilterName"
57 #define SC_UNONAME_FILTEROPTIONS "FilterOptions"
58 #define SC_UNONAME_INPUTSTREAM "InputStream"
60 #define DBF_CHAR_SET "CharSet"
61 #define DBF_SEP_PATH_IMPORT "Office.Calc/Dialogs/DBFImport"
62 #define DBF_SEP_PATH_EXPORT "Office.Calc/Dialogs/DBFExport"
70 charset_from_user_setting,
78 return charsetSource::charset_from_file;
82 const Any *pProperties;
87 aValues = aItem.GetProperties( aNames );
88 pProperties = aValues.getConstArray();
90 if( pProperties[0].hasValue() )
93 pProperties[0] >>= nChar;
96 nCharSet =
static_cast<rtl_TextEncoding
>(nChar);
97 return charsetSource::charset_from_user_setting;
102 nCharSet = RTL_TEXTENCODING_IBM_850;
103 return charsetSource::charset_default;
106 void save_CharSet( rtl_TextEncoding nCharSet,
bool bExport )
114 aValues = aItem.GetProperties( aNames );
115 pProperties = aValues.getArray();
116 pProperties[0] <<=
static_cast<sal_Int32
>(nCharSet);
118 aItem.PutProperties(aNames, aValues);
131 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
150 for (
const beans::PropertyValue& rProp : aProps)
152 OUString aPropName(rProp.Name);
174 sal_Int16 nRet = ui::dialogs::ExecutableDialogResults::CANCEL;
185 OUString aPrivDatName(aURL.
getName());
186 std::unique_ptr<SvStream> pInStream;
198 nRet = ui::dialogs::ExecutableDialogResults::OK;
204 nRet = ui::dialogs::ExecutableDialogResults::OK;
211 if (pDlg->Execute() ==
RET_OK)
216 aBuf.append(OUString::number(static_cast<sal_uInt16>(eLang)));
218 aBuf.append(pDlg->IsDateConversionSet() ?
u'1' :
u'0');
220 nRet = ui::dialogs::ExecutableDialogResults::OK;
228 bool skipDialog =
false;
232 rtl_TextEncoding eEncoding = RTL_TEXTENCODING_DONTKNOW;
242 if (aExt.equalsIgnoreAsciiCase(
"CSV"))
247 aTitle =
ScResId( STR_EXPORT_ASCII );
253 OSL_ENSURE( !bExport,
"Filter Options for Lotus Export is not implemented" );
255 aTitle =
ScResId( STR_IMPORT_LOTUS );
256 eEncoding = RTL_TEXTENCODING_IBM_437;
263 aTitle =
ScResId( STR_EXPORT_DBF );
268 aTitle =
ScResId( STR_IMPORT_DBF );
271 std::unique_ptr<SvStream> pInStream;
274 switch(load_CharSet( eEncoding, bExport, pInStream.get()))
276 case charsetSource::charset_from_file:
279 case charsetSource::charset_from_user_setting:
280 case charsetSource::charset_default:
291 aTitle =
ScResId( STR_EXPORT_DIF );
296 aTitle =
ScResId( STR_IMPORT_DIF );
299 eEncoding = RTL_TEXTENCODING_MS_1252;
312 nRet = ui::dialogs::ExecutableDialogResults::OK;
317 bAscii, &aOptions, &aTitle,
319 if ( pDlg->Execute() ==
RET_OK )
321 pDlg->SaveImportOptions();
322 pDlg->GetImportOptions( aOptions );
323 save_CharSet( aOptions.
eCharSet, bExport );
324 nRet = ui::dialogs::ExecutableDialogResults::OK;
327 if (nRet == ui::dialogs::ExecutableDialogResults::OK)
360 if (aProperties.
has(
"ParentWindow"))
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getPropertyValues() override
virtual sal_Int16 SAL_CALL execute() override
virtual void SAL_CALL setTitle(const OUString &aTitle) override
#define SC_UNONAME_FILENAME
css::uno::Reference< css::io::XInputStream > xInputStream
static OUString GetAsciiFilterName()
virtual void GetOptions(ScAsciiOptions &rOpt)=0
static OUString GetHtmlFilterName()
virtual short Execute()=0
static OUString GetWebQueryFilterName()
#define SC_UNONAME_INPUTSTREAM
OUString WriteToString() const
bool dbfReadCharset(rtl_TextEncoding &nCharSet, SvStream *dbf_Stream)
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
PropertiesInfo aProperties
virtual void SAL_CALL setSourceDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &rArguments) override
#define SC_UNONAME_FILTERNAME
static OUString GetLotusFilterName()
static SC_DLLPUBLIC void Init()
DLL-init/exit-code must be linked to the DLL only.
OUString getName(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
OUString ScResId(const char *pId)
#define SCFILTEROPTIONSOBJ_SERVICE
#define SC_SIMPLE_SERVICE_INFO(ClassName, ClassNameAscii, ServiceAscii)
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< css::beans::PropertyValue > &aProps) override
virtual VclPtr< AbstractScTextImportOptionsDlg > CreateScTextImportOptionsDlg(weld::Window *pParent)=0
virtual VclPtr< AbstractScImportOptionsDlg > CreateScImportOptionsDlg(weld::Window *pParent, bool bAscii, const ScImportOptions *pOptions, const OUString *pStrTitle, bool bOnlyDbtoolsEncodings, bool bImport=true)=0
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_FilterOptionsDialog_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
virtual VclPtr< AbstractScImportAsciiDlg > CreateScImportAsciiDlg(weld::Window *pParent, const OUString &aDatName, SvStream *pInStream, ScImportAsciiCall eCall)=0
static SC_DLLPUBLIC ScAbstractDialogFactory * Create()
static OUString GetDBaseFilterName()
bool has(const char *_pAsciiValueName) const
#define DBF_SEP_PATH_IMPORT
OUString BuildString() const
css::uno::Reference< css::awt::XWindow > xDialogParent
rtl_TextEncoding eCharSet
#define SCFILTEROPTIONSOBJ_IMPLNAME
const css::uno::Any & get(const char *_pAsciiValueName) const
#define DBF_SEP_PATH_EXPORT
virtual void SaveParameters()=0
virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
#define SC_UNONAME_FILTEROPTIONS
virtual ~ScFilterOptionsObj() override
OUString getExtension(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
static OUString GetDifFilterName()