INTEGRATION: CWS textconnectionsettings (1.13.28); FILE MERGED
2008/03/05 13:10:43 fs 1.13.28.2: #i10000# 2008/03/05 12:55:50 fs 1.13.28.1: #i86720# some re-factoring, owed to the fact that we now have a stand-alone dialog for entering text/csv settings, which re-uses existing functionality
This commit is contained in:
parent
0d11ae7853
commit
2f9b6d82e9
1 changed files with 193 additions and 75 deletions
|
@ -4,9 +4,9 @@
|
|||
*
|
||||
* $RCSfile: TextConnectionHelper.cxx,v $
|
||||
*
|
||||
* $Revision: 1.13 $
|
||||
* $Revision: 1.14 $
|
||||
*
|
||||
* last change: $Author: rt $ $Date: 2008-01-30 08:44:02 $
|
||||
* last change: $Author: kz $ $Date: 2008-03-07 11:21:27 $
|
||||
*
|
||||
* The Contents of this file are made available subject to
|
||||
* the terms of GNU Lesser General Public License Version 2.1.
|
||||
|
@ -55,9 +55,6 @@
|
|||
#include "AutoControls.hrc"
|
||||
#endif
|
||||
|
||||
//#ifndef _DBAUI_DBADMIN_HRC_
|
||||
//#include "dbadmin.hrc"
|
||||
//#endif
|
||||
#ifndef _SFXITEMSET_HXX
|
||||
#include <svtools/itemset.hxx>
|
||||
#endif
|
||||
|
@ -165,31 +162,34 @@ namespace dbaui
|
|||
//========================================================================
|
||||
DBG_NAME(OTextConnectionHelper)
|
||||
//------------------------------------------------------------------------
|
||||
OTextConnectionHelper::OTextConnectionHelper( Window* pParent, sal_Bool _bWizardMode )
|
||||
:Control(pParent)
|
||||
,m_aHeader (pParent, ModuleRes(CB_AUTOHEADER))
|
||||
,m_aLineFormat (pParent, ModuleRes(FL_AUTOSEPARATOR2))
|
||||
,m_aFTExtensionHeader (pParent, ModuleRes(FT_AUTOEXTENSIONHEADER))
|
||||
,m_aRBAccessTextFiles (pParent, ModuleRes(RB_AUTOACCESSCTEXTFILES))
|
||||
,m_aRBAccessCSVFiles (pParent, ModuleRes(RB_AUTOACCESSCCSVFILES))
|
||||
,m_aRBAccessOtherFiles (pParent, ModuleRes(RB_AUTOACCESSOTHERS))
|
||||
,m_aETOwnExtension (pParent, ModuleRes(ET_AUTOOWNEXTENSION))
|
||||
,m_aFTExtensionExample (pParent, ModuleRes(FT_AUTOOWNEXTENSIONAPPENDIX))
|
||||
,m_aFieldSeparatorLabel (pParent, ModuleRes(FT_AUTOFIELDSEPARATOR))
|
||||
,m_aFieldSeparator (pParent, ModuleRes(CM_AUTOFIELDSEPARATOR))
|
||||
,m_aTextSeparatorLabel (pParent, ModuleRes(FT_AUTOTEXTSEPARATOR))
|
||||
,m_aTextSeparator (pParent, ModuleRes(CM_AUTOTEXTSEPARATOR))
|
||||
,m_aDecimalSeparatorLabel (pParent, ModuleRes(FT_AUTODECIMALSEPARATOR))
|
||||
,m_aDecimalSeparator (pParent, ModuleRes(CM_AUTODECIMALSEPARATOR))
|
||||
,m_aThousandsSeparatorLabel (pParent, ModuleRes(FT_AUTOTHOUSANDSSEPARATOR))
|
||||
,m_aThousandsSeparator (pParent, ModuleRes(CM_AUTOTHOUSANDSSEPARATOR))
|
||||
OTextConnectionHelper::OTextConnectionHelper( Window* pParent, const short _nAvailableSections )
|
||||
:Control( pParent, WB_DIALOGCONTROL )
|
||||
,m_aFTExtensionHeader (this, ModuleRes(FT_AUTOEXTENSIONHEADER))
|
||||
,m_aRBAccessTextFiles (this, ModuleRes(RB_AUTOACCESSCTEXTFILES))
|
||||
,m_aRBAccessCSVFiles (this, ModuleRes(RB_AUTOACCESSCCSVFILES))
|
||||
,m_aRBAccessOtherFiles (this, ModuleRes(RB_AUTOACCESSOTHERS))
|
||||
,m_aETOwnExtension (this, ModuleRes(ET_AUTOOWNEXTENSION))
|
||||
,m_aFTExtensionExample (this, ModuleRes(FT_AUTOOWNEXTENSIONAPPENDIX))
|
||||
,m_aLineFormat (this, ModuleRes(FL_AUTOSEPARATOR2))
|
||||
,m_aFieldSeparatorLabel (this, ModuleRes(FT_AUTOFIELDSEPARATOR))
|
||||
,m_aFieldSeparator (this, ModuleRes(CM_AUTOFIELDSEPARATOR))
|
||||
,m_aTextSeparatorLabel (this, ModuleRes(FT_AUTOTEXTSEPARATOR))
|
||||
,m_aTextSeparator (this, ModuleRes(CM_AUTOTEXTSEPARATOR))
|
||||
,m_aDecimalSeparatorLabel (this, ModuleRes(FT_AUTODECIMALSEPARATOR))
|
||||
,m_aDecimalSeparator (this, ModuleRes(CM_AUTODECIMALSEPARATOR))
|
||||
,m_aThousandsSeparatorLabel (this, ModuleRes(FT_AUTOTHOUSANDSSEPARATOR))
|
||||
,m_aThousandsSeparator (this, ModuleRes(CM_AUTOTHOUSANDSSEPARATOR))
|
||||
,m_aRowHeader (this, ModuleRes(CB_AUTOHEADER))
|
||||
,m_aCharSetHeader (this, ModuleRes(FL_DATACONVERT))
|
||||
,m_aCharSetLabel (this, ModuleRes(FT_CHARSET))
|
||||
,m_aCharSet (this, ModuleRes(LB_CHARSET))
|
||||
,m_aFieldSeparatorList (ModuleRes(STR_AUTOFIELDSEPARATORLIST))
|
||||
,m_aTextSeparatorList (ModuleRes(STR_AUTOTEXTSEPARATORLIST))
|
||||
,m_aTextNone (ModuleRes(STR_AUTOTEXT_FIELD_SEP_NONE))
|
||||
,m_nAvailableSections( _nAvailableSections )
|
||||
{
|
||||
DBG_CTOR(OTextConnectionHelper,NULL);
|
||||
|
||||
m_bWizardMode = _bWizardMode;
|
||||
xub_StrLen nCnt = m_aFieldSeparatorList.GetTokenCount( '\t' );
|
||||
xub_StrLen i;
|
||||
|
||||
|
@ -206,6 +206,7 @@ DBG_NAME(OTextConnectionHelper)
|
|||
m_aFieldSeparator.SetSelectHdl(getControlModifiedLink());
|
||||
m_aTextSeparator.SetUpdateDataHdl(getControlModifiedLink());
|
||||
m_aTextSeparator.SetSelectHdl(getControlModifiedLink());
|
||||
m_aCharSet.SetSelectHdl(getControlModifiedLink());
|
||||
|
||||
m_aFieldSeparator.SetModifyHdl(getControlModifiedLink());
|
||||
m_aTextSeparator.SetModifyHdl(getControlModifiedLink());
|
||||
|
@ -216,6 +217,94 @@ DBG_NAME(OTextConnectionHelper)
|
|||
m_aRBAccessCSVFiles.SetToggleHdl(LINK(this, OTextConnectionHelper, OnSetExtensionHdl));
|
||||
m_aRBAccessOtherFiles.SetToggleHdl(LINK(this, OTextConnectionHelper, OnSetExtensionHdl));
|
||||
m_aRBAccessCSVFiles.Check(sal_True);
|
||||
|
||||
struct SectionDescriptor
|
||||
{
|
||||
short nFlag;
|
||||
Window* pFirstControl;
|
||||
} aSections[] = {
|
||||
{ TC_EXTENSION, &m_aFTExtensionHeader },
|
||||
{ TC_SEPARATORS, &m_aLineFormat },
|
||||
{ TC_HEADER, &m_aRowHeader },
|
||||
{ TC_CHARSET, &m_aCharSetHeader },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
for ( size_t section=0; section < sizeof( aSections ) / sizeof( aSections[0] ) - 1; ++section )
|
||||
{
|
||||
if ( ( m_nAvailableSections & aSections[section].nFlag ) != 0 )
|
||||
{
|
||||
// the section is visible, no need to do anything here
|
||||
continue;
|
||||
}
|
||||
|
||||
Window* pThisSection = aSections[section].pFirstControl;
|
||||
Window* pNextSection = aSections[section+1].pFirstControl;
|
||||
|
||||
// hide all elements from this section
|
||||
Window* pControl = pThisSection;
|
||||
while ( ( pControl != pNextSection ) && pControl )
|
||||
{
|
||||
Window* pRealWindow = pControl->GetWindow( WINDOW_CLIENT );
|
||||
#if OSL_DEBUG_LEVEL > 0
|
||||
String sWindowText( pRealWindow->GetText() );
|
||||
(void)sWindowText;
|
||||
#endif
|
||||
pRealWindow->Hide();
|
||||
pControl = pControl->GetWindow( WINDOW_NEXT );
|
||||
}
|
||||
|
||||
// move all controls in following sections up
|
||||
if ( !pNextSection )
|
||||
continue;
|
||||
const long nThisSectionStart = pThisSection->GetPosPixel().Y();
|
||||
const long nNextSectionStart = pNextSection->GetPosPixel().Y();
|
||||
const long nMoveOffset( nThisSectionStart - nNextSectionStart );
|
||||
while ( pControl )
|
||||
{
|
||||
Point aPos = pControl->GetPosPixel();
|
||||
aPos.Move( 0, nMoveOffset );
|
||||
pControl->SetPosPixel( aPos );
|
||||
pControl = pControl->GetWindow( WINDOW_NEXT );
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle aControlRectUnion;
|
||||
for ( Window* pControl = aSections[0].pFirstControl;
|
||||
pControl != NULL;
|
||||
pControl = pControl->GetWindow( WINDOW_NEXT )
|
||||
)
|
||||
{
|
||||
aControlRectUnion = aControlRectUnion.Union( Rectangle( pControl->GetPosPixel(), pControl->GetSizePixel() ) );
|
||||
}
|
||||
|
||||
// need some adjustments to the positions, since the resource-specified
|
||||
// positions for the control were relative to *our* parent, while by now
|
||||
// the controls have |this| as parent.
|
||||
|
||||
// first, move ourself to the upper left of the area occupied by all controls
|
||||
SetPosPixel( aControlRectUnion.TopLeft() );
|
||||
|
||||
// then, compensate in the control positions, by moving them the up/left
|
||||
for ( Window* pControl = aSections[0].pFirstControl;
|
||||
pControl != NULL;
|
||||
pControl = pControl->GetWindow( WINDOW_NEXT )
|
||||
)
|
||||
{
|
||||
Point aPos( pControl->GetPosPixel() );
|
||||
aPos.Move( -aControlRectUnion.Left(), -aControlRectUnion.Top() );
|
||||
pControl->SetPosPixel( aPos );
|
||||
|
||||
// while we are here ... the controls should not have an own background
|
||||
// (this would not be needed when our outer dialog were also the parent
|
||||
// of the controls)
|
||||
pControl->SetBackground();
|
||||
}
|
||||
|
||||
// now, change our own size so all controls fit
|
||||
SetSizePixel( aControlRectUnion.GetSize() );
|
||||
|
||||
SetBackground();
|
||||
Show();
|
||||
}
|
||||
|
||||
|
@ -259,7 +348,8 @@ DBG_NAME(OTextConnectionHelper)
|
|||
_rControlList.push_back(new OSaveValueWrapper<ComboBox>(&m_aTextSeparator));
|
||||
_rControlList.push_back(new OSaveValueWrapper<ComboBox>(&m_aDecimalSeparator));
|
||||
_rControlList.push_back(new OSaveValueWrapper<ComboBox>(&m_aThousandsSeparator));
|
||||
_rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aHeader));
|
||||
_rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aRowHeader));
|
||||
_rControlList.push_back(new OSaveValueWrapper<ListBox>(&m_aCharSet));
|
||||
}
|
||||
// -----------------------------------------------------------------------
|
||||
void OTextConnectionHelper::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
|
||||
|
@ -268,34 +358,47 @@ DBG_NAME(OTextConnectionHelper)
|
|||
_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aTextSeparatorLabel));
|
||||
_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aDecimalSeparatorLabel));
|
||||
_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aThousandsSeparatorLabel));
|
||||
_rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aCharSetHeader));
|
||||
_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aCharSetLabel));
|
||||
_rControlList.push_back(new ODisableWrapper<ListBox>(&m_aCharSet));
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
void OTextConnectionHelper::implInitControls(const SfxItemSet& _rSet, sal_Bool /*_bSaveValue*/, sal_Bool _bValid)
|
||||
void OTextConnectionHelper::implInitControls(const SfxItemSet& _rSet, sal_Bool _bValid)
|
||||
{
|
||||
m_aHeader.Show(!m_bWizardMode);
|
||||
if ( !_bValid )
|
||||
return;
|
||||
|
||||
// first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
|
||||
SFX_ITEMSET_GET(_rSet, pDelItem, SfxStringItem, DSID_FIELDDELIMITER, sal_True);
|
||||
SFX_ITEMSET_GET(_rSet, pStrItem, SfxStringItem, DSID_TEXTDELIMITER, sal_True);
|
||||
SFX_ITEMSET_GET(_rSet, pDecdelItem, SfxStringItem, DSID_DECIMALDELIMITER, sal_True);
|
||||
SFX_ITEMSET_GET(_rSet, pThodelItem, SfxStringItem, DSID_THOUSANDSDELIMITER, sal_True);
|
||||
SFX_ITEMSET_GET(_rSet, pExtensionItem, SfxStringItem, DSID_TEXTFILEEXTENSION, sal_True);
|
||||
if (_bValid)
|
||||
SFX_ITEMSET_GET( _rSet, pDelItem, SfxStringItem, DSID_FIELDDELIMITER, sal_True );
|
||||
SFX_ITEMSET_GET( _rSet, pStrItem, SfxStringItem, DSID_TEXTDELIMITER, sal_True );
|
||||
SFX_ITEMSET_GET( _rSet, pDecdelItem, SfxStringItem, DSID_DECIMALDELIMITER, sal_True );
|
||||
SFX_ITEMSET_GET( _rSet, pThodelItem, SfxStringItem, DSID_THOUSANDSDELIMITER, sal_True );
|
||||
SFX_ITEMSET_GET( _rSet, pExtensionItem, SfxStringItem, DSID_TEXTFILEEXTENSION, sal_True );
|
||||
SFX_ITEMSET_GET( _rSet, pCharsetItem, SfxStringItem, DSID_CHARSET, sal_True );
|
||||
|
||||
if ( ( m_nAvailableSections & TC_EXTENSION ) != 0 )
|
||||
{
|
||||
if (!m_bWizardMode)
|
||||
{
|
||||
SFX_ITEMSET_GET(_rSet, pHdrItem, SfxBoolItem, DSID_TEXTFILEHEADER, sal_True);
|
||||
m_aHeader.Check( pHdrItem->GetValue() );
|
||||
}
|
||||
m_aOldExtension = pExtensionItem->GetValue();
|
||||
SetExtension(m_aOldExtension);
|
||||
SetSeparator(m_aFieldSeparator, m_aFieldSeparatorList, pDelItem->GetValue());
|
||||
SetSeparator(m_aTextSeparator, m_aTextSeparatorList, pStrItem->GetValue());
|
||||
SetExtension( m_aOldExtension );
|
||||
}
|
||||
|
||||
m_aDecimalSeparator.SetText(pDecdelItem->GetValue());
|
||||
m_aThousandsSeparator.SetText(pThodelItem->GetValue());
|
||||
m_aETOwnExtension.Show();
|
||||
if ( ( m_nAvailableSections & TC_HEADER ) != 0 )
|
||||
{
|
||||
SFX_ITEMSET_GET( _rSet, pHdrItem, SfxBoolItem, DSID_TEXTFILEHEADER, sal_True );
|
||||
m_aRowHeader.Check( pHdrItem->GetValue() );
|
||||
}
|
||||
|
||||
if ( ( m_nAvailableSections & TC_SEPARATORS ) != 0 )
|
||||
{
|
||||
SetSeparator( m_aFieldSeparator, m_aFieldSeparatorList, pDelItem->GetValue() );
|
||||
SetSeparator( m_aTextSeparator, m_aTextSeparatorList, pStrItem->GetValue() );
|
||||
m_aDecimalSeparator.SetText( pDecdelItem->GetValue() );
|
||||
m_aThousandsSeparator.SetText( pThodelItem->GetValue() );
|
||||
}
|
||||
|
||||
if ( ( m_nAvailableSections & TC_CHARSET ) != 0 )
|
||||
{
|
||||
m_aCharSet.SelectEntryByIanaName( pCharsetItem->GetValue() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -385,42 +488,57 @@ DBG_NAME(OTextConnectionHelper)
|
|||
sal_Bool OTextConnectionHelper::FillItemSet( SfxItemSet& rSet, const sal_Bool _bChangedSomething )
|
||||
{
|
||||
sal_Bool bChangedSomething = _bChangedSomething;
|
||||
if( m_aFieldSeparator.GetText() != m_aFieldSeparator.GetSavedValue() )
|
||||
{
|
||||
rSet.Put( SfxStringItem(DSID_FIELDDELIMITER, GetSeparator( m_aFieldSeparator, m_aFieldSeparatorList) ) );
|
||||
bChangedSomething = sal_True;
|
||||
}
|
||||
if( m_aTextSeparator.GetText() != m_aTextSeparator.GetSavedValue() )
|
||||
{
|
||||
rSet.Put( SfxStringItem(DSID_TEXTDELIMITER, GetSeparator( m_aTextSeparator, m_aTextSeparatorList) ) );
|
||||
bChangedSomething = sal_True;
|
||||
}
|
||||
|
||||
if( m_aDecimalSeparator.GetText() != m_aDecimalSeparator.GetSavedValue() )
|
||||
if ( ( m_nAvailableSections & TC_EXTENSION ) != 0 )
|
||||
{
|
||||
rSet.Put( SfxStringItem(DSID_DECIMALDELIMITER, m_aDecimalSeparator.GetText().Copy(0, 1) ) );
|
||||
bChangedSomething = sal_True;
|
||||
}
|
||||
if( m_aThousandsSeparator.GetText() != m_aThousandsSeparator.GetSavedValue() )
|
||||
{
|
||||
rSet.Put( SfxStringItem(DSID_THOUSANDSDELIMITER, m_aThousandsSeparator.GetText().Copy(0,1) ) );
|
||||
bChangedSomething = sal_True;
|
||||
}
|
||||
String sExtension = GetExtension();
|
||||
if(!m_aOldExtension.Equals(sExtension))
|
||||
{
|
||||
rSet.Put(SfxStringItem(DSID_TEXTFILEEXTENSION, sExtension));
|
||||
bChangedSomething = sal_True;
|
||||
}
|
||||
|
||||
if (!m_bWizardMode)
|
||||
{
|
||||
if( (m_aHeader.GetState() != m_aHeader.GetSavedValue()) )
|
||||
String sExtension = GetExtension();
|
||||
if( !m_aOldExtension.Equals( sExtension ) )
|
||||
{
|
||||
rSet.Put(SfxBoolItem(DSID_TEXTFILEHEADER, m_aHeader.IsChecked()));
|
||||
rSet.Put( SfxStringItem( DSID_TEXTFILEEXTENSION, sExtension ) );
|
||||
bChangedSomething = sal_True;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( m_nAvailableSections & TC_HEADER ) != 0 )
|
||||
{
|
||||
if( (m_aRowHeader.GetState() != m_aRowHeader.GetSavedValue()) )
|
||||
{
|
||||
rSet.Put(SfxBoolItem(DSID_TEXTFILEHEADER, m_aRowHeader.IsChecked()));
|
||||
bChangedSomething = sal_True;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( m_nAvailableSections & TC_SEPARATORS ) != 0 )
|
||||
{
|
||||
if( m_aFieldSeparator.GetText() != m_aFieldSeparator.GetSavedValue() )
|
||||
{
|
||||
rSet.Put( SfxStringItem(DSID_FIELDDELIMITER, GetSeparator( m_aFieldSeparator, m_aFieldSeparatorList) ) );
|
||||
bChangedSomething = sal_True;
|
||||
}
|
||||
if( m_aTextSeparator.GetText() != m_aTextSeparator.GetSavedValue() )
|
||||
{
|
||||
rSet.Put( SfxStringItem(DSID_TEXTDELIMITER, GetSeparator( m_aTextSeparator, m_aTextSeparatorList) ) );
|
||||
bChangedSomething = sal_True;
|
||||
}
|
||||
|
||||
if( m_aDecimalSeparator.GetText() != m_aDecimalSeparator.GetSavedValue() )
|
||||
{
|
||||
rSet.Put( SfxStringItem(DSID_DECIMALDELIMITER, m_aDecimalSeparator.GetText().Copy(0, 1) ) );
|
||||
bChangedSomething = sal_True;
|
||||
}
|
||||
if( m_aThousandsSeparator.GetText() != m_aThousandsSeparator.GetSavedValue() )
|
||||
{
|
||||
rSet.Put( SfxStringItem(DSID_THOUSANDSDELIMITER, m_aThousandsSeparator.GetText().Copy(0,1) ) );
|
||||
bChangedSomething = sal_True;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( m_nAvailableSections & TC_CHARSET ) != 0 )
|
||||
{
|
||||
if ( m_aCharSet.StoreSelectedCharSet( rSet, DSID_CHARSET ) )
|
||||
bChangedSomething = sal_True;
|
||||
}
|
||||
|
||||
return bChangedSomething;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue