LCOV - code coverage report
Current view: top level - include/svx - fmtools.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 15 25 60.0 %
Date: 2015-06-13 12:38:46 Functions: 14 26 53.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #ifndef INCLUDED_SVX_FMTOOLS_HXX
      20             : #define INCLUDED_SVX_FMTOOLS_HXX
      21             : 
      22             : #include <svx/svxdllapi.h>
      23             : 
      24             : #include <com/sun/star/sdb/SQLContext.hpp>
      25             : #include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
      26             : #include <com/sun/star/sdbcx/Privilege.hpp>
      27             : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
      28             : #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
      29             : #include <com/sun/star/sdbc/XRowSet.hpp>
      30             : #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
      31             : #include <com/sun/star/sdb/XColumn.hpp>
      32             : #include <com/sun/star/sdb/XColumnUpdate.hpp>
      33             : #include <com/sun/star/sdb/SQLErrorEvent.hpp>
      34             : #include <com/sun/star/sdbc/XConnection.hpp>
      35             : #include <com/sun/star/sdbc/XResultSet.hpp>
      36             : #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
      37             : #include <com/sun/star/sdbcx/XRowLocate.hpp>
      38             : #include <com/sun/star/sdbc/XDataSource.hpp>
      39             : #include <com/sun/star/beans/XPropertySet.hpp>
      40             : #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
      41             : #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
      42             : #include <com/sun/star/container/XIndexContainer.hpp>
      43             : #include <com/sun/star/frame/XDispatch.hpp>
      44             : #include <com/sun/star/frame/XStatusListener.hpp>
      45             : #include <com/sun/star/frame/FeatureStateEvent.hpp>
      46             : #include <com/sun/star/frame/XModel.hpp>
      47             : #include <com/sun/star/script/ScriptEventDescriptor.hpp>
      48             : #include <com/sun/star/container/XNameAccess.hpp>
      49             : #include <com/sun/star/container/XEnumeration.hpp>
      50             : #include <com/sun/star/container/XIndexAccess.hpp>
      51             : #include <com/sun/star/awt/XControlModel.hpp>
      52             : #include <com/sun/star/awt/XControl.hpp>
      53             : #include <com/sun/star/awt/FontSlant.hpp>
      54             : #include <com/sun/star/awt/FontDescriptor.hpp>
      55             : #include <com/sun/star/awt/FontUnderline.hpp>
      56             : #include <com/sun/star/awt/FontStrikeout.hpp>
      57             : #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
      58             : #include <com/sun/star/lang/XServiceInfo.hpp>
      59             : #include <com/sun/star/io/XObjectInputStream.hpp>
      60             : #include <com/sun/star/io/XObjectOutputStream.hpp>
      61             : #include <com/sun/star/io/XPersistObject.hpp>
      62             : #include <com/sun/star/util/XNumberFormatter.hpp>
      63             : #include <com/sun/star/util/XNumberFormats.hpp>
      64             : 
      65             : #include <tools/wintypes.hxx>
      66             : #include <cppuhelper/weakref.hxx>
      67             : #include <comphelper/uno3.hxx>
      68             : #include <comphelper/stl_types.hxx>
      69             : #include <cppuhelper/implbase1.hxx>
      70             : 
      71             : #include <set>
      72             : 
      73             : namespace vcl { class Window; }
      74             : 
      75             : 
      76             : // common types
      77             : 
      78             : // displaying a database exception for the user
      79             : // display info about a simple css::sdbc::SQLException
      80             : void displayException(const css::sdbc::SQLException&, vcl::Window* _pParent = NULL);
      81             : void displayException(const css::sdbc::SQLWarning&, vcl::Window* _pParent = NULL);
      82             : SVX_DLLPUBLIC void displayException(const css::sdb::SQLContext&, vcl::Window* _pParent = NULL);
      83             : void displayException(const css::sdb::SQLErrorEvent&, vcl::Window* _pParent = NULL);
      84             : void displayException(const css::uno::Any&, vcl::Window* _pParent = NULL);
      85             : 
      86             : sal_Int32 getElementPos(const css::uno::Reference< css::container::XIndexAccess>& xCont, const css::uno::Reference< css::uno::XInterface>& xElement);
      87             : 
      88             : SVX_DLLPUBLIC OUString getLabelName(const css::uno::Reference< css::beans::XPropertySet>& xControlModel);
      89             : 
      90             : 
      91             : // = class CursorWrapper - a helper class which works in common with a css::uno::Reference<XDatabaseUpdateCursor>,
      92             : //                          XDatabaseBookmarkCursor and XDatabaseDirectCursor each
      93             : 
      94             : 
      95           2 : class SAL_WARN_UNUSED CursorWrapper
      96             : {
      97             : private:
      98             :     css::uno::Reference< css::uno::XInterface>                m_xGeneric;
      99             :     css::uno::Reference< css::sdbc::XResultSet>               m_xMoveOperations;
     100             :     css::uno::Reference< css::sdbcx::XRowLocate>              m_xBookmarkOperations;
     101             :     css::uno::Reference< css::sdbcx::XColumnsSupplier>        m_xColumnsSupplier;
     102             :     css::uno::Reference< css::beans::XPropertySet>            m_xPropertyAccess;
     103             : 
     104             : public:
     105             :     // Construction/Destruction
     106           0 :     CursorWrapper() { }
     107             :     CursorWrapper(const css::uno::Reference< css::sdbc::XRowSet>& _rxCursor, bool bUseCloned = false);
     108             :     SVX_DLLPUBLIC CursorWrapper(const css::uno::Reference< css::sdbc::XResultSet>& _rxCursor, bool bUseCloned = false);
     109             :         // if bUseCloned == sal_True, the cursor is first doubled over the XCloneable interface (which it must implement)
     110             :         // and then used
     111             : 
     112             :     friend bool operator==(const CursorWrapper& lhs, const CursorWrapper& rhs)
     113             :     {
     114             :         return lhs.m_xGeneric.get() == rhs.m_xGeneric.get();
     115             :     }
     116             : 
     117             :     bool is() const { return m_xMoveOperations.is(); }
     118          17 :     bool Is() const { return m_xMoveOperations.is(); }
     119             : 
     120             :     CursorWrapper* operator ->() { return this; }
     121          32 :     operator const css::uno::Reference< css::uno::XInterface>& () const{ return m_xGeneric; }
     122             : 
     123             :     // 'Conversions'
     124             :     const CursorWrapper& operator=(const css::uno::Reference< css::sdbc::XRowSet>& xCursor);
     125           0 :     operator const css::uno::Reference< css::sdbc::XResultSet>& () const          { return m_xMoveOperations; }
     126             :     operator const css::uno::Reference< css::sdbcx::XRowLocate>& () const         { return m_xBookmarkOperations; }
     127             :     operator const css::uno::Reference< css::sdbcx::XColumnsSupplier>& () const   { return m_xColumnsSupplier; }
     128             : 
     129           6 :     const css::uno::Reference< css::beans::XPropertySet >&        getPropertySet() const      { return m_xPropertyAccess; }
     130             :     const css::uno::Reference< css::sdbc::XResultSet >&           getResultSet() const        { return m_xMoveOperations; }
     131             :     const css::uno::Reference< css::sdbcx::XRowLocate >&          getRowLocate() const        { return m_xBookmarkOperations; }
     132             :     const css::uno::Reference< css::sdbcx::XColumnsSupplier >&    getColumnsSupplier() const  { return m_xColumnsSupplier; }
     133             : 
     134             :     // the usual queryInterface
     135             :     css::uno::Any SAL_CALL queryInterface( const css::uno::Type& type) throw ( css::uno::RuntimeException )
     136             :     { return m_xMoveOperations->queryInterface(type); }
     137             : 
     138             :     // css::uno::Reference< css::sdbcx::XRowLocate>
     139          18 :     css::uno::Any getBookmark()
     140             :         throw( css::sdbc::SQLException, css::uno::RuntimeException )
     141          18 :     { return m_xBookmarkOperations->getBookmark(); }
     142           1 :     bool moveToBookmark(const css::uno::Any& bookmark) throw( css::sdbc::SQLException, css::uno::RuntimeException ) { return m_xBookmarkOperations->moveToBookmark(bookmark); }
     143             :     bool moveRelativeToBookmark(const css::uno::Any& bookmark, sal_Int32 rows) throw( css::sdbc::SQLException, css::uno::RuntimeException ) { return m_xBookmarkOperations->moveRelativeToBookmark(bookmark, rows); }
     144             :     sal_Int32 compareBookmarks(const css::uno::Any& lhs, const css::uno::Any& rhs) const throw( css::sdbc::SQLException, css::uno::RuntimeException ) { return m_xBookmarkOperations->compareBookmarks(lhs, rhs); }
     145             :     bool hasOrderedBookmarks() const throw( css::sdbc::SQLException, css::uno::RuntimeException ) { return m_xBookmarkOperations->hasOrderedBookmarks(); }
     146             :     sal_Int32 hashBookmark(const css::uno::Any& bookmark) const throw( css::sdbc::SQLException, css::uno::RuntimeException ) { return m_xBookmarkOperations->hashBookmark(bookmark); }
     147             : 
     148             :     // css::sdbc::XResultSet
     149          18 :     bool isBeforeFirst() const              { return m_xMoveOperations->isBeforeFirst(); }
     150          18 :     bool isAfterLast() const                { return m_xMoveOperations->isAfterLast(); }
     151           0 :     bool isFirst() const                    { return m_xMoveOperations->isFirst(); }
     152           0 :     bool isLast() const                     { return m_xMoveOperations->isLast(); }
     153           0 :     void beforeFirst()                          { m_xMoveOperations->beforeFirst(); }
     154           0 :     bool first()                            { return m_xMoveOperations->first(); }
     155           0 :     bool last()                             { return m_xMoveOperations->last(); }
     156          34 :     sal_Int32 getRow() const                    { return m_xMoveOperations->getRow(); }
     157           1 :     bool absolute(sal_Int32 nPosition)          { return m_xMoveOperations->absolute(nPosition); }
     158          15 :     bool relative(sal_Int32 nCount)             { return m_xMoveOperations->relative(nCount); }
     159           0 :     bool previous()                         { return m_xMoveOperations->previous(); }
     160           0 :     bool next()                             { return m_xMoveOperations->next(); }
     161           0 :     void refreshRow()                       { m_xMoveOperations->refreshRow(); }
     162             :     bool rowUpdated()                       { return m_xMoveOperations->rowUpdated(); }
     163             :     bool rowInserted()                      { return m_xMoveOperations->rowInserted(); }
     164          35 :     bool rowDeleted()                       { return m_xMoveOperations->rowDeleted(); }
     165             :     css::uno::Reference< css::uno::XInterface> getStatement()         { return m_xMoveOperations->getStatement(); }
     166             :     // css::sdbcx::XColumnsSupplier
     167           2 :     css::uno::Reference< css::container::XNameAccess> getColumns() const throw( css::uno::RuntimeException ) { return m_xColumnsSupplier->getColumns(); }
     168             : private:
     169             :     void ImplConstruct(const css::uno::Reference< css::sdbc::XResultSet>& _rxCursor, bool bUseCloned);
     170             : };
     171             : 
     172             : 
     173             : class FmXDisposeMultiplexer;
     174             : class SAL_WARN_UNUSED FmXDisposeListener
     175             : {
     176             :     friend class FmXDisposeMultiplexer;
     177             : 
     178             :     FmXDisposeMultiplexer*  m_pAdapter;
     179             :     ::osl::Mutex&   m_rMutex;
     180             : 
     181             : public:
     182           1 :     FmXDisposeListener(::osl::Mutex& _rMutex) : m_pAdapter(NULL), m_rMutex(_rMutex) { }
     183             :     virtual ~FmXDisposeListener();
     184             : 
     185             :     virtual void disposing(const css::lang::EventObject& _rEvent, sal_Int16 _nId) throw( css::uno::RuntimeException ) = 0;
     186             : 
     187             : protected:
     188             :     void setAdapter(FmXDisposeMultiplexer* pAdapter);
     189             : };
     190             : 
     191             : class SAL_WARN_UNUSED FmXDisposeMultiplexer : public ::cppu::WeakImplHelper1< css::lang::XEventListener>
     192             : {
     193             :     css::uno::Reference< css::lang::XComponent>       m_xObject;
     194             :     FmXDisposeListener* m_pListener;
     195             :     sal_Int16           m_nId;
     196             : 
     197             :     virtual ~FmXDisposeMultiplexer();
     198             : public:
     199             :     FmXDisposeMultiplexer(FmXDisposeListener* _pListener, const css::uno::Reference< css::lang::XComponent>& _rxObject, sal_Int16 _nId = -1);
     200             : 
     201             : // css::lang::XEventListener
     202             :     virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     203             : 
     204             :     void dispose();
     205             : };
     206             : 
     207             : sal_Int16       getControlTypeByObject(const css::uno::Reference< css::lang::XServiceInfo>& _rxObject);
     208             :     // get the object type (OBJ_FM_...) from the services the object supports
     209             : 
     210             : 
     211             : bool isRowSetAlive(const css::uno::Reference< css::uno::XInterface>& _rxRowSet);
     212             :     // checks if the css::sdbcx::XColumnsSupplier provided by _rxRowSet supllies any columns
     213             : 
     214             : 
     215             : typedef ::std::set  < css::uno::Reference< css::uno::XInterface >
     216             :                     , ::comphelper::OInterfaceCompare< css::uno::XInterface >
     217             :                     > InterfaceBag;
     218             : 
     219             : #endif // INCLUDED_SVX_FMTOOLS_HXX
     220             : 
     221             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11