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

Generated by: LCOV version 1.10