LCOV - code coverage report
Current view: top level - dbaccess/source/ui/dlg - tablespage.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 272 0.4 %
Date: 2015-06-13 12:38:46 Functions: 2 23 8.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "tablespage.hxx"
      21             : #include "dbu_dlg.hrc"
      22             : #include "dsitems.hxx"
      23             : #include "browserids.hxx"
      24             : #include "datasourceconnector.hxx"
      25             : #include <comphelper/types.hxx>
      26             : #include <connectivity/dbtools.hxx>
      27             : #include <connectivity/dbexception.hxx>
      28             : #include "stringlistitem.hxx"
      29             : #include <svl/eitem.hxx>
      30             : #include <svl/stritem.hxx>
      31             : #include "dbustrings.hrc"
      32             : #include <vcl/svapp.hxx>
      33             : #include <vcl/settings.hxx>
      34             : #include <vcl/waitobj.hxx>
      35             : #include <com/sun/star/i18n/Collator.hpp>
      36             : #include <com/sun/star/sdb/SQLContext.hpp>
      37             : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
      38             : #include <com/sun/star/sdbcx/XAppend.hpp>
      39             : #include <com/sun/star/util/XModifiable.hpp>
      40             : #include <com/sun/star/sdbcx/XDrop.hpp>
      41             : #include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
      42             : #include "sqlmessage.hxx"
      43             : #include <vcl/msgbox.hxx>
      44             : #include "dbaccess_helpid.hrc"
      45             : #include "UITools.hxx"
      46             : #include <osl/mutex.hxx>
      47             : #include <osl/diagnose.h>
      48             : #include <svtools/imgdef.hxx>
      49             : #include "svtools/treelistentry.hxx"
      50             : #include "TablesSingleDlg.hxx"
      51             : #include <tools/diagnose_ex.h>
      52             : #include <comphelper/processfactory.hxx>
      53             : #include <cppuhelper/exc_hlp.hxx>
      54             : 
      55             : namespace dbaui
      56             : {
      57             : 
      58             :     using namespace ::com::sun::star::uno;
      59             :     using namespace ::com::sun::star::sdbc;
      60             :     using namespace ::com::sun::star::sdbcx;
      61             :     using namespace ::com::sun::star::sdb;
      62             :     using namespace ::com::sun::star::beans;
      63             :     using namespace ::com::sun::star::lang;
      64             :     using namespace ::com::sun::star::i18n;
      65             :     using namespace ::com::sun::star::container;
      66             :     using namespace ::com::sun::star::frame;
      67             :     using namespace ::com::sun::star::util;
      68             :     using namespace ::dbtools;
      69             :     using namespace ::comphelper;
      70             : 
      71             :     // OTableSubscriptionPage
      72           0 :     OTableSubscriptionPage::OTableSubscriptionPage(vcl::Window* pParent, const SfxItemSet& _rCoreAttrs,
      73             :         OTableSubscriptionDialog* _pTablesDlg)
      74             :         : OGenericAdministrationPage(pParent, "TablesFilterPage",
      75             :             "dbaccess/ui/tablesfilterpage.ui", _rCoreAttrs)
      76             :         , m_bCatalogAtStart(true)
      77           0 :         , m_pTablesDlg(_pTablesDlg)
      78             :     {
      79           0 :         get(m_pTables, "TablesFilterPage");
      80             : 
      81           0 :         get(m_pTablesList, "treeview");
      82           0 :         m_pTablesList->init(true);
      83           0 :         m_pTablesList->set_width_request(56 * m_pTablesList->approximate_char_width());
      84           0 :         m_pTablesList->set_height_request(12 * m_pTablesList->GetTextHeight());
      85             : 
      86           0 :         m_pTablesList->SetCheckHandler(getControlModifiedLink());
      87             : 
      88             :         // initialize the TabListBox
      89           0 :         m_pTablesList->SetSelectionMode( MULTIPLE_SELECTION );
      90           0 :         m_pTablesList->SetDragDropMode( DragDropMode::NONE );
      91           0 :         m_pTablesList->EnableInplaceEditing( false );
      92           0 :         m_pTablesList->SetStyle(m_pTablesList->GetStyle() | WB_BORDER | WB_HASLINES | WB_HASLINESATROOT | WB_SORT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT);
      93             : 
      94           0 :         m_pTablesList->Clear();
      95             : 
      96           0 :         m_pTablesList->SetCheckButtonHdl(LINK(this, OTableSubscriptionPage, OnTreeEntryChecked));
      97           0 :         m_pTablesList->SetCheckHandler(LINK(this, OTableSubscriptionPage, OnTreeEntryChecked));
      98           0 :     }
      99             : 
     100           0 :     OTableSubscriptionPage::~OTableSubscriptionPage()
     101             :     {
     102           0 :         disposeOnce();
     103           0 :     }
     104             : 
     105           0 :     void OTableSubscriptionPage::dispose()
     106             :     {
     107             :         // just to make sure that our connection will be removed
     108             :         try
     109             :         {
     110           0 :             ::comphelper::disposeComponent(m_xCurrentConnection);
     111             :         }
     112           0 :         catch (RuntimeException&) { }
     113           0 :         m_pTables.clear();
     114           0 :         m_pTablesList.clear();
     115           0 :         m_pTablesDlg.clear();
     116           0 :         OGenericAdministrationPage::dispose();
     117           0 :     }
     118             : 
     119           0 :     void OTableSubscriptionPage::StateChanged( StateChangedType nType )
     120             :     {
     121           0 :         OGenericAdministrationPage::StateChanged( nType );
     122             : 
     123           0 :         if ( nType == StateChangedType::ControlBackground )
     124             :         {
     125             :             // Check if we need to get new images for normal/high contrast mode
     126           0 :             m_pTablesList->notifyHiContrastChanged();
     127             :         }
     128           0 :     }
     129           0 :     void OTableSubscriptionPage::DataChanged( const DataChangedEvent& rDCEvt )
     130             :     {
     131           0 :         OGenericAdministrationPage::DataChanged( rDCEvt );
     132             : 
     133           0 :         if ((( rDCEvt.GetType() == DataChangedEventType::SETTINGS )   ||
     134           0 :             ( rDCEvt.GetType() == DataChangedEventType::DISPLAY   ))  &&
     135           0 :             ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE        ))
     136             :         {
     137             :             // Check if we need to get new images for normal/high contrast mode
     138           0 :             m_pTablesList->notifyHiContrastChanged();
     139             :         }
     140           0 :     }
     141           0 :     void OTableSubscriptionPage::resizeControls(const Size& _rDiff)
     142             :     {
     143           0 :         if ( _rDiff.Height() )
     144             :         {
     145           0 :             Size aOldSize = m_pTablesList->GetSizePixel();
     146           0 :             aOldSize.Height() -= _rDiff.Height();
     147           0 :             m_pTablesList->SetPosSizePixel(
     148           0 :                     m_pTablesList->GetPosPixel()+Point(0,_rDiff.Height()),
     149             :                     aOldSize
     150           0 :                     );
     151             :         }
     152           0 :     }
     153           0 :     void OTableSubscriptionPage::implCheckTables(const Sequence< OUString >& _rTables)
     154             :     {
     155             :         // the meta data for the current connection, used for splitting up table names
     156           0 :         Reference< XDatabaseMetaData > xMeta;
     157             :         try
     158             :         {
     159           0 :             if (m_xCurrentConnection.is())
     160           0 :                 xMeta = m_xCurrentConnection->getMetaData();
     161             :         }
     162           0 :         catch(SQLException&)
     163             :         {
     164             :             OSL_FAIL("OTableSubscriptionPage::implCheckTables : could not retrieve the current connection's meta data!");
     165             :         }
     166             : 
     167             :         // uncheck all
     168           0 :         CheckAll(false);
     169             : 
     170             :         // check the ones which are in the list
     171           0 :         OUString sCatalog, sSchema, sName;
     172             : 
     173           0 :         SvTreeListEntry* pRootEntry = m_pTablesList->getAllObjectsEntry();
     174             : 
     175           0 :         const OUString* pIncludeTable = _rTables.getConstArray();
     176           0 :         for (sal_Int32 i=0; i<_rTables.getLength(); ++i, ++pIncludeTable)
     177             :         {
     178           0 :             if (xMeta.is())
     179           0 :                 qualifiedNameComponents(xMeta, pIncludeTable->getStr(), sCatalog, sSchema, sName,::dbtools::eInDataManipulation);
     180             :             else
     181           0 :                 sName = pIncludeTable->getStr();
     182             : 
     183           0 :             bool bAllTables = (1 == sName.getLength()) && ('%' == sName[0]);
     184           0 :             bool bAllSchemas = (1 == sSchema.getLength()) && ('%' == sSchema[0]);
     185             : 
     186             :             // the catalog entry
     187           0 :             SvTreeListEntry* pCatalog = m_pTablesList->GetEntryPosByName(sCatalog, pRootEntry);
     188           0 :             if (!(pCatalog || sCatalog.isEmpty()))
     189             :                 // the table (resp. its catalog) referred in this filter entry does not exist anymore
     190           0 :                 continue;
     191             : 
     192           0 :             if (bAllSchemas && pCatalog)
     193             :             {
     194           0 :                 m_pTablesList->checkWildcard(pCatalog);
     195           0 :                 continue;
     196             :             }
     197             : 
     198             :             // the schema entry
     199           0 :             SvTreeListEntry* pSchema = m_pTablesList->GetEntryPosByName(sSchema, (pCatalog ? pCatalog : pRootEntry));
     200           0 :             if (!(pSchema || sSchema.isEmpty()))
     201             :                 // the table (resp. its schema) referred in this filter entry does not exist anymore
     202           0 :                 continue;
     203             : 
     204           0 :             if (bAllTables && pSchema)
     205             :             {
     206           0 :                 m_pTablesList->checkWildcard(pSchema);
     207           0 :                 continue;
     208             :             }
     209             : 
     210           0 :             SvTreeListEntry* pEntry = m_pTablesList->GetEntryPosByName(sName, pSchema ? pSchema : (pCatalog ? pCatalog : pRootEntry) );
     211           0 :             if (pEntry)
     212           0 :                 m_pTablesList->SetCheckButtonState(pEntry, SV_BUTTON_CHECKED);
     213             :         }
     214           0 :         m_pTablesList->CheckButtons();
     215           0 :     }
     216             : 
     217           0 :     void OTableSubscriptionPage::implCompleteTablesCheck( const ::com::sun::star::uno::Sequence< OUString >& _rTableFilter )
     218             :     {
     219           0 :         if (!_rTableFilter.getLength())
     220             :         {   // no tables visible
     221           0 :             CheckAll(false);
     222             :         }
     223             :         else
     224             :         {
     225           0 :             if ((1 == _rTableFilter.getLength()) && _rTableFilter[0] == "%")
     226             :             {   // all tables visible
     227           0 :                 CheckAll(true);
     228             :             }
     229             :             else
     230           0 :                 implCheckTables( _rTableFilter );
     231             :         }
     232           0 :     }
     233             : 
     234           0 :     void OTableSubscriptionPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
     235             :     {
     236             :         // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
     237             :         bool bValid, bReadonly;
     238           0 :         getFlags(_rSet, bValid, bReadonly);
     239             : 
     240             :         // get the name of the data source we're working for
     241           0 :         SFX_ITEMSET_GET(_rSet, pNameItem, SfxStringItem, DSID_NAME, true);
     242             :         OSL_ENSURE(pNameItem, "OTableSubscriptionPage::implInitControls: missing the name attribute!");
     243           0 :         OUString sDSName = pNameItem->GetValue();
     244             : 
     245           0 :         if (bValid && !sDSName.isEmpty() && !m_xCurrentConnection.is() )
     246             :         {   // get the current table list from the connection for the current settings
     247             : 
     248             :             // the PropertyValues for the current dialog settings
     249           0 :             Sequence< PropertyValue > aConnectionParams;
     250             :             OSL_ENSURE(m_pTablesDlg, "OTableSubscriptionPage::implInitControls: need a parent dialog doing the translation!");
     251           0 :             if ( m_pTablesDlg )
     252             :             {
     253           0 :                 if (!m_pTablesDlg->getCurrentSettings(aConnectionParams))
     254             :                 {
     255           0 :                     m_pTablesList->Clear();
     256           0 :                     m_pTablesDlg->endExecution();
     257           0 :                     return;
     258             :                 }
     259             :             }
     260             : 
     261           0 :             if (!m_xCollator.is())
     262             :             {
     263             :                 // the collator for the string compares
     264             :                 try
     265             :                 {
     266           0 :                     m_xCollator = Collator::create(m_xORB);
     267           0 :                     m_xCollator->loadDefaultCollator(Application::GetSettings().GetLanguageTag().getLocale(), 0);
     268             :                 }
     269           0 :                 catch(const Exception&)
     270             :                 {
     271             :                     DBG_UNHANDLED_EXCEPTION();
     272             :                 }
     273             :             }
     274             : 
     275             :             // fill the table list with this connection information
     276           0 :             SQLExceptionInfo aErrorInfo;
     277             :             // the current DSN
     278           0 :             OUString sURL;
     279           0 :             if ( m_pTablesDlg )
     280           0 :                 sURL = m_pTablesDlg->getConnectionURL();
     281             : 
     282             :             try
     283             :             {
     284           0 :                 WaitObject aWaitCursor(this);
     285           0 :                 m_pTablesList->GetModel()->SetSortMode(SortAscending);
     286           0 :                 m_pTablesList->GetModel()->SetCompareHdl(LINK(this, OTableSubscriptionPage, OnTreeEntryCompare));
     287             : 
     288           0 :                 Reference< XDriver > xDriver;
     289           0 :                 Reference<XPropertySet> xProp = m_pTablesDlg->getCurrentDataSource();
     290             :                 OSL_ENSURE(xProp.is(),"No data source set!");
     291           0 :                 if ( xProp.is() )
     292             :                 {
     293           0 :                     Any aTableFilter = xProp->getPropertyValue(PROPERTY_TABLEFILTER);
     294           0 :                     Any aTableTypeFilter = xProp->getPropertyValue(PROPERTY_TABLETYPEFILTER);
     295             : 
     296           0 :                     Reference<XModifiable> xModi(getDataSourceOrModel(xProp),UNO_QUERY);
     297           0 :                     bool bModified = ( xModi.is() && xModi->isModified() );
     298             : 
     299           0 :                     Sequence< OUString > aNewTableFilter(1);
     300           0 :                     aNewTableFilter[0] = "%";
     301           0 :                     xProp->setPropertyValue(PROPERTY_TABLEFILTER,makeAny(aNewTableFilter));
     302             : 
     303           0 :                     xProp->setPropertyValue( PROPERTY_TABLETYPEFILTER, makeAny( Sequence< OUString >() ) );
     304           0 :                     Reference< ::com::sun::star::lang::XEventListener> xEvt;
     305           0 :                     aErrorInfo = ::dbaui::createConnection(xProp, m_xORB, xEvt, m_xCurrentConnection);
     306             : 
     307           0 :                     xProp->setPropertyValue(PROPERTY_TABLEFILTER,aTableFilter);
     308           0 :                     xProp->setPropertyValue(PROPERTY_TABLETYPEFILTER,aTableTypeFilter);
     309             : 
     310           0 :                     if ( xModi.is() && !bModified )
     311           0 :                         xModi->setModified(sal_False);
     312             : 
     313             :                 }
     314             : 
     315           0 :                 if ( m_xCurrentConnection.is() )
     316             :                 {
     317           0 :                     m_pTablesList->UpdateTableList( m_xCurrentConnection );
     318           0 :                     if (m_pTablesDlg)
     319           0 :                         m_pTablesDlg->successfullyConnected();
     320           0 :                 }
     321             :             }
     322           0 :             catch (const SQLException&)
     323             :             {
     324           0 :                 aErrorInfo = ::cppu::getCaughtException();
     325             :             }
     326             : 
     327           0 :             if (aErrorInfo.isValid())
     328             :             {
     329             :                 // establishing the connection failed. Show an error window and exit.
     330           0 :                 ScopedVclPtrInstance< OSQLMessageBox > aMessageBox( GetParentDialog(), aErrorInfo );
     331           0 :                 aMessageBox->Execute();
     332           0 :                 m_pTables->Enable(false);
     333           0 :                 m_pTablesList->Clear();
     334             : 
     335           0 :                 if ( m_pTablesDlg )
     336             :                 {
     337           0 :                     m_pTablesDlg->clearPassword();
     338           0 :                     m_pTablesDlg->endExecution();
     339           0 :                 }
     340             :             }
     341             :             else
     342             :             {
     343             :                 // in addition, we need some infos about the connection used
     344           0 :                 m_sCatalogSeparator = ".";    // (default)
     345           0 :                 m_bCatalogAtStart = true;   // (default)
     346             :                 try
     347             :                 {
     348           0 :                     Reference< XDatabaseMetaData > xMeta;
     349           0 :                     if (m_xCurrentConnection.is())
     350           0 :                         xMeta = m_xCurrentConnection->getMetaData();
     351           0 :                     if (xMeta.is() && xMeta->supportsCatalogsInDataManipulation())
     352             :                     {
     353           0 :                         m_sCatalogSeparator = xMeta->getCatalogSeparator();
     354           0 :                         m_bCatalogAtStart = xMeta->isCatalogAtStart();
     355           0 :                     }
     356             :                 }
     357           0 :                 catch(Exception&)
     358             :                 {
     359             :                     DBG_UNHANDLED_EXCEPTION();
     360             :                 }
     361           0 :             }
     362             :         }
     363             : 
     364             :         // get the current table filter
     365           0 :         SFX_ITEMSET_GET(_rSet, pTableFilter, OStringListItem, DSID_TABLEFILTER, true);
     366           0 :         Sequence< OUString > aTableFilter;
     367           0 :         if (pTableFilter)
     368           0 :             aTableFilter = pTableFilter->getList();
     369             : 
     370           0 :         implCompleteTablesCheck( aTableFilter );
     371             : 
     372             :         // expand the first entry by default
     373           0 :         SvTreeListEntry* pExpand = m_pTablesList->getAllObjectsEntry();
     374           0 :         while (pExpand)
     375             :         {
     376           0 :             m_pTablesList->Expand(pExpand);
     377           0 :             pExpand = m_pTablesList->FirstChild(pExpand);
     378           0 :             if (pExpand && SvTreeList::NextSibling(pExpand))
     379           0 :                 pExpand = NULL;
     380             :         }
     381             : 
     382             :         // update the toolbox according the current selection and check state
     383           0 :         OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
     384             :     }
     385             : 
     386           0 :     void OTableSubscriptionPage::CheckAll( bool _bCheck )
     387             :     {
     388           0 :         SvButtonState eState = _bCheck ? SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED;
     389           0 :         SvTreeListEntry* pEntry = m_pTablesList->First();
     390           0 :         while (pEntry)
     391             :         {
     392           0 :             m_pTablesList->SetCheckButtonState( pEntry, eState);
     393           0 :             pEntry = m_pTablesList->Next(pEntry);
     394             :         }
     395             : 
     396           0 :         if (_bCheck && m_pTablesList->getAllObjectsEntry())
     397           0 :             m_pTablesList->checkWildcard(m_pTablesList->getAllObjectsEntry());
     398           0 :     }
     399             : 
     400           0 :     SfxTabPage::sfxpg OTableSubscriptionPage::DeactivatePage(SfxItemSet* _pSet)
     401             :     {
     402           0 :         sfxpg nResult = OGenericAdministrationPage::DeactivatePage(_pSet);
     403             : 
     404             :         // dispose the connection, we don't need it anymore, so we're not wasting resources
     405             :         try
     406             :         {
     407           0 :             ::comphelper::disposeComponent(m_xCurrentConnection);
     408             :         }
     409           0 :         catch (RuntimeException&) { }
     410             : 
     411           0 :         return nResult;
     412             :     }
     413           0 :     IMPL_LINK( OTableSubscriptionPage, OnTreeEntryChecked, Control*, _pControl )
     414             :     {
     415           0 :         return OnControlModified(_pControl);
     416             :     }
     417           0 :     IMPL_LINK( OTableSubscriptionPage, OnTreeEntryCompare, const SvSortData*, _pSortData )
     418             :     {
     419           0 :         const SvTreeListEntry* pLHS = static_cast<const SvTreeListEntry*>(_pSortData->pLeft);
     420           0 :         const SvTreeListEntry* pRHS = static_cast<const SvTreeListEntry*>(_pSortData->pRight);
     421             :         OSL_ENSURE(pLHS && pRHS, "SbaTableQueryBrowser::OnTreeEntryCompare: invalid tree entries!");
     422             : 
     423           0 :         const SvLBoxString* pLeftTextItem = static_cast<const SvLBoxString*>(pLHS->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
     424           0 :         const SvLBoxString* pRightTextItem = static_cast<const SvLBoxString*>(pRHS->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
     425             :         OSL_ENSURE(pLeftTextItem && pRightTextItem, "SbaTableQueryBrowser::OnTreeEntryCompare: invalid text items!");
     426             : 
     427           0 :         OUString sLeftText = pLeftTextItem->GetText();
     428           0 :         OUString sRightText = pRightTextItem->GetText();
     429             : 
     430           0 :         sal_Int32 nCompareResult = 0;   // equal by default
     431             : 
     432           0 :         if (m_xCollator.is())
     433             :         {
     434             :             try
     435             :             {
     436           0 :                 nCompareResult = m_xCollator->compareString(sLeftText, sRightText);
     437             :             }
     438           0 :             catch(Exception&)
     439             :             {
     440             :             }
     441             :         }
     442             :         else
     443             :             // default behaviour if we do not have a collator -> do the simple string compare
     444           0 :             nCompareResult = sLeftText.compareTo(sRightText);
     445             : 
     446           0 :         return nCompareResult;
     447             :     }
     448             : 
     449           0 :     Sequence< OUString > OTableSubscriptionPage::collectDetailedSelection() const
     450             :     {
     451           0 :         Sequence< OUString > aTableFilter;
     452             :         static const char sDot[] = ".";
     453             :         static const char sWildcard[] = "%";
     454             : 
     455           0 :         OUString sComposedName;
     456           0 :         const SvTreeListEntry* pAllObjectsEntry = m_pTablesList->getAllObjectsEntry();
     457           0 :         if (!pAllObjectsEntry)
     458           0 :             return aTableFilter;
     459           0 :         SvTreeListEntry* pEntry = m_pTablesList->GetModel()->Next(const_cast<SvTreeListEntry*>(pAllObjectsEntry));
     460           0 :         while(pEntry)
     461             :         {
     462           0 :             bool bCatalogWildcard = false;
     463           0 :             bool bSchemaWildcard =  false;
     464           0 :             SvTreeListEntry* pSchema = NULL;
     465           0 :             SvTreeListEntry* pCatalog = NULL;
     466             : 
     467           0 :             if (m_pTablesList->GetCheckButtonState(pEntry) == SV_BUTTON_CHECKED && !m_pTablesList->GetModel()->HasChildren(pEntry))
     468             :             {   // checked and a leaf, which means it's no catalog, no schema, but a real table
     469           0 :                 OUString sCatalog;
     470           0 :                 if(m_pTablesList->GetModel()->HasParent(pEntry))
     471             :                 {
     472           0 :                     pSchema = m_pTablesList->GetModel()->GetParent(pEntry);
     473           0 :                     if (pAllObjectsEntry == pSchema)
     474             :                         // do not want to have the root entry
     475           0 :                         pSchema = NULL;
     476             : 
     477           0 :                     if (pSchema)
     478             :                     {   // it's a real schema entry, not the "all objects" root
     479           0 :                         if(m_pTablesList->GetModel()->HasParent(pSchema))
     480             :                         {
     481           0 :                             pCatalog = m_pTablesList->GetModel()->GetParent(pSchema);
     482           0 :                             if (pAllObjectsEntry == pCatalog)
     483             :                                 // do not want to have the root entry
     484           0 :                                 pCatalog = NULL;
     485             : 
     486           0 :                             if (pCatalog)
     487             :                             {   // it's a real catalog entry, not the "all objects" root
     488           0 :                                 bCatalogWildcard = OTableTreeListBox::isWildcardChecked(pCatalog);
     489           0 :                                 if (m_bCatalogAtStart)
     490             :                                 {
     491           0 :                                     sComposedName += m_pTablesList->GetEntryText( pCatalog );
     492           0 :                                     sComposedName += m_sCatalogSeparator;
     493           0 :                                     if (bCatalogWildcard)
     494           0 :                                         sComposedName += sWildcard;
     495             :                                 }
     496             :                                 else
     497             :                                 {
     498           0 :                                     if (bCatalogWildcard)
     499           0 :                                         sCatalog = sWildcard;
     500             :                                     else
     501           0 :                                         sCatalog.clear();
     502           0 :                                     sCatalog += m_sCatalogSeparator;
     503           0 :                                     sCatalog += m_pTablesList->GetEntryText( pCatalog );
     504             :                                 }
     505             :                             }
     506             :                         }
     507           0 :                         bSchemaWildcard = OTableTreeListBox::isWildcardChecked(pSchema);
     508           0 :                         sComposedName += m_pTablesList->GetEntryText( pSchema );
     509           0 :                         sComposedName += sDot;
     510             :                     }
     511             : 
     512           0 :                     if (bSchemaWildcard)
     513           0 :                         sComposedName += sWildcard;
     514             :                 }
     515           0 :                 if (!bSchemaWildcard && !bCatalogWildcard)
     516           0 :                     sComposedName += m_pTablesList->GetEntryText( pEntry );
     517             : 
     518           0 :                 if (!m_bCatalogAtStart && !bCatalogWildcard)
     519           0 :                     sComposedName += sCatalog;
     520             : 
     521             :                 // need some space
     522           0 :                 sal_Int32 nOldLen = aTableFilter.getLength();
     523           0 :                 aTableFilter.realloc(nOldLen + 1);
     524             :                 // add the new name
     525           0 :                 aTableFilter[nOldLen] = sComposedName;
     526             : 
     527             :                 // reset the composed name
     528           0 :                 sComposedName.clear();
     529             :             }
     530             : 
     531           0 :             if (bCatalogWildcard)
     532           0 :                 pEntry = implNextSibling(pCatalog);
     533           0 :             else if (bSchemaWildcard)
     534           0 :                 pEntry = implNextSibling(pSchema);
     535             :             else
     536           0 :                 pEntry = m_pTablesList->GetModel()->Next(pEntry);
     537             :         }
     538             : 
     539           0 :         return aTableFilter;
     540             :     }
     541             : 
     542           0 :     SvTreeListEntry* OTableSubscriptionPage::implNextSibling(SvTreeListEntry* _pEntry) const
     543             :     {
     544           0 :         SvTreeListEntry* pReturn = NULL;
     545           0 :         if (_pEntry)
     546             :         {
     547           0 :             pReturn = SvTreeList::NextSibling(_pEntry);
     548           0 :             if (!pReturn)
     549           0 :                 pReturn = implNextSibling(m_pTablesList->GetParent(_pEntry));
     550             :         }
     551           0 :         return pReturn;
     552             :     }
     553             : 
     554           0 :     bool OTableSubscriptionPage::FillItemSet( SfxItemSet* _rCoreAttrs )
     555             :     {
     556             :         bool bValid, bReadonly;
     557           0 :         getFlags(*_rCoreAttrs, bValid, bReadonly);
     558             : 
     559           0 :         if (!bValid || bReadonly)
     560             :             // don't store anything if the data we're working with is invalid or readonly
     561           0 :             return true;
     562             : 
     563             :         // create the output string which contains all the table names
     564           0 :         if ( m_xCurrentConnection.is() )
     565             :         {   // collect the table filter data only if we have a connection - else no tables are displayed at all
     566           0 :             Sequence< OUString > aTableFilter;
     567           0 :             if (dbaui::OTableTreeListBox::isWildcardChecked(m_pTablesList->getAllObjectsEntry()))
     568             :             {
     569           0 :                 aTableFilter.realloc(1);
     570           0 :                 aTableFilter[0] = "%";
     571             :             }
     572             :             else
     573             :             {
     574           0 :                 aTableFilter = collectDetailedSelection();
     575             :             }
     576           0 :             _rCoreAttrs->Put( OStringListItem(DSID_TABLEFILTER, aTableFilter) );
     577             :         }
     578             : 
     579           0 :         return true;
     580             :     }
     581             : 
     582           0 :     void OTableSubscriptionPage::fillControls(::std::vector< ISaveValueWrapper* >& /*_rControlList*/)
     583             :     {
     584           0 :     }
     585             : 
     586           0 :     void OTableSubscriptionPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
     587             :     {
     588           0 :         _rControlList.push_back(new ODisableWrapper<VclContainer>(m_pTables));
     589           0 :     }
     590          36 : }   // namespace dbaui
     591             : 
     592             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11