1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir #include <cppuhelper/bootstrap.hxx> 28*cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp> 29*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp> 30*cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp> 31*cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiComponentFactory.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/beans/XIntrospection.hpp> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #include <sfx2/objsh.hxx> 42*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 43*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 44*cdf0e10cSrcweir #include <sfx2/app.hxx> 45*cdf0e10cSrcweir #include <svl/stritem.hxx> 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir #include <docuno.hxx> 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir #include <basic/sbx.hxx> 50*cdf0e10cSrcweir #include <basic/sbstar.hxx> 51*cdf0e10cSrcweir #include <rtl/math.hxx> 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir #include <math.h> 54*cdf0e10cSrcweir #include "vbahelper.hxx" 55*cdf0e10cSrcweir #include "tabvwsh.hxx" 56*cdf0e10cSrcweir #include "transobj.hxx" 57*cdf0e10cSrcweir #include "scmod.hxx" 58*cdf0e10cSrcweir #include "vbashape.hxx" 59*cdf0e10cSrcweir #include "unonames.hxx" 60*cdf0e10cSrcweir #include "cellsuno.hxx" 61*cdf0e10cSrcweir using namespace ::com::sun::star; 62*cdf0e10cSrcweir using namespace ::ooo::vba; 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir #define POINTTO100THMILLIMETERFACTOR 35.27778 65*cdf0e10cSrcweir void unoToSbxValue( SbxVariable* pVar, const uno::Any& aValue ); 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir uno::Any sbxToUnoValue( SbxVariable* pVar ); 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir namespace ooo 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir namespace vba 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir const double Millimeter::factor = 35.27778; 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir uno::Reference< beans::XIntrospectionAccess > 78*cdf0e10cSrcweir getIntrospectionAccess( const uno::Any& aObject ) throw (uno::RuntimeException) 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir static uno::Reference< beans::XIntrospection > xIntrospection; 81*cdf0e10cSrcweir if( !xIntrospection.is() ) 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); 84*cdf0e10cSrcweir xIntrospection.set( xFactory->createInstance( rtl::OUString::createFromAscii("com.sun.star.beans.Introspection") ), uno::UNO_QUERY_THROW ); 85*cdf0e10cSrcweir } 86*cdf0e10cSrcweir return xIntrospection->inspect( aObject ); 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir uno::Reference< script::XTypeConverter > 90*cdf0e10cSrcweir getTypeConverter( const uno::Reference< uno::XComponentContext >& xContext ) throw (uno::RuntimeException) 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir static uno::Reference< script::XTypeConverter > xTypeConv( xContext->getServiceManager()->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.script.Converter") ), xContext ), uno::UNO_QUERY_THROW ); 93*cdf0e10cSrcweir return xTypeConv; 94*cdf0e10cSrcweir } 95*cdf0e10cSrcweir // helper method to determine if the view ( calc ) is in print-preview mode 96*cdf0e10cSrcweir bool isInPrintPreview( SfxViewFrame* pView ) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir sal_uInt16 nViewNo = SID_VIEWSHELL1 - SID_VIEWSHELL0; 99*cdf0e10cSrcweir if ( pView->GetObjectShell()->GetFactory().GetViewFactoryCount() > 100*cdf0e10cSrcweir nViewNo && !pView->GetObjectShell()->IsInPlaceActive() ) 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir SfxViewFactory &rViewFactory = 103*cdf0e10cSrcweir pView->GetObjectShell()->GetFactory().GetViewFactory(nViewNo); 104*cdf0e10cSrcweir if ( pView->GetCurViewId() == rViewFactory.GetOrdinal() ) 105*cdf0e10cSrcweir return true; 106*cdf0e10cSrcweir } 107*cdf0e10cSrcweir return false; 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir const ::rtl::OUString REPLACE_CELLS_WARNING( RTL_CONSTASCII_USTRINGPARAM( "ReplaceCellsWarning")); 110*cdf0e10cSrcweir const uno::Any& 111*cdf0e10cSrcweir aNULL() 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir static uno::Any aNULLL = uno::makeAny( uno::Reference< uno::XInterface >() ); 114*cdf0e10cSrcweir return aNULLL; 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir class PasteCellsWarningReseter 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir private: 120*cdf0e10cSrcweir bool bInitialWarningState; 121*cdf0e10cSrcweir static uno::Reference< beans::XPropertySet > getGlobalSheetSettings() throw ( uno::RuntimeException ) 122*cdf0e10cSrcweir { 123*cdf0e10cSrcweir static uno::Reference< beans::XPropertySet > xTmpProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); 124*cdf0e10cSrcweir static uno::Reference<uno::XComponentContext > xContext( xTmpProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW ); 125*cdf0e10cSrcweir static uno::Reference<lang::XMultiComponentFactory > xServiceManager( 126*cdf0e10cSrcweir xContext->getServiceManager(), uno::UNO_QUERY_THROW ); 127*cdf0e10cSrcweir static uno::Reference< beans::XPropertySet > xProps( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.GlobalSheetSettings" ) ) ,xContext ), uno::UNO_QUERY_THROW ); 128*cdf0e10cSrcweir return xProps; 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir bool getReplaceCellsWarning() throw ( uno::RuntimeException ) 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir sal_Bool res = sal_False; 134*cdf0e10cSrcweir getGlobalSheetSettings()->getPropertyValue( REPLACE_CELLS_WARNING ) >>= res; 135*cdf0e10cSrcweir return ( res == sal_True ); 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir void setReplaceCellsWarning( bool bState ) throw ( uno::RuntimeException ) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir getGlobalSheetSettings()->setPropertyValue( REPLACE_CELLS_WARNING, uno::makeAny( bState ) ); 141*cdf0e10cSrcweir } 142*cdf0e10cSrcweir public: 143*cdf0e10cSrcweir PasteCellsWarningReseter() throw ( uno::RuntimeException ) 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir bInitialWarningState = getReplaceCellsWarning(); 146*cdf0e10cSrcweir if ( bInitialWarningState ) 147*cdf0e10cSrcweir setReplaceCellsWarning( false ); 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir ~PasteCellsWarningReseter() 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir if ( bInitialWarningState ) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir // don't allow dtor to throw 154*cdf0e10cSrcweir try 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir setReplaceCellsWarning( true ); 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir catch ( uno::Exception& /*e*/ ){} 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir }; 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir void dispatchExecute(css::uno::Reference< css::frame::XModel>& xModel, sal_uInt16 nSlot, SfxCallMode nCall) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir ScTabViewShell* pViewShell = getBestViewShell( xModel ); 166*cdf0e10cSrcweir SfxViewFrame* pViewFrame = NULL; 167*cdf0e10cSrcweir if ( pViewShell ) 168*cdf0e10cSrcweir pViewFrame = pViewShell->GetViewFrame(); 169*cdf0e10cSrcweir if ( pViewFrame ) 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher(); 172*cdf0e10cSrcweir if( pDispatcher ) 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir pDispatcher->Execute( nSlot , nCall ); 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir void 180*cdf0e10cSrcweir implnPaste() 181*cdf0e10cSrcweir { 182*cdf0e10cSrcweir PasteCellsWarningReseter resetWarningBox; 183*cdf0e10cSrcweir ScTabViewShell* pViewShell = getCurrentBestViewShell(); 184*cdf0e10cSrcweir if ( pViewShell ) 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir pViewShell->PasteFromSystem(); 187*cdf0e10cSrcweir pViewShell->CellContentChanged(); 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir void 193*cdf0e10cSrcweir implnCopy() 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir ScTabViewShell* pViewShell = getCurrentBestViewShell(); 196*cdf0e10cSrcweir if ( pViewShell ) 197*cdf0e10cSrcweir pViewShell->CopyToClip(NULL,false,false,true); 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir void 201*cdf0e10cSrcweir implnCut() 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir ScTabViewShell* pViewShell = getCurrentBestViewShell(); 204*cdf0e10cSrcweir if ( pViewShell ) 205*cdf0e10cSrcweir pViewShell->CutToClip( NULL, sal_True ); 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir void implnPasteSpecial(sal_uInt16 nFlags,sal_uInt16 nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose) 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir PasteCellsWarningReseter resetWarningBox; 211*cdf0e10cSrcweir sal_Bool bAsLink(sal_False), bOtherDoc(sal_False); 212*cdf0e10cSrcweir InsCellCmd eMoveMode = INS_NONE; 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir ScTabViewShell* pTabViewShell = ScTabViewShell::GetActiveViewShell(); 215*cdf0e10cSrcweir if ( !pTabViewShell ) 216*cdf0e10cSrcweir // none active, try next best 217*cdf0e10cSrcweir pTabViewShell = getCurrentBestViewShell(); 218*cdf0e10cSrcweir if ( pTabViewShell ) 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir ScViewData* pView = pTabViewShell->GetViewData(); 221*cdf0e10cSrcweir Window* pWin = ( pView != NULL ) ? pView->GetActiveWin() : NULL; 222*cdf0e10cSrcweir if ( pView && pWin ) 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir if ( bAsLink && bOtherDoc ) 225*cdf0e10cSrcweir pTabViewShell->PasteFromSystem(0);//SOT_FORMATSTR_ID_LINK 226*cdf0e10cSrcweir else 227*cdf0e10cSrcweir { 228*cdf0e10cSrcweir ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin ); 229*cdf0e10cSrcweir ScDocument* pDoc = NULL; 230*cdf0e10cSrcweir if ( pOwnClip ) 231*cdf0e10cSrcweir pDoc = pOwnClip->GetDocument(); 232*cdf0e10cSrcweir pTabViewShell->PasteFromClip( nFlags, pDoc, 233*cdf0e10cSrcweir nFunction, bSkipEmpty, bTranspose, bAsLink, 234*cdf0e10cSrcweir eMoveMode, IDF_NONE, sal_True ); 235*cdf0e10cSrcweir pTabViewShell->CellContentChanged(); 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir uno::Reference< frame::XModel > 243*cdf0e10cSrcweir getCurrentDocument() throw (uno::RuntimeException) 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir uno::Reference< frame::XModel > xModel; 246*cdf0e10cSrcweir SbxObject* pBasic = dynamic_cast< SbxObject* > ( SFX_APP()->GetBasic() ); 247*cdf0e10cSrcweir SbxObject* basicChosen = pBasic ; 248*cdf0e10cSrcweir if ( basicChosen == NULL) 249*cdf0e10cSrcweir { 250*cdf0e10cSrcweir OSL_TRACE("getModelFromBasic() StarBASIC* is NULL" ); 251*cdf0e10cSrcweir return xModel; 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir SbxObject* p = pBasic; 254*cdf0e10cSrcweir SbxObject* pParent = p->GetParent(); 255*cdf0e10cSrcweir SbxObject* pParentParent = pParent ? pParent->GetParent() : NULL; 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir if( pParentParent ) 258*cdf0e10cSrcweir { 259*cdf0e10cSrcweir basicChosen = pParentParent; 260*cdf0e10cSrcweir } 261*cdf0e10cSrcweir else if( pParent ) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir basicChosen = pParent; 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir uno::Any aModel; 268*cdf0e10cSrcweir SbxVariable *pCompVar = basicChosen->Find( UniString(RTL_CONSTASCII_USTRINGPARAM("ThisComponent")), SbxCLASS_OBJECT ); 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir if ( pCompVar ) 271*cdf0e10cSrcweir { 272*cdf0e10cSrcweir aModel = sbxToUnoValue( pCompVar ); 273*cdf0e10cSrcweir if ( sal_False == ( aModel >>= xModel ) || 274*cdf0e10cSrcweir !xModel.is() ) 275*cdf0e10cSrcweir { 276*cdf0e10cSrcweir // trying last gasp try the current component 277*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); 278*cdf0e10cSrcweir // test if vba service is present 279*cdf0e10cSrcweir uno::Reference< uno::XComponentContext > xCtx( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW ); 280*cdf0e10cSrcweir uno::Reference<lang::XMultiComponentFactory > xSMgr( xCtx->getServiceManager(), uno::UNO_QUERY_THROW ); 281*cdf0e10cSrcweir uno::Reference< frame::XDesktop > xDesktop (xSMgr->createInstanceWithContext(::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop"), xCtx), uno::UNO_QUERY_THROW ); 282*cdf0e10cSrcweir xModel.set( xDesktop->getCurrentComponent(), uno::UNO_QUERY ); 283*cdf0e10cSrcweir if ( !xModel.is() ) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir throw uno::RuntimeException( 286*cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can't extract model from basic ( its obviously not set yet ) therefore don't know the currently selected document") ), uno::Reference< uno::XInterface >() ); 287*cdf0e10cSrcweir } 288*cdf0e10cSrcweir return xModel; 289*cdf0e10cSrcweir } 290*cdf0e10cSrcweir else 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir OSL_TRACE("Have model ThisComponent points to url %s", 293*cdf0e10cSrcweir ::rtl::OUStringToOString( xModel->getURL(), 294*cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ).pData->buffer ); 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir } 297*cdf0e10cSrcweir else 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir OSL_TRACE("Failed to get ThisComponent"); 300*cdf0e10cSrcweir throw uno::RuntimeException( 301*cdf0e10cSrcweir rtl::OUString( 302*cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 303*cdf0e10cSrcweir "Can't determine the currently selected document") ), 304*cdf0e10cSrcweir uno::Reference< uno::XInterface >() ); 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir return xModel; 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir ScDocShell* 310*cdf0e10cSrcweir getDocShell( css::uno::Reference< css::frame::XModel>& xModel ) 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir uno::Reference< uno::XInterface > xIf( xModel, uno::UNO_QUERY_THROW ); 313*cdf0e10cSrcweir ScModelObj* pModel = dynamic_cast< ScModelObj* >( xIf.get() ); 314*cdf0e10cSrcweir ScDocShell* pDocShell = NULL; 315*cdf0e10cSrcweir if ( pModel ) 316*cdf0e10cSrcweir pDocShell = (ScDocShell*)pModel->GetEmbeddedObject(); 317*cdf0e10cSrcweir return pDocShell; 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir ScTabViewShell* 322*cdf0e10cSrcweir getBestViewShell( css::uno::Reference< css::frame::XModel>& xModel ) 323*cdf0e10cSrcweir { 324*cdf0e10cSrcweir ScDocShell* pDocShell = getDocShell( xModel ); 325*cdf0e10cSrcweir if ( pDocShell ) 326*cdf0e10cSrcweir return pDocShell->GetBestViewShell(); 327*cdf0e10cSrcweir return NULL; 328*cdf0e10cSrcweir } 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir ScTabViewShell* 331*cdf0e10cSrcweir getCurrentBestViewShell() 332*cdf0e10cSrcweir { 333*cdf0e10cSrcweir uno::Reference< frame::XModel > xModel = getCurrentDocument(); 334*cdf0e10cSrcweir return getBestViewShell( xModel ); 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir SfxViewFrame* 338*cdf0e10cSrcweir getCurrentViewFrame() 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir ScTabViewShell* pViewShell = getCurrentBestViewShell(); 341*cdf0e10cSrcweir if ( pViewShell ) 342*cdf0e10cSrcweir return pViewShell->GetViewFrame(); 343*cdf0e10cSrcweir return NULL; 344*cdf0e10cSrcweir } 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir sal_Int32 347*cdf0e10cSrcweir OORGBToXLRGB( sal_Int32 nCol ) 348*cdf0e10cSrcweir { 349*cdf0e10cSrcweir sal_Int32 nRed = nCol; 350*cdf0e10cSrcweir nRed &= 0x00FF0000; 351*cdf0e10cSrcweir nRed >>= 16; 352*cdf0e10cSrcweir sal_Int32 nGreen = nCol; 353*cdf0e10cSrcweir nGreen &= 0x0000FF00; 354*cdf0e10cSrcweir nGreen >>= 8; 355*cdf0e10cSrcweir sal_Int32 nBlue = nCol; 356*cdf0e10cSrcweir nBlue &= 0x000000FF; 357*cdf0e10cSrcweir sal_Int32 nRGB = ( (nBlue << 16) | (nGreen << 8) | nRed ); 358*cdf0e10cSrcweir return nRGB; 359*cdf0e10cSrcweir } 360*cdf0e10cSrcweir sal_Int32 361*cdf0e10cSrcweir XLRGBToOORGB( sal_Int32 nCol ) 362*cdf0e10cSrcweir { 363*cdf0e10cSrcweir sal_Int32 nBlue = nCol; 364*cdf0e10cSrcweir nBlue &= 0x00FF0000; 365*cdf0e10cSrcweir nBlue >>= 16; 366*cdf0e10cSrcweir sal_Int32 nGreen = nCol; 367*cdf0e10cSrcweir nGreen &= 0x0000FF00; 368*cdf0e10cSrcweir nGreen >>= 8; 369*cdf0e10cSrcweir sal_Int32 nRed = nCol; 370*cdf0e10cSrcweir nRed &= 0x000000FF; 371*cdf0e10cSrcweir sal_Int32 nRGB = ( (nRed << 16) | (nGreen << 8) | nBlue ); 372*cdf0e10cSrcweir return nRGB; 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir uno::Any 375*cdf0e10cSrcweir OORGBToXLRGB( const uno::Any& aCol ) 376*cdf0e10cSrcweir { 377*cdf0e10cSrcweir sal_Int32 nCol=0; 378*cdf0e10cSrcweir aCol >>= nCol; 379*cdf0e10cSrcweir nCol = OORGBToXLRGB( nCol ); 380*cdf0e10cSrcweir return uno::makeAny( nCol ); 381*cdf0e10cSrcweir } 382*cdf0e10cSrcweir uno::Any 383*cdf0e10cSrcweir XLRGBToOORGB( const uno::Any& aCol ) 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir sal_Int32 nCol=0; 386*cdf0e10cSrcweir aCol >>= nCol; 387*cdf0e10cSrcweir nCol = XLRGBToOORGB( nCol ); 388*cdf0e10cSrcweir return uno::makeAny( nCol ); 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir void PrintOutHelper( const uno::Any& From, const uno::Any& To, const uno::Any& Copies, const uno::Any& Preview, const uno::Any& /*ActivePrinter*/, const uno::Any& /*PrintToFile*/, const uno::Any& Collate, const uno::Any& PrToFileName, css::uno::Reference< frame::XModel >& xModel, sal_Bool bUseSelection ) 392*cdf0e10cSrcweir { 393*cdf0e10cSrcweir sal_Int32 nTo = 0; 394*cdf0e10cSrcweir sal_Int32 nFrom = 0; 395*cdf0e10cSrcweir sal_Int16 nCopies = 1; 396*cdf0e10cSrcweir sal_Bool bPreview = sal_False; 397*cdf0e10cSrcweir sal_Bool bCollate = sal_False; 398*cdf0e10cSrcweir sal_Bool bSelection = bUseSelection; 399*cdf0e10cSrcweir From >>= nFrom; 400*cdf0e10cSrcweir To >>= nTo; 401*cdf0e10cSrcweir Copies >>= nCopies; 402*cdf0e10cSrcweir Preview >>= bPreview; 403*cdf0e10cSrcweir if ( nCopies > 1 ) // Collate only useful when more that 1 copy 404*cdf0e10cSrcweir Collate >>= bCollate; 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir rtl::OUString sRange( RTL_CONSTASCII_USTRINGPARAM( "-" ) ); 407*cdf0e10cSrcweir rtl::OUString sFileName; 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir if (( nFrom || nTo ) ) 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir if ( nFrom ) 412*cdf0e10cSrcweir sRange = ( ::rtl::OUString::valueOf( nFrom ) + sRange ); 413*cdf0e10cSrcweir if ( nTo ) 414*cdf0e10cSrcweir sRange += ::rtl::OUString::valueOf( nTo ); 415*cdf0e10cSrcweir } 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir if ( PrToFileName.getValue() ) 418*cdf0e10cSrcweir { 419*cdf0e10cSrcweir PrToFileName >>= sFileName; 420*cdf0e10cSrcweir } 421*cdf0e10cSrcweir ScTabViewShell* pViewShell = getBestViewShell( xModel ); 422*cdf0e10cSrcweir SfxViewFrame* pViewFrame = NULL; 423*cdf0e10cSrcweir if ( pViewShell ) 424*cdf0e10cSrcweir pViewFrame = pViewShell->GetViewFrame(); 425*cdf0e10cSrcweir if ( pViewFrame ) 426*cdf0e10cSrcweir { 427*cdf0e10cSrcweir SfxAllItemSet aArgs( SFX_APP()->GetPool() ); 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir SfxBoolItem sfxCollate( SID_PRINT_COLLATE, bCollate ); 430*cdf0e10cSrcweir aArgs.Put( sfxCollate, sfxCollate.Which() ); 431*cdf0e10cSrcweir SfxInt16Item sfxCopies( SID_PRINT_COPIES, nCopies ); 432*cdf0e10cSrcweir aArgs.Put( sfxCopies, sfxCopies.Which() ); 433*cdf0e10cSrcweir if ( sFileName.getLength() ) 434*cdf0e10cSrcweir { 435*cdf0e10cSrcweir SfxStringItem sfxFileName( SID_FILE_NAME, sFileName); 436*cdf0e10cSrcweir aArgs.Put( sfxFileName, sfxFileName.Which() ); 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir } 439*cdf0e10cSrcweir if ( sRange.getLength() ) 440*cdf0e10cSrcweir { 441*cdf0e10cSrcweir SfxStringItem sfxRange( SID_PRINT_PAGES, sRange ); 442*cdf0e10cSrcweir aArgs.Put( sfxRange, sfxRange.Which() ); 443*cdf0e10cSrcweir } 444*cdf0e10cSrcweir SfxBoolItem sfxSelection( SID_SELECTION, bSelection ); 445*cdf0e10cSrcweir aArgs.Put( sfxSelection, sfxSelection.Which() ); 446*cdf0e10cSrcweir SfxBoolItem sfxAsync( SID_ASYNCHRON, sal_False ); 447*cdf0e10cSrcweir aArgs.Put( sfxAsync, sfxAsync.Which() ); 448*cdf0e10cSrcweir SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher(); 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir if ( pDispatcher ) 451*cdf0e10cSrcweir { 452*cdf0e10cSrcweir if ( bPreview ) 453*cdf0e10cSrcweir { 454*cdf0e10cSrcweir if ( !pViewFrame->GetFrame().IsInPlace() ) 455*cdf0e10cSrcweir { 456*cdf0e10cSrcweir SC_MOD()->InputEnterHandler(); 457*cdf0e10cSrcweir pViewFrame->GetDispatcher()->Execute( SID_VIEWSHELL1, SFX_CALLMODE_SYNCHRON ); 458*cdf0e10cSrcweir while ( isInPrintPreview( pViewFrame ) ) 459*cdf0e10cSrcweir Application::Yield(); 460*cdf0e10cSrcweir } 461*cdf0e10cSrcweir } 462*cdf0e10cSrcweir else 463*cdf0e10cSrcweir pDispatcher->Execute( (sal_uInt16)SID_PRINTDOC, (SfxCallMode)SFX_CALLMODE_SYNCHRON, aArgs ); 464*cdf0e10cSrcweir } 465*cdf0e10cSrcweir 466*cdf0e10cSrcweir } 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir // #FIXME #TODO 469*cdf0e10cSrcweir // 1 ActivePrinter ( how/can we switch a printer via API? ) 470*cdf0e10cSrcweir // 2 PrintToFile ( ms behaviour if this option is specified but no 471*cdf0e10cSrcweir // filename supplied 'PrToFileName' then the user will be prompted ) 472*cdf0e10cSrcweir // 3 Need to check behaviour of Selected sheets with range ( e.g. From & To 473*cdf0e10cSrcweir // values ) in oOO these options are mutually exclusive 474*cdf0e10cSrcweir // 4 There is a pop up to do with transparent objects in the print source 475*cdf0e10cSrcweir // should be able to disable that via configuration for the duration 476*cdf0e10cSrcweir // of this method 477*cdf0e10cSrcweir } 478*cdf0e10cSrcweir 479*cdf0e10cSrcweir void PrintPreviewHelper( const css::uno::Any& /*EnableChanges*/, css::uno::Reference< css::frame::XModel >& xModel ) 480*cdf0e10cSrcweir { 481*cdf0e10cSrcweir dispatchExecute( xModel, SID_VIEWSHELL1 ); 482*cdf0e10cSrcweir } 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir rtl::OUString getAnyAsString( const uno::Any& pvargItem ) throw ( uno::RuntimeException ) 485*cdf0e10cSrcweir { 486*cdf0e10cSrcweir uno::Type aType = pvargItem.getValueType(); 487*cdf0e10cSrcweir uno::TypeClass eTypeClass = aType.getTypeClass(); 488*cdf0e10cSrcweir rtl::OUString sString; 489*cdf0e10cSrcweir switch ( eTypeClass ) 490*cdf0e10cSrcweir { 491*cdf0e10cSrcweir case uno::TypeClass_BOOLEAN: 492*cdf0e10cSrcweir { 493*cdf0e10cSrcweir sal_Bool bBool = sal_False; 494*cdf0e10cSrcweir pvargItem >>= bBool; 495*cdf0e10cSrcweir sString = rtl::OUString::valueOf( bBool ); 496*cdf0e10cSrcweir break; 497*cdf0e10cSrcweir } 498*cdf0e10cSrcweir case uno::TypeClass_STRING: 499*cdf0e10cSrcweir pvargItem >>= sString; 500*cdf0e10cSrcweir break; 501*cdf0e10cSrcweir case uno::TypeClass_FLOAT: 502*cdf0e10cSrcweir { 503*cdf0e10cSrcweir float aFloat = 0; 504*cdf0e10cSrcweir pvargItem >>= aFloat; 505*cdf0e10cSrcweir sString = rtl::OUString::valueOf( aFloat ); 506*cdf0e10cSrcweir break; 507*cdf0e10cSrcweir } 508*cdf0e10cSrcweir case uno::TypeClass_DOUBLE: 509*cdf0e10cSrcweir { 510*cdf0e10cSrcweir double aDouble = 0; 511*cdf0e10cSrcweir pvargItem >>= aDouble; 512*cdf0e10cSrcweir sString = rtl::OUString::valueOf( aDouble ); 513*cdf0e10cSrcweir break; 514*cdf0e10cSrcweir } 515*cdf0e10cSrcweir case uno::TypeClass_SHORT: 516*cdf0e10cSrcweir case uno::TypeClass_LONG: 517*cdf0e10cSrcweir case uno::TypeClass_BYTE: 518*cdf0e10cSrcweir { 519*cdf0e10cSrcweir sal_Int32 aNum = 0; 520*cdf0e10cSrcweir pvargItem >>= aNum; 521*cdf0e10cSrcweir sString = rtl::OUString::valueOf( aNum ); 522*cdf0e10cSrcweir break; 523*cdf0e10cSrcweir } 524*cdf0e10cSrcweir 525*cdf0e10cSrcweir case uno::TypeClass_HYPER: 526*cdf0e10cSrcweir { 527*cdf0e10cSrcweir sal_Int64 aHyper = 0; 528*cdf0e10cSrcweir pvargItem >>= aHyper; 529*cdf0e10cSrcweir sString = rtl::OUString::valueOf( aHyper ); 530*cdf0e10cSrcweir break; 531*cdf0e10cSrcweir } 532*cdf0e10cSrcweir default: 533*cdf0e10cSrcweir throw uno::RuntimeException( rtl::OUString::createFromAscii( "Invalid type, can't convert" ), uno::Reference< uno::XInterface >() ); 534*cdf0e10cSrcweir } 535*cdf0e10cSrcweir return sString; 536*cdf0e10cSrcweir } 537*cdf0e10cSrcweir 538*cdf0e10cSrcweir 539*cdf0e10cSrcweir rtl::OUString 540*cdf0e10cSrcweir ContainerUtilities::getUniqueName( const uno::Sequence< ::rtl::OUString >& _slist, const rtl::OUString& _sElementName, const ::rtl::OUString& _sSuffixSeparator) 541*cdf0e10cSrcweir { 542*cdf0e10cSrcweir return getUniqueName(_slist, _sElementName, _sSuffixSeparator, sal_Int32(2)); 543*cdf0e10cSrcweir } 544*cdf0e10cSrcweir 545*cdf0e10cSrcweir rtl::OUString 546*cdf0e10cSrcweir ContainerUtilities::getUniqueName( const uno::Sequence< rtl::OUString >& _slist, const rtl::OUString _sElementName, const rtl::OUString& _sSuffixSeparator, sal_Int32 _nStartSuffix) 547*cdf0e10cSrcweir { 548*cdf0e10cSrcweir sal_Int32 a = _nStartSuffix; 549*cdf0e10cSrcweir rtl::OUString scompname = _sElementName; 550*cdf0e10cSrcweir bool bElementexists = true; 551*cdf0e10cSrcweir sal_Int32 nLen = _slist.getLength(); 552*cdf0e10cSrcweir if ( nLen == 0 ) 553*cdf0e10cSrcweir return _sElementName; 554*cdf0e10cSrcweir 555*cdf0e10cSrcweir while (bElementexists == true) 556*cdf0e10cSrcweir { 557*cdf0e10cSrcweir for (sal_Int32 i = 0; i < nLen; i++) 558*cdf0e10cSrcweir { 559*cdf0e10cSrcweir if (FieldInList(_slist, scompname) == -1) 560*cdf0e10cSrcweir { 561*cdf0e10cSrcweir return scompname; 562*cdf0e10cSrcweir } 563*cdf0e10cSrcweir } 564*cdf0e10cSrcweir scompname = _sElementName + _sSuffixSeparator + rtl::OUString::valueOf( a++ ); 565*cdf0e10cSrcweir } 566*cdf0e10cSrcweir return rtl::OUString(); 567*cdf0e10cSrcweir } 568*cdf0e10cSrcweir 569*cdf0e10cSrcweir sal_Int32 570*cdf0e10cSrcweir ContainerUtilities::FieldInList( const uno::Sequence< rtl::OUString >& SearchList, const rtl::OUString& SearchString ) 571*cdf0e10cSrcweir { 572*cdf0e10cSrcweir sal_Int32 FieldLen = SearchList.getLength(); 573*cdf0e10cSrcweir sal_Int32 retvalue = -1; 574*cdf0e10cSrcweir for (sal_Int32 i = 0; i < FieldLen; i++) 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir // I wonder why comparing lexicographically is done 577*cdf0e10cSrcweir // when its a match is whats interesting? 578*cdf0e10cSrcweir //if (SearchList[i].compareTo(SearchString) == 0) 579*cdf0e10cSrcweir if ( SearchList[i].equals( SearchString ) ) 580*cdf0e10cSrcweir { 581*cdf0e10cSrcweir retvalue = i; 582*cdf0e10cSrcweir break; 583*cdf0e10cSrcweir } 584*cdf0e10cSrcweir } 585*cdf0e10cSrcweir return retvalue; 586*cdf0e10cSrcweir 587*cdf0e10cSrcweir } 588*cdf0e10cSrcweir bool NeedEsc(sal_Unicode cCode) 589*cdf0e10cSrcweir { 590*cdf0e10cSrcweir String sEsc(RTL_CONSTASCII_USTRINGPARAM(".^$+\\|{}()")); 591*cdf0e10cSrcweir return (STRING_NOTFOUND != sEsc.Search(cCode)); 592*cdf0e10cSrcweir } 593*cdf0e10cSrcweir 594*cdf0e10cSrcweir rtl::OUString VBAToRegexp(const rtl::OUString &rIn, bool bForLike ) 595*cdf0e10cSrcweir { 596*cdf0e10cSrcweir rtl::OUStringBuffer sResult; 597*cdf0e10cSrcweir const sal_Unicode *start = rIn.getStr(); 598*cdf0e10cSrcweir const sal_Unicode *end = start + rIn.getLength(); 599*cdf0e10cSrcweir 600*cdf0e10cSrcweir int seenright = 0; 601*cdf0e10cSrcweir if ( bForLike ) 602*cdf0e10cSrcweir sResult.append(static_cast<sal_Unicode>('^')); 603*cdf0e10cSrcweir 604*cdf0e10cSrcweir while (start < end) 605*cdf0e10cSrcweir { 606*cdf0e10cSrcweir switch (*start) 607*cdf0e10cSrcweir { 608*cdf0e10cSrcweir case '?': 609*cdf0e10cSrcweir sResult.append(static_cast<sal_Unicode>('.')); 610*cdf0e10cSrcweir start++; 611*cdf0e10cSrcweir break; 612*cdf0e10cSrcweir case '*': 613*cdf0e10cSrcweir sResult.append(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".*"))); 614*cdf0e10cSrcweir start++; 615*cdf0e10cSrcweir break; 616*cdf0e10cSrcweir case '#': 617*cdf0e10cSrcweir sResult.append(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("[0-9]"))); 618*cdf0e10cSrcweir start++; 619*cdf0e10cSrcweir break; 620*cdf0e10cSrcweir case '~': 621*cdf0e10cSrcweir sResult.append(static_cast<sal_Unicode>('\\')); 622*cdf0e10cSrcweir sResult.append(*(++start)); 623*cdf0e10cSrcweir start++; 624*cdf0e10cSrcweir break; 625*cdf0e10cSrcweir // dump the ~ and escape the next characture 626*cdf0e10cSrcweir case ']': 627*cdf0e10cSrcweir sResult.append(static_cast<sal_Unicode>('\\')); 628*cdf0e10cSrcweir sResult.append(*start++); 629*cdf0e10cSrcweir break; 630*cdf0e10cSrcweir case '[': 631*cdf0e10cSrcweir sResult.append(*start++); 632*cdf0e10cSrcweir seenright = 0; 633*cdf0e10cSrcweir while (start < end && !seenright) 634*cdf0e10cSrcweir { 635*cdf0e10cSrcweir switch (*start) 636*cdf0e10cSrcweir { 637*cdf0e10cSrcweir case '[': 638*cdf0e10cSrcweir case '?': 639*cdf0e10cSrcweir case '*': 640*cdf0e10cSrcweir sResult.append(static_cast<sal_Unicode>('\\')); 641*cdf0e10cSrcweir sResult.append(*start); 642*cdf0e10cSrcweir break; 643*cdf0e10cSrcweir case ']': 644*cdf0e10cSrcweir sResult.append(*start); 645*cdf0e10cSrcweir seenright = 1; 646*cdf0e10cSrcweir break; 647*cdf0e10cSrcweir case '!': 648*cdf0e10cSrcweir sResult.append(static_cast<sal_Unicode>('^')); 649*cdf0e10cSrcweir break; 650*cdf0e10cSrcweir default: 651*cdf0e10cSrcweir if (NeedEsc(*start)) 652*cdf0e10cSrcweir sResult.append(static_cast<sal_Unicode>('\\')); 653*cdf0e10cSrcweir sResult.append(*start); 654*cdf0e10cSrcweir break; 655*cdf0e10cSrcweir } 656*cdf0e10cSrcweir start++; 657*cdf0e10cSrcweir } 658*cdf0e10cSrcweir break; 659*cdf0e10cSrcweir default: 660*cdf0e10cSrcweir if (NeedEsc(*start)) 661*cdf0e10cSrcweir sResult.append(static_cast<sal_Unicode>('\\')); 662*cdf0e10cSrcweir sResult.append(*start++); 663*cdf0e10cSrcweir } 664*cdf0e10cSrcweir } 665*cdf0e10cSrcweir 666*cdf0e10cSrcweir if ( bForLike ) 667*cdf0e10cSrcweir sResult.append(static_cast<sal_Unicode>('$')); 668*cdf0e10cSrcweir 669*cdf0e10cSrcweir return sResult.makeStringAndClear( ); 670*cdf0e10cSrcweir } 671*cdf0e10cSrcweir 672*cdf0e10cSrcweir double getPixelTo100thMillimeterConversionFactor( css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical) 673*cdf0e10cSrcweir { 674*cdf0e10cSrcweir double fConvertFactor = 1.0; 675*cdf0e10cSrcweir if( bVertical ) 676*cdf0e10cSrcweir { 677*cdf0e10cSrcweir fConvertFactor = xDevice->getInfo().PixelPerMeterY/100000; 678*cdf0e10cSrcweir } 679*cdf0e10cSrcweir else 680*cdf0e10cSrcweir { 681*cdf0e10cSrcweir fConvertFactor = xDevice->getInfo().PixelPerMeterX/100000; 682*cdf0e10cSrcweir } 683*cdf0e10cSrcweir return fConvertFactor; 684*cdf0e10cSrcweir } 685*cdf0e10cSrcweir 686*cdf0e10cSrcweir double PointsToPixels( css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical) 687*cdf0e10cSrcweir { 688*cdf0e10cSrcweir double fConvertFactor = getPixelTo100thMillimeterConversionFactor( xDevice, bVertical ); 689*cdf0e10cSrcweir return fPoints * POINTTO100THMILLIMETERFACTOR * fConvertFactor; 690*cdf0e10cSrcweir } 691*cdf0e10cSrcweir double PixelsToPoints( css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical) 692*cdf0e10cSrcweir { 693*cdf0e10cSrcweir double fConvertFactor = getPixelTo100thMillimeterConversionFactor( xDevice, bVertical ); 694*cdf0e10cSrcweir return (fPixels/fConvertFactor)/POINTTO100THMILLIMETERFACTOR; 695*cdf0e10cSrcweir } 696*cdf0e10cSrcweir 697*cdf0e10cSrcweir ConcreteXShapeGeometryAttributes::ConcreteXShapeGeometryAttributes( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::drawing::XShape >& xShape ) 698*cdf0e10cSrcweir { 699*cdf0e10cSrcweir m_xShape = new ScVbaShape( xContext, xShape ); 700*cdf0e10cSrcweir } 701*cdf0e10cSrcweir 702*cdf0e10cSrcweir #define VBA_LEFT "PositionX" 703*cdf0e10cSrcweir #define VBA_TOP "PositionY" 704*cdf0e10cSrcweir UserFormGeometryHelper::UserFormGeometryHelper( const uno::Reference< uno::XComponentContext >& /*xContext*/, const uno::Reference< awt::XControl >& xControl ) 705*cdf0e10cSrcweir { 706*cdf0e10cSrcweir mxModel.set( xControl->getModel(), uno::UNO_QUERY_THROW ); 707*cdf0e10cSrcweir } 708*cdf0e10cSrcweir double UserFormGeometryHelper::getLeft() 709*cdf0e10cSrcweir { 710*cdf0e10cSrcweir sal_Int32 nLeft = 0; 711*cdf0e10cSrcweir mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_LEFT ) ) ) >>= nLeft; 712*cdf0e10cSrcweir return Millimeter::getInPoints( nLeft ); 713*cdf0e10cSrcweir } 714*cdf0e10cSrcweir void UserFormGeometryHelper::setLeft( double nLeft ) 715*cdf0e10cSrcweir { 716*cdf0e10cSrcweir mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_LEFT ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nLeft ) ) ); 717*cdf0e10cSrcweir } 718*cdf0e10cSrcweir double UserFormGeometryHelper::getTop() 719*cdf0e10cSrcweir { 720*cdf0e10cSrcweir sal_Int32 nTop = 0; 721*cdf0e10cSrcweir mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_TOP ) ) ) >>= nTop; 722*cdf0e10cSrcweir return Millimeter::getInPoints( nTop ); 723*cdf0e10cSrcweir } 724*cdf0e10cSrcweir void UserFormGeometryHelper::setTop( double nTop ) 725*cdf0e10cSrcweir { 726*cdf0e10cSrcweir mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_TOP ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nTop ) ) ); 727*cdf0e10cSrcweir } 728*cdf0e10cSrcweir double UserFormGeometryHelper::getHeight() 729*cdf0e10cSrcweir { 730*cdf0e10cSrcweir sal_Int32 nHeight = 0; 731*cdf0e10cSrcweir mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLHGT ) ) ) >>= nHeight; 732*cdf0e10cSrcweir return Millimeter::getInPoints( nHeight ); 733*cdf0e10cSrcweir } 734*cdf0e10cSrcweir void UserFormGeometryHelper::setHeight( double nHeight ) 735*cdf0e10cSrcweir { 736*cdf0e10cSrcweir mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLHGT ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nHeight ) ) ); 737*cdf0e10cSrcweir } 738*cdf0e10cSrcweir double UserFormGeometryHelper::getWidth() 739*cdf0e10cSrcweir { 740*cdf0e10cSrcweir sal_Int32 nWidth = 0; 741*cdf0e10cSrcweir mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLWID ) ) ) >>= nWidth; 742*cdf0e10cSrcweir return Millimeter::getInPoints( nWidth ); 743*cdf0e10cSrcweir } 744*cdf0e10cSrcweir void UserFormGeometryHelper::setWidth( double nWidth) 745*cdf0e10cSrcweir { 746*cdf0e10cSrcweir mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLWID ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nWidth ) ) ); 747*cdf0e10cSrcweir } 748*cdf0e10cSrcweir 749*cdf0e10cSrcweir SfxItemSet* 750*cdf0e10cSrcweir ScVbaCellRangeAccess::GetDataSet( ScCellRangeObj* pRangeObj ) 751*cdf0e10cSrcweir { 752*cdf0e10cSrcweir SfxItemSet* pDataSet = pRangeObj ? pRangeObj->GetCurrentDataSet( true ) : NULL ; 753*cdf0e10cSrcweir return pDataSet; 754*cdf0e10cSrcweir 755*cdf0e10cSrcweir } 756*cdf0e10cSrcweir 757*cdf0e10cSrcweir } // vba 758*cdf0e10cSrcweir } // ooo 759