LCOV - code coverage report
Current view: top level - dbaccess/source/ui/querydesign - querycontroller.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 18 879 2.0 %
Date: 2012-08-25 Functions: 6 72 8.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 10 2033 0.5 %

           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 "adtabdlg.hxx"
      22                 :            : #include "browserids.hxx"
      23                 :            : #include "dbu_qry.hrc"
      24                 :            : #include "dbu_reghelper.hxx"
      25                 :            : #include "dbustrings.hrc"
      26                 :            : #include "defaultobjectnamecheck.hxx"
      27                 :            : #include "dlgsave.hxx"
      28                 :            : #include "localresaccess.hxx"
      29                 :            : #include "QTableWindow.hxx"
      30                 :            : #include "QTableWindowData.hxx"
      31                 :            : #include "querycontainerwindow.hxx"
      32                 :            : #include "querycontroller.hxx"
      33                 :            : #include "QueryDesignView.hxx"
      34                 :            : #include "QueryTableView.hxx"
      35                 :            : #include "QueryTextView.hxx"
      36                 :            : #include "queryview.hxx"
      37                 :            : #include "QueryViewSwitch.hxx"
      38                 :            : #include "sqlmessage.hxx"
      39                 :            : #include "TableConnectionData.hxx"
      40                 :            : #include "TableFieldDescription.hxx"
      41                 :            : #include "UITools.hxx"
      42                 :            : 
      43                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      44                 :            : #include <com/sun/star/container/XChild.hpp>
      45                 :            : #include <com/sun/star/container/XNameContainer.hpp>
      46                 :            : #include <com/sun/star/frame/FrameSearchFlag.hpp>
      47                 :            : #include <com/sun/star/frame/XLoadEventListener.hpp>
      48                 :            : #include <com/sun/star/io/XActiveDataSink.hpp>
      49                 :            : #include <com/sun/star/io/XActiveDataSource.hpp>
      50                 :            : #include <com/sun/star/sdb/CommandType.hpp>
      51                 :            : #include <com/sun/star/sdb/SQLContext.hpp>
      52                 :            : #include <com/sun/star/sdb/XQueriesSupplier.hpp>
      53                 :            : #include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
      54                 :            : #include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
      55                 :            : #include <com/sun/star/sdbc/SQLWarning.hpp>
      56                 :            : #include <com/sun/star/sdbc/XRow.hpp>
      57                 :            : #include <com/sun/star/sdbcx/XAppend.hpp>
      58                 :            : #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
      59                 :            : #include <com/sun/star/sdbcx/XDrop.hpp>
      60                 :            : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
      61                 :            : #include <com/sun/star/sdbcx/XViewsSupplier.hpp>
      62                 :            : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
      63                 :            : #include <com/sun/star/util/XCloseable.hpp>
      64                 :            : #include <com/sun/star/util/VetoException.hpp>
      65                 :            : #include <com/sun/star/frame/XUntitledNumbers.hpp>
      66                 :            : 
      67                 :            : #include <comphelper/basicio.hxx>
      68                 :            : #include <comphelper/extract.hxx>
      69                 :            : #include <comphelper/property.hxx>
      70                 :            : #include <comphelper/seqstream.hxx>
      71                 :            : #include <comphelper/streamsection.hxx>
      72                 :            : #include <comphelper/types.hxx>
      73                 :            : #include <connectivity/dbexception.hxx>
      74                 :            : #include <connectivity/dbtools.hxx>
      75                 :            : #include <cppuhelper/exc_hlp.hxx>
      76                 :            : #include <sfx2/sfxsids.hrc>
      77                 :            : #include <svtools/localresaccess.hxx>
      78                 :            : #include <toolkit/helper/vclunohelper.hxx>
      79                 :            : #include <tools/diagnose_ex.h>
      80                 :            : #include <osl/diagnose.h>
      81                 :            : #include <vcl/msgbox.hxx>
      82                 :            : #include <vcl/svapp.hxx>
      83                 :            : #include <osl/mutex.hxx>
      84                 :            : #include <rtl/strbuf.hxx>
      85                 :            : #include <vector>
      86                 :            : 
      87                 :          8 : extern "C" void SAL_CALL createRegistryInfo_OQueryControl()
      88                 :            : {
      89 [ +  - ][ +  - ]:          8 :     static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OQueryController > aAutoRegistration;
         [ +  - ][ #  # ]
      90                 :          8 : }
      91                 :            : namespace dbaui
      92                 :            : {
      93                 :            :     using namespace ::com::sun::star::uno;
      94                 :            :     using namespace ::com::sun::star::beans;
      95                 :            :     using namespace ::com::sun::star::frame;
      96                 :            :     using namespace ::com::sun::star::util;
      97                 :            :     using namespace ::com::sun::star::lang;
      98                 :            : 
      99         [ #  # ]:          0 :     class OViewController : public OQueryController
     100                 :            :     {
     101                 :            :         //------------------------------------------------------------------------------
     102                 :          0 :         virtual ::rtl::OUString SAL_CALL getImplementationName() throw( RuntimeException )
     103                 :            :         {
     104                 :          0 :             return getImplementationName_Static();
     105                 :            :         }
     106                 :            :         //-------------------------------------------------------------------------
     107                 :          0 :         virtual Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames() throw(RuntimeException)
     108                 :            :         {
     109                 :          0 :             return getSupportedServiceNames_Static();
     110                 :            :         }
     111                 :            :     public:
     112                 :          0 :         OViewController(const Reference< XMultiServiceFactory >& _rM) : OQueryController(_rM){}
     113                 :            : 
     114                 :            :         // need by registration
     115                 :         16 :         static ::rtl::OUString getImplementationName_Static() throw( RuntimeException )
     116                 :            :         {
     117                 :         16 :             return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.OViewDesign"));
     118                 :            :         }
     119                 :          8 :         static Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( RuntimeException )
     120                 :            :         {
     121                 :          8 :             Sequence< ::rtl::OUString> aSupported(1);
     122 [ +  - ][ +  - ]:          8 :             aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.ViewDesign"));
     123                 :          8 :             return aSupported;
     124                 :            :         }
     125                 :          0 :         static Reference< XInterface > SAL_CALL Create(const Reference< XMultiServiceFactory >& _rM)
     126                 :            :         {
     127         [ #  # ]:          0 :             return *(new OViewController(_rM));
     128                 :            :         }
     129                 :            :     };
     130                 :            : }
     131                 :          8 : extern "C" void SAL_CALL createRegistryInfo_OViewControl()
     132                 :            : {
     133 [ +  - ][ +  - ]:          8 :     static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OViewController > aAutoRegistration;
         [ +  - ][ #  # ]
     134                 :          8 : }
     135                 :            : 
     136                 :            : namespace dbaui
     137                 :            : {
     138                 :            :     using namespace ::connectivity;
     139                 :            : #if OSL_DEBUG_LEVEL > 1
     140                 :            :     namespace
     141                 :            :     {
     142                 :            :         // -----------------------------------------------------------------------------
     143                 :            :         void insertParseTree(SvTreeListBox* _pBox,::connectivity::OSQLParseNode* _pNode,SvLBoxEntry* _pParent = NULL)
     144                 :            :         {
     145                 :            :             ::rtl::OUString rString;
     146                 :            :             if (!_pNode->isToken())
     147                 :            :             {
     148                 :            :                 // Regelnamen als rule: ...
     149                 :            :                 rString = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RULE_ID: "));
     150                 :            :                 rString += ::rtl::OUString::valueOf( (sal_Int32)_pNode->getRuleID());
     151                 :            :                 rString+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("("));
     152                 :            :                 rString += OSQLParser::RuleIDToStr(_pNode->getRuleID());
     153                 :            :                 rString+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")"));
     154                 :            : 
     155                 :            : 
     156                 :            :                 _pParent = _pBox->InsertEntry(rString,_pParent);
     157                 :            : 
     158                 :            :                 // einmal auswerten wieviel Subtrees dieser Knoten besitzt
     159                 :            :                 sal_uInt32 nStop = _pNode->count();
     160                 :            :                 // hol dir den ersten Subtree
     161                 :            :                 for(sal_uInt32 i=0;i<nStop;++i)
     162                 :            :                     insertParseTree(_pBox,_pNode->getChild(i),_pParent);
     163                 :            :             }
     164                 :            :             else
     165                 :            :             {
     166                 :            :                 // ein Token gefunden
     167                 :            :                 // tabs fuer das Einruecken entsprechend nLevel
     168                 :            : 
     169                 :            :                 switch (_pNode->getNodeType())
     170                 :            :                 {
     171                 :            : 
     172                 :            :                 case SQL_NODE_KEYWORD:
     173                 :            :                     {
     174                 :            :                         rString += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SQL_KEYWORD:"));
     175                 :            :                         ::rtl::OString sT = OSQLParser::TokenIDToStr(_pNode->getTokenID());
     176                 :            :                         rString += ::rtl::OStringToOUString(sT, RTL_TEXTENCODING_UTF8);
     177                 :            :                      break;}
     178                 :            : 
     179                 :            :                 case SQL_NODE_COMPARISON:
     180                 :            :                     {
     181                 :            :                         rString+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SQL_COMPARISON:"));
     182                 :            :                         rString += _pNode->getTokenValue(); // haenge Nodevalue an
     183                 :            :                             // und beginne neu Zeile
     184                 :            :                         break;}
     185                 :            : 
     186                 :            :                 case SQL_NODE_NAME:
     187                 :            :                     {
     188                 :            :                         rString+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SQL_NAME:"));
     189                 :            :                         rString+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\""));
     190                 :            :                         rString += _pNode->getTokenValue();
     191                 :            :                         rString+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\""));
     192                 :            :                         break;}
     193                 :            : 
     194                 :            :                 case SQL_NODE_STRING:
     195                 :            :                     {
     196                 :            :                         rString += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SQL_STRING:'"));
     197                 :            :                         rString += _pNode->getTokenValue();
     198                 :            :                         break;}
     199                 :            : 
     200                 :            :                 case SQL_NODE_INTNUM:
     201                 :            :                     {
     202                 :            :                         rString += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SQL_INTNUM:"));
     203                 :            :                         rString += _pNode->getTokenValue();
     204                 :            :                         break;}
     205                 :            : 
     206                 :            :                 case SQL_NODE_APPROXNUM:
     207                 :            :                     {
     208                 :            :                         rString += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SQL_APPROXNUM:"));
     209                 :            :                         rString += _pNode->getTokenValue();
     210                 :            :                         break;}
     211                 :            : 
     212                 :            :                 case SQL_NODE_PUNCTUATION:
     213                 :            :                     {
     214                 :            :                         rString += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SQL_PUNCTUATION:"));
     215                 :            :                         rString += _pNode->getTokenValue(); // haenge Nodevalue an
     216                 :            :                         break;}
     217                 :            : 
     218                 :            :                 case SQL_NODE_AMMSC:
     219                 :            :                     {
     220                 :            :                         rString += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SQL_AMMSC:"));
     221                 :            :                         rString += _pNode->getTokenValue(); // haenge Nodevalue an
     222                 :            :                         break;}
     223                 :            : 
     224                 :            :                 default:
     225                 :            :                     OSL_FAIL("OSQLParser::ShowParseTree: unzulaessiger NodeType");
     226                 :            :                     rString += _pNode->getTokenValue();
     227                 :            :                 }
     228                 :            :                 _pBox->InsertEntry(rString,_pParent);
     229                 :            :             }
     230                 :            :         }
     231                 :            :     }
     232                 :            : #endif // OSL_DEBUG_LEVEL
     233                 :            : 
     234                 :            :     namespace
     235                 :            :     {
     236                 :            :         // -----------------------------------------------------------------------------
     237                 :          0 :         String lcl_getObjectResourceString( sal_uInt16 _nResId, sal_Int32 _nCommandType )
     238                 :            :         {
     239 [ #  # ][ #  # ]:          0 :             String sMessageText = String( ModuleRes( _nResId ) );
     240         [ #  # ]:          0 :             String sObjectType;
     241                 :            :             {
     242         [ #  # ]:          0 :                 LocalResourceAccess aLocalRes( RSC_QUERY_OBJECT_TYPE, RSC_RESOURCE );
     243 [ #  # ][ #  # ]:          0 :                 sObjectType = String( ModuleRes( (sal_uInt16)( _nCommandType + 1 ) ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     244                 :            :             }
     245 [ #  # ][ #  # ]:          0 :             sMessageText.SearchAndReplace( rtl::OUString("$object$"), sObjectType );
                 [ #  # ]
     246         [ #  # ]:          0 :             return sMessageText;
     247                 :            :         }
     248                 :            :     }
     249                 :            : 
     250                 :            : using namespace ::com::sun::star::uno;
     251                 :            : using namespace ::com::sun::star::io;
     252                 :            : using namespace ::com::sun::star::beans;
     253                 :            : using namespace ::com::sun::star::frame;
     254                 :            : using namespace ::com::sun::star::util;
     255                 :            : using namespace ::com::sun::star::lang;
     256                 :            : using namespace ::com::sun::star::container;
     257                 :            : using namespace ::com::sun::star::sdbcx;
     258                 :            : using namespace ::com::sun::star::sdbc;
     259                 :            : using namespace ::com::sun::star::sdb;
     260                 :            : using namespace ::com::sun::star::ui::dialogs;
     261                 :            : using namespace ::com::sun::star::awt;
     262                 :            : using namespace ::dbtools;
     263                 :            : 
     264                 :            : using namespace ::comphelper;
     265                 :            : 
     266                 :            : namespace
     267                 :            : {
     268                 :          0 :     void ensureToolbars( OQueryController& _rController, sal_Bool _bDesign )
     269                 :            :     {
     270 [ #  # ][ #  # ]:          0 :         Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager = _rController.getLayoutManager( _rController.getFrame() );
     271         [ #  # ]:          0 :         if ( xLayoutManager.is() )
     272                 :            :         {
     273 [ #  # ][ #  # ]:          0 :             xLayoutManager->lock();
     274 [ #  # ][ #  # ]:          0 :             static ::rtl::OUString s_sDesignToolbar(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/designobjectbar"));
         [ #  # ][ #  # ]
     275 [ #  # ][ #  # ]:          0 :             static ::rtl::OUString s_sSqlToolbar(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/sqlobjectbar"));
         [ #  # ][ #  # ]
     276         [ #  # ]:          0 :             if ( _bDesign )
     277                 :            :             {
     278 [ #  # ][ #  # ]:          0 :                 xLayoutManager->destroyElement( s_sSqlToolbar );
     279 [ #  # ][ #  # ]:          0 :                 xLayoutManager->createElement( s_sDesignToolbar );
     280                 :            :             }
     281                 :            :             else
     282                 :            :             {
     283 [ #  # ][ #  # ]:          0 :                 xLayoutManager->destroyElement( s_sDesignToolbar );
     284 [ #  # ][ #  # ]:          0 :                 xLayoutManager->createElement( s_sSqlToolbar );
     285                 :            :             }
     286 [ #  # ][ #  # ]:          0 :             xLayoutManager->unlock();
     287 [ #  # ][ #  # ]:          0 :             xLayoutManager->doLayout();
     288                 :          0 :         }
     289                 :          0 :     }
     290                 :            : }
     291                 :            : 
     292                 :            : //------------------------------------------------------------------------------
     293                 :          0 : ::rtl::OUString SAL_CALL OQueryController::getImplementationName() throw( RuntimeException )
     294                 :            : {
     295                 :          0 :     return getImplementationName_Static();
     296                 :            : }
     297                 :            : 
     298                 :            : //------------------------------------------------------------------------------
     299                 :         16 : ::rtl::OUString OQueryController::getImplementationName_Static() throw( RuntimeException )
     300                 :            : {
     301                 :         16 :     return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.OQueryDesign"));
     302                 :            : }
     303                 :            : //------------------------------------------------------------------------------
     304                 :          8 : Sequence< ::rtl::OUString> OQueryController::getSupportedServiceNames_Static(void) throw( RuntimeException )
     305                 :            : {
     306                 :          8 :     Sequence< ::rtl::OUString> aSupported(1);
     307 [ +  - ][ +  - ]:          8 :     aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.QueryDesign"));
     308                 :          8 :     return aSupported;
     309                 :            : }
     310                 :            : //-------------------------------------------------------------------------
     311                 :          0 : Sequence< ::rtl::OUString> SAL_CALL OQueryController::getSupportedServiceNames() throw(RuntimeException)
     312                 :            : {
     313                 :          0 :     return getSupportedServiceNames_Static();
     314                 :            : }
     315                 :            : // -------------------------------------------------------------------------
     316                 :          0 : Reference< XInterface > SAL_CALL OQueryController::Create(const Reference<XMultiServiceFactory >& _rxFactory)
     317                 :            : {
     318         [ #  # ]:          0 :     return *(new OQueryController(_rxFactory));
     319                 :            : }
     320                 :            : DBG_NAME(OQueryController);
     321                 :            : // -----------------------------------------------------------------------------
     322                 :          0 : OQueryController::OQueryController(const Reference< XMultiServiceFactory >& _rM)
     323                 :            :     :OJoinController(_rM)
     324                 :          0 :     ,OQueryController_PBase( getBroadcastHelper() )
     325         [ #  # ]:          0 :     ,m_pParseContext( new svxform::OSystemParseContext )
     326                 :            :     ,m_aSqlParser( _rM, m_pParseContext )
     327                 :            :     ,m_pSqlIterator(NULL)
     328                 :            :     ,m_nVisibleRows(0x400)
     329                 :            :     ,m_nSplitPos(-1)
     330                 :            :     ,m_nCommandType( CommandType::QUERY )
     331                 :            :     ,m_bGraphicalDesign(sal_False)
     332                 :            :     ,m_bDistinct(sal_False)
     333                 :            :     ,m_bViewAlias(sal_False)
     334                 :            :     ,m_bViewTable(sal_False)
     335                 :            :     ,m_bViewFunction(sal_False)
     336 [ #  # ][ #  # ]:          0 :     ,m_bEscapeProcessing(sal_True)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     337                 :            : {
     338                 :            :     DBG_CTOR(OQueryController,NULL);
     339         [ #  # ]:          0 :     InvalidateAll();
     340                 :            : 
     341                 :            :     registerProperty( PROPERTY_ACTIVECOMMAND, PROPERTY_ID_ACTIVECOMMAND, PropertyAttribute::READONLY | PropertyAttribute::BOUND,
     342 [ #  # ][ #  # ]:          0 :         &m_sStatement, ::getCppuType( &m_sStatement ) );
                 [ #  # ]
     343                 :            :     registerProperty( PROPERTY_ESCAPE_PROCESSING, PROPERTY_ID_ESCAPE_PROCESSING, PropertyAttribute::READONLY | PropertyAttribute::BOUND,
     344 [ #  # ][ #  # ]:          0 :         &m_bEscapeProcessing, ::getCppuType( &m_bEscapeProcessing ) );
                 [ #  # ]
     345                 :          0 : }
     346                 :            : 
     347                 :            : // -----------------------------------------------------------------------------
     348 [ #  # ][ #  # ]:          0 : OQueryController::~OQueryController()
         [ #  # ][ #  # ]
     349                 :            : {
     350                 :            :     DBG_DTOR(OQueryController,NULL);
     351 [ #  # ][ #  # ]:          0 :     if ( !getBroadcastHelper().bDisposed && !getBroadcastHelper().bInDispose )
                 [ #  # ]
     352                 :            :     {
     353                 :            :         OSL_FAIL("Please check who doesn't dispose this component!");
     354                 :            :         // increment ref count to prevent double call of Dtor
     355         [ #  # ]:          0 :         osl_incrementInterlockedCount( &m_refCount );
     356         [ #  # ]:          0 :         dispose();
     357                 :            :     }
     358         [ #  # ]:          0 : }
     359                 :            : 
     360 [ #  # ][ #  # ]:          0 : IMPLEMENT_FORWARD_XINTERFACE2( OQueryController, OJoinController, OQueryController_PBase )
     361 [ #  # ][ #  # ]:          0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( OQueryController, OJoinController, OQueryController_PBase )
                 [ #  # ]
     362                 :            : 
     363                 :            : //-------------------------------------------------------------------------
     364                 :          0 : Reference< XPropertySetInfo > SAL_CALL OQueryController::getPropertySetInfo() throw(RuntimeException)
     365                 :            : {
     366                 :          0 :     Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
     367                 :          0 :     return xInfo;
     368                 :            : }
     369                 :            : 
     370                 :            : //-------------------------------------------------------------------------
     371                 :          0 : sal_Bool SAL_CALL OQueryController::convertFastPropertyValue( Any& o_rConvertedValue, Any& o_rOldValue, sal_Int32 i_nHandle, const Any& i_rValue ) throw (IllegalArgumentException)
     372                 :            : {
     373                 :          0 :     return OPropertyContainer::convertFastPropertyValue( o_rConvertedValue, o_rOldValue, i_nHandle, i_rValue );
     374                 :            : }
     375                 :            : 
     376                 :            : //-------------------------------------------------------------------------
     377                 :          0 : void SAL_CALL OQueryController::setFastPropertyValue_NoBroadcast( sal_Int32 i_nHandle, const Any& i_rValue ) throw ( Exception )
     378                 :            : {
     379                 :          0 :     OPropertyContainer::setFastPropertyValue_NoBroadcast( i_nHandle, i_rValue );
     380                 :          0 : }
     381                 :            : 
     382                 :            : //-------------------------------------------------------------------------
     383                 :          0 : void SAL_CALL OQueryController::getFastPropertyValue( Any& o_rValue, sal_Int32 i_nHandle ) const
     384                 :            : {
     385         [ #  # ]:          0 :     switch ( i_nHandle )
     386                 :            :     {
     387                 :            :     case PROPERTY_ID_CURRENT_QUERY_DESIGN:
     388                 :            :     {
     389         [ #  # ]:          0 :         ::comphelper::NamedValueCollection aCurrentDesign;
     390         [ #  # ]:          0 :         aCurrentDesign.put( "GraphicalDesign", isGraphicalDesign() );
     391 [ #  # ][ #  # ]:          0 :         aCurrentDesign.put( (::rtl::OUString)PROPERTY_ESCAPE_PROCESSING, m_bEscapeProcessing );
     392                 :            : 
     393         [ #  # ]:          0 :         if ( isGraphicalDesign() )
     394                 :            :         {
     395         [ #  # ]:          0 :             getContainer()->SaveUIConfig();
     396         [ #  # ]:          0 :             saveViewSettings( aCurrentDesign, true );
     397         [ #  # ]:          0 :             aCurrentDesign.put( "Statement", m_sStatement );
     398                 :            :         }
     399                 :            :         else
     400                 :            :         {
     401 [ #  # ][ #  # ]:          0 :             aCurrentDesign.put( "Statement", getContainer()->getStatement() );
     402                 :            :         }
     403                 :            : 
     404 [ #  # ][ #  # ]:          0 :         o_rValue <<= aCurrentDesign.getPropertyValues();
         [ #  # ][ #  # ]
     405                 :            :     }
     406                 :          0 :     break;
     407                 :            : 
     408                 :            :     default:
     409                 :          0 :         OPropertyContainer::getFastPropertyValue( o_rValue, i_nHandle );
     410                 :          0 :         break;
     411                 :            :     }
     412                 :          0 : }
     413                 :            : 
     414                 :            : //-------------------------------------------------------------------------
     415                 :          0 : ::cppu::IPropertyArrayHelper& OQueryController::getInfoHelper()
     416                 :            : {
     417                 :          0 :     return *const_cast< OQueryController* >( this )->getArrayHelper();
     418                 :            : }
     419                 :            : 
     420                 :            : //--------------------------------------------------------------------
     421                 :          0 : ::cppu::IPropertyArrayHelper* OQueryController::createArrayHelper( ) const
     422                 :            : {
     423         [ #  # ]:          0 :     Sequence< Property > aProps;
     424         [ #  # ]:          0 :     describeProperties( aProps );
     425                 :            : 
     426                 :            :     // one additional property:
     427                 :          0 :     const sal_Int32 nLength = aProps.getLength();
     428         [ #  # ]:          0 :     aProps.realloc( nLength + 1 );
     429         [ #  # ]:          0 :     aProps[ nLength ] = Property(
     430                 :            :         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CurrentQueryDesign" ) ),
     431                 :            :         PROPERTY_ID_CURRENT_QUERY_DESIGN,
     432         [ #  # ]:          0 :         ::cppu::UnoType< Sequence< PropertyValue > >::get(),
     433                 :            :         PropertyAttribute::READONLY
     434         [ #  # ]:          0 :     );
     435                 :            : 
     436                 :            :     ::std::sort(
     437                 :            :         aProps.getArray(),
     438         [ #  # ]:          0 :         aProps.getArray() + aProps.getLength(),
     439                 :            :         ::comphelper::PropertyCompareByName()
     440 [ #  # ][ #  # ]:          0 :     );
     441                 :            : 
     442 [ #  # ][ #  # ]:          0 :     return new ::cppu::OPropertyArrayHelper(aProps);
     443                 :            : }
     444                 :            : 
     445                 :            : // -----------------------------------------------------------------------------
     446                 :          0 : void OQueryController::deleteIterator()
     447                 :            : {
     448         [ #  # ]:          0 :     if(m_pSqlIterator)
     449                 :            :     {
     450         [ #  # ]:          0 :         delete m_pSqlIterator->getParseTree();
     451                 :          0 :         m_pSqlIterator->dispose();
     452         [ #  # ]:          0 :         delete m_pSqlIterator;
     453                 :          0 :         m_pSqlIterator = NULL;
     454                 :            :     }
     455                 :          0 : }
     456                 :            : // -----------------------------------------------------------------------------
     457                 :          0 : void OQueryController::disposing()
     458                 :            : {
     459                 :          0 :     OQueryController_PBase::disposing();
     460                 :            : 
     461                 :          0 :     deleteIterator();
     462                 :            : 
     463         [ #  # ]:          0 :     delete m_pParseContext;
     464                 :            : 
     465                 :          0 :     clearFields();
     466                 :          0 :     OTableFields().swap(m_vUnUsedFieldsDesc);
     467                 :            : 
     468                 :          0 :     ::comphelper::disposeComponent(m_xComposer);
     469                 :          0 :     OJoinController::disposing();
     470                 :          0 :     OQueryController_PBase::disposing();
     471                 :          0 : }
     472                 :            : // -----------------------------------------------------------------------------
     473                 :          0 : void OQueryController::clearFields()
     474                 :            : {
     475                 :          0 :     OTableFields().swap(m_vTableFieldDesc);
     476                 :          0 : }
     477                 :            : // -----------------------------------------------------------------------------
     478                 :          0 : FeatureState OQueryController::GetState(sal_uInt16 _nId) const
     479                 :            : {
     480                 :          0 :     FeatureState aReturn;
     481                 :          0 :     aReturn.bEnabled = sal_True;
     482                 :            :         // (disabled automatically)
     483                 :            : 
     484   [ #  #  #  #  :          0 :     switch (_nId)
          #  #  #  #  #  
          #  #  #  #  #  
                #  #  # ]
     485                 :            :     {
     486                 :            :         case ID_BROWSER_EDITDOC:
     487         [ #  # ]:          0 :             if ( editingCommand() )
     488                 :          0 :                 aReturn.bEnabled = sal_False;
     489 [ #  # ][ #  # ]:          0 :             else if ( editingView() && !m_xAlterView.is() )
                 [ #  # ]
     490                 :          0 :                 aReturn.bEnabled = sal_False;
     491                 :            :             else
     492 [ #  # ][ #  # ]:          0 :                 aReturn = OJoinController::GetState( _nId );
                 [ #  # ]
     493                 :          0 :             break;
     494                 :            : 
     495                 :            :         case ID_BROWSER_ESACPEPROCESSING:
     496         [ #  # ]:          0 :             aReturn.bChecked = !m_bEscapeProcessing;
     497 [ #  # ][ #  # ]:          0 :             aReturn.bEnabled = ( m_pSqlIterator != NULL ) && !m_bGraphicalDesign;
     498                 :          0 :             break;
     499                 :            :         case SID_RELATION_ADD_RELATION:
     500 [ #  # ][ #  # ]:          0 :             aReturn.bEnabled = isEditable() && m_bGraphicalDesign && m_vTableData.size() > 1;
         [ #  # ][ #  # ]
     501                 :          0 :             break;
     502                 :            :         case ID_BROWSER_SAVEASDOC:
     503 [ #  # ][ #  # ]:          0 :             aReturn.bEnabled = !editingCommand() && !editingView() && (!m_bGraphicalDesign || !(m_vTableFieldDesc.empty() || m_vTableData.empty()));
         [ #  # ][ #  # ]
                 [ #  # ]
     504                 :          0 :             break;
     505                 :            :         case ID_BROWSER_SAVEDOC:
     506 [ #  # ][ #  # ]:          0 :             aReturn.bEnabled = impl_isModified() && (!m_bGraphicalDesign || !(m_vTableFieldDesc.empty() || m_vTableData.empty()));
         [ #  # ][ #  # ]
                 [ #  # ]
     507                 :          0 :             break;
     508                 :            :         case SID_PRINTDOCDIRECT:
     509                 :          0 :             break;
     510                 :            :         case ID_BROWSER_CUT:
     511 [ #  # ][ #  # ]:          0 :             aReturn.bEnabled = isEditable() && getContainer() && getContainer()->isCutAllowed();
         [ #  # ][ #  # ]
                 [ #  # ]
     512                 :          0 :             break;
     513                 :            :         case ID_BROWSER_COPY:
     514 [ #  # ][ #  # ]:          0 :             aReturn.bEnabled = getContainer() && getContainer()->isCopyAllowed();
                 [ #  # ]
     515                 :          0 :             break;
     516                 :            :         case ID_BROWSER_PASTE:
     517 [ #  # ][ #  # ]:          0 :             aReturn.bEnabled = isEditable() && getContainer() && getContainer()->isPasteAllowed();
         [ #  # ][ #  # ]
                 [ #  # ]
     518                 :          0 :             break;
     519                 :            :         case ID_BROWSER_SQL:
     520 [ #  # ][ #  # ]:          0 :             aReturn.bEnabled = m_bEscapeProcessing && m_pSqlIterator;
     521         [ #  # ]:          0 :             aReturn.bChecked = m_bGraphicalDesign;
     522                 :          0 :             break;
     523                 :            :         case SID_BROWSER_CLEAR_QUERY:
     524 [ #  # ][ #  # ]:          0 :             aReturn.bEnabled = isEditable() && (!m_sStatement.isEmpty() || !m_vTableData.empty());
         [ #  # ][ #  # ]
     525                 :          0 :             break;
     526                 :            :         case SID_QUERY_VIEW_FUNCTIONS:
     527                 :            :         case SID_QUERY_VIEW_TABLES:
     528                 :            :         case SID_QUERY_VIEW_ALIASES:
     529 [ #  # ][ #  # ]:          0 :             aReturn.bChecked = getContainer() && getContainer()->isSlotEnabled(_nId);
         [ #  # ][ #  # ]
     530                 :          0 :             aReturn.bEnabled = m_bGraphicalDesign;
     531                 :          0 :             break;
     532                 :            :         case SID_QUERY_DISTINCT_VALUES:
     533 [ #  # ][ #  # ]:          0 :             aReturn.bEnabled = m_bGraphicalDesign && isEditable();
                 [ #  # ]
     534         [ #  # ]:          0 :             aReturn.bChecked = m_bDistinct;
     535                 :          0 :             break;
     536                 :            :         case ID_BROWSER_QUERY_EXECUTE:
     537                 :          0 :             aReturn.bEnabled = sal_True;
     538                 :          0 :             break;
     539                 :            :         case SID_DB_QUERY_PREVIEW:
     540                 :          0 :             aReturn.bEnabled = sal_True;
     541 [ #  # ][ #  # ]:          0 :             aReturn.bChecked = getContainer() && getContainer()->getPreviewFrame().is();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     542                 :          0 :             break;
     543                 :            : #if OSL_DEBUG_LEVEL > 1
     544                 :            :         case ID_EDIT_QUERY_SQL:
     545                 :            :             break;
     546                 :            :         case ID_EDIT_QUERY_DESIGN:
     547                 :            :             break;
     548                 :            : #endif
     549                 :            :         case ID_BROWSER_ADDTABLE:
     550         [ #  # ]:          0 :             if ( !m_bGraphicalDesign )
     551                 :            :             {
     552                 :          0 :                 aReturn.bEnabled = sal_False;
     553                 :          0 :                 break;
     554                 :            :             }
     555                 :            :             // run through
     556                 :            :         default:
     557 [ #  # ][ #  # ]:          0 :             aReturn = OJoinController::GetState(_nId);
                 [ #  # ]
     558                 :          0 :             break;
     559                 :            :     }
     560                 :          0 :     return aReturn;
     561                 :            : }
     562                 :            : // -----------------------------------------------------------------------------
     563                 :          0 : void OQueryController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aArgs)
     564                 :            : {
     565   [ #  #  #  #  :          0 :     switch(_nId)
          #  #  #  #  #  
          #  #  #  #  #  
                   #  # ]
     566                 :            :     {
     567                 :            :         case ID_BROWSER_ESACPEPROCESSING:
     568                 :          0 :             setEscapeProcessing_fireEvent( !m_bEscapeProcessing );
     569         [ #  # ]:          0 :             if ( !editingView() )
     570                 :          0 :                 setModified(sal_True);
     571         [ #  # ]:          0 :             InvalidateFeature(ID_BROWSER_SQL);
     572                 :          0 :             break;
     573                 :            :         case ID_BROWSER_SAVEASDOC:
     574                 :            :         case ID_BROWSER_SAVEDOC:
     575                 :          0 :             doSaveAsDoc(ID_BROWSER_SAVEASDOC == _nId);
     576                 :          0 :             break;
     577                 :            :         case SID_RELATION_ADD_RELATION:
     578                 :            :             {
     579                 :          0 :                 OJoinDesignView* pView = getJoinView();
     580         [ #  # ]:          0 :                 if( pView )
     581                 :          0 :                     static_cast<OQueryTableView*>(pView->getTableView())->createNewConnection();
     582                 :            :             }
     583                 :          0 :             break;
     584                 :            :         case SID_PRINTDOCDIRECT:
     585                 :          0 :             break;
     586                 :            :         case ID_BROWSER_CUT:
     587                 :          0 :             getContainer()->cut();
     588                 :          0 :             break;
     589                 :            :         case ID_BROWSER_COPY:
     590                 :          0 :             getContainer()->copy();
     591                 :          0 :             break;
     592                 :            :         case ID_BROWSER_PASTE:
     593                 :          0 :             getContainer()->paste();
     594                 :          0 :             break;
     595                 :            :         case ID_BROWSER_SQL:
     596                 :            :         {
     597 [ #  # ][ #  # ]:          0 :             if ( !getContainer()->checkStatement() )
     598                 :            :                 break;
     599         [ #  # ]:          0 :             SQLExceptionInfo aError;
     600                 :            :             try
     601                 :            :             {
     602                 :          0 :                 ::rtl::OUString aErrorMsg;
     603 [ #  # ][ #  # ]:          0 :                 setStatement_fireEvent( getContainer()->getStatement() );
     604 [ #  # ][ #  # ]:          0 :                 if(m_sStatement.isEmpty() && m_pSqlIterator)
                 [ #  # ]
     605                 :            :                 {
     606                 :            :                     // change the view of the data
     607 [ #  # ][ #  # ]:          0 :                     delete m_pSqlIterator->getParseTree();
     608         [ #  # ]:          0 :                     m_pSqlIterator->setParseTree(NULL);
     609                 :          0 :                     m_bGraphicalDesign = !m_bGraphicalDesign;
     610         [ #  # ]:          0 :                     impl_setViewMode( &aError );
     611                 :            :                 }
     612                 :            :                 else
     613                 :            :                 {
     614         [ #  # ]:          0 :                     ::connectivity::OSQLParseNode* pNode = m_aSqlParser.parseTree(aErrorMsg,m_sStatement,m_bGraphicalDesign);
     615         [ #  # ]:          0 :                     if ( pNode )
     616                 :            :                     {
     617 [ #  # ][ #  # ]:          0 :                         delete m_pSqlIterator->getParseTree();
     618         [ #  # ]:          0 :                         m_pSqlIterator->setParseTree(pNode);
     619         [ #  # ]:          0 :                         m_pSqlIterator->traverseAll();
     620                 :            : 
     621         [ #  # ]:          0 :                         if ( m_pSqlIterator->hasErrors() )
     622                 :            :                         {
     623         [ #  # ]:          0 :                             aError = m_pSqlIterator->getErrors();
     624                 :            :                         }
     625                 :            :                         else
     626                 :            :                         {
     627         [ #  # ]:          0 :                             const OSQLTables& xTabs = m_pSqlIterator->getTables();
     628 [ #  # ][ #  # ]:          0 :                             if ( m_pSqlIterator->getStatementType() != SQL_STATEMENT_SELECT || xTabs.begin() == xTabs.end() )
         [ #  # ][ #  # ]
                 [ #  # ]
     629                 :            :                             {
     630                 :            :                                 aError = SQLException(
     631                 :            :                                     String( ModuleRes( STR_QRY_NOSELECT ) ),
     632                 :            :                                     NULL,
     633                 :            :                                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "S1000" ) ),
     634                 :            :                                     1000,
     635                 :            :                                     Any()
     636 [ #  # ][ #  # ]:          0 :                                 );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     637                 :            :                             }
     638                 :            :                             else
     639                 :            :                             {
     640                 :            :                                 // change the view of the data
     641                 :          0 :                                 m_bGraphicalDesign = !m_bGraphicalDesign;
     642                 :          0 :                                 ::rtl::OUString sNewStatement;
     643 [ #  # ][ #  # ]:          0 :                                 pNode->parseNodeToStr( sNewStatement, getConnection() );
     644         [ #  # ]:          0 :                                 setStatement_fireEvent( sNewStatement );
     645         [ #  # ]:          0 :                                 getContainer()->SaveUIConfig();
     646                 :          0 :                                 m_vTableConnectionData.clear();
     647         [ #  # ]:          0 :                                 impl_setViewMode( &aError );
     648                 :            :                             }
     649                 :            :                         }
     650                 :            :                     }
     651                 :            :                     else
     652                 :            :                     {
     653                 :            :                         aError = SQLException(
     654                 :            :                             String( ModuleRes( STR_QRY_SYNTAX ) ),
     655                 :            :                             NULL,
     656                 :            :                             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "S1000" ) ),
     657                 :            :                             1000,
     658                 :            :                             Any()
     659 [ #  # ][ #  # ]:          0 :                         );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     660                 :            :                     }
     661                 :          0 :                 }
     662                 :            :             }
     663   [ #  #  #  #  :          0 :             catch(const SQLException&)
                      # ]
     664                 :            :             {
     665   [ #  #  #  # ]:          0 :                 aError = ::cppu::getCaughtException();
     666                 :            :             }
     667         [ #  # ]:          0 :             catch(const Exception&)
     668                 :            :             {
     669                 :            :                 DBG_UNHANDLED_EXCEPTION();
     670                 :            :             }
     671                 :            : 
     672         [ #  # ]:          0 :             if ( aError.isValid() )
     673         [ #  # ]:          0 :                 showError( aError );
     674                 :            : 
     675         [ #  # ]:          0 :             if(m_bGraphicalDesign)
     676                 :            :             {
     677 [ #  # ][ #  # ]:          0 :                 InvalidateFeature(ID_BROWSER_ADDTABLE);
     678 [ #  # ][ #  # ]:          0 :                 InvalidateFeature(SID_RELATION_ADD_RELATION);
     679         [ #  # ]:          0 :             }
     680                 :            :         }
     681                 :          0 :         break;
     682                 :            :         case SID_BROWSER_CLEAR_QUERY:
     683                 :            :             {
     684 [ #  # ][ #  # ]:          0 :                 GetUndoManager().EnterListAction( String( ModuleRes(STR_QUERY_UNDO_TABWINDELETE) ), String() );
         [ #  # ][ #  # ]
     685                 :          0 :                 getContainer()->clear();
     686                 :          0 :                 GetUndoManager().LeaveListAction();
     687                 :            : 
     688         [ #  # ]:          0 :                 setStatement_fireEvent( ::rtl::OUString() );
     689         [ #  # ]:          0 :                 if(m_bGraphicalDesign)
     690         [ #  # ]:          0 :                     InvalidateFeature(ID_BROWSER_ADDTABLE);
     691                 :            :             }
     692                 :          0 :             break;
     693                 :            :         case SID_QUERY_VIEW_FUNCTIONS:
     694                 :            :         case SID_QUERY_VIEW_TABLES:
     695                 :            :         case SID_QUERY_VIEW_ALIASES:
     696                 :          0 :             getContainer()->setSlotEnabled(_nId,!getContainer()->isSlotEnabled(_nId));
     697                 :          0 :             setModified(sal_True);
     698                 :          0 :             break;
     699                 :            :         case SID_QUERY_DISTINCT_VALUES:
     700                 :          0 :             m_bDistinct = !m_bDistinct;
     701                 :          0 :             setModified(sal_True);
     702                 :          0 :             break;
     703                 :            :         case ID_BROWSER_QUERY_EXECUTE:
     704         [ #  # ]:          0 :             if ( getContainer()->checkStatement() )
     705                 :          0 :                 executeQuery();
     706                 :          0 :             break;
     707                 :            :         case SID_DB_QUERY_PREVIEW:
     708                 :            :             try
     709                 :            :             {
     710 [ #  # ][ #  # ]:          0 :                 Reference< ::com::sun::star::util::XCloseable > xCloseFrame( getContainer()->getPreviewFrame(), UNO_QUERY );
                 [ #  # ]
     711         [ #  # ]:          0 :                 if ( xCloseFrame.is() )
     712                 :            :                 {
     713                 :            :                     try
     714                 :            :                     {
     715 [ #  # ][ #  # ]:          0 :                         xCloseFrame->close( sal_True );
     716                 :            :                     }
     717         [ #  # ]:          0 :                     catch(const Exception&)
     718                 :            :                     {
     719                 :            :                         OSL_FAIL( "OQueryController::Execute(SID_DB_QUERY_PREVIEW): *nobody* is expected to veto closing the preview frame!" );
     720                 :            :                     }
     721                 :            :                 }
     722                 :            :                 else
     723 [ #  # ][ #  # ]:          0 :                     Execute(ID_BROWSER_QUERY_EXECUTE,Sequence< PropertyValue >());
         [ #  # ][ #  # ]
     724                 :            :             }
     725                 :          0 :             catch(const Exception&)
     726                 :            :             {
     727                 :            :             }
     728                 :          0 :             break;
     729                 :            :         case ID_QUERY_ZOOM_IN:
     730                 :            :             {
     731                 :            :             }
     732                 :          0 :             break;
     733                 :            :         case ID_QUERY_ZOOM_OUT:
     734                 :            :             {
     735                 :            :             }
     736                 :          0 :             break;
     737                 :            : #if OSL_DEBUG_LEVEL > 1
     738                 :            :         case ID_EDIT_QUERY_DESIGN:
     739                 :            :         case ID_EDIT_QUERY_SQL:
     740                 :            :             {
     741                 :            :                 ::rtl::OUString aErrorMsg;
     742                 :            :                 setStatement_fireEvent( getContainer()->getStatement() );
     743                 :            :                 ::connectivity::OSQLParseNode* pNode = m_aSqlParser.parseTree( aErrorMsg, m_sStatement, m_bGraphicalDesign );
     744                 :            :                 if ( pNode )
     745                 :            :                 {
     746                 :            :                     Window* pView = getView();
     747                 :            :                     ModalDialog* pWindow = new ModalDialog( pView, WB_STDMODAL | WB_SIZEMOVE | WB_CENTER );
     748                 :            :                     pWindow->SetSizePixel( ::Size( pView->GetSizePixel().Width() / 2, pView->GetSizePixel().Height() / 2 ) );
     749                 :            :                     SvTreeListBox* pTreeBox = new SvTreeListBox( pWindow, WB_BORDER | WB_HASLINES | WB_HASBUTTONS | WB_HASBUTTONSATROOT | WB_HASLINESATROOT | WB_VSCROLL );
     750                 :            :                     pTreeBox->SetPosSizePixel( ::Point( 6, 6 ), ::Size( pWindow->GetSizePixel().Width() - 12, pWindow->GetSizePixel().Height() - 12 ));
     751                 :            :                     pTreeBox->SetNodeDefaultImages();
     752                 :            : 
     753                 :            :                     if ( _nId == ID_EDIT_QUERY_DESIGN )
     754                 :            :                     {
     755                 :            :                         ::connectivity::OSQLParseNode* pTemp = pNode ? pNode->getChild(3)->getChild(1) : NULL;
     756                 :            :                         // no where clause found
     757                 :            :                         if ( pTemp && !pTemp->isLeaf() )
     758                 :            :                         {
     759                 :            :                             ::connectivity::OSQLParseNode * pCondition = pTemp->getChild(1);
     760                 :            :                             if ( pCondition ) // no where clause
     761                 :            :                             {
     762                 :            :                                 ::connectivity::OSQLParseNode::negateSearchCondition(pCondition);
     763                 :            :                                 ::connectivity::OSQLParseNode *pNodeTmp = pTemp->getChild(1);
     764                 :            : 
     765                 :            :                                 ::connectivity::OSQLParseNode::disjunctiveNormalForm(pNodeTmp);
     766                 :            :                                 pNodeTmp = pTemp->getChild(1);
     767                 :            :                                 ::connectivity::OSQLParseNode::absorptions(pNodeTmp);
     768                 :            :                                 pNodeTmp = pTemp->getChild(1);
     769                 :            :                                 OSQLParseNode::compress(pNodeTmp);
     770                 :            :                                 pNodeTmp = pTemp->getChild(1);
     771                 :            :                             }
     772                 :            :                             ::rtl::OUString sTemp;
     773                 :            :                             pNode->parseNodeToStr(sTemp,getConnection());
     774                 :            :                             getContainer()->setStatement(sTemp);
     775                 :            :                         }
     776                 :            :                     }
     777                 :            : 
     778                 :            :                     insertParseTree(pTreeBox,pNode);
     779                 :            : 
     780                 :            :                     pTreeBox->Show();
     781                 :            :                     pWindow->Execute();
     782                 :            : 
     783                 :            :                     delete pTreeBox;
     784                 :            :                     delete pWindow;
     785                 :            :                     delete pNode;
     786                 :            :                 }
     787                 :            :                 break;
     788                 :            :             }
     789                 :            : #endif
     790                 :            :         default:
     791                 :          0 :             OJoinController::Execute(_nId,aArgs);
     792                 :          0 :             return; // else we would invalidate twice
     793                 :            :     }
     794         [ #  # ]:          0 :     InvalidateFeature(_nId);
     795                 :            : }
     796                 :            : 
     797                 :            : // -----------------------------------------------------------------------------
     798                 :          0 : void OQueryController::impl_showAutoSQLViewError( const ::com::sun::star::uno::Any& _rErrorDetails )
     799                 :            : {
     800         [ #  # ]:          0 :     SQLContext aErrorContext;
     801 [ #  # ][ #  # ]:          0 :     aErrorContext.Message = lcl_getObjectResourceString( STR_ERROR_PARSING_STATEMENT, m_nCommandType );
                 [ #  # ]
     802 [ #  # ][ #  # ]:          0 :     aErrorContext.Context = *this;
     803 [ #  # ][ #  # ]:          0 :     aErrorContext.Details = lcl_getObjectResourceString( STR_INFO_OPENING_IN_SQL_VIEW, m_nCommandType );
                 [ #  # ]
     804                 :          0 :     aErrorContext.NextException = _rErrorDetails;
     805 [ #  # ][ #  # ]:          0 :     showError( aErrorContext );
         [ #  # ][ #  # ]
     806                 :          0 : }
     807                 :            : 
     808                 :            : // -----------------------------------------------------------------------------
     809                 :          0 : bool OQueryController::impl_setViewMode( ::dbtools::SQLExceptionInfo* _pErrorInfo )
     810                 :            : {
     811                 :            :     OSL_PRECOND( getContainer(), "OQueryController::impl_setViewMode: illegal call!" );
     812                 :            : 
     813         [ #  # ]:          0 :     bool wasModified = isModified();
     814                 :            : 
     815         [ #  # ]:          0 :     SQLExceptionInfo aError;
     816         [ #  # ]:          0 :     bool bSuccess = getContainer()->switchView( &aError );
     817         [ #  # ]:          0 :     if ( !bSuccess )
     818                 :            :     {
     819                 :          0 :         m_bGraphicalDesign = !m_bGraphicalDesign;
     820                 :            :         // restore old state
     821         [ #  # ]:          0 :         getContainer()->switchView( NULL );
     822                 :            :             // don't pass &aError here, this would overwrite the error which the first switchView call
     823                 :            :             // returned in this location.
     824         [ #  # ]:          0 :         if ( _pErrorInfo )
     825         [ #  # ]:          0 :             *_pErrorInfo = aError;
     826                 :            :         else
     827         [ #  # ]:          0 :             showError( aError );
     828                 :            :     }
     829                 :            :     else
     830                 :            :     {
     831         [ #  # ]:          0 :         ensureToolbars( *this, m_bGraphicalDesign );
     832                 :            :     }
     833                 :            : 
     834         [ #  # ]:          0 :     setModified( wasModified );
     835         [ #  # ]:          0 :     return bSuccess;
     836                 :            : }
     837                 :            : 
     838                 :            : // -----------------------------------------------------------------------------
     839                 :          0 : void OQueryController::impl_initialize()
     840                 :            : {
     841         [ #  # ]:          0 :     OJoinController::impl_initialize();
     842                 :            : 
     843                 :          0 :     const NamedValueCollection& rArguments( getInitParams() );
     844                 :            : 
     845                 :          0 :     ::rtl::OUString sCommand;
     846                 :          0 :     m_nCommandType = CommandType::QUERY;
     847                 :            : 
     848                 :            :     // �����������������������������������������������������������������������������������������������������������������
     849                 :            :     // � reading parameters
     850                 :            :     // �����������������������������������������������������������������������������������������������������������������
     851                 :            :     // legacy parameters first (later overwritten by regular parameters)
     852                 :          0 :     ::rtl::OUString sIndependentSQLCommand;
     853 [ #  # ][ #  # ]:          0 :     if ( rArguments.get_ensureType( "IndependentSQLCommand", sIndependentSQLCommand ) )
     854                 :            :     {
     855                 :            :         OSL_FAIL( "OQueryController::impl_initialize: IndependentSQLCommand is regognized for compatibility only!" );
     856                 :          0 :         sCommand = sIndependentSQLCommand;
     857                 :          0 :         m_nCommandType = CommandType::COMMAND;
     858                 :            :     }
     859                 :            : 
     860                 :          0 :     ::rtl::OUString sCurrentQuery;
     861 [ #  # ][ #  # ]:          0 :     if ( rArguments.get_ensureType( "CurrentQuery", sCurrentQuery ) )
     862                 :            :     {
     863                 :            :         OSL_FAIL( "OQueryController::impl_initialize: CurrentQuery is regognized for compatibility only!" );
     864                 :          0 :         sCommand = sCurrentQuery;
     865                 :          0 :         m_nCommandType = CommandType::QUERY;
     866                 :            :     }
     867                 :            : 
     868                 :          0 :     sal_Bool bCreateView( sal_False );
     869 [ #  # ][ #  # ]:          0 :     if ( rArguments.get_ensureType( "CreateView", bCreateView ) && bCreateView )
         [ #  # ][ #  # ]
     870                 :            :     {
     871                 :            :         OSL_FAIL( "OQueryController::impl_initialize: CurrentQuery is regognized for compatibility only!" );
     872                 :          0 :         m_nCommandType = CommandType::TABLE;
     873                 :            :     }
     874                 :            : 
     875                 :            :     // non-legacy parameters which overwrite the legacy parameters
     876 [ #  # ][ #  # ]:          0 :     rArguments.get_ensureType( (::rtl::OUString)PROPERTY_COMMAND, sCommand );
     877 [ #  # ][ #  # ]:          0 :     rArguments.get_ensureType( (::rtl::OUString)PROPERTY_COMMAND_TYPE, m_nCommandType );
     878                 :            : 
     879                 :            :     // translate Command/Type into proper members
     880                 :            :     // TODO/Later: all this (including those members) should be hidden behind some abstact interface,
     881                 :            :     // which is implemented for all the three commands
     882   [ #  #  #  # ]:          0 :     switch ( m_nCommandType )
     883                 :            :     {
     884                 :            :     case CommandType::QUERY:
     885                 :          0 :         m_sName = sCommand;
     886                 :          0 :         break;
     887                 :            :     case CommandType::TABLE:
     888                 :          0 :         m_sName = sCommand;
     889                 :          0 :         break;
     890                 :            :     case CommandType::COMMAND:
     891         [ #  # ]:          0 :         setStatement_fireEvent( sCommand );
     892                 :          0 :         m_sName = ::rtl::OUString();
     893                 :          0 :         break;
     894                 :            :     default:
     895                 :            :         OSL_FAIL( "OQueryController::impl_initialize: logic error in code!" );
     896         [ #  # ]:          0 :         throw RuntimeException();
     897                 :            :     }
     898                 :            : 
     899                 :            :     // more legacy parameters
     900                 :          0 :     sal_Bool bGraphicalDesign( sal_True );
     901 [ #  # ][ #  # ]:          0 :     if ( rArguments.get_ensureType( (::rtl::OUString)PROPERTY_QUERYDESIGNVIEW, bGraphicalDesign ) )
                 [ #  # ]
     902                 :            :     {
     903                 :            :         OSL_FAIL( "OQueryController::impl_initialize: QueryDesignView is regognized for compatibility only!" );
     904                 :          0 :         m_bGraphicalDesign = bGraphicalDesign;
     905                 :            :     }
     906                 :            : 
     907                 :            :     // more non-legacy
     908 [ #  # ][ #  # ]:          0 :     rArguments.get_ensureType( (::rtl::OUString)PROPERTY_GRAPHICAL_DESIGN, m_bGraphicalDesign );
     909                 :            : 
     910                 :          0 :     bool bEscapeProcessing( sal_True );
     911 [ #  # ][ #  # ]:          0 :     if ( rArguments.get_ensureType( (::rtl::OUString)PROPERTY_ESCAPE_PROCESSING, bEscapeProcessing ) )
                 [ #  # ]
     912                 :            :     {
     913         [ #  # ]:          0 :         setEscapeProcessing_fireEvent( bEscapeProcessing );
     914                 :            : 
     915                 :            :         OSL_ENSURE( m_bEscapeProcessing || !m_bGraphicalDesign, "OQueryController::impl_initialize: can't do the graphical design without escape processing!" );
     916         [ #  # ]:          0 :         if ( !m_bEscapeProcessing )
     917                 :          0 :             m_bGraphicalDesign = false;
     918                 :            :     }
     919                 :            : 
     920                 :            :     // .................................................................................................................
     921                 :            :     // . initial design
     922                 :          0 :     bool bForceInitialDesign = false;
     923         [ #  # ]:          0 :     Sequence< PropertyValue > aCurrentQueryDesignProps;
     924 [ #  # ][ #  # ]:          0 :     aCurrentQueryDesignProps = rArguments.getOrDefault( "CurrentQueryDesign", aCurrentQueryDesignProps );
                 [ #  # ]
     925                 :            : 
     926         [ #  # ]:          0 :     if ( aCurrentQueryDesignProps.getLength() )
     927                 :            :     {
     928         [ #  # ]:          0 :         ::comphelper::NamedValueCollection aCurrentQueryDesign( aCurrentQueryDesignProps );
     929 [ #  # ][ #  # ]:          0 :         if ( aCurrentQueryDesign.has( (::rtl::OUString)PROPERTY_GRAPHICAL_DESIGN ) )
                 [ #  # ]
     930                 :            :         {
     931 [ #  # ][ #  # ]:          0 :             aCurrentQueryDesign.get_ensureType( (::rtl::OUString)PROPERTY_GRAPHICAL_DESIGN, m_bGraphicalDesign );
     932                 :            :         }
     933 [ #  # ][ #  # ]:          0 :         if ( aCurrentQueryDesign.has( (::rtl::OUString)PROPERTY_ESCAPE_PROCESSING ) )
                 [ #  # ]
     934                 :            :         {
     935 [ #  # ][ #  # ]:          0 :             aCurrentQueryDesign.get_ensureType( (::rtl::OUString)PROPERTY_ESCAPE_PROCESSING, m_bEscapeProcessing );
     936                 :            :         }
     937 [ #  # ][ #  # ]:          0 :         if ( aCurrentQueryDesign.has( "Statement" ) )
     938                 :            :         {
     939                 :          0 :             ::rtl::OUString sStatement;
     940         [ #  # ]:          0 :             aCurrentQueryDesign.get_ensureType( "Statement", sStatement );
     941         [ #  # ]:          0 :             aCurrentQueryDesign.remove( "Statement" );
     942         [ #  # ]:          0 :             setStatement_fireEvent( sStatement );
     943                 :            :         }
     944                 :            : 
     945         [ #  # ]:          0 :         loadViewSettings( aCurrentQueryDesign );
     946                 :            : 
     947         [ #  # ]:          0 :         bForceInitialDesign = true;
     948                 :            :     }
     949                 :            : 
     950                 :            :     // �����������������������������������������������������������������������������������������������������������������
     951 [ #  # ][ #  # ]:          0 :     if ( !ensureConnected( sal_False ) )
     952                 :            :     {   // we have no connection so what else should we do
     953                 :          0 :         m_bGraphicalDesign = sal_False;
     954         [ #  # ]:          0 :         if ( editingView() )
     955                 :            :         {
     956         [ #  # ]:          0 :             connectionLostMessage();
     957         [ #  # ]:          0 :             throw SQLException();
     958                 :            :         }
     959                 :            :     }
     960                 :            : 
     961                 :            :     // check the view capabilities
     962 [ #  # ][ #  # ]:          0 :     if ( isConnected() && editingView() )
         [ #  # ][ #  # ]
     963                 :            :     {
     964 [ #  # ][ #  # ]:          0 :         Reference< XViewsSupplier > xViewsSup( getConnection(), UNO_QUERY );
     965                 :          0 :         Reference< XNameAccess > xViews;
     966         [ #  # ]:          0 :         if ( xViewsSup.is() )
     967 [ #  # ][ #  # ]:          0 :             xViews = xViewsSup->getViews();
                 [ #  # ]
     968                 :            : 
     969         [ #  # ]:          0 :         if ( !xViews.is() )
     970                 :            :         {   // we can't create views so we ask if the user wants to create a query instead
     971                 :          0 :             m_nCommandType = CommandType::QUERY;
     972                 :          0 :             sal_Bool bClose = sal_False;
     973                 :            :             {
     974 [ #  # ][ #  # ]:          0 :                 String aTitle( ModuleRes( STR_QUERYDESIGN_NO_VIEW_SUPPORT ) );
     975 [ #  # ][ #  # ]:          0 :                 String aMessage( ModuleRes( STR_QUERYDESIGN_NO_VIEW_ASK ) );
     976                 :          0 :                 ODataView* pWindow = getView();
     977         [ #  # ]:          0 :                 OSQLMessageBox aDlg( pWindow, aTitle, aMessage, WB_YES_NO | WB_DEF_YES, OSQLMessageBox::Query );
     978 [ #  # ][ #  # ]:          0 :                 bClose = aDlg.Execute() == RET_NO;
         [ #  # ][ #  # ]
     979                 :            :             }
     980         [ #  # ]:          0 :             if ( bClose )
     981         [ #  # ]:          0 :                 throw VetoException();
     982                 :            :         }
     983                 :            : 
     984                 :            :         // now if we are to edit an existing view, check whether this is possible
     985         [ #  # ]:          0 :         if ( !m_sName.isEmpty() )
     986                 :            :         {
     987 [ #  # ][ #  # ]:          0 :             Any aView( xViews->getByName( m_sName ) );
     988                 :            :                 // will throw if there is no such view
     989 [ #  # ][ #  # ]:          0 :             if ( !( aView >>= m_xAlterView ) )
     990                 :            :             {
     991                 :            :                 throw IllegalArgumentException(
     992                 :            :                     ::rtl::OUString( String( ModuleRes( STR_NO_ALTER_VIEW_SUPPORT ) ) ),
     993                 :            :                     *this,
     994                 :            :                     1
     995 [ #  # ][ #  # ]:          0 :                 );
         [ #  # ][ #  # ]
                 [ #  # ]
     996                 :          0 :             }
     997                 :          0 :         }
     998                 :            :     }
     999                 :            : 
    1000                 :            :     OSL_ENSURE(getDataSource().is(),"OQueryController::impl_initialize: need a datasource!");
    1001                 :            : 
    1002                 :            :     try
    1003                 :            :     {
    1004         [ #  # ]:          0 :         getContainer()->initialize();
    1005         [ #  # ]:          0 :         impl_reset( bForceInitialDesign );
    1006                 :            : 
    1007         [ #  # ]:          0 :         SQLExceptionInfo aError;
    1008                 :          0 :         const bool bAttemptedGraphicalDesign = m_bGraphicalDesign;
    1009                 :            : 
    1010         [ #  # ]:          0 :         if ( bForceInitialDesign )
    1011                 :            :         {
    1012         [ #  # ]:          0 :             getContainer()->forceInitialView();
    1013                 :            :         }
    1014                 :            :         else
    1015                 :            :         {
    1016         [ #  # ]:          0 :             impl_setViewMode( &aError );
    1017                 :            :         }
    1018                 :            : 
    1019 [ #  # ][ #  # ]:          0 :         if ( aError.isValid() && bAttemptedGraphicalDesign && !m_bGraphicalDesign )
         [ #  # ][ #  # ]
    1020                 :            :         {
    1021                 :            :             // we tried initializing the graphical view, this failed, and we were automatically switched to SQL
    1022                 :            :             // view => tell this to the user
    1023         [ #  # ]:          0 :             if ( !editingView() )
    1024                 :            :             {
    1025         [ #  # ]:          0 :                 impl_showAutoSQLViewError( aError.get() );
    1026                 :            :             }
    1027                 :            :         }
    1028                 :            : 
    1029         [ #  # ]:          0 :         ClearUndoManager();
    1030                 :            : 
    1031   [ #  #  #  #  :          0 :         if  (  ( m_bGraphicalDesign )
          #  #  #  #  #  
              # ][ #  # ]
    1032                 :          0 :             && (  ( m_sName.isEmpty() && !editingCommand() )
    1033                 :          0 :                || ( m_sStatement.isEmpty() && editingCommand() )
    1034                 :            :                )
    1035                 :            :             )
    1036                 :            :         {
    1037 [ #  # ][ #  # ]:          0 :             Application::PostUserEvent( LINK( this, OQueryController, OnExecuteAddTable ) );
    1038                 :            :         }
    1039                 :            : 
    1040 [ #  # ][ #  # ]:          0 :         setModified(sal_False);
    1041                 :            :     }
    1042         [ #  # ]:          0 :     catch(const SQLException& e)
    1043                 :            :     {
    1044                 :            :         DBG_UNHANDLED_EXCEPTION();
    1045                 :            :         // we caught an exception so we switch to text only mode
    1046                 :            :         {
    1047                 :          0 :             m_bGraphicalDesign = sal_False;
    1048         [ #  # ]:          0 :             getContainer()->initialize();
    1049                 :          0 :             ODataView* pWindow = getView();
    1050   [ #  #  #  #  :          0 :             OSQLMessageBox(pWindow,e).Execute();
          #  #  #  #  #  
                      # ]
    1051                 :            :         }
    1052                 :          0 :         throw;
    1053         [ #  # ]:          0 :     }
    1054                 :          0 : }
    1055                 :            : 
    1056                 :            : // -----------------------------------------------------------------------------
    1057                 :          0 : void OQueryController::onLoadedMenu(const Reference< ::com::sun::star::frame::XLayoutManager >& /*_xLayoutManager*/)
    1058                 :            : {
    1059                 :          0 :     ensureToolbars( *this, m_bGraphicalDesign );
    1060                 :          0 : }
    1061                 :            : 
    1062                 :            : // -----------------------------------------------------------------------------
    1063                 :          0 : ::rtl::OUString OQueryController::getPrivateTitle( ) const
    1064                 :            : {
    1065                 :          0 :     ::rtl::OUString sName = m_sName;
    1066         [ #  # ]:          0 :     if ( sName.isEmpty() )
    1067                 :            :     {
    1068         [ #  # ]:          0 :         if ( !editingCommand() )
    1069                 :            :         {
    1070         [ #  # ]:          0 :             SolarMutexGuard aSolarGuard;
    1071 [ #  # ][ #  # ]:          0 :             ::osl::MutexGuard aGuard( getMutex() );
    1072 [ #  # ][ #  # ]:          0 :             String aDefaultName = String( ModuleRes( editingView() ? STR_VIEW_TITLE : STR_QRY_TITLE ) );
                 [ #  # ]
    1073 [ #  # ][ #  # ]:          0 :             sName = aDefaultName.GetToken(0,' ');
                 [ #  # ]
    1074 [ #  # ][ #  # ]:          0 :             sName += ::rtl::OUString::valueOf(getCurrentStartNumber());
         [ #  # ][ #  # ]
    1075                 :            :         }
    1076                 :            :     }
    1077                 :          0 :     return sName;
    1078                 :            : }
    1079                 :            : // -----------------------------------------------------------------------------
    1080                 :          0 : void OQueryController::setQueryComposer()
    1081                 :            : {
    1082         [ #  # ]:          0 :     if(isConnected())
    1083                 :            :     {
    1084 [ #  # ][ #  # ]:          0 :         Reference< XSQLQueryComposerFactory >  xFactory(getConnection(), UNO_QUERY);
    1085                 :            :         OSL_ENSURE(xFactory.is(),"Connection doesn't support a querycomposer");
    1086 [ #  # ][ #  # ]:          0 :         if ( xFactory.is() && getContainer() )
                 [ #  # ]
    1087                 :            :         {
    1088                 :            :             try
    1089                 :            :             {
    1090 [ #  # ][ #  # ]:          0 :                 m_xComposer = xFactory->createQueryComposer();
                 [ #  # ]
    1091         [ #  # ]:          0 :                 getContainer()->setStatement(m_sStatement);
    1092                 :            :             }
    1093   [ #  #  #  # ]:          0 :             catch(const Exception&)
    1094                 :            :             {
    1095         [ #  # ]:          0 :                 m_xComposer = NULL;
    1096                 :            :             }
    1097                 :            :             OSL_ENSURE(m_xComposer.is(),"No querycomposer available!");
    1098 [ #  # ][ #  # ]:          0 :             Reference<XTablesSupplier> xTablesSup(getConnection(), UNO_QUERY);
    1099         [ #  # ]:          0 :             deleteIterator();
    1100 [ #  # ][ #  # ]:          0 :             m_pSqlIterator = new ::connectivity::OSQLParseTreeIterator( getConnection(), xTablesSup->getTables(), m_aSqlParser, NULL );
         [ #  # ][ #  # ]
    1101                 :          0 :         }
    1102                 :            :     }
    1103                 :          0 : }
    1104                 :            : // -----------------------------------------------------------------------------
    1105                 :          0 : sal_Bool OQueryController::Construct(Window* pParent)
    1106                 :            : {
    1107                 :            :     // TODO: we have to check if we should create the text- or the design- view
    1108                 :            : 
    1109 [ #  # ][ #  # ]:          0 :     setView( * new OQueryContainerWindow( pParent, *this, getORB() ) );
    1110                 :            : 
    1111                 :          0 :     return OJoinController::Construct(pParent);
    1112                 :            : }
    1113                 :            : 
    1114                 :            : // -----------------------------------------------------------------------------
    1115                 :          0 : OJoinDesignView* OQueryController::getJoinView()
    1116                 :            : {
    1117                 :          0 :     return getContainer()->getDesignView();
    1118                 :            : }
    1119                 :            : // -----------------------------------------------------------------------------
    1120                 :          0 : void OQueryController::describeSupportedFeatures()
    1121                 :            : {
    1122                 :          0 :     OJoinController::describeSupportedFeatures();
    1123                 :          0 :     implDescribeSupportedFeature( ".uno:SaveAs",            ID_BROWSER_SAVEASDOC,       CommandGroup::DOCUMENT );
    1124                 :          0 :     implDescribeSupportedFeature( ".uno:SbaNativeSql",      ID_BROWSER_ESACPEPROCESSING,CommandGroup::FORMAT );
    1125                 :          0 :     implDescribeSupportedFeature( ".uno:DBViewFunctions",   SID_QUERY_VIEW_FUNCTIONS,   CommandGroup::VIEW );
    1126                 :          0 :     implDescribeSupportedFeature( ".uno:DBViewTableNames",  SID_QUERY_VIEW_TABLES,      CommandGroup::VIEW );
    1127                 :          0 :     implDescribeSupportedFeature( ".uno:DBViewAliases",     SID_QUERY_VIEW_ALIASES,     CommandGroup::VIEW );
    1128                 :          0 :     implDescribeSupportedFeature( ".uno:DBDistinctValues",  SID_QUERY_DISTINCT_VALUES,  CommandGroup::FORMAT );
    1129                 :          0 :     implDescribeSupportedFeature( ".uno:DBChangeDesignMode",ID_BROWSER_SQL,             CommandGroup::VIEW );
    1130                 :          0 :     implDescribeSupportedFeature( ".uno:DBClearQuery",      SID_BROWSER_CLEAR_QUERY,    CommandGroup::EDIT );
    1131                 :          0 :     implDescribeSupportedFeature( ".uno:SbaExecuteSql",     ID_BROWSER_QUERY_EXECUTE,   CommandGroup::VIEW );
    1132                 :          0 :     implDescribeSupportedFeature( ".uno:DBAddRelation",     SID_RELATION_ADD_RELATION,  CommandGroup::EDIT );
    1133                 :          0 :     implDescribeSupportedFeature( ".uno:DBQueryPreview",    SID_DB_QUERY_PREVIEW,       CommandGroup::VIEW );
    1134                 :            : 
    1135                 :            : #if OSL_DEBUG_LEVEL > 1
    1136                 :            :     implDescribeSupportedFeature( ".uno:DBShowParseTree",   ID_EDIT_QUERY_SQL );
    1137                 :            :     implDescribeSupportedFeature( ".uno:DBMakeDisjunct",    ID_EDIT_QUERY_DESIGN );
    1138                 :            : #endif
    1139                 :          0 : }
    1140                 :            : // -----------------------------------------------------------------------------
    1141                 :          0 : void OQueryController::impl_onModifyChanged()
    1142                 :            : {
    1143                 :          0 :     OJoinController::impl_onModifyChanged();
    1144         [ #  # ]:          0 :     InvalidateFeature(SID_BROWSER_CLEAR_QUERY);
    1145         [ #  # ]:          0 :     InvalidateFeature(ID_BROWSER_SAVEASDOC);
    1146         [ #  # ]:          0 :     InvalidateFeature(ID_BROWSER_QUERY_EXECUTE);
    1147                 :          0 : }
    1148                 :            : // -----------------------------------------------------------------------------
    1149                 :          0 : void SAL_CALL OQueryController::disposing( const EventObject& Source ) throw(RuntimeException)
    1150                 :            : {
    1151         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1152                 :            : 
    1153 [ #  # ][ #  # ]:          0 :     if ( getContainer() && Source.Source.is() )
                 [ #  # ]
    1154                 :            :     {
    1155 [ #  # ][ #  # ]:          0 :         if ( Source.Source == m_aCurrentFrame.getFrame() )
                 [ #  # ]
    1156                 :            :         {   // our frame is being disposed -> close the preview window (if we have one)
    1157         [ #  # ]:          0 :             Reference< XFrame > xPreviewFrame( getContainer()->getPreviewFrame() );
    1158         [ #  # ]:          0 :             ::comphelper::disposeComponent( xPreviewFrame );
    1159                 :            :         }
    1160 [ #  # ][ #  # ]:          0 :         else if ( Source.Source == getContainer()->getPreviewFrame() )
                 [ #  # ]
    1161                 :            :         {
    1162         [ #  # ]:          0 :             getContainer()->disposingPreview();
    1163                 :            :         }
    1164                 :            :     }
    1165                 :            : 
    1166 [ #  # ][ #  # ]:          0 :     OJoinController::disposing(Source);
    1167                 :          0 : }
    1168                 :            : // -----------------------------------------------------------------------------
    1169                 :          0 : void OQueryController::reconnect(sal_Bool _bUI)
    1170                 :            : {
    1171                 :          0 :     deleteIterator();
    1172                 :          0 :     ::comphelper::disposeComponent(m_xComposer);
    1173                 :            : 
    1174                 :          0 :     OJoinController::reconnect( _bUI );
    1175                 :            : 
    1176         [ #  # ]:          0 :     if (isConnected())
    1177                 :            :     {
    1178                 :          0 :         setQueryComposer();
    1179                 :            :     }
    1180                 :            :     else
    1181                 :            :     {
    1182         [ #  # ]:          0 :         if(m_bGraphicalDesign)
    1183                 :            :         {
    1184                 :          0 :             m_bGraphicalDesign = sal_False;
    1185                 :            :             // don't call Execute(SQL) because this changes the sql statement
    1186                 :          0 :             impl_setViewMode( NULL );
    1187                 :            :         }
    1188                 :          0 :         InvalidateAll();
    1189                 :            :     }
    1190                 :          0 : }
    1191                 :            : 
    1192                 :            : // -----------------------------------------------------------------------------
    1193                 :          0 : void OQueryController::saveViewSettings( ::comphelper::NamedValueCollection& o_rViewSettings, const bool i_includingCriteria ) const
    1194                 :            : {
    1195         [ #  # ]:          0 :     saveTableWindows( o_rViewSettings );
    1196                 :            : 
    1197                 :          0 :     OTableFields::const_iterator field = m_vTableFieldDesc.begin();
    1198                 :          0 :     OTableFields::const_iterator fieldEnd = m_vTableFieldDesc.end();
    1199                 :            : 
    1200         [ #  # ]:          0 :     ::comphelper::NamedValueCollection aAllFieldsData;
    1201         [ #  # ]:          0 :     ::comphelper::NamedValueCollection aFieldData;
    1202 [ #  # ][ #  # ]:          0 :     for ( sal_Int32 i = 1; field != fieldEnd; ++field, ++i )
    1203                 :            :     {
    1204 [ #  # ][ #  # ]:          0 :         if ( !(*field)->IsEmpty() )
    1205                 :            :         {
    1206         [ #  # ]:          0 :             aFieldData.clear();
    1207         [ #  # ]:          0 :             (*field)->Save( aFieldData, i_includingCriteria );
    1208                 :            : 
    1209         [ #  # ]:          0 :             const ::rtl::OUString sFieldSettingName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Field" ) ) + ::rtl::OUString::valueOf( i );
    1210 [ #  # ][ #  # ]:          0 :             aAllFieldsData.put( sFieldSettingName, aFieldData.getPropertyValues() );
                 [ #  # ]
    1211                 :            :         }
    1212                 :            :     }
    1213                 :            : 
    1214 [ #  # ][ #  # ]:          0 :     o_rViewSettings.put( "Fields", aAllFieldsData.getPropertyValues() );
                 [ #  # ]
    1215         [ #  # ]:          0 :     o_rViewSettings.put( "SplitterPosition", m_nSplitPos );
    1216 [ #  # ][ #  # ]:          0 :     o_rViewSettings.put( "VisibleRows", m_nVisibleRows );
                 [ #  # ]
    1217                 :          0 : }
    1218                 :            : // -----------------------------------------------------------------------------
    1219                 :          0 : void OQueryController::loadViewSettings( const ::comphelper::NamedValueCollection& o_rViewSettings )
    1220                 :            : {
    1221                 :          0 :     loadTableWindows( o_rViewSettings );
    1222                 :            : 
    1223                 :          0 :     m_nSplitPos = o_rViewSettings.getOrDefault( "SplitterPosition", m_nSplitPos );
    1224                 :          0 :     m_nVisibleRows = o_rViewSettings.getOrDefault( "VisibleRows", m_nVisibleRows );
    1225         [ #  # ]:          0 :     m_aFieldInformation = o_rViewSettings.getOrDefault( "Fields", m_aFieldInformation );
    1226                 :          0 : }
    1227                 :            : // -----------------------------------------------------------------------------
    1228                 :          0 : sal_Int32 OQueryController::getColWidth(sal_uInt16 _nColPos)  const
    1229                 :            : {
    1230         [ #  # ]:          0 :     if ( _nColPos < m_aFieldInformation.getLength() )
    1231                 :            :     {
    1232 [ #  # ][ #  # ]:          0 :         ::std::auto_ptr<OTableFieldDesc> pField( new OTableFieldDesc());
    1233         [ #  # ]:          0 :         pField->Load( m_aFieldInformation[ _nColPos ], false );
    1234         [ #  # ]:          0 :         return pField->GetColWidth();
    1235                 :            :     }
    1236                 :          0 :     return 0;
    1237                 :            : }
    1238                 :            : // -----------------------------------------------------------------------------
    1239                 :          0 : Reference<XNameAccess> OQueryController::getObjectContainer()  const
    1240                 :            : {
    1241                 :          0 :     Reference< XNameAccess > xElements;
    1242         [ #  # ]:          0 :     if ( editingView() )
    1243                 :            :     {
    1244 [ #  # ][ #  # ]:          0 :         Reference< XViewsSupplier > xViewsSupp( getConnection(), UNO_QUERY );
    1245         [ #  # ]:          0 :         if ( xViewsSupp.is() )
    1246 [ #  # ][ #  # ]:          0 :             xElements = xViewsSupp->getViews();
                 [ #  # ]
    1247                 :            :     }
    1248                 :            :     else
    1249                 :            :     {
    1250 [ #  # ][ #  # ]:          0 :         Reference< XQueriesSupplier > xQueriesSupp( getConnection(), UNO_QUERY );
    1251         [ #  # ]:          0 :         if ( xQueriesSupp.is() )
    1252 [ #  # ][ #  # ]:          0 :             xElements = xQueriesSupp->getQueries();
                 [ #  # ]
    1253                 :            :         else
    1254                 :            :         {
    1255 [ #  # ][ #  # ]:          0 :             Reference< XQueryDefinitionsSupplier > xQueryDefsSupp( getDataSource(), UNO_QUERY );
    1256         [ #  # ]:          0 :             if ( xQueryDefsSupp.is() )
    1257 [ #  # ][ #  # ]:          0 :                 xElements = xQueryDefsSupp->getQueryDefinitions();
                 [ #  # ]
    1258                 :          0 :         }
    1259                 :            :     }
    1260                 :            : 
    1261                 :            :     OSL_ENSURE( xElements.is(), "OQueryController::getObjectContainer: unable to obtain the container!" );
    1262                 :          0 :     return xElements;
    1263                 :            : }
    1264                 :            : 
    1265                 :            : // -----------------------------------------------------------------------------
    1266                 :          0 : void OQueryController::executeQuery()
    1267                 :            : {
    1268                 :            :     // we don't need to check the connection here because we already check the composer
    1269                 :            :     // which can't live without his connection
    1270         [ #  # ]:          0 :     ::rtl::OUString sTranslatedStmt = translateStatement( false );
    1271                 :            : 
    1272         [ #  # ]:          0 :     ::rtl::OUString sDataSourceName = getDataSourceName();
    1273 [ #  # ][ #  # ]:          0 :     if ( !(sDataSourceName.isEmpty() || sTranslatedStmt.isEmpty()) )
                 [ #  # ]
    1274                 :            :     {
    1275                 :            :         try
    1276                 :            :         {
    1277 [ #  # ][ #  # ]:          0 :             getContainer()->showPreview( getFrame() );
    1278 [ #  # ][ #  # ]:          0 :             InvalidateFeature(SID_DB_QUERY_PREVIEW);
    1279                 :            : 
    1280                 :          0 :             URL aWantToDispatch;
    1281         [ #  # ]:          0 :             aWantToDispatch.Complete = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".component:DB/DataSourceBrowser"));
    1282                 :            : 
    1283         [ #  # ]:          0 :             ::rtl::OUString sFrameName( FRAME_NAME_QUERY_PREVIEW );
    1284                 :          0 :             sal_Int32 nSearchFlags = FrameSearchFlag::CHILDREN;
    1285                 :            : 
    1286                 :          0 :             Reference< XDispatch> xDisp;
    1287 [ #  # ][ #  # ]:          0 :             Reference< XDispatchProvider> xProv( getFrame()->findFrame( sFrameName, nSearchFlags ), UNO_QUERY );
         [ #  # ][ #  # ]
    1288         [ #  # ]:          0 :             if(!xProv.is())
    1289                 :            :             {
    1290 [ #  # ][ #  # ]:          0 :                 xProv.set( getFrame(), UNO_QUERY );
    1291         [ #  # ]:          0 :                 if (xProv.is())
    1292 [ #  # ][ #  # ]:          0 :                     xDisp = xProv->queryDispatch(aWantToDispatch, sFrameName, nSearchFlags);
                 [ #  # ]
    1293                 :            :             }
    1294                 :            :             else
    1295                 :            :             {
    1296 [ #  # ][ #  # ]:          0 :                 xDisp = xProv->queryDispatch(aWantToDispatch, sFrameName, FrameSearchFlag::SELF);
                 [ #  # ]
    1297                 :            :             }
    1298         [ #  # ]:          0 :             if (xDisp.is())
    1299                 :            :             {
    1300         [ #  # ]:          0 :                 Sequence< PropertyValue> aProps(9);
    1301 [ #  # ][ #  # ]:          0 :                 aProps[0].Name = PROPERTY_DATASOURCENAME;
    1302 [ #  # ][ #  # ]:          0 :                 aProps[0].Value <<= sDataSourceName;
    1303                 :            : 
    1304 [ #  # ][ #  # ]:          0 :                 aProps[1].Name = PROPERTY_COMMAND_TYPE;
    1305 [ #  # ][ #  # ]:          0 :                 aProps[1].Value <<= CommandType::COMMAND;
    1306                 :            : 
    1307 [ #  # ][ #  # ]:          0 :                 aProps[2].Name = PROPERTY_COMMAND;
    1308 [ #  # ][ #  # ]:          0 :                 aProps[2].Value <<= sTranslatedStmt;
    1309                 :            : 
    1310 [ #  # ][ #  # ]:          0 :                 aProps[3].Name = PROPERTY_ENABLE_BROWSER;
    1311 [ #  # ][ #  # ]:          0 :                 aProps[3].Value = ::cppu::bool2any(sal_False);
    1312                 :            : 
    1313 [ #  # ][ #  # ]:          0 :                 aProps[4].Name = PROPERTY_ACTIVE_CONNECTION;
    1314 [ #  # ][ #  # ]:          0 :                 aProps[4].Value <<= getConnection();
                 [ #  # ]
    1315                 :            : 
    1316 [ #  # ][ #  # ]:          0 :                 aProps[5].Name = PROPERTY_UPDATE_CATALOGNAME;
    1317 [ #  # ][ #  # ]:          0 :                 aProps[5].Value <<= m_sUpdateCatalogName;
    1318                 :            : 
    1319 [ #  # ][ #  # ]:          0 :                 aProps[6].Name = PROPERTY_UPDATE_SCHEMANAME;
    1320 [ #  # ][ #  # ]:          0 :                 aProps[6].Value <<= m_sUpdateSchemaName;
    1321                 :            : 
    1322 [ #  # ][ #  # ]:          0 :                 aProps[7].Name = PROPERTY_UPDATE_TABLENAME;
    1323 [ #  # ][ #  # ]:          0 :                 aProps[7].Value <<= m_sUpdateTableName;
    1324                 :            : 
    1325 [ #  # ][ #  # ]:          0 :                 aProps[8].Name = PROPERTY_ESCAPE_PROCESSING;
    1326 [ #  # ][ #  # ]:          0 :                 aProps[8].Value = ::cppu::bool2any(m_bEscapeProcessing);
    1327                 :            : 
    1328 [ #  # ][ #  # ]:          0 :                 xDisp->dispatch(aWantToDispatch, aProps);
    1329                 :            :                 // check the state of the beamer
    1330                 :            :                 // be notified when the beamer frame is closed
    1331 [ #  # ][ #  # ]:          0 :                 Reference< XComponent >  xComponent( getFrame()->findFrame( sFrameName, nSearchFlags ), UNO_QUERY );
         [ #  # ][ #  # ]
    1332         [ #  # ]:          0 :                 if (xComponent.is())
    1333                 :            :                 {
    1334                 :            :                     OSL_ENSURE(Reference< XFrame >(xComponent, UNO_QUERY).get() == getContainer()->getPreviewFrame().get(),
    1335                 :            :                         "OQueryController::executeQuery: oops ... which window do I have here?");
    1336         [ #  # ]:          0 :                     Reference< XEventListener> xEvtL((::cppu::OWeakObject*)this,UNO_QUERY);
    1337 [ #  # ][ #  # ]:          0 :                     xComponent->addEventListener(xEvtL);
    1338         [ #  # ]:          0 :                 }
    1339                 :            :             }
    1340                 :            :             else
    1341                 :            :             {
    1342                 :            :                 OSL_FAIL("Couldn't create a beamer window!");
    1343         [ #  # ]:          0 :             }
    1344                 :            :         }
    1345         [ #  # ]:          0 :         catch(const Exception&)
    1346                 :            :         {
    1347                 :            :             OSL_FAIL("Couldn't create a beamer window!");
    1348                 :            :         }
    1349                 :          0 :     }
    1350                 :          0 : }
    1351                 :            : // -----------------------------------------------------------------------------
    1352                 :          0 : sal_Bool OQueryController::askForNewName(const Reference<XNameAccess>& _xElements,sal_Bool _bSaveAs)
    1353                 :            : {
    1354                 :            :     OSL_ENSURE( !editingCommand(), "OQueryController::askForNewName: not to be called when designing an independent statement!" );
    1355         [ #  # ]:          0 :     if ( editingCommand() )
    1356                 :          0 :         return sal_False;
    1357                 :            : 
    1358                 :            :     OSL_PRECOND( _xElements.is(), "OQueryController::askForNewName: invalid container!" );
    1359         [ #  # ]:          0 :     if  ( !_xElements.is() )
    1360                 :          0 :         return sal_False;
    1361                 :            : 
    1362                 :          0 :     sal_Bool bRet = sal_True;
    1363 [ #  # ][ #  # ]:          0 :     sal_Bool bNew = _bSaveAs || !_xElements->hasByName( m_sName );
    1364         [ #  # ]:          0 :     if(bNew)
    1365                 :            :     {
    1366         [ #  # ]:          0 :         String aDefaultName;
    1367 [ #  # ][ #  # ]:          0 :         if ( ( _bSaveAs && !bNew ) || ( bNew && !m_sName.isEmpty() ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    1368 [ #  # ][ #  # ]:          0 :             aDefaultName = String( m_sName );
                 [ #  # ]
    1369                 :            :         else
    1370                 :            :         {
    1371 [ #  # ][ #  # ]:          0 :             String sName = String( ModuleRes( editingView() ? STR_VIEW_TITLE : STR_QRY_TITLE ) );
                 [ #  # ]
    1372 [ #  # ][ #  # ]:          0 :             aDefaultName = sName.GetToken(0,' ');
                 [ #  # ]
    1373 [ #  # ][ #  # ]:          0 :             aDefaultName = ::dbtools::createUniqueName(_xElements,aDefaultName);
         [ #  # ][ #  # ]
    1374                 :            :         }
    1375                 :            : 
    1376 [ #  # ][ #  # ]:          0 :         DynamicTableOrQueryNameCheck aNameChecker( getConnection(), CommandType::QUERY );
    1377                 :            :         OSaveAsDlg aDlg(
    1378                 :          0 :                 getView(),
    1379                 :            :                 m_nCommandType,
    1380                 :            :                 getORB(),
    1381         [ #  # ]:          0 :                 getConnection(),
    1382                 :            :                 aDefaultName,
    1383                 :            :                 aNameChecker,
    1384   [ #  #  #  # ]:          0 :                 SAD_DEFAULT );
    1385                 :            : 
    1386         [ #  # ]:          0 :         bRet = ( aDlg.Execute() == RET_OK );
    1387         [ #  # ]:          0 :         if ( bRet )
    1388                 :            :         {
    1389 [ #  # ][ #  # ]:          0 :             m_sName = aDlg.getName();
                 [ #  # ]
    1390         [ #  # ]:          0 :             if ( editingView() )
    1391                 :            :             {
    1392 [ #  # ][ #  # ]:          0 :                 m_sUpdateCatalogName    = aDlg.getCatalog();
                 [ #  # ]
    1393 [ #  # ][ #  # ]:          0 :                 m_sUpdateSchemaName     = aDlg.getSchema();
                 [ #  # ]
    1394                 :            :             }
    1395 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
    1396                 :            :     }
    1397                 :          0 :     return bRet;
    1398                 :            : }
    1399                 :            : // -----------------------------------------------------------------------------
    1400                 :          0 : bool OQueryController::doSaveAsDoc(sal_Bool _bSaveAs)
    1401                 :            : {
    1402                 :            :     OSL_ENSURE(isEditable(),"Slot ID_BROWSER_SAVEDOC should not be enabled!");
    1403 [ #  # ][ #  # ]:          0 :     if ( !editingCommand() && !haveDataSource() )
         [ #  # ][ #  # ]
    1404                 :            :     {
    1405 [ #  # ][ #  # ]:          0 :         String aMessage(ModuleRes(STR_DATASOURCE_DELETED));
    1406 [ #  # ][ #  # ]:          0 :         OSQLWarningBox( getView(), aMessage ).Execute();
                 [ #  # ]
    1407         [ #  # ]:          0 :         return false;
    1408                 :            :     }
    1409                 :            : 
    1410         [ #  # ]:          0 :     Reference< XNameAccess > xElements = getObjectContainer();
    1411         [ #  # ]:          0 :     if ( !xElements.is() )
    1412                 :          0 :         return false;
    1413                 :            : 
    1414 [ #  # ][ #  # ]:          0 :     if ( !getContainer()->checkStatement() )
    1415                 :          0 :         return false;
    1416                 :            : 
    1417         [ #  # ]:          0 :     ::rtl::OUString sTranslatedStmt = translateStatement();
    1418         [ #  # ]:          0 :     if ( editingCommand() )
    1419                 :            :     {
    1420         [ #  # ]:          0 :         setModified( sal_False );
    1421                 :            :         // this is all we need to do here. translateStatement implicitly set our m_sStatement, and
    1422                 :            :         // notified it, and that's all
    1423                 :          0 :         return true;
    1424                 :            :     }
    1425                 :            : 
    1426         [ #  # ]:          0 :     if ( sTranslatedStmt.isEmpty() )
    1427                 :          0 :         return false;
    1428                 :            : 
    1429                 :            :     // first we need a name for our query so ask the user
    1430                 :            :     // did we get a name
    1431                 :          0 :     ::rtl::OUString sOriginalName( m_sName );
    1432 [ #  # ][ #  # ]:          0 :     if ( !askForNewName( xElements, _bSaveAs ) || m_sName.isEmpty() )
         [ #  # ][ #  # ]
    1433                 :          0 :         return false;
    1434                 :            : 
    1435         [ #  # ]:          0 :     SQLExceptionInfo aInfo;
    1436                 :          0 :     bool bSuccess = false;
    1437                 :          0 :     bool bNew = false;
    1438                 :            :     try
    1439                 :            :     {
    1440                 :            :         bNew = ( _bSaveAs )
    1441 [ #  # ][ #  # ]:          0 :             || ( !xElements->hasByName( m_sName ) );
         [ #  # ][ #  # ]
    1442                 :            : 
    1443                 :          0 :         Reference<XPropertySet> xQuery;
    1444         [ #  # ]:          0 :         if ( bNew ) // just to make sure the query already exists
    1445                 :            :         {
    1446                 :            :             // drop the query, in case it already exists
    1447 [ #  # ][ #  # ]:          0 :             if ( xElements->hasByName( m_sName ) )
                 [ #  # ]
    1448                 :            :             {
    1449         [ #  # ]:          0 :                 Reference< XDrop > xNameCont( xElements, UNO_QUERY );
    1450         [ #  # ]:          0 :                 if ( xNameCont.is() )
    1451 [ #  # ][ #  # ]:          0 :                     xNameCont->dropByName( m_sName );
    1452                 :            :                 else
    1453                 :            :                 {
    1454         [ #  # ]:          0 :                     Reference< XNameContainer > xCont( xElements, UNO_QUERY );
    1455         [ #  # ]:          0 :                     if ( xCont.is() )
    1456 [ #  # ][ #  # ]:          0 :                         xCont->removeByName( m_sName );
    1457                 :          0 :                 }
    1458                 :            :             }
    1459                 :            : 
    1460                 :            :             // create a new (empty, uninitialized) query resp. view
    1461         [ #  # ]:          0 :             Reference< XDataDescriptorFactory > xFact( xElements, UNO_QUERY );
    1462         [ #  # ]:          0 :             if ( xFact.is() )
    1463                 :            :             {
    1464 [ #  # ][ #  # ]:          0 :                 xQuery = xFact->createDataDescriptor();
                 [ #  # ]
    1465                 :            :                 // to set the name is only allowed when the query is new
    1466 [ #  # ][ #  # ]:          0 :                 xQuery->setPropertyValue( PROPERTY_NAME, makeAny( m_sName ) );
         [ #  # ][ #  # ]
    1467                 :            :             }
    1468                 :            :             else
    1469                 :            :             {
    1470         [ #  # ]:          0 :                 Reference< XSingleServiceFactory > xSingleFac( xElements, UNO_QUERY );
    1471         [ #  # ]:          0 :                 if ( xSingleFac.is() )
    1472 [ #  # ][ #  # ]:          0 :                     xQuery = xQuery.query( xSingleFac->createInstance() );
         [ #  # ][ #  # ]
    1473                 :          0 :             }
    1474                 :            :         }
    1475                 :            :         else
    1476                 :            :         {
    1477 [ #  # ][ #  # ]:          0 :             xElements->getByName( m_sName ) >>= xQuery;
                 [ #  # ]
    1478                 :            :         }
    1479         [ #  # ]:          0 :         if ( !xQuery.is() )
    1480         [ #  # ]:          0 :             throw RuntimeException();
    1481                 :            : 
    1482                 :            :         // the new commands
    1483 [ #  # ][ #  # ]:          0 :         if ( editingView() && !bNew )
                 [ #  # ]
    1484                 :            :         {
    1485                 :            :             OSL_ENSURE( xQuery == m_xAlterView, "OQueryController::doSaveAsDoc: already have another alterable view ...!?" );
    1486         [ #  # ]:          0 :             m_xAlterView.set( xQuery, UNO_QUERY_THROW );
    1487 [ #  # ][ #  # ]:          0 :             m_xAlterView->alterCommand( sTranslatedStmt );
    1488                 :            :         }
    1489                 :            :         else
    1490                 :            :         {   // we're creating a query, or a *new* view
    1491 [ #  # ][ #  # ]:          0 :             xQuery->setPropertyValue( PROPERTY_COMMAND, makeAny( sTranslatedStmt ) );
         [ #  # ][ #  # ]
    1492                 :            : 
    1493         [ #  # ]:          0 :             if ( editingView() )
    1494                 :            :             {
    1495 [ #  # ][ #  # ]:          0 :                 xQuery->setPropertyValue( PROPERTY_CATALOGNAME, makeAny( m_sUpdateCatalogName ) );
         [ #  # ][ #  # ]
    1496 [ #  # ][ #  # ]:          0 :                 xQuery->setPropertyValue( PROPERTY_SCHEMANAME, makeAny( m_sUpdateSchemaName ) );
         [ #  # ][ #  # ]
    1497                 :            :             }
    1498                 :            : 
    1499         [ #  # ]:          0 :             if ( editingQuery() )
    1500                 :            :             {
    1501 [ #  # ][ #  # ]:          0 :                 xQuery->setPropertyValue( PROPERTY_UPDATE_TABLENAME, makeAny( m_sUpdateTableName ) );
         [ #  # ][ #  # ]
    1502 [ #  # ][ #  # ]:          0 :                 xQuery->setPropertyValue( PROPERTY_ESCAPE_PROCESSING,::cppu::bool2any( m_bEscapeProcessing ) );
         [ #  # ][ #  # ]
    1503                 :            : 
    1504 [ #  # ][ #  # ]:          0 :                 xQuery->setPropertyValue( PROPERTY_LAYOUTINFORMATION, getViewData() );
         [ #  # ][ #  # ]
    1505                 :            :             }
    1506                 :            :         }
    1507                 :            : 
    1508         [ #  # ]:          0 :         if ( bNew )
    1509                 :            :         {
    1510         [ #  # ]:          0 :             Reference< XAppend > xAppend( xElements, UNO_QUERY );
    1511         [ #  # ]:          0 :             if ( xAppend.is() )
    1512                 :            :             {
    1513 [ #  # ][ #  # ]:          0 :                 xAppend->appendByDescriptor( xQuery );
    1514                 :            :             }
    1515                 :            :             else
    1516                 :            :             {
    1517         [ #  # ]:          0 :                 Reference< XNameContainer > xCont( xElements, UNO_QUERY );
    1518         [ #  # ]:          0 :                 if ( xCont.is() )
    1519 [ #  # ][ #  # ]:          0 :                     xCont->insertByName( m_sName, makeAny( xQuery ) );
                 [ #  # ]
    1520                 :            :             }
    1521                 :            : 
    1522         [ #  # ]:          0 :             if ( editingView() )
    1523                 :            :             {
    1524                 :          0 :                 Reference< XPropertySet > xViewProps;
    1525 [ #  # ][ #  # ]:          0 :                 if ( xElements->hasByName( m_sName ) )
                 [ #  # ]
    1526 [ #  # ][ #  # ]:          0 :                     xViewProps.set( xElements->getByName( m_sName ), UNO_QUERY );
                 [ #  # ]
    1527                 :            : 
    1528         [ #  # ]:          0 :                 if ( !xViewProps.is() ) // correct name and try again
    1529 [ #  # ][ #  # ]:          0 :                     m_sName = ::dbtools::composeTableName( getMetaData(), xQuery, ::dbtools::eInDataManipulation, false, false, false );
    1530                 :            : 
    1531                 :            :                 OSL_ENSURE( xElements->hasByName( m_sName ), "OQueryController::doSaveAsDoc: newly creaed view does not exist!" );
    1532                 :            : 
    1533 [ #  # ][ #  # ]:          0 :                 if ( xElements->hasByName( m_sName ) )
                 [ #  # ]
    1534 [ #  # ][ #  # ]:          0 :                     m_xAlterView.set( xElements->getByName( m_sName ), UNO_QUERY );
                 [ #  # ]
    1535                 :            : 
    1536                 :            :                 // now check if our datasource has set a tablefilter and if so, append the new table name to it
    1537 [ #  # ][ #  # ]:          0 :                 ::dbaui::appendToFilter( getConnection(), m_sName, getORB(), getView() );
                 [ #  # ]
    1538                 :            :             }
    1539 [ #  # ][ #  # ]:          0 :             Reference< XTitleChangeListener> xEventListener(impl_getTitleHelper_throw(),UNO_QUERY);
    1540         [ #  # ]:          0 :             if ( xEventListener.is() )
    1541                 :            :             {
    1542         [ #  # ]:          0 :                 TitleChangedEvent aEvent;
    1543 [ #  # ][ #  # ]:          0 :                 xEventListener->titleChanged(aEvent);
                 [ #  # ]
    1544                 :            :             }
    1545         [ #  # ]:          0 :             releaseNumberForComponent();
    1546                 :            :         }
    1547                 :            : 
    1548         [ #  # ]:          0 :         setModified( sal_False );
    1549                 :          0 :         bSuccess = true;
    1550                 :            : 
    1551                 :            :     }
    1552   [ #  #  #  #  :          0 :     catch(const SQLException&)
                      # ]
    1553                 :            :     {
    1554         [ #  # ]:          0 :         if ( !bNew )
    1555                 :          0 :             m_sName = sOriginalName;
    1556   [ #  #  #  #  :          0 :         aInfo = SQLExceptionInfo( ::cppu::getCaughtException() );
             #  #  #  # ]
    1557                 :            :     }
    1558         [ #  # ]:          0 :     catch(const Exception&)
    1559                 :            :     {
    1560         [ #  # ]:          0 :         if ( !bNew )
    1561                 :          0 :             m_sName = sOriginalName;
    1562                 :            :         DBG_UNHANDLED_EXCEPTION();
    1563                 :            :     }
    1564                 :            : 
    1565         [ #  # ]:          0 :     showError( aInfo );
    1566                 :            : 
    1567                 :            :     // update the title of our window
    1568                 :            :     //updateTitle();
    1569                 :            : 
    1570                 :            :     // if we successfully saved a view we were creating, then close the designer
    1571 [ #  # ][ #  # ]:          0 :     if ( bSuccess && editingView() && !m_xAlterView.is() )
         [ #  # ][ #  # ]
    1572                 :            :     {
    1573         [ #  # ]:          0 :         closeTask();
    1574                 :            :     }
    1575                 :            : 
    1576 [ #  # ][ #  # ]:          0 :     if ( bSuccess && editingView() )
                 [ #  # ]
    1577 [ #  # ][ #  # ]:          0 :         InvalidateFeature( ID_BROWSER_EDITDOC );
    1578                 :            : 
    1579         [ #  # ]:          0 :     return bSuccess;
    1580                 :            : }
    1581                 :            : //-----------------------------------------------------------------------------
    1582                 :            : 
    1583                 :            : namespace {
    1584                 :          0 : struct CommentStrip
    1585                 :            : {
    1586                 :            :     ::rtl::OUString maComment;
    1587                 :            :     bool            mbLastOnLine;
    1588                 :          0 :     CommentStrip( const ::rtl::OUString& rComment, bool bLastOnLine )
    1589                 :          0 :         : maComment( rComment), mbLastOnLine( bLastOnLine) {}
    1590                 :            : };
    1591                 :            : }
    1592                 :            : 
    1593                 :            : /** Obtain all comments in a query.
    1594                 :            : 
    1595                 :            :     See also delComment() implementation for OSQLParser::parseTree().
    1596                 :            :  */
    1597                 :          0 : static ::std::vector< CommentStrip > getComment( const ::rtl::OUString& rQuery )
    1598                 :            : {
    1599         [ #  # ]:          0 :     ::std::vector< CommentStrip > aRet;
    1600                 :            :     // First a quick search if there is any "--" or "//" or "/*", if not then 
    1601                 :            :     // the whole copying loop is pointless.
    1602         [ #  # ]:          0 :     if (rQuery.indexOfAsciiL( "--", 2, 0) < 0 && rQuery.indexOfAsciiL( "//", 2, 0) < 0 &&
           [ #  #  #  # ]
                 [ #  # ]
    1603                 :          0 :             rQuery.indexOfAsciiL( "/*", 2, 0) < 0)
    1604                 :            :         return aRet;
    1605                 :            : 
    1606                 :          0 :     const sal_Unicode* pCopy = rQuery.getStr();
    1607                 :          0 :     const sal_Int32 nQueryLen = rQuery.getLength();
    1608                 :          0 :     bool bIsText1  = false;     // "text"
    1609                 :          0 :     bool bIsText2  = false;     // 'text'
    1610                 :          0 :     bool bComment2 = false;     // /* comment */
    1611                 :          0 :     bool bComment  = false;     // -- or // comment
    1612                 :          0 :     ::rtl::OUStringBuffer aBuf;
    1613         [ #  # ]:          0 :     for (sal_Int32 i=0; i < nQueryLen; ++i)
    1614                 :            :     {
    1615         [ #  # ]:          0 :         if (bComment2)
    1616                 :            :         {
    1617         [ #  # ]:          0 :             aBuf.append( &pCopy[i], 1);
    1618         [ #  # ]:          0 :             if ((i+1) < nQueryLen)
    1619                 :            :             {
    1620 [ #  # ][ #  # ]:          0 :                 if (pCopy[i]=='*' && pCopy[i+1]=='/')
    1621                 :            :                 {
    1622                 :          0 :                     bComment2 = false;
    1623         [ #  # ]:          0 :                     aBuf.append( &pCopy[++i], 1);
    1624 [ #  # ][ #  # ]:          0 :                     aRet.push_back( CommentStrip( aBuf.makeStringAndClear(), false));
    1625                 :            :                 }
    1626                 :            :             }
    1627                 :            :             else
    1628                 :            :             {
    1629                 :            :                 // comment can't close anymore, actually an error, but..
    1630 [ #  # ][ #  # ]:          0 :                 aRet.push_back( CommentStrip( aBuf.makeStringAndClear(), false));
    1631                 :            :             }
    1632                 :          0 :             continue;
    1633                 :            :         }
    1634 [ #  # ][ #  # ]:          0 :         if (pCopy[i] == '\n' || i == nQueryLen-1)
    1635                 :            :         {
    1636         [ #  # ]:          0 :             if (bComment)
    1637                 :            :             {
    1638 [ #  # ][ #  # ]:          0 :                 if (i == nQueryLen-1 && pCopy[i] != '\n')
    1639         [ #  # ]:          0 :                     aBuf.append( &pCopy[i], 1);
    1640 [ #  # ][ #  # ]:          0 :                 aRet.push_back( CommentStrip( aBuf.makeStringAndClear(), true));
    1641                 :          0 :                 bComment = false;
    1642                 :            :             }
    1643         [ #  # ]:          0 :             else if (!aRet.empty())
    1644         [ #  # ]:          0 :                 aRet.back().mbLastOnLine = true;
    1645                 :            :         }
    1646         [ #  # ]:          0 :         else if (!bComment)
    1647                 :            :         {
    1648 [ #  # ][ #  # ]:          0 :             if (pCopy[i] == '\"' && !bIsText2)
    1649                 :          0 :                 bIsText1 = !bIsText1;
    1650 [ #  # ][ #  # ]:          0 :             else if (pCopy[i] == '\'' && !bIsText1)
    1651                 :          0 :                 bIsText2 = !bIsText2;
    1652 [ #  # ][ #  # ]:          0 :             if (!bIsText1 && !bIsText2 && (i+1) < nQueryLen)
                 [ #  # ]
    1653                 :            :             {
    1654 [ #  # ][ #  # ]:          0 :                 if ((pCopy[i]=='-' && pCopy[i+1]=='-') || (pCopy[i]=='/' && pCopy[i+1]=='/'))
         [ #  # ][ #  # ]
    1655                 :          0 :                     bComment = true;
    1656 [ #  # ][ #  # ]:          0 :                 else if ((pCopy[i]=='/' && pCopy[i+1]=='*'))
    1657                 :          0 :                     bComment2 = true;
    1658                 :            :             }
    1659                 :            :         }
    1660 [ #  # ][ #  # ]:          0 :         if (bComment || bComment2)
    1661         [ #  # ]:          0 :             aBuf.append( &pCopy[i], 1);
    1662                 :            :     }
    1663                 :          0 :     return aRet;
    1664                 :            : }
    1665                 :            : //------------------------------------------------------------------------------
    1666                 :            : 
    1667                 :            : /** Concat/insert comments that were previously obtained with getComment().
    1668                 :            : 
    1669                 :            :     NOTE: The current parser implementation does not preserve newlines, so all 
    1670                 :            :     comments are always appended to the entire query, also inline comments 
    1671                 :            :     that would need positioning anyway that can't be obtained after 
    1672                 :            :     recomposition. This is ugly but at least allows commented queries while 
    1673                 :            :     preserving the comments _somehow_.
    1674                 :            :  */
    1675                 :          0 : static ::rtl::OUString concatComment( const ::rtl::OUString& rQuery, const ::std::vector< CommentStrip >& rComments )
    1676                 :            : {
    1677                 :            :     // No comments => return query.
    1678         [ #  # ]:          0 :     if (rComments.empty())
    1679                 :          0 :         return rQuery;
    1680                 :            : 
    1681                 :          0 :     const sal_Unicode* pBeg = rQuery.getStr();
    1682                 :          0 :     const sal_Int32 nLen = rQuery.getLength();
    1683                 :          0 :     const size_t nComments = rComments.size();
    1684                 :            :     // Obtaining the needed size once should be faster than reallocating.
    1685                 :            :     // Also add a blank or linefeed for each comment.
    1686                 :          0 :     sal_Int32 nBufSize = nLen + nComments;
    1687 [ #  # ][ #  # ]:          0 :     for (::std::vector< CommentStrip >::const_iterator it( rComments.begin()); it != rComments.end(); ++it)
    1688                 :          0 :         nBufSize += (*it).maComment.getLength();
    1689                 :          0 :     ::rtl::OUStringBuffer aBuf( nBufSize );
    1690                 :          0 :     sal_Int32 nIndBeg = 0;
    1691                 :          0 :     sal_Int32 nIndLF = rQuery.indexOf('\n');
    1692                 :          0 :     size_t i = 0;
    1693 [ #  # ][ #  # ]:          0 :     while (nIndLF >= 0 && i < nComments)
                 [ #  # ]
    1694                 :            :     {
    1695         [ #  # ]:          0 :         aBuf.append( pBeg + nIndBeg, nIndLF - nIndBeg);
    1696 [ #  # ][ #  # ]:          0 :         do
                 [ #  # ]
    1697                 :            :         {
    1698         [ #  # ]:          0 :             aBuf.append( rComments[i].maComment);
    1699                 :          0 :         } while (!rComments[i++].mbLastOnLine && i < nComments);
    1700         [ #  # ]:          0 :         aBuf.append( pBeg + nIndLF, 1);     // the LF
    1701                 :          0 :         nIndBeg = nIndLF + 1;
    1702         [ #  # ]:          0 :         nIndLF = (nIndBeg < nLen ? rQuery.indexOf( '\n', nIndBeg) : -1);
    1703                 :            :     }
    1704                 :            :     // Append remainder of query.
    1705         [ #  # ]:          0 :     if (nIndBeg < nLen)
    1706         [ #  # ]:          0 :         aBuf.append( pBeg + nIndBeg, nLen - nIndBeg);
    1707                 :            :     // Append all remaining comments, preserve lines.
    1708                 :          0 :     bool bNewLine = false;
    1709         [ #  # ]:          0 :     for ( ; i < nComments; ++i)
    1710                 :            :     {
    1711         [ #  # ]:          0 :         if (!bNewLine)
    1712         [ #  # ]:          0 :             aBuf.append( sal_Unicode(' '));
    1713         [ #  # ]:          0 :         aBuf.append( rComments[i].maComment);
    1714         [ #  # ]:          0 :         if (rComments[i].mbLastOnLine)
    1715                 :            :         {
    1716         [ #  # ]:          0 :             aBuf.append( sal_Unicode('\n'));
    1717                 :          0 :             bNewLine = true;
    1718                 :            :         }
    1719                 :            :         else
    1720                 :          0 :             bNewLine = false;
    1721                 :            :     }
    1722         [ #  # ]:          0 :     return aBuf.makeStringAndClear();
    1723                 :            : }
    1724                 :            : // -----------------------------------------------------------------------------
    1725                 :          0 : ::rtl::OUString OQueryController::translateStatement( bool _bFireStatementChange )
    1726                 :            : {
    1727                 :            :     // now set the properties
    1728         [ #  # ]:          0 :     setStatement_fireEvent( getContainer()->getStatement(), _bFireStatementChange );
    1729                 :          0 :     ::rtl::OUString sTranslatedStmt;
    1730 [ #  # ][ #  # ]:          0 :     if(!m_sStatement.isEmpty() && m_xComposer.is() && m_bEscapeProcessing)
         [ #  # ][ #  # ]
    1731                 :            :     {
    1732                 :            :         try
    1733                 :            :         {
    1734                 :          0 :             ::rtl::OUString aErrorMsg;
    1735                 :            : 
    1736         [ #  # ]:          0 :             ::std::vector< CommentStrip > aComments = getComment( m_sStatement);
    1737                 :            : 
    1738         [ #  # ]:          0 :             ::connectivity::OSQLParseNode* pNode = m_aSqlParser.parseTree( aErrorMsg, m_sStatement, m_bGraphicalDesign );
    1739         [ #  # ]:          0 :             if(pNode)
    1740                 :            :             {
    1741 [ #  # ][ #  # ]:          0 :                 pNode->parseNodeToStr( sTranslatedStmt, getConnection() );
    1742 [ #  # ][ #  # ]:          0 :                 delete pNode;
    1743                 :            :             }
    1744                 :            : 
    1745 [ #  # ][ #  # ]:          0 :             m_xComposer->setQuery(sTranslatedStmt);
    1746 [ #  # ][ #  # ]:          0 :             sTranslatedStmt = m_xComposer->getComposedQuery();
    1747         [ #  # ]:          0 :             sTranslatedStmt = concatComment( sTranslatedStmt, aComments);
    1748                 :            :         }
    1749   [ #  #  #  # ]:          0 :         catch(const SQLException& e)
    1750                 :            :         {
    1751         [ #  # ]:          0 :             ::dbtools::SQLExceptionInfo aInfo(e);
    1752         [ #  # ]:          0 :             showError(aInfo);
    1753                 :            :             // an error occurred so we clear the statement
    1754         [ #  # ]:          0 :             sTranslatedStmt = ::rtl::OUString();
    1755                 :            :         }
    1756                 :            :     }
    1757         [ #  # ]:          0 :     else if(m_sStatement.isEmpty())
    1758                 :            :     {
    1759         [ #  # ]:          0 :         ModuleRes aModuleRes(STR_QRY_NOSELECT);
    1760         [ #  # ]:          0 :         String sTmpStr(aModuleRes);
    1761         [ #  # ]:          0 :         ::rtl::OUString sError(sTmpStr);
    1762 [ #  # ][ #  # ]:          0 :         showError(SQLException(sError,NULL,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000") ),1000,Any()));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1763                 :            :     }
    1764                 :            :     else
    1765                 :          0 :         sTranslatedStmt = m_sStatement;
    1766                 :            : 
    1767                 :          0 :     return sTranslatedStmt;
    1768                 :            : }
    1769                 :            : // -----------------------------------------------------------------------------
    1770                 :          0 : short OQueryController::saveModified()
    1771                 :            : {
    1772         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
    1773 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard( getMutex() );
    1774                 :          0 :     short nRet = RET_YES;
    1775 [ #  # ][ #  # ]:          0 :     if ( !isConnected() || !isModified() )
         [ #  # ][ #  # ]
                 [ #  # ]
    1776                 :          0 :         return nRet;
    1777                 :            : 
    1778   [ #  #  #  #  :          0 :     if  (  !m_bGraphicalDesign
           #  # ][ #  # ]
    1779                 :          0 :         || (  !m_vTableFieldDesc.empty()
    1780                 :          0 :            && !m_vTableData.empty()
    1781                 :            :            )
    1782                 :            :         )
    1783                 :            :     {
    1784         [ #  # ]:          0 :         String sMessageText( lcl_getObjectResourceString( STR_QUERY_SAVEMODIFIED, m_nCommandType ) );
    1785         [ #  # ]:          0 :         QueryBox aQry( getView(), WB_YES_NO_CANCEL | WB_DEF_YES, sMessageText );
    1786                 :            : 
    1787         [ #  # ]:          0 :         nRet = aQry.Execute();
    1788 [ #  # ][ #  # ]:          0 :         if  (   ( nRet == RET_YES )
                 [ #  # ]
    1789         [ #  # ]:          0 :             &&  !doSaveAsDoc( sal_False )
    1790                 :            :             )
    1791                 :            :         {
    1792                 :          0 :             nRet = RET_CANCEL;
    1793 [ #  # ][ #  # ]:          0 :         }
    1794                 :            :     }
    1795 [ #  # ][ #  # ]:          0 :     return nRet;
    1796                 :            : }
    1797                 :            : // -----------------------------------------------------------------------------
    1798                 :          0 : void OQueryController::impl_reset( const bool i_bForceCurrentControllerSettings )
    1799                 :            : {
    1800                 :          0 :     bool bValid = false;
    1801                 :            : 
    1802         [ #  # ]:          0 :     Sequence< PropertyValue > aLayoutInformation;
    1803                 :            :     // get command from the query if a query name was supplied
    1804 [ #  # ][ #  # ]:          0 :     if ( !i_bForceCurrentControllerSettings && !editingCommand() )
                 [ #  # ]
    1805                 :            :     {
    1806         [ #  # ]:          0 :         if ( !m_sName.isEmpty() )
    1807                 :            :         {
    1808         [ #  # ]:          0 :             Reference< XNameAccess > xQueries = getObjectContainer();
    1809         [ #  # ]:          0 :             if ( xQueries.is() )
    1810                 :            :             {
    1811                 :          0 :                 Reference< XPropertySet > xProp;
    1812 [ #  # ][ #  # ]:          0 :                 if( xQueries->hasByName( m_sName ) && ( xQueries->getByName( m_sName ) >>= xProp ) && xProp.is() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
    1813                 :            :                 {
    1814                 :          0 :                     ::rtl::OUString sNewStatement;
    1815 [ #  # ][ #  # ]:          0 :                     xProp->getPropertyValue( PROPERTY_COMMAND ) >>= sNewStatement;
                 [ #  # ]
    1816         [ #  # ]:          0 :                     setStatement_fireEvent( sNewStatement );
    1817                 :            : 
    1818                 :          0 :                     sal_Bool bNewEscapeProcessing( sal_True );
    1819         [ #  # ]:          0 :                     if ( editingQuery() )
    1820                 :            :                     {
    1821 [ #  # ][ #  # ]:          0 :                         xProp->getPropertyValue( PROPERTY_ESCAPE_PROCESSING ) >>= bNewEscapeProcessing;
                 [ #  # ]
    1822         [ #  # ]:          0 :                         setEscapeProcessing_fireEvent( bNewEscapeProcessing );
    1823                 :            :                     }
    1824                 :            : 
    1825 [ #  # ][ #  # ]:          0 :                     m_bGraphicalDesign = m_bGraphicalDesign && m_bEscapeProcessing;
    1826                 :          0 :                     bValid = true;
    1827                 :            : 
    1828                 :            :                     try
    1829                 :            :                     {
    1830         [ #  # ]:          0 :                         if ( editingQuery() )
    1831 [ #  # ][ #  # ]:          0 :                             xProp->getPropertyValue( PROPERTY_LAYOUTINFORMATION ) >>= aLayoutInformation;
         [ #  # ][ #  # ]
                 [ #  # ]
    1832                 :            :                     }
    1833         [ #  # ]:          0 :                     catch( const Exception& )
    1834                 :            :                     {
    1835                 :            :                         OSL_FAIL( "OQueryController::impl_reset: could not retrieve the layout information from the query!" );
    1836                 :          0 :                     }
    1837                 :          0 :                 }
    1838                 :          0 :             }
    1839                 :            :         }
    1840                 :            :     }
    1841                 :            :     else
    1842                 :            :     {
    1843                 :          0 :         bValid = true;
    1844                 :            :         // assume that we got all necessary information during initialization
    1845                 :            :     }
    1846                 :            : 
    1847         [ #  # ]:          0 :     if ( bValid )
    1848                 :            :     {
    1849                 :            :         // load the layoutInformation
    1850         [ #  # ]:          0 :         if ( aLayoutInformation.getLength() )
    1851                 :            :         {
    1852                 :            :             try
    1853                 :            :             {
    1854 [ #  # ][ #  # ]:          0 :                 loadViewSettings( aLayoutInformation );
         [ #  # ][ #  # ]
    1855                 :            :             }
    1856         [ #  # ]:          0 :             catch( const Exception& )
    1857                 :            :             {
    1858                 :            :                 DBG_UNHANDLED_EXCEPTION();
    1859                 :            :             }
    1860                 :            :         }
    1861                 :            : 
    1862         [ #  # ]:          0 :         if ( !m_sStatement.isEmpty() )
    1863                 :            :         {
    1864         [ #  # ]:          0 :             setQueryComposer();
    1865                 :            : 
    1866                 :          0 :             bool bError( false );
    1867                 :            : 
    1868         [ #  # ]:          0 :             if ( !m_pSqlIterator )
    1869                 :            :             {
    1870                 :          0 :                 bError = true;
    1871                 :            :             }
    1872         [ #  # ]:          0 :             else if ( m_bEscapeProcessing )
    1873                 :            :             {
    1874                 :          0 :                 ::rtl::OUString aErrorMsg;
    1875                 :            :                 ::std::auto_ptr< ::connectivity::OSQLParseNode > pNode(
    1876         [ #  # ]:          0 :                     m_aSqlParser.parseTree( aErrorMsg, m_sStatement, m_bGraphicalDesign ) );
    1877                 :            : 
    1878         [ #  # ]:          0 :                 if ( pNode.get() )
    1879                 :            :                 {
    1880 [ #  # ][ #  # ]:          0 :                     delete m_pSqlIterator->getParseTree();
    1881         [ #  # ]:          0 :                     m_pSqlIterator->setParseTree( pNode.release() );
    1882         [ #  # ]:          0 :                     m_pSqlIterator->traverseAll();
    1883         [ #  # ]:          0 :                     if ( m_pSqlIterator->hasErrors() )
    1884                 :            :                     {
    1885 [ #  # ][ #  # ]:          0 :                         if ( !i_bForceCurrentControllerSettings && m_bGraphicalDesign && !editingView() )
         [ #  # ][ #  # ]
    1886                 :            :                         {
    1887 [ #  # ][ #  # ]:          0 :                             impl_showAutoSQLViewError( makeAny( m_pSqlIterator->getErrors() ) );
    1888                 :            :                         }
    1889                 :          0 :                         bError = true;
    1890                 :            :                     }
    1891                 :            :                 }
    1892                 :            :                 else
    1893                 :            :                 {
    1894 [ #  # ][ #  # ]:          0 :                     if ( !i_bForceCurrentControllerSettings && !editingView() )
                 [ #  # ]
    1895                 :            :                     {
    1896 [ #  # ][ #  # ]:          0 :                         String aTitle(ModuleRes(STR_SVT_SQL_SYNTAX_ERROR));
    1897 [ #  # ][ #  # ]:          0 :                         OSQLMessageBox aDlg(getView(),aTitle,aErrorMsg);
                 [ #  # ]
    1898 [ #  # ][ #  # ]:          0 :                         aDlg.Execute();
                 [ #  # ]
    1899                 :            :                     }
    1900                 :          0 :                     bError = true;
    1901         [ #  # ]:          0 :                 }
    1902                 :            :             }
    1903                 :            : 
    1904         [ #  # ]:          0 :             if ( bError )
    1905                 :            :             {
    1906                 :          0 :                 m_bGraphicalDesign = sal_False;
    1907         [ #  # ]:          0 :                 if ( editingView() )
    1908                 :            :                     // if we're editing a view whose statement could not be parsed, default to "no escape processing"
    1909         [ #  # ]:          0 :                     setEscapeProcessing_fireEvent( sal_False );
    1910                 :            :             }
    1911                 :            :         }
    1912                 :            :     }
    1913                 :            : 
    1914         [ #  # ]:          0 :     if(!m_pSqlIterator)
    1915         [ #  # ]:          0 :         setQueryComposer();
    1916                 :            :     OSL_ENSURE(m_pSqlIterator,"No SQLIterator set!");
    1917                 :            : 
    1918 [ #  # ][ #  # ]:          0 :     getContainer()->setNoneVisbleRow(m_nVisibleRows);
    1919                 :          0 : }
    1920                 :            : 
    1921                 :            : // -----------------------------------------------------------------------------
    1922                 :          0 : void OQueryController::reset()
    1923                 :            : {
    1924                 :          0 :     impl_reset();
    1925                 :          0 :     getContainer()->reset( NULL );
    1926                 :          0 :     ClearUndoManager();
    1927                 :          0 : }
    1928                 :            : 
    1929                 :            : // -----------------------------------------------------------------------------
    1930                 :          0 : void OQueryController::setStatement_fireEvent( const ::rtl::OUString& _rNewStatement, bool _bFireStatementChange )
    1931                 :            : {
    1932         [ #  # ]:          0 :     Any aOldValue = makeAny( m_sStatement );
    1933                 :          0 :     m_sStatement = _rNewStatement;
    1934         [ #  # ]:          0 :     Any aNewValue = makeAny( m_sStatement );
    1935                 :            : 
    1936                 :          0 :     sal_Int32 nHandle = PROPERTY_ID_ACTIVECOMMAND;
    1937         [ #  # ]:          0 :     if ( _bFireStatementChange )
    1938         [ #  # ]:          0 :         fire( &nHandle, &aNewValue, &aOldValue, 1, sal_False );
    1939                 :          0 : }
    1940                 :            : 
    1941                 :            : // -----------------------------------------------------------------------------
    1942                 :          0 : void OQueryController::setEscapeProcessing_fireEvent( const sal_Bool _bEscapeProcessing )
    1943                 :            : {
    1944         [ #  # ]:          0 :     if ( _bEscapeProcessing == m_bEscapeProcessing )
    1945                 :          0 :         return;
    1946                 :            : 
    1947         [ #  # ]:          0 :     Any aOldValue = makeAny( m_bEscapeProcessing );
    1948                 :          0 :     m_bEscapeProcessing = _bEscapeProcessing;
    1949         [ #  # ]:          0 :     Any aNewValue = makeAny( m_bEscapeProcessing );
    1950                 :            : 
    1951                 :          0 :     sal_Int32 nHandle = PROPERTY_ID_ESCAPE_PROCESSING;
    1952         [ #  # ]:          0 :     fire( &nHandle, &aNewValue, &aOldValue, 1, sal_False );
    1953                 :            : }
    1954                 :            : 
    1955                 :            : // -----------------------------------------------------------------------------
    1956                 :          0 : IMPL_LINK( OQueryController, OnExecuteAddTable, void*, /*pNotInterestedIn*/ )
    1957                 :            : {
    1958         [ #  # ]:          0 :     Execute( ID_BROWSER_ADDTABLE,Sequence<PropertyValue>() );
    1959                 :          0 :     return 0L;
    1960                 :            : }
    1961                 :            : 
    1962                 :            : // -----------------------------------------------------------------------------
    1963                 :          0 : bool OQueryController::allowViews() const
    1964                 :            : {
    1965                 :          0 :     return true;
    1966                 :            : }
    1967                 :            : 
    1968                 :            : // -----------------------------------------------------------------------------
    1969                 :          0 : bool OQueryController::allowQueries() const
    1970                 :            : {
    1971                 :            :     OSL_ENSURE( getSdbMetaData().isConnected(), "OQueryController::allowQueries: illegal call!" );
    1972         [ #  # ]:          0 :     if ( !getSdbMetaData().supportsSubqueriesInFrom() )
    1973                 :          0 :         return false;
    1974                 :            : 
    1975                 :          0 :     const NamedValueCollection& rArguments( getInitParams() );
    1976 [ #  # ][ #  # ]:          0 :     sal_Int32 nCommandType = rArguments.getOrDefault( (::rtl::OUString)PROPERTY_COMMAND_TYPE, (sal_Int32)CommandType::QUERY );
    1977                 :          0 :     sal_Bool bCreatingView = ( nCommandType == CommandType::TABLE );
    1978                 :          0 :     return !bCreatingView;
    1979                 :            : }
    1980                 :            : 
    1981                 :            : // -----------------------------------------------------------------------------
    1982                 :          0 : Any SAL_CALL OQueryController::getViewData() throw( RuntimeException )
    1983                 :            : {
    1984 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard( getMutex() );
    1985                 :            : 
    1986         [ #  # ]:          0 :     getContainer()->SaveUIConfig();
    1987                 :            : 
    1988         [ #  # ]:          0 :     ::comphelper::NamedValueCollection aViewSettings;
    1989         [ #  # ]:          0 :     saveViewSettings( aViewSettings, false );
    1990                 :            : 
    1991 [ #  # ][ #  # ]:          0 :     return makeAny( aViewSettings.getPropertyValues() );
         [ #  # ][ #  # ]
                 [ #  # ]
    1992                 :            : }
    1993                 :            : // -----------------------------------------------------------------------------
    1994                 :          0 : void SAL_CALL OQueryController::restoreViewData(const Any& /*Data*/) throw( RuntimeException )
    1995                 :            : {
    1996                 :            :     // TODO
    1997                 :          0 : }
    1998                 :            : 
    1999                 :            : // -----------------------------------------------------------------------------
    2000                 :            : } // namespace dbaui
    2001                 :            : // -----------------------------------------------------------------------------
    2002                 :            : 
    2003                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10