[Libreoffice-commits] .: sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Tue Dec 14 19:42:10 PST 2010


 sc/source/ui/docshell/impex.cxx |   14 +++++++++++++-
 sc/source/ui/view/viewfun5.cxx  |   19 +++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)

New commits:
commit ed5d652e91aaf681533e77c3d189b2e9b246e724
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue Dec 14 22:40:31 2010 -0500

    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.

diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index ba9c36e..2ad1225 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 818b602..a5a9ebe 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.


More information about the Libreoffice-commits mailing list