LCOV - code coverage report
Current view: top level - dbaccess/source/ui/dlg - tablespage.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 267 0.4 %
Date: 2014-11-03 Functions: 2 22 9.1 %
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->set_width_request(56 * m_pTablesList->approximate_char_width());
      83           0 :         m_pTablesList->set_height_request(12 * m_pTablesList->GetTextHeight());
      84             : 
      85           0 :         m_pTablesList->SetCheckHandler(getControlModifiedLink());
      86             : 
      87             :         // initialize the TabListBox
      88           0 :         m_pTablesList->SetSelectionMode( MULTIPLE_SELECTION );
      89           0 :         m_pTablesList->SetDragDropMode( 0 );
      90           0 :         m_pTablesList->EnableInplaceEditing( false );
      91           0 :         m_pTablesList->SetStyle(m_pTablesList->GetStyle() | WB_BORDER | WB_HASLINES | WB_HASLINESATROOT | WB_SORT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT);
      92             : 
      93           0 :         m_pTablesList->Clear();
      94             : 
      95           0 :         m_pTablesList->SetCheckButtonHdl(LINK(this, OTableSubscriptionPage, OnTreeEntryChecked));
      96           0 :         m_pTablesList->SetCheckHandler(LINK(this, OTableSubscriptionPage, OnTreeEntryChecked));
      97           0 :     }
      98             : 
      99           0 :     OTableSubscriptionPage::~OTableSubscriptionPage()
     100             :     {
     101             :         // just to make sure that our connection will be removed
     102             :         try
     103             :         {
     104           0 :             ::comphelper::disposeComponent(m_xCurrentConnection);
     105             :         }
     106           0 :         catch (RuntimeException&) { }
     107             : 
     108           0 :     }
     109             : 
     110           0 :     void OTableSubscriptionPage::StateChanged( StateChangedType nType )
     111             :     {
     112           0 :         OGenericAdministrationPage::StateChanged( nType );
     113             : 
     114           0 :         if ( nType == StateChangedType::CONTROLBACKGROUND )
     115             :         {
     116             :             // Check if we need to get new images for normal/high contrast mode
     117           0 :             m_pTablesList->notifyHiContrastChanged();
     118             :         }
     119           0 :     }
     120           0 :     void OTableSubscriptionPage::DataChanged( const DataChangedEvent& rDCEvt )
     121             :     {
     122           0 :         OGenericAdministrationPage::DataChanged( rDCEvt );
     123             : 
     124           0 :         if ((( rDCEvt.GetType() == DATACHANGED_SETTINGS )   ||
     125           0 :             ( rDCEvt.GetType() == DATACHANGED_DISPLAY   ))  &&
     126           0 :             ( rDCEvt.GetFlags() & SETTINGS_STYLE        ))
     127             :         {
     128             :             // Check if we need to get new images for normal/high contrast mode
     129           0 :             m_pTablesList->notifyHiContrastChanged();
     130             :         }
     131           0 :     }
     132           0 :     void OTableSubscriptionPage::resizeControls(const Size& _rDiff)
     133             :     {
     134           0 :         if ( _rDiff.Height() )
     135             :         {
     136           0 :             Size aOldSize = m_pTablesList->GetSizePixel();
     137           0 :             aOldSize.Height() -= _rDiff.Height();
     138             :             m_pTablesList->SetPosSizePixel(
     139           0 :                     m_pTablesList->GetPosPixel()+Point(0,_rDiff.Height()),
     140             :                     aOldSize
     141           0 :                     );
     142             :         }
     143           0 :     }
     144           0 :     void OTableSubscriptionPage::implCheckTables(const Sequence< OUString >& _rTables)
     145             :     {
     146             :         // the meta data for the current connection, used for splitting up table names
     147           0 :         Reference< XDatabaseMetaData > xMeta;
     148             :         try
     149             :         {
     150           0 :             if (m_xCurrentConnection.is())
     151           0 :                 xMeta = m_xCurrentConnection->getMetaData();
     152             :         }
     153           0 :         catch(SQLException&)
     154             :         {
     155             :             OSL_FAIL("OTableSubscriptionPage::implCheckTables : could not retrieve the current connection's meta data!");
     156             :         }
     157             : 
     158             :         // uncheck all
     159           0 :         CheckAll(false);
     160             : 
     161             :         // check the ones which are in the list
     162           0 :         OUString sCatalog, sSchema, sName;
     163             : 
     164           0 :         SvTreeListEntry* pRootEntry = m_pTablesList->getAllObjectsEntry();
     165           0 :         bool bAllTables = false;
     166           0 :         bool bAllSchemas = false;
     167             : 
     168           0 :         const OUString* pIncludeTable = _rTables.getConstArray();
     169           0 :         for (sal_Int32 i=0; i<_rTables.getLength(); ++i, ++pIncludeTable)
     170             :         {
     171           0 :             if (xMeta.is())
     172           0 :                 qualifiedNameComponents(xMeta, pIncludeTable->getStr(), sCatalog, sSchema, sName,::dbtools::eInDataManipulation);
     173             :             else
     174           0 :                 sName = pIncludeTable->getStr();
     175             : 
     176           0 :             bAllTables = (1 == sName.getLength()) && ('%' == sName[0]);
     177           0 :             bAllSchemas = (1 == sSchema.getLength()) && ('%' == sSchema[0]);
     178             : 
     179             :             // the catalog entry
     180           0 :             SvTreeListEntry* pCatalog = m_pTablesList->GetEntryPosByName(sCatalog, pRootEntry);
     181           0 :             if (!(pCatalog || sCatalog.isEmpty()))
     182             :                 // the table (resp. its catalog) referred in this filter entry does not exist anymore
     183           0 :                 continue;
     184             : 
     185           0 :             if (bAllSchemas && pCatalog)
     186             :             {
     187           0 :                 m_pTablesList->checkWildcard(pCatalog);
     188           0 :                 continue;
     189             :             }
     190             : 
     191             :             // the schema entry
     192           0 :             SvTreeListEntry* pSchema = m_pTablesList->GetEntryPosByName(sSchema, (pCatalog ? pCatalog : pRootEntry));
     193           0 :             if (!(pSchema || sSchema.isEmpty()))
     194             :                 // the table (resp. its schema) referred in this filter entry does not exist anymore
     195           0 :                 continue;
     196             : 
     197           0 :             if (bAllTables && pSchema)
     198             :             {
     199           0 :                 m_pTablesList->checkWildcard(pSchema);
     200           0 :                 continue;
     201             :             }
     202             : 
     203           0 :             SvTreeListEntry* pEntry = m_pTablesList->GetEntryPosByName(sName, pSchema ? pSchema : (pCatalog ? pCatalog : pRootEntry) );
     204           0 :             if (pEntry)
     205           0 :                 m_pTablesList->SetCheckButtonState(pEntry, SV_BUTTON_CHECKED);
     206             :         }
     207           0 :         m_pTablesList->CheckButtons();
     208           0 :     }
     209             : 
     210           0 :     void OTableSubscriptionPage::implCompleteTablesCheck( const ::com::sun::star::uno::Sequence< OUString >& _rTableFilter )
     211             :     {
     212           0 :         if (!_rTableFilter.getLength())
     213             :         {   // no tables visible
     214           0 :             CheckAll(false);
     215             :         }
     216             :         else
     217             :         {
     218           0 :             if ((1 == _rTableFilter.getLength()) && _rTableFilter[0] == "%")
     219             :             {   // all tables visible
     220           0 :                 CheckAll(true);
     221             :             }
     222             :             else
     223           0 :                 implCheckTables( _rTableFilter );
     224             :         }
     225           0 :     }
     226             : 
     227           0 :     void OTableSubscriptionPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
     228             :     {
     229             :         // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
     230             :         bool bValid, bReadonly;
     231           0 :         getFlags(_rSet, bValid, bReadonly);
     232             : 
     233             :         // get the name of the data source we're working for
     234           0 :         SFX_ITEMSET_GET(_rSet, pNameItem, SfxStringItem, DSID_NAME, true);
     235             :         OSL_ENSURE(pNameItem, "OTableSubscriptionPage::implInitControls: missing the name attribute!");
     236           0 :         OUString sDSName = pNameItem->GetValue();
     237             : 
     238           0 :         if (bValid && !sDSName.isEmpty() && !m_xCurrentConnection.is() )
     239             :         {   // get the current table list from the connection for the current settings
     240             : 
     241             :             // the PropertyValues for the current dialog settings
     242           0 :             Sequence< PropertyValue > aConnectionParams;
     243             :             OSL_ENSURE(m_pTablesDlg, "OTableSubscriptionPage::implInitControls: need a parent dialog doing the translation!");
     244           0 :             if ( m_pTablesDlg )
     245             :             {
     246           0 :                 if (!m_pTablesDlg->getCurrentSettings(aConnectionParams))
     247             :                 {
     248           0 :                     m_pTablesList->Clear();
     249           0 :                     m_pTablesDlg->endExecution();
     250           0 :                     return;
     251             :                 }
     252             :             }
     253             : 
     254           0 :             if (!m_xCollator.is())
     255             :             {
     256             :                 // the collator for the string compares
     257             :                 try
     258             :                 {
     259           0 :                     m_xCollator = Collator::create(m_xORB);
     260           0 :                     m_xCollator->loadDefaultCollator(Application::GetSettings().GetLanguageTag().getLocale(), 0);
     261             :                 }
     262           0 :                 catch(const Exception&)
     263             :                 {
     264             :                     DBG_UNHANDLED_EXCEPTION();
     265             :                 }
     266             :             }
     267             : 
     268             :             // fill the table list with this connection information
     269           0 :             SQLExceptionInfo aErrorInfo;
     270             :             // the current DSN
     271           0 :             OUString sURL;
     272           0 :             if ( m_pTablesDlg )
     273           0 :                 sURL = m_pTablesDlg->getConnectionURL();
     274             : 
     275             :             try
     276             :             {
     277           0 :                 WaitObject aWaitCursor(this);
     278           0 :                 m_pTablesList->GetModel()->SetSortMode(SortAscending);
     279           0 :                 m_pTablesList->GetModel()->SetCompareHdl(LINK(this, OTableSubscriptionPage, OnTreeEntryCompare));
     280             : 
     281           0 :                 Reference< XDriver > xDriver;
     282           0 :                 Reference<XPropertySet> xProp = m_pTablesDlg->getCurrentDataSource();
     283             :                 OSL_ENSURE(xProp.is(),"No data source set!");
     284           0 :                 if ( xProp.is() )
     285             :                 {
     286           0 :                     Any aTableFilter = xProp->getPropertyValue(PROPERTY_TABLEFILTER);
     287           0 :                     Any aTableTypeFilter = xProp->getPropertyValue(PROPERTY_TABLETYPEFILTER);
     288             : 
     289           0 :                     Reference<XModifiable> xModi(getDataSourceOrModel(xProp),UNO_QUERY);
     290           0 :                     bool bModified = ( xModi.is() && xModi->isModified() );
     291             : 
     292           0 :                     Sequence< OUString > aNewTableFilter(1);
     293           0 :                     aNewTableFilter[0] = "%";
     294           0 :                     xProp->setPropertyValue(PROPERTY_TABLEFILTER,makeAny(aNewTableFilter));
     295             : 
     296           0 :                     xProp->setPropertyValue( PROPERTY_TABLETYPEFILTER, makeAny( Sequence< OUString >() ) );
     297           0 :                     Reference< ::com::sun::star::lang::XEventListener> xEvt;
     298           0 :                     aErrorInfo = ::dbaui::createConnection(xProp, m_xORB, xEvt, m_xCurrentConnection);
     299             : 
     300           0 :                     xProp->setPropertyValue(PROPERTY_TABLEFILTER,aTableFilter);
     301           0 :                     xProp->setPropertyValue(PROPERTY_TABLETYPEFILTER,aTableTypeFilter);
     302             : 
     303           0 :                     if ( xModi.is() && !bModified )
     304           0 :                         xModi->setModified(sal_False);
     305             : 
     306             :                 }
     307             : 
     308           0 :                 if ( m_xCurrentConnection.is() )
     309             :                 {
     310           0 :                     m_pTablesList->UpdateTableList( m_xCurrentConnection );
     311           0 :                     if (m_pTablesDlg)
     312           0 :                         m_pTablesDlg->successfullyConnected();
     313           0 :                 }
     314             :             }
     315           0 :             catch (const SQLException&)
     316             :             {
     317           0 :                 aErrorInfo = ::cppu::getCaughtException();
     318             :             }
     319             : 
     320           0 :             if (aErrorInfo.isValid())
     321             :             {
     322             :                 // establishing the connection failed. Show an error window and exit.
     323           0 :                 OSQLMessageBox aMessageBox( GetParentDialog(), aErrorInfo );
     324           0 :                 aMessageBox.Execute();
     325           0 :                 m_pTables->Enable(false);
     326           0 :                 m_pTablesList->Clear();
     327             : 
     328           0 :                 if ( m_pTablesDlg )
     329             :                 {
     330           0 :                     m_pTablesDlg->clearPassword();
     331           0 :                     m_pTablesDlg->endExecution();
     332           0 :                 }
     333             :             }
     334             :             else
     335             :             {
     336             :                 // in addition, we need some infos about the connection used
     337           0 :                 m_sCatalogSeparator = ".";    // (default)
     338           0 :                 m_bCatalogAtStart = true;   // (default)
     339             :                 try
     340             :                 {
     341           0 :                     Reference< XDatabaseMetaData > xMeta;
     342           0 :                     if (m_xCurrentConnection.is())
     343           0 :                         xMeta = m_xCurrentConnection->getMetaData();
     344           0 :                     if (xMeta.is() && xMeta->supportsCatalogsInDataManipulation())
     345             :                     {
     346           0 :                         m_sCatalogSeparator = xMeta->getCatalogSeparator();
     347           0 :                         m_bCatalogAtStart = xMeta->isCatalogAtStart();
     348           0 :                     }
     349             :                 }
     350           0 :                 catch(Exception&)
     351             :                 {
     352             :                     DBG_UNHANDLED_EXCEPTION();
     353             :                 }
     354           0 :             }
     355             :         }
     356             : 
     357             :         // get the current table filter
     358           0 :         SFX_ITEMSET_GET(_rSet, pTableFilter, OStringListItem, DSID_TABLEFILTER, true);
     359           0 :         Sequence< OUString > aTableFilter;
     360           0 :         if (pTableFilter)
     361           0 :             aTableFilter = pTableFilter->getList();
     362             : 
     363           0 :         implCompleteTablesCheck( aTableFilter );
     364             : 
     365             :         // expand the first entry by default
     366           0 :         SvTreeListEntry* pExpand = m_pTablesList->getAllObjectsEntry();
     367           0 :         while (pExpand)
     368             :         {
     369           0 :             m_pTablesList->Expand(pExpand);
     370           0 :             pExpand = m_pTablesList->FirstChild(pExpand);
     371           0 :             if (pExpand && m_pTablesList->NextSibling(pExpand))
     372           0 :                 pExpand = NULL;
     373             :         }
     374             : 
     375             :         // update the toolbox according the current selection and check state
     376           0 :         OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
     377             :     }
     378             : 
     379           0 :     void OTableSubscriptionPage::CheckAll( bool _bCheck )
     380             :     {
     381           0 :         SvButtonState eState = _bCheck ? SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED;
     382           0 :         SvTreeListEntry* pEntry = m_pTablesList->First();
     383           0 :         while (pEntry)
     384             :         {
     385           0 :             m_pTablesList->SetCheckButtonState( pEntry, eState);
     386           0 :             pEntry = m_pTablesList->Next(pEntry);
     387             :         }
     388             : 
     389           0 :         if (_bCheck && m_pTablesList->getAllObjectsEntry())
     390           0 :             m_pTablesList->checkWildcard(m_pTablesList->getAllObjectsEntry());
     391           0 :     }
     392             : 
     393           0 :     int OTableSubscriptionPage::DeactivatePage(SfxItemSet* _pSet)
     394             :     {
     395           0 :         int nResult = OGenericAdministrationPage::DeactivatePage(_pSet);
     396             : 
     397             :         // dispose the connection, we don't need it anymore, so we're not wasting resources
     398             :         try
     399             :         {
     400           0 :             ::comphelper::disposeComponent(m_xCurrentConnection);
     401             :         }
     402           0 :         catch (RuntimeException&) { }
     403             : 
     404           0 :         return nResult;
     405             :     }
     406           0 :     IMPL_LINK( OTableSubscriptionPage, OnTreeEntryChecked, Control*, _pControl )
     407             :     {
     408           0 :         return OnControlModified(_pControl);
     409             :     }
     410           0 :     IMPL_LINK( OTableSubscriptionPage, OnTreeEntryCompare, const SvSortData*, _pSortData )
     411             :     {
     412           0 :         const SvTreeListEntry* pLHS = static_cast<const SvTreeListEntry*>(_pSortData->pLeft);
     413           0 :         const SvTreeListEntry* pRHS = static_cast<const SvTreeListEntry*>(_pSortData->pRight);
     414             :         OSL_ENSURE(pLHS && pRHS, "SbaTableQueryBrowser::OnTreeEntryCompare: invalid tree entries!");
     415             : 
     416           0 :         const SvLBoxString* pLeftTextItem = static_cast<const SvLBoxString*>(pLHS->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
     417           0 :         const SvLBoxString* pRightTextItem = static_cast<const SvLBoxString*>(pRHS->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
     418             :         OSL_ENSURE(pLeftTextItem && pRightTextItem, "SbaTableQueryBrowser::OnTreeEntryCompare: invalid text items!");
     419             : 
     420           0 :         OUString sLeftText = pLeftTextItem->GetText();
     421           0 :         OUString sRightText = pRightTextItem->GetText();
     422             : 
     423           0 :         sal_Int32 nCompareResult = 0;   // equal by default
     424             : 
     425           0 :         if (m_xCollator.is())
     426             :         {
     427             :             try
     428             :             {
     429           0 :                 nCompareResult = m_xCollator->compareString(sLeftText, sRightText);
     430             :             }
     431           0 :             catch(Exception&)
     432             :             {
     433             :             }
     434             :         }
     435             :         else
     436             :             // default behaviour if we do not have a collator -> do the simple string compare
     437           0 :             nCompareResult = sLeftText.compareTo(sRightText);
     438             : 
     439           0 :         return nCompareResult;
     440             :     }
     441             : 
     442           0 :     Sequence< OUString > OTableSubscriptionPage::collectDetailedSelection() const
     443             :     {
     444           0 :         Sequence< OUString > aTableFilter;
     445           0 :         static const OUString sDot(".");
     446           0 :         static const OUString sWildcard("%");
     447             : 
     448           0 :         OUString sComposedName;
     449           0 :         const SvTreeListEntry* pAllObjectsEntry = m_pTablesList->getAllObjectsEntry();
     450           0 :         if (!pAllObjectsEntry)
     451           0 :             return aTableFilter;
     452           0 :         SvTreeListEntry* pEntry = m_pTablesList->GetModel()->Next(const_cast<SvTreeListEntry*>(pAllObjectsEntry));
     453           0 :         while(pEntry)
     454             :         {
     455           0 :             bool bCatalogWildcard = false;
     456           0 :             bool bSchemaWildcard =  false;
     457           0 :             SvTreeListEntry* pSchema = NULL;
     458           0 :             SvTreeListEntry* pCatalog = NULL;
     459             : 
     460           0 :             if (m_pTablesList->GetCheckButtonState(pEntry) == SV_BUTTON_CHECKED && !m_pTablesList->GetModel()->HasChildren(pEntry))
     461             :             {   // checked and a leaf, which means it's no catalog, no schema, but a real table
     462           0 :                 OUString sCatalog;
     463           0 :                 if(m_pTablesList->GetModel()->HasParent(pEntry))
     464             :                 {
     465           0 :                     pSchema = m_pTablesList->GetModel()->GetParent(pEntry);
     466           0 :                     if (pAllObjectsEntry == pSchema)
     467             :                         // do not want to have the root entry
     468           0 :                         pSchema = NULL;
     469             : 
     470           0 :                     if (pSchema)
     471             :                     {   // it's a real schema entry, not the "all objects" root
     472           0 :                         if(m_pTablesList->GetModel()->HasParent(pSchema))
     473             :                         {
     474           0 :                             pCatalog = m_pTablesList->GetModel()->GetParent(pSchema);
     475           0 :                             if (pAllObjectsEntry == pCatalog)
     476             :                                 // do not want to have the root entry
     477           0 :                                 pCatalog = NULL;
     478             : 
     479           0 :                             if (pCatalog)
     480             :                             {   // it's a real catalog entry, not the "all objects" root
     481           0 :                                 bCatalogWildcard = m_pTablesList->isWildcardChecked(pCatalog);
     482           0 :                                 if (m_bCatalogAtStart)
     483             :                                 {
     484           0 :                                     sComposedName += m_pTablesList->GetEntryText( pCatalog );
     485           0 :                                     sComposedName += m_sCatalogSeparator;
     486           0 :                                     if (bCatalogWildcard)
     487           0 :                                         sComposedName += sWildcard;
     488             :                                 }
     489             :                                 else
     490             :                                 {
     491           0 :                                     if (bCatalogWildcard)
     492           0 :                                         sCatalog = sWildcard;
     493             :                                     else
     494           0 :                                         sCatalog = "";
     495           0 :                                     sCatalog += m_sCatalogSeparator;
     496           0 :                                     sCatalog += m_pTablesList->GetEntryText( pCatalog );
     497             :                                 }
     498             :                             }
     499             :                         }
     500           0 :                         bSchemaWildcard = m_pTablesList->isWildcardChecked(pSchema);
     501           0 :                         sComposedName += m_pTablesList->GetEntryText( pSchema );
     502           0 :                         sComposedName += sDot;
     503             :                     }
     504             : 
     505           0 :                     if (bSchemaWildcard)
     506           0 :                         sComposedName += sWildcard;
     507             :                 }
     508           0 :                 if (!bSchemaWildcard && !bCatalogWildcard)
     509           0 :                     sComposedName += m_pTablesList->GetEntryText( pEntry );
     510             : 
     511           0 :                 if (!m_bCatalogAtStart && !bCatalogWildcard)
     512           0 :                     sComposedName += sCatalog;
     513             : 
     514             :                 // need some space
     515           0 :                 sal_Int32 nOldLen = aTableFilter.getLength();
     516           0 :                 aTableFilter.realloc(nOldLen + 1);
     517             :                 // add the new name
     518           0 :                 aTableFilter[nOldLen] = sComposedName;
     519             : 
     520             :                 // reset the composed name
     521           0 :                 sComposedName = "";
     522             :             }
     523             : 
     524           0 :             if (bCatalogWildcard)
     525           0 :                 pEntry = implNextSibling(pCatalog);
     526           0 :             else if (bSchemaWildcard)
     527           0 :                 pEntry = implNextSibling(pSchema);
     528             :             else
     529           0 :                 pEntry = m_pTablesList->GetModel()->Next(pEntry);
     530             :         }
     531             : 
     532           0 :         return aTableFilter;
     533             :     }
     534             : 
     535           0 :     SvTreeListEntry* OTableSubscriptionPage::implNextSibling(SvTreeListEntry* _pEntry) const
     536             :     {
     537           0 :         SvTreeListEntry* pReturn = NULL;
     538           0 :         if (_pEntry)
     539             :         {
     540           0 :             pReturn = m_pTablesList->NextSibling(_pEntry);
     541           0 :             if (!pReturn)
     542           0 :                 pReturn = implNextSibling(m_pTablesList->GetParent(_pEntry));
     543             :         }
     544           0 :         return pReturn;
     545             :     }
     546             : 
     547           0 :     bool OTableSubscriptionPage::FillItemSet( SfxItemSet* _rCoreAttrs )
     548             :     {
     549             :         bool bValid, bReadonly;
     550           0 :         getFlags(*_rCoreAttrs, bValid, bReadonly);
     551             : 
     552           0 :         if (!bValid || bReadonly)
     553             :             // don't store anything if the data we're working with is invalid or readonly
     554           0 :             return true;
     555             : 
     556             :         // create the output string which contains all the table names
     557           0 :         if ( m_xCurrentConnection.is() )
     558             :         {   // collect the table filter data only if we have a connection - else no tables are displayed at all
     559           0 :             Sequence< OUString > aTableFilter;
     560           0 :             if (m_pTablesList->isWildcardChecked(m_pTablesList->getAllObjectsEntry()))
     561             :             {
     562           0 :                 aTableFilter.realloc(1);
     563           0 :                 aTableFilter[0] = "%";
     564             :             }
     565             :             else
     566             :             {
     567           0 :                 aTableFilter = collectDetailedSelection();
     568             :             }
     569           0 :             _rCoreAttrs->Put( OStringListItem(DSID_TABLEFILTER, aTableFilter) );
     570             :         }
     571             : 
     572           0 :         return true;
     573             :     }
     574             : 
     575           0 :     void OTableSubscriptionPage::fillControls(::std::vector< ISaveValueWrapper* >& /*_rControlList*/)
     576             :     {
     577           0 :     }
     578             : 
     579           0 :     void OTableSubscriptionPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
     580             :     {
     581           0 :         _rControlList.push_back(new ODisableWrapper<VclContainer>(m_pTables));
     582           0 :     }
     583          72 : }   // namespace dbaui
     584             : 
     585             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10