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

Generated by: LCOV version 1.10