diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2010-12-14 22:40:31 -0500 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2010-12-14 22:40:31 -0500 |
commit | ed5d652e91aaf681533e77c3d189b2e9b246e724 (patch) | |
tree | 52bbaf7a154bc6356dcd8da66dd05a3547316794 | |
parent | 568229e5a07ab0082b7c172f48a2905abbb112a1 (diff) |
Provide import options when pasting HTML data. (fdo#32400)
When importing an html document, we launch text import options to
provide several options for the user. Let's do the same when
pasting html data too.
-rw-r--r-- | sc/source/ui/docshell/impex.cxx | 14 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun5.cxx | 19 |
2 files changed, 32 insertions, 1 deletions
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index ba9c36e90..2ad12257e 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -2035,7 +2035,19 @@ BOOL ScImportExport::HTML2Doc( SvStream& rStrm, const String& rBaseURL ) USHORT nFlags = IDF_ALL & ~IDF_STYLES; pDoc->DeleteAreaTab( aRange, nFlags ); - pImp->WriteToDocument(); + + if (pExtOptions) + { + // Pick up import options if available. + LanguageType eLang = pExtOptions->GetLanguage(); + SvNumberFormatter aNumFormatter(pDoc->GetServiceManager(), eLang); + bool bSpecialNumber = pExtOptions->IsDetectSpecialNumber(); + pImp->WriteToDocument(false, 1.0, &aNumFormatter, bSpecialNumber); + } + else + // Regular import, with no options. + pImp->WriteToDocument(); + EndPaste(); } delete pImp; diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx index 818b602da..a5a9ebedd 100644 --- a/sc/source/ui/view/viewfun5.cxx +++ b/sc/source/ui/view/viewfun5.cxx @@ -320,8 +320,27 @@ BOOL ScViewFunc::PasteDataFormat( ULONG nFormatId, ::rtl::OUString aStr; SotStorageStreamRef xStream; if ( aDataHelper.GetSotStorageStream( nFormatId, xStream ) && xStream.Is() ) + { + if (nFormatId == SOT_FORMATSTR_ID_HTML) + { + // Launch the text import options dialog. For now, we do + // this for html pasting only, but in the future it may + // make sense to do it for other data types too. + ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); + ::std::auto_ptr<AbstractScTextImportOptionsDlg> pDlg( + pFact->CreateScTextImportOptionsDlg(NULL, RID_SCDLG_TEXT_IMPORT_OPTIONS)); + + if (pDlg->Execute() == RET_OK) + { + ScAsciiOptions aOptions; + aOptions.SetLanguage(pDlg->GetLanguageType()); + aOptions.SetDetectSpecialNumber(pDlg->IsDateConversionSet()); + aObj.SetExtOptions(aOptions); + } + } // mba: clipboard always must contain absolute URLs (could be from alien source) bRet = aObj.ImportStream( *xStream, String(), nFormatId ); + } else if (nFormatId == FORMAT_STRING && aDataHelper.GetString( nFormatId, aStr )) { // Do CSV dialog if more than one line. |