weld OGeneralPage and OGeneralPageWizard

Change-Id: I7caa08a5e060371c9b80ff83b141c27af09246bf
Reviewed-on: https://gerrit.libreoffice.org/76817
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2019-08-01 17:05:28 +01:00
parent aee3aa2610
commit 57f3009608
7 changed files with 165 additions and 246 deletions

View File

@@ -57,11 +57,10 @@ namespace dbaui
using ::com::sun::star::ui::XImageManager;
using ::com::sun::star::graphic::XGraphic;
Image GetCommandIcon( const sal_Char* _pCommandURL, const OUString& _rModuleName )
Reference< XGraphic> GetCommandIcon( const sal_Char* _pCommandURL, const OUString& _rModuleName )
{
Image aIcon;
if ( !_pCommandURL || !*_pCommandURL )
return aIcon;
return nullptr;
OUString sCommandURL = OUString::createFromAscii( _pCommandURL );
try
@@ -88,27 +87,24 @@ namespace dbaui
if ( !xIconList.hasElements() )
break;
aIcon = Image(Graphic(xIconList[0]).GetBitmapEx());
return xIconList[0];
}
while ( false );
}
catch ( Exception& ) {}
return aIcon;
return nullptr;
}
}
// OpenButton
OpenDocumentButton::OpenDocumentButton( vcl::Window* _pParent, const sal_Char* _pAsciiModuleName )
:PushButton( _pParent )
OpenDocumentButton::OpenDocumentButton(std::unique_ptr<weld::Button> xControl, const sal_Char* _pAsciiModuleName)
: m_xControl(std::move(xControl))
{
impl_init( _pAsciiModuleName );
}
VCL_BUILDER_FACTORY_ARGS( OpenDocumentButton, "com.sun.star.sdb.OfficeDatabaseDocument" );
void OpenDocumentButton::impl_init( const sal_Char* _pAsciiModuleName )
{
OSL_ENSURE( _pAsciiModuleName, "OpenDocumentButton::impl_init: invalid module name!" );
@@ -116,26 +112,20 @@ namespace dbaui
// our label should equal the UI text of the "Open" command
OUString sLabel(vcl::CommandInfoProvider::GetLabelForCommand(".uno:Open", m_sModule));
SetText(" " + sLabel.replaceAll("~", ""));
m_xControl->set_label(" " + sLabel.replaceAll("~", ""));
// Place icon left of text and both centered in the button.
SetModeImage( GetCommandIcon( ".uno:Open", m_sModule ) );
EnableImageDisplay( true );
EnableTextDisplay( true );
SetImageAlign( ImageAlign::Left );
SetStyle( GetStyle() | WB_CENTER );
m_xControl->set_image(GetCommandIcon(".uno:Open", m_sModule));
}
// OpenDocumentListBox
OpenDocumentListBox::OpenDocumentListBox( vcl::Window* _pParent, const sal_Char* _pAsciiModuleName )
:ListBox( _pParent, WB_BORDER | WB_DROPDOWN )
OpenDocumentListBox::OpenDocumentListBox(std::unique_ptr<weld::ComboBox> xControl, const sal_Char* _pAsciiModuleName )
: m_xControl(std::move(xControl))
{
impl_init( _pAsciiModuleName );
}
VCL_BUILDER_FACTORY_ARGS( OpenDocumentListBox, "com.sun.star.sdb.OfficeDatabaseDocument" );
void OpenDocumentListBox::impl_init( const sal_Char* _pAsciiModuleName )
{
OSL_ENSURE( _pAsciiModuleName, "OpenDocumentListBox::impl_init: invalid module name!" );
@@ -179,8 +169,8 @@ namespace dbaui
OUString sDecodedURL = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE );
sal_Int32 nPos = InsertEntry( sTitle );
m_aURLs.emplace( nPos, StringPair( sDecodedURL, sFilter ) );
m_xControl->append_text(sTitle);
m_aURLs.emplace_back(StringPair(sDecodedURL, sFilter));
}
}
catch( Exception& ) {}
@@ -190,50 +180,23 @@ namespace dbaui
OUString OpenDocumentListBox::GetSelectedDocumentURL() const
{
OUString sURL;
sal_Int32 nSelected = GetSelectedEntryPos();
if ( LISTBOX_ENTRY_NOTFOUND != GetSelectedEntryPos() )
sal_Int32 nSelected = m_xControl->get_active();
if (nSelected != -1)
sURL = impl_getDocumentAtIndex( nSelected ).first;
return sURL;
}
OpenDocumentListBox::StringPair OpenDocumentListBox::impl_getDocumentAtIndex( sal_uInt16 _nListIndex, bool _bSystemNotation ) const
{
MapIndexToStringPair::const_iterator pos = m_aURLs.find( _nListIndex );
OSL_ENSURE( pos != m_aURLs.end(), "OpenDocumentListBox::impl_getDocumentAtIndex: invalid index!" );
StringPair aDocumentDescriptor;
if ( pos != m_aURLs.end() )
StringPair aDocumentDescriptor = m_aURLs[_nListIndex];
if ( _bSystemNotation && !aDocumentDescriptor.first.isEmpty() )
{
aDocumentDescriptor = pos->second;
if ( _bSystemNotation && !aDocumentDescriptor.first.isEmpty() )
{
::svt::OFileNotation aNotation( aDocumentDescriptor.first );
aDocumentDescriptor.first = aNotation.get( ::svt::OFileNotation::N_SYSTEM );
}
::svt::OFileNotation aNotation( aDocumentDescriptor.first );
aDocumentDescriptor.first = aNotation.get( ::svt::OFileNotation::N_SYSTEM );
}
return aDocumentDescriptor;
}
void OpenDocumentListBox::RequestHelp( const HelpEvent& _rHEvt )
{
if( !( _rHEvt.GetMode() & HelpEventMode::QUICK ) )
return;
if ( !IsEnabled() )
return;
Point aRequestPos( ScreenToOutputPixel( _rHEvt.GetMousePosPixel() ) );
sal_Int32 nItemIndex = LISTBOX_ENTRY_NOTFOUND;
if ( GetIndexForPoint( aRequestPos, nItemIndex ) != -1 )
{
tools::Rectangle aItemRect( GetBoundingRectangle( nItemIndex ) );
aItemRect = tools::Rectangle(
OutputToScreenPixel( aItemRect.TopLeft() ),
OutputToScreenPixel( aItemRect.BottomRight() ) );
OUString sHelpText = impl_getDocumentAtIndex( nItemIndex, true ).first;
Help::ShowQuickHelp( this, aItemRect, sHelpText, QuickHelpFlags::Left | QuickHelpFlags::VCenter );
}
}
} // namespace dbaui
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -53,17 +53,14 @@ namespace dbaui
using namespace ::com::sun::star::container;
// OGeneralPage
OGeneralPage::OGeneralPage( vcl::Window* pParent, const OUString& _rUIXMLDescription, const SfxItemSet& _rItems )
:OGenericAdministrationPage( pParent, "PageGeneral", _rUIXMLDescription, _rItems )
,m_pSpecialMessage ( nullptr )
,m_eLastMessage ( smNone )
,m_bInitTypeList ( true )
,m_pDatasourceType ( nullptr )
,m_pCollection ( nullptr )
OGeneralPage::OGeneralPage(TabPageParent pParent, const OUString& _rUIXMLDescription, const SfxItemSet& _rItems)
: OGenericAdministrationPage(pParent, _rUIXMLDescription, "PageGeneral", _rItems)
, m_xSpecialMessage(m_xBuilder->weld_label("specialMessage"))
, m_eLastMessage(smNone)
, m_bInitTypeList(true)
, m_xDatasourceType(m_xBuilder->weld_combo_box("datasourceType"))
, m_pCollection(nullptr)
{
get( m_pDatasourceType, "datasourceType" );
get( m_pSpecialMessage, "specialMessage" );
// extract the datasource type collection from the item set
const DbuTypeCollectionItem* pCollectionItem = dynamic_cast<const DbuTypeCollectionItem*>( _rItems.GetItem(DSID_TYPECOLLECTION) );
if (pCollectionItem)
@@ -71,19 +68,11 @@ namespace dbaui
SAL_WARN_IF(!m_pCollection, "dbaccess.ui.generalpage", "OGeneralPage::OGeneralPage : really need a DSN type collection !");
// do some knittings
m_pDatasourceType->SetSelectHdl(LINK(this, OGeneralPage, OnDatasourceTypeSelected));
m_xDatasourceType->connect_changed(LINK(this, OGeneralPage, OnDatasourceTypeSelected));
}
OGeneralPage::~OGeneralPage()
{
disposeOnce();
}
void OGeneralPage::dispose()
{
m_pSpecialMessage.clear();
m_pDatasourceType.clear();
OGenericAdministrationPage::dispose();
}
namespace
@@ -111,7 +100,7 @@ namespace dbaui
if ( m_bInitTypeList )
{
m_bInitTypeList = false;
m_pDatasourceType->Clear();
m_xDatasourceType->clear();
if ( m_pCollection )
{
@@ -131,8 +120,8 @@ namespace dbaui
continue;
OUString sDisplayName = aTypeLoop.getDisplayName();
if ( m_pDatasourceType->GetEntryPos( sDisplayName ) == LISTBOX_ENTRY_NOTFOUND
&& approveDatasourceType( sURLPrefix, sDisplayName ) )
if (m_xDatasourceType->find_text(sDisplayName) == -1 &&
approveDatasourceType(sURLPrefix, sDisplayName))
{
aDisplayedTypes.emplace_back( sURLPrefix, sDisplayName );
}
@@ -150,7 +139,7 @@ namespace dbaui
if ( m_bInitEmbeddedDBList )
{
m_bInitEmbeddedDBList = false;
m_pEmbeddedDBType->Clear();
m_xEmbeddedDBType->clear();
if ( m_pCollection )
{
@@ -166,8 +155,8 @@ namespace dbaui
if ( !sURLPrefix.isEmpty() )
{
OUString sDisplayName = aTypeLoop.getDisplayName();
if ( m_pEmbeddedDBType->GetEntryPos( sDisplayName ) == LISTBOX_ENTRY_NOTFOUND
&& dbaccess::ODsnTypeCollection::isEmbeddedDatabase( sURLPrefix ) )
if (m_xEmbeddedDBType->find_text(sDisplayName) == -1 &&
dbaccess::ODsnTypeCollection::isEmbeddedDatabase(sURLPrefix))
{
aDisplayedTypes.emplace_back( sURLPrefix, sDisplayName );
}
@@ -201,7 +190,7 @@ namespace dbaui
if ( pResId )
sMessage = DBA_RES(pResId);
m_pSpecialMessage->SetText( sMessage );
m_xSpecialMessage->set_label( sMessage );
m_eLastMessage = eMessage;
}
}
@@ -220,7 +209,7 @@ namespace dbaui
{
initializeTypeList();
m_pDatasourceType->SelectEntry( getDatasourceName( _rSet ) );
m_xDatasourceType->set_active_text(getDatasourceName(_rSet));
// notify our listener that our type selection has changed (if so)
// FIXME: how to detect that it did not changed? (fdo#62937)
@@ -254,8 +243,7 @@ namespace dbaui
// select the correct datasource type
if ( dbaccess::ODsnTypeCollection::isEmbeddedDatabase( m_eCurrentSelection )
&& ( LISTBOX_ENTRY_NOTFOUND == m_pEmbeddedDBType->GetEntryPos( sDisplayName ) )
)
&& m_xEmbeddedDBType->find_text(sDisplayName) == -1 )
{ // this indicates it's really a type which is known in general, but not supported on the current platform
// show a message saying so
// eSpecialMessage = smUnsupportedType;
@@ -293,9 +281,8 @@ namespace dbaui
}
// select the correct datasource type
if ( approveDatasourceType( m_eCurrentSelection, sDisplayName )
&& ( LISTBOX_ENTRY_NOTFOUND == m_pDatasourceType->GetEntryPos( sDisplayName ) )
)
if ( approveDatasourceType( m_eCurrentSelection, sDisplayName )
&& m_xDatasourceType->find_text(sDisplayName) == -1 )
{ // this indicates it's really a type which is known in general, but not supported on the current platform
// show a message saying so
// eSpecialMessage = smUnsupportedType;
@@ -336,29 +323,25 @@ namespace dbaui
void OGeneralPage::insertDatasourceTypeEntryData(const OUString& _sType, const OUString& sDisplayName)
{
// insert a (temporary) entry
const sal_Int32 nPos = m_pDatasourceType->InsertEntry(sDisplayName);
if ( static_cast<size_t>(nPos) >= m_aURLPrefixes.size() )
m_aURLPrefixes.resize(nPos+1);
m_aURLPrefixes[nPos] = _sType;
m_xDatasourceType->append_text(sDisplayName);
m_aURLPrefixes.push_back(_sType);
}
void OGeneralPageWizard::insertEmbeddedDBTypeEntryData(const OUString& _sType, const OUString& sDisplayName)
{
// insert a (temporary) entry
const sal_Int32 nPos = m_pEmbeddedDBType->InsertEntry(sDisplayName);
if ( static_cast<size_t>(nPos) >= m_aEmbeddedURLPrefixes.size() )
m_aEmbeddedURLPrefixes.resize(nPos+1);
m_aEmbeddedURLPrefixes[nPos] = _sType;
m_xEmbeddedDBType->append_text(sDisplayName);
m_aEmbeddedURLPrefixes.push_back(_sType);
}
void OGeneralPage::fillWindows(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList)
{
_rControlList.emplace_back( new ODisableWrapper<FixedText>( m_pSpecialMessage ) );
_rControlList.emplace_back(new ODisableWidgetWrapper<weld::Label>(m_xSpecialMessage.get()));
}
void OGeneralPage::fillControls(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList)
{
_rControlList.emplace_back( new OSaveValueWrapper<ListBox>( m_pDatasourceType ) );
_rControlList.emplace_back(new OSaveValueWidgetWrapper<weld::ComboBox>(m_xDatasourceType.get()));
}
void OGeneralPage::implSetCurrentType( const OUString& _eType )
@@ -378,10 +361,10 @@ namespace dbaui
OGenericAdministrationPage::Reset(_rCoreAttrs);
}
IMPL_LINK( OGeneralPageWizard, OnEmbeddedDBTypeSelected, ListBox&, _rBox, void )
IMPL_LINK( OGeneralPageWizard, OnEmbeddedDBTypeSelected, weld::ComboBox&, _rBox, void )
{
// get the type from the entry data
const sal_Int32 nSelected = _rBox.GetSelectedEntryPos();
const sal_Int32 nSelected = _rBox.get_active();
if (static_cast<size_t>(nSelected) >= m_aEmbeddedURLPrefixes.size() )
{
SAL_WARN("dbaccess.ui.generalpage", "Got out-of-range value '" << nSelected << "' from the DatasourceType selection ListBox's GetSelectedEntryPos(): no corresponding URL prefix");
@@ -396,11 +379,11 @@ namespace dbaui
callModifiedHdl();
}
IMPL_LINK( OGeneralPage, OnDatasourceTypeSelected, ListBox&, _rBox, void )
IMPL_LINK( OGeneralPage, OnDatasourceTypeSelected, weld::ComboBox&, _rBox, void )
{
// get the type from the entry data
const sal_Int32 nSelected = _rBox.GetSelectedEntryPos();
if ( nSelected == LISTBOX_ENTRY_NOTFOUND)
const sal_Int32 nSelected = _rBox.get_active();
if (nSelected == -1)
return;
if (static_cast<size_t>(nSelected) >= m_aURLPrefixes.size() )
{
@@ -440,17 +423,17 @@ namespace dbaui
bool bValid, bReadonly;
getFlags(_rSet, bValid, bReadonly );
m_pDatasourceType->Enable( bValid );
m_xDatasourceType->set_sensitive( bValid );
}
bool OGeneralPageDialog::FillItemSet( SfxItemSet* _rCoreAttrs )
{
bool bChangedSomething = false;
const sal_Int32 nEntry = m_pDatasourceType->GetSelectedEntryPos();
const sal_Int32 nEntry = m_xDatasourceType->get_active();
OUString sURLPrefix = m_aURLPrefixes[ nEntry ];
if ( m_pDatasourceType->IsValueChangedFromSaved() )
if (m_xDatasourceType->get_value_changed_from_saved())
{
_rCoreAttrs->Put( SfxStringItem( DSID_CONNECTURL, sURLPrefix ) );
bChangedSomething = true;
@@ -461,27 +444,18 @@ namespace dbaui
// OGeneralPageWizard
OGeneralPageWizard::OGeneralPageWizard( vcl::Window* pParent, const SfxItemSet& _rItems )
:OGeneralPage( pParent, "dbaccess/ui/generalpagewizard.ui", _rItems )
,m_pRB_CreateDatabase ( nullptr )
,m_pRB_OpenExistingDatabase ( nullptr )
,m_pRB_ConnectDatabase ( nullptr )
,m_pFT_EmbeddedDBLabel ( nullptr )
,m_pEmbeddedDBType ( nullptr )
,m_pFT_DocListLabel ( nullptr )
,m_pLB_DocumentList ( nullptr )
,m_pPB_OpenDatabase ( nullptr )
,m_eOriginalCreationMode ( eCreateNew )
,m_bInitEmbeddedDBList ( true )
: OGeneralPage( pParent, "dbaccess/ui/generalpagewizard.ui", _rItems )
, m_xRB_CreateDatabase(m_xBuilder->weld_radio_button("createDatabase"))
, m_xRB_OpenExistingDatabase(m_xBuilder->weld_radio_button("openExistingDatabase"))
, m_xRB_ConnectDatabase(m_xBuilder->weld_radio_button("connectDatabase"))
, m_xFT_EmbeddedDBLabel(m_xBuilder->weld_label("embeddeddbLabel"))
, m_xEmbeddedDBType(m_xBuilder->weld_combo_box("embeddeddbList"))
, m_xFT_DocListLabel(m_xBuilder->weld_label("docListLabel"))
, m_xLB_DocumentList(new OpenDocumentListBox(m_xBuilder->weld_combo_box("documentList"), "com.sun.star.sdb.OfficeDatabaseDocument"))
, m_xPB_OpenDatabase(new OpenDocumentButton(m_xBuilder->weld_button("openDatabase"), "com.sun.star.sdb.OfficeDatabaseDocument"))
, m_eOriginalCreationMode(eCreateNew)
, m_bInitEmbeddedDBList(true)
{
get( m_pRB_CreateDatabase, "createDatabase" );
get( m_pRB_OpenExistingDatabase, "openExistingDatabase" );
get( m_pRB_ConnectDatabase, "connectDatabase" );
get( m_pFT_EmbeddedDBLabel, "embeddeddbLabel" );
get( m_pEmbeddedDBType, "embeddeddbList" );
get( m_pFT_DocListLabel, "docListLabel" );
get( m_pLB_DocumentList, "documentList" );
get( m_pPB_OpenDatabase, "openDatabase" );
// If no driver for embedded DBs is installed, and no dBase driver, then hide the "Create new database" option
sal_Int32 nCreateNewDBIndex = m_pCollection->getIndexOf( dbaccess::ODsnTypeCollection::getEmbeddedDatabase() );
if ( nCreateNewDBIndex == -1 )
@@ -500,44 +474,30 @@ namespace dbaui
if ( bHideCreateNew )
{
m_pRB_CreateDatabase->Hide();
m_pRB_ConnectDatabase->Check();
m_xRB_CreateDatabase->hide();
m_xRB_ConnectDatabase->set_active(true);
}
else
m_pRB_CreateDatabase->Check();
m_xRB_CreateDatabase->set_active(true);
// do some knittings
m_pEmbeddedDBType->SetSelectHdl(LINK(this, OGeneralPageWizard, OnEmbeddedDBTypeSelected));
m_pRB_CreateDatabase->SetClickHdl( LINK( this, OGeneralPageWizard, OnCreateDatabaseModeSelected ) );
m_pRB_ConnectDatabase->SetClickHdl( LINK( this, OGeneralPageWizard, OnSetupModeSelected ) );
m_pRB_OpenExistingDatabase->SetClickHdl( LINK( this, OGeneralPageWizard, OnSetupModeSelected ) );
m_pLB_DocumentList->SetSelectHdl( LINK( this, OGeneralPageWizard, OnDocumentSelected ) );
m_pPB_OpenDatabase->SetClickHdl( LINK( this, OGeneralPageWizard, OnOpenDocument ) );
m_xEmbeddedDBType->connect_changed(LINK(this, OGeneralPageWizard, OnEmbeddedDBTypeSelected));
m_xRB_CreateDatabase->connect_clicked( LINK( this, OGeneralPageWizard, OnCreateDatabaseModeSelected ) );
m_xRB_ConnectDatabase->connect_clicked( LINK( this, OGeneralPageWizard, OnSetupModeSelected ) );
m_xRB_OpenExistingDatabase->connect_clicked( LINK( this, OGeneralPageWizard, OnSetupModeSelected ) );
m_xLB_DocumentList->connect_changed( LINK( this, OGeneralPageWizard, OnDocumentSelected ) );
m_xPB_OpenDatabase->connect_clicked( LINK( this, OGeneralPageWizard, OnOpenDocument ) );
}
OGeneralPageWizard::~OGeneralPageWizard()
{
disposeOnce();
}
void OGeneralPageWizard::dispose()
{
m_pRB_CreateDatabase.clear();
m_pRB_OpenExistingDatabase.clear();
m_pRB_ConnectDatabase.clear();
m_pFT_EmbeddedDBLabel.clear();
m_pEmbeddedDBType.clear();
m_pFT_DocListLabel.clear();
m_pLB_DocumentList.clear();
m_pPB_OpenDatabase.clear();
OGeneralPage::dispose();
}
OGeneralPageWizard::CreationMode OGeneralPageWizard::GetDatabaseCreationMode() const
{
if ( m_pRB_CreateDatabase->IsChecked() )
if ( m_xRB_CreateDatabase->get_active() )
return eCreateNew;
if ( m_pRB_ConnectDatabase->IsChecked() )
if ( m_xRB_ConnectDatabase->get_active() )
return eConnectExternal;
return eOpenExisting;
}
@@ -545,10 +505,10 @@ namespace dbaui
void OGeneralPageWizard::GetFocus()
{
OGeneralPage::GetFocus();
if ( m_pLB_DocumentList && m_pLB_DocumentList->IsEnabled() )
m_pLB_DocumentList->GrabFocus();
else if ( m_pDatasourceType && m_pDatasourceType->IsEnabled() )
m_pDatasourceType->GrabFocus();
if ( m_xLB_DocumentList && m_xLB_DocumentList->get_sensitive() )
m_xLB_DocumentList->grab_focus();
else if ( m_xDatasourceType && m_xDatasourceType->get_sensitive() )
m_xDatasourceType->grab_focus();
}
void OGeneralPageWizard::implInitControls( const SfxItemSet& _rSet, bool _bSaveValue )
@@ -556,7 +516,7 @@ namespace dbaui
OGeneralPage::implInitControls( _rSet, _bSaveValue );
initializeEmbeddedDBList();
m_pEmbeddedDBType->SelectEntry( getEmbeddedDBName( _rSet ) );
m_xEmbeddedDBType->set_active_text(getEmbeddedDBName(_rSet));
// first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
bool bValid, bReadonly;
@@ -564,27 +524,24 @@ namespace dbaui
SetText( OUString() );
LayoutHelper::positionBelow( *m_pRB_ConnectDatabase, *m_pDatasourceType, INDENT_BELOW_RADIO );
if ( !bValid || bReadonly )
{
m_pFT_EmbeddedDBLabel->Enable( false );
m_pDatasourceType->Enable( false );
m_pPB_OpenDatabase->Enable( false );
m_pFT_DocListLabel->Enable( false );
m_pLB_DocumentList->Enable( false );
m_xFT_EmbeddedDBLabel->set_sensitive( false );
m_xDatasourceType->set_sensitive( false );
m_xPB_OpenDatabase->set_sensitive( false );
m_xFT_DocListLabel->set_sensitive( false );
m_xLB_DocumentList->set_sensitive( false );
}
else
{
m_pDatasourceType->Enable( false );
m_pPB_OpenDatabase->Enable( false );
m_pFT_DocListLabel->Enable( false );
m_pLB_DocumentList->Enable( false );
m_xDatasourceType->set_sensitive( false );
m_xPB_OpenDatabase->set_sensitive( false );
m_xFT_DocListLabel->set_sensitive( false );
m_xLB_DocumentList->set_sensitive( false );
}
m_pLB_DocumentList->SetDropDownLineCount( 20 );
if ( m_pLB_DocumentList->GetEntryCount() )
m_pLB_DocumentList->SelectEntryPos( 0 );
if (m_xLB_DocumentList->get_count())
m_xLB_DocumentList->set_active(0);
m_eOriginalCreationMode = GetDatabaseCreationMode();
}
@@ -592,7 +549,7 @@ namespace dbaui
OUString OGeneralPageWizard::getDatasourceName(const SfxItemSet& _rSet)
{
// Sets the default selected database on startup.
if (m_pRB_CreateDatabase->IsChecked() )
if (m_xRB_CreateDatabase->get_active() )
{
return m_pCollection->getTypeDisplayName( "sdbc:firebird:" );
}
@@ -622,15 +579,15 @@ namespace dbaui
bool bCommitTypeSelection = true;
if ( m_pRB_CreateDatabase->IsChecked() )
if ( m_xRB_CreateDatabase->get_active() )
{
_rCoreAttrs->Put( SfxStringItem( DSID_CONNECTURL, "sdbc:dbase:" ) );
bChangedSomething = true;
bCommitTypeSelection = false;
}
else if ( m_pRB_OpenExistingDatabase->IsChecked() )
else if ( m_xRB_OpenExistingDatabase->get_active() )
{
if ( m_pRB_OpenExistingDatabase->IsValueChangedFromSaved() )
if ( m_xRB_OpenExistingDatabase->get_state_changed_from_saved() )
bChangedSomething = true;
// TODO
@@ -639,10 +596,10 @@ namespace dbaui
if ( bCommitTypeSelection )
{
const sal_Int32 nEntry = m_pDatasourceType->GetSelectedEntryPos();
const sal_Int32 nEntry = m_xDatasourceType->get_active();
OUString sURLPrefix = m_aURLPrefixes[nEntry];
if ( m_pDatasourceType->IsValueChangedFromSaved()
if ( m_xDatasourceType->get_value_changed_from_saved()
|| ( GetDatabaseCreationMode() != m_eOriginalCreationMode )
)
{
@@ -660,56 +617,56 @@ namespace dbaui
if ( !m_aBrowsedDocumentURL.isEmpty() )
return m_aBrowsedDocumentURL;
else
return m_pLB_DocumentList->GetSelectedDocumentURL();
return m_xLB_DocumentList->GetSelectedDocumentURL();
}
IMPL_LINK_NOARG( OGeneralPageWizard, OnCreateDatabaseModeSelected, Button*, void )
IMPL_LINK_NOARG( OGeneralPageWizard, OnCreateDatabaseModeSelected, weld::Button&, void )
{
m_aCreationModeHandler.Call( *this );
OnEmbeddedDBTypeSelected( *m_pEmbeddedDBType );
OnEmbeddedDBTypeSelected( *m_xEmbeddedDBType );
bool bValid, bReadonly;
getFlags( GetItemSet(), bValid, bReadonly );
if ( bValid && !bReadonly )
{
m_pEmbeddedDBType->Enable(m_pRB_CreateDatabase->IsChecked());
m_pFT_EmbeddedDBLabel->Enable(m_pRB_CreateDatabase->IsChecked());
m_pDatasourceType->Enable(m_pRB_ConnectDatabase->IsChecked());
m_pPB_OpenDatabase->Enable(m_pRB_OpenExistingDatabase->IsChecked());
m_pFT_DocListLabel->Enable(m_pRB_OpenExistingDatabase->IsChecked());
m_pLB_DocumentList->Enable(m_pRB_OpenExistingDatabase->IsChecked());
m_xEmbeddedDBType->set_sensitive(m_xRB_CreateDatabase->get_active());
m_xFT_EmbeddedDBLabel->set_sensitive(m_xRB_CreateDatabase->get_active());
m_xDatasourceType->set_sensitive(m_xRB_ConnectDatabase->get_active());
m_xPB_OpenDatabase->set_sensitive(m_xRB_OpenExistingDatabase->get_active());
m_xFT_DocListLabel->set_sensitive(m_xRB_OpenExistingDatabase->get_active());
m_xLB_DocumentList->set_sensitive(m_xRB_OpenExistingDatabase->get_active());
}
}
IMPL_LINK_NOARG( OGeneralPageWizard, OnSetupModeSelected, Button*, void )
IMPL_LINK_NOARG( OGeneralPageWizard, OnSetupModeSelected, weld::Button&, void )
{
m_aCreationModeHandler.Call( *this );
OnDatasourceTypeSelected(*m_pDatasourceType);
OnDatasourceTypeSelected(*m_xDatasourceType);
bool bValid, bReadonly;
getFlags( GetItemSet(), bValid, bReadonly );
if ( bValid && !bReadonly )
{
m_pEmbeddedDBType->Enable(m_pRB_CreateDatabase->IsChecked());
m_pFT_EmbeddedDBLabel->Enable(m_pRB_CreateDatabase->IsChecked());
m_pDatasourceType->Enable(m_pRB_ConnectDatabase->IsChecked());
m_pPB_OpenDatabase->Enable(m_pRB_OpenExistingDatabase->IsChecked());
m_pFT_DocListLabel->Enable(m_pRB_OpenExistingDatabase->IsChecked());
m_pLB_DocumentList->Enable(m_pRB_OpenExistingDatabase->IsChecked());
m_xEmbeddedDBType->set_sensitive(m_xRB_CreateDatabase->get_active());
m_xFT_EmbeddedDBLabel->set_sensitive(m_xRB_CreateDatabase->get_active());
m_xDatasourceType->set_sensitive(m_xRB_ConnectDatabase->get_active());
m_xPB_OpenDatabase->set_sensitive(m_xRB_OpenExistingDatabase->get_active());
m_xFT_DocListLabel->set_sensitive(m_xRB_OpenExistingDatabase->get_active());
m_xLB_DocumentList->set_sensitive(m_xRB_OpenExistingDatabase->get_active());
}
}
IMPL_LINK_NOARG( OGeneralPageWizard, OnDocumentSelected, ListBox&, void )
IMPL_LINK_NOARG( OGeneralPageWizard, OnDocumentSelected, weld::ComboBox&, void )
{
m_aDocumentSelectionHandler.Call( *this );
}
IMPL_LINK_NOARG( OGeneralPageWizard, OnOpenDocument, Button*, void )
IMPL_LINK_NOARG( OGeneralPageWizard, OnOpenDocument, weld::Button&, void )
{
::sfx2::FileDialogHelper aFileDlg(
ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
FileDialogFlags::NONE, "sdatabase", SfxFilterFlags::NONE, SfxFilterFlags::NONE, GetFrameWeld());
FileDialogFlags::NONE, "sdatabase", SfxFilterFlags::NONE, SfxFilterFlags::NONE, GetDialogFrameWeld());
std::shared_ptr<const SfxFilter> pFilter = getStandardDatabaseFilter();
if ( pFilter )
{
@@ -724,12 +681,12 @@ namespace dbaui
if ( !pFilter->GetWildcard().Matches(sPath) )
{
OUString sMessage(DBA_RES(STR_ERR_USE_CONNECT_TO));
std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetDialogFrameWeld(),
VclMessageType::Info, VclButtonsType::Ok,
sMessage));
xInfoBox->run();
m_pRB_ConnectDatabase->Check();
OnSetupModeSelected( m_pRB_ConnectDatabase );
m_xRB_ConnectDatabase->set_active(true);
OnSetupModeSelected( *m_xRB_ConnectDatabase );
return;
}
m_aBrowsedDocumentURL = sPath;

View File

@@ -32,12 +32,12 @@ namespace dbaui
class OGeneralPage : public OGenericAdministrationPage
{
protected:
OGeneralPage( vcl::Window* pParent, const OUString& _rUIXMLDescription, const SfxItemSet& _rItems );
OGeneralPage(TabPageParent pParent, const OUString& _rUIXMLDescription, const SfxItemSet& _rItems);
OUString m_eCurrentSelection; /// currently selected type
private:
VclPtr<FixedText> m_pSpecialMessage;
std::unique_ptr<weld::Label> m_xSpecialMessage;
enum SPECIAL_MESSAGE
{
@@ -52,7 +52,7 @@ namespace dbaui
void insertDatasourceTypeEntryData( const OUString& _sType, const OUString& sDisplayName );
protected:
VclPtr<ListBox> m_pDatasourceType;
std::unique_ptr<weld::ComboBox> m_xDatasourceType;
::dbaccess::ODsnTypeCollection*
m_pCollection; /// the DSN type collection instance
@@ -62,7 +62,6 @@ namespace dbaui
public:
virtual ~OGeneralPage() override;
virtual void dispose() override;
/// set a handler which gets called every time the user selects a new type
void SetTypeSelectHandler( const Link<OGeneralPage&,void>& _rHandler ) { m_aTypeSelectHandler = _rHandler; }
@@ -98,7 +97,7 @@ namespace dbaui
/// sets the title of the parent dialog
virtual void setParentTitle( const OUString& _sURLPrefix );
DECL_LINK(OnDatasourceTypeSelected, ListBox&, void);
DECL_LINK(OnDatasourceTypeSelected, weld::ComboBox&, void);
};
// OGeneralPageDialog
@@ -120,7 +119,6 @@ namespace dbaui
public:
OGeneralPageWizard( vcl::Window* pParent, const SfxItemSet& _rItems );
virtual ~OGeneralPageWizard() override;
virtual void dispose() override;
enum CreationMode
{
@@ -131,16 +129,16 @@ namespace dbaui
private:
// dialog controls
VclPtr<RadioButton> m_pRB_CreateDatabase;
VclPtr<RadioButton> m_pRB_OpenExistingDatabase;
VclPtr<RadioButton> m_pRB_ConnectDatabase;
std::unique_ptr<weld::RadioButton> m_xRB_CreateDatabase;
std::unique_ptr<weld::RadioButton> m_xRB_OpenExistingDatabase;
std::unique_ptr<weld::RadioButton> m_xRB_ConnectDatabase;
VclPtr<FixedText> m_pFT_EmbeddedDBLabel;
VclPtr<ListBox> m_pEmbeddedDBType;
std::unique_ptr<weld::Label> m_xFT_EmbeddedDBLabel;
std::unique_ptr<weld::ComboBox> m_xEmbeddedDBType;
VclPtr<FixedText> m_pFT_DocListLabel;
VclPtr<OpenDocumentListBox> m_pLB_DocumentList;
VclPtr<OpenDocumentButton> m_pPB_OpenDatabase;
std::unique_ptr<weld::Label> m_xFT_DocListLabel;
std::unique_ptr<OpenDocumentListBox> m_xLB_DocumentList;
std::unique_ptr<OpenDocumentButton> m_xPB_OpenDatabase;
// state
OUString m_aBrowsedDocumentURL;
@@ -176,11 +174,11 @@ namespace dbaui
OUString getEmbeddedDBName( const SfxItemSet& _rSet );
void initializeEmbeddedDBList();
DECL_LINK( OnEmbeddedDBTypeSelected, ListBox&, void );
DECL_LINK( OnCreateDatabaseModeSelected, Button*, void );
DECL_LINK( OnSetupModeSelected, Button*, void );
DECL_LINK( OnDocumentSelected, ListBox&, void );
DECL_LINK( OnOpenDocument, Button*, void );
DECL_LINK( OnEmbeddedDBTypeSelected, weld::ComboBox&, void );
DECL_LINK( OnCreateDatabaseModeSelected, weld::Button&, void );
DECL_LINK( OnSetupModeSelected, weld::Button&, void );
DECL_LINK( OnDocumentSelected, weld::ComboBox&, void );
DECL_LINK( OnOpenDocument, weld::Button&, void );
};
} // namespace dbaui

View File

@@ -21,7 +21,7 @@
#define INCLUDED_DBACCESS_SOURCE_UI_INC_OPENDOCCONTROLS_HXX
#include <vcl/button.hxx>
#include <vcl/lstbox.hxx>
#include <vcl/weld.hxx>
#include <rtl/ustring.hxx>
#include <map>
@@ -34,35 +34,46 @@ namespace dbaui
The text of the button is the same as for the "Open" command in the application
UI. Additionally, the icon for this command is also displayed on the button.
*/
class OpenDocumentButton final : public PushButton
class OpenDocumentButton
{
private:
OUString m_sModule;
std::unique_ptr<weld::Button> m_xControl;
public:
OpenDocumentButton( vcl::Window* _pParent, const sal_Char* _pAsciiModuleName );
OpenDocumentButton(std::unique_ptr<weld::Button> xControl, const sal_Char* _pAsciiModuleName);
void set_sensitive(bool bSensitive) { m_xControl->set_sensitive(bSensitive); }
bool get_sensitive() const { return m_xControl->get_sensitive(); }
void connect_clicked(const Link<weld::Button&, void>& rLink) { m_xControl->connect_clicked(rLink); }
private:
void impl_init( const sal_Char* _pAsciiModuleName );
};
// OpenDocumentListBox
class OpenDocumentListBox final : public ListBox
class OpenDocumentListBox
{
private:
typedef std::pair< OUString, OUString > StringPair;
typedef std::map< sal_uInt16, StringPair > MapIndexToStringPair;
MapIndexToStringPair m_aURLs;
std::vector<StringPair> m_aURLs;
std::unique_ptr<weld::ComboBox> m_xControl;
public:
OpenDocumentListBox( vcl::Window* _pParent, const sal_Char* _pAsciiModuleName );
OpenDocumentListBox(std::unique_ptr<weld::ComboBox> xControl, const sal_Char* _pAsciiModuleName);
OUString GetSelectedDocumentURL() const;
private:
virtual void RequestHelp( const HelpEvent& _rHEvt ) override;
void set_sensitive(bool bSensitive) { m_xControl->set_sensitive(bSensitive); }
bool get_sensitive() const { return m_xControl->get_sensitive(); }
void grab_focus() { m_xControl->grab_focus(); }
int get_count() { return m_xControl->get_count(); }
void set_active(int nPos) { m_xControl->set_active(nPos); }
void connect_changed(const Link<weld::ComboBox&, void>& rLink) { m_xControl->connect_changed(rLink); }
private:
StringPair impl_getDocumentAtIndex( sal_uInt16 _nListIndex, bool _bSystemNotation = false ) const;
void impl_init( const sal_Char* _pAsciiModuleName );

View File

@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="dba">
<requires lib="gtk+" version="3.18"/>
<requires lib="LibreOffice" version="1.0"/>
<object class="GtkBox" id="PageGeneral">
<property name="width_request">400</property>
<property name="visible">True</property>
@@ -14,9 +13,9 @@
<object class="GtkLabel" id="headerText">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="generalpagewizard|headerText">Welcome to the %PRODUCTNAME Database Wizard</property>
<property name="wrap">True</property>
<property name="xalign">0</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
@@ -31,10 +30,11 @@
<object class="GtkLabel" id="helpText">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="generalpagewizard|helpText">Use the Database Wizard to create a new database, open an existing database file, or connect to a database stored on a server.</property>
<property name="wrap">True</property>
<property name="width_chars">72</property>
<property name="max_width_chars">72</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
@@ -46,9 +46,9 @@
<object class="GtkLabel" id="sourceTypeHeader">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="generalpagewizard|sourceTypeHeader">What do you want to do?</property>
<property name="wrap">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
@@ -84,10 +84,10 @@
<object class="GtkLabel" id="embeddeddbLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="generalpagewizard|embeddeddbLabel">_Embedded database:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">embeddeddbList</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
@@ -142,10 +142,10 @@
<object class="GtkLabel" id="docListLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="generalpagewizard|docListLabel">_Recently used:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">documentList</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
@@ -154,12 +154,10 @@
</packing>
</child>
<child>
<object class="dbulo-OpenDocumentListBox" id="documentList">
<object class="GtkComboBoxText" id="documentList">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="entry_text_column">0</property>
<property name="id_column">1</property>
</object>
<packing>
<property name="expand">False</property>
@@ -175,7 +173,7 @@
</packing>
</child>
<child>
<object class="dbulo-OpenDocumentButton" id="openDatabase">
<object class="GtkButton" id="openDatabase">
<property name="label" translatable="yes" context="generalpagewizard|openDatabase">Open</property>
<property name="visible">True</property>
<property name="can_focus">True</property>

View File

@@ -218,10 +218,6 @@
generic-name="LanguageBox" parent="VclComboBoxText"
icon-name="widget-gtk-combobox"/>
<glade-widget-class title="Open Document ListBox" name="dbulo-OpenDocumentListBox"
generic-name="Open Document ListBox" parent="GtkComboBox"
icon-name="widget-gtk-combobox"/>
<glade-widget-class title="Fill Type ListBox" name="svxlo-SvxFillTypeBox"
generic-name="Fill Type ListBox" parent="GtkComboBox"
icon-name="widget-gtk-combobox"/>
@@ -246,10 +242,6 @@
generic-name="Same Content Preset ListBox" parent="GtkComboBox"
icon-name="widget-gtk-combobox"/>
<glade-widget-class title="Open Document Button" name="dbulo-OpenDocumentButton"
generic-name="Open Document Button" parent="GtkButton"
icon-name="widget-gtk-button"/>
<glade-widget-class title="Relation Control" name="dbulo-ORelationControl"
generic-name="Relation Control" parent="GtkTreeView"
icon-name="widget-gtk-treeview"/>

View File

@@ -32,7 +32,7 @@ dbaccess/uiconfig/ui/generalpagedialog.ui://GtkLabel[@id='specialMessage'] orpha
dbaccess/uiconfig/ui/generalpagewizard.ui://GtkLabel[@id='headerText'] orphan-label
dbaccess/uiconfig/ui/generalpagewizard.ui://GtkLabel[@id='helpText'] orphan-label
dbaccess/uiconfig/ui/generalpagewizard.ui://GtkLabel[@id='sourceTypeHeader'] orphan-label
dbaccess/uiconfig/ui/generalpagewizard.ui://dbulo-OpenDocumentButton[@id='openDatabase'] no-labelled-by
dbaccess/uiconfig/ui/generalpagewizard.ui://GtkButton[@id='openDatabase'] no-labelled-by
dbaccess/uiconfig/ui/generalpagewizard.ui://GtkComboBoxText[@id='datasourceType'] no-labelled-by
dbaccess/uiconfig/ui/generalpagewizard.ui://GtkLabel[@id='specialMessage'] orphan-label
dbaccess/uiconfig/ui/generalspecialjdbcdetailspage.ui://GtkLabel[@id='socketLabel'] orphan-label