Tag: cws_src680_hsqlcsv User: fs Date: 2006/10/19 03:15:18 Modified: dba/dbaccess/source/ext/hsqldb/linkedtable.cxx dba/dbaccess/source/ext/hsqldb/linkedtable.hxx dba/dbaccess/source/ext/hsqldb/linkedtable.src
Log: #i69526# some actual connections between the items and the controls File Changes: Directory: /dba/dbaccess/source/ext/hsqldb/ =========================================== File [changed]: linkedtable.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ext/hsqldb/linkedtable.cxx?r1=1.1.2.2&r2=1.1.2.3 Delta lines: +174 -2 --------------------- --- linkedtable.cxx 20 Sep 2006 09:09:31 -0000 1.1.2.2 +++ linkedtable.cxx 19 Oct 2006 10:15:15 -0000 1.1.2.3 @@ -4,9 +4,9 @@ * * $RCSfile: linkedtable.cxx,v $ * -* $Revision: 1.1.2.2 $ +* $Revision: 1.1.2.3 $ * -* last change: $Author: fs $ $Date: 2006/09/20 09:09:31 $ +* last change: $Author: fs $ $Date: 2006/10/19 10:15:15 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -42,6 +42,13 @@ #ifndef DBACCESS_HSQL_MODULE_HXX #include "hsql_module.hxx" #endif +#ifndef DBACCESS_LTE_ITEMS_HXX +#include "lte_items.hxx" +#endif + +#ifndef SFX_ITEMCONNECT_HXX +#include <sfx2/itemconnect.hxx> +#endif //......................................................................... namespace hsqlui @@ -51,6 +58,60 @@ //===================================================================== //= TextFilePage //===================================================================== + typedef ::sfx::SingleControlWrapper< SvxTextEncodingBox, rtl_TextEncoding > EncodingListBoxWrapper_Base; + class EncodingListBoxWrapper :public EncodingListBoxWrapper_Base + { + public: + explicit EncodingListBoxWrapper( SvxTextEncodingBox& _rListBox ); + + virtual bool IsControlDontKnow() const; + virtual void SetControlDontKnow( bool bSet ); + + virtual rtl_TextEncoding GetControlValue() const; + virtual void SetControlValue( rtl_TextEncoding eValue ); + }; + + //--------------------------------------------------------------------- + EncodingListBoxWrapper::EncodingListBoxWrapper( SvxTextEncodingBox& _rListBox ) + :EncodingListBoxWrapper_Base( _rListBox ) + { + } + + //--------------------------------------------------------------------- + bool EncodingListBoxWrapper::IsControlDontKnow() const + { + return ( GetControl().GetSelectEntryCount() == 0 ); + } + + //--------------------------------------------------------------------- + void EncodingListBoxWrapper::SetControlDontKnow( bool bSet ) + { + if ( bSet ) + GetControl().SetNoSelection(); + else + GetControl().SelectTextEncoding( GetControl().GetBestMimeEncoding() ); + } + + //--------------------------------------------------------------------- + rtl_TextEncoding EncodingListBoxWrapper::GetControlValue() const + { + return GetControl().GetSelectTextEncoding(); + } + + //--------------------------------------------------------------------- + void EncodingListBoxWrapper::SetControlValue( rtl_TextEncoding eValue ) + { + GetControl().SelectTextEncoding( eValue ); + } + + //===================================================================== + //= EncodingListBoxConnection + //===================================================================== + typedef ::sfx::ItemControlConnection< ::sfx::UInt16ItemWrapper, EncodingListBoxWrapper > EncodingListBoxConnection; + + //===================================================================== + //= TextFilePage + //===================================================================== //--------------------------------------------------------------------- TextFilePage::TextFilePage( Window* _pParent, const SfxItemSet& _rAttributes ) :SfxTabPage( _pParent, HsqlResId( TP_TEXT_FILE ), _rAttributes ) @@ -66,6 +127,14 @@ ,m_aPreviewTable ( this, ResId( CTL_PREVIEW_TABLE ) ) { FreeResource(); + + m_aCharSetList.SetDropDownLineCount( 20 ); + m_aCharSetList.FillWithMimeAndSelectBest(); + + AddItemConnection( new ::sfx::EditConnection( LSID_FILE_PATH, m_aFileSelection ) ); + AddItemConnection( new ::sfx::CheckBoxConnection( LSID_RELATIVE_PATH, m_aRelative ) ); + AddItemConnection( new ::sfx::CheckBoxConnection( LSID_HEADER_LINE, m_aHeader ) ); + AddItemConnection( new EncodingListBoxConnection( LSID_ENCODING, m_aCharSetList ) ); } //--------------------------------------------------------------------- @@ -96,12 +165,115 @@ ,m_aPreviewTable ( this, ResId( CTL_PREVIEW_TABLE ) ) { FreeResource(); + impl_init(); + + AddItemConnection( new ::sfx::CheckBoxConnection( LSID_ALL_QUOTED, m_aForceQuote ) ); + + m_aControlDepdencies.enableOnRadioCheck( m_aSepOther, m_aCharSepOther ); } //--------------------------------------------------------------------- SfxTabPage* FormatPage::Create( Window* _pParent, const SfxItemSet& _rAttributes ) { return new FormatPage( _pParent, _rAttributes ); + } + + //--------------------------------------------------------------------- + BOOL FormatPage::FillItemSet( SfxItemSet& _rSet ) + { + return SfxTabPage::FillItemSet( _rSet ); + } + + //--------------------------------------------------------------------- + void FormatPage::Reset( const SfxItemSet& _rSet ) + { + SfxTabPage::Reset( _rSet ); + + const SfxStringItem& rSeparatorItem( dynamic_cast< const SfxStringItem& >( _rSet.Get( LSID_FIELD_SEPARATOR ) ) ); + impl_resetSeparatorControls( rSeparatorItem.GetValue() ); + } + + //--------------------------------------------------------------------- + void FormatPage::impl_init() + { + m_aSeparatorDescs.push_back( SeparatorDesc( "\\t", '\t', &m_aSepTab ) ); + m_aSeparatorDescs.push_back( SeparatorDesc( "\\semi", ';', &m_aSepSemi ) ); + m_aSeparatorDescs.push_back( SeparatorDesc( ",", ',', &m_aSepComma ) ); + m_aSeparatorDescs.push_back( SeparatorDesc( "\\space", ' ', &m_aSepSpace ) ); + m_aSeparatorDescs.push_back( SeparatorDesc( "", 0, &m_aSepDefault ) ); + } + + //--------------------------------------------------------------------- + namespace + { + struct SeparatorEscape + { + const sal_Char* pAsciiEscape; + sal_Unicode cSeparator; + }; + + //................................................................. + static const SeparatorEscape* lcl_getSeparatorEscapes() + { + // (only those not already present in FormatPage::m_aSeparatorDescs) + static const SeparatorEscape aSequences[] = + { + { "\\quote", '\"' }, + { "\\apos", '\'' }, + { "\\\\", '\\' }, + { NULL, 0 } + }; + return aSequences; + } + + //................................................................. + /** checks whether the given separator string describes an special, escaped separator, + and if so, returns this spearator. Returns 0 otherwise. + */ + static sal_Unicode lcl_checkForEscapedSeparator( const String& _rSeparator ) + { + if ( !_rSeparator.Len() || ( _rSeparator.GetChar(0) != '\\' ) ) + return 0; + + const SeparatorEscape* pSep = lcl_getSeparatorEscapes(); + while ( pSep->pAsciiEscape ) + { + if ( _rSeparator.EqualsAscii( pSep->pAsciiEscape ) ) + return pSep->cSeparator; + ++pSep; + } + + // it *is* an escaped separator (since it starts with a backslahs), + // but none we know. + OSL_ENSURE( false, "lcl_checkForEscapedSeparator: cannot handle this separator!" ); + return 0; + } + } + + //--------------------------------------------------------------------- + void FormatPage::impl_resetSeparatorControls( const String& _rSeparator ) + { + // can we represent the seprarator with a dedicated radio button? + bool bKnownSep = false; + for ( SeparatorDescArray::const_iterator loop = m_aSeparatorDescs.begin(); + loop != m_aSeparatorDescs.end(); + ++loop + ) + { + bool bCheck = _rSeparator.GetChar(0) == loop->cSeparator; + // note that this also covers the case of _rSeparator being empty, + // which means "Default Separator" + loop->pAssociatedButton->Check( bCheck ); + bKnownSep |= bCheck; + } + + if ( bKnownSep ) + return; + + // we can't. + m_aSepOther.Check( TRUE ); + sal_Unicode cSeparator = lcl_checkForEscapedSeparator( _rSeparator ); + m_aCharSepOther.SetText( cSeparator ? String( cSeparator ) : _rSeparator ); } //===================================================================== File [changed]: linkedtable.hxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ext/hsqldb/linkedtable.hxx?r1=1.1.2.2&r2=1.1.2.3 Delta lines: +53 -12 --------------------- --- linkedtable.hxx 20 Sep 2006 09:09:31 -0000 1.1.2.2 +++ linkedtable.hxx 19 Oct 2006 10:15:15 -0000 1.1.2.3 @@ -4,9 +4,9 @@ * * $RCSfile: linkedtable.hxx,v $ * -* $Revision: 1.1.2.2 $ +* $Revision: 1.1.2.3 $ * -* last change: $Author: fs $ $Date: 2006/09/20 09:09:31 $ +* last change: $Author: fs $ $Date: 2006/10/19 10:15:15 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -36,14 +36,20 @@ #ifndef LINKEDTABLE_HXX #define LINKEDTABLE_HXX +#include <svx/txencbox.hxx> + #include <sfx2/tabdlg.hxx> +#include <svtools/fileurlbox.hxx> +#include <svtools/dialogcontrolling.hxx> + #include <vcl/edit.hxx> #include <vcl/combobox.hxx> #include <vcl/fixed.hxx> #include <vcl/lstbox.hxx> #include <vcl/button.hxx> +#include <vector> //......................................................................... namespace hsqlui @@ -58,12 +64,12 @@ private: FixedLine m_aTableSource; FixedText m_aFile; - ComboBox m_aFileSelection; + ::svt::FileURLBox m_aFileSelection; PushButton m_aSelect; CheckBox m_aRelative; CheckBox m_aHeader; FixedText m_aCharSet; - ListBox m_aCharSetList; + SvxTextEncodingBox m_aCharSetList; FixedLine m_aPreview; Control m_aPreviewTable; @@ -94,10 +100,45 @@ FixedLine m_aPreview; Control m_aPreviewTable; + ::svt::ControlDependencyManager + m_aControlDepdencies; + + private: + struct SeparatorDesc + { + const sal_Char* pEscapedSeparator; + sal_Unicode cSeparator; + RadioButton* pAssociatedButton; + + SeparatorDesc() + :pEscapedSeparator( NULL ) + ,cSeparator( 0 ) + ,pAssociatedButton( NULL ) + { + } + + SeparatorDesc( const sal_Char* _pEscapedSep, sal_Unicode _cSeparator, RadioButton* _pRadioButton ) + :pEscapedSeparator( _pEscapedSep ) + ,cSeparator( _cSeparator ) + ,pAssociatedButton( _pRadioButton ) + { + } + }; + typedef ::std::vector< SeparatorDesc > SeparatorDescArray; + SeparatorDescArray m_aSeparatorDescs; + public: FormatPage( Window* _pParent, const SfxItemSet& _rAttributes ); static SfxTabPage* Create( Window* _pParent, const SfxItemSet& _rAttributes ); + + protected: + virtual BOOL FillItemSet( SfxItemSet& _rSet ); + virtual void Reset( const SfxItemSet& _rSet ); + + private: + void impl_init(); + void impl_resetSeparatorControls( const String& _rSeparator ); }; //===================================================================== File [changed]: linkedtable.src Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ext/hsqldb/linkedtable.src?r1=1.1.2.2&r2=1.1.2.3 Delta lines: +2 -3 ------------------- --- linkedtable.src 20 Sep 2006 09:09:31 -0000 1.1.2.2 +++ linkedtable.src 19 Oct 2006 10:15:15 -0000 1.1.2.3 @@ -4,9 +4,9 @@ * * $RCSfile: linkedtable.src,v $ * -* $Revision: 1.1.2.2 $ +* $Revision: 1.1.2.3 $ * -* last change: $Author: fs $ $Date: 2006/09/20 09:09:31 $ +* last change: $Author: fs $ $Date: 2006/10/19 10:15:15 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -234,7 +234,6 @@ Border = TRUE; Disable = TRUE; - MaxTextLength = 1; }; FixedLine FL_OPTIONS --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
