LCOV - code coverage report
Current view: top level - dbaccess/source/ui/app - AppControllerGen.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 354 0.0 %
Date: 2012-08-25 Functions: 0 37 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 943 0.0 %

           Branch data     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 "AppController.hxx"
      22                 :            : #include "AppDetailView.hxx"
      23                 :            : #include "AppView.hxx"
      24                 :            : #include "dbaccess_slotid.hrc"
      25                 :            : #include "dbu_app.hrc"
      26                 :            : #include "dbustrings.hrc"
      27                 :            : #include "defaultobjectnamecheck.hxx"
      28                 :            : #include "dlgsave.hxx"
      29                 :            : #include "UITools.hxx"
      30                 :            : #include "subcomponentmanager.hxx"
      31                 :            : 
      32                 :            : #include <com/sun/star/container/XChild.hpp>
      33                 :            : #include <com/sun/star/container/XContainer.hpp>
      34                 :            : #include <com/sun/star/container/XHierarchicalNameContainer.hpp>
      35                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      36                 :            : #include <com/sun/star/container/XNameContainer.hpp>
      37                 :            : #include <com/sun/star/lang/XEventListener.hpp>
      38                 :            : #include <com/sun/star/sdb/CommandType.hpp>
      39                 :            : #include <com/sun/star/sdb/SQLContext.hpp>
      40                 :            : #include <com/sun/star/sdb/XQueriesSupplier.hpp>
      41                 :            : #include <com/sun/star/sdbcx/XRename.hpp>
      42                 :            : #include <com/sun/star/sdb/ErrorCondition.hpp>
      43                 :            : #include <com/sun/star/sdb/application/DatabaseObject.hpp>
      44                 :            : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
      45                 :            : #include <com/sun/star/sdbcx/XViewsSupplier.hpp>
      46                 :            : #include <com/sun/star/ucb/Command.hpp>
      47                 :            : #include <com/sun/star/ucb/XCommandEnvironment.hpp>
      48                 :            : #include <com/sun/star/ucb/XCommandProcessor.hpp>
      49                 :            : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
      50                 :            : #include <com/sun/star/uno/XNamingService.hpp>
      51                 :            : #include <com/sun/star/util/XCloseable.hpp>
      52                 :            : #include <com/sun/star/util/XRefreshable.hpp>
      53                 :            : 
      54                 :            : #include <cppuhelper/exc_hlp.hxx>
      55                 :            : #include <connectivity/dbexception.hxx>
      56                 :            : #include <connectivity/dbtools.hxx>
      57                 :            : #include <connectivity/sqlerror.hxx>
      58                 :            : #include <sfx2/mailmodelapi.hxx>
      59                 :            : #include <svx/dbaexchange.hxx>
      60                 :            : #include <toolkit/unohlp.hxx>
      61                 :            : #include <tools/diagnose_ex.h>
      62                 :            : #include <osl/diagnose.h>
      63                 :            : #include <unotools/bootstrap.hxx>
      64                 :            : #include <vcl/mnemonic.hxx>
      65                 :            : #include <vcl/svapp.hxx>
      66                 :            : #include <vcl/waitobj.hxx>
      67                 :            : #include <osl/mutex.hxx>
      68                 :            : 
      69                 :            : //........................................................................
      70                 :            : namespace dbaui
      71                 :            : {
      72                 :            : using namespace ::dbtools;
      73                 :            : using namespace ::connectivity;
      74                 :            : using namespace ::svx;
      75                 :            : using namespace ::com::sun::star;
      76                 :            : using namespace ::com::sun::star::uno;
      77                 :            : using namespace ::com::sun::star::awt;
      78                 :            : using namespace ::com::sun::star::util;
      79                 :            : using namespace ::com::sun::star::frame;
      80                 :            : using namespace ::com::sun::star::lang;
      81                 :            : using namespace ::com::sun::star::ui::dialogs;
      82                 :            : using namespace ::com::sun::star::sdb;
      83                 :            : using namespace ::com::sun::star::sdbc;
      84                 :            : using namespace ::com::sun::star::sdbcx;
      85                 :            : using namespace ::com::sun::star::beans;
      86                 :            : using namespace ::com::sun::star::container;
      87                 :            : using namespace ::com::sun::star::ucb;
      88                 :            : 
      89                 :            : /** === begin UNO using === **/
      90                 :            : using ::com::sun::star::util::XCloseable;
      91                 :            : using ::com::sun::star::ui::XContextMenuInterceptor;
      92                 :            : /** === end UNO using === **/
      93                 :            : 
      94                 :            : namespace DatabaseObject = ::com::sun::star::sdb::application::DatabaseObject;
      95                 :            : namespace ErrorCondition = ::com::sun::star::sdb::ErrorCondition;
      96                 :            : 
      97                 :            : //........................................................................
      98                 :            : // -----------------------------------------------------------------------------
      99                 :            : 
     100                 :            : class CloseChecker : public ::cppu::WeakImplHelper1< com::sun::star::lang::XEventListener >
     101                 :            : {
     102                 :            :     bool    m_bClosed;
     103                 :            : 
     104                 :            : public:
     105                 :            :     CloseChecker()
     106                 :            :         :m_bClosed( false )
     107                 :            :     {
     108                 :            :     }
     109                 :            : 
     110                 :          0 :     virtual ~CloseChecker()
     111                 :          0 :     {
     112         [ #  # ]:          0 :     }
     113                 :            : 
     114                 :            :     bool isClosed()
     115                 :            :     {
     116                 :            :         return true;
     117                 :            :     }
     118                 :            : 
     119                 :            :     // interface XEventListener
     120                 :          0 :     virtual void SAL_CALL disposing( const EventObject& /*Source*/ ) throw( RuntimeException )
     121                 :            :     {
     122                 :          0 :         m_bClosed = true;
     123                 :          0 :     }
     124                 :            : 
     125                 :            : };
     126                 :            : // -----------------------------------------------------------------------------
     127                 :          0 : void OApplicationController::convertToView(const ::rtl::OUString& _sName)
     128                 :            : {
     129                 :            :     try
     130                 :            :     {
     131         [ #  # ]:          0 :         SharedConnection xConnection( getConnection() );
     132         [ #  # ]:          0 :         Reference< XQueriesSupplier > xSup( xConnection, UNO_QUERY_THROW );
     133 [ #  # ][ #  # ]:          0 :         Reference< XNameAccess > xQueries( xSup->getQueries(), UNO_QUERY_THROW );
                 [ #  # ]
     134 [ #  # ][ #  # ]:          0 :         Reference< XPropertySet > xSourceObject( xQueries->getByName( _sName ), UNO_QUERY_THROW );
                 [ #  # ]
     135                 :            : 
     136         [ #  # ]:          0 :         Reference< XTablesSupplier > xTablesSup( xConnection, UNO_QUERY_THROW );
     137 [ #  # ][ #  # ]:          0 :         Reference< XNameAccess > xTables( xTablesSup->getTables(), UNO_QUERY_THROW );
                 [ #  # ]
     138                 :            : 
     139 [ #  # ][ #  # ]:          0 :         Reference< XDatabaseMetaData  > xMeta = xConnection->getMetaData();
     140                 :            : 
     141 [ #  # ][ #  # ]:          0 :         String aName = String(ModuleRes(STR_TBL_TITLE));
     142 [ #  # ][ #  # ]:          0 :         aName = aName.GetToken(0,' ');
                 [ #  # ]
     143 [ #  # ][ #  # ]:          0 :         String aDefaultName = ::dbaui::createDefaultName(xMeta,xTables,aName);
                 [ #  # ]
     144                 :            : 
     145         [ #  # ]:          0 :         DynamicTableOrQueryNameCheck aNameChecker( xConnection, CommandType::TABLE );
     146 [ #  # ][ #  # ]:          0 :         OSaveAsDlg aDlg( getView(), CommandType::TABLE, getORB(), xConnection, aDefaultName, aNameChecker );
     147 [ #  # ][ #  # ]:          0 :         if ( aDlg.Execute() == RET_OK )
     148                 :            :         {
     149 [ #  # ][ #  # ]:          0 :             ::rtl::OUString sName = aDlg.getName();
                 [ #  # ]
     150 [ #  # ][ #  # ]:          0 :             ::rtl::OUString sCatalog = aDlg.getCatalog();
                 [ #  # ]
     151 [ #  # ][ #  # ]:          0 :             ::rtl::OUString sSchema  = aDlg.getSchema();
                 [ #  # ]
     152                 :            :             ::rtl::OUString sNewName(
     153         [ #  # ]:          0 :                 ::dbtools::composeTableName( xMeta, sCatalog, sSchema, sName, sal_False, ::dbtools::eInTableDefinitions ) );
     154         [ #  # ]:          0 :             Reference<XPropertySet> xView = ::dbaui::createView(sNewName,xConnection,xSourceObject);
     155         [ #  # ]:          0 :             if ( !xView.is() )
     156 [ #  # ][ #  # ]:          0 :                 throw SQLException(String(ModuleRes(STR_NO_TABLE_FORMAT_INSIDE)),*this,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")) ,0,Any());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     157 [ #  # ][ #  # ]:          0 :             getContainer()->elementAdded(E_TABLE,sNewName,makeAny(xView));
                 [ #  # ]
     158 [ #  # ][ #  # ]:          0 :         }
         [ #  # ][ #  # ]
                 [ #  # ]
     159                 :            :     }
     160      [ #  #  # ]:          0 :     catch(const SQLException& )
     161                 :            :     {
     162   [ #  #  #  #  :          0 :         showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
             #  #  #  # ]
     163                 :            :     }
     164                 :          0 :     catch( const Exception& )
     165                 :            :     {
     166                 :            :         DBG_UNHANDLED_EXCEPTION();
     167                 :            :     }
     168                 :          0 : }
     169                 :            : // -----------------------------------------------------------------------------
     170                 :          0 : void OApplicationController::pasteFormat(sal_uInt32 _nFormatId)
     171                 :            : {
     172         [ #  # ]:          0 :     if ( _nFormatId )
     173                 :            :     {
     174                 :            :         try
     175                 :            :         {
     176                 :          0 :             const TransferableDataHelper& rClipboard = getViewClipboard();
     177 [ #  # ][ #  # ]:          0 :             ElementType eType = getContainer()->getElementType();
     178         [ #  # ]:          0 :             if ( eType == E_TABLE )
     179                 :            :             {
     180 [ #  # ][ #  # ]:          0 :                 m_aTableCopyHelper.pasteTable( _nFormatId, rClipboard, getDatabaseName(), ensureConnection() );
                 [ #  # ]
     181                 :            :             }
     182                 :            :             else
     183 [ #  # ][ #  # ]:          0 :                 paste( eType, ODataAccessObjectTransferable::extractObjectDescriptor( rClipboard ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     184                 :            : 
     185                 :            :         }
     186                 :          0 :         catch( const Exception& )
     187                 :            :         {
     188                 :            :             DBG_UNHANDLED_EXCEPTION();
     189                 :            :         }
     190                 :            :     }
     191                 :          0 : }
     192                 :            : // -----------------------------------------------------------------------------
     193                 :          0 : void OApplicationController::openDataSourceAdminDialog()
     194                 :            : {
     195         [ #  # ]:          0 :     openDialog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.DatasourceAdministrationDialog" ) ) );
     196                 :          0 : }
     197                 :            : 
     198                 :            : // -----------------------------------------------------------------------------
     199                 :          0 : void OApplicationController::openDialog( const ::rtl::OUString& _sServiceName )
     200                 :            : {
     201                 :            :     try
     202                 :            :     {
     203         [ #  # ]:          0 :         SolarMutexGuard aSolarGuard;
     204 [ #  # ][ #  # ]:          0 :         ::osl::MutexGuard aGuard( getMutex() );
     205         [ #  # ]:          0 :         WaitObject aWO(getView());
     206                 :            : 
     207         [ #  # ]:          0 :         Sequence< Any > aArgs(3);
     208                 :          0 :         sal_Int32 nArgPos = 0;
     209                 :            : 
     210         [ #  # ]:          0 :         Reference< ::com::sun::star::awt::XWindow> xWindow = getTopMostContainerWindow();
     211         [ #  # ]:          0 :         if ( !xWindow.is() )
     212                 :            :         {
     213                 :            :             OSL_ENSURE( getContainer(), "OApplicationController::Construct: have no view!" );
     214 [ #  # ][ #  # ]:          0 :             if ( getContainer() )
     215 [ #  # ][ #  # ]:          0 :                 xWindow = VCLUnoHelper::GetInterface(getView()->Window::GetParent());
                 [ #  # ]
     216                 :            :         }
     217                 :            :         // the parent window
     218         [ #  # ]:          0 :         aArgs[nArgPos++] <<= PropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParentWindow")),
     219                 :            :                                     0,
     220                 :            :                                     makeAny(xWindow),
     221 [ #  # ][ #  # ]:          0 :                                     PropertyState_DIRECT_VALUE);
                 [ #  # ]
     222                 :            : 
     223                 :            :         // the initial selection
     224                 :          0 :         ::rtl::OUString sInitialSelection;
     225 [ #  # ][ #  # ]:          0 :         if ( getContainer() )
     226         [ #  # ]:          0 :             sInitialSelection = getDatabaseName();
     227         [ #  # ]:          0 :         if ( !sInitialSelection.isEmpty() )
     228                 :            :         {
     229         [ #  # ]:          0 :             aArgs[ nArgPos++ ] <<= PropertyValue(
     230                 :            :                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InitialSelection" ) ), 0,
     231 [ #  # ][ #  # ]:          0 :                 makeAny( sInitialSelection ), PropertyState_DIRECT_VALUE );
                 [ #  # ]
     232                 :            :         }
     233                 :            : 
     234         [ #  # ]:          0 :         SharedConnection xConnection( getConnection() );
     235         [ #  # ]:          0 :         if ( xConnection.is() )
     236                 :            :         {
     237         [ #  # ]:          0 :             aArgs[ nArgPos++ ] <<= PropertyValue(
     238                 :            :                 PROPERTY_ACTIVE_CONNECTION, 0,
     239 [ #  # ][ #  # ]:          0 :                 makeAny( xConnection ), PropertyState_DIRECT_VALUE );
                 [ #  # ]
     240                 :            :         }
     241         [ #  # ]:          0 :         aArgs.realloc( nArgPos );
     242                 :            : 
     243                 :            :         // create the dialog
     244                 :          0 :         Reference< XExecutableDialog > xAdminDialog;
     245                 :            :         xAdminDialog = Reference< XExecutableDialog >(
     246 [ #  # ][ #  # ]:          0 :             getORB()->createInstanceWithArguments(_sServiceName,aArgs), UNO_QUERY);
         [ #  # ][ #  # ]
                 [ #  # ]
     247                 :            : 
     248                 :            :         // execute it
     249         [ #  # ]:          0 :         if (xAdminDialog.is())
     250 [ #  # ][ #  # ]:          0 :             xAdminDialog->execute();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     251                 :            :     }
     252                 :          0 :     catch( const Exception& )
     253                 :            :     {
     254                 :            :         DBG_UNHANDLED_EXCEPTION();
     255                 :            :     }
     256                 :          0 : }
     257                 :            : // -----------------------------------------------------------------------------
     258                 :          0 : void OApplicationController::openTableFilterDialog()
     259                 :            : {
     260         [ #  # ]:          0 :     openDialog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.TableFilterDialog" ) ) );
     261                 :          0 : }
     262                 :            : 
     263                 :            : // -----------------------------------------------------------------------------
     264                 :          0 : void OApplicationController::refreshTables()
     265                 :            : {
     266 [ #  # ][ #  # ]:          0 :     if ( getContainer() && getContainer()->getDetailView() )
                 [ #  # ]
     267                 :            :     {
     268         [ #  # ]:          0 :         WaitObject aWO(getView());
     269                 :            :         OSL_ENSURE(getContainer()->getElementType() == E_TABLE,"Only allowed when the tables container is selected!");
     270                 :            :         try
     271                 :            :         {
     272 [ #  # ][ #  # ]:          0 :             Reference<XRefreshable> xRefresh(getElements(E_TABLE),UNO_QUERY);
     273         [ #  # ]:          0 :             if ( xRefresh.is() )
     274 [ #  # ][ #  # ]:          0 :                 xRefresh->refresh();
                 [ #  # ]
     275                 :            :         }
     276         [ #  # ]:          0 :         catch(const Exception&)
     277                 :            :         {
     278                 :            :             OSL_FAIL("Could not refresh tables!");
     279                 :            :         }
     280                 :            : 
     281 [ #  # ][ #  # ]:          0 :         getContainer()->getDetailView()->clearPages(sal_False);
                 [ #  # ]
     282 [ #  # ][ #  # ]:          0 :         getContainer()->getDetailView()->createTablesPage( ensureConnection() );
         [ #  # ][ #  # ]
                 [ #  # ]
     283                 :            :     }
     284                 :          0 : }
     285                 :            : // -----------------------------------------------------------------------------
     286                 :          0 : void OApplicationController::openDirectSQLDialog()
     287                 :            : {
     288         [ #  # ]:          0 :     openDialog( SERVICE_SDB_DIRECTSQLDIALOG );
     289                 :          0 : }
     290                 :            : // -----------------------------------------------------------------------------
     291                 :          0 : void SAL_CALL OApplicationController::propertyChange( const PropertyChangeEvent& evt ) throw (RuntimeException)
     292                 :            : {
     293         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     294 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard( getMutex() );
     295 [ #  # ][ #  # ]:          0 :     if ( evt.PropertyName == PROPERTY_USER )
     296                 :            :     {
     297                 :          0 :         m_bNeedToReconnect = sal_True;
     298 [ #  # ][ #  # ]:          0 :         InvalidateFeature(SID_DB_APP_STATUS_USERNAME);
     299                 :            :     }
     300 [ #  # ][ #  # ]:          0 :     else if ( evt.PropertyName == PROPERTY_URL )
     301                 :            :     {
     302                 :          0 :         m_bNeedToReconnect = sal_True;
     303 [ #  # ][ #  # ]:          0 :         InvalidateFeature(SID_DB_APP_STATUS_DBNAME);
     304 [ #  # ][ #  # ]:          0 :         InvalidateFeature(SID_DB_APP_STATUS_TYPE);
     305 [ #  # ][ #  # ]:          0 :         InvalidateFeature(SID_DB_APP_STATUS_HOSTNAME);
     306                 :            :     }
     307 [ #  # ][ #  # ]:          0 :     else if ( PROPERTY_NAME == evt.PropertyName )
     308                 :            :     {
     309 [ #  # ][ #  # ]:          0 :         const ElementType eType = getContainer()->getElementType();
     310 [ #  # ][ #  # ]:          0 :         if ( eType == E_FORM || eType == E_REPORT )
     311                 :            :         {
     312                 :          0 :             ::rtl::OUString sOldName,sNewName;
     313                 :          0 :             evt.OldValue >>= sOldName;
     314                 :          0 :             evt.NewValue >>= sNewName;
     315                 :            : 
     316                 :            :             // if the old name is empty, then this is a newly inserted content. We're notified of it via the
     317                 :            :             // elementInserted method, so there's no need to handle it here.
     318                 :            : 
     319         [ #  # ]:          0 :             if ( !sOldName.isEmpty() )
     320                 :            :             {
     321         [ #  # ]:          0 :                 Reference<XChild> xChild(evt.Source,UNO_QUERY);
     322         [ #  # ]:          0 :                 if ( xChild.is() )
     323                 :            :                 {
     324 [ #  # ][ #  # ]:          0 :                     Reference<XContent> xContent(xChild->getParent(),UNO_QUERY);
                 [ #  # ]
     325         [ #  # ]:          0 :                     if ( xContent.is() )
     326 [ #  # ][ #  # ]:          0 :                         sOldName = xContent->getIdentifier()->getContentIdentifier() + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sOldName;
         [ #  # ][ #  # ]
                 [ #  # ]
     327                 :            :                 }
     328                 :            : 
     329 [ #  # ][ #  # ]:          0 :                 getContainer()->elementReplaced( eType , sOldName, sNewName );
     330                 :          0 :             }
     331                 :            :         }
     332                 :            :     }
     333                 :            : 
     334         [ #  # ]:          0 :     EventObject aEvt;
     335         [ #  # ]:          0 :     aEvt.Source = m_xModel;
     336 [ #  # ][ #  # ]:          0 :     modified(aEvt);
         [ #  # ][ #  # ]
     337                 :          0 : }
     338                 :            : 
     339                 :            : // -----------------------------------------------------------------------------
     340                 :          0 : Reference< XDataSource > SAL_CALL OApplicationController::getDataSource() throw (RuntimeException)
     341                 :            : {
     342 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard( getMutex() );
     343         [ #  # ]:          0 :     Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY );
     344         [ #  # ]:          0 :     return xDataSource;
     345                 :            : }
     346                 :            : 
     347                 :            : // -----------------------------------------------------------------------------
     348                 :          0 : Reference< XWindow > SAL_CALL OApplicationController::getApplicationMainWindow() throw (RuntimeException)
     349                 :            : {
     350 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard( getMutex() );
     351 [ #  # ][ #  # ]:          0 :     Reference< XFrame > xFrame( getFrame(), UNO_QUERY_THROW );
     352 [ #  # ][ #  # ]:          0 :     Reference< XWindow > xWindow( xFrame->getContainerWindow(), UNO_QUERY_THROW );
                 [ #  # ]
     353         [ #  # ]:          0 :     return xWindow;
     354                 :            : }
     355                 :            : 
     356                 :            : // -----------------------------------------------------------------------------
     357                 :          0 : Sequence< Reference< XComponent > > SAL_CALL OApplicationController::getSubComponents() throw (RuntimeException)
     358                 :            : {
     359 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard( getMutex() );
     360 [ #  # ][ #  # ]:          0 :     return m_pSubComponentManager->getSubComponents();
     361                 :            : }
     362                 :            : 
     363                 :            : // -----------------------------------------------------------------------------
     364                 :          0 : Reference< XConnection > SAL_CALL OApplicationController::getActiveConnection() throw (RuntimeException)
     365                 :            : {
     366 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard( getMutex() );
     367         [ #  # ]:          0 :     return m_xDataSourceConnection.getTyped();
     368                 :            : }
     369                 :            : 
     370                 :            : // -----------------------------------------------------------------------------
     371                 :          0 : ::sal_Bool SAL_CALL OApplicationController::isConnected(  ) throw (RuntimeException)
     372                 :            : {
     373 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard( getMutex() );
     374         [ #  # ]:          0 :     return m_xDataSourceConnection.is();
     375                 :            : }
     376                 :            : 
     377                 :            : // -----------------------------------------------------------------------------
     378                 :          0 : void SAL_CALL OApplicationController::connect(  ) throw (SQLException, RuntimeException)
     379                 :            : {
     380         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     381 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard( getMutex() );
     382                 :            : 
     383         [ #  # ]:          0 :     SQLExceptionInfo aError;
     384 [ #  # ][ #  # ]:          0 :     SharedConnection xConnection = ensureConnection( &aError );
     385         [ #  # ]:          0 :     if ( !xConnection.is() )
     386                 :            :     {
     387         [ #  # ]:          0 :         if ( aError.isValid() )
     388         [ #  # ]:          0 :             aError.doThrow();
     389                 :            : 
     390                 :            :         // no particular error, but nonetheless could not connect -> throw a generic exception
     391 [ #  # ][ #  # ]:          0 :         String sConnectingContext( ModuleRes( STR_COULDNOTCONNECT_DATASOURCE ) );
     392 [ #  # ][ #  # ]:          0 :         sConnectingContext.SearchAndReplaceAscii( "$name$", getStrippedDatabaseName() );
         [ #  # ][ #  # ]
     393 [ #  # ][ #  # ]:          0 :         ::dbtools::throwGenericSQLException( sConnectingContext, *this );
         [ #  # ][ #  # ]
     394 [ #  # ][ #  # ]:          0 :     }
         [ #  # ][ #  # ]
     395                 :          0 : }
     396                 :            : 
     397                 :            : // -----------------------------------------------------------------------------
     398                 :          0 : beans::Pair< ::sal_Int32, ::rtl::OUString > SAL_CALL OApplicationController::identifySubComponent( const Reference< XComponent >& i_rSubComponent ) throw (IllegalArgumentException, RuntimeException)
     399                 :            : {
     400 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard( getMutex() );
     401                 :            : 
     402                 :          0 :     sal_Int32 nType = -1;
     403                 :          0 :     ::rtl::OUString sName;
     404                 :            : 
     405 [ #  # ][ #  # ]:          0 :     if ( !m_pSubComponentManager->lookupSubComponent( i_rSubComponent, sName, nType ) )
     406 [ #  # ][ #  # ]:          0 :         throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
     407                 :            : 
     408         [ #  # ]:          0 :     if ( nType == SID_DB_APP_DSRELDESIGN )
     409                 :            :         // this is somewhat hacky ... we're expected to return a DatabaseObject value. However, there is no such
     410                 :            :         // value for the relation design. /me thinks we should change the API definition here ...
     411                 :          0 :         nType = -1;
     412                 :            : 
     413         [ #  # ]:          0 :     return beans::Pair< ::sal_Int32, ::rtl::OUString >( nType, sName );
     414                 :            : }
     415                 :            : 
     416                 :            : // -----------------------------------------------------------------------------
     417                 :          0 : ::sal_Bool SAL_CALL OApplicationController::closeSubComponents(  ) throw (RuntimeException)
     418                 :            : {
     419         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     420 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard( getMutex() );
     421 [ #  # ][ #  # ]:          0 :     return m_pSubComponentManager->closeSubComponents();
                 [ #  # ]
     422                 :            : }
     423                 :            : 
     424                 :            : 
     425                 :            : // -----------------------------------------------------------------------------
     426                 :            : namespace
     427                 :            : {
     428                 :          0 :     ElementType lcl_objectType2ElementType( const sal_Int32 _nObjectType )
     429                 :            :     {
     430                 :          0 :         ElementType eType( E_NONE );
     431   [ #  #  #  #  :          0 :         switch ( _nObjectType )
                      # ]
     432                 :            :         {
     433                 :          0 :         case DatabaseObject::TABLE:  eType = E_TABLE;   break;
     434                 :          0 :         case DatabaseObject::QUERY:  eType = E_QUERY;   break;
     435                 :          0 :         case DatabaseObject::FORM:   eType = E_FORM;    break;
     436                 :          0 :         case DatabaseObject::REPORT: eType = E_REPORT;  break;
     437                 :            :         default:
     438                 :            :             OSL_FAIL( "lcl_objectType2ElementType: unsupported object type!" );
     439                 :            :                 // this should have been caught earlier
     440                 :            :         }
     441                 :          0 :         return eType;
     442                 :            :     }
     443                 :            : }
     444                 :            : 
     445                 :            : // -----------------------------------------------------------------------------
     446                 :          0 : void OApplicationController::impl_validateObjectTypeAndName_throw( const sal_Int32 _nObjectType, const ::boost::optional< ::rtl::OUString >& i_rObjectName )
     447                 :            : {
     448                 :            :     // ensure we're connected
     449 [ #  # ][ #  # ]:          0 :     if ( !isConnected() )
     450                 :            :     {
     451 [ #  # ][ #  # ]:          0 :         SQLError aError( getORB() );
         [ #  # ][ #  # ]
     452 [ #  # ][ #  # ]:          0 :         aError.raiseException( ErrorCondition::DB_NOT_CONNECTED, *this );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     453                 :            :     }
     454                 :            : 
     455                 :            :     // ensure a proper object type
     456 [ #  # ][ #  # ]:          0 :     if  (   ( _nObjectType != DatabaseObject::TABLE )
         [ #  # ][ #  # ]
     457                 :            :         &&  ( _nObjectType != DatabaseObject::QUERY )
     458                 :            :         &&  ( _nObjectType != DatabaseObject::FORM )
     459                 :            :         &&  ( _nObjectType != DatabaseObject::REPORT )
     460                 :            :         )
     461 [ #  # ][ #  # ]:          0 :         throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
     462                 :            : 
     463 [ #  # ][ #  # ]:          0 :     if ( !i_rObjectName )
     464                 :          0 :         return;
     465                 :            : 
     466                 :            :     // ensure an existing object
     467         [ #  # ]:          0 :     Reference< XNameAccess > xContainer( getElements( lcl_objectType2ElementType( _nObjectType ) ) );
     468         [ #  # ]:          0 :     if ( !xContainer.is() )
     469                 :            :         // all possible reasons for this (e.g. not being connected currently) should
     470                 :            :         // have been handled before
     471 [ #  # ][ #  # ]:          0 :         throw RuntimeException( ::rtl::OUString(), *this );
     472                 :            : 
     473                 :          0 :     bool bExistentObject = false;
     474      [ #  #  # ]:          0 :     switch ( _nObjectType )
     475                 :            :     {
     476                 :            :     case DatabaseObject::TABLE:
     477                 :            :     case DatabaseObject::QUERY:
     478 [ #  # ][ #  # ]:          0 :         bExistentObject = xContainer->hasByName( *i_rObjectName );
                 [ #  # ]
     479                 :          0 :         break;
     480                 :            :     case DatabaseObject::FORM:
     481                 :            :     case DatabaseObject::REPORT:
     482                 :            :     {
     483         [ #  # ]:          0 :         Reference< XHierarchicalNameAccess > xHierarchy( xContainer, UNO_QUERY_THROW );
     484 [ #  # ][ #  # ]:          0 :         bExistentObject = xHierarchy->hasByHierarchicalName( *i_rObjectName );
                 [ #  # ]
     485                 :            :     }
     486                 :          0 :     break;
     487                 :            :     }
     488                 :            : 
     489         [ #  # ]:          0 :     if ( !bExistentObject )
     490 [ #  # ][ #  # ]:          0 :         throw NoSuchElementException( *i_rObjectName, *this );
                 [ #  # ]
     491                 :            : }
     492                 :            : 
     493                 :            : // -----------------------------------------------------------------------------
     494                 :          0 : Reference< XComponent > SAL_CALL OApplicationController::loadComponent( ::sal_Int32 _ObjectType,
     495                 :            :     const ::rtl::OUString& _ObjectName, ::sal_Bool _ForEditing ) throw (IllegalArgumentException, NoSuchElementException, SQLException, RuntimeException)
     496                 :            : {
     497         [ #  # ]:          0 :     return loadComponentWithArguments( _ObjectType, _ObjectName, _ForEditing, Sequence< PropertyValue >() );
     498                 :            : }
     499                 :            : 
     500                 :            : // -----------------------------------------------------------------------------
     501                 :          0 : Reference< XComponent > SAL_CALL OApplicationController::loadComponentWithArguments( ::sal_Int32 _ObjectType,
     502                 :            :     const ::rtl::OUString& _ObjectName, ::sal_Bool _ForEditing, const Sequence< PropertyValue >& _Arguments ) throw (IllegalArgumentException, NoSuchElementException, SQLException, RuntimeException)
     503                 :            : {
     504         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     505 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard( getMutex() );
     506                 :            : 
     507 [ #  # ][ #  # ]:          0 :     impl_validateObjectTypeAndName_throw( _ObjectType, _ObjectName );
                 [ #  # ]
     508                 :            : 
     509                 :            :     Reference< XComponent > xComponent( openElementWithArguments(
     510                 :            :         _ObjectName,
     511                 :            :         lcl_objectType2ElementType( _ObjectType ),
     512                 :            :         _ForEditing ? E_OPEN_DESIGN : E_OPEN_NORMAL,
     513                 :            :         _ForEditing ? SID_DB_APP_EDIT : SID_DB_APP_OPEN,
     514                 :            :         ::comphelper::NamedValueCollection( _Arguments )
     515 [ #  # ][ #  # ]:          0 :     ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     516                 :            : 
     517 [ #  # ][ #  # ]:          0 :     return xComponent;
     518                 :            : }
     519                 :            : 
     520                 :            : // -----------------------------------------------------------------------------
     521                 :          0 : Reference< XComponent > SAL_CALL OApplicationController::createComponent( ::sal_Int32 i_nObjectType, Reference< XComponent >& o_DocumentDefinition  ) throw (IllegalArgumentException, SQLException, RuntimeException)
     522                 :            : {
     523         [ #  # ]:          0 :     return createComponentWithArguments( i_nObjectType, Sequence< PropertyValue >(), o_DocumentDefinition );
     524                 :            : }
     525                 :            : 
     526                 :            : // -----------------------------------------------------------------------------
     527                 :          0 : Reference< XComponent > SAL_CALL OApplicationController::createComponentWithArguments( ::sal_Int32 i_nObjectType, const Sequence< PropertyValue >& i_rArguments, Reference< XComponent >& o_DocumentDefinition ) throw (IllegalArgumentException, SQLException, RuntimeException)
     528                 :            : {
     529         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     530 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard( getMutex() );
     531                 :            : 
     532 [ #  # ][ #  # ]:          0 :     impl_validateObjectTypeAndName_throw( i_nObjectType, ::boost::optional< ::rtl::OUString >() );
                 [ #  # ]
     533                 :            : 
     534                 :            :     Reference< XComponent > xComponent( newElement(
     535                 :            :         lcl_objectType2ElementType( i_nObjectType ),
     536                 :            :         ::comphelper::NamedValueCollection( i_rArguments ),
     537                 :            :         o_DocumentDefinition
     538 [ #  # ][ #  # ]:          0 :     ) );
                 [ #  # ]
     539                 :            : 
     540 [ #  # ][ #  # ]:          0 :     return xComponent;
     541                 :            : }
     542                 :            : 
     543                 :            : // -----------------------------------------------------------------------------
     544                 :          0 : void SAL_CALL OApplicationController::registerContextMenuInterceptor( const Reference< XContextMenuInterceptor >& _Interceptor ) throw (RuntimeException)
     545                 :            : {
     546         [ #  # ]:          0 :     if ( _Interceptor.is() )
     547                 :          0 :         m_aContextMenuInterceptors.addInterface( _Interceptor );
     548                 :          0 : }
     549                 :            : 
     550                 :            : // -----------------------------------------------------------------------------
     551                 :          0 : void SAL_CALL OApplicationController::releaseContextMenuInterceptor( const Reference< XContextMenuInterceptor >& _Interceptor ) throw (RuntimeException)
     552                 :            : {
     553                 :          0 :     m_aContextMenuInterceptors.removeInterface( _Interceptor );
     554                 :          0 : }
     555                 :            : 
     556                 :            : // -----------------------------------------------------------------------------
     557                 :          0 : void OApplicationController::previewChanged( sal_Int32 _nMode )
     558                 :            : {
     559         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     560 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard( getMutex() );
     561                 :            : 
     562 [ #  # ][ #  # ]:          0 :     if ( m_xDataSource.is() && !isDataSourceReadOnly() )
         [ #  # ][ #  # ]
     563                 :            :     {
     564                 :            :         try
     565                 :            :         {
     566 [ #  # ][ #  # ]:          0 :             ::comphelper::NamedValueCollection aLayoutInfo( m_xDataSource->getPropertyValue( PROPERTY_LAYOUTINFORMATION ) );
         [ #  # ][ #  # ]
     567         [ #  # ]:          0 :             sal_Int32 nOldMode = aLayoutInfo.getOrDefault( "Preview", _nMode );
     568         [ #  # ]:          0 :             if ( nOldMode != _nMode )
     569                 :            :             {
     570         [ #  # ]:          0 :                 aLayoutInfo.put( "Preview", _nMode );
     571 [ #  # ][ #  # ]:          0 :                 m_xDataSource->setPropertyValue( PROPERTY_LAYOUTINFORMATION, makeAny( aLayoutInfo.getPropertyValues() ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     572 [ #  # ][ #  # ]:          0 :             }
     573                 :            :         }
     574         [ #  # ]:          0 :         catch ( const Exception& )
     575                 :            :         {
     576                 :            :             DBG_UNHANDLED_EXCEPTION();
     577                 :            :         }
     578                 :            :     }
     579 [ #  # ][ #  # ]:          0 :     InvalidateFeature(SID_DB_APP_DISABLE_PREVIEW);
     580 [ #  # ][ #  # ]:          0 :     InvalidateFeature(SID_DB_APP_VIEW_DOCINFO_PREVIEW);
     581 [ #  # ][ #  # ]:          0 :     InvalidateFeature(SID_DB_APP_VIEW_DOC_PREVIEW);
         [ #  # ][ #  # ]
     582                 :          0 : }
     583                 :            : // -----------------------------------------------------------------------------
     584                 :          0 : void OApplicationController::askToReconnect()
     585                 :            : {
     586         [ #  # ]:          0 :     if ( m_bNeedToReconnect )
     587                 :            :     {
     588                 :          0 :         m_bNeedToReconnect = sal_False;
     589                 :          0 :         sal_Bool bClear = sal_True;
     590         [ #  # ]:          0 :         if ( !m_pSubComponentManager->empty() )
     591                 :            :         {
     592 [ #  # ][ #  # ]:          0 :             QueryBox aQry(getView(), ModuleRes(APP_CLOSEDOCUMENTS));
     593 [ #  # ][ #  # ]:          0 :             switch (aQry.Execute())
     594                 :            :             {
     595                 :            :                 case RET_YES:
     596         [ #  # ]:          0 :                     closeSubComponents();
     597                 :          0 :                     break;
     598                 :            :                 default:
     599                 :          0 :                     bClear = sal_False;
     600                 :          0 :                     break;
     601         [ #  # ]:          0 :             }
     602                 :            :         }
     603         [ #  # ]:          0 :         if ( bClear )
     604                 :            :         {
     605                 :          0 :             ElementType eType = getContainer()->getElementType();
     606                 :          0 :             disconnect();
     607                 :          0 :             getContainer()->getDetailView()->clearPages(sal_False);
     608                 :          0 :             getContainer()->selectContainer(E_NONE); // invalidate the old selection
     609                 :          0 :             m_eCurrentType = E_NONE;
     610                 :          0 :             getContainer()->selectContainer(eType); // reselect the current one again
     611                 :            :         }
     612                 :            :     }
     613                 :          0 : }
     614                 :            : 
     615                 :            : // -----------------------------------------------------------------------------
     616                 :          0 : ::rtl::OUString OApplicationController::getDatabaseName() const
     617                 :            : {
     618                 :          0 :     ::rtl::OUString sDatabaseName;
     619                 :            :     try
     620                 :            :     {
     621         [ #  # ]:          0 :         if ( m_xDataSource.is() )
     622                 :            :         {
     623 [ #  # ][ #  # ]:          0 :             OSL_VERIFY( m_xDataSource->getPropertyValue( PROPERTY_NAME ) >>= sDatabaseName );
         [ #  # ][ #  # ]
     624                 :            :         }
     625                 :            :     }
     626         [ #  # ]:          0 :     catch ( const Exception& )
     627                 :            :     {
     628                 :            :         DBG_UNHANDLED_EXCEPTION();
     629                 :            :     }
     630                 :          0 :     return sDatabaseName;
     631                 :            : }
     632                 :            : 
     633                 :            : // -----------------------------------------------------------------------------
     634                 :          0 : ::rtl::OUString OApplicationController::getStrippedDatabaseName() const
     635                 :            : {
     636                 :          0 :     ::rtl::OUString sDatabaseName;
     637         [ #  # ]:          0 :     return ::dbaui::getStrippedDatabaseName( m_xDataSource, sDatabaseName );
     638                 :            : }
     639                 :            : 
     640                 :            : // -----------------------------------------------------------------------------
     641                 :          0 : void OApplicationController::onDocumentOpened( const ::rtl::OUString& _rName, const sal_Int32 _nType,
     642                 :            :         const ElementOpenMode _eMode, const Reference< XComponent >& _xDocument, const Reference< XComponent >& _rxDefinition )
     643                 :            : {
     644         [ #  # ]:          0 :     if ( !_xDocument.is() )
     645                 :          0 :         return;
     646                 :            : 
     647                 :            :     try
     648                 :            :     {
     649                 :            :         OSL_ENSURE( _xDocument.is(), "OApplicationController::onDocumentOpened: is there any *valid* scenario where this fails?" );
     650 [ #  # ][ #  # ]:          0 :         m_pSubComponentManager->onSubComponentOpened( _rName, _nType, _eMode, _xDocument.is() ? _xDocument : _rxDefinition );
     651                 :            : 
     652         [ #  # ]:          0 :         if ( _rxDefinition.is() )
     653                 :            :         {
     654         [ #  # ]:          0 :             Reference< XPropertySet > xProp( _rxDefinition, UNO_QUERY_THROW );
     655 [ #  # ][ #  # ]:          0 :             Reference< XPropertySetInfo > xPSI( xProp->getPropertySetInfo(), UNO_SET_THROW );
                 [ #  # ]
     656 [ #  # ][ #  # ]:          0 :             xProp->addPropertyChangeListener( PROPERTY_NAME, static_cast< XPropertyChangeListener* >( this ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     657                 :            :         }
     658                 :            :     }
     659                 :          0 :     catch( const Exception& )
     660                 :            :     {
     661                 :            :         DBG_UNHANDLED_EXCEPTION();
     662                 :            :     }
     663                 :            : }
     664                 :            : // -----------------------------------------------------------------------------
     665                 :          0 : sal_Bool OApplicationController::insertHierachyElement(ElementType _eType,const String& _sParentFolder,sal_Bool _bCollection,const Reference<XContent>& _xContent,sal_Bool _bMove)
     666                 :            : {
     667 [ #  # ][ #  # ]:          0 :     Reference<XHierarchicalNameContainer> xNames(getElements(_eType), UNO_QUERY);
     668                 :          0 :     return dbaui::insertHierachyElement(getView()
     669                 :            :                            ,getORB()
     670                 :            :                            ,xNames
     671                 :            :                            ,_sParentFolder
     672                 :            :                            ,_eType == E_FORM
     673                 :            :                            ,_bCollection
     674                 :            :                            ,_xContent
     675   [ #  #  #  # ]:          0 :                            ,_bMove);
     676                 :            : }
     677                 :            : // -----------------------------------------------------------------------------
     678                 :          0 : sal_Bool OApplicationController::isRenameDeleteAllowed(ElementType _eType,sal_Bool _bDelete) const
     679                 :            : {
     680                 :          0 :     ElementType eType = getContainer()->getElementType();
     681 [ #  # ][ #  # ]:          0 :     sal_Bool bEnabled = !isDataSourceReadOnly() && eType == _eType;
     682         [ #  # ]:          0 :     if ( bEnabled )
     683                 :            :     {
     684                 :            : 
     685         [ #  # ]:          0 :         if ( E_TABLE == eType )
     686 [ #  # ][ #  # ]:          0 :             bEnabled = !isConnectionReadOnly() && getContainer()->isALeafSelected();
     687                 :            : 
     688                 :          0 :         sal_Bool bCompareRes = sal_False;
     689         [ #  # ]:          0 :         if ( _bDelete )
     690                 :          0 :             bCompareRes = getContainer()->getSelectionCount() > 0;
     691                 :            :         else
     692                 :            :         {
     693                 :          0 :             bCompareRes = getContainer()->getSelectionCount() == 1;
     694 [ #  # ][ #  # ]:          0 :             if ( bEnabled && bCompareRes && E_TABLE == eType )
                 [ #  # ]
     695                 :            :             {
     696         [ #  # ]:          0 :                 ::std::vector< ::rtl::OUString> aList;
     697         [ #  # ]:          0 :                 getSelectionElementNames(aList);
     698                 :            : 
     699                 :            :                 try
     700                 :            :                 {
     701         [ #  # ]:          0 :                     Reference< XNameAccess > xContainer = const_cast<OApplicationController*>(this)->getElements(eType);
     702 [ #  # ][ #  # ]:          0 :                     bEnabled = (xContainer.is() && xContainer->hasByName(*aList.begin()));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     703         [ #  # ]:          0 :                     if ( bEnabled )
     704 [ #  # ][ #  # ]:          0 :                         bEnabled = Reference<XRename>(xContainer->getByName(*aList.begin()),UNO_QUERY).is();
         [ #  # ][ #  # ]
     705                 :            :                 }
     706         [ #  # ]:          0 :                 catch(Exception&)
     707                 :            :                 {
     708                 :          0 :                     bEnabled = sal_False;
     709                 :          0 :                 }
     710                 :            :             }
     711                 :            :         }
     712                 :            : 
     713 [ #  # ][ #  # ]:          0 :         bEnabled = bEnabled && bCompareRes;
     714                 :            :     }
     715                 :          0 :     return bEnabled;
     716                 :            : }
     717                 :            : // -----------------------------------------------------------------------------
     718                 :          0 : void OApplicationController::onLoadedMenu(const Reference< ::com::sun::star::frame::XLayoutManager >& _xLayoutManager)
     719                 :            : {
     720                 :            : 
     721         [ #  # ]:          0 :     if ( _xLayoutManager.is() )
     722                 :            :     {
     723 [ #  # ][ #  # ]:          0 :         static ::rtl::OUString s_sStatusbar(RTL_CONSTASCII_USTRINGPARAM("private:resource/statusbar/statusbar"));
         [ #  # ][ #  # ]
     724                 :          0 :         _xLayoutManager->createElement( s_sStatusbar );
     725                 :          0 :         _xLayoutManager->requestElement( s_sStatusbar );
     726                 :            : 
     727         [ #  # ]:          0 :         if ( getContainer() )
     728                 :            :         {
     729                 :            :             // we need to share the "mnemonic space":
     730         [ #  # ]:          0 :             MnemonicGenerator aMnemonicGenerator;
     731                 :            :             // - the menu already has mnemonics
     732 [ #  # ][ #  # ]:          0 :             SystemWindow* pSystemWindow = getContainer()->GetSystemWindow();
     733         [ #  # ]:          0 :             MenuBar* pMenu = pSystemWindow ? pSystemWindow->GetMenuBar() : NULL;
     734         [ #  # ]:          0 :             if ( pMenu )
     735                 :            :             {
     736         [ #  # ]:          0 :                 sal_uInt16 nMenuItems = pMenu->GetItemCount();
     737         [ #  # ]:          0 :                 for ( sal_uInt16 i = 0; i < nMenuItems; ++i )
     738 [ #  # ][ #  # ]:          0 :                     aMnemonicGenerator.RegisterMnemonic( pMenu->GetItemText( pMenu->GetItemId( i ) ) );
         [ #  # ][ #  # ]
     739                 :            :             }
     740                 :            :             // - the icons should use automatic ones
     741 [ #  # ][ #  # ]:          0 :             getContainer()->createIconAutoMnemonics( aMnemonicGenerator );
     742                 :            :             // - as well as the entries in the task pane
     743 [ #  # ][ #  # ]:          0 :             getContainer()->setTaskExternalMnemonics( aMnemonicGenerator );
                 [ #  # ]
     744                 :            :         }
     745                 :            : 
     746         [ #  # ]:          0 :         Execute( SID_DB_APP_VIEW_FORMS, Sequence< PropertyValue >() );
     747                 :          0 :         InvalidateAll();
     748                 :            :     }
     749                 :          0 : }
     750                 :            : // -----------------------------------------------------------------------------
     751                 :          0 : void OApplicationController::doAction(sal_uInt16 _nId ,ElementOpenMode _eOpenMode)
     752                 :            : {
     753         [ #  # ]:          0 :     ::std::vector< ::rtl::OUString> aList;
     754         [ #  # ]:          0 :     getSelectionElementNames(aList);
     755 [ #  # ][ #  # ]:          0 :     ElementType eType = getContainer()->getElementType();
     756         [ #  # ]:          0 :     ::comphelper::NamedValueCollection aArguments;
     757                 :          0 :     ElementOpenMode eOpenMode = _eOpenMode;
     758 [ #  # ][ #  # ]:          0 :     if ( eType == E_REPORT && E_OPEN_FOR_MAIL == _eOpenMode )
     759                 :            :     {
     760         [ #  # ]:          0 :         aArguments.put("Hidden",true);
     761                 :          0 :         eOpenMode = E_OPEN_NORMAL;
     762                 :            :     }
     763                 :            : 
     764         [ #  # ]:          0 :     ::std::vector< ::std::pair< ::rtl::OUString ,Reference< XModel > > > aCompoments;
     765                 :          0 :     ::std::vector< ::rtl::OUString>::iterator aEnd = aList.end();
     766 [ #  # ][ #  # ]:          0 :     for (::std::vector< ::rtl::OUString>::iterator aIter = aList.begin(); aIter != aEnd; ++aIter)
     767                 :            :     {
     768         [ #  # ]:          0 :         if ( SID_DB_APP_CONVERTTOVIEW == _nId )
     769         [ #  # ]:          0 :             convertToView(*aIter);
     770                 :            :         else
     771                 :            :         {
     772 [ #  # ][ #  # ]:          0 :             Reference< XModel > xModel( openElementWithArguments( *aIter, eType, eOpenMode, _nId,aArguments ), UNO_QUERY );
     773 [ #  # ][ #  # ]:          0 :             aCompoments.push_back( ::std::pair< ::rtl::OUString, Reference< XModel > >( *aIter, xModel ) );
                 [ #  # ]
     774                 :            :         }
     775                 :            :     }
     776                 :            : 
     777                 :            :     // special handling for mail, if more than one document is selected attach them all
     778         [ #  # ]:          0 :     if ( _eOpenMode == E_OPEN_FOR_MAIL )
     779                 :            :     {
     780                 :            : 
     781                 :          0 :         ::std::vector< ::std::pair< ::rtl::OUString ,Reference< XModel > > >::iterator componentIter = aCompoments.begin();
     782                 :          0 :         ::std::vector< ::std::pair< ::rtl::OUString ,Reference< XModel > > >::iterator componentEnd = aCompoments.end();
     783                 :          0 :         ::rtl::OUString aDocTypeString;
     784         [ #  # ]:          0 :         SfxMailModel aSendMail;
     785                 :          0 :         SfxMailModel::SendMailResult eResult = SfxMailModel::SEND_MAIL_OK;
     786 [ #  # ][ #  # ]:          0 :         for (; componentIter != componentEnd && SfxMailModel::SEND_MAIL_OK == eResult; ++componentIter)
         [ #  # ][ #  # ]
     787                 :            :         {
     788                 :            :             try
     789                 :            :             {
     790         [ #  # ]:          0 :                 Reference< XModel > xModel(componentIter->second,UNO_QUERY);
     791                 :            : 
     792                 :            :                 // Send document as e-Mail using stored/default type
     793         [ #  # ]:          0 :                 eResult = aSendMail.AttachDocument(aDocTypeString,xModel,componentIter->first);
     794 [ #  # ][ #  # ]:          0 :                 ::comphelper::disposeComponent(xModel);
     795                 :            :             }
     796         [ #  # ]:          0 :             catch(const Exception&)
     797                 :            :             {
     798                 :            :                 DBG_UNHANDLED_EXCEPTION();
     799                 :            :             }
     800                 :            :         }
     801 [ #  # ][ #  # ]:          0 :         if ( !aSendMail.IsEmpty() )
     802 [ #  # ][ #  # ]:          0 :             aSendMail.Send( getFrame() );
                 [ #  # ]
     803         [ #  # ]:          0 :     }
     804                 :          0 : }
     805                 :            : // -----------------------------------------------------------------------------
     806                 :          0 : ElementType OApplicationController::getElementType(const Reference< XContainer >& _xContainer) const
     807                 :            : {
     808                 :          0 :     ElementType eRet = E_NONE;
     809         [ #  # ]:          0 :     Reference<XServiceInfo> xServiceInfo(_xContainer,UNO_QUERY);
     810         [ #  # ]:          0 :     if ( xServiceInfo.is() )
     811                 :            :     {
     812 [ #  # ][ #  # ]:          0 :         if ( xServiceInfo->supportsService(SERVICE_SDBCX_TABLES) )
         [ #  # ][ #  # ]
     813                 :          0 :             eRet = E_TABLE;
     814 [ #  # ][ #  # ]:          0 :         else if ( xServiceInfo->supportsService(SERVICE_NAME_FORM_COLLECTION) )
         [ #  # ][ #  # ]
     815                 :          0 :             eRet = E_FORM;
     816 [ #  # ][ #  # ]:          0 :         else if ( xServiceInfo->supportsService(SERVICE_NAME_REPORT_COLLECTION) )
         [ #  # ][ #  # ]
     817                 :          0 :             eRet = E_REPORT;
     818                 :            :         else
     819                 :          0 :             eRet = E_QUERY;
     820                 :            :     }
     821                 :          0 :     return eRet;
     822                 :            : }
     823                 :            : 
     824                 :            : //........................................................................
     825                 :            : }   // namespace dbaui
     826                 :            : //........................................................................
     827                 :            : 
     828                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10