[Libreoffice-commits] .: 2 commits - officecfg/registry sc/inc sc/source

Eike Rathke erack at kemper.freedesktop.org
Tue Aug 14 06:41:51 PDT 2012


 officecfg/registry/schema/org/openoffice/Office/Calc.xcs |  133 ++++++++
 sc/inc/scabstdlg.hxx                                     |    4 
 sc/source/ui/attrdlg/scdlgfact.cxx                       |    9 
 sc/source/ui/attrdlg/scdlgfact.hxx                       |    3 
 sc/source/ui/dbgui/scuiasciiopt.cxx                      |  243 ++++++++-------
 sc/source/ui/inc/asciiopt.hxx                            |    6 
 sc/source/ui/inc/scuiasciiopt.hxx                        |    7 
 sc/source/ui/unoobj/filtuno.cxx                          |    9 
 sc/source/ui/view/cellsh2.cxx                            |    4 
 sc/source/ui/view/viewfun5.cxx                           |    3 
 10 files changed, 294 insertions(+), 127 deletions(-)

New commits:
commit d26599c3e1dea940439985b46b727cfc22b37c38
Author: Eike Rathke <erack at redhat.com>
Date:   Tue Aug 14 15:35:16 2012 +0200

    changes to "fdo#47674 Save settings for Import Ascii Text Dlg"
    
    * For TextToColumn some fields are preset and not changeable and
      configuration does not provide properties, do not attempt to access
      non-existing properties. In fact unotools/source/config/configmgr.cxx
      mocks about these cases if built with debug.
    * Do not use RTL_CONSTASCII_USTRINGPARAM with new code, OUString knows
      about ASCII literals.
    * Converted an if(meCall==...){}if(meCall==...) to a switch case.
    * Sensible indentation, please ;-)
    
    Change-Id: I6ef78cad3958b6379d17275a716bb62553b07601

diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx
index 753bda6..4a25381 100644
--- a/sc/source/ui/dbgui/scuiasciiopt.cxx
+++ b/sc/source/ui/dbgui/scuiasciiopt.cxx
@@ -121,18 +121,21 @@ static void load_Separators( OUString &sFieldSeparators, OUString &sTextSeparato
 {
     Sequence<Any>aValues;
     const Any *pProperties;
-    Sequence<OUString> aNames(9);
+    Sequence<OUString> aNames( eCall == SC_TEXTTOCOLUMNS ? 4 : 9 );
     OUString* pNames = aNames.getArray();
     OUString aSepPath;
     switch(eCall)
     {
-     case SC_IMPORTFILE : aSepPath=OUString(RTL_CONSTASCII_USTRINGPARAM(SEP_PATH));
-                          break;
-     case SC_PASTETEXT  : aSepPath=OUString(RTL_CONSTASCII_USTRINGPARAM(SEP_PATH_CLPBRD));
-                          break;
-     case SC_TEXTTOCOLUMNS :
-     default            : aSepPath=OUString(RTL_CONSTASCII_USTRINGPARAM(SEP_PATH_TEXT2COL));
-                          break;
+        case SC_IMPORTFILE:
+            aSepPath = SEP_PATH;
+            break;
+        case SC_PASTETEXT:
+            aSepPath = SEP_PATH_CLPBRD;
+            break;
+        case SC_TEXTTOCOLUMNS:
+        default:
+            aSepPath = SEP_PATH_TEXT2COL;
+            break;
     }
     ScLinkConfigItem aItem( aSepPath );
 
@@ -140,61 +143,72 @@ static void load_Separators( OUString &sFieldSeparators, OUString &sTextSeparato
     pNames[1] = OUString(RTL_CONSTASCII_USTRINGPARAM( SEPARATORS ));
     pNames[2] = OUString(RTL_CONSTASCII_USTRINGPARAM( TEXT_SEPARATORS ));
     pNames[3] = OUString(RTL_CONSTASCII_USTRINGPARAM( FIXED_WIDTH ));
-    pNames[4] = OUString(RTL_CONSTASCII_USTRINGPARAM( FROM_ROW ));
-    pNames[5] = OUString(RTL_CONSTASCII_USTRINGPARAM( CHAR_SET ));
-    pNames[6] = OUString(RTL_CONSTASCII_USTRINGPARAM( QUOTED_AS_TEXT ));
-    pNames[7] = OUString(RTL_CONSTASCII_USTRINGPARAM( DETECT_SPECIAL_NUM ));
-    pNames[8] = OUString(RTL_CONSTASCII_USTRINGPARAM( LANGUAGE ));
+    if (eCall != SC_TEXTTOCOLUMNS)
+    {
+        pNames[4] = OUString(RTL_CONSTASCII_USTRINGPARAM( FROM_ROW ));
+        pNames[5] = OUString(RTL_CONSTASCII_USTRINGPARAM( CHAR_SET ));
+        pNames[6] = OUString(RTL_CONSTASCII_USTRINGPARAM( QUOTED_AS_TEXT ));
+        pNames[7] = OUString(RTL_CONSTASCII_USTRINGPARAM( DETECT_SPECIAL_NUM ));
+        pNames[8] = OUString(RTL_CONSTASCII_USTRINGPARAM( LANGUAGE ));
+    }
     aValues = aItem.GetProperties( aNames );
     pProperties = aValues.getConstArray();
+
+    if( pProperties[0].hasValue() )
+        bMergeDelimiters = ScUnoHelpFunctions::GetBoolFromAny( pProperties[0] );
+
     if( pProperties[1].hasValue() )
         pProperties[1] >>= sFieldSeparators;
 
     if( pProperties[2].hasValue() )
         pProperties[2] >>= sTextSeparators;
 
-    if( pProperties[0].hasValue() )
-        bMergeDelimiters = ScUnoHelpFunctions::GetBoolFromAny( pProperties[0] );
-
     if( pProperties[3].hasValue() )
         bFixedWidth = ScUnoHelpFunctions::GetBoolFromAny( pProperties[3] );
 
-    if( pProperties[4].hasValue() )
-        pProperties[4] >>= nFromRow;
+    if (eCall != SC_TEXTTOCOLUMNS)
+    {
+        if( pProperties[4].hasValue() )
+            pProperties[4] >>= nFromRow;
 
-    if( pProperties[5].hasValue() )
-        pProperties[5] >>= nCharSet;
+        if( pProperties[5].hasValue() )
+            pProperties[5] >>= nCharSet;
 
-    if ( pProperties[6].hasValue() )
-        pProperties[6] >>= bQuotedAsText;
+        if ( pProperties[6].hasValue() )
+            pProperties[6] >>= bQuotedAsText;
 
-    if ( pProperties[7].hasValue() )
-        pProperties[7] >>= bDetectSpecialNum;
+        if ( pProperties[7].hasValue() )
+            pProperties[7] >>= bDetectSpecialNum;
 
-    if ( pProperties[8].hasValue() )
-        pProperties[8] >>= nLanguage;
+        if ( pProperties[8].hasValue() )
+            pProperties[8] >>= nLanguage;
+    }
 }
 
 static void save_Separators(
     String maSeparators, String maTxtSep, bool bMergeDelimiters, bool bQuotedAsText,
-    bool bDetectSpecialNum, bool bFixedWidth, sal_Int32 nFromRow, sal_Int32 nCharSet, sal_Int32 nLanguage, ScImportAsciiCall eCall )
+    bool bDetectSpecialNum, bool bFixedWidth, sal_Int32 nFromRow,
+    sal_Int32 nCharSet, sal_Int32 nLanguage, ScImportAsciiCall eCall )
 {
     OUString sFieldSeparators = OUString( maSeparators );
     OUString sTextSeparators = OUString( maTxtSep );
     Sequence<Any> aValues;
     Any *pProperties;
-    Sequence<OUString> aNames(9);
+    Sequence<OUString> aNames( eCall == SC_TEXTTOCOLUMNS ? 4 : 9 );
     OUString* pNames = aNames.getArray();
     OUString aSepPath;
     switch(eCall)
     {
-     case SC_IMPORTFILE : aSepPath=OUString(RTL_CONSTASCII_USTRINGPARAM(SEP_PATH));
-                          break;
-     case SC_PASTETEXT  : aSepPath=OUString(RTL_CONSTASCII_USTRINGPARAM(SEP_PATH_CLPBRD));
-                          break;
-     case SC_TEXTTOCOLUMNS :
-     default            : aSepPath=OUString(RTL_CONSTASCII_USTRINGPARAM(SEP_PATH_TEXT2COL));
-                          break;
+        case SC_IMPORTFILE:
+            aSepPath = SEP_PATH;
+            break;
+        case SC_PASTETEXT:
+            aSepPath = SEP_PATH_CLPBRD;
+            break;
+        case SC_TEXTTOCOLUMNS:
+        default:
+            aSepPath = SEP_PATH_TEXT2COL;
+            break;
     }
     ScLinkConfigItem aItem( aSepPath );
 
@@ -202,22 +216,28 @@ static void save_Separators(
     pNames[1] = OUString(RTL_CONSTASCII_USTRINGPARAM( SEPARATORS ));
     pNames[2] = OUString(RTL_CONSTASCII_USTRINGPARAM( TEXT_SEPARATORS ));
     pNames[3] = OUString(RTL_CONSTASCII_USTRINGPARAM( FIXED_WIDTH ));
-    pNames[4] = OUString(RTL_CONSTASCII_USTRINGPARAM( FROM_ROW ));
-    pNames[5] = OUString(RTL_CONSTASCII_USTRINGPARAM( CHAR_SET ));
-    pNames[6] = OUString(RTL_CONSTASCII_USTRINGPARAM( QUOTED_AS_TEXT ));
-    pNames[7] = OUString(RTL_CONSTASCII_USTRINGPARAM( DETECT_SPECIAL_NUM ));
-    pNames[8] = OUString(RTL_CONSTASCII_USTRINGPARAM( LANGUAGE ));
+    if (eCall != SC_TEXTTOCOLUMNS)
+    {
+        pNames[4] = OUString(RTL_CONSTASCII_USTRINGPARAM( FROM_ROW ));
+        pNames[5] = OUString(RTL_CONSTASCII_USTRINGPARAM( CHAR_SET ));
+        pNames[6] = OUString(RTL_CONSTASCII_USTRINGPARAM( QUOTED_AS_TEXT ));
+        pNames[7] = OUString(RTL_CONSTASCII_USTRINGPARAM( DETECT_SPECIAL_NUM ));
+        pNames[8] = OUString(RTL_CONSTASCII_USTRINGPARAM( LANGUAGE ));
+    }
     aValues = aItem.GetProperties( aNames );
     pProperties = aValues.getArray();
+    ScUnoHelpFunctions::SetBoolInAny( pProperties[0], bMergeDelimiters );
     pProperties[1] <<= sFieldSeparators;
     pProperties[2] <<= sTextSeparators;
-    ScUnoHelpFunctions::SetBoolInAny( pProperties[0], bMergeDelimiters );
     ScUnoHelpFunctions::SetBoolInAny( pProperties[3], bFixedWidth );
-    pProperties[4] <<= nFromRow;
-    pProperties[5] <<= nCharSet;
-    pProperties[6] <<= static_cast<sal_Bool>(bQuotedAsText);
-    pProperties[7] <<= static_cast<sal_Bool>(bDetectSpecialNum);
-    pProperties[8] <<= nLanguage;
+    if (eCall != SC_TEXTTOCOLUMNS)
+    {
+        pProperties[4] <<= nFromRow;
+        pProperties[5] <<= nCharSet;
+        pProperties[6] <<= static_cast<sal_Bool>(bQuotedAsText);
+        pProperties[7] <<= static_cast<sal_Bool>(bDetectSpecialNum);
+        pProperties[8] <<= nLanguage;
+    }
 
     aItem.PutProperties(aNames, aValues);
 }
@@ -281,19 +301,18 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
     FreeResource();
 
     String aName = GetText();
-    if (meCall==SC_IMPORTFILE)
+    switch (meCall)
     {
-        aName.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" - ["));
-        aName += aDatName;
-        aName += ']';
-    }
-    if(meCall == SC_TEXTTOCOLUMNS)
-    {
-     SetText( maStrTextToColumns );
-    }
-    else
-    {
-     SetText( aName );
+        case SC_IMPORTFILE:
+            aName.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" - ["));
+            aName += aDatName;
+            aName += ']';
+            break;
+        case SC_TEXTTOCOLUMNS:
+            SetText( maStrTextToColumns );
+            break;
+        default:
+            SetText( aName );
     }
 
     // Default options are set in officecfg/registry/schema/org/openoffice/Office/Calc.xcs
@@ -439,23 +458,23 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
     aEdOther.SetAccessibleName(aCkbOther.GetText());
     aEdOther.SetAccessibleRelationLabeledBy(&aCkbOther);
 
-    if(meCall == SC_TEXTTOCOLUMNS)
+    if (meCall == SC_TEXTTOCOLUMNS)
     {
-     aFtCharSet.Disable();
-     aLbCharSet.Disable();
-     aFtCustomLang.Disable();
-     aLbCustomLang.SelectLanguage(LANGUAGE_SYSTEM);
-     aLbCustomLang.Disable();
-     aFtRow.Disable();
-     aNfRow.Disable();
-
-    // Quoted field as text option is not used for text-to-columns mode.
-     aCkbQuotedAsText.Check(false);
-     aCkbQuotedAsText.Disable();
-
-    // Always detect special numbers for text-to-columns mode.
-     aCkbDetectNumber.Check();
-     aCkbDetectNumber.Disable();
+        aFtCharSet.Disable();
+        aLbCharSet.Disable();
+        aFtCustomLang.Disable();
+        aLbCustomLang.SelectLanguage(LANGUAGE_SYSTEM);
+        aLbCustomLang.Disable();
+        aFtRow.Disable();
+        aNfRow.Disable();
+
+        // Quoted field as text option is not used for text-to-columns mode.
+        aCkbQuotedAsText.Check(false);
+        aCkbQuotedAsText.Disable();
+
+        // Always detect special numbers for text-to-columns mode.
+        aCkbDetectNumber.Check();
+        aCkbDetectNumber.Disable();
     }
 }
 
commit 597bdd89d108fb8325d81f5b30ffdd0d3ea68072
Author: Laurent Balland-Poirier <laurent.balland-poirier at laposte.net>
Date:   Sat Aug 4 22:07:20 2012 +0200

    fdo#47674 Save settings for Import Ascii Text Dlg
    
    Add save of settings for Paste Unformatted Text and
    Text to Columns.
    Remove useless cSep parameter because default are set in Calc.xcs
    
    Change-Id: Iff4b976f434a63d2d1f56e497852c7c1e763151c

diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
index d9aaabd..97516da 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
@@ -1070,8 +1070,7 @@
                 <prop oor:name="QuotedFieldAsText" oor:type="xs:boolean" oor:nillable="false">
                     <info>
                         <author>kyoshida</author>
-                        <desc>If true, quoted field is always imported as text 
-                            with no exception.</desc>
+                        <desc>If true, quoted field is always imported as text with no exception.</desc>
                         <label>QuotedFieldAsText</label>
                     </info>
                     <value>false</value>
@@ -1141,6 +1140,136 @@
                     <value></value>
                 </prop>
             </group>
+            <group oor:name="ClipboardTextImport">
+                <info>
+                    <desc>Contains setting for Unformatted Text Import from Clipboard</desc>
+                </info>
+                <prop oor:name="MergeDelimiters" oor:type="xs:boolean" oor:nillable="false">
+                    <info>
+                        <author>muthusuba</author>
+                        <desc>Merge Delimiter check box status</desc>
+                        <label>MergeDelimiters</label>
+                    </info>
+                    <value>false</value>
+                </prop>
+                <prop oor:name="QuotedFieldAsText" oor:type="xs:boolean" oor:nillable="false">
+                    <info>
+                        <author>kyoshida</author>
+                        <desc>If true, quoted field is always imported as text with no exception.</desc>
+                        <label>QuotedFieldAsText</label>
+                    </info>
+                    <value>false</value>
+                </prop>
+                <prop oor:name="DetectSpecialNumbers" oor:type="xs:boolean" oor:nillable="false">
+                    <info>
+                        <author>kyoshida</author>
+                        <desc>If true, Calc tries to detect special number format, such as date and scientific notation.</desc>
+                        <label>DetectSpecialNumbers</label>
+                    </info>
+                    <value>true</value>
+                </prop>
+                <prop oor:name="Language" oor:type="xs:int" oor:nillable="false">
+                    <info>
+                        <author>kyoshida</author>
+                        <desc>Language to use for CSV import.  This determines how the numbers are parsed.</desc>
+                        <label>Language</label>
+                    </info>
+                    <value>0</value>
+                </prop>
+                <prop oor:name="Separators" oor:type="xs:string" oor:nillable="false">
+                    <info>
+                        <author>muthusuba</author>
+                        <desc>List of Separators - as a String</desc>
+                        <label>Separators</label>
+                    </info>
+                    <value>	</value>
+                </prop>
+                <prop oor:name="TextSeparators" oor:type="xs:string" oor:nillable="false">
+                    <info>
+                        <author>muthusuba</author>
+                        <desc>Text Separators</desc>
+                        <label>TextSeparators</label>
+                    </info>
+                    <value>"</value>
+                </prop>
+                <prop oor:name="FixedWidth" oor:type="xs:boolean" oor:nillable="false">
+                    <info>
+                        <author>muthusuba</author>
+                        <desc>Fixed width</desc>
+                        <label>FixedWidth</label>
+                    </info>
+                    <value>false</value>
+                </prop>
+                <prop oor:name="FromRow" oor:type="xs:int" oor:nillable="false">
+                    <info>
+                        <author>muthusuba</author>
+                        <desc>From Row</desc>
+                        <label>FromRow</label>
+                    </info>
+                    <value>1</value>
+                </prop>
+                <prop oor:name="CharSet" oor:type="xs:int" oor:nillable="false">
+                    <info>
+                        <author>muthusuba</author>
+                        <desc>Char Set</desc>
+                        <label>CharSet</label>
+                    </info>
+                    <value>-1</value>
+                </prop>
+                <prop oor:name="FixedWidthList" oor:type="xs:string" oor:nillable="false">
+                    <info>
+                        <author>muthusuba</author>
+                        <desc>Fixed Width List of separators</desc>
+                        <label>FixedWidthList</label>
+                    </info>
+                    <value></value>
+                </prop>
+            </group>
+            <group oor:name="TextToColumnsImport">
+                <info>
+                    <desc>Contains setting for Text to Columns Import</desc>
+                </info>
+                <prop oor:name="MergeDelimiters" oor:type="xs:boolean" oor:nillable="false">
+                    <info>
+                        <author>muthusuba</author>
+                        <desc>Merge Delimiter check box status</desc>
+                        <label>MergeDelimiters</label>
+                    </info>
+                    <value>false</value>
+                </prop>
+                <prop oor:name="Separators" oor:type="xs:string" oor:nillable="false">
+                    <info>
+                        <author>muthusuba</author>
+                        <desc>List of Separators - as a String</desc>
+                        <label>Separators</label>
+                    </info>
+                    <value>	</value>
+                </prop>
+                <prop oor:name="TextSeparators" oor:type="xs:string" oor:nillable="false">
+                    <info>
+                        <author>muthusuba</author>
+                        <desc>Text Separators</desc>
+                        <label>TextSeparators</label>
+                    </info>
+                    <value>"</value>
+                </prop>
+                <prop oor:name="FixedWidth" oor:type="xs:boolean" oor:nillable="false">
+                    <info>
+                        <author>muthusuba</author>
+                        <desc>Fixed width</desc>
+                        <label>FixedWidth</label>
+                    </info>
+                    <value>false</value>
+                </prop>
+                <prop oor:name="FixedWidthList" oor:type="xs:string" oor:nillable="false">
+                    <info>
+                        <author>muthusuba</author>
+                        <desc>Fixed Width List of separators</desc>
+                        <label>FixedWidthList</label>
+                    </info>
+                    <value></value>
+                </prop>
+            </group>
         </group>
 		<group oor:name="Calculate">
 			<info>
diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index 58e4659..2dca713 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -38,6 +38,7 @@
 #include "global.hxx"
 #include "pivot.hxx"
 #include "i18npool/lang.h"
+#include "asciiopt.hxx"
 
 #include <tabvwsh.hxx>
 
@@ -65,7 +66,6 @@ class AbstractScImportAsciiDlg : public VclAbstractDialog  //add for ScImportAsc
 {
 public:
     virtual void                        GetOptions( ScAsciiOptions& rOpt ) = 0;
-    virtual void                        SetTextToColumnsMode() = 0;
     virtual void                        SaveParameters() = 0;
 };
 
@@ -342,7 +342,7 @@ public:
 
     virtual     AbstractScImportAsciiDlg * CreateScImportAsciiDlg( Window* pParent, String aDatName, //add for ScImportAsciiDlg
                                                                     SvStream* pInStream, int nId,
-                                                                    sal_Unicode cSep = '\t') = 0;
+                                                                    ScImportAsciiCall eCall) = 0;
 
     virtual     AbstractScTextImportOptionsDlg * CreateScTextImportOptionsDlg( Window* pParent, int nId ) = 0;
 
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index 4dd5292..eb34106 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -161,11 +161,6 @@ void AbstractScImportAsciiDlg_Impl::GetOptions( ScAsciiOptions& rOpt )
     pDlg->GetOptions( rOpt );
 }
 
-void AbstractScImportAsciiDlg_Impl::SetTextToColumnsMode()
-{
-    pDlg->SetTextToColumnsMode();
-}
-
 void AbstractScImportAsciiDlg_Impl::SaveParameters()
 {
     pDlg->SaveParameters();
@@ -657,13 +652,13 @@ bool AbstractScTextImportOptionsDlg_Impl::IsDateConversionSet() const
 
 
 AbstractScImportAsciiDlg * ScAbstractDialogFactory_Impl::CreateScImportAsciiDlg ( Window* pParent, String aDatName,
-                                                    SvStream* pInStream, int nId, sal_Unicode cSep )
+                                                    SvStream* pInStream, int nId, ScImportAsciiCall eCall )
 {
     ScImportAsciiDlg* pDlg=NULL;
     switch ( nId )
     {
         case RID_SCDLG_ASCII :
-            pDlg = new ScImportAsciiDlg( pParent, aDatName,pInStream, cSep );
+            pDlg = new ScImportAsciiDlg( pParent, aDatName,pInStream, eCall );
             break;
         default:
             break;
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index f5b2e91..a6a8ad5 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -119,7 +119,6 @@ class AbstractScImportAsciiDlg_Impl : public AbstractScImportAsciiDlg  //add for
 {
     DECL_ABSTDLG_BASE(AbstractScImportAsciiDlg_Impl, ScImportAsciiDlg)
     virtual void                        GetOptions( ScAsciiOptions& rOpt );
-    virtual void                        SetTextToColumnsMode();
     virtual void                        SaveParameters();
 };
 
@@ -412,7 +411,7 @@ public:
 
     virtual     AbstractScImportAsciiDlg * CreateScImportAsciiDlg( Window* pParent, String aDatName, //add for ScImportAsciiDlg
                                                                     SvStream* pInStream, int nId,
-                                                                    sal_Unicode cSep = '\t');
+                                                                    ScImportAsciiCall eCall);
 
     virtual AbstractScTextImportOptionsDlg * CreateScTextImportOptionsDlg( Window* pParent, int nId );
 
diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx
index 11b2bb3..753bda6 100644
--- a/sc/source/ui/dbgui/scuiasciiopt.cxx
+++ b/sc/source/ui/dbgui/scuiasciiopt.cxx
@@ -43,6 +43,7 @@
 #include <com/sun/star/uno/Any.hxx>
 #include <com/sun/star/uno/Sequence.hxx>
 #include "miscuno.hxx"
+#include <tools/urlobj.hxx>
 
 //! TODO make dynamic
 const SCSIZE ASCIIDLG_MAXROWS                = MAXROWCOUNT;
@@ -63,6 +64,8 @@ using ::rtl::OUString;
 #define DETECT_SPECIAL_NUM  "DetectSpecialNumbers"
 #define LANGUAGE            "Language"
 #define SEP_PATH            "Office.Calc/Dialogs/CSVImport"
+#define SEP_PATH_CLPBRD     "Office.Calc/Dialogs/ClipboardTextImport"
+#define SEP_PATH_TEXT2COL   "Office.Calc/Dialogs/TextToColumnsImport"
 
 // ============================================================================
 
@@ -114,13 +117,24 @@ sal_Unicode lcl_CharFromCombo( ComboBox& rCombo, const String& rList )
 static void load_Separators( OUString &sFieldSeparators, OUString &sTextSeparators,
                              bool &bMergeDelimiters, bool& bQuotedAsText, bool& bDetectSpecialNum,
                              bool &bFixedWidth, sal_Int32 &nFromRow, sal_Int32 &nCharSet,
-                             sal_Int32& nLanguage )
+                             sal_Int32& nLanguage, ScImportAsciiCall eCall )
 {
     Sequence<Any>aValues;
     const Any *pProperties;
     Sequence<OUString> aNames(9);
     OUString* pNames = aNames.getArray();
-    ScLinkConfigItem aItem( OUString(RTL_CONSTASCII_USTRINGPARAM( SEP_PATH )) );
+    OUString aSepPath;
+    switch(eCall)
+    {
+     case SC_IMPORTFILE : aSepPath=OUString(RTL_CONSTASCII_USTRINGPARAM(SEP_PATH));
+                          break;
+     case SC_PASTETEXT  : aSepPath=OUString(RTL_CONSTASCII_USTRINGPARAM(SEP_PATH_CLPBRD));
+                          break;
+     case SC_TEXTTOCOLUMNS :
+     default            : aSepPath=OUString(RTL_CONSTASCII_USTRINGPARAM(SEP_PATH_TEXT2COL));
+                          break;
+    }
+    ScLinkConfigItem aItem( aSepPath );
 
     pNames[0] = OUString(RTL_CONSTASCII_USTRINGPARAM( MERGE_DELIMITERS ));
     pNames[1] = OUString(RTL_CONSTASCII_USTRINGPARAM( SEPARATORS ));
@@ -163,7 +177,7 @@ static void load_Separators( OUString &sFieldSeparators, OUString &sTextSeparato
 
 static void save_Separators(
     String maSeparators, String maTxtSep, bool bMergeDelimiters, bool bQuotedAsText,
-    bool bDetectSpecialNum, bool bFixedWidth, sal_Int32 nFromRow, sal_Int32 nCharSet, sal_Int32 nLanguage )
+    bool bDetectSpecialNum, bool bFixedWidth, sal_Int32 nFromRow, sal_Int32 nCharSet, sal_Int32 nLanguage, ScImportAsciiCall eCall )
 {
     OUString sFieldSeparators = OUString( maSeparators );
     OUString sTextSeparators = OUString( maTxtSep );
@@ -171,7 +185,18 @@ static void save_Separators(
     Any *pProperties;
     Sequence<OUString> aNames(9);
     OUString* pNames = aNames.getArray();
-    ScLinkConfigItem aItem( OUString(RTL_CONSTASCII_USTRINGPARAM( SEP_PATH )) );
+    OUString aSepPath;
+    switch(eCall)
+    {
+     case SC_IMPORTFILE : aSepPath=OUString(RTL_CONSTASCII_USTRINGPARAM(SEP_PATH));
+                          break;
+     case SC_PASTETEXT  : aSepPath=OUString(RTL_CONSTASCII_USTRINGPARAM(SEP_PATH_CLPBRD));
+                          break;
+     case SC_TEXTTOCOLUMNS :
+     default            : aSepPath=OUString(RTL_CONSTASCII_USTRINGPARAM(SEP_PATH_TEXT2COL));
+                          break;
+    }
+    ScLinkConfigItem aItem( aSepPath );
 
     pNames[0] = OUString(RTL_CONSTASCII_USTRINGPARAM( MERGE_DELIMITERS ));
     pNames[1] = OUString(RTL_CONSTASCII_USTRINGPARAM( SEPARATORS ));
@@ -200,7 +225,7 @@ static void save_Separators(
 // ----------------------------------------------------------------------------
 
 ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
-                                    SvStream* pInStream, sal_Unicode cSep ) :
+                                    SvStream* pInStream, ScImportAsciiCall eCall ) :
         ModalDialog ( pParent, ScResId( RID_SCDLG_ASCII ) ),
         mpDatStream  ( pInStream ),
         mnStreamPos( pInStream ? pInStream->Tell() : 0 ),
@@ -251,41 +276,39 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
         aTextSepList( ScResId( SCSTR_TEXTSEP ) ),
         mcTextSep   ( ScAsciiOptions::cDefaultTextSep ),
         maStrTextToColumns( ScResId( STR_TEXTTOCOLUMNS ) ),
-        mbFileImport(true)
+        meCall(eCall)
 {
     FreeResource();
-    mbFileImport = aDatName.Len() > 0;
 
     String aName = GetText();
-    // aDatName is empty if invoked during paste from clipboard.
-    if (mbFileImport)
+    if (meCall==SC_IMPORTFILE)
     {
         aName.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" - ["));
         aName += aDatName;
         aName += ']';
     }
-    SetText( aName );
+    if(meCall == SC_TEXTTOCOLUMNS)
+    {
+     SetText( maStrTextToColumns );
+    }
+    else
+    {
+     SetText( aName );
+    }
 
-    // Default options
+    // Default options are set in officecfg/registry/schema/org/openoffice/Office/Calc.xcs
     OUString sFieldSeparators(RTL_CONSTASCII_USTRINGPARAM(",;\t"));
     OUString sTextSeparators(mcTextSep);
     bool bMergeDelimiters = false;
     bool bFixedWidth = false;
     bool bQuotedFieldAsText = false;
-    bool bDetectSpecialNum = false;
+    bool bDetectSpecialNum = true;
     sal_Int32 nFromRow = 1;
     sal_Int32 nCharSet = -1;
     sal_Int32 nLanguage = 0;
-    if (mbFileImport)
-        // load separators only when importing csv files.
-        load_Separators (sFieldSeparators, sTextSeparators, bMergeDelimiters,
-                         bQuotedFieldAsText, bDetectSpecialNum, bFixedWidth, nFromRow, nCharSet, nLanguage);
-    else
-    {
-        // #i115474# otherwise use sensible defaults
-        sFieldSeparators = OUString( cSep );
-        sTextSeparators = OUString( ScAsciiOptions::cDefaultTextSep );
-    }
+    load_Separators (sFieldSeparators, sTextSeparators, bMergeDelimiters,
+                         bQuotedFieldAsText, bDetectSpecialNum, bFixedWidth, nFromRow, nCharSet, nLanguage, meCall);
+    // load from saved settings
     maFieldSeparators = String(sFieldSeparators);
 
     if( bMergeDelimiters )
@@ -299,29 +322,14 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
     if( nFromRow != 1 )
         aNfRow.SetValue( nFromRow );
 
-    rtl::OString sString(rtl::OUStringToOString(maFieldSeparators,
-        RTL_TEXTENCODING_MS_1252));
-    const sal_Char *aSep = sString.getStr();
-    int len = maFieldSeparators.Len();
-    for (int i = 0; i < len; ++i)
-    {
-        switch( aSep[i] )
-        {
-            case '\t':  aCkbTab.Check();        break;
-            case ';':   aCkbSemicolon.Check();  break;
-            case ',':   aCkbComma.Check();      break;
-            case ' ':   aCkbSpace.Check();      break;
-            default:
-                aCkbOther.Check();
-                aEdOther.SetText( aEdOther.GetText() + OUString( aSep[i] ) );
-        }
-    }
+    // Set Separators in the dialog from maFieldSeparators (empty are not set)
+    SetSeparators();
 
-    // Get Separators from the dialog
+    // Get Separators from the dialog (empty are set from default)
     maFieldSeparators = GetSeparators();
 
     // Clipboard is always Unicode, else detect.
-    rtl_TextEncoding ePreselectUnicode = (mbFileImport ?
+    rtl_TextEncoding ePreselectUnicode = (meCall == SC_IMPORTFILE ?
             RTL_TEXTENCODING_DONTKNOW : RTL_TEXTENCODING_UNICODE);
     // Sniff for Unicode / not
     if( ePreselectUnicode == RTL_TEXTENCODING_DONTKNOW && mpDatStream )
@@ -430,6 +438,25 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
 
     aEdOther.SetAccessibleName(aCkbOther.GetText());
     aEdOther.SetAccessibleRelationLabeledBy(&aCkbOther);
+
+    if(meCall == SC_TEXTTOCOLUMNS)
+    {
+     aFtCharSet.Disable();
+     aLbCharSet.Disable();
+     aFtCustomLang.Disable();
+     aLbCustomLang.SelectLanguage(LANGUAGE_SYSTEM);
+     aLbCustomLang.Disable();
+     aFtRow.Disable();
+     aNfRow.Disable();
+
+    // Quoted field as text option is not used for text-to-columns mode.
+     aCkbQuotedAsText.Check(false);
+     aCkbQuotedAsText.Disable();
+
+    // Always detect special numbers for text-to-columns mode.
+     aCkbDetectNumber.Check();
+     aCkbDetectNumber.Disable();
+    }
 }
 
 
@@ -527,38 +554,35 @@ void ScImportAsciiDlg::GetOptions( ScAsciiOptions& rOpt )
     rOpt.SetDetectSpecialNumber(aCkbDetectNumber.IsChecked());
 }
 
-void ScImportAsciiDlg::SetTextToColumnsMode()
-{
-    SetText( maStrTextToColumns );
-    aFtCharSet.Disable();
-    aLbCharSet.Disable();
-    aFtCustomLang.Disable();
-    aLbCustomLang.SelectLanguage(LANGUAGE_SYSTEM);
-    aLbCustomLang.Disable();
-    aFtRow.Disable();
-    aNfRow.Disable();
-
-    // Quoted field as text option is not used for text-to-columns mode.
-    aCkbQuotedAsText.Check(false);
-    aCkbQuotedAsText.Disable();
-
-    // Always detect special numbers for text-to-columns mode.
-    aCkbDetectNumber.Check();
-    aCkbDetectNumber.Disable();
-}
-
 void ScImportAsciiDlg::SaveParameters()
 {
-    if (!mbFileImport)
-        // We save parameters only for file import.
-        return;
-
     save_Separators( maFieldSeparators, aCbTextSep.GetText(), aCkbAsOnce.IsChecked(),
                      aCkbQuotedAsText.IsChecked(), aCkbDetectNumber.IsChecked(),
                      aRbFixed.IsChecked(),
                      static_cast<sal_Int32>(aNfRow.GetValue()),
                      static_cast<sal_Int32>(aLbCharSet.GetSelectEntryPos()),
-                     static_cast<sal_Int32>(aLbCustomLang.GetSelectLanguage()) );
+                     static_cast<sal_Int32>(aLbCustomLang.GetSelectLanguage()), meCall );
+}
+
+void ScImportAsciiDlg::SetSeparators()
+{
+    rtl::OString sString(rtl::OUStringToOString(maFieldSeparators,
+        RTL_TEXTENCODING_MS_1252));
+    const sal_Char *aSep = sString.getStr();
+    int len = maFieldSeparators.Len();
+    for (int i = 0; i < len; ++i)
+    {
+        switch( aSep[i] )
+        {
+            case '\t':  aCkbTab.Check();        break;
+            case ';':   aCkbSemicolon.Check();  break;
+            case ',':   aCkbComma.Check();      break;
+            case ' ':   aCkbSpace.Check();      break;
+            default:
+                aCkbOther.Check();
+               aEdOther.SetText( aEdOther.GetText() + OUString( aSep[i] ) );
+        }
+    }
 }
 
 void ScImportAsciiDlg::SetSelectedCharSet()
diff --git a/sc/source/ui/inc/asciiopt.hxx b/sc/source/ui/inc/asciiopt.hxx
index 53a22dd..45107c1 100644
--- a/sc/source/ui/inc/asciiopt.hxx
+++ b/sc/source/ui/inc/asciiopt.hxx
@@ -107,6 +107,12 @@ public:
     void    SetColumnInfo( const ScCsvExpDataVec& rDataVec );
 };
 
+/// How ScImportAsciiDlg is called
+enum ScImportAsciiCall {
+        SC_IMPORTFILE,           // with File > Open: Text - CSV
+        SC_PASTETEXT,            // with Paste > Unformatted Text
+        SC_TEXTTOCOLUMNS };      // with Data > Text to Columns
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/scuiasciiopt.hxx b/sc/source/ui/inc/scuiasciiopt.hxx
index c45b9ac..e95103c 100644
--- a/sc/source/ui/inc/scuiasciiopt.hxx
+++ b/sc/source/ui/inc/scuiasciiopt.hxx
@@ -94,21 +94,22 @@ class ScImportAsciiDlg : public ModalDialog
 
     CharSet                     meCharSet;          /// Selected char set.
     bool                        mbCharSetSystem;    /// Is System char set selected?
-    bool                        mbFileImport;       /// Is this dialog involked for csv file import ?
+    ScImportAsciiCall           meCall;             /// How the dialog is called (see asciiopt.hxx)
 
 public:
                                 ScImportAsciiDlg(
                                     Window* pParent, String aDatName,
-                                    SvStream* pInStream, sal_Unicode cSep = '\t' );
+                                    SvStream* pInStream, ScImportAsciiCall eCall );
                                 ~ScImportAsciiDlg();
 
     void                        GetOptions( ScAsciiOptions& rOpt );
-    void                        SetTextToColumnsMode();
     void                        SaveParameters();
 
 private:
     /** Sets the selected char set data to meCharSet and mbCharSetSystem. */
     void                        SetSelectedCharSet();
+    /** Set separators in ui from maFieldSeparators    */
+    void                        SetSeparators();
     /** Returns all separator characters in a string. */
     String                      GetSeparators() const;
 
diff --git a/sc/source/ui/unoobj/filtuno.cxx b/sc/source/ui/unoobj/filtuno.cxx
index 6180743..1d35a9c 100644
--- a/sc/source/ui/unoobj/filtuno.cxx
+++ b/sc/source/ui/unoobj/filtuno.cxx
@@ -211,19 +211,12 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() throw(uno::RuntimeException)
         //  ascii import is special...
 
         INetURLObject aURL( aFileName );
-        String aExt(aURL.getExtension());
         String aPrivDatName(aURL.getName());
-        sal_Unicode cAsciiDel;
-        if (aExt.EqualsIgnoreCaseAscii("CSV"))
-            cAsciiDel = ',';
-        else
-            cAsciiDel = '\t';
-
         SvStream* pInStream = NULL;
         if ( xInputStream.is() )
             pInStream = utl::UcbStreamHelper::CreateStream( xInputStream );
 
-        AbstractScImportAsciiDlg* pDlg = pFact->CreateScImportAsciiDlg( NULL, aPrivDatName, pInStream, RID_SCDLG_ASCII, cAsciiDel);
+        AbstractScImportAsciiDlg* pDlg = pFact->CreateScImportAsciiDlg( NULL, aPrivDatName, pInStream, RID_SCDLG_ASCII,SC_IMPORTFILE);
         OSL_ENSURE(pDlg, "Dialog create fail!");
         if ( pDlg->Execute() == RET_OK )
         {
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index 65f89f8..325e713 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -936,9 +936,8 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
                     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
                     OSL_ENSURE( pFact, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pFact is null!" );
                     AbstractScImportAsciiDlg *pDlg = pFact->CreateScImportAsciiDlg(
-                        NULL, String(), &aStream, RID_SCDLG_ASCII );
+                        NULL, String(), &aStream, RID_SCDLG_ASCII,SC_TEXTTOCOLUMNS);
                     OSL_ENSURE( pDlg, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pDlg is null!" );
-                    pDlg->SetTextToColumnsMode();
 
                     if ( pDlg->Execute() == RET_OK )
                     {
@@ -951,6 +950,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
                         ScImportExport aImport( pDoc, aRange.aStart );
                         ScAsciiOptions aOptions;
                         pDlg->GetOptions( aOptions );
+                        pDlg->SaveParameters();
                         aImport.SetExtOptions( aOptions );
                         aImport.SetApi( false );
                         aStream.Seek( 0 );
diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx
index 6f7e890..be970f4 100644
--- a/sc/source/ui/view/viewfun5.cxx
+++ b/sc/source/ui/view/viewfun5.cxx
@@ -340,12 +340,13 @@ sal_Bool ScViewFunc::PasteDataFormat( sal_uLong nFormatId,
                         ScAbstractDialogFactory::Create();
                     AbstractScImportAsciiDlg *pDlg =
                         pFact->CreateScImportAsciiDlg( NULL, String(), &aStrm,
-                                RID_SCDLG_ASCII);
+                                RID_SCDLG_ASCII, SC_PASTETEXT);
 
                     if (pDlg->Execute() == RET_OK)
                     {
                         ScAsciiOptions aOptions;
                         pDlg->GetOptions( aOptions );
+                        pDlg->SaveParameters();
                         aObj.SetExtOptions( aOptions );
 
                         bRet = aObj.ImportString( aStr, nFormatId );


More information about the Libreoffice-commits mailing list