LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/vbahelper - vbahelper.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 5 19 26.3 %
Date: 2012-08-25 Functions: 3 25 12.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 11 88 12.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                 :            : #ifndef OOVBAAPI_VBA_HELPER_HXX
      20                 :            : #define OOVBAAPI_VBA_HELPER_HXX
      21                 :            : 
      22                 :            : #include <com/sun/star/drawing/XShape.hpp>
      23                 :            : #include <com/sun/star/beans/XIntrospectionAccess.hpp>
      24                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      25                 :            : #include <com/sun/star/script/BasicErrorException.hpp>
      26                 :            : #include <com/sun/star/script/XTypeConverter.hpp>
      27                 :            : #include <com/sun/star/lang/IllegalArgumentException.hpp>
      28                 :            : #include <com/sun/star/awt/XControl.hpp>
      29                 :            : #include <com/sun/star/awt/XDevice.hpp>
      30                 :            : #include <com/sun/star/frame/XDispatchResultListener.hpp>
      31                 :            : #include <com/sun/star/frame/DispatchResultEvent.hpp>
      32                 :            : #include <com/sun/star/frame/DispatchResultState.hpp>
      33                 :            : #include <com/sun/star/lang/EventObject.hpp>
      34                 :            : #include <com/sun/star/awt/XUnitConversion.hpp>
      35                 :            : #include <basic/basmgr.hxx>
      36                 :            : #include <basic/sberrors.hxx>
      37                 :            : #include <cppuhelper/implbase1.hxx>
      38                 :            : #include <com/sun/star/frame/XModel.hpp>
      39                 :            : #include <sfx2/dispatch.hxx>
      40                 :            : #include <sfx2/objsh.hxx>
      41                 :            : #include <sfx2/docfilt.hxx>
      42                 :            : #include <sfx2/docfile.hxx>
      43                 :            : #include <vcl/pointr.hxx>
      44                 :            : #include <memory>
      45                 :            : #include "vbaaccesshelper.hxx"
      46                 :            : 
      47                 :            : namespace css = ::com::sun::star;
      48                 :            : namespace ooo
      49                 :            : {
      50                 :            :     namespace vba
      51                 :            :     {
      52                 :            :         template < class T >
      53                 :         51 :         css::uno::Reference< T > getXSomethingFromArgs( css::uno::Sequence< css::uno::Any > const & args, sal_Int32 nPos, bool bCanBeNull = true ) throw (css::lang::IllegalArgumentException)
      54                 :            :         {
      55 [ -  + ][ -  + ]:         51 :             if ( args.getLength() < ( nPos + 1) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ -  + ]
      56 [ #  # ][ #  # ]:          0 :                 throw css::lang::IllegalArgumentException();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      57                 :         51 :             css::uno::Reference< T > aSomething( args[ nPos ], css::uno::UNO_QUERY );
      58         [ -  + ]:         51 :             if ( !bCanBeNull && !aSomething.is() )
           [ -  +  -  + ]
                 [ #  # ]
           [ -  +  #  # ]
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
           [ #  #  -  + ]
         [ #  # ][ -  + ]
                 [ +  + ]
      59 [ #  # ][ #  # ]:          0 :                 throw css::lang::IllegalArgumentException();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      60                 :         51 :             return aSomething;
      61                 :            :         }
      62                 :            : 
      63                 :            :         class XHelperInterface;
      64                 :            : 
      65                 :            :         /** Returns the VBA document implementation object representing the passed UNO document model. */
      66                 :            :         VBAHELPER_DLLPUBLIC css::uno::Reference< XHelperInterface > getVBADocument( const css::uno::Reference< css::frame::XModel >& xModel );
      67                 :            :         VBAHELPER_DLLPUBLIC css::uno::Reference< XHelperInterface > getUnoDocModule( const String& aModName, SfxObjectShell* pShell );
      68                 :            :         VBAHELPER_DLLPUBLIC SfxObjectShell* getSfxObjShell( const css::uno::Reference< css::frame::XModel >& xModel ) throw ( css::uno::RuntimeException);
      69                 :            : 
      70                 :            :         css::uno::Reference< css::frame::XModel > getCurrentDoc( const rtl::OUString& sKey ) throw (css::uno::RuntimeException);
      71                 :            :         VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getThisExcelDoc( const css::uno::Reference< css::uno::XComponentContext >& xContext ) throw (css::uno::RuntimeException);
      72                 :            :         VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getThisWordDoc( const css::uno::Reference< css::uno::XComponentContext >& xContext ) throw (css::uno::RuntimeException);
      73                 :            :         VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getCurrentExcelDoc( const css::uno::Reference< css::uno::XComponentContext >& xContext ) throw (css::uno::RuntimeException);
      74                 :            :         VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getCurrentWordDoc( const css::uno::Reference< css::uno::XComponentContext >& xContext ) throw (css::uno::RuntimeException);
      75                 :            : 
      76                 :            :         VBAHELPER_DLLPUBLIC css::uno::Reference< css::beans::XIntrospectionAccess > getIntrospectionAccess( const css::uno::Any& aObject ) throw (css::uno::RuntimeException);
      77                 :            :         VBAHELPER_DLLPUBLIC css::uno::Reference< css::script::XTypeConverter > getTypeConverter( const css::uno::Reference< css::uno::XComponentContext >& xContext ) throw (css::uno::RuntimeException);
      78                 :            : 
      79                 :            :         VBAHELPER_DLLPUBLIC void dispatchRequests( const css::uno::Reference< css::frame::XModel>& xModel, const rtl::OUString& aUrl );
      80                 :            :      VBAHELPER_DLLPUBLIC void dispatchRequests (const css::uno::Reference< css::frame::XModel>& xModel, const rtl::OUString & aUrl, const css::uno::Sequence< css::beans::PropertyValue >& sProps, const css::uno::Reference< css::frame::XDispatchResultListener >& rListener = css::uno::Reference< css::frame::XDispatchResultListener >(), const sal_Bool bSilent = sal_True );
      81                 :            :         VBAHELPER_DLLPUBLIC void dispatchExecute(SfxViewShell* pView, sal_uInt16 nSlot, SfxCallMode nCall = SFX_CALLMODE_SYNCHRON );
      82                 :            :         VBAHELPER_DLLPUBLIC sal_Int32 OORGBToXLRGB( sal_Int32 );
      83                 :            :         VBAHELPER_DLLPUBLIC sal_Int32 XLRGBToOORGB( sal_Int32 );
      84                 :            :         VBAHELPER_DLLPUBLIC css::uno::Any OORGBToXLRGB( const css::uno::Any& );
      85                 :            :         VBAHELPER_DLLPUBLIC css::uno::Any XLRGBToOORGB( const css::uno::Any& );
      86                 :            :         // provide a NULL object that can be passed as variant so that
      87                 :            :         // the object when passed to IsNull will return true. aNULL
      88                 :            :         // contains an empty object reference
      89                 :            :         VBAHELPER_DLLPUBLIC const css::uno::Any& aNULL();
      90                 :            :         VBAHELPER_DLLPUBLIC void PrintOutHelper( SfxViewShell* pViewShell, const css::uno::Any& From, const css::uno::Any& To, const css::uno::Any& Copies, const css::uno::Any& Preview, const css::uno::Any& ActivePrinter, const css::uno::Any& PrintToFile, const css::uno::Any& Collate, const css::uno::Any& PrToFileName, sal_Bool bSelection  );
      91                 :            :         VBAHELPER_DLLPUBLIC void PrintPreviewHelper( const css::uno::Any& EnableChanges,  SfxViewShell* );
      92                 :            :         VBAHELPER_DLLPUBLIC void WaitUntilPreviewIsClosed( SfxViewFrame* );
      93                 :            : 
      94                 :            :         /** Extracts a boolean value from the passed Any, which may contain a Boolean or an integer or floating-point value.
      95                 :            :             Throws, if the Any is empty or contains an incompatible type. */
      96                 :            :         VBAHELPER_DLLPUBLIC bool extractBoolFromAny( const css::uno::Any& rAny ) throw (css::uno::RuntimeException);
      97                 :            : 
      98                 :            :         /** Extracts a string from the passed Any, which may contain a Boolean, a value, or a string.
      99                 :            :             Throws, if the Any is empty or contains an incompatible type. */
     100                 :            :         VBAHELPER_DLLPUBLIC ::rtl::OUString extractStringFromAny( const css::uno::Any& rAny, bool bUppercaseBool = false ) throw (css::uno::RuntimeException);
     101                 :            :         /** Extracts a string from the passed Any, which may contain a Boolean, a value, or a string.
     102                 :            :             Returns rDefault, if rAny is empty. Throws, if the Any contains an incompatible type. */
     103                 :            :         VBAHELPER_DLLPUBLIC ::rtl::OUString extractStringFromAny( const css::uno::Any& rAny, const ::rtl::OUString& rDefault, bool bUppercaseBool = false ) throw (css::uno::RuntimeException);
     104                 :            : 
     105                 :            :         VBAHELPER_DLLPUBLIC rtl::OUString getAnyAsString( const css::uno::Any& pvargItem ) throw ( css::uno::RuntimeException );
     106                 :            :         VBAHELPER_DLLPUBLIC rtl::OUString VBAToRegexp(const rtl::OUString &rIn, bool bForLike = false); // needs to be in an uno service ( already this code is duplicated in basic )
     107                 :            :         VBAHELPER_DLLPUBLIC double getPixelTo100thMillimeterConversionFactor( const css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical);
     108                 :            :         VBAHELPER_DLLPUBLIC double PointsToPixels( const css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical);
     109                 :            :         VBAHELPER_DLLPUBLIC double PixelsToPoints( const css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical);
     110                 :            :         VBAHELPER_DLLPUBLIC sal_Int32 PointsToHmm( double fPoints );
     111                 :            :         VBAHELPER_DLLPUBLIC double HmmToPoints( sal_Int32 nHmm );
     112                 :            :         VBAHELPER_DLLPUBLIC sal_Int32 getPointerStyle( const css::uno::Reference< css::frame::XModel >& );
     113                 :            :         VBAHELPER_DLLPUBLIC void setCursorHelper( const css::uno::Reference< css::frame::XModel >& xModel, const Pointer& rPointer, sal_Bool bOverWrite );
     114                 :            :         VBAHELPER_DLLPUBLIC void setDefaultPropByIntrospection( const css::uno::Any& aObj, const css::uno::Any& aValue  ) throw ( css::uno::RuntimeException );
     115                 :            :         VBAHELPER_DLLPUBLIC css::uno::Any getDefaultPropByIntrospection( const css::uno::Any& aObj ) throw ( css::uno::RuntimeException );
     116                 :            :         VBAHELPER_DLLPUBLIC css::uno::Any getPropertyValue( const css::uno::Sequence< css::beans::PropertyValue >& aProp, const rtl::OUString& aName );
     117                 :            :         VBAHELPER_DLLPUBLIC sal_Bool setPropertyValue( css::uno::Sequence< css::beans::PropertyValue >& aProp, const rtl::OUString& aName, const css::uno::Any& aValue );
     118                 :            :         VBAHELPER_DLLPUBLIC void setOrAppendPropertyValue( css::uno::Sequence< css::beans::PropertyValue >& aProp, const rtl::OUString& aName, const css::uno::Any& aValue );
     119                 :            : 
     120                 :            : class VBAHELPER_DLLPUBLIC Millimeter
     121                 :            : {
     122                 :            : //Factor to translate between points and hundredths of millimeters:
     123                 :            : private:
     124                 :            :     double m_nMillimeter;
     125                 :            : 
     126                 :            : public:
     127                 :            :     Millimeter();
     128                 :            : 
     129                 :            :     Millimeter(double mm);
     130                 :            : 
     131                 :            :     void setInPoints(double points) ;
     132                 :            :     double getInHundredthsOfOneMillimeter();
     133                 :            :     static sal_Int32 getInHundredthsOfOneMillimeter(double points);
     134                 :            :     static double getInPoints(int _hmm);
     135                 :            : };
     136                 :            : 
     137                 :          0 : class VBAHELPER_DLLPUBLIC AbstractGeometryAttributes // probably should replace the ShapeHelper below
     138                 :            : {
     139                 :            : public:
     140         [ #  # ]:          0 :     virtual ~AbstractGeometryAttributes() {}
     141                 :            :     virtual double getLeft() const = 0;
     142                 :            :     virtual void setLeft( double ) = 0;
     143                 :            :     virtual double getTop() const = 0;
     144                 :            :     virtual void setTop( double ) = 0;
     145                 :            :     virtual double getHeight() const = 0;
     146                 :            :     virtual void setHeight( double ) = 0;
     147                 :            :     virtual double getWidth() const = 0;
     148                 :            :     virtual void setWidth( double ) = 0;
     149                 :            : 
     150                 :          0 :     virtual double getInnerHeight() const { return 0.0; }
     151                 :          0 :     virtual void setInnerHeight( double ) {}
     152                 :          0 :     virtual double getInnerWidth() const { return 0.0; }
     153                 :          0 :     virtual void setInnerWidth( double ) {}
     154                 :          0 :     virtual double getOffsetX() const { return 0.0; }
     155                 :          0 :     virtual double getOffsetY() const { return 0.0; }
     156                 :            : };
     157                 :            : 
     158                 :            : namespace msforms {
     159                 :            :     class XShape;
     160                 :            : }
     161                 :            : 
     162                 :          0 : class VBAHELPER_DLLPUBLIC ShapeHelper
     163                 :            : {
     164                 :            : protected:
     165                 :            :     css::uno::Reference< css::drawing::XShape > xShape;
     166                 :            : public:
     167                 :            :     ShapeHelper( const css::uno::Reference< css::drawing::XShape >& _xShape) throw (css::script::BasicErrorException );
     168                 :            : 
     169                 :            :     double getHeight() const;
     170                 :            :        void setHeight(double _fheight) throw ( css::script::BasicErrorException );
     171                 :            :     double getWidth() const;
     172                 :            :     void setWidth(double _fWidth) throw ( css::script::BasicErrorException );
     173                 :            :     double getLeft() const;
     174                 :            :     void setLeft(double _fLeft);
     175                 :            :     double getTop() const;
     176                 :            :     void setTop(double _fTop);
     177                 :            : };
     178                 :            : 
     179                 :            : class VBAHELPER_DLLPUBLIC ConcreteXShapeGeometryAttributes : public AbstractGeometryAttributes
     180                 :            : {
     181                 :            :     std::auto_ptr< ShapeHelper > m_pShapeHelper;
     182                 :            : public:
     183                 :            :     ConcreteXShapeGeometryAttributes( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::drawing::XShape >& xShape );
     184                 :            :     virtual double getLeft() const;
     185                 :            :     virtual void setLeft( double nLeft );
     186                 :            :     virtual double getTop() const;
     187                 :            :     virtual void setTop( double nTop );
     188                 :            :     virtual double getHeight() const;
     189                 :            :     virtual void setHeight( double nHeight );
     190                 :            :     virtual double getWidth() const;
     191                 :            :     virtual void setWidth( double nWidth);
     192                 :            :     virtual ~ConcreteXShapeGeometryAttributes();
     193                 :            : };
     194                 :            : 
     195                 :            : #define VBA_LEFT "PositionX"
     196                 :            : #define VBA_TOP "PositionY"
     197         [ #  # ]:          0 : class VBAHELPER_DLLPUBLIC UserFormGeometryHelper : public AbstractGeometryAttributes
     198                 :            : {
     199                 :            : public:
     200                 :            :     UserFormGeometryHelper(
     201                 :            :         const css::uno::Reference< css::uno::XComponentContext >& xContext,
     202                 :            :         const css::uno::Reference< css::awt::XControl >& xControl,
     203                 :            :         double fOffsetX, double fOffsetY );
     204                 :            :     virtual double getLeft() const;
     205                 :            :     virtual void setLeft( double fLeft );
     206                 :            :     virtual double getTop() const;
     207                 :            :     virtual void setTop( double fTop );
     208                 :            :     virtual double getWidth() const;
     209                 :            :     virtual void setWidth( double fWidth );
     210                 :            :     virtual double getHeight() const;
     211                 :            :     virtual void setHeight( double fHeight );
     212                 :            :     virtual double getInnerWidth() const;
     213                 :            :     virtual void setInnerWidth( double fWidth );
     214                 :            :     virtual double getInnerHeight() const;
     215                 :            :     virtual void setInnerHeight( double fHeight );
     216                 :            :     virtual double getOffsetX() const;
     217                 :            :     virtual double getOffsetY() const;
     218                 :            : 
     219                 :            : private:
     220                 :            :     double implGetPos( bool bPosY ) const;
     221                 :            :     void implSetPos( double fPos, bool bPosY );
     222                 :            :     double implGetSize( bool bHeight, bool bOuter ) const;
     223                 :            :     void implSetSize( double fSize, bool bHeight, bool bOuter );
     224                 :            : 
     225                 :            : private:
     226                 :            :     css::uno::Reference< css::awt::XWindow > mxWindow;
     227                 :            :     css::uno::Reference< css::beans::XPropertySet > mxModelProps;
     228                 :            :     css::uno::Reference< css::awt::XUnitConversion > mxUnitConv;
     229                 :            :     double mfOffsetX;
     230                 :            :     double mfOffsetY;
     231                 :            :     sal_Bool mbDialog;
     232                 :            : };
     233                 :            : 
     234                 :            : class VBAHELPER_DLLPUBLIC ContainerUtilities
     235                 :            : {
     236                 :            : 
     237                 :            : public:
     238                 :            :     static rtl::OUString getUniqueName( const css::uno::Sequence< ::rtl::OUString >&  _slist, const rtl::OUString& _sElementName, const ::rtl::OUString& _sSuffixSeparator);
     239                 :            :     static rtl::OUString getUniqueName( const css::uno::Sequence< rtl::OUString >& _slist, const rtl::OUString _sElementName, const rtl::OUString& _sSuffixSeparator, sal_Int32 _nStartSuffix );
     240                 :            : 
     241                 :            :     static sal_Int32 FieldInList( const css::uno::Sequence< rtl::OUString >& SearchList, const rtl::OUString& SearchString );
     242                 :            : };
     243                 :            : 
     244                 :            : // really just a a place holder to ease the porting pain
     245                 :            : class VBAHELPER_DLLPUBLIC DebugHelper
     246                 :            : {
     247                 :            : public:
     248                 :            :     static void exception( const rtl::OUString&  DetailedMessage, const css::uno::Exception& ex,  int err, const rtl::OUString& /*additionalArgument*/ ) throw( css::script::BasicErrorException );
     249                 :            : 
     250                 :            :     static void exception( int err,  const rtl::OUString& additionalArgument ) throw( css::script::BasicErrorException );
     251                 :            : 
     252                 :            :     static void exception( const css::uno::Exception& ex ) throw( css::script::BasicErrorException );
     253                 :            : };
     254                 :            : 
     255                 :            : class VBAHELPER_DLLPUBLIC VBADispatchListener : public cppu::WeakImplHelper1< css::frame::XDispatchResultListener >
     256                 :            : {
     257                 :            : private:
     258                 :            :     css::uno::Any m_Result;
     259                 :            :     sal_Bool m_State;
     260                 :            : 
     261                 :            : public:
     262                 :            :     VBADispatchListener();
     263                 :            :     ~VBADispatchListener();
     264                 :            : 
     265                 :          0 :     css::uno::Any getResult() { return m_Result; }
     266                 :          0 :     sal_Bool getState() { return m_State; }
     267                 :            : 
     268                 :            :     // XDispatchResultListener
     269                 :            :     virtual void SAL_CALL dispatchFinished( const css::frame::DispatchResultEvent& aEvent ) throw ( css::uno::RuntimeException );
     270                 :            :     virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) throw ( css::uno::RuntimeException );
     271                 :            : };
     272                 :            : 
     273                 :            :     } // vba
     274                 :            : } // ooo
     275                 :            : 
     276                 :            : namespace ov = ooo::vba;
     277                 :            : 
     278                 :            : #endif
     279                 :            : 
     280                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10