diff options
author | Noel Power <npower@openoffice.org> | 2009-09-18 15:24:22 +0000 |
---|---|---|
committer | Noel Power <npower@openoffice.org> | 2009-09-18 15:24:22 +0000 |
commit | dfc77d75e1bbf9ff8b9ad43d1d79caee38f927f0 (patch) | |
tree | a48f7ee96890d25edf0242b641511fc7fa5dd2ff /sc/source/ui | |
parent | 4694e90c500d8cd3782bb374a1d76781e8f41f4a (diff) |
initial commit of code reorg, existing files that are modified
Diffstat (limited to 'sc/source/ui')
96 files changed, 1122 insertions, 3150 deletions
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index c8a41e81497d..df7cb24e605f 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -128,7 +128,8 @@ #include <rtl/logfile.hxx> #include <comphelper/processfactory.hxx> - +#include <basic/sbstar.hxx> +#include <basic/basmgr.hxx> using namespace com::sun::star; // STATIC DATA ----------------------------------------------------------- @@ -358,7 +359,16 @@ void ScDocShell::AfterXMLLoading(sal_Bool bRet) } else aDocument.SetInsertingFromOtherDoc( FALSE ); - + // add vba globals ( if they are availabl ) + SfxObjectShell* pShell = aDocument.GetDocumentShell(); + if ( pShell ) + { + uno::Any aGlobs; + uno::Sequence< uno::Any > aArgs(1); + aArgs[ 0 ] <<= pShell->GetModel(); + aGlobs <<= ::comphelper::getProcessServiceFactory()->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.Globals" ) ), aArgs ); + pShell->GetBasicManager()->SetGlobalUNOConstant( "VBAGlobals", aGlobs ); + } aDocument.SetImportingXML( FALSE ); aDocument.EnableExecuteLink( true ); aDocument.EnableUndo( TRUE ); diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx index fe5da618e895..9ec5ce507209 100644 --- a/sc/source/ui/inc/tabview.hxx +++ b/sc/source/ui/inc/tabview.hxx @@ -292,7 +292,7 @@ public: void TabChanged(); void SetZoom( const Fraction& rNewX, const Fraction& rNewY, BOOL bAll ); - void RefreshZoom(); + SC_DLLPUBLIC void RefreshZoom(); void SetPagebreakMode( BOOL bSet ); void UpdateLayerLocks(); diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx index 709bd7898e22..dc2fe4522ecd 100644 --- a/sc/source/ui/inc/viewdata.hxx +++ b/sc/source/ui/inc/viewdata.hxx @@ -225,6 +225,7 @@ private: SC_DLLPRIVATE void CalcPPT(); SC_DLLPRIVATE void CreateTabData( SCTAB nNewTab ); + SC_DLLPRIVATE void CreateTabData( std::vector< SCTAB >& rvTabs ); SC_DLLPRIVATE void CreateSelectedTabData(); public: @@ -311,6 +312,8 @@ public: void SetPagebreakMode( BOOL bSet ); void SetZoomType( SvxZoomType eNew, BOOL bAll ); + void SetZoomType( SvxZoomType eNew, std::vector< SCTAB >& tabs ); + void SetZoom( const Fraction& rNewX, const Fraction& rNewY, std::vector< SCTAB >& tabs ); void SetZoom( const Fraction& rNewX, const Fraction& rNewY, BOOL bAll ); void RefreshZoom(); diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index cd63adc33989..0e6a1f7ca49a 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -102,6 +102,7 @@ using namespace com::sun::star; +#define SC_UNO_VBADOCOBJ "ThisVBADocObj" // perhaps we want to actually make this ThisWorkbook ? //------------------------------------------------------------------------ // alles ohne Which-ID, Map nur fuer PropertySetInfo @@ -116,6 +117,7 @@ const SfxItemPropertyMapEntry* lcl_GetDocOptPropertyMap() {MAP_CHAR_LEN(SC_UNO_AUTOCONTFOC), 0, &getBooleanCppuType(), 0, 0}, {MAP_CHAR_LEN(SC_UNO_BASICLIBRARIES), 0, &getCppuType((uno::Reference< script::XLibraryContainer >*)0), beans::PropertyAttribute::READONLY, 0}, {MAP_CHAR_LEN(SC_UNO_DIALOGLIBRARIES), 0, &getCppuType((uno::Reference< script::XLibraryContainer >*)0), beans::PropertyAttribute::READONLY, 0}, + {MAP_CHAR_LEN(SC_UNO_VBADOCOBJ), 0, &getCppuType((beans::PropertyValue*)0), beans::PropertyAttribute::READONLY, 0}, {MAP_CHAR_LEN(SC_UNO_CALCASSHOWN), PROP_UNO_CALCASSHOWN, &getBooleanCppuType(), 0, 0}, {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), 0, &getCppuType((lang::Locale*)0), 0, 0}, {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), 0, &getCppuType((lang::Locale*)0), 0, 0}, @@ -1568,6 +1570,13 @@ uno::Any SAL_CALL ScModelObj::getPropertyValue( const rtl::OUString& aPropertyNa { aRet <<= pDocShell->GetDialogContainer(); } + else if ( aString.EqualsAscii( SC_UNO_VBADOCOBJ ) ) + { + beans::PropertyValue aProp; + aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ThisExcelDoc") ); + aProp.Value <<= pDocShell->GetModel(); + aRet <<= aProp; + } else if ( aString.EqualsAscii( SC_UNO_RUNTIMEUID ) ) { aRet <<= getRuntimeUID(); @@ -1771,6 +1780,12 @@ sal_Int64 SAL_CALL ScModelObj::getSomething( return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); } + if ( rId.getLength() == 16 && + 0 == rtl_compareMemory( SfxObjectShell::getUnoTunnelId().getConstArray(), + rId.getConstArray(), 16 ) ) + { + return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(pDocShell )); + } // aggregated number formats supplier has XUnoTunnel, too // interface from aggregated object must be obtained via queryAggregation diff --git a/sc/source/ui/vba/helperdecl.hxx b/sc/source/ui/vba/helperdecl.hxx index 95569a993b9c..9c37d418a561 100644 --- a/sc/source/ui/vba/helperdecl.hxx +++ b/sc/source/ui/vba/helperdecl.hxx @@ -32,107 +32,25 @@ namespace comphelper { namespace service_decl { - -namespace detail { -namespace css = ::com::sun::star; -template <typename ImplT> -class OwnServiceImpl - : public ImplT, - private ::boost::noncopyable -{ - typedef ImplT BaseT; - -public: - OwnServiceImpl( - ServiceDecl const& rServiceDecl, - css::uno::Sequence<css::uno::Any> const& args, - css::uno::Reference<css::uno::XComponentContext> const& xContext ) - :BaseT(args, xContext), m_rServiceDecl(rServiceDecl) {} - OwnServiceImpl( - ServiceDecl const& rServiceDecl, - css::uno::Reference<css::uno::XComponentContext> const& xContext ) - : BaseT(xContext), m_rServiceDecl(rServiceDecl) {} - - // XServiceInfo - virtual ::rtl::OUString SAL_CALL getImplementationName() - throw (css::uno::RuntimeException) { - return m_rServiceDecl.getImplementationName(); - } - virtual sal_Bool SAL_CALL supportsService( ::rtl::OUString const& name ) - throw (css::uno::RuntimeException) { - return m_rServiceDecl.supportsService(name); - } - virtual css::uno::Sequence< ::rtl::OUString> - SAL_CALL getSupportedServiceNames() throw (css::uno::RuntimeException) { - return m_rServiceDecl.getSupportedServiceNames(); - } - -private: - ServiceDecl const& m_rServiceDecl; -}; - - -template <typename ImplT, typename WithArgsT> -struct OwnCreateFunc; - -template <typename ImplT> -struct OwnCreateFunc<ImplT, with_args<false> > { - explicit OwnCreateFunc( ) - {} - - css::uno::Reference<css::uno::XInterface> - operator()( ServiceDecl const& rServiceDecl, - css::uno::Sequence<css::uno::Any> const&, - css::uno::Reference<css::uno::XComponentContext> - const& xContext ) const - { - return css::uno::Reference< ooo::vba::XHelperInterface >(new OwnServiceImpl<ImplT>( rServiceDecl, xContext )); - } -}; - -template <typename ImplT> -struct OwnCreateFunc<ImplT, with_args<true> > { - explicit OwnCreateFunc( ) - {} - - css::uno::Reference<css::uno::XInterface> - operator()( ServiceDecl const& rServiceDecl, - css::uno::Sequence<css::uno::Any> const& args, - css::uno::Reference<css::uno::XComponentContext> - const& xContext ) const - { - css::uno::Reference< ooo::vba::XHelperInterface > xHelp( - new OwnServiceImpl<ImplT>( rServiceDecl, args, xContext ) ); - css::uno::Reference< css::uno::XInterface > xIf( xHelp, css::uno::UNO_QUERY ) ; - return xIf; - } -}; - -} // namespace detail - -/** Defines a service implementation class. - - @tpl ImplT_ service implementation class - @WithArgsT whether the implementation class ctor expects arguments - (uno::Sequence<uno::Any>, uno::Reference<uno::XComponentContext>) - or just (uno::Reference<uno::XComponentContext>) -*/ template <typename ImplT_, typename WithArgsT = with_args<false> > -struct vba_service_class_ { - typedef ImplT_ ImplT; - typedef detail::OwnServiceImpl<ImplT_ > ServiceImplT; - - detail::CreateFuncF const m_createFunc; - +struct vba_service_class_ : public serviceimpl_base< detail::OwnServiceImpl<ImplT_>, WithArgsT > +{ + typedef serviceimpl_base< detail::OwnServiceImpl<ImplT_>, WithArgsT > baseT; /** Default ctor. Implementation class without args, expecting component context as single argument. */ - vba_service_class_() : m_createFunc( - detail::OwnCreateFunc<ImplT, WithArgsT>() ) {} - + vba_service_class_() : baseT() {} + template <typename PostProcessFuncT> + /** Ctor to pass a post processing function/functor. + + @tpl PostProcessDefaultT let your compiler deduce this + @param postProcessFunc function/functor that gets the yet unacquired + ImplT_ pointer returning a + uno::Reference<uno::XInterface> + */ + explicit vba_service_class_( PostProcessFuncT const& postProcessFunc ) : baseT( postProcessFunc ) {} }; - } // namespace service_decl } // namespace comphelper diff --git a/sc/source/ui/vba/makefile.mk b/sc/source/ui/vba/makefile.mk index fb1cc00488b8..e07d5fdcb7e3 100644 --- a/sc/source/ui/vba/makefile.mk +++ b/sc/source/ui/vba/makefile.mk @@ -64,7 +64,7 @@ SLOFILES= \ $(SLO)$/vbaworksheet.obj \ $(SLO)$/vbaoutline.obj \ $(SLO)$/vbafont.obj\ - $(SLO)$/vbahelper.obj\ + $(SLO)$/excelvbahelper.obj\ $(SLO)$/vbainterior.obj\ $(SLO)$/vbawsfunction.obj\ $(SLO)$/vbawindow.obj\ @@ -81,28 +81,11 @@ SLOFILES= \ $(SLO)$/vbapalette.obj \ $(SLO)$/vbaborders.obj \ $(SLO)$/vbacharacters.obj \ - $(SLO)$/vbacombobox.obj \ $(SLO)$/vbavalidation.obj \ - $(SLO)$/vbacontrol.obj \ - $(SLO)$/vbacontrols.obj \ $(SLO)$/vbaoleobject.obj \ $(SLO)$/vbaoleobjects.obj \ - $(SLO)$/vbabutton.obj \ - $(SLO)$/vbalabel.obj \ - $(SLO)$/vbatextbox.obj \ $(SLO)$/vbatextboxshape.obj \ - $(SLO)$/vbaradiobutton.obj \ - $(SLO)$/vbalistbox.obj \ - $(SLO)$/vbalistcontrolhelper.obj \ - $(SLO)$/vbapropvalue.obj \ $(SLO)$/vbapane.obj \ - $(SLO)$/vbashape.obj \ - $(SLO)$/vbacolorformat.obj \ - $(SLO)$/vbashapes.obj \ - $(SLO)$/vbalineformat.obj \ - $(SLO)$/vbafillformat.obj \ - $(SLO)$/vbapictureformat.obj \ - $(SLO)$/vbashaperange.obj \ $(SLO)$/vbatextframe.obj \ $(SLO)$/vbacharttitle.obj \ $(SLO)$/vbacharts.obj \ @@ -116,24 +99,10 @@ SLOFILES= \ $(SLO)$/vbastyle.obj \ $(SLO)$/vbastyles.obj \ $(SLO)$/vbaassistant.obj \ - $(SLO)$/vbauserform.obj \ - $(SLO)$/vbacheckbox.obj \ - $(SLO)$/vbatogglebutton.obj \ - $(SLO)$/vbaframe.obj \ - $(SLO)$/vbascrollbar.obj \ - $(SLO)$/vbaprogressbar.obj \ - $(SLO)$/vbamultipage.obj \ - $(SLO)$/vbapages.obj \ - $(SLO)$/vbacommandbarcontrol.obj \ - $(SLO)$/vbacommandbarcontrols.obj \ - $(SLO)$/vbacommandbar.obj \ - $(SLO)$/vbacommandbars.obj \ $(SLO)$/vbahyperlink.obj \ $(SLO)$/vbapagesetup.obj \ $(SLO)$/vbapagebreak.obj \ $(SLO)$/vbapagebreaks.obj \ - $(SLO)$/vbaspinbutton.obj \ - $(SLO)$/vbaimage.obj \ $(SLO)$/service.obj # --- Targets ------------------------------------------------------ diff --git a/sc/source/ui/vba/service.cxx b/sc/source/ui/vba/service.cxx index 53ed2d3bebcb..6286b6873321 100644 --- a/sc/source/ui/vba/service.cxx +++ b/sc/source/ui/vba/service.cxx @@ -61,11 +61,15 @@ namespace globals { extern sdecl::ServiceDecl const serviceDecl; } -namespace userform +namespace hyperlink { extern sdecl::ServiceDecl const serviceDecl; } -namespace hyperlink +namespace application +{ +extern sdecl::ServiceDecl const serviceDecl; +} +namespace textframe { extern sdecl::ServiceDecl const serviceDecl; } @@ -83,10 +87,10 @@ extern "C" lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey ) { OSL_TRACE("In component_writeInfo"); - +#if 0 // Component registration if ( component_writeInfoHelper( pServiceManager, pRegistryKey, - range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, userform::serviceDecl, window::serviceDecl, hyperlink::serviceDecl ) ) + range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl ) ) { // Singleton registration try @@ -106,6 +110,12 @@ extern "C" } } return sal_False; +#else + // Component registration + return component_writeInfoHelper( pServiceManager, pRegistryKey, + range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl ) && component_writeInfoHelper( pServiceManager, pRegistryKey, textframe::serviceDecl ); +#endif + } SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( @@ -114,7 +124,9 @@ extern "C" { OSL_TRACE("In component_getFactory for %s", pImplName ); void* pRet = component_getFactoryHelper( - pImplName, pServiceManager, pRegistryKey, range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, userform::serviceDecl, window::serviceDecl, hyperlink::serviceDecl ); + pImplName, pServiceManager, pRegistryKey, range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl ); + if( !pRet ) + pRet = component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, textframe::serviceDecl ); OSL_TRACE("Ret is 0x%x", pRet); return pRet; } diff --git a/sc/source/ui/vba/testvba/TestDocuments/Ranges.xls b/sc/source/ui/vba/testvba/TestDocuments/Ranges.xls Binary files differindex 3abdc4620aa8..1c1d74d37486 100644 --- a/sc/source/ui/vba/testvba/TestDocuments/Ranges.xls +++ b/sc/source/ui/vba/testvba/TestDocuments/Ranges.xls diff --git a/sc/source/ui/vba/testvba/TestDocuments/TestAddress.xls b/sc/source/ui/vba/testvba/TestDocuments/TestAddress.xls Binary files differindex 1834bd649f3d..48d30cbe2e9e 100644 --- a/sc/source/ui/vba/testvba/TestDocuments/TestAddress.xls +++ b/sc/source/ui/vba/testvba/TestDocuments/TestAddress.xls diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/Ranges.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/Ranges.log index dd4fb4923209..cdd18685e977 100644 --- a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/Ranges.log +++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/Ranges.log @@ -1,4 +1,4 @@ -Test run started : 17/12/2008 14:18:34 +Test run started : 10/03/2008 15:15:11 ---------------------------------------------------------------- ApplicationMethods TEST START : ApplicationMethods @@ -7,8 +7,8 @@ ApplicationMethods ITEM Assertion OK : Address of Application.Rows is: $1:$1 ITEM Assertion OK : Address of Application.Range is: $1:$1,$5:$7 ITEM Assertion OK : Please check manually: DefaultFilePath is: /data4/home/npower/Documents - ITEM Assertion OK : Please check manually: Library Path is: /media/disk/BUILD-related/CWS/my_working_copy/INSTALL_FOR_TEST/opt/UserInstallation/user/basic - ITEM Assertion OK : Please check manually: Template Path is: /media/disk/BUILD-related/CWS/my_working_copy/INSTALL_FOR_TEST/opt/UserInstallation/user/template + ITEM Assertion OK : Please check manually: Library Path is: /data4/home/npower/.ooo-2.0/user/basic + ITEM Assertion OK : Please check manually: Template Path is: /data4/home/npower/.ooo-2.0/user/template ITEM Assertion OK : FileSeparator is / ITEM Assertion OK : Name of ActiveWorkbook is: Ranges.xls END 'ApplicationMethods' Symbol @@ -111,8 +111,8 @@ END 'Value-Issue' Symbol ---------------------------------------------------------------- AutoFit issue TEST START : AutoFit issue - ITEM Assertion OK : Columns.AutoFit: CurrentWidth is 679 - ITEM Assertion OK : Rows.AutoFit: CurrentHeight is 546 + ITEM Assertion OK : Columns.AutoFit: CurrentWidth is 680 + ITEM Assertion OK : Rows.AutoFit: CurrentHeight is 554 END 'AutoFit issue' Symbol TEST OK : AutoFit issue ---------------------------------------------------------------- @@ -204,11 +204,11 @@ Heights and Widths ITEM Assertion OK : Range RowHeight is 40 ITEM Assertion OK : Range ColumnWidth is 50 ITEM Assertion OK : Range Height is 240 - ITEM Assertion OK : Range Width is 787.5 + ITEM Assertion OK : Range Width is 795 ITEM Assertion OK : Range RowHeight is 50 ITEM Assertion OK : Range ColumnWidth is 50 ITEM Assertion OK : Range Height is 300 - ITEM Assertion OK : Range Width is 787.5 + ITEM Assertion OK : Range Width is 795 ITEM Assertion OK : RowHeight is null: True ITEM Assertion OK : ColumnWidth is null: True END 'Heights and Widths' Symbol @@ -218,7 +218,7 @@ RangeRowColumn-Issue TEST START : RangeRowColumn-Issue ITEM Assertion OK : Row is: 8 ITEM Assertion OK : Column is: 5 - ITEM Assertion OK : EntireRow.Columns.Count = 1024 + ITEM Assertion OK : EntireRow.Columns.Count = 256 ITEM Assertion OK : EntireColumn.Rows.Count = 131072 END 'RangeRowColumn-Issue' Symbol TEST OK : RangeRowColumn-Issue @@ -255,7 +255,7 @@ End issue ITEM Assertion OK : - = $E$3 ITEM Assertion OK : - = $A$8 ITEM Assertion OK : - = $B$8 - ITEM Assertion FAIL : - = $AMJ$8 + ITEM Assertion OK : - = $IV$8 ITEM Assertion OK : - = $Z$8 END 'End issue' Symbol TEST OK : End issue @@ -277,4 +277,4 @@ Validation ITEM Assertion OK : Validation Error Title is : Microsoft Excel END 'Validation' Symbol TEST OK : Validation -Test run finished : 17/12/2008 14:18:40 +Test run finished : 10/03/2008 15:15:13 diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/TestAddress.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/TestAddress.log index 42360c3ffe8a..4fa4bc820f59 100644 --- a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/TestAddress.log +++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/TestAddress.log @@ -1,4 +1,4 @@ -Test run started : 17/07/2007 20:56:04 +Test run started : 12/05/2009 11:23:35 ---------------------------------------------------------------- TestAddress TEST START : TestAddress @@ -51,12 +51,17 @@ TestAddress ITEM Assertion OK : test47 Range('a2:b4').Rows('1:2') ITEM Assertion OK : test48 Range('a2:b4').Rows('2:2') ITEM Assertion OK : test49 Range('a2:b4').Rows('2:3') + ITEM Assertion OK : test50 Range(' A2:B4 ') + ITEM Assertion OK : test51 Range('A 2:B 4') + ITEM Assertion OK : test52 Range('A2 : B4 ') + ITEM Assertion OK : test53 Range('Sheet1 !A2 : B4 ') + ITEM Assertion OK : test54 Range('Sheet1! A2 : B4 ') Test Results ============ -Tests passed: 49 +Tests passed: 54 Tests failed: 0 END 'TestAddress TEST OK : TestAddress -Test run finished : 17/07/2007 20:56:05 +Test run finished : 12/05/2009 11:23:35 diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/format.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/format.log index 50fac171544b..96725bf7daa8 100644 --- a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/format.log +++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/format.log @@ -1,4 +1,4 @@ -Test run started : 17/12/2008 14:15:22 +Test run started : 2008/09/18 11:35:34 BEGIN Format TEST START : Test Predefined_Number_Format_Sample function ITEM Assertion OK : General Number: 562486.2356 @@ -33,4 +33,4 @@ BEGIN Format ITEM Assertion OK : >: VBA TEST OK : Test Custom_Text_Format_Sample function END Format -Test run finished : 17/12/2008 14:15:22 +Test run finished : 2008/09/18 11:35:34 diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/replace.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/replace.log index 461955dc2402..8f600faaa6b1 100644 --- a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/replace.log +++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/replace.log @@ -1,4 +1,4 @@ -Test run started : 17/12/2008 13:53:49 +Test run started : 09/05/2008 10:21:46 AM BEGIN Replace TEST START : Test Replace function ITEM Assertion OK : common string:aefefdBc @@ -11,4 +11,4 @@ BEGIN Replace ITEM Assertion OK : start = 1, count = 0, not support in Unix: abcbcdBc TEST OK : Test Replace function END Replace -Test run finished : 17/12/2008 13:53:49 +Test run finished : 09/05/2008 10:21:47 AM diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/window2.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/window2.log index 5d297f80a152..8e26d0580621 100644 --- a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/window2.log +++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/window2.log @@ -1,20 +1,15 @@ -Test run started : 05/29/2008 02:55:48 PM +Test run started : 2008/09/22 11:18:57 BEGIN Window2 TEST START : Test Window.SplitRow - ITEM Assertion OK : Test SplitColumn: 2 - ITEM Assertion FAIL : Test SplitRow: 5 - ITEM Assertion FAIL : Test SplitVertical: 64.5090003183026 - ITEM Assertion OK : Test SplitHorizontal: 502.570118758869 - ITEM Assertion OK : Test SplitVertical: 242.283803521067 - ITEM Assertion OK : Test SplitRow: 19 - ITEM Assertion OK : Test SplitHorizontal: 242.283803521067 - ITEM Assertion OK : Test SplitColumn: 1 - ITEM Assertion FAIL : Test SplitRow: 8 - ITEM Assertion OK : Test SplitColumn: 10 + ITEM Assertion OK : Test SplitColumn: 2 (Test only applies to maximized Window and at least has 800*600 solotion) + ITEM Assertion OK : Test SplitRow: 2 (Test only applies to maximized Window and at least has 800*600 solotion) + ITEM Assertion OK : Test SplitVertical: 242.465788476212 + ITEM Assertion OK : Test SplitHorizontal: 242.465788476212 + ITEM Assertion OK : Test SplitRow: 4 (Test only applies to maximized Window and at least has 800*600 solotion) + ITEM Assertion OK : Test SplitColumn: 3 (Test only applies to maximized Window and at least has 800*600 solotion) ITEM Assertion OK : Test SplitColumn: 0 ITEM Assertion OK : Test SplitRow: 0 TEST OK : Test Window.SplitRow -TEST ERROR - no test begun: Test Window.SplitRow TEST START : Test Window.DisplayGridlines ITEM Assertion OK : Test gridlines are on ITEM Assertion OK : Test gridlines are off @@ -25,7 +20,8 @@ TEST ERROR - no test begun: Test Window.SplitRow TEST OK : Test Window.DisplayHeadings TEST START : Test Window.Visibility ITEM Assertion OK : Window is visible - TEST FAIL : Test Window.Visibility (hit error handler). + ITEM Assertion OK : Window is not visible + TEST OK : Test Window.Visibility TEST START : Test Window.FreezePanes ITEM Assertion OK : Test no panes frozen ITEM Assertion OK : Test panes frozen at center @@ -42,4 +38,4 @@ TEST ERROR - no test begun: Test Window.SplitRow ITEM Assertion OK : Application.Windows Count: 1 TEST OK : Test Windows.Count END Window2 -Test run finished : 05/29/2008 02:55:48 PM +Test run finished : 2008/09/22 11:18:58 diff --git a/sc/source/ui/vba/testvba/TestDocuments/window2.xls b/sc/source/ui/vba/testvba/TestDocuments/window2.xls Binary files differindex 1bb2cd5a67da..4d5e1cbfe944 100755 --- a/sc/source/ui/vba/testvba/TestDocuments/window2.xls +++ b/sc/source/ui/vba/testvba/TestDocuments/window2.xls diff --git a/sc/source/ui/vba/testvba/runTests.pl b/sc/source/ui/vba/testvba/runTests.pl index 8f8f329504c0..f5051516a9c4 100644 --- a/sc/source/ui/vba/testvba/runTests.pl +++ b/sc/source/ui/vba/testvba/runTests.pl @@ -20,7 +20,7 @@ my $theResult; my $officepath = shift || die "please specify path to office installation program dir"; my $DocName = shift || ""; my $programpath = "$officepath"."3/program:$officepath/program:"; -my $basiclibrarypath = "$officepath/basis3.1/program"; +my $basiclibrarypath = "$officepath/basis3.2/program"; my $urelibpath = "$officepath/ure/lib"; my $binext = ""; my $testDocDir = "$binDir/TestDocuments"; diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx index 32ed5f9e0af2..880a691701ff 100644 --- a/sc/source/ui/vba/vbaapplication.cxx +++ b/sc/source/ui/vba/vbaapplication.cxx @@ -57,10 +57,9 @@ #include "tabvwsh.hxx" #include "gridwin.hxx" #include "vbanames.hxx" -#include "vbashape.hxx" +#include <vbahelper/vbashape.hxx> #include "vbatextboxshape.hxx" #include "vbaassistant.hxx" -#include "vbacommandbars.hxx" #include "sc.hrc" #include <osl/file.hxx> @@ -85,6 +84,9 @@ #include "convuno.hxx" #include "cellsuno.hxx" #include "docsh.hxx" +#include <vbahelper/helperdecl.hxx> +#include "excelvbahelper.hxx" + using namespace ::ooo::vba; using namespace ::com::sun::star; @@ -102,20 +104,20 @@ using namespace ::com::sun::star; #define FILE_PATH_SEPERATOR "\\" #endif -#define EXCELVERSION "11.0" +uno::Any sbxToUnoValue( SbxVariable* pVar ); class ActiveWorkbook : public ScVbaWorkbook { protected: virtual uno::Reference< frame::XModel > getModel() { - return getCurrentDocument(); + return getCurrentExcelDoc(mxContext); } public: ActiveWorkbook( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext) : ScVbaWorkbook( xParent, xContext ){} }; -ScVbaApplication::ScVbaApplication( uno::Reference<uno::XComponentContext >& xContext ): ScVbaApplication_BASE( uno::Reference< XHelperInterface >(), xContext ), m_xCalculation( excel::XlCalculation::xlCalculationAutomatic ) +ScVbaApplication::ScVbaApplication( const uno::Reference<uno::XComponentContext >& xContext ): ScVbaApplication_BASE( xContext ), m_xCalculation( excel::XlCalculation::xlCalculationAutomatic ) { } @@ -123,7 +125,10 @@ ScVbaApplication::~ScVbaApplication() { } - +SfxObjectShell* ScVbaApplication::GetDocShell( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) +{ + return static_cast< SfxObjectShell* >( excel::getDocShell( xModel ) ); +} uno::Reference< excel::XWorkbook > ScVbaApplication::getActiveWorkbook() throw (uno::RuntimeException) @@ -143,23 +148,15 @@ ScVbaApplication::getAssistant() throw (uno::RuntimeException) } uno::Any SAL_CALL -ScVbaApplication::CommandBars( const uno::Any& aIndex ) throw (uno::RuntimeException) -{ - uno::Reference< XCommandBars > xCommandBars( new ScVbaCommandBars( this, mxContext, uno::Reference< container::XIndexAccess >() ) ); - if( aIndex.hasValue() ) - return uno::makeAny( xCommandBars->Item( aIndex, uno::Any() ) ); - return uno::makeAny( xCommandBars ); -} - -uno::Any SAL_CALL ScVbaApplication::getSelection() throw (uno::RuntimeException) { OSL_TRACE("** ScVbaApplication::getSelection() ** "); - uno::Reference< lang::XServiceInfo > xServiceInfo( getCurrentDocument()->getCurrentSelection(), uno::UNO_QUERY_THROW ); + uno::Reference< frame::XModel > xModel( getCurrentDocument() ); + uno::Reference< lang::XServiceInfo > xServiceInfo( xModel->getCurrentController(), uno::UNO_QUERY_THROW ); rtl::OUString sImpementaionName = xServiceInfo->getImplementationName(); if( sImpementaionName.equalsIgnoreAsciiCaseAscii("com.sun.star.drawing.SvxShapeCollection") ) { - uno::Reference< drawing::XShapes > xShapes( getCurrentDocument()->getCurrentSelection(), uno::UNO_QUERY_THROW ); + uno::Reference< drawing::XShapes > xShapes( xModel->getCurrentSelection(), uno::UNO_QUERY_THROW ); uno::Reference< container::XIndexAccess > xIndexAccess( xShapes, uno::UNO_QUERY_THROW ); uno::Reference< drawing::XShape > xShape( xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW ); // if ScVbaShape::getType( xShape ) == office::MsoShapeType::msoAutoShape @@ -170,10 +167,10 @@ ScVbaApplication::getSelection() throw (uno::RuntimeException) uno::Reference< lang::XServiceInfo > xShapeServiceInfo( xShape, uno::UNO_QUERY_THROW ); if ( xShapeServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.Text" ) ) ) ) { - return uno::makeAny( uno::Reference< msforms::XTextBoxShape >(new ScVbaTextBoxShape( mxContext, xShape, xShapes, getCurrentDocument() ) ) ); + return uno::makeAny( uno::Reference< msforms::XTextBoxShape >(new ScVbaTextBoxShape( mxContext, xShape, xShapes, xModel ) ) ); } } - return uno::makeAny( uno::Reference< msforms::XShape >(new ScVbaShape( this, mxContext, xShape, xShapes, ScVbaShape::getType( xShape ) ) ) ); + return uno::makeAny( uno::Reference< msforms::XShape >(new ScVbaShape( this, mxContext, xShape, xShapes, xModel, ScVbaShape::getType( xShape ) ) ) ); } else if( xServiceInfo->supportsService( rtl::OUString::createFromAscii("com.sun.star.sheet.SheetCellRange")) || xServiceInfo->supportsService( rtl::OUString::createFromAscii("com.sun.star.sheet.SheetCellRanges"))) @@ -199,7 +196,7 @@ ScVbaApplication::getActiveCell() throw (uno::RuntimeException ) { uno::Reference< sheet::XSpreadsheetView > xView( getCurrentDocument()->getCurrentController(), uno::UNO_QUERY_THROW ); uno::Reference< table::XCellRange > xRange( xView->getActiveSheet(), ::uno::UNO_QUERY_THROW); - ScTabViewShell* pViewShell = getCurrentBestViewShell(); + ScTabViewShell* pViewShell = excel::getCurrentBestViewShell(mxContext); if ( !pViewShell ) throw uno::RuntimeException( rtl::OUString::createFromAscii("No ViewShell available"), uno::Reference< uno::XInterface >() ); ScViewData* pTabView = pViewShell->GetViewData(); @@ -212,65 +209,6 @@ ScVbaApplication::getActiveCell() throw (uno::RuntimeException ) return new ScVbaRange( this, mxContext, xRange->getCellRangeByPosition( nCursorX, nCursorY, nCursorX, nCursorY ) ); } -sal_Bool -ScVbaApplication::getScreenUpdating() throw (uno::RuntimeException) -{ - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - return !xModel->hasControllersLocked(); -} - -void -ScVbaApplication::setScreenUpdating(sal_Bool bUpdate) throw (uno::RuntimeException) -{ - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - if (bUpdate) - xModel->unlockControllers(); - else - xModel->lockControllers(); -} - -sal_Bool -ScVbaApplication::getDisplayStatusBar() throw (uno::RuntimeException) -{ - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - uno::Reference< frame::XFrame > xFrame( xModel->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW ); - uno::Reference< beans::XPropertySet > xProps( xFrame, uno::UNO_QUERY_THROW ); - - if( xProps.is() ){ - uno::Reference< frame::XLayoutManager > xLayoutManager( xProps->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LayoutManager")) ), uno::UNO_QUERY_THROW ); - rtl::OUString url(RTL_CONSTASCII_USTRINGPARAM( "private:resource/statusbar/statusbar" )); - if( xLayoutManager.is() && xLayoutManager->isElementVisible( url ) ){ - return sal_True; - } - } - return sal_False; -} - -void -ScVbaApplication::setDisplayStatusBar(sal_Bool bDisplayStatusBar) throw (uno::RuntimeException) -{ - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - uno::Reference< frame::XFrame > xFrame( xModel->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW ); - uno::Reference< beans::XPropertySet > xProps( xFrame, uno::UNO_QUERY_THROW ); - - if( xProps.is() ){ - uno::Reference< frame::XLayoutManager > xLayoutManager( xProps->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LayoutManager")) ), uno::UNO_QUERY_THROW ); - rtl::OUString url(RTL_CONSTASCII_USTRINGPARAM( "private:resource/statusbar/statusbar" )); - if( xLayoutManager.is() ){ - if( bDisplayStatusBar && !xLayoutManager->isElementVisible( url ) ){ - if( !xLayoutManager->showElement( url ) ) - xLayoutManager->createElement( url ); - return; - } - else if( !bDisplayStatusBar && xLayoutManager->isElementVisible( url ) ){ - xLayoutManager->hideElement( url ); - return; - } - } - } - return; -} - uno::Any SAL_CALL ScVbaApplication::Workbooks( const uno::Any& aIndex ) throw (uno::RuntimeException) { @@ -319,7 +257,7 @@ ScVbaApplication::Evaluate( const ::rtl::OUString& Name ) throw (uno::RuntimeExc uno::Any ScVbaApplication::Dialogs( const uno::Any &aIndex ) throw (uno::RuntimeException) { - uno::Reference< excel::XDialogs > xDialogs( new ScVbaDialogs( uno::Reference< XHelperInterface >( ScVbaGlobals::getGlobalsImpl( mxContext )->getApplication(), uno::UNO_QUERY_THROW ), mxContext ) ); + uno::Reference< excel::XDialogs > xDialogs( new ScVbaDialogs( uno::Reference< XHelperInterface >( this ), mxContext, getCurrentDocument() ) ); if( !aIndex.hasValue() ) return uno::Any( xDialogs ); return uno::Any( xDialogs->Item( aIndex ) ); @@ -341,12 +279,6 @@ ScVbaApplication::getCutCopyMode() throw (uno::RuntimeException) return result; } -::rtl::OUString -ScVbaApplication::getVersion() throw (uno::RuntimeException) -{ - return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(EXCELVERSION)); -} - void SAL_CALL ScVbaApplication::setCutCopyMode( const uno::Any& /*_cutcopymode*/ ) throw (uno::RuntimeException) { @@ -432,7 +364,7 @@ ScVbaApplication::setCalculation( ::sal_Int32 _calculation ) throw (uno::Runtime uno::Any SAL_CALL ScVbaApplication::Windows( const uno::Any& aIndex ) throw (uno::RuntimeException) { - uno::Reference< XCollection > xWindows = ScVbaWindows::Windows( mxContext ); + uno::Reference< excel::XWindows > xWindows( new ScVbaWindows( this, mxContext ) ); if ( aIndex.getValueTypeClass() == uno::TypeClass_VOID ) return uno::Any( xWindows ); return uno::Any( xWindows->Item( aIndex, uno::Any() ) ); @@ -543,11 +475,11 @@ ScVbaApplication::GoTo( const uno::Any& Reference, const uno::Any& Scroll ) thro xModel->getCurrentController(), uno::UNO_QUERY_THROW ); uno::Reference< sheet::XSpreadsheet > xDoc = xSpreadsheet->getActiveSheet(); - ScTabViewShell* pShell = getCurrentBestViewShell(); + ScTabViewShell* pShell = excel::getCurrentBestViewShell( mxContext ); ScGridWindow* gridWindow = (ScGridWindow*)pShell->GetWindow(); try { - uno::Reference< excel::XRange > xVbaSheetRange = ScVbaRange::getRangeObjectForName( mxContext, sRangeName, getDocShell( xModel ), formula::FormulaGrammar::CONV_XL_R1C1 ); + uno::Reference< excel::XRange > xVbaSheetRange = ScVbaRange::getRangeObjectForName( mxContext, sRangeName, excel::getDocShell( xModel ), formula::FormulaGrammar::CONV_XL_R1C1 ); ; if( bScroll ) { @@ -585,7 +517,7 @@ ScVbaApplication::GoTo( const uno::Any& Reference, const uno::Any& Scroll ) thro if( Reference >>= xRange ) { uno::Reference< excel::XRange > xVbaRange( Reference, uno::UNO_QUERY ); - ScTabViewShell* pShell = getCurrentBestViewShell(); + ScTabViewShell* pShell = excel::getCurrentBestViewShell( mxContext ); ScGridWindow* gridWindow = (ScGridWindow*)pShell->GetWindow(); if ( xVbaRange.is() ) { @@ -615,38 +547,10 @@ ScVbaApplication::GoTo( const uno::Any& Reference, const uno::Any& Scroll ) thro uno::Reference< uno::XInterface >() ); } -namespace -{ - static uno::Reference< frame::XController > lcl_getCurrentController() - { - const uno::Reference< frame::XModel > xWorkingDoc( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY ); - uno::Reference< frame::XController > xController; - if ( xWorkingDoc.is() ) - xController.set( xWorkingDoc->getCurrentController(), uno::UNO_SET_THROW ); - else - xController.set( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY_THROW ); - return xController; - } -} - sal_Int32 SAL_CALL ScVbaApplication::getCursor() throw (uno::RuntimeException) { - sal_Int32 nPointerStyle( POINTER_ARROW ); - try - { - const uno::Reference< frame::XController > xController( lcl_getCurrentController(), uno::UNO_SET_THROW ); - const uno::Reference< frame::XFrame > xFrame ( xController->getFrame(), uno::UNO_SET_THROW ); - const uno::Reference< awt::XWindow > xWindow ( xFrame->getContainerWindow(), uno::UNO_SET_THROW ); - // why the heck isn't there an XWindowPeer::getPointer, but a setPointer only? - const Window* pWindow = VCLUnoHelper::GetWindow( xWindow ); - if ( pWindow ) - nPointerStyle = pWindow->GetSystemWindow()->GetPointer().GetStyle(); - } - catch( const uno::Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } + sal_Int32 nPointerStyle = getPointerStyle(getCurrentDocument()); switch( nPointerStyle ) { @@ -668,81 +572,34 @@ ScVbaApplication::setCursor( sal_Int32 _cursor ) throw (uno::RuntimeException) { try { - ::std::vector< uno::Reference< frame::XController > > aControllers; - - const uno::Reference< frame::XModel2 > xModel2( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY ); - if ( xModel2.is() ) - { - const uno::Reference< container::XEnumeration > xEnumControllers( xModel2->getControllers(), uno::UNO_SET_THROW ); - while ( xEnumControllers->hasMoreElements() ) - { - const uno::Reference< frame::XController > xController( xEnumControllers->nextElement(), uno::UNO_QUERY_THROW ); - aControllers.push_back( xController ); - } - } - else + uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); + switch( _cursor ) { - const uno::Reference< frame::XModel > xModel( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY ); - if ( xModel.is() ) + case excel::XlMousePointer::xlNorthwestArrow: { - const uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_SET_THROW ); - aControllers.push_back( xController ); + const Pointer& rPointer( POINTER_ARROW ); + setCursorHelper( xModel, rPointer, sal_False ); + break; } - else + case excel::XlMousePointer::xlWait: + case excel::XlMousePointer::xlIBeam: { - const uno::Reference< frame::XController > xController( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY_THROW ); - aControllers.push_back( xController ); + const Pointer& rPointer( static_cast< PointerStyle >( _cursor ) ); + //It will set the edit window, toobar and statusbar's mouse pointer. + setCursorHelper( xModel, rPointer, sal_True ); + break; } - } - - for ( ::std::vector< uno::Reference< frame::XController > >::const_iterator controller = aControllers.begin(); - controller != aControllers.end(); - ++controller - ) - { - const uno::Reference< frame::XFrame > xFrame ( (*controller)->getFrame(), uno::UNO_SET_THROW ); - const uno::Reference< awt::XWindow > xWindow ( xFrame->getContainerWindow(), uno::UNO_SET_THROW ); - - Window* pWindow = VCLUnoHelper::GetWindow( xWindow ); - OSL_ENSURE( pWindow, "ScVbaApplication::setCursor: no window!" ); - if ( !pWindow ) - continue; - - switch( _cursor ) + case excel::XlMousePointer::xlDefault: { - case excel::XlMousePointer::xlNorthwestArrow: - { - const Pointer& rPointer( POINTER_ARROW ); - pWindow->GetSystemWindow()->SetPointer( rPointer ); - pWindow->GetSystemWindow()->EnableChildPointerOverwrite( sal_False ); - break; - } - case excel::XlMousePointer::xlWait: - case excel::XlMousePointer::xlIBeam: - { - const Pointer& rPointer( static_cast< PointerStyle >( _cursor ) ); - //It will set the edit window, toobar and statusbar's mouse pointer. - pWindow->GetSystemWindow()->SetPointer( rPointer ); - pWindow->GetSystemWindow()->EnableChildPointerOverwrite( sal_True ); - //It only set the edit window's mouse pointer - //pWindow->.SetPointer( rPointer ); - //pWindow->.EnableChildPointerOverwrite( sal_True ); - //printf("\nset Cursor...%d\n", pWindow->.GetType()); - break; - } - case excel::XlMousePointer::xlDefault: - { - const Pointer& rPointer( POINTER_NULL ); - pWindow->GetSystemWindow()->SetPointer( rPointer ); - pWindow->GetSystemWindow()->EnableChildPointerOverwrite( sal_False ); - break; - } - default: - throw uno::RuntimeException( rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("Unknown value for Cursor pointer")), uno::Reference< uno::XInterface >() ); - // TODO: isn't this a flaw in the API? It should be allowed to throw an - // IllegalArgumentException, or so + const Pointer& rPointer( POINTER_NULL ); + setCursorHelper( xModel, rPointer, sal_False ); + break; } + default: + throw uno::RuntimeException( rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("Unknown value for Cursor pointer")), uno::Reference< uno::XInterface >() ); + // TODO: isn't this a flaw in the API? It should be allowed to throw an + // IllegalArgumentException, or so } } catch( const uno::Exception& ) @@ -1117,7 +974,7 @@ ScVbaApplication::Intersect( const uno::Reference< excel::XRange >& Arg1, const } uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - ScDocShell* pDocShell = getDocShell( xModel ); + ScDocShell* pDocShell = excel::getDocShell( xModel ); if ( aCellRanges.Count() == 1 ) { xRefRange = new ScVbaRange( uno::Reference< XHelperInterface >(), mxContext, new ScCellRangeObj( pDocShell, *aCellRanges.First() ) ); @@ -1206,7 +1063,7 @@ ScVbaApplication::Union( const uno::Reference< excel::XRange >& Arg1, const uno: aCellRanges.Append( *it ); uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - ScDocShell* pDocShell = getDocShell( xModel ); + ScDocShell* pDocShell = excel::getDocShell( xModel ); if ( aCellRanges.Count() == 1 ) { // normal range @@ -1228,29 +1085,17 @@ ScVbaApplication::Volatile( const uno::Any& aVolatile ) throw ( uno::RuntimeExc sal_Bool bVolatile = sal_True; aVolatile >>= bVolatile; return; -/* - if ( bVolatile ) - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Volatile - not supported" ) ), uno::Reference< uno::XInterface >() ); - // bVoloatile is false - currently this only would make sense if - // the autocalculate mode is set to be true. - - // so really this is crap, #TODO try and understand how ( or if ) - // the calculation mode and volatile interoperate - if ( ! getCalculation() == excel::XlCalculation::xlCalculationAutomatic ) - setCalculation( excel::XlCalculation::xlCalculationAutomatic ); -*/ } void SAL_CALL ScVbaApplication::DoEvents() throw ( uno::RuntimeException ) { } - ::sal_Bool SAL_CALL ScVbaApplication::getDisplayFormulaBar() throw ( css::uno::RuntimeException ) { sal_Bool bRes = sal_False; - ScTabViewShell* pViewShell = getCurrentBestViewShell(); + ScTabViewShell* pViewShell = excel::getCurrentBestViewShell( mxContext ); if ( pViewShell ) { SfxBoolItem sfxFormBar( FID_TOGGLEINPUTLINE); @@ -1268,7 +1113,7 @@ ScVbaApplication::getDisplayFormulaBar() throw ( css::uno::RuntimeException ) void SAL_CALL ScVbaApplication::setDisplayFormulaBar( ::sal_Bool _displayformulabar ) throw ( css::uno::RuntimeException ) { - ScTabViewShell* pViewShell = getCurrentBestViewShell(); + ScTabViewShell* pViewShell = excel::getCurrentBestViewShell( mxContext ); if ( pViewShell && ( _displayformulabar != getDisplayFormulaBar() ) ) { SfxBoolItem sfxFormBar( FID_TOGGLEINPUTLINE, _displayformulabar); @@ -1278,6 +1123,31 @@ ScVbaApplication::setDisplayFormulaBar( ::sal_Bool _displayformulabar ) throw ( } } +uno::Any SAL_CALL +ScVbaApplication::Caller( const uno::Any& /*aIndex*/ ) throw ( uno::RuntimeException ) +{ + StarBASIC* pBasic = SFX_APP()->GetBasic(); + SFX_APP()->EnterBasicCall(); + SbMethod* pMeth = (SbMethod*)pBasic->GetRtl()->Find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FuncCaller") ), SbxCLASS_METHOD ); + uno::Any aRet; + if ( pMeth ) + { + SbxVariableRef refTemp = pMeth; + // forces a broadcast + SbxVariableRef pNew = new SbxMethod( *((SbxMethod*)pMeth)); + OSL_TRACE("pNew has type %d and string value %s", pNew->GetType(), rtl::OUStringToOString( pNew->GetString(), RTL_TEXTENCODING_UTF8 ).getStr() ); + aRet = sbxToUnoValue( pNew ); + } + SFX_APP()->LeaveBasicCall(); + return aRet; +} + +uno::Reference< frame::XModel > +ScVbaApplication::getCurrentDocument() throw (css::uno::RuntimeException) +{ + return getCurrentExcelDoc(mxContext); +} + rtl::OUString& ScVbaApplication::getServiceImplName() { @@ -1296,3 +1166,13 @@ ScVbaApplication::getServiceNames() } return aServiceNames; } + +namespace application +{ +namespace sdecl = comphelper::service_decl; +sdecl::vba_service_class_<ScVbaApplication, sdecl::with_args<false> > serviceImpl; +extern sdecl::ServiceDecl const serviceDecl( + serviceImpl, + "ScVbaApplication", + "ooo.vba.excel.Application" ); +} diff --git a/sc/source/ui/vba/vbaapplication.hxx b/sc/source/ui/vba/vbaapplication.hxx index dd828298fe2a..8d5f4a3b2354 100644 --- a/sc/source/ui/vba/vbaapplication.hxx +++ b/sc/source/ui/vba/vbaapplication.hxx @@ -35,21 +35,25 @@ #include <ooo/vba/excel/XApplication.hpp> #include <com/sun/star/uno/XComponentContext.hpp> -#include "vbahelperinterface.hxx" +#include <vbahelper/vbahelperinterface.hxx> +#include <vbahelper/vbaapplicationbase.hxx> +#include <cppuhelper/implbase1.hxx> -typedef InheritedHelperInterfaceImpl1< ov::excel::XApplication > ScVbaApplication_BASE; +//typedef InheritedHelperInterfaceImpl1< ov::excel::XApplication > ScVbaApplication_BASE; +typedef cppu::ImplInheritanceHelper1< VbaApplicationBase, ov::excel::XApplication > ScVbaApplication_BASE; class ScVbaApplication : public ScVbaApplication_BASE { private: sal_Int32 m_xCalculation; rtl::OUString getOfficePath( const rtl::OUString& sPath ) throw ( css::uno::RuntimeException ); +protected: + virtual css::uno::Reference< css::frame::XModel > getCurrentDocument() throw (css::uno::RuntimeException); public: - ScVbaApplication( css::uno::Reference< css::uno::XComponentContext >& m_xContext ); + ScVbaApplication( const css::uno::Reference< css::uno::XComponentContext >& m_xContext ); virtual ~ScVbaApplication(); - // XHelperInterface ( parent is itself ) - virtual css::uno::Reference< ov::XHelperInterface > SAL_CALL getParent( ) throw (css::script::BasicErrorException, css::uno::RuntimeException) { return this; } + virtual SfxObjectShell* GetDocShell( const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException); // XApplication virtual ::rtl::OUString SAL_CALL PathSeparator( ) throw (css::script::BasicErrorException, css::uno::RuntimeException); @@ -68,15 +72,10 @@ public: virtual css::uno::Reference< ov::excel::XRange > SAL_CALL getActiveCell() throw ( css::uno::RuntimeException); virtual css::uno::Reference< ov::excel::XWindow > SAL_CALL getActiveWindow() throw (css::uno::RuntimeException); virtual css::uno::Reference< ov::excel::XWorksheet > SAL_CALL getActiveSheet() throw (css::uno::RuntimeException); - virtual sal_Bool SAL_CALL getScreenUpdating() throw (css::uno::RuntimeException); - virtual void SAL_CALL setScreenUpdating(sal_Bool bUpdate) throw (css::uno::RuntimeException); - virtual sal_Bool SAL_CALL getDisplayStatusBar() throw (css::uno::RuntimeException); - virtual void SAL_CALL setDisplayStatusBar(sal_Bool bDisplayStatusBar) throw (css::uno::RuntimeException); virtual ::sal_Bool SAL_CALL getDisplayFormulaBar() throw ( css::uno::RuntimeException ); virtual void SAL_CALL setDisplayFormulaBar( ::sal_Bool _displayformulabar ) throw ( css::uno::RuntimeException ); virtual css::uno::Reference< ov::XAssistant > SAL_CALL getAssistant() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL CommandBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); virtual css::uno::Reference< ov::excel::XWorkbook > SAL_CALL getThisWorkbook() throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL Workbooks( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL Worksheets( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); @@ -85,7 +84,6 @@ public: virtual css::uno::Any SAL_CALL Dialogs( const css::uno::Any& DialogIndex ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getCutCopyMode() throw (css::uno::RuntimeException); virtual void SAL_CALL setCutCopyMode( const css::uno::Any& _cutcopymode ) throw (css::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getVersion() throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getStatusBar() throw (css::uno::RuntimeException); virtual void SAL_CALL setStatusBar( const css::uno::Any& _statusbar ) throw (css::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getCursor() throw (css::uno::RuntimeException); @@ -103,6 +101,7 @@ public: virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Union( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorException, css::uno::RuntimeException); virtual void SAL_CALL Volatile( const css::uno::Any& Volatile ) throw (css::uno::RuntimeException ); virtual void SAL_CALL DoEvents() throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL Caller( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); // XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence<rtl::OUString> getServiceNames(); diff --git a/sc/source/ui/vba/vbaassistant.hxx b/sc/source/ui/vba/vbaassistant.hxx index a91d1bfd9c39..fa811f548430 100644 --- a/sc/source/ui/vba/vbaassistant.hxx +++ b/sc/source/ui/vba/vbaassistant.hxx @@ -40,8 +40,8 @@ #include <sfx2/sfxhelp.hxx> -#include "vbahelper.hxx" -#include "vbahelperinterface.hxx" +#include "excelvbahelper.hxx" +#include <vbahelper/vbahelperinterface.hxx> typedef ::cppu::WeakImplHelper1< ov::XAssistant > Assistant; typedef InheritedHelperInterfaceImpl< Assistant > ScVbaAssistantImpl_BASE; diff --git a/sc/source/ui/vba/vbaaxes.hxx b/sc/source/ui/vba/vbaaxes.hxx index e0bfbe350acb..62be9ba97a39 100644 --- a/sc/source/ui/vba/vbaaxes.hxx +++ b/sc/source/ui/vba/vbaaxes.hxx @@ -32,7 +32,7 @@ #include <ooo/vba/excel/XAxes.hpp> #include <ooo/vba/excel/XAxis.hpp> #include <ooo/vba/excel/XChart.hpp> -#include "vbacollectionimpl.hxx" +#include <vbahelper/vbacollectionimpl.hxx> typedef CollTestImplHelper< ov::excel::XAxes > ScVbaAxes_BASE; class ScVbaAxes : public ScVbaAxes_BASE diff --git a/sc/source/ui/vba/vbaaxis.hxx b/sc/source/ui/vba/vbaaxis.hxx index b8fafed82ee1..72ff614805e4 100644 --- a/sc/source/ui/vba/vbaaxis.hxx +++ b/sc/source/ui/vba/vbaaxis.hxx @@ -32,8 +32,8 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <ooo/vba/excel/XAxis.hpp> #include <ooo/vba/excel/XChart.hpp> -#include "vbahelperinterface.hxx" - +#include <vbahelper/vbahelperinterface.hxx> +#include <memory> typedef InheritedHelperInterfaceImpl1< ov::excel::XAxis > ScVbaAxis_BASE; class ScVbaChart; class ScVbaAxis : public ScVbaAxis_BASE diff --git a/sc/source/ui/vba/vbaborders.hxx b/sc/source/ui/vba/vbaborders.hxx index bcaecff05aff..ec7deed20ebe 100644 --- a/sc/source/ui/vba/vbaborders.hxx +++ b/sc/source/ui/vba/vbaborders.hxx @@ -38,7 +38,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> -#include "vbacollectionimpl.hxx" +#include <vbahelper/vbacollectionimpl.hxx> typedef CollTestImplHelper< ov::excel::XBorders > ScVbaBorders_BASE; class ScVbaPalette; diff --git a/sc/source/ui/vba/vbacharacters.hxx b/sc/source/ui/vba/vbacharacters.hxx index 10fcfc5bbddf..092d80a91e02 100644 --- a/sc/source/ui/vba/vbacharacters.hxx +++ b/sc/source/ui/vba/vbacharacters.hxx @@ -36,7 +36,7 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/text/XSimpleText.hpp> -#include "vbahelperinterface.hxx" +#include <vbahelper/vbahelperinterface.hxx> #include "vbapalette.hxx" typedef InheritedHelperInterfaceImpl1< ov::excel::XCharacters > ScVbaCharacters_BASE; diff --git a/sc/source/ui/vba/vbachart.hxx b/sc/source/ui/vba/vbachart.hxx index 19efc430f2fd..3ec8e77c4dc5 100644 --- a/sc/source/ui/vba/vbachart.hxx +++ b/sc/source/ui/vba/vbachart.hxx @@ -41,7 +41,7 @@ #include <ooo/vba/excel/XChart.hpp> #include <ooo/vba/excel/XDataLabels.hpp> #include <ooo/vba/excel/XSeries.hpp> -#include "vbahelperinterface.hxx" +#include <vbahelper/vbahelperinterface.hxx> typedef InheritedHelperInterfaceImpl1<ov::excel::XChart > ChartImpl_BASE; diff --git a/sc/source/ui/vba/vbachartobject.cxx b/sc/source/ui/vba/vbachartobject.cxx index feecb7182d97..85104ff20cde 100644 --- a/sc/source/ui/vba/vbachartobject.cxx +++ b/sc/source/ui/vba/vbachartobject.cxx @@ -120,10 +120,11 @@ ScVbaChartObject::Activate() throw ( script::BasicErrorException ) { try { - // #TODO #FIXME should be ThisWorkbook or equivelant - // XModel + // #TODO #FIXME should be ThisWorkbook or equivelant, or in + // fact probably the chart object should be created with + // the XModel owner //uno::Reference< view::XSelectionSupplier > xSelectionSupplier( getXModel().getCurrentController()); - uno::Reference< view::XSelectionSupplier > xSelectionSupplier( getCurrentDocument()->getCurrentController(), uno::UNO_QUERY_THROW ); + uno::Reference< view::XSelectionSupplier > xSelectionSupplier( getCurrentExcelDoc(mxContext)->getCurrentController(), uno::UNO_QUERY_THROW ); xSelectionSupplier->select(uno::makeAny(xShape)); } catch (uno::Exception& ) diff --git a/sc/source/ui/vba/vbachartobject.hxx b/sc/source/ui/vba/vbachartobject.hxx index 3b2b6b3469ec..c7bfbd15c4c1 100644 --- a/sc/source/ui/vba/vbachartobject.hxx +++ b/sc/source/ui/vba/vbachartobject.hxx @@ -36,7 +36,7 @@ #include <com/sun/star/container/XNamed.hpp> #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp> #include <ooo/vba/excel/XChartObject.hpp> -#include "vbahelperinterface.hxx" +#include <vbahelper/vbahelperinterface.hxx> #include <memory> typedef InheritedHelperInterfaceImpl1<ov::excel::XChartObject > ChartObjectImpl_BASE; diff --git a/sc/source/ui/vba/vbachartobjects.hxx b/sc/source/ui/vba/vbachartobjects.hxx index a966dbb66518..5a11e92e8dbc 100644 --- a/sc/source/ui/vba/vbachartobjects.hxx +++ b/sc/source/ui/vba/vbachartobjects.hxx @@ -36,8 +36,8 @@ #include <com/sun/star/table/XTableCharts.hpp> #include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> -#include"vbacollectionimpl.hxx" -#include "vbahelper.hxx" +#include <vbahelper/vbacollectionimpl.hxx> +#include "excelvbahelper.hxx" #include <hash_map> typedef CollTestImplHelper< ov::excel::XChartObjects > ChartObjects_BASE; diff --git a/sc/source/ui/vba/vbacharts.cxx b/sc/source/ui/vba/vbacharts.cxx index 73be2b84e6c6..4c21720ca7f3 100644 --- a/sc/source/ui/vba/vbacharts.cxx +++ b/sc/source/ui/vba/vbacharts.cxx @@ -35,11 +35,9 @@ using namespace ::com::sun::star; using namespace ::ooo::vba; -ScVbaCharts::ScVbaCharts( const css::uno::Reference< ov::XHelperInterface >& _xParent, const css::uno::Reference< css::uno::XComponentContext >& _xContext ) : Charts_BASE(_xParent, _xContext, uno::Reference< container::XIndexAccess >() ) +ScVbaCharts::ScVbaCharts( const css::uno::Reference< ov::XHelperInterface >& _xParent, const css::uno::Reference< css::uno::XComponentContext >& _xContext, const uno::Reference< frame::XModel >& xModel ) : Charts_BASE(_xParent, _xContext, uno::Reference< container::XIndexAccess >()) { - // #TODO #FIXME surely this is wrong, you should never use the - // currently documement ( it could be anything ) - xComponent.set( getCurrentDocument(), uno::UNO_QUERY_THROW ); + xComponent.set( xModel, uno::UNO_QUERY_THROW ); xSpreadsheetDocument.set( xComponent, uno::UNO_QUERY_THROW ); } diff --git a/sc/source/ui/vba/vbacharts.hxx b/sc/source/ui/vba/vbacharts.hxx index f3bbf80f8d16..ac804e5ac873 100644 --- a/sc/source/ui/vba/vbacharts.hxx +++ b/sc/source/ui/vba/vbacharts.hxx @@ -31,8 +31,8 @@ #define SC_VBA_CHARTS_HXX #include <ooo/vba/excel/XCharts.hpp> #include <com/sun/star/sheet/XSpreadsheetDocument.hpp> -#include"vbacollectionimpl.hxx" -#include "vbahelper.hxx" +#include <vbahelper/vbacollectionimpl.hxx> +#include "excelvbahelper.hxx" #include <hash_map> typedef CollTestImplHelper< ov::excel::XCharts > Charts_BASE; @@ -43,7 +43,7 @@ class ScVbaCharts : public Charts_BASE css::uno::Reference< css::sheet::XSpreadsheetDocument > xSpreadsheetDocument; css::uno::Reference< css::lang::XComponent > xComponent; public: - ScVbaCharts( const css::uno::Reference< ov::XHelperInterface >& _xParent, const css::uno::Reference< css::uno::XComponentContext >& _xContext ); + ScVbaCharts( const css::uno::Reference< ov::XHelperInterface >& _xParent, const css::uno::Reference< css::uno::XComponentContext >& _xContext, const css::uno::Reference< css::frame::XModel >& xModel ); // XCharts virtual css::uno::Any SAL_CALL Add() throw (css::script::BasicErrorException, css::uno::RuntimeException); virtual css::uno::Reference< ov::excel::XChart > SAL_CALL getActiveChart( ) throw (css::script::BasicErrorException, css::uno::RuntimeException); diff --git a/sc/source/ui/vba/vbacomment.hxx b/sc/source/ui/vba/vbacomment.hxx index 6676d09bd660..8601fa303844 100644 --- a/sc/source/ui/vba/vbacomment.hxx +++ b/sc/source/ui/vba/vbacomment.hxx @@ -39,7 +39,7 @@ #include <com/sun/star/table/XCellRange.hpp> #include <com/sun/star/uno/XComponentContext.hpp> -#include "vbahelperinterface.hxx" +#include <vbahelper/vbahelperinterface.hxx> typedef InheritedHelperInterfaceImpl1< ov::excel::XComment > ScVbaComment_BASE; diff --git a/sc/source/ui/vba/vbacomments.hxx b/sc/source/ui/vba/vbacomments.hxx index 098dfd5153a3..be876ab2f76e 100644 --- a/sc/source/ui/vba/vbacomments.hxx +++ b/sc/source/ui/vba/vbacomments.hxx @@ -34,8 +34,8 @@ #include <ooo/vba/excel/XComments.hpp> -#include "vbahelper.hxx" -#include "vbacollectionimpl.hxx" +#include "excelvbahelper.hxx" +#include <vbahelper/vbacollectionimpl.hxx> #include "vbacomment.hxx" typedef CollTestImplHelper< ov::excel::XComments > ScVbaComments_BASE; diff --git a/sc/source/ui/vba/vbacondition.hxx b/sc/source/ui/vba/vbacondition.hxx index ac44130e5127..823e889ae298 100644 --- a/sc/source/ui/vba/vbacondition.hxx +++ b/sc/source/ui/vba/vbacondition.hxx @@ -31,7 +31,7 @@ #define SC_VBA_CONDITION_HXX #include <com/sun/star/sheet/XSheetCondition.hpp> #include <com/sun/star/sheet/XCellRangeAddressable.hpp> -#include "vbahelperinterface.hxx" +#include <vbahelper/vbahelperinterface.hxx> #include <com/sun/star/sheet/ConditionOperator.hpp> template< typename Ifc1 > diff --git a/sc/source/ui/vba/vbacontrol.cxx b/sc/source/ui/vba/vbacontrol.cxx index eaf9365016ec..e69de29bb2d1 100644 --- a/sc/source/ui/vba/vbacontrol.cxx +++ b/sc/source/ui/vba/vbacontrol.cxx @@ -1,468 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: vbacontrol.cxx,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <com/sun/star/form/FormComponentType.hpp> -#include <com/sun/star/awt/XControlModel.hpp> -#include <com/sun/star/awt/XControl.hpp> -#include <com/sun/star/awt/XWindow2.hpp> -#include <com/sun/star/lang/XEventListener.hpp> -#include <com/sun/star/drawing/XShape.hpp> -#include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/view/XControlAccess.hpp> -#include <com/sun/star/container/XChild.hpp> -#include <com/sun/star/form/binding/XBindableValue.hpp> -#include <com/sun/star/form/binding/XListEntrySink.hpp> -#include <com/sun/star/table/CellAddress.hpp> -#include <com/sun/star/table/CellRangeAddress.hpp> -#ifdef VBA_OOBUILD_HACK -#include <svtools/bindablecontrolhelper.hxx> -#endif -#include"vbacontrol.hxx" -#include"vbacombobox.hxx" -#include "vbabutton.hxx" -#include "vbalabel.hxx" -#include "vbatextbox.hxx" -#include "vbaradiobutton.hxx" -#include "vbalistbox.hxx" -#include "vbatogglebutton.hxx" -#include "vbacheckbox.hxx" -#include "vbaframe.hxx" -#include "vbascrollbar.hxx" -#include "vbaprogressbar.hxx" -#include "vbamultipage.hxx" -#include "vbaspinbutton.hxx" -#include "vbaimage.hxx" - - -using namespace com::sun::star; -using namespace ooo::vba; - -uno::Reference< css::awt::XWindowPeer > -ScVbaControl::getWindowPeer() throw (uno::RuntimeException) -{ - uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY ); - - uno::Reference< awt::XControlModel > xControlModel; - uno::Reference< css::awt::XWindowPeer > xWinPeer; - if ( !xControlShape.is() ) - { - // would seem to be a Userform control - uno::Reference< awt::XControl > xControl( m_xControl, uno::UNO_QUERY_THROW ); - xWinPeer = xControl->getPeer(); - return xWinPeer; - } - // form control - xControlModel.set( xControlShape->getControl(), uno::UNO_QUERY_THROW ); - - uno::Reference< view::XControlAccess > xControlAccess( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - try - { - uno::Reference< awt::XControl > xControl( xControlAccess->getControl( xControlModel ), uno::UNO_QUERY ); - xWinPeer = xControl->getPeer(); - } - catch( uno::Exception ) - { - throw uno::RuntimeException( rtl::OUString::createFromAscii( "The Control does not exsit" ), - uno::Reference< uno::XInterface >() ); - } - return xWinPeer; -} - -//ScVbaControlListener -class ScVbaControlListener: public cppu::WeakImplHelper1< lang::XEventListener > -{ -private: - ScVbaControl *pControl; -public: - ScVbaControlListener( ScVbaControl *pTmpControl ); - virtual ~ScVbaControlListener(); - virtual void SAL_CALL disposing( const lang::EventObject& rEventObject ) throw( uno::RuntimeException ); -}; - -ScVbaControlListener::ScVbaControlListener( ScVbaControl *pTmpControl ): pControl( pTmpControl ) -{ -} - -ScVbaControlListener::~ScVbaControlListener() -{ -} - -void SAL_CALL -ScVbaControlListener::disposing( const lang::EventObject& ) throw( uno::RuntimeException ) -{ - if( pControl ) - { - pControl->removeResouce(); - pControl = NULL; - } -} - -//ScVbaControl - -ScVbaControl::ScVbaControl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< ::uno::XInterface >& xControl, const css::uno::Reference< css::frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper ) : ControlImpl_BASE( xParent, xContext ), m_xControl( xControl ), m_xModel( xModel ) -{ - //add listener - m_xEventListener.set( new ScVbaControlListener( this ) ); - setGeometryHelper( pGeomHelper ); - uno::Reference< lang::XComponent > xComponent( m_xControl, uno::UNO_QUERY_THROW ); - xComponent->addEventListener( m_xEventListener ); - - //init m_xProps - uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY ) ; - uno::Reference< awt::XControl> xUserFormControl( m_xControl, uno::UNO_QUERY ) ; - if ( xControlShape.is() ) // form control - m_xProps.set( xControlShape->getControl(), uno::UNO_QUERY_THROW ); - else if ( xUserFormControl.is() ) // userform control - m_xProps.set( xUserFormControl->getModel(), uno::UNO_QUERY_THROW ); -} - -ScVbaControl::~ScVbaControl() -{ - if( m_xControl.is() ) -{ - uno::Reference< lang::XComponent > xComponent( m_xControl, uno::UNO_QUERY_THROW ); - xComponent->removeEventListener( m_xEventListener ); -} -} - -void -ScVbaControl::setGeometryHelper( AbstractGeometryAttributes* pHelper ) -{ - mpGeometryHelper.reset( pHelper ); -} - -void ScVbaControl::removeResouce() throw( uno::RuntimeException ) -{ - uno::Reference< lang::XComponent > xComponent( m_xControl, uno::UNO_QUERY_THROW ); - xComponent->removeEventListener( m_xEventListener ); - m_xControl= NULL; - m_xProps = NULL; -} - -//In design model has different behavior -sal_Bool SAL_CALL ScVbaControl::getEnabled() throw (uno::RuntimeException) -{ - uno::Any aValue = m_xProps->getPropertyValue - (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Enabled" ) ) ); - sal_Bool bRet = false; - aValue >>= bRet; - return bRet; -} - -void SAL_CALL ScVbaControl::setEnabled( sal_Bool bVisible ) throw (uno::RuntimeException) -{ - uno::Any aValue( bVisible ); - m_xProps->setPropertyValue - (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Enabled" ) ), aValue); - -} - -sal_Bool SAL_CALL ScVbaControl::getVisible() throw (uno::RuntimeException) -{ - sal_Bool bVisible = sal_False; - m_xProps->getPropertyValue(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EnableVisible" ) ) ) >>= bVisible; - return bVisible; -} - -void SAL_CALL ScVbaControl::setVisible( sal_Bool bVisible ) throw (uno::RuntimeException) -{ - m_xProps->setPropertyValue - (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EnableVisible" ) ), uno::makeAny( bVisible ) ); -} -double SAL_CALL ScVbaControl::getHeight() throw (uno::RuntimeException) -{ - return mpGeometryHelper->getHeight(); -} -void SAL_CALL ScVbaControl::setHeight( double _height ) throw (uno::RuntimeException) -{ - mpGeometryHelper->setHeight( _height ); -} - -double SAL_CALL ScVbaControl::getWidth() throw (uno::RuntimeException) -{ - return mpGeometryHelper->getWidth(); -} -void SAL_CALL ScVbaControl::setWidth( double _width ) throw (uno::RuntimeException) -{ - mpGeometryHelper->setWidth( _width ); -} - -double SAL_CALL -ScVbaControl::getLeft() throw (uno::RuntimeException) -{ - return mpGeometryHelper->getLeft(); -} - -void SAL_CALL -ScVbaControl::setLeft( double _left ) throw (uno::RuntimeException) -{ - mpGeometryHelper->setLeft( _left ); - -} - -double SAL_CALL -ScVbaControl::getTop() throw (uno::RuntimeException) -{ - return mpGeometryHelper->getTop(); -} - -void SAL_CALL -ScVbaControl::setTop( double _top ) throw (uno::RuntimeException) -{ - mpGeometryHelper->setTop( _top ); -} - -uno::Reference< uno::XInterface > SAL_CALL -ScVbaControl::getObject() throw (uno::RuntimeException) -{ - uno::Reference< msforms::XControl > xRet( this ); - return xRet; -} - -void SAL_CALL ScVbaControl::SetFocus() throw (uno::RuntimeException) -{ - uno::Reference< awt::XWindow > xWin( m_xControl, uno::UNO_QUERY_THROW ); - xWin->setFocus(); -} - -rtl::OUString SAL_CALL -ScVbaControl::getControlSource() throw (uno::RuntimeException) -{ -// #FIXME I *hate* having these upstream differences -// but this is necessary until I manage to upstream other -// dependant parts -#ifdef VBA_OOBUILD_HACK - rtl::OUString sControlSource; - uno::Reference< form::binding::XBindableValue > xBindable( m_xProps, uno::UNO_QUERY ); - if ( xBindable.is() ) - { - try - { - uno::Reference< lang::XMultiServiceFactory > xFac( m_xModel, uno::UNO_QUERY_THROW ); - uno::Reference< beans::XPropertySet > xConvertor( xFac->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.table.CellAddressConversion" ))), uno::UNO_QUERY ); - uno::Reference< beans::XPropertySet > xProps( xBindable->getValueBinding(), uno::UNO_QUERY_THROW ); - table::CellAddress aAddress; - xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BoundCell") ) ) >>= aAddress; - xConvertor->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Address") ), uno::makeAny( aAddress ) ); - xConvertor->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("XL_A1_Representation") ) ) >>= sControlSource; - } - catch( uno::Exception& ) - { - } - } - return sControlSource; -#else - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("getControlSource not supported") ), uno::Reference< uno::XInterface >()); // not supported -#endif -} - -void SAL_CALL -ScVbaControl::setControlSource( const rtl::OUString& _controlsource ) throw (uno::RuntimeException) -{ -#ifdef VBA_OOBUILD_HACK - rtl::OUString sEmpty; - svt::BindableControlHelper::ApplyListSourceAndBindableData( m_xModel, m_xProps, _controlsource, sEmpty ); -#else - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("setControlSource not supported ") ).concat( _controlsource ), uno::Reference< uno::XInterface >()); // not supported -#endif -} - -rtl::OUString SAL_CALL -ScVbaControl::getRowSource() throw (uno::RuntimeException) -{ -#ifdef VBA_OOBUILD_HACK - rtl::OUString sRowSource; - uno::Reference< form::binding::XListEntrySink > xListSink( m_xProps, uno::UNO_QUERY ); - if ( xListSink.is() ) - { - try - { - uno::Reference< lang::XMultiServiceFactory > xFac( m_xModel, uno::UNO_QUERY_THROW ); - uno::Reference< beans::XPropertySet > xConvertor( xFac->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.table.CellRangeAddressConversion" ))), uno::UNO_QUERY ); - - uno::Reference< beans::XPropertySet > xProps( xListSink->getListEntrySource(), uno::UNO_QUERY_THROW ); - table::CellRangeAddress aAddress; - xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CellRange") ) ) >>= aAddress; - xConvertor->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Address")), uno::makeAny( aAddress ) ); - xConvertor->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("XL_A1_Representation") ) ) >>= sRowSource; - } - catch( uno::Exception& ) - { - } - } - return sRowSource; -#else - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("getRowSource not supported") ), uno::Reference< uno::XInterface >()); // not supported -#endif -} - -void SAL_CALL -ScVbaControl::setRowSource( const rtl::OUString& _rowsource ) throw (uno::RuntimeException) -{ -#ifdef VBA_OOBUILD_HACK - rtl::OUString sEmpty; - svt::BindableControlHelper::ApplyListSourceAndBindableData( m_xModel, m_xProps, sEmpty, _rowsource ); -#else - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("setRowSource not supported ") ).concat( _rowsource ), uno::Reference< uno::XInterface >()); // not supported -#endif -} - -rtl::OUString SAL_CALL -ScVbaControl::getName() throw (uno::RuntimeException) -{ - rtl::OUString sName; - m_xProps->getPropertyValue - (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ) ) >>= sName; - return sName; - -} - -void SAL_CALL -ScVbaControl::setName( const rtl::OUString& _name ) throw (uno::RuntimeException) -{ - m_xProps->setPropertyValue - (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), uno::makeAny( _name ) ); - } -//ScVbaControlFactory - -ScVbaControlFactory::ScVbaControlFactory( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel ): m_xContext( xContext ), m_xControl( xControl ), m_xModel( xModel ) -{ -} - -ScVbaControl* ScVbaControlFactory::createControl() throw (uno::RuntimeException) -{ - return createControl( m_xModel ); -} -ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< uno::XInterface >& xParent ) throw (uno::RuntimeException) -{ - uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY ); - if ( xControlShape.is() ) // form controls - return createControl( xControlShape, xParent ); - uno::Reference< awt::XControl > xControl( m_xControl, uno::UNO_QUERY ); - if ( !xControl.is() ) - throw uno::RuntimeException(); // really we should be more informative - return createControl( xControl, xParent ); - -} - -ScVbaControl* ScVbaControlFactory::createControl(const uno::Reference< drawing::XControlShape >& xControlShape, const uno::Reference< uno::XInterface >& /*xParent*/ ) throw (uno::RuntimeException) -{ - uno::Reference< beans::XPropertySet > xProps( xControlShape->getControl(), uno::UNO_QUERY_THROW ); - sal_Int32 nClassId = -1; - const static rtl::OUString sClassId( RTL_CONSTASCII_USTRINGPARAM("ClassId") ); - xProps->getPropertyValue( sClassId ) >>= nClassId; - uno::Reference< XHelperInterface > xVbaParent; // #FIXME - should be worksheet I guess - switch( nClassId ) - { - case form::FormComponentType::COMBOBOX: - return new ScVbaComboBox( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); - case form::FormComponentType::COMMANDBUTTON: - return new ScVbaButton( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); - case form::FormComponentType::FIXEDTEXT: - return new ScVbaLabel( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); - case form::FormComponentType::TEXTFIELD: - return new ScVbaTextBox( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); - case form::FormComponentType::RADIOBUTTON: - return new ScVbaRadioButton( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); - case form::FormComponentType::LISTBOX: - return new ScVbaListBox( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); - case form::FormComponentType::SPINBUTTON: - return new ScVbaSpinButton( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); - case form::FormComponentType::IMAGECONTROL: - return new ScVbaImage( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); - default: - throw uno::RuntimeException( rtl::OUString::createFromAscii( - "Donot support this Control Type." ), uno::Reference< uno::XInterface >() ); - } -} - -ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< awt::XControl >& xControl, const uno::Reference< uno::XInterface >& xParent ) throw (uno::RuntimeException) -{ - uno::Reference< beans::XPropertySet > xProps( xControl->getModel(), uno::UNO_QUERY_THROW ); - uno::Reference< lang::XServiceInfo > xServiceInfo( xProps, uno::UNO_QUERY_THROW ); - ScVbaControl* pControl = NULL; - uno::Reference< XHelperInterface > xVbaParent; // #FIXME - should be worksheet I guess - if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlCheckBoxModel") ) ) ) - pControl = new ScVbaCheckbox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); - else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") ) ) ) - pControl = new ScVbaRadioButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); - else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlEditModel") ) ) ) - pControl = new ScVbaTextBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), true ); - else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlButtonModel") ) ) ) - { - sal_Bool bToggle = sal_False; - xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Toggle") ) ) >>= bToggle; - if ( bToggle ) - pControl = new ScVbaToggleButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); - else - pControl = new ScVbaButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); - } - else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlComboBoxModel") ) ) ) - pControl = new ScVbaComboBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), true ); - else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlListBoxModel") ) ) ) - pControl = new ScVbaListBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); - else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedTextModel") ) ) ) - pControl = new ScVbaLabel( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); - else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlImageControlModel") ) ) ) - pControl = new ScVbaImage( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); - else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlProgressBarModel") ) ) ) - pControl = new ScVbaProgressBar( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); - else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") ) ) ) - pControl = new ScVbaFrame( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); - else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlScrollBarModel") ) ) ) - pControl = new ScVbaScrollBar( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); - else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoMultiPageModel") ) ) ) - pControl = new ScVbaMultiPage( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), xParent ); - else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlSpinButtonModel") ) ) ) - pControl = new ScVbaSpinButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); - else - throw uno::RuntimeException( rtl::OUString::createFromAscii("Unsupported control " ), uno::Reference< uno::XInterface >() ); - return pControl; -} - -rtl::OUString& -ScVbaControl::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaControl") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -ScVbaControl::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Control" ) ); - } - return aServiceNames; -} - - diff --git a/sc/source/ui/vba/vbadialog.cxx b/sc/source/ui/vba/vbadialog.cxx index eb0cdfa6386e..06faebc3a37b 100644 --- a/sc/source/ui/vba/vbadialog.cxx +++ b/sc/source/ui/vba/vbadialog.cxx @@ -27,39 +27,11 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#include <comphelper/processfactory.hxx> - -#include <com/sun/star/lang/XMultiComponentFactory.hpp> -#include <com/sun/star/frame/XModel.hpp> -#include <ooo/vba/excel/XApplication.hpp> - -#include <tools/string.hxx> - -#include "vbahelper.hxx" #include "vbadialog.hxx" -#include "vbaglobals.hxx" using namespace ::ooo::vba; using namespace ::com::sun::star; -// fails silently -void -ScVbaDialog::Show() throw(uno::RuntimeException) -{ - rtl::OUString aURL; - uno::Reference< frame::XModel > xModel = getCurrentDocument(); - if ( xModel.is() ) - { - aURL = mapIndexToName( mnIndex ); - if( aURL.getLength() ) - throw uno::RuntimeException( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " Unable to open the specified dialog " ) ), - uno::Reference< XInterface > () ); - dispatchRequests( xModel, aURL ); - } -} - - static const rtl::OUString aStringList[]= { rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Open" ) ), @@ -102,7 +74,7 @@ ScVbaDialog::mapIndexToName( sal_Int32 nIndex ) rtl::OUString& ScVbaDialog::getServiceImplName() { - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaPivotTable") ); + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaDialog") ); return sImplName; } @@ -113,7 +85,7 @@ ScVbaDialog::getServiceNames() if ( aServiceNames.getLength() == 0 ) { aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.PivotTable" ) ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Dialog" ) ); } return aServiceNames; } diff --git a/sc/source/ui/vba/vbadialog.hxx b/sc/source/ui/vba/vbadialog.hxx index 8b488abebb19..77be9341f7f3 100644 --- a/sc/source/ui/vba/vbadialog.hxx +++ b/sc/source/ui/vba/vbadialog.hxx @@ -31,27 +31,20 @@ #define SC_VBA_DIALOG_HXX #include <cppuhelper/implbase1.hxx> - -#include <com/sun/star/uno/XComponentContext.hpp> -#include <ooo/vba/XGlobals.hpp> -#include <ooo/vba/excel/XApplication.hpp> #include <ooo/vba/excel/XDialog.hpp> +#include <vbahelper/vbahelperinterface.hxx> +#include <vbahelper/vbadialogbase.hxx> -#include "vbahelperinterface.hxx" -#include "vbadialog.hxx" - -typedef InheritedHelperInterfaceImpl1< ov::excel::XDialog > ScVbaDialog_BASE; +typedef cppu::ImplInheritanceHelper1< VbaDialogBase, ov::excel::XDialog > ScVbaDialog_BASE; class ScVbaDialog : public ScVbaDialog_BASE { - sal_Int32 mnIndex; public: - ScVbaDialog( const css::uno::Reference< ov::XHelperInterface >& xParent, sal_Int32 nIndex, const css::uno::Reference< css::uno::XComponentContext > xContext ):ScVbaDialog_BASE( xParent, xContext ), mnIndex( nIndex ) {} + ScVbaDialog( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, const css::uno::Reference< css::frame::XModel >& xModel, sal_Int32 nIndex ):ScVbaDialog_BASE( xParent, xContext, xModel, nIndex ) {} virtual ~ScVbaDialog() {} // Methods - virtual void SAL_CALL Show() throw (css::uno::RuntimeException); - rtl::OUString mapIndexToName( sal_Int32 nIndex ); + virtual rtl::OUString mapIndexToName( sal_Int32 nIndex ); // XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence<rtl::OUString> getServiceNames(); diff --git a/sc/source/ui/vba/vbadialogs.cxx b/sc/source/ui/vba/vbadialogs.cxx index 1dca41d5d1e1..aa2161f33c21 100644 --- a/sc/source/ui/vba/vbadialogs.cxx +++ b/sc/source/ui/vba/vbadialogs.cxx @@ -27,18 +27,8 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#include <comphelper/processfactory.hxx> - -#include <com/sun/star/lang/XMultiComponentFactory.hpp> -#include <com/sun/star/frame/XModel.hpp> -#include <ooo/vba/excel/XApplication.hpp> #include <ooo/vba/excel/XDialog.hpp> - -#include <tools/string.hxx> - -#include "vbahelper.hxx" #include "vbadialogs.hxx" -#include "vbaglobals.hxx" #include "vbadialog.hxx" using namespace ::ooo::vba; @@ -49,26 +39,19 @@ ScVbaDialogs::Dummy() throw (uno::RuntimeException) { } -::sal_Int32 -ScVbaDialogs::getCount() throw (uno::RuntimeException) -{ - //#TODO #FIXEME - //SC_VBA_STUB(); - return 0; -} - uno::Any ScVbaDialogs::Item( const uno::Any &aItem ) throw (uno::RuntimeException) { sal_Int32 nIndex = 0; aItem >>= nIndex; - uno::Reference< excel::XDialog > aDialog( new ScVbaDialog( uno::Reference< XHelperInterface >( ScVbaGlobals::getGlobalsImpl( mxContext )->getApplication(), uno::UNO_QUERY_THROW ), nIndex, mxContext ) ); + uno::Reference< excel::XDialog > aDialog( new ScVbaDialog( uno::Reference< XHelperInterface >( Application(),uno::UNO_QUERY_THROW ), mxContext, m_xModel, nIndex ) ); return uno::Any( aDialog ); } + rtl::OUString& ScVbaDialogs::getServiceImplName() { - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaWorksheet") ); + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaDialogs") ); return sImplName; } @@ -79,7 +62,7 @@ ScVbaDialogs::getServiceNames() if ( aServiceNames.getLength() == 0 ) { aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Worksheet" ) ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Dialogs" ) ); } return aServiceNames; } diff --git a/sc/source/ui/vba/vbadialogs.hxx b/sc/source/ui/vba/vbadialogs.hxx index 40eeb78663a2..a1785defc255 100644 --- a/sc/source/ui/vba/vbadialogs.hxx +++ b/sc/source/ui/vba/vbadialogs.hxx @@ -30,25 +30,22 @@ #ifndef SC_VBA_DIALOGS_HXX #define SC_VBA_DIALOGS_HXX -#include <cppuhelper/implbase1.hxx> - #include <com/sun/star/uno/XComponentContext.hpp> #include <ooo/vba/excel/XDialogs.hpp> #include <ooo/vba/XCollection.hpp> -#include "vbahelperinterface.hxx" - -class ScModelObj; +#include <vbahelper/vbahelperinterface.hxx> +#include <vbahelper/vbadialogsbase.hxx> +#include <cppuhelper/implbase1.hxx> -typedef InheritedHelperInterfaceImpl1< ov::excel::XDialogs > ScVbaDialogs_BASE; +typedef cppu::ImplInheritanceHelper1< VbaDialogsBase, ov::excel::XDialogs > ScVbaDialogs_BASE; class ScVbaDialogs : public ScVbaDialogs_BASE { public: - ScVbaDialogs( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext ): ScVbaDialogs_BASE( xParent, xContext ) {} + ScVbaDialogs( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::frame::XModel >& xModel ): ScVbaDialogs_BASE( xParent, xContext, xModel ) {} virtual ~ScVbaDialogs() {} // XCollection - virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index ) throw (css::uno::RuntimeException); // XDialogs diff --git a/sc/source/ui/vba/vbafont.cxx b/sc/source/ui/vba/vbafont.cxx index 9855d5e056af..7f85f71e76bf 100644 --- a/sc/source/ui/vba/vbafont.cxx +++ b/sc/source/ui/vba/vbafont.cxx @@ -46,37 +46,14 @@ using namespace ::ooo::vba; using namespace ::com::sun::star; -// use local constants there is no need to expose these constants -// externally. Looking at the Format->Character dialog it seem that -// these may infact be even be calculated. Leave hardcoded for now -// #FIXEME #TBD investigate the code for dialog mentioned above - -// The font baseline is not specified. -const short NORMAL = 0; - -// specifies a superscripted. -const short SUPERSCRIPT = 33; - -// specifies a subscripted. -const short SUBSCRIPT = -33; - -// specifies a hight of superscripted font - const sal_Int8 SUPERSCRIPTHEIGHT = 58; - -// specifies a hight of subscripted font -const sal_Int8 SUBSCRIPTHEIGHT = 58; - -// specifies a hight of normal font -const short NORMALHEIGHT = 100; - -ScVbaFont::ScVbaFont( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const ScVbaPalette& dPalette, uno::Reference< beans::XPropertySet > xPropertySet, ScCellRangeObj* pRangeObj ) throw ( uno::RuntimeException ) : ScVbaFont_BASE( xParent, xContext ), mxFont( xPropertySet, css::uno::UNO_QUERY_THROW ), mPalette( dPalette ), mpRangeObj( pRangeObj ) +ScVbaFont::ScVbaFont( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const ScVbaPalette& dPalette, uno::Reference< beans::XPropertySet > xPropertySet, ScCellRangeObj* pRangeObj ) throw ( uno::RuntimeException ) : ScVbaFont_BASE( xParent, xContext, dPalette.getPalette(), xPropertySet ), mPalette( dPalette ), mpRangeObj( pRangeObj ) { } SfxItemSet* ScVbaFont::GetDataSet() { - SfxItemSet* pDataSet = ScVbaCellRangeAccess::GetDataSet( mpRangeObj ); + SfxItemSet* pDataSet = excel::ScVbaCellRangeAccess::GetDataSet( mpRangeObj ); return pDataSet; } @@ -243,19 +220,13 @@ ScVbaFont::getSubscript() throw ( uno::RuntimeException ) return uno::makeAny( ( nValue == SUBSCRIPT ) ); } -void SAL_CALL -ScVbaFont::setSize( const uno::Any& aValue ) throw( uno::RuntimeException ) -{ - mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharHeight" ) ), aValue ); -} - uno::Any SAL_CALL ScVbaFont::getSize() throw ( uno::RuntimeException ) { if ( GetDataSet() ) if ( GetDataSet()->GetItemState( ATTR_FONT_HEIGHT, TRUE, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); - return mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharHeight" ) ) ); + return ScVbaFont_BASE::getSize(); } void SAL_CALL @@ -267,13 +238,12 @@ ScVbaFont::setColorIndex( const uno::Any& _colorindex ) throw( uno::RuntimeExcep // handled properly here if ( !nIndex || ( nIndex == excel::XlColorIndex::xlColorIndexAutomatic ) ) + { nIndex = 1; // check defualt ( assume black ) - --nIndex; // OOo indices are zero bases - uno::Reference< container::XIndexAccess > xIndex = mPalette.getPalette(); - // setColor expects colors in XL RGB values - // #FIXME this is daft we convert OO RGB val to XL RGB val and - // then back again to OO RGB value - setColor( OORGBToXLRGB(xIndex->getByIndex( nIndex )) ); + ScVbaFont_BASE::setColorIndex( uno::makeAny( nIndex ) ); + } + else + ScVbaFont_BASE::setColorIndex( _colorindex ); } @@ -284,26 +254,7 @@ ScVbaFont::getColorIndex() throw ( uno::RuntimeException ) if ( GetDataSet() ) if ( GetDataSet()->GetItemState( ATTR_FONT_COLOR, TRUE, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); - - // getColor returns Xl ColorValue, need to convert it to OO val - // as the palette deals with OO RGB values - // #FIXME this is daft in getColor we convert OO RGB val to XL RGB val - // and then back again to OO RGB value - XLRGBToOORGB( getColor() ) >>= nColor; - uno::Reference< container::XIndexAccess > xIndex = mPalette.getPalette(); - sal_Int32 nElems = xIndex->getCount(); - sal_Int32 nIndex = -1; - for ( sal_Int32 count=0; count<nElems; ++count ) - { - sal_Int32 nPaletteColor = 0; - xIndex->getByIndex( count ) >>= nPaletteColor; - if ( nPaletteColor == nColor ) - { - nIndex = count + 1; // 1 based - break; - } - } - return uno::makeAny( nIndex ); + return ScVbaFont_BASE::getColorIndex(); } ////////////////////////////////////////////////////////////////////////////////////////// @@ -396,28 +347,13 @@ ScVbaFont::getFontStyle() throw ( uno::RuntimeException ) return uno::makeAny( aStyles.makeStringAndClear() ); } -void SAL_CALL -ScVbaFont::setBold( const uno::Any& aValue ) throw( uno::RuntimeException ) -{ - sal_Bool bValue = sal_False; - aValue >>= bValue; - double fBoldValue = awt::FontWeight::NORMAL; - if( bValue ) - fBoldValue = awt::FontWeight::BOLD; - mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharWeight" ) ), ( uno::Any )fBoldValue ); - -} - uno::Any SAL_CALL ScVbaFont::getBold() throw ( uno::RuntimeException ) { if ( GetDataSet() ) if ( GetDataSet()->GetItemState( ATTR_FONT_WEIGHT, TRUE, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); - - double fValue = 0.0; - mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharWeight" ) ) ) >>= fValue; - return uno::makeAny( fValue == awt::FontWeight::BOLD ); + return ScVbaFont_BASE::getBold(); } void SAL_CALL @@ -481,32 +417,13 @@ ScVbaFont::getUnderline() throw ( uno::RuntimeException ) return uno::makeAny( nValue ); } -void SAL_CALL -ScVbaFont::setStrikethrough( const uno::Any& aValue ) throw ( uno::RuntimeException ) -{ - sal_Bool bValue = sal_False; - aValue >>= bValue; - short nValue = awt::FontStrikeout::NONE; - if( bValue ) - nValue = awt::FontStrikeout::SINGLE; - mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharStrikeout" ) ), ( uno::Any )nValue ); -} - uno::Any SAL_CALL ScVbaFont::getStrikethrough() throw ( uno::RuntimeException ) { if ( GetDataSet() ) if ( GetDataSet()->GetItemState( ATTR_FONT_CROSSEDOUT, TRUE, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); - short nValue = 0; - mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharStrikeout" ) ) ) >>= nValue; - return uno::Any( nValue == awt::FontStrikeout::SINGLE ); -} - -void SAL_CALL -ScVbaFont::setShadow( const uno::Any& aValue ) throw ( uno::RuntimeException ) -{ - mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharShadowed" ) ), aValue ); + return ScVbaFont_BASE::getStrikethrough(); } uno::Any SAL_CALL @@ -515,18 +432,7 @@ ScVbaFont::getShadow() throw (uno::RuntimeException) if ( GetDataSet() ) if ( GetDataSet()->GetItemState( ATTR_FONT_SHADOWED, TRUE, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); - return mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharShadowed" ) ) ); -} - -void SAL_CALL -ScVbaFont::setItalic( const uno::Any& aValue ) throw ( uno::RuntimeException ) -{ - sal_Bool bValue = sal_False; - aValue >>= bValue; - short nValue = awt::FontSlant_NONE; - if( bValue ) - nValue = awt::FontSlant_ITALIC; - mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharPosture" ) ), ( uno::Any )nValue ); + return ScVbaFont_BASE::getShadow(); } uno::Any SAL_CALL @@ -536,17 +442,7 @@ ScVbaFont::getItalic() throw ( uno::RuntimeException ) if ( GetDataSet()->GetItemState( ATTR_FONT_POSTURE, TRUE, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); - awt::FontSlant aFS; - mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharPosture" ) ) ) >>= aFS; - return uno::makeAny( aFS == awt::FontSlant_ITALIC ); -} - -void SAL_CALL -ScVbaFont::setName( const uno::Any& aValue ) throw ( uno::RuntimeException ) -{ - rtl::OUString sString; - aValue >>= sString; - mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharFontName" ) ), aValue); + return ScVbaFont_BASE::getItalic(); } uno::Any SAL_CALL @@ -555,22 +451,17 @@ ScVbaFont::getName() throw ( uno::RuntimeException ) if ( GetDataSet() ) if ( GetDataSet()->GetItemState( ATTR_FONT, TRUE, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); - return mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharFontName" ) ) ); + return ScVbaFont_BASE::getName(); } uno::Any ScVbaFont::getColor() throw (uno::RuntimeException) { + // #TODO #FIXME - behave like getXXX above ( wrt. GetDataSet ) uno::Any aAny; aAny = OORGBToXLRGB( mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharColor" ) ) ) ); return aAny; } -void -ScVbaFont::setColor( const uno::Any& _color ) throw (uno::RuntimeException) -{ - mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharColor" ) ) , XLRGBToOORGB(_color)); -} - void SAL_CALL ScVbaFont::setOutlineFont( const uno::Any& aValue ) throw ( uno::RuntimeException ) { diff --git a/sc/source/ui/vba/vbafont.hxx b/sc/source/ui/vba/vbafont.hxx index a0b9b2ebf140..625985564cda 100644 --- a/sc/source/ui/vba/vbafont.hxx +++ b/sc/source/ui/vba/vbafont.hxx @@ -32,19 +32,19 @@ #include <cppuhelper/implbase1.hxx> -#include <ooo/vba/excel/XFont.hpp> #include <com/sun/star/beans/XPropertySet.hpp> -#include "vbahelperinterface.hxx" +#include <ooo/vba/excel/XFont.hpp> +#include <vbahelper/vbahelperinterface.hxx> +#include <vbahelper/vbafontbase.hxx> #include "vbapalette.hxx" class ScTableSheetsObj; class ScCellRangeObj; -typedef InheritedHelperInterfaceImpl1< ov::excel::XFont > ScVbaFont_BASE; +typedef cppu::ImplInheritanceHelper1< VbaFontBase, ov::excel::XFont > ScVbaFont_BASE; class ScVbaFont : public ScVbaFont_BASE { - css::uno::Reference< css::beans::XPropertySet > mxFont; ScVbaPalette mPalette; ScCellRangeObj* mpRangeObj; SfxItemSet* GetDataSet(); @@ -54,7 +54,6 @@ public: // Attributes virtual css::uno::Any SAL_CALL getSize() throw (css::uno::RuntimeException); - virtual void SAL_CALL setSize( const css::uno::Any& _size ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getStandardFontSize() throw (css::uno::RuntimeException); virtual void SAL_CALL setStandardFontSize( const css::uno::Any& _standardfontsize ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getStandardFont() throw (css::uno::RuntimeException); @@ -64,23 +63,17 @@ public: virtual css::uno::Any SAL_CALL getColorIndex() throw (css::uno::RuntimeException); virtual void SAL_CALL setColorIndex( const css::uno::Any& _colorindex ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getBold() throw (css::uno::RuntimeException); - virtual void SAL_CALL setBold( const css::uno::Any& _bold ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getUnderline() throw (css::uno::RuntimeException); virtual void SAL_CALL setUnderline( const css::uno::Any& _underline ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getStrikethrough() throw (css::uno::RuntimeException); - virtual void SAL_CALL setStrikethrough( const css::uno::Any& _strikethrough ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getShadow() throw (css::uno::RuntimeException); - virtual void SAL_CALL setShadow( const css::uno::Any& _shadow ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getItalic() throw (css::uno::RuntimeException); - virtual void SAL_CALL setItalic( const css::uno::Any& _italic ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getSubscript() throw (css::uno::RuntimeException); virtual void SAL_CALL setSubscript( const css::uno::Any& _subscript ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getSuperscript() throw (css::uno::RuntimeException); virtual void SAL_CALL setSuperscript( const css::uno::Any& _superscript ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getName() throw (css::uno::RuntimeException); - virtual void SAL_CALL setName( const css::uno::Any& _name ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getColor() throw (css::uno::RuntimeException) ; - virtual void SAL_CALL setColor( const css::uno::Any& _color ) throw (css::uno::RuntimeException) ; virtual css::uno::Any SAL_CALL getOutlineFont() throw (css::uno::RuntimeException) ; virtual void SAL_CALL setOutlineFont( const css::uno::Any& _outlinefont ) throw (css::uno::RuntimeException) ; // XHelperInterface diff --git a/sc/source/ui/vba/vbaformat.cxx b/sc/source/ui/vba/vbaformat.cxx index a627ed3a4d92..1d30f92e1c6c 100644 --- a/sc/source/ui/vba/vbaformat.cxx +++ b/sc/source/ui/vba/vbaformat.cxx @@ -33,6 +33,7 @@ #include <ooo/vba/excel/XlHAlign.hpp> #include <ooo/vba/excel/XlOrientation.hpp> #include <ooo/vba/excel/Constants.hpp> +#include <ooo/vba/excel/XRange.hpp> #include <com/sun/star/table/CellVertJustify.hpp> #include <com/sun/star/table/CellHoriJustify.hpp> #include <com/sun/star/table/CellOrientation.hpp> @@ -341,7 +342,7 @@ template< typename Ifc1 > uno::Any SAL_CALL ScVbaFormat<Ifc1>::Borders( const uno::Any& Index ) throw (script::BasicErrorException, uno::RuntimeException ) { - ScVbaPalette aPalette( getDocShell( mxModel ) ); + ScVbaPalette aPalette( excel::getDocShell( mxModel ) ); uno::Reference< XCollection > xColl = new ScVbaBorders( thisHelperIface(), ScVbaFormat_BASE::mxContext, uno::Reference< table::XCellRange >( mxPropertySet, uno::UNO_QUERY_THROW ), aPalette ); if ( Index.hasValue() ) @@ -355,7 +356,7 @@ template< typename Ifc1 > uno::Reference< excel::XFont > SAL_CALL ScVbaFormat<Ifc1>::Font( ) throw (script::BasicErrorException, uno::RuntimeException) { - ScVbaPalette aPalette( getDocShell( mxModel ) ); + ScVbaPalette aPalette( excel::getDocShell( mxModel ) ); return new ScVbaFont( thisHelperIface(), ScVbaFormat_BASE::mxContext, aPalette, mxPropertySet ); } diff --git a/sc/source/ui/vba/vbaformat.hxx b/sc/source/ui/vba/vbaformat.hxx index afb5e5a45c29..cb33ad818f59 100644 --- a/sc/source/ui/vba/vbaformat.hxx +++ b/sc/source/ui/vba/vbaformat.hxx @@ -39,7 +39,7 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/Locale.hpp> #include <com/sun/star/beans/XPropertyState.hpp> -#include "vbahelperinterface.hxx" +#include <vbahelper/vbahelperinterface.hxx> template< typename Ifc1 > class ScVbaFormat : public InheritedHelperInterfaceImpl1< Ifc1 > diff --git a/sc/source/ui/vba/vbaformatconditions.cxx b/sc/source/ui/vba/vbaformatconditions.cxx index 06067d470177..1048cd91d2d3 100644 --- a/sc/source/ui/vba/vbaformatconditions.cxx +++ b/sc/source/ui/vba/vbaformatconditions.cxx @@ -36,6 +36,7 @@ #include "vbaformatcondition.hxx" #include "vbaworkbook.hxx" #include "vbastyles.hxx" +#include "vbaglobals.hxx" using namespace ::ooo::vba; using namespace ::com::sun::star; @@ -50,7 +51,7 @@ static rtl::OUString sStyleNamePrefix( RTL_CONSTASCII_USTRINGPARAM("Excel_CondFo ScVbaFormatConditions::ScVbaFormatConditions( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< sheet::XSheetConditionalEntries >& _xSheetConditionalEntries, const uno::Reference< frame::XModel >& xModel ) : ScVbaFormatConditions_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( _xSheetConditionalEntries, uno::UNO_QUERY_THROW ) ), mxSheetConditionalEntries( _xSheetConditionalEntries ) { mxRangeParent.set( xParent, uno::UNO_QUERY_THROW ); - uno::Reference< excel::XWorkbook > xWorkbook = new ScVbaWorkbook( uno::Reference< XHelperInterface >( ScVbaGlobals::getGlobalsImpl( xContext )->getApplication(), uno::UNO_QUERY_THROW ), xContext, xModel ); + uno::Reference< excel::XWorkbook > xWorkbook = new ScVbaWorkbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), xContext, xModel ); mxStyles.set( xWorkbook->Styles( uno::Any() ), uno::UNO_QUERY_THROW ); uno::Reference< sheet::XCellRangeAddressable > xCellRange( mxRangeParent->getCellRange(), uno::UNO_QUERY_THROW ); mxParentRangePropertySet.set( xCellRange, uno::UNO_QUERY_THROW ); diff --git a/sc/source/ui/vba/vbaformatconditions.hxx b/sc/source/ui/vba/vbaformatconditions.hxx index e5524a746638..177ddd168f35 100644 --- a/sc/source/ui/vba/vbaformatconditions.hxx +++ b/sc/source/ui/vba/vbaformatconditions.hxx @@ -35,7 +35,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/table/CellAddress.hpp> #include <com/sun/star/sheet/XSheetConditionalEntries.hpp> -#include "vbacollectionimpl.hxx" +#include <vbahelper/vbacollectionimpl.hxx> typedef CollTestImplHelper< ov::excel::XFormatConditions > ScVbaFormatConditions_BASE; class ScVbaFormatConditions: public ScVbaFormatConditions_BASE diff --git a/sc/source/ui/vba/vbaglobals.cxx b/sc/source/ui/vba/vbaglobals.cxx index 216a8a3d1f70..982289f0002e 100644 --- a/sc/source/ui/vba/vbaglobals.cxx +++ b/sc/source/ui/vba/vbaglobals.cxx @@ -27,13 +27,14 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#include "helperdecl.hxx" +#include <vbahelper/helperdecl.hxx> #include "vbaglobals.hxx" #include <comphelper/unwrapargs.hxx> #include <com/sun/star/lang/XMultiComponentFactory.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <cppuhelper/component_context.hxx> #include "vbaapplication.hxx" #include "vbaworksheet.hxx" @@ -49,11 +50,20 @@ using namespace ::ooo::vba; // ScVbaGlobals // ============================================================================= -ScVbaGlobals::ScVbaGlobals( css::uno::Reference< css::uno::XComponentContext >const& rxContext ) - :m_xContext( rxContext ) +//ScVbaGlobals::ScVbaGlobals( css::uno::Reference< css::uno::XComponentContext >const& rxContext, ) : ScVbaGlobals_BASE( uno::Reference< XHelperInterface >(), rxContext ) +rtl::OUString sDocCtxName( RTL_CONSTASCII_USTRINGPARAM("ExcelDocumentContext") ); + +ScVbaGlobals::ScVbaGlobals( uno::Sequence< uno::Any > const& aArgs, uno::Reference< uno::XComponentContext >const& rxContext ) : ScVbaGlobals_BASE( uno::Reference< XHelperInterface >(), rxContext, sDocCtxName ) { OSL_TRACE("ScVbaGlobals::ScVbaGlobals()"); - mxApplication = uno::Reference< excel::XApplication > ( new ScVbaApplication( m_xContext) ); + + uno::Sequence< beans::PropertyValue > aInitArgs( 2 ); + aInitArgs[ 0 ].Name = rtl::OUString::createFromAscii("Application"); + aInitArgs[ 0 ].Value = uno::makeAny( getApplication() ); + aInitArgs[ 1 ].Name = sDocCtxName; + aInitArgs[ 1 ].Value = uno::makeAny( getXSomethingFromArgs< frame::XModel >( aArgs, 0 ) ); + + init( aInitArgs ); } ScVbaGlobals::~ScVbaGlobals() @@ -61,23 +71,6 @@ ScVbaGlobals::~ScVbaGlobals() OSL_TRACE("ScVbaGlobals::~ScVbaGlobals"); } -// Will throw if singleton can't be accessed -uno::Reference< XGlobals > -ScVbaGlobals::getGlobalsImpl( const uno::Reference< uno::XComponentContext >& xContext ) throw ( uno::RuntimeException ) -{ - uno::Reference< XGlobals > xGlobals( - xContext->getValueByName( ::rtl::OUString::createFromAscii( - "/singletons/ooo.vba.theGlobals") ), uno::UNO_QUERY); - - if ( !xGlobals.is() ) - { - throw uno::RuntimeException( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": Couldn't access Globals" ) ), - uno::Reference< XInterface >() ); - } - return xGlobals; -} - // ============================================================================= // XGlobals // ============================================================================= @@ -85,14 +78,16 @@ uno::Reference<excel::XApplication > ScVbaGlobals::getApplication() throw (uno::RuntimeException) { // OSL_TRACE("In ScVbaGlobals::getApplication"); - return mxApplication; + if ( !mxApplication.is() ) + mxApplication.set( new ScVbaApplication( mxContext) ); + return mxApplication; } uno::Reference< excel::XWorkbook > SAL_CALL ScVbaGlobals::getActiveWorkbook() throw (uno::RuntimeException) { // OSL_TRACE("In ScVbaGlobals::getActiveWorkbook"); - uno::Reference< excel::XWorkbook > xWorkbook( mxApplication->getActiveWorkbook(), uno::UNO_QUERY); + uno::Reference< excel::XWorkbook > xWorkbook( getApplication()->getActiveWorkbook(), uno::UNO_QUERY); if ( xWorkbook.is() ) { return xWorkbook; @@ -103,22 +98,28 @@ ScVbaGlobals::getActiveWorkbook() throw (uno::RuntimeException) } +uno::Reference< excel::XWindow > SAL_CALL +ScVbaGlobals::getActiveWindow() throw (uno::RuntimeException) +{ + return getApplication()->getActiveWindow(); +} + uno::Reference< excel::XWorksheet > SAL_CALL ScVbaGlobals::getActiveSheet() throw (uno::RuntimeException) { - return mxApplication->getActiveSheet(); + return getApplication()->getActiveSheet(); } uno::Any SAL_CALL ScVbaGlobals::WorkBooks( const uno::Any& aIndex ) throw (uno::RuntimeException) { - return uno::Any( mxApplication->Workbooks(aIndex) ); + return uno::Any( getApplication()->Workbooks(aIndex) ); } uno::Any SAL_CALL ScVbaGlobals::WorkSheets(const uno::Any& aIndex) throw (uno::RuntimeException) { - return mxApplication->Worksheets( aIndex ); + return getApplication()->Worksheets( aIndex ); } uno::Any SAL_CALL ScVbaGlobals::Sheets( const uno::Any& aIndex ) throw (uno::RuntimeException) @@ -126,26 +127,6 @@ ScVbaGlobals::Sheets( const uno::Any& aIndex ) throw (uno::RuntimeException) return WorkSheets( aIndex ); } -::uno::Sequence< ::uno::Any > SAL_CALL -ScVbaGlobals::getGlobals( ) throw (::uno::RuntimeException) -{ - sal_uInt32 nMax = 0; - uno::Sequence< uno::Any > maGlobals(4); - maGlobals[ nMax++ ] <<= ScVbaGlobals::getGlobalsImpl(m_xContext); - maGlobals[ nMax++ ] <<= mxApplication; - - uno::Reference< excel::XWorkbook > xWorkbook = mxApplication->getActiveWorkbook(); - if( xWorkbook.is() ) - { - maGlobals[ nMax++ ] <<= xWorkbook; - uno::Reference< excel::XWorksheet > xWorksheet = xWorkbook->getActiveSheet(); - if( xWorksheet.is() ) - maGlobals[ nMax++ ] <<= xWorksheet; - } - maGlobals.realloc( nMax ); - return maGlobals; -} - uno::Any SAL_CALL ScVbaGlobals::Range( const uno::Any& Cell1, const uno::Any& Cell2 ) throw (uno::RuntimeException) { @@ -158,13 +139,140 @@ ScVbaGlobals::Names( const css::uno::Any& aIndex ) throw ( uno::RuntimeException return getApplication()->Names( aIndex ); } +uno::Reference< excel::XRange > SAL_CALL +ScVbaGlobals::getActiveCell() throw (uno::RuntimeException) +{ + return getApplication()->getActiveCell(); +} + +uno::Reference< XAssistant > SAL_CALL +ScVbaGlobals::getAssistant() throw (uno::RuntimeException) +{ + return getApplication()->getAssistant(); +} + +uno::Any SAL_CALL +ScVbaGlobals::getSelection() throw (uno::RuntimeException) +{ + return getApplication()->getSelection(); +} + +uno::Reference< excel::XWorkbook > SAL_CALL +ScVbaGlobals::getThisWorkbook() throw (uno::RuntimeException) +{ + return getApplication()->getThisWorkbook(); +} +void SAL_CALL +ScVbaGlobals::Calculate() throw (::com::sun::star::script::BasicErrorException, ::com::sun::star::uno::RuntimeException) +{ + return getApplication()->Calculate(); +} + +uno::Reference< excel::XRange > SAL_CALL +ScVbaGlobals::Cells( const uno::Any& RowIndex, const uno::Any& ColumnIndex ) throw (uno::RuntimeException) +{ + return getApplication()->getActiveSheet()->Cells( RowIndex, ColumnIndex ); +} +uno::Reference< excel::XRange > SAL_CALL +ScVbaGlobals::Columns( const uno::Any& aIndex ) throw (uno::RuntimeException) +{ + return getApplication()->getActiveSheet()->Columns( aIndex ); +} + +uno::Any SAL_CALL +ScVbaGlobals::CommandBars( const uno::Any& aIndex ) throw (uno::RuntimeException) +{ + uno::Reference< XApplicationBase > xBase( getApplication(), uno::UNO_QUERY_THROW ); + return xBase->CommandBars( aIndex ); +} + +css::uno::Reference< ov::excel::XRange > SAL_CALL +ScVbaGlobals::Union( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorException, css::uno::RuntimeException) +{ + return getApplication()->Union( Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10, Arg11, Arg12, Arg13, Arg14, Arg15, Arg16, Arg17, Arg18, Arg19, Arg20, Arg21, Arg22, Arg23, Arg24, Arg25, Arg26, Arg27, Arg28, Arg29, Arg30 ); +} +css::uno::Reference< ov::excel::XRange > SAL_CALL +ScVbaGlobals::Intersect( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorException, css::uno::RuntimeException) +{ + return getApplication()->Intersect( Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10, Arg11, Arg12, Arg13, Arg14, Arg15, Arg16, Arg17, Arg18, Arg19, Arg20, Arg21, Arg22, Arg23, Arg24, Arg25, Arg26, Arg27, Arg28, Arg29, Arg30 ); +} + +uno::Any SAL_CALL +ScVbaGlobals::Evaluate( const ::rtl::OUString& Name ) throw (uno::RuntimeException) +{ + return getApplication()->Evaluate( Name ); +} + +css::uno::Any SAL_CALL +ScVbaGlobals::WorksheetFunction( ) throw (css::uno::RuntimeException) +{ + return getApplication()->WorksheetFunction(); +} + +uno::Any SAL_CALL +ScVbaGlobals::Windows( const uno::Any& aIndex ) throw (uno::RuntimeException) +{ + return getApplication()->Windows( aIndex ); +} + +uno::Reference< excel::XRange > SAL_CALL +ScVbaGlobals::Rows( const uno::Any& aIndex ) throw (uno::RuntimeException) +{ + return getApplication()->getActiveSheet()->Rows( aIndex ); + +} + +uno::Sequence< ::rtl::OUString > SAL_CALL +ScVbaGlobals::getAvailableServiceNames( ) throw (uno::RuntimeException) +{ + static bool bInit = false; + static uno::Sequence< rtl::OUString > serviceNames( ScVbaGlobals_BASE::getAvailableServiceNames() ); + if ( !bInit ) + { + rtl::OUString names[] = { + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Range" ) ), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Workbook" ) ), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Window" ) ), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Worksheet" ) ), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Application" ) ), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Hyperlink" ) ), + }; + sal_Int32 nExcelServices = ( sizeof( names )/ sizeof( names[0] ) ); + sal_Int32 startIndex = serviceNames.getLength(); + serviceNames.realloc( serviceNames.getLength() + nExcelServices ); + for ( sal_Int32 index = 0; index < nExcelServices; ++index ) + serviceNames[ startIndex + index ] = names[ index ]; + bInit = true; + } + return serviceNames; +} + +rtl::OUString& +ScVbaGlobals::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaGlobals") ); + return sImplName; +} + +uno::Sequence< rtl::OUString > +ScVbaGlobals::getServiceNames() +{ + static uno::Sequence< rtl::OUString > aServiceNames; + if ( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc( 1 ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Globals" ) ); + } + return aServiceNames; +} + namespace globals { namespace sdecl = comphelper::service_decl; -sdecl::class_<ScVbaGlobals, sdecl::with_args<false> > serviceImpl; +sdecl::vba_service_class_<ScVbaGlobals, sdecl::with_args<true> > serviceImpl; extern sdecl::ServiceDecl const serviceDecl( serviceImpl, "ScVbaGlobals", - "ooo.vba.Globals" ); + "ooo.vba.excel.Globals" ); } diff --git a/sc/source/ui/vba/vbaglobals.hxx b/sc/source/ui/vba/vbaglobals.hxx index f24032d14ad9..25d36af55c8d 100644 --- a/sc/source/ui/vba/vbaglobals.hxx +++ b/sc/source/ui/vba/vbaglobals.hxx @@ -33,43 +33,65 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/uno/XComponentContext.hpp> -#include <ooo/vba/XGlobals.hpp> +#include <ooo/vba/excel/XGlobals.hpp> +#include <ooo/vba/excel/XApplication.hpp> #include <cppuhelper/implbase1.hxx> -#include "vbahelper.hxx" +#include "excelvbahelper.hxx" +#include <vbahelper/vbaglobalbase.hxx> // ============================================================================= // class ScVbaGlobals // ============================================================================= - typedef ::cppu::WeakImplHelper1< - ov::XGlobals > ScVbaGlobals_BASE; - +typedef ::cppu::ImplInheritanceHelper1< VbaGlobalsBase, ov::excel::XGlobals > ScVbaGlobals_BASE; class ScVbaGlobals : public ScVbaGlobals_BASE { - private: - css::uno::Reference< css::uno::XComponentContext > m_xContext; - css::uno::Reference< ov::excel::XApplication > mxApplication; + css::uno::Reference< ov::excel::XApplication > mxApplication; + virtual css::uno::Reference< + ov::excel::XApplication > SAL_CALL getApplication() + throw (css::uno::RuntimeException); public: - ScVbaGlobals( + ScVbaGlobals( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& rxContext ); + //ScVbaGlobals( + // css::uno::Reference< css::uno::XComponentContext >const& rxContext, ); virtual ~ScVbaGlobals(); - static css::uno::Reference< ov::XGlobals > getGlobalsImpl(const css::uno::Reference< css::uno::XComponentContext >& ) throw (css::uno::RuntimeException); - // XGlobals - virtual css::uno::Reference< - ov::excel::XApplication > SAL_CALL getApplication() - throw (css::uno::RuntimeException); virtual css::uno::Reference< ov::excel::XWorkbook > SAL_CALL getActiveWorkbook() throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::excel::XWindow > SAL_CALL getActiveWindow() throw (css::uno::RuntimeException); virtual css::uno::Reference< ov::excel::XWorksheet > SAL_CALL getActiveSheet() throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::XAssistant > SAL_CALL getAssistant() throw (css::uno::RuntimeException); + virtual void SAL_CALL Calculate( ) throw (::com::sun::star::script::BasicErrorException, ::com::sun::star::uno::RuntimeException); + + virtual css::uno::Any SAL_CALL getSelection() throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::excel::XRange > SAL_CALL getActiveCell() throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::excel::XWorkbook > SAL_CALL getThisWorkbook() throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Cells( const css::uno::Any& RowIndex, const css::uno::Any& ColumnIndex ) throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Columns( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL CommandBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL Evaluate( const ::rtl::OUString& Name ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL WorkSheets(const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL WorkBooks(const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL WorksheetFunction( ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL Windows( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL Sheets( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); - virtual css::uno::Sequence< css::uno::Any > SAL_CALL getGlobals( ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL Range( const css::uno::Any& Cell1, const css::uno::Any& Cell2 ) throw (css::uno::RuntimeException); + virtual css::uno::Reference< ::ooo::vba::excel::XRange > SAL_CALL Rows( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL Names( const css::uno::Any& aIndex ) throw ( css::uno::RuntimeException ); + virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Intersect( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorException, css::uno::RuntimeException); + virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Union( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorException, css::uno::RuntimeException); + + + + // XMultiServiceFactory + virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableServiceNames( ) throw (css::uno::RuntimeException); + // XHelperInterface + virtual rtl::OUString& getServiceImplName(); + virtual css::uno::Sequence<rtl::OUString> getServiceNames(); }; #endif // diff --git a/sc/source/ui/vba/vbahelper.cxx b/sc/source/ui/vba/vbahelper.cxx index 353c036393c2..e69de29bb2d1 100644 --- a/sc/source/ui/vba/vbahelper.cxx +++ b/sc/source/ui/vba/vbahelper.cxx @@ -1,828 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: vbahelper.cxx,v $ - * $Revision: 1.5.32.1 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <cppuhelper/bootstrap.hxx> -#include <com/sun/star/util/XURLTransformer.hpp> -#include <com/sun/star/frame/XDispatchProvider.hpp> -#include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/frame/XFrame.hpp> -#include <com/sun/star/frame/XDesktop.hpp> -#include <com/sun/star/frame/XController.hpp> -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/lang/XMultiComponentFactory.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/beans/XIntrospection.hpp> - -#include <comphelper/processfactory.hxx> - -#include <sfx2/objsh.hxx> -#include <sfx2/viewfrm.hxx> -#include <sfx2/dispatch.hxx> -#include <sfx2/app.hxx> -#include <svtools/stritem.hxx> - -#include <docuno.hxx> - -#include <basic/sbx.hxx> -#include <basic/sbstar.hxx> -#include <rtl/math.hxx> - -#include <math.h> -#include "vbahelper.hxx" -#include "tabvwsh.hxx" -#include "transobj.hxx" -#include "scmod.hxx" -#include "vbashape.hxx" -#include "unonames.hxx" -#include "cellsuno.hxx" -using namespace ::com::sun::star; -using namespace ::ooo::vba; - -#define POINTTO100THMILLIMETERFACTOR 35.27778 -void unoToSbxValue( SbxVariable* pVar, const uno::Any& aValue ); - -uno::Any sbxToUnoValue( SbxVariable* pVar ); - - -namespace ooo -{ -namespace vba -{ - -const double Millimeter::factor = 35.27778; - -uno::Reference< beans::XIntrospectionAccess > -getIntrospectionAccess( const uno::Any& aObject ) throw (uno::RuntimeException) -{ - static uno::Reference< beans::XIntrospection > xIntrospection; - if( !xIntrospection.is() ) - { - uno::Reference< lang::XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); - xIntrospection.set( xFactory->createInstance( rtl::OUString::createFromAscii("com.sun.star.beans.Introspection") ), uno::UNO_QUERY_THROW ); - } - return xIntrospection->inspect( aObject ); -} - -uno::Reference< script::XTypeConverter > -getTypeConverter( const uno::Reference< uno::XComponentContext >& xContext ) throw (uno::RuntimeException) -{ - static uno::Reference< script::XTypeConverter > xTypeConv( xContext->getServiceManager()->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.script.Converter") ), xContext ), uno::UNO_QUERY_THROW ); - return xTypeConv; -} -// helper method to determine if the view ( calc ) is in print-preview mode -bool isInPrintPreview( SfxViewFrame* pView ) -{ - sal_uInt16 nViewNo = SID_VIEWSHELL1 - SID_VIEWSHELL0; - if ( pView->GetObjectShell()->GetFactory().GetViewFactoryCount() > -nViewNo && !pView->GetObjectShell()->IsInPlaceActive() ) - { - SfxViewFactory &rViewFactory = - pView->GetObjectShell()->GetFactory().GetViewFactory(nViewNo); - if ( pView->GetCurViewId() == rViewFactory.GetOrdinal() ) - return true; - } - return false; -} -const ::rtl::OUString REPLACE_CELLS_WARNING( RTL_CONSTASCII_USTRINGPARAM( "ReplaceCellsWarning")); -const uno::Any& -aNULL() -{ - static uno::Any aNULLL = uno::makeAny( uno::Reference< uno::XInterface >() ); - return aNULLL; -} - -class PasteCellsWarningReseter -{ -private: - bool bInitialWarningState; - static uno::Reference< beans::XPropertySet > getGlobalSheetSettings() throw ( uno::RuntimeException ) - { - static uno::Reference< beans::XPropertySet > xTmpProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); - static uno::Reference<uno::XComponentContext > xContext( xTmpProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW ); - static uno::Reference<lang::XMultiComponentFactory > xServiceManager( - xContext->getServiceManager(), uno::UNO_QUERY_THROW ); - static uno::Reference< beans::XPropertySet > xProps( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.GlobalSheetSettings" ) ) ,xContext ), uno::UNO_QUERY_THROW ); - return xProps; - } - - bool getReplaceCellsWarning() throw ( uno::RuntimeException ) - { - sal_Bool res = sal_False; - getGlobalSheetSettings()->getPropertyValue( REPLACE_CELLS_WARNING ) >>= res; - return ( res == sal_True ); - } - - void setReplaceCellsWarning( bool bState ) throw ( uno::RuntimeException ) - { - getGlobalSheetSettings()->setPropertyValue( REPLACE_CELLS_WARNING, uno::makeAny( bState ) ); - } -public: - PasteCellsWarningReseter() throw ( uno::RuntimeException ) - { - bInitialWarningState = getReplaceCellsWarning(); - if ( bInitialWarningState ) - setReplaceCellsWarning( false ); - } - ~PasteCellsWarningReseter() - { - if ( bInitialWarningState ) - { - // don't allow dtor to throw - try - { - setReplaceCellsWarning( true ); - } - catch ( uno::Exception& /*e*/ ){} - } - } -}; - -void -dispatchRequests (uno::Reference< frame::XModel>& xModel,rtl::OUString & aUrl, uno::Sequence< beans::PropertyValue >& sProps ) -{ - - util::URL url ; - url.Complete = aUrl; - rtl::OUString emptyString = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "" )); - uno::Reference<frame::XController> xController = xModel->getCurrentController(); - uno::Reference<frame::XFrame> xFrame = xController->getFrame(); - uno::Reference<frame::XDispatchProvider> xDispatchProvider (xFrame,uno::UNO_QUERY_THROW); - try - { - uno::Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); - uno::Reference<uno::XComponentContext > xContext( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW ); - if ( !xContext.is() ) - { - return ; - } - - uno::Reference<lang::XMultiComponentFactory > xServiceManager( - xContext->getServiceManager() ); - if ( !xServiceManager.is() ) - { - return ; - } - uno::Reference<util::XURLTransformer> xParser( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ) ) - ,xContext), uno::UNO_QUERY_THROW ); - if (!xParser.is()) - return; - xParser->parseStrict (url); - } - catch ( uno::Exception & /*e*/ ) - { - return ; - } - - uno::Reference<frame::XDispatch> xDispatcher = xDispatchProvider->queryDispatch(url,emptyString,0); - - uno::Sequence<beans::PropertyValue> dispatchProps(1); - - sal_Int32 nProps = sProps.getLength(); - beans::PropertyValue* pDest = dispatchProps.getArray(); - if ( nProps ) - { - dispatchProps.realloc( nProps + 1 ); - // need to reaccquire pDest after realloc - pDest = dispatchProps.getArray(); - beans::PropertyValue* pSrc = sProps.getArray(); - for ( sal_Int32 index=0; index<nProps; ++index, ++pSrc, ++pDest ) - *pDest = *pSrc; - } - - (*pDest).Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Silent" )); - (*pDest).Value <<= (sal_Bool)sal_True; - - if (xDispatcher.is()) - xDispatcher->dispatch( url, dispatchProps ); -} - -void -dispatchRequests (uno::Reference< frame::XModel>& xModel,rtl::OUString & aUrl) -{ - uno::Sequence<beans::PropertyValue> dispatchProps; - dispatchRequests( xModel, aUrl, dispatchProps ); -} - - -void dispatchExecute(css::uno::Reference< css::frame::XModel>& xModel, USHORT nSlot, SfxCallMode nCall) -{ - ScTabViewShell* pViewShell = getBestViewShell( xModel ); - SfxViewFrame* pViewFrame = NULL; - if ( pViewShell ) - pViewFrame = pViewShell->GetViewFrame(); - if ( pViewFrame ) - { - SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher(); - if( pDispatcher ) - { - pDispatcher->Execute( nSlot , nCall ); - } - } -} - -void -implnPaste() -{ - PasteCellsWarningReseter resetWarningBox; - ScTabViewShell* pViewShell = getCurrentBestViewShell(); - if ( pViewShell ) - { - pViewShell->PasteFromSystem(); - pViewShell->CellContentChanged(); - } -} - - -void -implnCopy() -{ - ScTabViewShell* pViewShell = getCurrentBestViewShell(); - if ( pViewShell ) - pViewShell->CopyToClip(NULL,false,false,true); -} - -void -implnCut() -{ - ScTabViewShell* pViewShell = getCurrentBestViewShell(); - if ( pViewShell ) - pViewShell->CutToClip( NULL, TRUE ); -} - -void implnPasteSpecial(USHORT nFlags,USHORT nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose) -{ - PasteCellsWarningReseter resetWarningBox; - sal_Bool bAsLink(sal_False), bOtherDoc(sal_False); - InsCellCmd eMoveMode = INS_NONE; - - ScTabViewShell* pTabViewShell = ScTabViewShell::GetActiveViewShell(); - if ( !pTabViewShell ) - // none active, try next best - pTabViewShell = getCurrentBestViewShell(); - if ( pTabViewShell ) - { - ScViewData* pView = pTabViewShell->GetViewData(); - Window* pWin = ( pView != NULL ) ? pView->GetActiveWin() : NULL; - if ( pView && pWin ) - { - if ( bAsLink && bOtherDoc ) - pTabViewShell->PasteFromSystem(0);//SOT_FORMATSTR_ID_LINK - else - { - ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin ); - ScDocument* pDoc = NULL; - if ( pOwnClip ) - pDoc = pOwnClip->GetDocument(); - pTabViewShell->PasteFromClip( nFlags, pDoc, - nFunction, bSkipEmpty, bTranspose, bAsLink, - eMoveMode, IDF_NONE, TRUE ); - pTabViewShell->CellContentChanged(); - } - } - } - -} - - uno::Reference< frame::XModel > -getCurrentDocument() throw (uno::RuntimeException) -{ - uno::Reference< frame::XModel > xModel; - SbxObject* pBasic = dynamic_cast< SbxObject* > ( SFX_APP()->GetBasic() ); - SbxObject* basicChosen = pBasic ; - if ( basicChosen == NULL) - { - OSL_TRACE("getModelFromBasic() StarBASIC* is NULL" ); - return xModel; - } - SbxObject* p = pBasic; - SbxObject* pParent = p->GetParent(); - SbxObject* pParentParent = pParent ? pParent->GetParent() : NULL; - - if( pParentParent ) - { - basicChosen = pParentParent; - } - else if( pParent ) - { - basicChosen = pParent; - } - - - uno::Any aModel; - SbxVariable *pCompVar = basicChosen->Find( UniString(RTL_CONSTASCII_USTRINGPARAM("ThisComponent")), SbxCLASS_OBJECT ); - - if ( pCompVar ) - { - aModel = sbxToUnoValue( pCompVar ); - if ( sal_False == ( aModel >>= xModel ) || - !xModel.is() ) - { - // trying last gasp try the current component - uno::Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); - // test if vba service is present - uno::Reference< uno::XComponentContext > xCtx( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW ); - uno::Reference<lang::XMultiComponentFactory > xSMgr( xCtx->getServiceManager(), uno::UNO_QUERY_THROW ); - uno::Reference< frame::XDesktop > xDesktop (xSMgr->createInstanceWithContext(::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop"), xCtx), uno::UNO_QUERY_THROW ); - xModel.set( xDesktop->getCurrentComponent(), uno::UNO_QUERY ); - if ( !xModel.is() ) - { - throw uno::RuntimeException( - 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 >() ); - } - return xModel; - } - else - { - OSL_TRACE("Have model ThisComponent points to url %s", - ::rtl::OUStringToOString( xModel->getURL(), - RTL_TEXTENCODING_ASCII_US ).pData->buffer ); - } - } - else - { - OSL_TRACE("Failed to get ThisComponent"); - throw uno::RuntimeException( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "Can't determine the currently selected document") ), - uno::Reference< uno::XInterface >() ); - } - return xModel; -} - -ScDocShell* -getDocShell( css::uno::Reference< css::frame::XModel>& xModel ) -{ - uno::Reference< uno::XInterface > xIf( xModel, uno::UNO_QUERY_THROW ); - ScModelObj* pModel = dynamic_cast< ScModelObj* >( xIf.get() ); - ScDocShell* pDocShell = NULL; - if ( pModel ) - pDocShell = (ScDocShell*)pModel->GetEmbeddedObject(); - return pDocShell; - -} - -ScTabViewShell* -getBestViewShell( css::uno::Reference< css::frame::XModel>& xModel ) -{ - ScDocShell* pDocShell = getDocShell( xModel ); - if ( pDocShell ) - return pDocShell->GetBestViewShell(); - return NULL; -} - -ScTabViewShell* -getCurrentBestViewShell() -{ - uno::Reference< frame::XModel > xModel = getCurrentDocument(); - return getBestViewShell( xModel ); -} - -SfxViewFrame* -getCurrentViewFrame() -{ - ScTabViewShell* pViewShell = getCurrentBestViewShell(); - if ( pViewShell ) - return pViewShell->GetViewFrame(); - return NULL; -} - -sal_Int32 -OORGBToXLRGB( sal_Int32 nCol ) -{ - sal_Int32 nRed = nCol; - nRed &= 0x00FF0000; - nRed >>= 16; - sal_Int32 nGreen = nCol; - nGreen &= 0x0000FF00; - nGreen >>= 8; - sal_Int32 nBlue = nCol; - nBlue &= 0x000000FF; - sal_Int32 nRGB = ( (nBlue << 16) | (nGreen << 8) | nRed ); - return nRGB; -} -sal_Int32 -XLRGBToOORGB( sal_Int32 nCol ) -{ - sal_Int32 nBlue = nCol; - nBlue &= 0x00FF0000; - nBlue >>= 16; - sal_Int32 nGreen = nCol; - nGreen &= 0x0000FF00; - nGreen >>= 8; - sal_Int32 nRed = nCol; - nRed &= 0x000000FF; - sal_Int32 nRGB = ( (nRed << 16) | (nGreen << 8) | nBlue ); - return nRGB; -} -uno::Any -OORGBToXLRGB( const uno::Any& aCol ) -{ - sal_Int32 nCol=0; - aCol >>= nCol; - nCol = OORGBToXLRGB( nCol ); - return uno::makeAny( nCol ); -} -uno::Any -XLRGBToOORGB( const uno::Any& aCol ) -{ - sal_Int32 nCol=0; - aCol >>= nCol; - nCol = XLRGBToOORGB( nCol ); - return uno::makeAny( nCol ); -} - -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 ) -{ - sal_Int32 nTo = 0; - sal_Int32 nFrom = 0; - sal_Int16 nCopies = 1; - sal_Bool bPreview = sal_False; - sal_Bool bCollate = sal_False; - sal_Bool bSelection = bUseSelection; - From >>= nFrom; - To >>= nTo; - Copies >>= nCopies; - Preview >>= bPreview; - if ( nCopies > 1 ) // Collate only useful when more that 1 copy - Collate >>= bCollate; - - rtl::OUString sRange( RTL_CONSTASCII_USTRINGPARAM( "-" ) ); - rtl::OUString sFileName; - - if (( nFrom || nTo ) ) - { - if ( nFrom ) - sRange = ( ::rtl::OUString::valueOf( nFrom ) + sRange ); - if ( nTo ) - sRange += ::rtl::OUString::valueOf( nTo ); - } - - if ( PrToFileName.getValue() ) - { - PrToFileName >>= sFileName; - } - ScTabViewShell* pViewShell = getBestViewShell( xModel ); - SfxViewFrame* pViewFrame = NULL; - if ( pViewShell ) - pViewFrame = pViewShell->GetViewFrame(); - if ( pViewFrame ) - { - SfxAllItemSet aArgs( SFX_APP()->GetPool() ); - - SfxBoolItem sfxCollate( SID_PRINT_COLLATE, bCollate ); - aArgs.Put( sfxCollate, sfxCollate.Which() ); - SfxInt16Item sfxCopies( SID_PRINT_COPIES, nCopies ); - aArgs.Put( sfxCopies, sfxCopies.Which() ); - if ( sFileName.getLength() ) - { - SfxStringItem sfxFileName( SID_FILE_NAME, sFileName); - aArgs.Put( sfxFileName, sfxFileName.Which() ); - - } - if ( sRange.getLength() ) - { - SfxStringItem sfxRange( SID_PRINT_PAGES, sRange ); - aArgs.Put( sfxRange, sfxRange.Which() ); - } - SfxBoolItem sfxSelection( SID_SELECTION, bSelection ); - aArgs.Put( sfxSelection, sfxSelection.Which() ); - SfxBoolItem sfxAsync( SID_ASYNCHRON, sal_False ); - aArgs.Put( sfxAsync, sfxAsync.Which() ); - SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher(); - - if ( pDispatcher ) - { - if ( bPreview ) - { - if ( !pViewFrame->GetFrame()->IsInPlace() ) - { - SC_MOD()->InputEnterHandler(); - pViewFrame->GetDispatcher()->Execute( SID_VIEWSHELL1, SFX_CALLMODE_SYNCHRON ); - while ( isInPrintPreview( pViewFrame ) ) - Application::Yield(); - } - } - else - pDispatcher->Execute( (USHORT)SID_PRINTDOC, (SfxCallMode)SFX_CALLMODE_SYNCHRON, aArgs ); - } - - } - - // #FIXME #TODO - // 1 ActivePrinter ( how/can we switch a printer via API? ) - // 2 PrintToFile ( ms behaviour if this option is specified but no - // filename supplied 'PrToFileName' then the user will be prompted ) - // 3 Need to check behaviour of Selected sheets with range ( e.g. From & To - // values ) in oOO these options are mutually exclusive - // 4 There is a pop up to do with transparent objects in the print source - // should be able to disable that via configuration for the duration - // of this method -} - - void PrintPreviewHelper( const css::uno::Any& /*EnableChanges*/, css::uno::Reference< css::frame::XModel >& xModel ) -{ - dispatchExecute( xModel, SID_VIEWSHELL1 ); -} - -rtl::OUString getAnyAsString( const uno::Any& pvargItem ) throw ( uno::RuntimeException ) -{ - uno::Type aType = pvargItem.getValueType(); - uno::TypeClass eTypeClass = aType.getTypeClass(); - rtl::OUString sString; - switch ( eTypeClass ) - { - case uno::TypeClass_BOOLEAN: - { - sal_Bool bBool = sal_False; - pvargItem >>= bBool; - sString = rtl::OUString::valueOf( bBool ); - break; - } - case uno::TypeClass_STRING: - pvargItem >>= sString; - break; - case uno::TypeClass_FLOAT: - { - float aFloat = 0; - pvargItem >>= aFloat; - sString = rtl::OUString::valueOf( aFloat ); - break; - } - case uno::TypeClass_DOUBLE: - { - double aDouble = 0; - pvargItem >>= aDouble; - sString = rtl::OUString::valueOf( aDouble ); - break; - } - case uno::TypeClass_SHORT: - case uno::TypeClass_LONG: - case uno::TypeClass_BYTE: - { - sal_Int32 aNum = 0; - pvargItem >>= aNum; - sString = rtl::OUString::valueOf( aNum ); - break; - } - - case uno::TypeClass_HYPER: - { - sal_Int64 aHyper = 0; - pvargItem >>= aHyper; - sString = rtl::OUString::valueOf( aHyper ); - break; - } - default: - throw uno::RuntimeException( rtl::OUString::createFromAscii( "Invalid type, can't convert" ), uno::Reference< uno::XInterface >() ); - } - return sString; -} - - -rtl::OUString -ContainerUtilities::getUniqueName( const uno::Sequence< ::rtl::OUString >& _slist, const rtl::OUString& _sElementName, const ::rtl::OUString& _sSuffixSeparator) -{ - return getUniqueName(_slist, _sElementName, _sSuffixSeparator, sal_Int32(2)); -} - -rtl::OUString -ContainerUtilities::getUniqueName( const uno::Sequence< rtl::OUString >& _slist, const rtl::OUString _sElementName, const rtl::OUString& _sSuffixSeparator, sal_Int32 _nStartSuffix) -{ - sal_Int32 a = _nStartSuffix; - rtl::OUString scompname = _sElementName; - bool bElementexists = true; - sal_Int32 nLen = _slist.getLength(); - if ( nLen == 0 ) - return _sElementName; - - while (bElementexists == true) - { - for (sal_Int32 i = 0; i < nLen; i++) - { - if (FieldInList(_slist, scompname) == -1) - { - return scompname; - } - } - scompname = _sElementName + _sSuffixSeparator + rtl::OUString::valueOf( a++ ); - } - return rtl::OUString(); -} - -sal_Int32 -ContainerUtilities::FieldInList( const uno::Sequence< rtl::OUString >& SearchList, const rtl::OUString& SearchString ) -{ - sal_Int32 FieldLen = SearchList.getLength(); - sal_Int32 retvalue = -1; - for (sal_Int32 i = 0; i < FieldLen; i++) - { - // I wonder why comparing lexicographically is done - // when its a match is whats interesting? - //if (SearchList[i].compareTo(SearchString) == 0) - if ( SearchList[i].equals( SearchString ) ) - { - retvalue = i; - break; - } - } - return retvalue; - -} -bool NeedEsc(sal_Unicode cCode) -{ - String sEsc(RTL_CONSTASCII_USTRINGPARAM(".^$+\\|{}()")); - return (STRING_NOTFOUND != sEsc.Search(cCode)); -} - -rtl::OUString VBAToRegexp(const rtl::OUString &rIn, bool bForLike ) -{ - rtl::OUStringBuffer sResult; - const sal_Unicode *start = rIn.getStr(); - const sal_Unicode *end = start + rIn.getLength(); - - int seenright = 0; - if ( bForLike ) - sResult.append(static_cast<sal_Unicode>('^')); - - while (start < end) - { - switch (*start) - { - case '?': - sResult.append(static_cast<sal_Unicode>('.')); - start++; - break; - case '*': - sResult.append(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".*"))); - start++; - break; - case '#': - sResult.append(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("[0-9]"))); - start++; - break; - case '~': - sResult.append(static_cast<sal_Unicode>('\\')); - sResult.append(*(++start)); - start++; - break; - // dump the ~ and escape the next characture - case ']': - sResult.append(static_cast<sal_Unicode>('\\')); - sResult.append(*start++); - break; - case '[': - sResult.append(*start++); - seenright = 0; - while (start < end && !seenright) - { - switch (*start) - { - case '[': - case '?': - case '*': - sResult.append(static_cast<sal_Unicode>('\\')); - sResult.append(*start); - break; - case ']': - sResult.append(*start); - seenright = 1; - break; - case '!': - sResult.append(static_cast<sal_Unicode>('^')); - break; - default: - if (NeedEsc(*start)) - sResult.append(static_cast<sal_Unicode>('\\')); - sResult.append(*start); - break; - } - start++; - } - break; - default: - if (NeedEsc(*start)) - sResult.append(static_cast<sal_Unicode>('\\')); - sResult.append(*start++); - } - } - - if ( bForLike ) - sResult.append(static_cast<sal_Unicode>('$')); - - return sResult.makeStringAndClear( ); -} - -double getPixelTo100thMillimeterConversionFactor( css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical) -{ - double fConvertFactor = 1.0; - if( bVertical ) - { - fConvertFactor = xDevice->getInfo().PixelPerMeterY/100000; - } - else - { - fConvertFactor = xDevice->getInfo().PixelPerMeterX/100000; - } - return fConvertFactor; -} - -double PointsToPixels( css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical) -{ - double fConvertFactor = getPixelTo100thMillimeterConversionFactor( xDevice, bVertical ); - return fPoints * POINTTO100THMILLIMETERFACTOR * fConvertFactor; -} -double PixelsToPoints( css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical) -{ - double fConvertFactor = getPixelTo100thMillimeterConversionFactor( xDevice, bVertical ); - return (fPixels/fConvertFactor)/POINTTO100THMILLIMETERFACTOR; -} - -ConcreteXShapeGeometryAttributes::ConcreteXShapeGeometryAttributes( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::drawing::XShape >& xShape ) -{ - m_xShape = new ScVbaShape( xContext, xShape ); -} - -#define VBA_LEFT "PositionX" -#define VBA_TOP "PositionY" -UserFormGeometryHelper::UserFormGeometryHelper( const uno::Reference< uno::XComponentContext >& /*xContext*/, const uno::Reference< awt::XControl >& xControl ) -{ - mxModel.set( xControl->getModel(), uno::UNO_QUERY_THROW ); -} - double UserFormGeometryHelper::getLeft() - { - sal_Int32 nLeft = 0; - mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_LEFT ) ) ) >>= nLeft; - return Millimeter::getInPoints( nLeft ); - } - void UserFormGeometryHelper::setLeft( double nLeft ) - { - mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_LEFT ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nLeft ) ) ); - } - double UserFormGeometryHelper::getTop() - { - sal_Int32 nTop = 0; - mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_TOP ) ) ) >>= nTop; - return Millimeter::getInPoints( nTop ); - } - void UserFormGeometryHelper::setTop( double nTop ) - { - mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_TOP ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nTop ) ) ); - } - double UserFormGeometryHelper::getHeight() - { - sal_Int32 nHeight = 0; - mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLHGT ) ) ) >>= nHeight; - return Millimeter::getInPoints( nHeight ); - } - void UserFormGeometryHelper::setHeight( double nHeight ) - { - mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLHGT ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nHeight ) ) ); - } - double UserFormGeometryHelper::getWidth() - { - sal_Int32 nWidth = 0; - mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLWID ) ) ) >>= nWidth; - return Millimeter::getInPoints( nWidth ); - } - void UserFormGeometryHelper::setWidth( double nWidth) - { - mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLWID ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nWidth ) ) ); - } - -SfxItemSet* -ScVbaCellRangeAccess::GetDataSet( ScCellRangeObj* pRangeObj ) -{ - SfxItemSet* pDataSet = pRangeObj ? pRangeObj->GetCurrentDataSet( true ) : NULL ; - return pDataSet; - -} - -} // openoffice -} //org diff --git a/sc/source/ui/vba/vbahyperlink.cxx b/sc/source/ui/vba/vbahyperlink.cxx index 27bcfaa28145..f6aa8cf8c4cb 100644 --- a/sc/source/ui/vba/vbahyperlink.cxx +++ b/sc/source/ui/vba/vbahyperlink.cxx @@ -32,7 +32,7 @@ * MA 02111-1307 USA * ************************************************************************/ -#include "helperdecl.hxx" +#include <vbahelper/helperdecl.hxx> #include "vbahyperlink.hxx" #include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/text/XTextFieldsSupplier.hpp> diff --git a/sc/source/ui/vba/vbahyperlink.hxx b/sc/source/ui/vba/vbahyperlink.hxx index 2789b4d133b2..a72eeb325ac6 100644 --- a/sc/source/ui/vba/vbahyperlink.hxx +++ b/sc/source/ui/vba/vbahyperlink.hxx @@ -40,7 +40,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <ooo/vba/excel/XRange.hpp> -#include "vbahelperinterface.hxx" +#include <vbahelper/vbahelperinterface.hxx> typedef InheritedHelperInterfaceImpl1< ov::excel::XHyperlink > HyperlinkImpl_BASE; diff --git a/sc/source/ui/vba/vbainterior.cxx b/sc/source/ui/vba/vbainterior.cxx index bb85b6c21922..9c309c997ed3 100644 --- a/sc/source/ui/vba/vbainterior.cxx +++ b/sc/source/ui/vba/vbainterior.cxx @@ -163,10 +163,18 @@ ScVbaInterior::setColorIndex( const css::uno::Any& _colorindex ) throw (css::uno sal_Int32 nIndex = 0; _colorindex >>= nIndex; - // setColor expects colors in XL RGB values - // #FIXME this is daft we convert OO RGB val to XL RGB val and - // then back again to OO RGB value - setColor( OORGBToXLRGB( GetIndexColor( nIndex ) ) ); + // hackly for excel::XlColorIndex::xlColorIndexNone + if( nIndex == excel::XlColorIndex::xlColorIndexNone ) + { + m_xProps->setPropertyValue( BACKCOLOR, uno::makeAny( sal_Int32( -1 ) ) ); + } + else + { + // setColor expects colors in XL RGB values + // #FIXME this is daft we convert OO RGB val to XL RGB val and + // then back again to OO RGB value + setColor( OORGBToXLRGB( GetIndexColor( nIndex ) ) ); + } } uno::Any ScVbaInterior::GetIndexColor( const sal_Int32& nColorIndex ) @@ -204,13 +212,21 @@ uno::Any SAL_CALL ScVbaInterior::getColorIndex() throw ( css::uno::RuntimeException ) { sal_Int32 nColor = 0; + // hackly for excel::XlColorIndex::xlColorIndexNone + uno::Any aColor = m_xProps->getPropertyValue( BACKCOLOR ); + if( ( aColor >>= nColor ) && ( nColor == -1 ) ) + { + nColor = excel::XlColorIndex::xlColorIndexNone; + return uno::makeAny( nColor ); + } + // getColor returns Xl ColorValue, need to convert it to OO val // as the palette deals with OO RGB values // #FIXME this is daft in getColor we convert OO RGB val to XL RGB val // and then back again to OO RGB value XLRGBToOORGB( getColor() ) >>= nColor; - return uno::makeAny( GetIndexColor( nColor ) ); + return uno::makeAny( GetColorIndex( nColor ) ); } Color ScVbaInterior::GetPatternColor( const Color& rPattColor, const Color& rBackColor, sal_uInt32 nXclPattern ) diff --git a/sc/source/ui/vba/vbainterior.hxx b/sc/source/ui/vba/vbainterior.hxx index 1184d33e6cd9..d3ca677d4890 100644 --- a/sc/source/ui/vba/vbainterior.hxx +++ b/sc/source/ui/vba/vbainterior.hxx @@ -34,9 +34,10 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/script/XInvocation.hpp> -#include "vbahelperinterface.hxx" +#include <vbahelper/vbahelperinterface.hxx> class ScDocument; diff --git a/sc/source/ui/vba/vbaname.cxx b/sc/source/ui/vba/vbaname.cxx index 72ef5afb3b7f..0d82f4ee45f8 100644 --- a/sc/source/ui/vba/vbaname.cxx +++ b/sc/source/ui/vba/vbaname.cxx @@ -27,7 +27,7 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#include "helperdecl.hxx" +#include <vbahelper/helperdecl.hxx> #include <com/sun/star/table/XCellRange.hpp> #include <com/sun/star/sheet/XCellRangeAddressable.hpp> @@ -64,7 +64,8 @@ ScVbaName::~ScVbaName() css::uno::Reference< ov::excel::XWorksheet > ScVbaName::getWorkSheet() throw (css::uno::RuntimeException) { - return ScVbaGlobals::getGlobalsImpl( mxContext )->getActiveSheet(); + uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW ); + return xApplication->getActiveSheet(); } ::rtl::OUString @@ -234,7 +235,7 @@ ScVbaName::setRefersToR1C1Local( const ::rtl::OUString & rRefersTo ) throw (css: css::uno::Reference< ov::excel::XRange > ScVbaName::getRefersToRange() throw (css::uno::RuntimeException) { - uno::Reference< ov::excel::XRange > xRange = ScVbaRange::getRangeObjectForName( mxContext, mxNamedRange->getName(), getDocShell( mxModel ), formula::FormulaGrammar::CONV_XL_R1C1 ); + uno::Reference< ov::excel::XRange > xRange = ScVbaRange::getRangeObjectForName( mxContext, mxNamedRange->getName(), excel::getDocShell( mxModel ), formula::FormulaGrammar::CONV_XL_R1C1 ); return xRange; } diff --git a/sc/source/ui/vba/vbaname.hxx b/sc/source/ui/vba/vbaname.hxx index 691a882cb3e1..6fb585100d4c 100644 --- a/sc/source/ui/vba/vbaname.hxx +++ b/sc/source/ui/vba/vbaname.hxx @@ -34,7 +34,9 @@ #include <com/sun/star/sheet/XNamedRange.hpp> #include <com/sun/star/sheet/XNamedRanges.hpp> -#include "vbahelperinterface.hxx" +#include <vbahelper/vbahelperinterface.hxx> + +class ScDocument; typedef InheritedHelperInterfaceImpl1< ov::excel::XName > NameImpl_BASE; diff --git a/sc/source/ui/vba/vbanames.cxx b/sc/source/ui/vba/vbanames.cxx index 1bd3a2359377..043e7d386f15 100644 --- a/sc/source/ui/vba/vbanames.cxx +++ b/sc/source/ui/vba/vbanames.cxx @@ -27,7 +27,7 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#include "helperdecl.hxx" +#include <vbahelper/helperdecl.hxx> #include <com/sun/star/table/XCellRange.hpp> #include <com/sun/star/sheet/XCellRangeAddressable.hpp> @@ -81,7 +81,7 @@ ScDocument * ScVbaNames::getScDocument() { uno::Reference< frame::XModel > xModel( getModel() , uno::UNO_QUERY_THROW ); - ScTabViewShell * pTabViewShell = getBestViewShell( xModel ); + ScTabViewShell * pTabViewShell = excel::getBestViewShell( xModel ); if ( !pTabViewShell ) throw uno::RuntimeException( rtl::OUString::createFromAscii("No ViewShell available"), uno::Reference< uno::XInterface >() ); ScViewData* pViewData = pTabViewShell->GetViewData(); diff --git a/sc/source/ui/vba/vbanames.hxx b/sc/source/ui/vba/vbanames.hxx index 02a86da325b5..524277bdc0bd 100644 --- a/sc/source/ui/vba/vbanames.hxx +++ b/sc/source/ui/vba/vbanames.hxx @@ -34,7 +34,10 @@ #include <ooo/vba/XCollection.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/sheet/XNamedRanges.hpp> -#include "vbacollectionimpl.hxx" +#include <vbahelper/vbacollectionimpl.hxx> + +class ScDocument; +class ScDocShell; typedef CollTestImplHelper< ov::excel::XNames > ScVbaNames_BASE; diff --git a/sc/source/ui/vba/vbaoleobject.cxx b/sc/source/ui/vba/vbaoleobject.cxx index 455141cf03fd..64e5f05f90e1 100644 --- a/sc/source/ui/vba/vbaoleobject.cxx +++ b/sc/source/ui/vba/vbaoleobject.cxx @@ -33,6 +33,7 @@ #include <com/sun/star/view/XControlAccess.hpp> #include <com/sun/star/container/XChild.hpp> #include <com/sun/star/drawing/XShape.hpp> +#include <ooo/vba/XControlProvider.hpp> #include "vbaoleobject.hxx" @@ -61,8 +62,9 @@ ScVbaOLEObject::ScVbaOLEObject( const uno::Reference< XHelperInterface >& xParen xChild.set( xChild->getParent(), uno::UNO_QUERY_THROW ); xChild.set( xChild->getParent(), uno::UNO_QUERY_THROW ); css::uno::Reference< css::frame::XModel > xModel( xChild->getParent(), uno::UNO_QUERY_THROW ); - css::uno::Reference< css::view::XControlAccess > xControlAccess( xModel->getCurrentController(), css::uno::UNO_QUERY_THROW ); - m_xWindowPeer = xControlAccess->getControl( xControlModel )->getPeer(); + uno::Reference<lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_QUERY_THROW ); + uno::Reference< XControlProvider > xControlProvider( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.ControlProvider" ) ), mxContext ), uno::UNO_QUERY_THROW ); + m_xControl.set( xControlProvider->createControl( xControlShape, xModel ) ); } uno::Reference< uno::XInterface > SAL_CALL @@ -74,98 +76,76 @@ ScVbaOLEObject::getObject() throw (uno::RuntimeException) sal_Bool SAL_CALL ScVbaOLEObject::getEnabled() throw (uno::RuntimeException) { - uno::Reference< css::awt::XWindow2 > xWindow2( m_xWindowPeer, css::uno::UNO_QUERY_THROW ); - return xWindow2->isEnabled(); + return m_xControl->getEnabled(); } void SAL_CALL ScVbaOLEObject::setEnabled( sal_Bool _enabled ) throw (uno::RuntimeException) { - uno::Reference< css::awt::XWindow2 > xWindow2( m_xWindowPeer, css::uno::UNO_QUERY_THROW ); - xWindow2->setEnable( _enabled ); + m_xControl->setEnabled( _enabled ); } sal_Bool SAL_CALL ScVbaOLEObject::getVisible() throw (uno::RuntimeException) { - uno::Reference< css::awt::XWindow2 > xWindow2( m_xWindowPeer, css::uno::UNO_QUERY_THROW ); - return xWindow2->isVisible(); + OSL_TRACE("OleObject %s returning visible %s", rtl::OUStringToOString( m_xControl->getName(), RTL_TEXTENCODING_UTF8 ).getStr(), m_xControl->getVisible() ? "true" : "false" ); + return m_xControl->getVisible(); } void SAL_CALL ScVbaOLEObject::setVisible( sal_Bool _visible ) throw (uno::RuntimeException) { - uno::Reference< css::awt::XWindow2 > xWindow2( m_xWindowPeer, css::uno::UNO_QUERY_THROW ); - xWindow2->setVisible( _visible ); + OSL_TRACE("OleObject %s set visible %s", rtl::OUStringToOString( m_xControl->getName(), RTL_TEXTENCODING_UTF8 ).getStr(), _visible ? "true" : "false" ); + m_xControl->setVisible( _visible ); } double SAL_CALL ScVbaOLEObject::getLeft() throw (uno::RuntimeException) { - uno::Reference< drawing::XShape > xShape( m_xControlShape, uno::UNO_QUERY_THROW ); - return mm2pt( xShape->getPosition().X / 100 ); + return m_xControl->getLeft(); } void SAL_CALL ScVbaOLEObject::setLeft( double _left ) throw (uno::RuntimeException) { - awt::Point oldPosition; - uno::Reference< drawing::XShape > xShape( m_xControlShape, uno::UNO_QUERY_THROW ); - oldPosition = xShape->getPosition(); - oldPosition.X = pt2mm( _left ) * 100; - xShape->setPosition( oldPosition ); + m_xControl->setLeft( _left ); } double SAL_CALL ScVbaOLEObject::getTop() throw (uno::RuntimeException) { - uno::Reference< drawing::XShape > xShape( m_xControlShape, uno::UNO_QUERY_THROW ); - return mm2pt( xShape->getPosition().Y / 100 ); + return m_xControl->getTop(); } void SAL_CALL ScVbaOLEObject::setTop( double _top ) throw (uno::RuntimeException) { - awt::Point oldPosition; - uno::Reference< drawing::XShape > xShape( m_xControlShape, uno::UNO_QUERY_THROW ); - oldPosition = xShape->getPosition(); - oldPosition.Y = pt2mm( _top ) * 100;; - xShape->setPosition( oldPosition ); + m_xControl->setTop( _top ); } double SAL_CALL ScVbaOLEObject::getHeight() throw (uno::RuntimeException) { - uno::Reference< drawing::XShape > xShape( m_xControlShape, uno::UNO_QUERY_THROW ); - return mm2pt( xShape->getSize().Height / 100 );//1pt = 1/72in + return m_xControl->getHeight(); } void SAL_CALL ScVbaOLEObject::setHeight( double _height ) throw (uno::RuntimeException) { - awt::Size oldSize; - uno::Reference< drawing::XShape > xShape( m_xControlShape, uno::UNO_QUERY_THROW ); - oldSize = xShape->getSize(); - oldSize.Height = pt2mm( _height ) * 100; - xShape->setSize( oldSize ); + m_xControl->setHeight( _height ); } double SAL_CALL ScVbaOLEObject::getWidth() throw (uno::RuntimeException) { - uno::Reference< drawing::XShape > xShape( m_xControlShape, uno::UNO_QUERY_THROW ); - return mm2pt ( xShape->getSize().Width / 100 ); + return m_xControl->getWidth(); } void SAL_CALL ScVbaOLEObject::setWidth( double _width ) throw (uno::RuntimeException) { - awt::Size oldSize; - uno::Reference< drawing::XShape > xShape( m_xControlShape, uno::UNO_QUERY_THROW ); - oldSize = xShape->getSize(); - oldSize.Width = pt2mm( _width ) * 100; - xShape->setSize( oldSize ); + m_xControl->setWidth( _width ); } rtl::OUString& ScVbaOLEObject::getServiceImplName() diff --git a/sc/source/ui/vba/vbaoleobject.hxx b/sc/source/ui/vba/vbaoleobject.hxx index 1b900aacf916..9ad6d6acc2b6 100644 --- a/sc/source/ui/vba/vbaoleobject.hxx +++ b/sc/source/ui/vba/vbaoleobject.hxx @@ -32,20 +32,20 @@ #include <cppuhelper/implbase1.hxx> #include <com/sun/star/drawing/XControlShape.hpp> -#include <com/sun/star/awt/XWindowPeer.hpp> #include <ooo/vba/excel/XOLEObject.hpp> +#include <ooo/vba/msforms/XControl.hpp> -#include "vbahelperinterface.hxx" +#include <vbahelper/vbahelperinterface.hxx> typedef InheritedHelperInterfaceImpl1< ov::excel::XOLEObject > OLEObjectImpl_BASE; class ScVbaOLEObject : public OLEObjectImpl_BASE { - css::uno::Reference< css::awt::XWindowPeer > m_xWindowPeer; protected: css::uno::Reference< css::drawing::XControlShape > m_xControlShape; virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence<rtl::OUString> getServiceNames(); + css::uno::Reference< ov::msforms::XControl> m_xControl; public: ScVbaOLEObject( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, css::uno::Reference< css::drawing::XControlShape > xControlShape ); diff --git a/sc/source/ui/vba/vbaoleobjects.hxx b/sc/source/ui/vba/vbaoleobjects.hxx index 3d2c1b82c6a5..6372a1d2acf3 100644 --- a/sc/source/ui/vba/vbaoleobjects.hxx +++ b/sc/source/ui/vba/vbaoleobjects.hxx @@ -33,8 +33,8 @@ #include <cppuhelper/implbase1.hxx> #include <ooo/vba/excel/XOLEObjects.hpp> -#include "vbacollectionimpl.hxx" -#include "vbahelper.hxx" +#include <vbahelper/vbacollectionimpl.hxx> +#include "excelvbahelper.hxx" typedef CollTestImplHelper< ov::excel::XOLEObjects > OLEObjectsImpl_BASE; diff --git a/sc/source/ui/vba/vbaoutline.hxx b/sc/source/ui/vba/vbaoutline.hxx index 346ca973f021..423b97a34671 100644 --- a/sc/source/ui/vba/vbaoutline.hxx +++ b/sc/source/ui/vba/vbaoutline.hxx @@ -34,7 +34,7 @@ #include <cppuhelper/implbase1.hxx> #include <ooo/vba/excel/XOutline.hpp> #include <com/sun/star/uno/XComponentContext.hpp> -#include "vbahelperinterface.hxx" +#include <vbahelper/vbahelperinterface.hxx> typedef InheritedHelperInterfaceImpl1< ov::excel::XOutline > ScVbaOutline_BASE; diff --git a/sc/source/ui/vba/vbapagebreak.cxx b/sc/source/ui/vba/vbapagebreak.cxx index 83fd0687c4c7..6e8357be7a8c 100644 --- a/sc/source/ui/vba/vbapagebreak.cxx +++ b/sc/source/ui/vba/vbapagebreak.cxx @@ -139,3 +139,37 @@ ScVbaHPageBreak::getServiceNames() return aServiceNames; } +template class ScVbaPageBreak< excel::XVPageBreak >; + +/* class ScVbaVPageBreak */ +ScVbaVPageBreak::ScVbaVPageBreak( const css::uno::Reference< ov::XHelperInterface >& xParent, + const css::uno::Reference< css::uno::XComponentContext >& xContext, + css::uno::Reference< css::beans::XPropertySet >& xProps, + css::sheet::TablePageBreakData aTablePageBreakData ) throw ( css::uno::RuntimeException ) +: ScVbaVPageBreak_BASE( xParent, xContext, xProps, aTablePageBreakData ) +{ +} + +ScVbaVPageBreak::~ScVbaVPageBreak() +{ +} + +rtl::OUString& +ScVbaVPageBreak::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaVPageBreak") ); + return sImplName; +} + +uno::Sequence< rtl::OUString > +ScVbaVPageBreak::getServiceNames() +{ + static uno::Sequence< rtl::OUString > aServiceNames; + if ( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc( 1 ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.VPageBreak" ) ); + } + return aServiceNames; +} + diff --git a/sc/source/ui/vba/vbapagebreak.hxx b/sc/source/ui/vba/vbapagebreak.hxx index 0b05c8895711..2e83d3d9b6d6 100644 --- a/sc/source/ui/vba/vbapagebreak.hxx +++ b/sc/source/ui/vba/vbapagebreak.hxx @@ -33,12 +33,13 @@ #include <cppuhelper/implbase1.hxx> #include <ooo/vba/excel/XPageBreak.hpp> #include <ooo/vba/excel/XHPageBreak.hpp> +#include <ooo/vba/excel/XVPageBreak.hpp> #include <ooo/vba/excel/XRange.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/script/BasicErrorException.hpp> #include <com/sun/star/sheet/TablePageBreakData.hpp> #include <com/sun/star/beans/XPropertySet.hpp> -#include "vbahelperinterface.hxx" +#include <vbahelper/vbahelperinterface.hxx> template< typename Ifc1 > class ScVbaPageBreak : public InheritedHelperInterfaceImpl1< Ifc1 > @@ -84,4 +85,22 @@ public: virtual css::uno::Sequence<rtl::OUString> getServiceNames(); }; +//VPageBreak +typedef ScVbaPageBreak < ov::excel::XVPageBreak > ScVbaVPageBreak_BASE; + +class ScVbaVPageBreak : public ScVbaVPageBreak_BASE +{ +public: + ScVbaVPageBreak( const css::uno::Reference< ov::XHelperInterface >& xParent, + const css::uno::Reference< css::uno::XComponentContext >& xContext, + css::uno::Reference< css::beans::XPropertySet >& xProps, + css::sheet::TablePageBreakData aTablePageBreakData) throw (css::uno::RuntimeException); + + virtual ~ScVbaVPageBreak(); + + // XHelperInterface + virtual rtl::OUString& getServiceImplName(); + virtual css::uno::Sequence<rtl::OUString> getServiceNames(); +}; + #endif diff --git a/sc/source/ui/vba/vbapagebreaks.cxx b/sc/source/ui/vba/vbapagebreaks.cxx index 7e04b982b530..c3b86b77d0bd 100644 --- a/sc/source/ui/vba/vbapagebreaks.cxx +++ b/sc/source/ui/vba/vbapagebreaks.cxx @@ -90,8 +90,8 @@ public: virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException); virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) { - //if( m_bColumn ) - // return excel::XVPageBreak::static_type(0); + if( m_bColumn ) + return excel::XVPageBreak::static_type(0); return excel::XHPageBreak::static_type(0); } virtual sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) @@ -137,8 +137,8 @@ uno::Any SAL_CALL RangePageBreaks::getByIndex( sal_Int32 Index ) throw (lang::In if( (nPos < xIndexAccess->getCount()) && (nPos > -1) ) { uno::Reference< beans::XPropertySet > xRowColPropertySet( xIndexAccess->getByIndex(nPos), uno::UNO_QUERY_THROW ); - //if( m_bColumn ) - // return uno::makeAny( uno::Reference< excel::XVPageBreak >( new ScVbaVPageBreak( mxParent, mxContext, xRowColPropertySet, aTablePageBreakData) )); + if( m_bColumn ) + return uno::makeAny( uno::Reference< excel::XVPageBreak >( new ScVbaVPageBreak( mxParent, mxContext, xRowColPropertySet, aTablePageBreakData) )); return uno::makeAny( uno::Reference< excel::XHPageBreak >( new ScVbaHPageBreak( mxParent, mxContext, xRowColPropertySet, aTablePageBreakData) )); } } @@ -187,8 +187,8 @@ uno::Any RangePageBreaks::Add( const css::uno::Any& Before ) throw ( css::script sheet::TablePageBreakData aTablePageBreakData; aTablePageBreakData.ManualBreak = sal_True; aTablePageBreakData.Position = nAPIRowColIndex; - //if( m_bColumn ) - // return uno::makeAny( uno::Reference< excel::XVPageBreak >( new ScVbaVPageBreak( mxParent, mxContext, xRowColPropertySet, aTablePageBreakData) )); + if( m_bColumn ) + return uno::makeAny( uno::Reference< excel::XVPageBreak >( new ScVbaVPageBreak( mxParent, mxContext, xRowColPropertySet, aTablePageBreakData) )); return uno::makeAny( uno::Reference< excel::XHPageBreak >( new ScVbaHPageBreak( mxParent, mxContext, xRowColPropertySet, aTablePageBreakData) )); } @@ -267,3 +267,64 @@ ScVbaHPageBreaks::getServiceNames() return aServiceNames; } +//VPageBreak +ScVbaVPageBreaks::ScVbaVPageBreaks( const uno::Reference< XHelperInterface >& xParent, + const uno::Reference< uno::XComponentContext >& xContext, + uno::Reference< sheet::XSheetPageBreak >& xSheetPageBreak ) throw ( uno::RuntimeException ) +: ScVbaVPageBreaks_BASE( xParent, xContext, new RangePageBreaks( xParent, xContext, xSheetPageBreak, sal_True ) ), + mxSheetPageBreak( xSheetPageBreak ) +{ +} + +ScVbaVPageBreaks::~ScVbaVPageBreaks() +{ +} + +uno::Any SAL_CALL +ScVbaVPageBreaks::Add( const uno::Any& Before ) throw ( script::BasicErrorException, uno::RuntimeException ) +{ + RangePageBreaks* pPageBreaks = dynamic_cast< RangePageBreaks* >( m_xIndexAccess.get() ); + if( pPageBreaks ) + { + return pPageBreaks->Add( Before ); + } + return uno::Any(); +} + +uno::Reference< container::XEnumeration > +ScVbaVPageBreaks::createEnumeration() throw ( uno::RuntimeException ) +{ + return new RangePageBreaksEnumWrapper( m_xIndexAccess ); +} + +uno::Any +ScVbaVPageBreaks::createCollectionObject( const css::uno::Any& aSource ) +{ + return aSource; // its already a pagebreak object +} + +uno::Type +ScVbaVPageBreaks::getElementType() throw ( uno::RuntimeException ) +{ + return excel::XVPageBreak::static_type( 0 ); +} + +rtl::OUString& +ScVbaVPageBreaks::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM( "ScVbaVPageBreaks" ) ); + return sImplName; +} + +uno::Sequence< rtl::OUString > +ScVbaVPageBreaks::getServiceNames() +{ + static uno::Sequence< rtl::OUString > aServiceNames; + if ( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc( 1 ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.VPageBreaks" ) ); + } + return aServiceNames; +} + diff --git a/sc/source/ui/vba/vbapagebreaks.hxx b/sc/source/ui/vba/vbapagebreaks.hxx index 26d3e6961297..5c90745d61ff 100644 --- a/sc/source/ui/vba/vbapagebreaks.hxx +++ b/sc/source/ui/vba/vbapagebreaks.hxx @@ -33,6 +33,8 @@ #include <cppuhelper/implbase1.hxx> #include <ooo/vba/excel/XHPageBreaks.hpp> #include <ooo/vba/excel/XHPageBreak.hpp> +#include <ooo/vba/excel/XVPageBreaks.hpp> +#include <ooo/vba/excel/XVPageBreak.hpp> #include <ooo/vba/excel/XRange.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/script/BasicErrorException.hpp> @@ -41,8 +43,8 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/table/XColumnRowRange.hpp> -#include "vbahelperinterface.hxx" -#include "vbacollectionimpl.hxx" +#include <vbahelper/vbahelperinterface.hxx> +#include <vbahelper/vbacollectionimpl.hxx> typedef CollTestImplHelper< ov::excel::XHPageBreaks > ScVbaHPageBreaks_BASE; @@ -68,4 +70,31 @@ public: virtual css::uno::Sequence<rtl::OUString> getServiceNames(); }; +//VPageBreaks +typedef CollTestImplHelper< ov::excel::XVPageBreaks > ScVbaVPageBreaks_BASE; + +class ScVbaVPageBreaks : public ScVbaVPageBreaks_BASE +{ + css::uno::Reference< css::sheet::XSheetPageBreak > mxSheetPageBreak; + +public: + ScVbaVPageBreaks( const css::uno::Reference< ov::XHelperInterface >& xParent, + const css::uno::Reference< css::uno::XComponentContext >& xContext, + css::uno::Reference< css::sheet::XSheetPageBreak >& xSheetPageBreak ) throw ( css::uno::RuntimeException ); + + virtual ~ScVbaVPageBreaks(); + + // XVPageBreaks + virtual css::uno::Any SAL_CALL Add( const css::uno::Any& Before ) throw ( css::script::BasicErrorException, css::uno::RuntimeException ); + + // XEnumerationAccess + virtual css::uno::Type SAL_CALL getElementType() throw ( css::uno::RuntimeException ); + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw ( css::uno::RuntimeException ); + virtual css::uno::Any createCollectionObject( const css::uno::Any& ); + + // XHelperInterface + virtual rtl::OUString& getServiceImplName(); + virtual css::uno::Sequence<rtl::OUString> getServiceNames(); +}; + #endif diff --git a/sc/source/ui/vba/vbapagesetup.cxx b/sc/source/ui/vba/vbapagesetup.cxx index 2e7dd57a7afd..cbc9360db523 100644 --- a/sc/source/ui/vba/vbapagesetup.cxx +++ b/sc/source/ui/vba/vbapagesetup.cxx @@ -31,6 +31,7 @@ #include "cellsuno.hxx" #include "convuno.hxx" #include "rangelst.hxx" +#include "excelvbahelper.hxx" #include <com/sun/star/sheet/XPrintAreas.hpp> #include <com/sun/star/sheet/XHeaderFooterContent.hpp> #include <com/sun/star/text/XText.hpp> @@ -52,10 +53,10 @@ ScVbaPageSetup::ScVbaPageSetup(const uno::Reference< XHelperInterface >& xParent const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< sheet::XSpreadsheet >& xSheet, const uno::Reference< frame::XModel >& xModel) throw (uno::RuntimeException): - ScVbaPageSetup_BASE( xParent, xContext ), - mxSheet( xSheet ), mxModel( xModel ) + ScVbaPageSetup_BASE( xParent, xContext ), mxSheet( xSheet ) { // query for current page style + mxModel.set( xModel, uno::UNO_QUERY_THROW ); uno::Reference< beans::XPropertySet > xSheetProps( mxSheet, uno::UNO_QUERY_THROW ); uno::Any aValue = xSheetProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageStyle" ))); rtl::OUString aStyleName; @@ -65,6 +66,8 @@ ScVbaPageSetup::ScVbaPageSetup(const uno::Reference< XHelperInterface >& xParent uno::Reference< container::XNameAccess > xStyleFamilies = xStyleFamiliesSup->getStyleFamilies(); uno::Reference< container::XNameAccess > xPageStyle( xStyleFamilies->getByName(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageStyles"))), uno::UNO_QUERY_THROW ); mxPageProps.set( xPageStyle->getByName(aStyleName), uno::UNO_QUERY_THROW ); + mnOrientLandscape = excel::XlPageOrientation::xlLandscape; + mnOrientPortrait = excel::XlPageOrientation::xlPortrait; } rtl::OUString SAL_CALL ScVbaPageSetup::getPrintArea() throw (css::uno::RuntimeException) @@ -85,7 +88,7 @@ rtl::OUString SAL_CALL ScVbaPageSetup::getPrintArea() throw (css::uno::RuntimeEx ScUnoConversion::FillScRange( aRange, aSeq[i] ); aRangeList.Append( aRange ); } - ScDocument* pDoc = getDocShell( mxModel )->GetDocument(); + ScDocument* pDoc = excel::getDocShell( mxModel )->GetDocument(); aRangeList.Format( aPrintArea, nFlags, pDoc, formula::FormulaGrammar::CONV_XL_A1, ',' ); } @@ -106,7 +109,7 @@ void SAL_CALL ScVbaPageSetup::setPrintArea( const rtl::OUString& rAreas ) throw { ScRangeList aCellRanges; ScRange aRange; - if( getScRangeListForAddress( rAreas, getDocShell( mxModel ) , aRange, aCellRanges ) ) + if( getScRangeListForAddress( rAreas, excel::getDocShell( mxModel ) , aRange, aCellRanges ) ) { uno::Sequence< table::CellRangeAddress > aSeq( aCellRanges.Count() ); USHORT i=0; @@ -121,290 +124,24 @@ void SAL_CALL ScVbaPageSetup::setPrintArea( const rtl::OUString& rAreas ) throw } } -double SAL_CALL ScVbaPageSetup::getTopMargin() throw (css::uno::RuntimeException) -{ - sal_Bool headerOn = sal_False; - sal_Int32 topMargin = 0; - sal_Int32 headerHeight = 0; - - try - { - uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderIsOn"))); - aValue >>= headerOn; - - aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TopMargin"))); - aValue >>= topMargin; - - if( headerOn ) - { - aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderHeight"))); - aValue >>= headerHeight; - topMargin += headerHeight; - } - } - catch( uno::Exception& ) - { - } - - return Millimeter::getInPoints( topMargin ); -} - -void SAL_CALL ScVbaPageSetup::setTopMargin( double margin ) throw (css::uno::RuntimeException) -{ - sal_Int32 topMargin = Millimeter::getInHundredthsOfOneMillimeter( margin ); - sal_Bool headerOn = sal_False; - sal_Int32 headerHeight = 0; - - try - { - uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderIsOn"))); - aValue >>= headerOn; - - if( headerOn ) - { - aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderHeight"))); - aValue >>= headerHeight; - topMargin -= headerHeight; - } - - aValue <<= topMargin; - mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TopMargin")), aValue ); - } - catch( uno::Exception& ) - { - } -} - -double SAL_CALL ScVbaPageSetup::getBottomMargin() throw (css::uno::RuntimeException) -{ - sal_Bool footerOn = sal_False; - sal_Int32 bottomMargin = 0; - sal_Int32 footerHeight = 0; - - try - { - uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterIsOn"))); - aValue >>= footerOn; - - aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BottomMargin"))); - aValue >>= bottomMargin; - - if( footerOn ) - { - aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterHeight"))); - aValue >>= footerHeight; - bottomMargin += footerHeight; - } - } - catch( uno::Exception& ) - { - } - - return Millimeter::getInPoints( bottomMargin ); -} - -void SAL_CALL ScVbaPageSetup::setBottomMargin( double margin ) throw (css::uno::RuntimeException) -{ - sal_Int32 bottomMargin = Millimeter::getInHundredthsOfOneMillimeter( margin ); - sal_Bool footerOn = sal_False; - sal_Int32 footerHeight = 0; - - try - { - uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterIsOn"))); - aValue >>= footerOn; - - if( footerOn ) - { - aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterHeight"))); - aValue >>= footerHeight; - bottomMargin -= footerHeight; - } - - aValue <<= bottomMargin; - mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BottomMargin")), aValue ); - } - catch( uno::Exception& ) - { - } -} - -double SAL_CALL ScVbaPageSetup::getRightMargin() throw (css::uno::RuntimeException) -{ - sal_Int32 rightMargin = 0; - try - { - uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightMargin"))); - aValue >>= rightMargin; - } - catch( uno::Exception& ) - { - } - - return Millimeter::getInPoints( rightMargin );; -} - -void SAL_CALL ScVbaPageSetup::setRightMargin( double margin ) throw (css::uno::RuntimeException) -{ - sal_Int32 rightMargin = Millimeter::getInHundredthsOfOneMillimeter( margin ); - try - { - uno::Any aValue; - aValue <<= rightMargin; - mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightMargin")), aValue ); - } - catch( uno::Exception& ) - { - } - -} - -double SAL_CALL ScVbaPageSetup::getLeftMargin() throw (css::uno::RuntimeException) -{ - sal_Int32 leftMargin = 0; - try - { - uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LeftMargin"))); - aValue >>= leftMargin; - } - catch( uno::Exception& ) - { - } - - return Millimeter::getInPoints( leftMargin );; -} - -void SAL_CALL ScVbaPageSetup::setLeftMargin( double margin ) throw (css::uno::RuntimeException) -{ - sal_Int32 leftMargin = Millimeter::getInHundredthsOfOneMillimeter( margin ); - try - { - uno::Any aValue; - aValue <<= leftMargin; - mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LeftMargin")), aValue ); - } - catch( uno::Exception& ) - { - } -} - double SAL_CALL ScVbaPageSetup::getHeaderMargin() throw (css::uno::RuntimeException) { - sal_Int32 headerMargin = 0; - try - { - uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TopMargin"))); - aValue >>= headerMargin; - } - catch( uno::Exception& ) - { - } - - return Millimeter::getInPoints( headerMargin );; + return VbaPageSetupBase::getHeaderMargin(); } void SAL_CALL ScVbaPageSetup::setHeaderMargin( double margin ) throw (css::uno::RuntimeException) { - sal_Int32 headerMargin = Millimeter::getInHundredthsOfOneMillimeter( margin ); - try - { - uno::Any aValue; - aValue <<= headerMargin; - mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TopMargin")), aValue ); - } - catch( uno::Exception& ) - { - } + VbaPageSetupBase::setHeaderMargin( margin ); } double SAL_CALL ScVbaPageSetup::getFooterMargin() throw (css::uno::RuntimeException) { - sal_Int32 footerMargin = 0; - try - { - uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BottomMargin"))); - aValue >>= footerMargin; - } - catch( uno::Exception& ) - { - } - - return Millimeter::getInPoints( footerMargin );; + return VbaPageSetupBase::getFooterMargin(); } void SAL_CALL ScVbaPageSetup::setFooterMargin( double margin ) throw (css::uno::RuntimeException) { - sal_Int32 footerMargin = Millimeter::getInHundredthsOfOneMillimeter( margin ); - try - { - uno::Any aValue; - aValue <<= footerMargin; - mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BottomMargin")), aValue ); - } - catch( uno::Exception& ) - { - } -} - -sal_Int32 SAL_CALL ScVbaPageSetup::getOrientation() throw (css::uno::RuntimeException) -{ - sal_Int32 orientation = excel::XlPageOrientation::xlPortrait; - try - { - sal_Bool isLandscape = sal_False; - uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IsLandscape"))); - aValue >>= isLandscape; - - if( isLandscape ) - { - orientation = excel::XlPageOrientation::xlLandscape; - } - } - catch( uno::Exception& ) - { - } - return orientation; -} - -void SAL_CALL ScVbaPageSetup::setOrientation( sal_Int32 orientation ) throw (css::uno::RuntimeException) -{ - if( ( orientation != excel::XlPageOrientation::xlPortrait ) && - ( orientation != excel::XlPageOrientation::xlLandscape ) ) - { - DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() ); - } - - try - { - sal_Bool isLandscape = sal_False; - uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IsLandscape"))); - aValue >>= isLandscape; - - sal_Bool switchOrientation = sal_False; - if(( isLandscape && orientation != excel::XlPageOrientation::xlLandscape ) || - ( !isLandscape && orientation != excel::XlPageOrientation::xlPortrait )) - { - switchOrientation = sal_True; - } - - if( switchOrientation ) - { - aValue <<= !isLandscape; - uno::Any aHeight = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Height"))); - uno::Any aWidth = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Width"))); - mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IsLandscape")), aValue ); - mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Width")), aHeight ); - mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Height")), aWidth ); - } - - if( isLandscape ) - { - orientation = excel::XlPageOrientation::xlLandscape; - } - } - catch( uno::Exception& ) - { - } + VbaPageSetupBase::setFooterMargin( margin ); } uno::Any SAL_CALL ScVbaPageSetup::getFitToPagesTall() throw (css::uno::RuntimeException) diff --git a/sc/source/ui/vba/vbapagesetup.hxx b/sc/source/ui/vba/vbapagesetup.hxx index e3cafc9fb78d..2b8b1fffde43 100644 --- a/sc/source/ui/vba/vbapagesetup.hxx +++ b/sc/source/ui/vba/vbapagesetup.hxx @@ -35,39 +35,28 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/sheet/XSpreadsheet.hpp> #include <com/sun/star/beans/XPropertySet.hpp> -#include "vbahelperinterface.hxx" +#include <vbahelper/vbahelperinterface.hxx> +#include <vbahelper/vbapagesetupbase.hxx> -typedef InheritedHelperInterfaceImpl1< ov::excel::XPageSetup > ScVbaPageSetup_BASE; +typedef cppu::ImplInheritanceHelper1< VbaPageSetupBase, ov::excel::XPageSetup > ScVbaPageSetup_BASE; class ScVbaPageSetup : public ScVbaPageSetup_BASE { css::uno::Reference< css::sheet::XSpreadsheet > mxSheet; - css::uno::Reference< css::beans::XPropertySet > mxPageProps; - css::uno::Reference< css::frame::XModel > mxModel; public: ScVbaPageSetup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::sheet::XSpreadsheet>& xSheet, - const css::uno::Reference< css::frame::XModel >& xModlel) throw (css::uno::RuntimeException); + const css::uno::Reference< css::frame::XModel >& xModel) throw (css::uno::RuntimeException); virtual ~ScVbaPageSetup(){} // Attribute virtual rtl::OUString SAL_CALL getPrintArea() throw (css::uno::RuntimeException); virtual void SAL_CALL setPrintArea( const rtl::OUString& rAreas ) throw (css::uno::RuntimeException); - virtual double SAL_CALL getTopMargin() throw (css::uno::RuntimeException); - virtual void SAL_CALL setTopMargin( double margin ) throw (css::uno::RuntimeException); - virtual double SAL_CALL getBottomMargin() throw (css::uno::RuntimeException); - virtual void SAL_CALL setBottomMargin( double margin ) throw (css::uno::RuntimeException); - virtual double SAL_CALL getRightMargin() throw (css::uno::RuntimeException); - virtual void SAL_CALL setRightMargin( double margin ) throw (css::uno::RuntimeException); - virtual double SAL_CALL getLeftMargin() throw (css::uno::RuntimeException); - virtual void SAL_CALL setLeftMargin( double margin ) throw (css::uno::RuntimeException); virtual double SAL_CALL getHeaderMargin() throw (css::uno::RuntimeException); - virtual void SAL_CALL setHeaderMargin( double margin ) throw (css::uno::RuntimeException); - virtual double SAL_CALL getFooterMargin() throw (css::uno::RuntimeException); - virtual void SAL_CALL setFooterMargin( double margin ) throw (css::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getOrientation() throw (css::uno::RuntimeException); - virtual void SAL_CALL setOrientation( sal_Int32 orientation ) throw (css::uno::RuntimeException); + void SAL_CALL setHeaderMargin( double margin ) throw (css::uno::RuntimeException); + double SAL_CALL getFooterMargin() throw (css::uno::RuntimeException); + void SAL_CALL setFooterMargin( double margin ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getFitToPagesTall() throw (css::uno::RuntimeException); virtual void SAL_CALL setFitToPagesTall( const css::uno::Any& fitToPagesTall ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getFitToPagesWide() throw (css::uno::RuntimeException); diff --git a/sc/source/ui/vba/vbapalette.cxx b/sc/source/ui/vba/vbapalette.cxx index d3bbbd6ae121..f9afaa00c191 100644 --- a/sc/source/ui/vba/vbapalette.cxx +++ b/sc/source/ui/vba/vbapalette.cxx @@ -92,7 +92,7 @@ ScVbaPalette::getDefaultPalette() } uno::Reference< container::XIndexAccess > -ScVbaPalette::getPalette() +ScVbaPalette::getPalette() const { uno::Reference< container::XIndexAccess > xIndex; uno::Reference< beans::XPropertySet > xProps; diff --git a/sc/source/ui/vba/vbapalette.hxx b/sc/source/ui/vba/vbapalette.hxx index aa1c8eb27d6c..388fd5908b6b 100644 --- a/sc/source/ui/vba/vbapalette.hxx +++ b/sc/source/ui/vba/vbapalette.hxx @@ -30,7 +30,7 @@ #ifndef SC_VBAPALETTE_HXX #define SC_VBAPALETTE_HXX -#include "vbahelper.hxx" +#include "excelvbahelper.hxx" #include <document.hxx> #include <com/sun/star/container/XIndexAccess.hpp> @@ -42,7 +42,7 @@ public: ScVbaPalette( SfxObjectShell* pShell = NULL ) : m_pShell( pShell ){} // if no palette available e.g. because the document doesn't have a // palette defined then a default palette will be returned. - css::uno::Reference< css::container::XIndexAccess > getPalette(); + css::uno::Reference< css::container::XIndexAccess > getPalette() const; static css::uno::Reference< css::container::XIndexAccess > getDefaultPalette(); }; diff --git a/sc/source/ui/vba/vbapane.hxx b/sc/source/ui/vba/vbapane.hxx index 0f67bbf6038c..97eb3e8f366c 100644 --- a/sc/source/ui/vba/vbapane.hxx +++ b/sc/source/ui/vba/vbapane.hxx @@ -34,7 +34,7 @@ #include<com/sun/star/sheet/XViewPane.hpp> #include<ooo/vba/excel/XPane.hpp> -#include"vbahelper.hxx" +#include"excelvbahelper.hxx" typedef cppu::WeakImplHelper1< ov::excel::XPane > PaneImpl_Base; diff --git a/sc/source/ui/vba/vbapivotcache.hxx b/sc/source/ui/vba/vbapivotcache.hxx index 8a57401d2ff9..6e98344d115e 100644 --- a/sc/source/ui/vba/vbapivotcache.hxx +++ b/sc/source/ui/vba/vbapivotcache.hxx @@ -34,7 +34,7 @@ #include <com/sun/star/sheet/XDataPilotTable.hpp> #include <ooo/vba/excel/XPivotCache.hpp> -#include "vbahelperinterface.hxx" +#include <vbahelper/vbahelperinterface.hxx> typedef InheritedHelperInterfaceImpl1<ov::excel::XPivotCache > PivotCacheImpl_BASE; diff --git a/sc/source/ui/vba/vbapivottable.hxx b/sc/source/ui/vba/vbapivottable.hxx index 55f32a36e60d..7fccada818fc 100644 --- a/sc/source/ui/vba/vbapivottable.hxx +++ b/sc/source/ui/vba/vbapivottable.hxx @@ -33,8 +33,8 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/sheet/XDataPilotTable.hpp> #include <ooo/vba/excel/XPivotTable.hpp> -#include "vbahelper.hxx" -#include "vbahelperinterface.hxx" +#include "excelvbahelper.hxx" +#include <vbahelper/vbahelperinterface.hxx> typedef InheritedHelperInterfaceImpl1< ov::excel::XPivotTable > PivotTableImpl_BASE; diff --git a/sc/source/ui/vba/vbapivottables.hxx b/sc/source/ui/vba/vbapivottables.hxx index 6a6d5afb67a5..b2f71cdc3ff0 100644 --- a/sc/source/ui/vba/vbapivottables.hxx +++ b/sc/source/ui/vba/vbapivottables.hxx @@ -36,9 +36,9 @@ #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/uno/XComponentContext.hpp> -#include "vbahelper.hxx" -#include "vbahelperinterface.hxx" -#include "vbacollectionimpl.hxx" +#include "excelvbahelper.hxx" +#include <vbahelper/vbahelperinterface.hxx> +#include <vbahelper/vbacollectionimpl.hxx> typedef CollTestImplHelper< ov::excel::XPivotTables > ScVbaPivotTables_BASE; diff --git a/sc/source/ui/vba/vbapropvalue.hxx b/sc/source/ui/vba/vbapropvalue.hxx index d6ddb33505e1..f521212f2ceb 100644 --- a/sc/source/ui/vba/vbapropvalue.hxx +++ b/sc/source/ui/vba/vbapropvalue.hxx @@ -32,7 +32,7 @@ #include <ooo/vba/XPropValue.hpp> #include <cppuhelper/implbase1.hxx> -#include "vbahelper.hxx" +#include "excelvbahelper.hxx" typedef ::cppu::WeakImplHelper1< ov::XPropValue > PropValueImpl_BASE; diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index d1ac4504ce96..f6c58c23f79a 100644 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -27,7 +27,7 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#include "helperdecl.hxx" +#include <vbahelper/helperdecl.hxx> #include <comphelper/unwrapargs.hxx> #include <comphelper/processfactory.hxx> @@ -149,7 +149,6 @@ #include "rangelst.hxx" #include "convuno.hxx" #include "compiler.hxx" -#include "formula/grammar.hxx" #include "attrib.hxx" #include "undodat.hxx" #include "dbdocfun.hxx" @@ -162,7 +161,7 @@ #include "vbaglobals.hxx" #include "vbastyle.hxx" #include <vector> -#include <vbacollectionimpl.hxx> +#include <vbahelper/vbacollectionimpl.hxx> // begin test includes #include <com/sun/star/sheet/FunctionArgument.hpp> // end test includes @@ -256,7 +255,7 @@ ScCellRangeObj* ScVbaRange::getCellRangeObj() throw ( uno::RuntimeException ) SfxItemSet* ScVbaRange::getCurrentDataSet( ) throw ( uno::RuntimeException ) { ScCellRangeObj* pUnoCellRange = getCellRangeObj(); - SfxItemSet* pDataSet = ScVbaCellRangeAccess::GetDataSet( pUnoCellRange ); + SfxItemSet* pDataSet = excel::ScVbaCellRangeAccess::GetDataSet( pUnoCellRange ); if ( !pDataSet ) throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can't access Itemset for range" ) ), uno::Reference< uno::XInterface >() ); return pDataSet; @@ -473,7 +472,7 @@ public: if ( pUnoCellRange ) { - SfxItemSet* pDataSet = ScVbaCellRangeAccess::GetDataSet( pUnoCellRange ); + SfxItemSet* pDataSet = excel::ScVbaCellRangeAccess::GetDataSet( pUnoCellRange ); SfxItemState eState = pDataSet->GetItemState( ATTR_VALUE_FORMAT, TRUE, NULL); // one of the cells in the range is not like the other ;-) // so return a zero length format to indicate that @@ -1979,7 +1978,7 @@ ScVbaRange::Select() throw (uno::RuntimeException) // ThisComponent.CurrentController.Frame.getContainerWindow.SetFocus try { - uno::Reference< frame::XController > xController( getCurrentDocument()->getCurrentController(), uno::UNO_QUERY_THROW ); + uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_QUERY_THROW ); uno::Reference< frame::XFrame > xFrame( xController->getFrame(), uno::UNO_QUERY_THROW ); uno::Reference< awt::XWindow > xWin( xFrame->getContainerWindow(), uno::UNO_QUERY_THROW ); xWin->setFocus(); @@ -1999,9 +1998,9 @@ bool cellInRange( const table::CellRangeAddress& rAddr, const sal_Int32& nCol, c return false; } -void setCursor( const SCCOL& nCol, const SCROW& nRow, bool bInSel = true ) +void setCursor( const SCCOL& nCol, const SCROW& nRow, const uno::Reference< frame::XModel >& xModel, bool bInSel = true ) { - ScTabViewShell* pShell = getCurrentBestViewShell(); + ScTabViewShell* pShell = excel::getBestViewShell( xModel ); if ( pShell ) { if ( bInSel ) @@ -2027,11 +2026,19 @@ ScVbaRange::Activate() throw (uno::RuntimeException) RangeHelper thisRange( xCellRange ); uno::Reference< sheet::XCellRangeAddressable > xThisRangeAddress = thisRange.getCellRangeAddressable(); table::CellRangeAddress thisRangeAddress = xThisRangeAddress->getRangeAddress(); + uno::Reference< frame::XModel > xModel; + ScDocShell* pShell = getScDocShell(); + + if ( pShell ) + xModel = pShell->GetModel(); + + if ( !xModel.is() ) + throw uno::RuntimeException(); // get current selection - uno::Reference< sheet::XCellRangeAddressable > xRange( getCurrentDocument()->getCurrentSelection(), ::uno::UNO_QUERY); + uno::Reference< sheet::XCellRangeAddressable > xRange( xModel->getCurrentSelection(), ::uno::UNO_QUERY); - uno::Reference< sheet::XSheetCellRanges > xRanges( getCurrentDocument()->getCurrentSelection(), ::uno::UNO_QUERY); + uno::Reference< sheet::XSheetCellRanges > xRanges( xModel->getCurrentSelection(), ::uno::UNO_QUERY); if ( xRanges.is() ) { @@ -2040,7 +2047,7 @@ ScVbaRange::Activate() throw (uno::RuntimeException) { if ( cellInRange( nAddrs[index], thisRangeAddress.StartColumn, thisRangeAddress.StartRow ) ) { - setCursor( static_cast< SCCOL >( thisRangeAddress.StartColumn ), static_cast< SCROW >( thisRangeAddress.StartRow ) ); + setCursor( static_cast< SCCOL >( thisRangeAddress.StartColumn ), static_cast< SCROW >( thisRangeAddress.StartRow ), xModel ); return; } @@ -2048,7 +2055,7 @@ ScVbaRange::Activate() throw (uno::RuntimeException) } if ( xRange.is() && cellInRange( xRange->getRangeAddress(), thisRangeAddress.StartColumn, thisRangeAddress.StartRow ) ) - setCursor( static_cast< SCCOL >( thisRangeAddress.StartColumn ), static_cast< SCROW >( thisRangeAddress.StartRow ) ); + setCursor( static_cast< SCCOL >( thisRangeAddress.StartColumn ), static_cast< SCROW >( thisRangeAddress.StartRow ), xModel ); else { // if this range is multi cell select the range other @@ -2056,7 +2063,7 @@ ScVbaRange::Activate() throw (uno::RuntimeException) if ( isSingleCellRange() ) // This top-leftmost cell of this Range is not in the current // selection so just select this range - setCursor( static_cast< SCCOL >( thisRangeAddress.StartColumn ), static_cast< SCROW >( thisRangeAddress.StartRow ), false ); + setCursor( static_cast< SCCOL >( thisRangeAddress.StartColumn ), static_cast< SCROW >( thisRangeAddress.StartRow ), xModel, false ); else Select(); } @@ -2211,8 +2218,9 @@ ScVbaRange::Copy(const ::uno::Any& Destination) throw (uno::RuntimeException) } else { + uno::Reference< frame::XModel > xModel = getModelFromRange( mxRange ); Select(); - implnCopy(); + excel::implnCopy( xModel ); } } @@ -2235,8 +2243,9 @@ ScVbaRange::Cut(const ::uno::Any& Destination) throw (uno::RuntimeException) xMover->moveRange( xDestination->getCellAddress(), xSource->getRangeAddress() ); } { + uno::Reference< frame::XModel > xModel = getModelFromRange( mxRange ); Select(); - implnCut(); + excel::implnCut( xModel ); } } @@ -2544,9 +2553,12 @@ ScVbaRange::PasteSpecial( const uno::Any& Paste, const uno::Any& Operation, cons { if ( m_Areas->getCount() > 1 ) throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("That command cannot be used on multiple selections" ) ), uno::Reference< uno::XInterface >() ); - uno::Reference< view::XSelectionSupplier > xSelection( getCurrentDocument()->getCurrentController(), uno::UNO_QUERY_THROW ); + ScDocShell* pShell = getScDocShell(); + + uno::Reference< frame::XModel > xModel( ( pShell ? pShell->GetModel() : NULL ), uno::UNO_QUERY_THROW ); + uno::Reference< view::XSelectionSupplier > xSelection( xModel->getCurrentController(), uno::UNO_QUERY_THROW ); // save old selection - uno::Reference< uno::XInterface > xSel( getCurrentDocument()->getCurrentSelection() ); + uno::Reference< uno::XInterface > xSel( xModel->getCurrentSelection() ); // select this range xSelection->select( uno::makeAny( mxRange ) ); // set up defaults @@ -2566,7 +2578,7 @@ ScVbaRange::PasteSpecial( const uno::Any& Paste, const uno::Any& Operation, cons USHORT nFlags = getPasteFlags(nPaste); USHORT nFormulaBits = getPasteFormulaBits(nOperation); - implnPasteSpecial(nFlags,nFormulaBits,bSkipBlanks,bTranspose); + excel::implnPasteSpecial(pShell->GetModel(), nFlags,nFormulaBits,bSkipBlanks,bTranspose); // restore selection xSelection->select( uno::makeAny( xSel ) ); } @@ -3235,13 +3247,15 @@ ScVbaRange::End( ::sal_Int32 Direction ) throw (uno::RuntimeException) // Save ActiveCell pos ( to restore later ) uno::Any aDft; - rtl::OUString sActiveCell = ScVbaGlobals::getGlobalsImpl( - mxContext )->getApplication()->getActiveCell()->Address(aDft, aDft, aDft, aDft, aDft ); + uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW ); + rtl::OUString sActiveCell = xApplication->getActiveCell()->Address(aDft, aDft, aDft, aDft, aDft ); // position current cell upper left of this range Cells( uno::makeAny( (sal_Int32) 1 ), uno::makeAny( (sal_Int32) 1 ) )->Select(); - SfxViewFrame* pViewFrame = getCurrentViewFrame(); + uno::Reference< frame::XModel > xModel = getModelFromRange( mxRange ); + + SfxViewFrame* pViewFrame = excel::getViewFrame( xModel ); if ( pViewFrame ) { SfxAllItemSet aArgs( SFX_APP()->GetPool() ); @@ -3277,18 +3291,17 @@ ScVbaRange::End( ::sal_Int32 Direction ) throw (uno::RuntimeException) } // result is the ActiveCell - rtl::OUString sMoved = ScVbaGlobals::getGlobalsImpl( - mxContext )->getApplication()->getActiveCell()->Address(aDft, aDft, aDft, aDft, aDft ); + rtl::OUString sMoved = xApplication->getActiveCell()->Address(aDft, aDft, aDft, aDft, aDft ); // restore old ActiveCell uno::Any aVoid; - uno::Reference< excel::XRange > xOldActiveCell( ScVbaGlobals::getGlobalsImpl( - mxContext )->getActiveSheet()->Range( uno::makeAny( sActiveCell ), aVoid ), uno::UNO_QUERY_THROW ); + + uno::Reference< excel::XRange > xOldActiveCell( xApplication->getActiveSheet()->Range( uno::makeAny( sActiveCell ), aVoid ), uno::UNO_QUERY_THROW ); xOldActiveCell->Select(); uno::Reference< excel::XRange > resultCell; - resultCell.set( ScVbaGlobals::getGlobalsImpl( - mxContext )->getActiveSheet()->Range( uno::makeAny( sMoved ), aVoid ), uno::UNO_QUERY_THROW ); + + resultCell.set( xApplication->getActiveSheet()->Range( uno::makeAny( sMoved ), aVoid ), uno::UNO_QUERY_THROW ); // return result @@ -3321,7 +3334,6 @@ ScVbaRange::characters( const uno::Any& Start, const uno::Any& Length ) throw (u void SAL_CALL ScVbaRange::Delete( const uno::Any& Shift ) throw (uno::RuntimeException) { - if ( m_Areas->getCount() > 1 ) { sal_Int32 nItems = m_Areas->getCount(); @@ -3333,6 +3345,8 @@ ScVbaRange::Delete( const uno::Any& Shift ) throw (uno::RuntimeException) return; } sheet::CellDeleteMode mode = sheet::CellDeleteMode_NONE ; + RangeHelper thisRange( mxRange ); + table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); if ( Shift.hasValue() ) { sal_Int32 nShift = 0; @@ -3350,13 +3364,17 @@ ScVbaRange::Delete( const uno::Any& Shift ) throw (uno::RuntimeException) } } else - if ( getRow() > getColumn() ) + { + bool bFullRow = ( thisAddress.StartColumn == 0 && thisAddress.EndColumn == MAXCOL ); + sal_Int32 nCols = thisAddress.EndColumn - thisAddress.StartColumn; + sal_Int32 nRows = thisAddress.EndRow - thisAddress.StartRow; + if ( mbIsRows || bFullRow || ( nCols >= nRows ) ) mode = sheet::CellDeleteMode_UP; else mode = sheet::CellDeleteMode_LEFT; - RangeHelper thisRange( mxRange ); + } uno::Reference< sheet::XCellRangeMovement > xCellRangeMove( thisRange.getSpreadSheet(), uno::UNO_QUERY_THROW ); - xCellRangeMove->removeRange( thisRange.getCellRangeAddressable()->getRangeAddress(), mode ); + xCellRangeMove->removeRange( thisAddress, mode ); } @@ -3394,7 +3412,7 @@ ScVbaRange::createEnumeration() throw (uno::RuntimeException) ::rtl::OUString SAL_CALL ScVbaRange::getDefaultMethodName( ) throw (uno::RuntimeException) { - const static rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM("Cells") ); + const static rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM("Item") ); return sName; } @@ -3751,7 +3769,7 @@ ScVbaRange::setPageBreak( const uno::Any& _pagebreak) throw (uno::RuntimeExcepti uno::Reference< frame::XModel > xModel = pShell->GetModel(); if ( xModel.is() ) { - ScTabViewShell* pViewShell = getBestViewShell( xModel ); + ScTabViewShell* pViewShell = excel::getBestViewShell( xModel ); if ( nPageBreak == excel::XlPageBreak::xlPageBreakManual ) pViewShell->InsertPageBreak( bColumn, TRUE, &aAddr); else if ( nPageBreak == excel::XlPageBreak::xlPageBreakNone ) @@ -3881,7 +3899,7 @@ ScVbaRange::ApplicationRange( const uno::Reference< uno::XComponentContext >& xC if ( Cell1.hasValue() && !Cell2.hasValue() && sRangeName.getLength() ) { const static rtl::OUString sNamedRanges( RTL_CONSTASCII_USTRINGPARAM("NamedRanges")); - uno::Reference< beans::XPropertySet > xPropSet( getCurrentDocument(), uno::UNO_QUERY_THROW ); + uno::Reference< beans::XPropertySet > xPropSet( getCurrentExcelDoc(xContext), uno::UNO_QUERY_THROW ); uno::Reference< container::XNameAccess > xNamed( xPropSet->getPropertyValue( sNamedRanges ), uno::UNO_QUERY_THROW ); uno::Reference< sheet::XCellRangeReferrer > xReferrer; @@ -3904,7 +3922,7 @@ ScVbaRange::ApplicationRange( const uno::Reference< uno::XComponentContext >& xC } } } - uno::Reference< sheet::XSpreadsheetView > xView( getCurrentDocument()->getCurrentController(), uno::UNO_QUERY ); + uno::Reference< sheet::XSpreadsheetView > xView( getCurrentExcelDoc(xContext)->getCurrentController(), uno::UNO_QUERY ); uno::Reference< table::XCellRange > xSheetRange( xView->getActiveSheet(), uno::UNO_QUERY_THROW ); ScVbaRange* pRange = new ScVbaRange( uno::Reference< XHelperInterface >(), xContext, xSheetRange ); uno::Reference< excel::XRange > xVbSheetRange( pRange ); @@ -4351,8 +4369,10 @@ ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const } void SAL_CALL -ScVbaRange::Insert( const uno::Any& Shift, const uno::Any& /*CopyOrigin*/ ) throw (uno::RuntimeException) +ScVbaRange::Insert( const uno::Any& Shift, const uno::Any& CopyOrigin ) throw (uno::RuntimeException) { + sal_Bool bCopyOrigin = sal_True; + CopyOrigin >>= bCopyOrigin; // It appears ( from the web ) that the undocumented CopyOrigin // param should contain member of enum XlInsertFormatOrigin // which can have values xlFormatFromLeftOrAbove or xlFormatFromRightOrBelow @@ -4384,8 +4404,17 @@ ScVbaRange::Insert( const uno::Any& Shift, const uno::Any& /*CopyOrigin*/ ) thro mode = sheet::CellInsertMode_RIGHT; } RangeHelper thisRange( mxRange ); + table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); uno::Reference< sheet::XCellRangeMovement > xCellRangeMove( thisRange.getSpreadSheet(), uno::UNO_QUERY_THROW ); - xCellRangeMove->insertCells( thisRange.getCellRangeAddressable()->getRangeAddress(), mode ); + xCellRangeMove->insertCells( thisAddress, mode ); + if ( bCopyOrigin ) + { + // After the insert ( this range ) actually has moved + ScRange aRange( static_cast< SCCOL >( thisAddress.StartColumn ), static_cast< SCROW >( thisAddress.StartRow ), static_cast< SCTAB >( thisAddress.Sheet ), static_cast< SCCOL >( thisAddress.EndColumn ), static_cast< SCROW >( thisAddress.EndRow ), static_cast< SCTAB >( thisAddress.Sheet ) ); + uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( getDocShellFromRange( mxRange ) , aRange ) ); + uno::Reference< excel::XRange > xVbaRange( new ScVbaRange( getParent(), mxContext, xRange, mbIsRows, mbIsColumns ) ); + xVbaRange->PasteSpecial( uno::Any(), uno::Any(), uno::Any(), uno::Any() ); + } } void SAL_CALL @@ -4720,7 +4749,7 @@ ScVbaRange::PrintOut( const uno::Any& From, const uno::Any& To, const uno::Any& { xPrintAreas->setPrintAreas( printAreas ); uno::Reference< frame::XModel > xModel = pShell->GetModel(); - PrintOutHelper( From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, xModel, sal_True ); + PrintOutHelper( excel::getBestViewShell( xModel ), From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, sal_True ); } } } @@ -5034,6 +5063,7 @@ ScVbaRange::getStyle() throw (uno::RuntimeException) } uno::Reference< beans::XPropertySet > xProps( mxRange, uno::UNO_QUERY_THROW ); rtl::OUString sStyleName; + xProps->getPropertyValue(CELLSTYLE) >>= sStyleName; ScDocShell* pShell = getScDocShell(); uno::Reference< frame::XModel > xModel( pShell->GetModel() ); uno::Reference< excel::XStyle > xStyle = new ScVbaStyle( this, mxContext, sStyleName, xModel ); diff --git a/sc/source/ui/vba/vbarange.hxx b/sc/source/ui/vba/vbarange.hxx index abc2f608bb62..1d2d82442be3 100644 --- a/sc/source/ui/vba/vbarange.hxx +++ b/sc/source/ui/vba/vbarange.hxx @@ -53,12 +53,15 @@ #include <com/sun/star/sheet/XSpreadsheet.hpp> #include <com/sun/star/sheet/XSheetCellRangeContainer.hpp> -//#include "vbahelperinterface.hxx" +//#include <vbahelper/vbahelperinterface.hxx> #include "vbaformat.hxx" +#include <formula/grammar.hxx> class ScTableSheetsObj; class ScCellRangesBase; class ScCellRangeObj; +class ScDocShell; +class ScDocument; //typedef InheritedHelperInterfaceImpl1< ov::excel::XRange > ScVbaRange_BASE; typedef ScVbaFormat< ov::excel::XRange > ScVbaRange_BASE; diff --git a/sc/source/ui/vba/vbaseriescollection.hxx b/sc/source/ui/vba/vbaseriescollection.hxx index ccd544fe4f26..48ec78025d79 100644 --- a/sc/source/ui/vba/vbaseriescollection.hxx +++ b/sc/source/ui/vba/vbaseriescollection.hxx @@ -31,9 +31,9 @@ #define SC_VBA_SERIESCOLLECTION_HXX #include <ooo/vba/excel/XSeriesCollection.hpp> -#include "vbahelperinterface.hxx" -#include "vbacollectionimpl.hxx" -#include "vbahelper.hxx" +#include <vbahelper/vbahelperinterface.hxx> +#include <vbahelper/vbacollectionimpl.hxx> +#include "excelvbahelper.hxx" typedef CollTestImplHelper< ov::excel::XSeriesCollection > SeriesCollection_BASE; diff --git a/sc/source/ui/vba/vbastyle.cxx b/sc/source/ui/vba/vbastyle.cxx index fbcfb0b97f65..8b7731c2d358 100644 --- a/sc/source/ui/vba/vbastyle.cxx +++ b/sc/source/ui/vba/vbastyle.cxx @@ -71,7 +71,7 @@ void ScVbaStyle::initialise() throw ( uno::RuntimeException ) } -ScVbaStyle::ScVbaStyle( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const rtl::OUString& sStyleName, const uno::Reference< frame::XModel >& _xModel ) throw ( script::BasicErrorException, uno::RuntimeException ) : ScVbaStyle_BASE( xParent, xContext, lcl_getStyleProps( sStyleName, _xModel ), _xModel, false ) +ScVbaStyle::ScVbaStyle( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const rtl::OUString& sStyleName, const uno::Reference< frame::XModel >& _xModel ) throw ( script::BasicErrorException, uno::RuntimeException ) : ScVbaStyle_BASE( xParent, xContext, lcl_getStyleProps( sStyleName, _xModel ), _xModel, false ), mxModel( _xModel ) { try { @@ -83,7 +83,7 @@ ScVbaStyle::ScVbaStyle( const uno::Reference< ov::XHelperInterface >& xParent, c } } -ScVbaStyle::ScVbaStyle( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< beans::XPropertySet >& _xPropertySet, const uno::Reference< frame::XModel >& _xModel ) throw ( script::BasicErrorException, uno::RuntimeException ) : ScVbaStyle_BASE( xParent, xContext, _xPropertySet, _xModel, false ) +ScVbaStyle::ScVbaStyle( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< beans::XPropertySet >& _xPropertySet, const uno::Reference< frame::XModel >& _xModel ) throw ( script::BasicErrorException, uno::RuntimeException ) : ScVbaStyle_BASE( xParent, xContext, _xPropertySet, _xModel, false ), mxModel( _xModel ) { try { diff --git a/sc/source/ui/vba/vbastyles.cxx b/sc/source/ui/vba/vbastyles.cxx index 18111fc5eae7..6cb35d19a67e 100644 --- a/sc/source/ui/vba/vbastyles.cxx +++ b/sc/source/ui/vba/vbastyles.cxx @@ -29,6 +29,7 @@ ************************************************************************/ #include "vbastyles.hxx" #include "vbastyle.hxx" +#include <ooo/vba/excel/XRange.hpp> using namespace ::ooo::vba; using namespace ::com::sun::star; diff --git a/sc/source/ui/vba/vbastyles.hxx b/sc/source/ui/vba/vbastyles.hxx index 4ad8980fe201..1e238a9d1c13 100644 --- a/sc/source/ui/vba/vbastyles.hxx +++ b/sc/source/ui/vba/vbastyles.hxx @@ -31,7 +31,7 @@ #define SC_VBA_STYLES_HXX #include <ooo/vba/excel/XStyles.hpp> #include <com/sun/star/container/XNameContainer.hpp> -#include "vbacollectionimpl.hxx" +#include <vbahelper/vbacollectionimpl.hxx> typedef CollTestImplHelper< ov::excel::XStyles > ScVbaStyles_BASE; class ScVbaStyles: public ScVbaStyles_BASE diff --git a/sc/source/ui/vba/vbatextboxshape.cxx b/sc/source/ui/vba/vbatextboxshape.cxx index 82af63e5754e..b8148e129220 100644 --- a/sc/source/ui/vba/vbatextboxshape.cxx +++ b/sc/source/ui/vba/vbatextboxshape.cxx @@ -41,7 +41,7 @@ using namespace com::sun::star; using namespace ooo::vba; -ScVbaTextBoxShape::ScVbaTextBoxShape( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< drawing::XShape >& xShape, const uno::Reference< drawing::XShapes >& xShapes, const uno::Reference< frame::XModel >& xModel ) : TextBoxShapeImpl_BASE( uno::Reference< XHelperInterface >(), xContext, xShape, xShapes, ScVbaShape::getType( xShape ) ) +ScVbaTextBoxShape::ScVbaTextBoxShape( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< drawing::XShape >& xShape, const uno::Reference< drawing::XShapes >& xShapes, const uno::Reference< frame::XModel >& xModel ) : TextBoxShapeImpl_BASE( uno::Reference< XHelperInterface >(), xContext, xShape, xShapes, xModel, ScVbaShape::getType( xShape ) ) { m_xTextRange.set( xShape , uno::UNO_QUERY_THROW ); m_xModel.set( xModel ); @@ -62,7 +62,7 @@ ScVbaTextBoxShape::setText( const rtl::OUString& _text ) throw (css::uno::Runtim uno::Reference< excel::XCharacters > SAL_CALL ScVbaTextBoxShape::characters( const uno::Any& Start, const uno::Any& Length ) throw (uno::RuntimeException) { - ScDocShell* pDocShell = getDocShell( m_xModel ); + ScDocShell* pDocShell = excel::getDocShell( m_xModel ); ScDocument* pDoc = pDocShell ? pDocShell->GetDocument() : NULL; if ( !pDoc ) diff --git a/sc/source/ui/vba/vbatextboxshape.hxx b/sc/source/ui/vba/vbatextboxshape.hxx index c8c79b626069..733849e6be12 100644 --- a/sc/source/ui/vba/vbatextboxshape.hxx +++ b/sc/source/ui/vba/vbatextboxshape.hxx @@ -37,8 +37,8 @@ #include <cppuhelper/implbase1.hxx> #include <com/sun/star/text/XTextRange.hpp> #include <ooo/vba/msforms/XTextBoxShape.hpp> -#include "vbashape.hxx" -#include "vbahelper.hxx" +#include <vbahelper/vbashape.hxx> +#include "excelvbahelper.hxx" #include "vbacharacters.hxx" typedef cppu::ImplInheritanceHelper1< ScVbaShape, ov::msforms::XTextBoxShape > TextBoxShapeImpl_BASE; diff --git a/sc/source/ui/vba/vbatextframe.cxx b/sc/source/ui/vba/vbatextframe.cxx index f66d83c22c2d..81a8f0b5654c 100644 --- a/sc/source/ui/vba/vbatextframe.cxx +++ b/sc/source/ui/vba/vbatextframe.cxx @@ -27,6 +27,7 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ +#include <vbahelper/helperdecl.hxx> #include <com/sun/star/drawing/TextFitToSizeType.hpp> #include <com/sun/star/text/XText.hpp> #include "vbatextframe.hxx" @@ -35,121 +36,19 @@ using namespace ::ooo::vba; using namespace ::com::sun::star; -ScVbaTextFrame::ScVbaTextFrame( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, uno::Reference< drawing::XShape > xShape ) : ScVbaTextFrame_BASE( xParent, xContext ), m_xShape( xShape ) +ScVbaTextFrame::ScVbaTextFrame( uno::Sequence< uno::Any> const & args, uno::Reference< uno::XComponentContext> const & xContext ) throw ( lang::IllegalArgumentException ) : ScVbaTextFrame_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext, getXSomethingFromArgs< drawing::XShape >( args, 1, false ) ) { - m_xPropertySet.set( m_xShape, uno::UNO_QUERY_THROW ); } -void -ScVbaTextFrame::setAsMSObehavior() -{ - //set property TextWordWrap default as False. - // TextFitToSize control the text content. it seems we should set the default as False. - // com.sun.star.drawing.TextFitToSizeType.NONE - m_xPropertySet->setPropertyValue( rtl::OUString::createFromAscii( "TextWordWrap" ), uno::makeAny( sal_False ) ); - m_xPropertySet->setPropertyValue( rtl::OUString::createFromAscii( "TextFitToSize" ), uno::makeAny( drawing::TextFitToSizeType_NONE ) ); -} - -sal_Int32 ScVbaTextFrame::getMargin( rtl::OUString sMarginType ) -{ - sal_Int32 nMargin = 0; - uno::Any aMargin = m_xPropertySet->getPropertyValue( sMarginType ); - aMargin >>= nMargin; - return nMargin; -} - -void ScVbaTextFrame::setMargin( rtl::OUString sMarginType, float fMargin ) -{ - sal_Int32 nMargin = Millimeter::getInHundredthsOfOneMillimeter( fMargin ); - m_xPropertySet->setPropertyValue( sMarginType, uno::makeAny( nMargin ) ); -} - -// Attributes -sal_Bool SAL_CALL -ScVbaTextFrame::getAutoSize() throw (uno::RuntimeException) -{ - // I don't know why, but in OOo, TextAutoGrowHeight is the property control autosize. not TextFitToSize. - // TextFitToSize control the text content. - // and in mso, there isnot option TextWordWrap which means auto wrap. the default is False. - sal_Bool bAutosize = sal_False; - uno::Any aTextAutoGrowHeight = m_xPropertySet->getPropertyValue( rtl::OUString::createFromAscii( "TextAutoGrowHeight" ) ); - aTextAutoGrowHeight >>= bAutosize; - return bAutosize; -} - -void SAL_CALL -ScVbaTextFrame::setAutoSize( sal_Bool _autosize ) throw (uno::RuntimeException) -{ - setAsMSObehavior(); - m_xPropertySet->setPropertyValue( rtl::OUString::createFromAscii( "TextAutoGrowHeight" ), uno::makeAny( _autosize ) ); -} - -float SAL_CALL -ScVbaTextFrame::getMarginBottom() throw (uno::RuntimeException) -{ - sal_Int32 nMargin = getMargin( rtl::OUString::createFromAscii( "TextLowerDistance" ) ); - float fMargin = (float)Millimeter::getInPoints( nMargin ); - return fMargin; -} - -void SAL_CALL -ScVbaTextFrame::setMarginBottom( float _marginbottom ) throw (uno::RuntimeException) -{ - setMargin( rtl::OUString::createFromAscii( "TextLowerDistance" ), _marginbottom ); -} - -float SAL_CALL -ScVbaTextFrame::getMarginTop() throw (uno::RuntimeException) -{ - sal_Int32 nMargin = getMargin( rtl::OUString::createFromAscii( "TextUpperDistance" ) ); - float fMargin = (float)Millimeter::getInPoints( nMargin ); - return fMargin; -} - -void SAL_CALL -ScVbaTextFrame::setMarginTop( float _margintop ) throw (uno::RuntimeException) -{ - setMargin( rtl::OUString::createFromAscii( "TextUpperDistance" ), _margintop ); -} - -float SAL_CALL -ScVbaTextFrame::getMarginLeft() throw (uno::RuntimeException) -{ - sal_Int32 nMargin = getMargin( rtl::OUString::createFromAscii( "TextLeftDistance" ) ); - float fMargin = (float)Millimeter::getInPoints( nMargin ); - return fMargin; -} - -void SAL_CALL -ScVbaTextFrame::setMarginLeft( float _marginleft ) throw (uno::RuntimeException) -{ - setMargin( rtl::OUString::createFromAscii( "TextLeftDistance" ), _marginleft ); -} - -float SAL_CALL -ScVbaTextFrame::getMarginRight() throw (uno::RuntimeException) -{ - sal_Int32 nMargin = getMargin( rtl::OUString::createFromAscii( "TextRightDistance" ) ); - float fMargin = (float)Millimeter::getInPoints( nMargin ); - return fMargin; -} - -void SAL_CALL -ScVbaTextFrame::setMarginRight( float _marginright ) throw (uno::RuntimeException) -{ - setMargin( rtl::OUString::createFromAscii( "TextRightDistance" ), _marginright ); -} - - // Methods -uno::Reference< ov::excel::XCharacters > SAL_CALL +uno::Any SAL_CALL ScVbaTextFrame::Characters() throw (uno::RuntimeException) { uno::Reference< text::XSimpleText > xSimpleText( m_xShape, uno::UNO_QUERY_THROW ); ScVbaPalette aPalette( SfxObjectShell::Current() ); uno::Any aStart( sal_Int32( 1 ) ); uno::Any aLength(sal_Int32( -1 ) ); - return uno::Reference< ov::excel::XCharacters >( new ScVbaCharacters( this, mxContext, aPalette, xSimpleText, aStart, aLength, sal_True ) ); + return uno::makeAny( uno::Reference< ov::excel::XCharacters >( new ScVbaCharacters( this, mxContext, aPalette, xSimpleText, aStart, aLength, sal_True ) ) ); } rtl::OUString& @@ -171,3 +70,12 @@ ScVbaTextFrame::getServiceNames() return aServiceNames; } +namespace textframe +{ +namespace sdecl = comphelper::service_decl; +sdecl::vba_service_class_<ScVbaTextFrame, sdecl::with_args<true> > serviceImpl; +extern sdecl::ServiceDecl const serviceDecl( + serviceImpl, + "ScVbaTextFrame", + "ooo.vba.excel.TextFrame" ); +} diff --git a/sc/source/ui/vba/vbatextframe.hxx b/sc/source/ui/vba/vbatextframe.hxx index 6bb75551c00c..8aa85f34be09 100644 --- a/sc/source/ui/vba/vbatextframe.hxx +++ b/sc/source/ui/vba/vbatextframe.hxx @@ -29,45 +29,23 @@ ************************************************************************/ #ifndef SC_VBA_TEXTFRAME_HXX #define SC_VBA_TEXTFRAME_HXX -#include <com/sun/star/drawing/XShape.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <ooo/vba/excel/XCharacters.hpp> #include <ooo/vba/excel/XTextFrame.hpp> +#include <vbahelper/vbahelperinterface.hxx> +#include <vbahelper/vbatextframe.hxx> -#include "vbahelperinterface.hxx" -#include "vbapalette.hxx" - -typedef InheritedHelperInterfaceImpl1< ov::excel::XTextFrame > ScVbaTextFrame_BASE; +//typedef InheritedHelperInterfaceImpl1< ov::excel::XTextFrame > ScVbaTextFrame_BASE; +typedef cppu::ImplInheritanceHelper1< VbaTextFrame, ov::excel::XTextFrame > ScVbaTextFrame_BASE; class ScVbaTextFrame : public ScVbaTextFrame_BASE { -private: - css::uno::Reference< ov::excel::XCharacters > m_xCharacters; - css::uno::Reference< css::drawing::XShape > m_xShape; - css::uno::Reference< css::beans::XPropertySet > m_xPropertySet; -protected: - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); - virtual void setAsMSObehavior(); - sal_Int32 getMargin( rtl::OUString sMarginType ); - void setMargin( rtl::OUString sMarginType, float fMargin ); public: - ScVbaTextFrame( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext , css::uno::Reference< css::drawing::XShape > xShape); + ScVbaTextFrame( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext > const& xContext ) throw ( css::lang::IllegalArgumentException ); virtual ~ScVbaTextFrame() {} - // Attributes - virtual sal_Bool SAL_CALL getAutoSize() throw (css::uno::RuntimeException); - virtual void SAL_CALL setAutoSize( sal_Bool _autosize ) throw (css::uno::RuntimeException); - virtual float SAL_CALL getMarginBottom() throw (css::uno::RuntimeException); - virtual void SAL_CALL setMarginBottom( float _marginbottom ) throw (css::uno::RuntimeException); - virtual float SAL_CALL getMarginTop() throw (css::uno::RuntimeException); - virtual void SAL_CALL setMarginTop( float _margintop ) throw (css::uno::RuntimeException); - virtual float SAL_CALL getMarginLeft() throw (css::uno::RuntimeException); - virtual void SAL_CALL setMarginLeft( float _marginleft ) throw (css::uno::RuntimeException); - virtual float SAL_CALL getMarginRight() throw (css::uno::RuntimeException); - virtual void SAL_CALL setMarginRight( float _marginright ) throw (css::uno::RuntimeException); - // Methods - virtual css::uno::Reference< ov::excel::XCharacters > SAL_CALL Characters( ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL Characters( ) throw (css::uno::RuntimeException); + // XHelperInterface + virtual rtl::OUString& getServiceImplName(); + virtual css::uno::Sequence<rtl::OUString> getServiceNames(); }; diff --git a/sc/source/ui/vba/vbatitle.hxx b/sc/source/ui/vba/vbatitle.hxx index 3d6c597bc67a..e696640d757f 100644 --- a/sc/source/ui/vba/vbatitle.hxx +++ b/sc/source/ui/vba/vbatitle.hxx @@ -30,14 +30,15 @@ #ifndef SC_VBA_TITLE_HXX #define SC_VBA_TITLE_HXX -#include "vbahelperinterface.hxx" -#include "vbahelper.hxx" +#include <vbahelper/vbahelperinterface.hxx> +#include "excelvbahelper.hxx" #include "vbainterior.hxx" #include "vbafont.hxx" #include "vbapalette.hxx" #include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <ooo/vba/excel/XTitle.hpp> +#include <ooo/vba/excel/XCharacters.hpp> #include <basic/sberrors.hxx> #include <memory> diff --git a/sc/source/ui/vba/vbavalidation.hxx b/sc/source/ui/vba/vbavalidation.hxx index 60d24ac0c6c5..cef989aa3cea 100644 --- a/sc/source/ui/vba/vbavalidation.hxx +++ b/sc/source/ui/vba/vbavalidation.hxx @@ -33,7 +33,7 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <ooo/vba/excel/XValidation.hpp> #include <com/sun/star/table/XCellRange.hpp> -#include "vbahelperinterface.hxx" +#include <vbahelper/vbahelperinterface.hxx> typedef InheritedHelperInterfaceImpl1<ov::excel::XValidation > ValidationImpl_BASE; diff --git a/sc/source/ui/vba/vbawindow.cxx b/sc/source/ui/vba/vbawindow.cxx index a38ba7c9ed46..d782fb95dc70 100644 --- a/sc/source/ui/vba/vbawindow.cxx +++ b/sc/source/ui/vba/vbawindow.cxx @@ -27,10 +27,11 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#include "helperdecl.hxx" +#include <vbahelper/helperdecl.hxx> #include "vbawindow.hxx" #include "vbaworksheets.hxx" #include "vbaworksheet.hxx" +#include "vbaglobals.hxx" #include "vbapane.hxx" #include <com/sun/star/sheet/XSpreadsheetDocument.hpp> #include <com/sun/star/sheet/XSpreadsheet.hpp> @@ -57,6 +58,9 @@ using namespace ::com::sun::star; using namespace ::ooo::vba; using namespace ::ooo::vba::excel::XlWindowState; +// nameExists defined in vbaworksheet.cxx +bool nameExists( uno::Reference <sheet::XSpreadsheetDocument>& xSpreadDoc, ::rtl::OUString & name, SCTAB& nTab ) throw ( lang::IllegalArgumentException ); + typedef std::hash_map< rtl::OUString, SCTAB, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > NameIndexHash; @@ -118,7 +122,7 @@ public: ScDocShell* pDocShell = (ScDocShell*)pModel->GetEmbeddedObject(); if ( !pDocShell ) throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Cannot obtain docshell" ) ), uno::Reference< uno::XInterface >() ); - ScTabViewShell* pViewShell = getBestViewShell( m_xModel ); + ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel ); if ( !pViewShell ) throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Cannot obtain view shell" ) ), uno::Reference< uno::XInterface >() ); @@ -202,14 +206,13 @@ public: }; -ScVbaWindow::ScVbaWindow( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : WindowImpl_BASE( xParent, xContext ), m_xModel( xModel ) +ScVbaWindow::ScVbaWindow( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : WindowImpl_BASE( xParent, xContext, xModel ) { init(); } ScVbaWindow::ScVbaWindow( uno::Sequence< uno::Any > const & args, uno::Reference< uno::XComponentContext > const & xContext ) - : WindowImpl_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext ), - m_xModel( getXSomethingFromArgs< frame::XModel >( args, 1 ) ) + : WindowImpl_BASE( args, xContext ) { init(); } @@ -306,8 +309,7 @@ ScVbaWindow::getCaption() throw (uno::RuntimeException) if ( ( nCrudLen + nCrudIndex ) == sTitle.getLength() ) { sTitle = sTitle.copy( 0, nCrudIndex ); - uno::Reference< ov::XGlobals > xTemp( ScVbaGlobals::getGlobalsImpl( mxContext )); // temporary needed for g++ 3.3.5 - ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( xTemp->getApplication(), uno::UNO_QUERY_THROW ), mxContext, m_xModel ); + ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel ); rtl::OUString sName = workbook.getName(); // rather bizare hack to make sure the name behavior // is like XL @@ -343,7 +345,7 @@ uno::Any SAL_CALL ScVbaWindow::getScrollRow() throw (uno::RuntimeException) { sal_Int32 nValue = 0; - ScTabViewShell* pViewShell = getBestViewShell( m_xModel ); + ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel ); if ( pViewShell ) { ScSplitPos eWhich = pViewShell->GetViewData()->GetActivePart(); @@ -356,7 +358,7 @@ ScVbaWindow::getScrollRow() throw (uno::RuntimeException) void SAL_CALL ScVbaWindow::setScrollRow( const uno::Any& _scrollrow ) throw (uno::RuntimeException) { - ScTabViewShell* pViewShell = getBestViewShell( m_xModel ); + ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel ); if ( pViewShell ) { sal_Int32 scrollRow = 0; @@ -371,7 +373,7 @@ uno::Any SAL_CALL ScVbaWindow::getScrollColumn() throw (uno::RuntimeException) { sal_Int32 nValue = 0; - ScTabViewShell* pViewShell = getBestViewShell( m_xModel ); + ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel ); if ( pViewShell ) { ScSplitPos eWhich = pViewShell->GetViewData()->GetActivePart(); @@ -384,7 +386,7 @@ ScVbaWindow::getScrollColumn() throw (uno::RuntimeException) void SAL_CALL ScVbaWindow::setScrollColumn( const uno::Any& _scrollcolumn ) throw (uno::RuntimeException) { - ScTabViewShell* pViewShell = getBestViewShell( m_xModel ); + ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel ); if ( pViewShell ) { sal_Int32 scrollColumn = 0; @@ -399,7 +401,7 @@ uno::Any SAL_CALL ScVbaWindow::getWindowState() throw (uno::RuntimeException) { sal_Int32 nwindowState = xlNormal; - ScTabViewShell* pViewShell = getBestViewShell( m_xModel ); + ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel ); SfxViewFrame* pViewFrame = pViewShell -> GetViewFrame(); SfxTopViewFrame *pTop= PTR_CAST( SfxTopViewFrame, pViewFrame -> GetTopViewFrame() ); if ( pTop ) @@ -421,7 +423,7 @@ ScVbaWindow::setWindowState( const uno::Any& _windowstate ) throw (uno::RuntimeE { sal_Int32 nwindowState = xlMaximized; _windowstate >>= nwindowState; - ScTabViewShell* pViewShell = getBestViewShell( m_xModel ); + ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel ); SfxViewFrame* pViewFrame = pViewShell -> GetViewFrame(); SfxTopViewFrame *pTop= PTR_CAST( SfxTopViewFrame, pViewFrame -> GetTopViewFrame() ); if ( pTop ) @@ -444,8 +446,7 @@ ScVbaWindow::setWindowState( const uno::Any& _windowstate ) throw (uno::RuntimeE void ScVbaWindow::Activate() throw (css::uno::RuntimeException) { - uno::Reference< ov::XGlobals > xTemp( ScVbaGlobals::getGlobalsImpl( mxContext )); // temporary needed for g++ 3.3.5 - ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( xTemp->getApplication(), uno::UNO_QUERY_THROW ), mxContext, m_xModel ); + ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel ); workbook.Activate(); } @@ -453,8 +454,7 @@ ScVbaWindow::Activate() throw (css::uno::RuntimeException) void ScVbaWindow::Close( const uno::Any& SaveChanges, const uno::Any& FileName, const uno::Any& RouteWorkBook ) throw (uno::RuntimeException) { - uno::Reference< ov::XGlobals > xTemp( ScVbaGlobals::getGlobalsImpl( mxContext )); // temporary needed for g++ 3.3.5 - ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( xTemp->getApplication(), uno::UNO_QUERY_THROW ), mxContext, m_xModel ); + ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel ); workbook.Close(SaveChanges, FileName, RouteWorkBook ); } @@ -467,13 +467,15 @@ ScVbaWindow::ActivePane() throw (script::BasicErrorException, uno::RuntimeExcept uno::Reference< excel::XRange > SAL_CALL ScVbaWindow::ActiveCell( ) throw (script::BasicErrorException, uno::RuntimeException) { - return ScVbaGlobals::getGlobalsImpl( mxContext )->getApplication()->getActiveCell(); + uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW ); + return xApplication->getActiveCell(); } uno::Any SAL_CALL ScVbaWindow::Selection( ) throw (script::BasicErrorException, uno::RuntimeException) { - return ScVbaGlobals::getGlobalsImpl( mxContext )->getApplication()->getSelection(); + uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW ); + return xApplication->getSelection(); } ::sal_Bool SAL_CALL @@ -736,30 +738,25 @@ ScVbaWindow::getZoom() throw (uno::RuntimeException) void SAL_CALL ScVbaWindow::setZoom( const uno::Any& _zoom ) throw (uno::RuntimeException) { - uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - rtl::OUString sZoomType( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_ZOOMTYPE ) ); - sal_Int16 nZoomType = view::DocumentZoomType::PAGE_WIDTH; - if( _zoom.getValueTypeClass() == uno::TypeClass_BOOLEAN ) - { - //zoom type is PAGE_WIDTH_EXACT in helperapi, it seems that there is a issue for this zoom type in current OOo. - // so PAGE_WIDTH is used. - xProps->setPropertyValue(sZoomType, uno::makeAny( nZoomType )); - } - else - { - nZoomType = view::DocumentZoomType::BY_VALUE; - rtl::OUString sZoomValue( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_ZOOMVALUE )); - sal_Int16 nZoomValue = 100; - _zoom >>= nZoomValue; - xProps->setPropertyValue( sZoomType, uno::makeAny( nZoomType )); - xProps->setPropertyValue( sZoomValue, uno::makeAny( nZoomValue )); - } + sal_Int16 nZoom = 100; + _zoom >>= nZoom; + uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( m_xModel, uno::UNO_QUERY_THROW ); + uno::Reference< excel::XWorksheet > xActiveSheet = ActiveSheet(); + SCTAB nTab = 0; + rtl::OUString sName = xActiveSheet->getName(); + bool bSheetExists = nameExists (xSpreadDoc, sName, nTab); + if ( !bSheetExists ) + throw uno::RuntimeException(); + std::vector< SCTAB > vTabs; + vTabs.push_back( nTab ); + excel::implSetZoom( m_xModel, nZoom, vTabs ); } uno::Reference< excel::XWorksheet > SAL_CALL ScVbaWindow::ActiveSheet( ) throw (script::BasicErrorException, uno::RuntimeException) { - return ScVbaGlobals::getGlobalsImpl(mxContext)->getApplication()->getActiveSheet(); + uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW ); + return xApplication->getActiveSheet(); } uno::Any SAL_CALL @@ -787,121 +784,9 @@ ScVbaWindow::setView( const uno::Any& _view) throw (uno::RuntimeException) default: DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() ); } - dispatchExecute( m_xModel, nSlot ); -} - -sal_Bool SAL_CALL -ScVbaWindow::getVisible() throw (uno::RuntimeException) -{ - sal_Bool bVisible = sal_True; - uno::Reference< frame::XController > xController( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - uno::Reference< css::awt::XWindow > xWindow (xController->getFrame()->getContainerWindow(), uno::UNO_QUERY_THROW ); - uno::Reference< css::awt::XWindow2 > xWindow2 (xWindow, uno::UNO_QUERY_THROW ); - if( xWindow2.is() ) - { - bVisible = xWindow2->isVisible(); - } - return bVisible; -} - -void SAL_CALL -ScVbaWindow::setVisible(sal_Bool _visible) throw (uno::RuntimeException) -{ - uno::Reference< frame::XController > xController( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - uno::Reference< css::awt::XWindow > xWindow (xController->getFrame()->getContainerWindow(), uno::UNO_QUERY_THROW ); - if( xWindow.is() ) - { - xWindow->setVisible( _visible ); - } -} - -css::awt::Rectangle getPosSize( const uno::Reference< frame::XModel >& xModel ) -{ - css::awt::Rectangle aRect; - uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - uno::Reference< css::awt::XWindow > xWindow (xController->getFrame()->getContainerWindow(), uno::UNO_QUERY_THROW ); - if( xWindow.is() ) - { - aRect = xWindow->getPosSize(); - } - return aRect; -} - -void setPosSize( const uno::Reference< frame::XModel >& xModel, sal_Int32 nValue, USHORT nFlag ) -{ - uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - uno::Reference< css::awt::XWindow > xWindow (xController->getFrame()->getContainerWindow(), uno::UNO_QUERY_THROW ); - if( xWindow.is() ) - { - css::awt::Rectangle aRect = xWindow->getPosSize(); - switch( nFlag ) - { - case css::awt::PosSize::X: - xWindow->setPosSize( nValue, aRect.Y, 0, 0, css::awt::PosSize::X ); - break; - case css::awt::PosSize::Y: - xWindow->setPosSize( aRect.X, nValue, 0, 0, css::awt::PosSize::Y ); - break; - case css::awt::PosSize::WIDTH: - xWindow->setPosSize( 0, 0, nValue, aRect.Height, css::awt::PosSize::WIDTH ); - break; - case css::awt::PosSize::HEIGHT: - xWindow->setPosSize( 0, 0, aRect.Width, nValue, css::awt::PosSize::HEIGHT ); - break; - default: - break; - } - } -} - -sal_Int32 SAL_CALL -ScVbaWindow::getHeight() throw (uno::RuntimeException) -{ - css::awt::Rectangle aRect = getPosSize(m_xModel); - return aRect.Height; -} - -void SAL_CALL -ScVbaWindow::setHeight( sal_Int32 _height ) throw (uno::RuntimeException) -{ - setPosSize(m_xModel, _height, css::awt::PosSize::HEIGHT); -} - -sal_Int32 SAL_CALL -ScVbaWindow::getLeft() throw (uno::RuntimeException) -{ - css::awt::Rectangle aRect = getPosSize(m_xModel); - return aRect.X; -} - -void SAL_CALL -ScVbaWindow::setLeft( sal_Int32 _left ) throw (uno::RuntimeException) -{ - setPosSize(m_xModel, _left, css::awt::PosSize::X); -} -sal_Int32 SAL_CALL -ScVbaWindow::getTop() throw (uno::RuntimeException) -{ - css::awt::Rectangle aRect = getPosSize(m_xModel); - return aRect.Y; -} - -void SAL_CALL -ScVbaWindow::setTop( sal_Int32 _top ) throw (uno::RuntimeException) -{ - setPosSize(m_xModel, _top, css::awt::PosSize::Y); -} -sal_Int32 SAL_CALL -ScVbaWindow::getWidth() throw (uno::RuntimeException) -{ - css::awt::Rectangle aRect = getPosSize(m_xModel); - return aRect.Width; -} - -void SAL_CALL -ScVbaWindow::setWidth( sal_Int32 _width ) throw (uno::RuntimeException) -{ - setPosSize(m_xModel, _width, css::awt::PosSize::WIDTH); + ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel ); + if ( pViewShell ) + dispatchExecute( pViewShell, nSlot ); } sal_Int32 SAL_CALL @@ -924,14 +809,14 @@ void SAL_CALL ScVbaWindow::PrintOut( 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 ) throw (css::script::BasicErrorException, css::uno::RuntimeException) { // need test, print current active sheet - PrintOutHelper( From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, m_xModel, sal_True ); + PrintOutHelper( excel::getBestViewShell( m_xModel ), From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, sal_True ); } void SAL_CALL ScVbaWindow::PrintPreview( const css::uno::Any& EnableChanges ) throw (css::script::BasicErrorException, css::uno::RuntimeException) { // need test, print preview current active sheet - PrintPreviewHelper( EnableChanges, m_xModel ); + PrintPreviewHelper( EnableChanges, excel::getBestViewShell( m_xModel ) ); } rtl::OUString& diff --git a/sc/source/ui/vba/vbawindow.hxx b/sc/source/ui/vba/vbawindow.hxx index b32f3b99398a..968d258961c8 100644 --- a/sc/source/ui/vba/vbawindow.hxx +++ b/sc/source/ui/vba/vbawindow.hxx @@ -39,15 +39,16 @@ #include <ooo/vba/excel/XPane.hpp> #include <com/sun/star/awt/XDevice.hpp> -#include "vbahelperinterface.hxx" +#include <vbahelper/vbahelperinterface.hxx> +#include <vbahelper/vbawindowbase.hxx> #include "vbaworkbook.hxx" -typedef InheritedHelperInterfaceImpl1<ov::excel::XWindow > WindowImpl_BASE; +//typedef InheritedHelperInterfaceImpl1<ov::excel::XWindow > WindowImpl_BASE; +typedef cppu::ImplInheritanceHelper1< VbaWindowBase, ov::excel::XWindow > WindowImpl_BASE; class ScVbaWindow : public WindowImpl_BASE { private: - css::uno::Reference< css::frame::XModel > m_xModel; css::uno::Reference< css::sheet::XViewPane > m_xViewPane; css::uno::Reference< css::sheet::XViewFreezable > m_xViewFreezable; css::uno::Reference< css::sheet::XViewSplitable > m_xViewSplitable; @@ -82,10 +83,6 @@ public: virtual void SAL_CALL setDisplayWorkbookTabs( ::sal_Bool _bDisplayWorkbookTabs ) throw (css::uno::RuntimeException); virtual ::sal_Bool SAL_CALL getFreezePanes() throw (css::uno::RuntimeException); virtual void SAL_CALL setFreezePanes( ::sal_Bool _bFreezePanes ) throw (css::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getHeight() throw (css::uno::RuntimeException) ; - virtual void SAL_CALL setHeight( sal_Int32 _height ) throw (css::uno::RuntimeException) ; - virtual sal_Int32 SAL_CALL getLeft() throw (css::uno::RuntimeException) ; - virtual void SAL_CALL setLeft( sal_Int32 _left ) throw (css::uno::RuntimeException) ; virtual ::sal_Bool SAL_CALL getSplit() throw (css::uno::RuntimeException); virtual void SAL_CALL setSplit( ::sal_Bool _bSplit ) throw (css::uno::RuntimeException); virtual sal_Int32 SAL_CALL getSplitColumn() throw (css::uno::RuntimeException) ; @@ -100,14 +97,8 @@ public: virtual void SAL_CALL setScrollRow( const css::uno::Any& _scrollrow ) throw (css::uno::RuntimeException) ; virtual css::uno::Any SAL_CALL getScrollColumn() throw (css::uno::RuntimeException) ; virtual void SAL_CALL setScrollColumn( const css::uno::Any& _scrollcolumn ) throw (css::uno::RuntimeException) ; - virtual sal_Int32 SAL_CALL getTop() throw (css::uno::RuntimeException) ; - virtual void SAL_CALL setTop( sal_Int32 _top ) throw (css::uno::RuntimeException) ; virtual css::uno::Any SAL_CALL getView() throw (css::uno::RuntimeException); virtual void SAL_CALL setView( const css::uno::Any& _view ) throw (css::uno::RuntimeException); - virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException); - virtual void SAL_CALL setVisible( sal_Bool _visible ) throw (css::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getWidth() throw (css::uno::RuntimeException) ; - virtual void SAL_CALL setWidth( sal_Int32 _width ) throw (css::uno::RuntimeException) ; virtual css::uno::Any SAL_CALL getWindowState() throw (css::uno::RuntimeException); virtual void SAL_CALL setWindowState( const css::uno::Any& _windowstate ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getZoom() throw (css::uno::RuntimeException); diff --git a/sc/source/ui/vba/vbawindows.cxx b/sc/source/ui/vba/vbawindows.cxx index b14a31c7c42c..ae16efdebcf4 100644 --- a/sc/source/ui/vba/vbawindows.cxx +++ b/sc/source/ui/vba/vbawindows.cxx @@ -37,6 +37,7 @@ #include <tools/urlobj.hxx> #include "vbawindow.hxx" +#include "vbaglobals.hxx" //#include "vbaworkbook.hxx" using namespace ::com::sun::star; @@ -47,15 +48,15 @@ sal_Int32, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > NameIndexHash; -uno::Reference< XHelperInterface > lcl_createWorkbookHIParent( const uno::Reference< frame::XModel >& xModel, const uno::Reference< uno::XComponentContext >& xContext ) +uno::Reference< XHelperInterface > lcl_createWorkbookHIParent( const uno::Reference< frame::XModel >& xModel, const uno::Reference< uno::XComponentContext >& xContext, const uno::Any& aApplication ) { - return new ScVbaWorkbook( uno::Reference< XHelperInterface >( ScVbaGlobals::getGlobalsImpl( xContext )->getApplication(), uno::UNO_QUERY_THROW ), xContext, xModel ); + return new ScVbaWorkbook( uno::Reference< XHelperInterface >( aApplication, uno::UNO_QUERY_THROW ), xContext, xModel ); } -uno::Any ComponentToWindow( const uno::Any& aSource, uno::Reference< uno::XComponentContext > & xContext ) +uno::Any ComponentToWindow( const uno::Any& aSource, uno::Reference< uno::XComponentContext > & xContext, const uno::Any& aApplication ) { uno::Reference< frame::XModel > xModel( aSource, uno::UNO_QUERY_THROW ); - uno::Reference< excel::XWindow > xWin( new ScVbaWindow( lcl_createWorkbookHIParent( xModel, xContext ), xContext,xModel ) ); + uno::Reference< excel::XWindow > xWin( new ScVbaWindow( lcl_createWorkbookHIParent( xModel, xContext, aApplication ), xContext,xModel ) ); return uno::makeAny( xWin ); } @@ -108,12 +109,13 @@ public: class WindowEnumImpl : public WindowComponentEnumImpl { + uno::Any m_aApplication; public: - WindowEnumImpl(const uno::Reference< uno::XComponentContext >& xContext, const Components& components ):WindowComponentEnumImpl( xContext, components ) {} - WindowEnumImpl( const uno::Reference< uno::XComponentContext >& xContext ): WindowComponentEnumImpl( xContext ) {} + WindowEnumImpl(const uno::Reference< uno::XComponentContext >& xContext, const Components& components, const uno::Any& aApplication ):WindowComponentEnumImpl( xContext, components ), m_aApplication( aApplication ){} + WindowEnumImpl( const uno::Reference< uno::XComponentContext >& xContext, const uno::Any& aApplication ): WindowComponentEnumImpl( xContext ), m_aApplication( aApplication ) {} virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) { - return ComponentToWindow( WindowComponentEnumImpl::nextElement(), m_xContext ); + return ComponentToWindow( WindowComponentEnumImpl::nextElement(), m_xContext, m_aApplication ); } }; @@ -212,16 +214,19 @@ ScVbaWindows::ScVbaWindows( const uno::Reference< ov::XHelperInterface >& xParen { } +ScVbaWindows::ScVbaWindows( const uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : ScVbaWindows_BASE( xParent, xContext, uno::Reference< container::XIndexAccess > ( new WindowsAccessImpl( xContext ) ) ) +{ +} uno::Reference< container::XEnumeration > ScVbaWindows::createEnumeration() throw (uno::RuntimeException) { - return new WindowEnumImpl( mxContext ); + return new WindowEnumImpl( mxContext, Application() ); } uno::Any ScVbaWindows::createCollectionObject( const css::uno::Any& aSource ) { - return ComponentToWindow( aSource, mxContext ); + return ComponentToWindow( aSource, mxContext, Application() ); } uno::Type @@ -230,12 +235,6 @@ ScVbaWindows::getElementType() throw (uno::RuntimeException) return excel::XWindows::static_type(0); } -uno::Reference< XCollection > -ScVbaWindows::Windows( const css::uno::Reference< css::uno::XComponentContext >& xContext ) -{ - uno::Reference< container::XIndexAccess > xIndex( new WindowsAccessImpl( xContext ) ); - return new ScVbaWindows( uno::Reference< XHelperInterface >( ScVbaGlobals::getGlobalsImpl( xContext )->getApplication(), uno::UNO_QUERY_THROW ), xContext , xIndex ); -} void SAL_CALL ScVbaWindows::Arrange( ::sal_Int32 /*ArrangeStyle*/, const uno::Any& /*ActiveWorkbook*/, const uno::Any& /*SyncHorizontal*/, const uno::Any& /*SyncVertical*/ ) throw (uno::RuntimeException) diff --git a/sc/source/ui/vba/vbawindows.hxx b/sc/source/ui/vba/vbawindows.hxx index 3c828d4e3355..5aff0094ebf3 100644 --- a/sc/source/ui/vba/vbawindows.hxx +++ b/sc/source/ui/vba/vbawindows.hxx @@ -35,8 +35,8 @@ #include <com/sun/star/uno/XComponentContext.hpp> -#include "vbahelper.hxx" -#include "vbacollectionimpl.hxx" +#include "excelvbahelper.hxx" +#include <vbahelper/vbacollectionimpl.hxx> typedef CollTestImplHelper< ov::excel::XWindows > ScVbaWindows_BASE; @@ -45,6 +45,7 @@ class ScVbaWindows : public ScVbaWindows_BASE { public: ScVbaWindows( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess ); + ScVbaWindows( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext ); virtual ~ScVbaWindows() {} // XEnumerationAccess @@ -57,8 +58,6 @@ public: // ScVbaCollectionBaseImpl virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - static css::uno::Reference< ov::XCollection > Windows( const css::uno::Reference< css::uno::XComponentContext >& xContext ); - // XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence<rtl::OUString> getServiceNames(); diff --git a/sc/source/ui/vba/vbaworkbook.cxx b/sc/source/ui/vba/vbaworkbook.cxx index c89de4c2a10a..498d77e79a14 100644 --- a/sc/source/ui/vba/vbaworkbook.cxx +++ b/sc/source/ui/vba/vbaworkbook.cxx @@ -27,7 +27,7 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#include "helperdecl.hxx" +#include <vbahelper/helperdecl.hxx> #include <tools/urlobj.hxx> #include <comphelper/unwrapargs.hxx> @@ -46,12 +46,13 @@ #include "vbaworkbook.hxx" #include "vbawindows.hxx" #include "vbastyles.hxx" -#include "vbahelper.hxx" +#include "excelvbahelper.hxx" #include "vbapalette.hxx" #include <osl/file.hxx> #include <stdio.h> #include "vbanames.hxx" // Amelia Wang #include "nameuno.hxx" +#include "docoptio.hxx" // Much of the impl. for the equivalend UNO module is // sc/source/ui/unoobj/docuno.cxx, viewuno.cxx @@ -64,7 +65,7 @@ class ActiveSheet : public ScVbaWorksheet protected: virtual uno::Reference< frame::XModel > getModel() { - return getCurrentDocument(); + return getCurrentExcelDoc( mxContext ); } virtual uno::Reference< sheet::XSpreadsheet > getSheet() { @@ -192,7 +193,7 @@ ScVbaWorkbook::init() if ( !ColorData.getLength() ) ResetColors(); } -ScVbaWorkbook::ScVbaWorkbook( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext) :ScVbaWorkbook_BASE( xParent, xContext ), mxModel(NULL) +ScVbaWorkbook::ScVbaWorkbook( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext) :ScVbaWorkbook_BASE( xParent, xContext ) { //#FIXME this persists the color data per office instance and // not per workbook instance, need to hook the data into XModel @@ -203,58 +204,27 @@ ScVbaWorkbook::ScVbaWorkbook( const css::uno::Reference< ov::XHelperInterface init(); } -ScVbaWorkbook::ScVbaWorkbook( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, css::uno::Reference< css::frame::XModel > xModel ) : ScVbaWorkbook_BASE( xParent, xContext ), mxModel( xModel ) +ScVbaWorkbook::ScVbaWorkbook( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, css::uno::Reference< css::frame::XModel > xModel ) : ScVbaWorkbook_BASE( xParent, xContext, xModel ) { init(); } ScVbaWorkbook::ScVbaWorkbook( uno::Sequence< uno::Any> const & args, - uno::Reference< uno::XComponentContext> const & xContext ) : ScVbaWorkbook_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext ), mxModel( getXSomethingFromArgs< frame::XModel >( args, 1 ) ) + uno::Reference< uno::XComponentContext> const & xContext ) : ScVbaWorkbook_BASE( args, xContext ) { init(); } -::rtl::OUString -ScVbaWorkbook::getName() throw (uno::RuntimeException) -{ - rtl::OUString sName = getModel()->getURL(); - if ( sName.getLength() ) - { - - INetURLObject aURL( getModel()->getURL() ); - ::osl::File::getSystemPathFromFileURL( aURL.GetLastName(), sName ); - } - else - { - const static rtl::OUString sTitle( RTL_CONSTASCII_USTRINGPARAM("Title" ) ); - // process "UntitledX - $(PRODUCTNAME)" - uno::Reference< frame::XFrame > xFrame( getModel()->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW ); - uno::Reference< beans::XPropertySet > xProps( xFrame, uno::UNO_QUERY_THROW ); - xProps->getPropertyValue(sTitle ) >>= sName; - sal_Int32 pos = 0; - sName = sName.getToken(0,' ',pos); - } - return sName; -} -::rtl::OUString -ScVbaWorkbook::getPath() throw (uno::RuntimeException) -{ - INetURLObject aURL( getModel()->getURL() ); - aURL.CutLastName(); - return aURL.GetURLPath(); -} - -::rtl::OUString -ScVbaWorkbook::getFullName() throw (uno::RuntimeException) -{ - INetURLObject aURL( getModel()->getURL() ); - return aURL.GetURLPath(); -} uno::Reference< excel::XWorksheet > ScVbaWorkbook::getActiveSheet() throw (uno::RuntimeException) { - return new ActiveSheet( this, mxContext ); + uno::Reference< frame::XModel > xModel( getCurrentExcelDoc( mxContext ) ); + uno::Reference< sheet::XSpreadsheet > xSheet; + uno::Reference< sheet::XSpreadsheetView > xView( xModel->getCurrentController(), uno::UNO_QUERY_THROW ); + if ( xView.is() ) + xSheet = xView->getActiveSheet(); + return new ScVbaWorksheet( this, mxContext, xSheet, xModel ); } uno::Any SAL_CALL ScVbaWorkbook::Sheets( const uno::Any& aIndex ) throw (uno::RuntimeException) @@ -281,89 +251,17 @@ ScVbaWorkbook::Worksheets( const uno::Any& aIndex ) throw (uno::RuntimeException uno::Any SAL_CALL ScVbaWorkbook::Windows( const uno::Any& aIndex ) throw (uno::RuntimeException) { - uno::Reference< XCollection > xWindows = ScVbaWindows::Windows( mxContext ); + + uno::Reference< excel::XWindows > xWindows( new ScVbaWindows( getParent(), mxContext ) ); if ( aIndex.getValueTypeClass() == uno::TypeClass_VOID ) return uno::Any( xWindows ); return uno::Any( xWindows->Item( aIndex, uno::Any() ) ); } -void -ScVbaWorkbook::Close( const uno::Any &rSaveArg, const uno::Any &rFileArg, - const uno::Any &rRouteArg ) throw (uno::RuntimeException) -{ - sal_Bool bSaveChanges = sal_False; - rtl::OUString aFileName; - sal_Bool bRouteWorkbook = sal_True; - - rSaveArg >>= bSaveChanges; - sal_Bool bFileName = ( rFileArg >>= aFileName ); - rRouteArg >>= bRouteWorkbook; - uno::Reference< frame::XStorable > xStorable( getModel(), uno::UNO_QUERY_THROW ); - uno::Reference< util::XModifiable > xModifiable( getModel(), uno::UNO_QUERY_THROW ); - - if( bSaveChanges ) - { - if( xStorable->isReadonly() ) - { - throw uno::RuntimeException(::rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "Unable to save to a read only file ") ), - uno::Reference< XInterface >() ); - } - if( bFileName ) - xStorable->storeAsURL( aFileName, uno::Sequence< beans::PropertyValue >(0) ); - else - xStorable->store(); - } - else - xModifiable->setModified( false ); - - uno::Reference< util::XCloseable > xCloseable( getModel(), uno::UNO_QUERY ); - - if( xCloseable.is() ) - // use close(boolean DeliverOwnership) - // The boolean parameter DeliverOwnership tells objects vetoing the close process that they may - // assume ownership if they object the closure by throwing a CloseVetoException - // Here we give up ownership. To be on the safe side, catch possible veto exception anyway. - xCloseable->close(sal_True); - // If close is not supported by this model - try to dispose it. - // But if the model disagree with a reset request for the modify state - // we shouldn't do so. Otherwhise some strange things can happen. - else - { - uno::Reference< lang::XComponent > xDisposable ( getCurrentDocument(), uno::UNO_QUERY ); - if ( xDisposable.is() ) - xDisposable->dispose(); - } -} - -void -ScVbaWorkbook::Protect( const uno::Any &aPassword ) throw (uno::RuntimeException) +void SAL_CALL +ScVbaWorkbook::Activate() throw (uno::RuntimeException) { - rtl::OUString rPassword; - uno::Reference< util::XProtectable > xProt( getModel(), uno::UNO_QUERY_THROW ); - SC_VBA_FIXME(("Workbook::Protect stub")); - if( aPassword >>= rPassword ) - xProt->protect( rPassword ); - else - xProt->protect( rtl::OUString() ); -} - -void -ScVbaWorkbook::Unprotect( const uno::Any &aPassword ) throw (uno::RuntimeException) -{ - rtl::OUString rPassword; - uno::Reference< util::XProtectable > xProt( getModel(), uno::UNO_QUERY_THROW ); - if( !getProtectStructure() ) - throw uno::RuntimeException(::rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "File is already unprotected" ) ), - uno::Reference< XInterface >() ); - else - { - if( aPassword >>= rPassword ) - xProt->unprotect( rPassword ); - else - xProt->unprotect( rtl::OUString() ); - } + VbaDocumentBase::Activate(); } ::sal_Bool @@ -373,26 +271,20 @@ ScVbaWorkbook::getProtectStructure() throw (uno::RuntimeException) return xProt->isProtected(); } -void -ScVbaWorkbook::setSaved( sal_Bool bSave ) throw (uno::RuntimeException) +::sal_Bool SAL_CALL ScVbaWorkbook::getPrecisionAsDisplayed() throw (uno::RuntimeException) { - uno::Reference< util::XModifiable > xModifiable( getModel(), uno::UNO_QUERY_THROW ); - xModifiable->setModified( bSave ); -} - -sal_Bool -ScVbaWorkbook::getSaved() throw (uno::RuntimeException) -{ - uno::Reference< util::XModifiable > xModifiable( getModel(), uno::UNO_QUERY_THROW ); - return xModifiable->isModified(); + uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW ); + ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument(); + return pDoc->GetDocOptions().IsCalcAsShown(); } -void -ScVbaWorkbook::Save() throw (uno::RuntimeException) +void SAL_CALL ScVbaWorkbook::setPrecisionAsDisplayed( sal_Bool _precisionAsDisplayed ) throw (uno::RuntimeException) { - rtl::OUString url = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".uno:Save")); - uno::Reference< frame::XModel > xModel = getModel(); - dispatchRequests(xModel,url); + uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW ); + ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument(); + ScDocOptions aOpt = pDoc->GetDocOptions(); + aOpt.SetCalcAsShown( _precisionAsDisplayed ); + pDoc->SetDocOptions( aOpt ); } void @@ -407,13 +299,6 @@ ScVbaWorkbook::SaveCopyAs( const rtl::OUString& sFileName ) throw ( uno::Runtime xStor->storeToURL( aURL, storeProps ); } -void -ScVbaWorkbook::Activate() throw (uno::RuntimeException) -{ - uno::Reference< frame::XFrame > xFrame( getModel()->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW ); - xFrame->activate(); -} - css::uno::Any SAL_CALL ScVbaWorkbook::Styles( const::uno::Any& Item ) throw (uno::RuntimeException) { @@ -465,7 +350,7 @@ ScVbaWorkbook::getCodeName() throw (css::uno::RuntimeException) { #ifdef VBA_OOBUILD_HACK uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW ); - ScDocument* pDoc = getDocShell( xModel )->GetDocument(); + ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument(); ScExtDocOptions* pExtOptions = pDoc->GetExtDocOptions(); ScExtDocSettings pExtSettings = pExtOptions->GetDocSettings(); ::rtl::OUString sGlobCodeName = pExtSettings.maGlobCodeName; @@ -479,7 +364,7 @@ void SAL_CALL ScVbaWorkbook::setCodeName( const ::rtl::OUString& sGlobCodeName ) throw (css::uno::RuntimeException) { uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW ); - ScDocument* pDoc = getDocShell( xModel )->GetDocument(); + ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument(); ScExtDocOptions* pExtOptions = pDoc->GetExtDocOptions(); ScExtDocSettings pExtSettings = pExtOptions->GetDocSettings(); pExtSettings.maGlobCodeName = sGlobCodeName; diff --git a/sc/source/ui/vba/vbaworkbook.hxx b/sc/source/ui/vba/vbaworkbook.hxx index 67d14dac148c..cf221fd934a0 100644 --- a/sc/source/ui/vba/vbaworkbook.hxx +++ b/sc/source/ui/vba/vbaworkbook.hxx @@ -32,21 +32,20 @@ #include <com/sun/star/frame/XModel.hpp> #include <ooo/vba/excel/XWorkbook.hpp> -#include "vbahelperinterface.hxx" +#include <vbahelper/vbahelperinterface.hxx> +#include <vbahelper/vbadocumentbase.hxx> class ScModelObj; -typedef InheritedHelperInterfaceImpl1< ov::excel::XWorkbook > ScVbaWorkbook_BASE; +typedef cppu::ImplInheritanceHelper1< VbaDocumentBase, ov::excel::XWorkbook > ScVbaWorkbook_BASE; class ScVbaWorkbook : public ScVbaWorkbook_BASE { - css::uno::Reference< css::frame::XModel > mxModel; static css::uno::Sequence< sal_Int32 > ColorData; void initColorData( const css::uno::Sequence< sal_Int32 >& sColors ); void init(); protected: - virtual css::uno::Reference< css::frame::XModel > getModel() { return mxModel; } ScVbaWorkbook( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext); public: ScVbaWorkbook( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, @@ -55,24 +54,15 @@ public: virtual ~ScVbaWorkbook() {} // Attributes - virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getPath() throw (css::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getFullName() throw (css::uno::RuntimeException); virtual ::sal_Bool SAL_CALL getProtectStructure() throw (css::uno::RuntimeException); virtual css::uno::Reference< ov::excel::XWorksheet > SAL_CALL getActiveSheet() throw (css::uno::RuntimeException); - virtual sal_Bool SAL_CALL getSaved() throw (css::uno::RuntimeException); - virtual void SAL_CALL setSaved( sal_Bool bSave ) throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getPrecisionAsDisplayed() throw (css::uno::RuntimeException); + virtual void SAL_CALL setPrecisionAsDisplayed( sal_Bool _precisionAsDisplayed ) throw (css::uno::RuntimeException); // Methods virtual css::uno::Any SAL_CALL Worksheets( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL Sheets( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL Windows( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); - virtual void SAL_CALL Close( const css::uno::Any &bSaveChanges, - const css::uno::Any &aFileName, - const css::uno::Any &bRouteWorkbook ) throw (css::uno::RuntimeException); - virtual void SAL_CALL Protect( const css::uno::Any & aPassword ) throw (css::uno::RuntimeException); - virtual void SAL_CALL Unprotect( const css::uno::Any &aPassword ) throw (css::uno::RuntimeException); - virtual void SAL_CALL Save() throw (css::uno::RuntimeException); virtual void SAL_CALL Activate() throw (css::uno::RuntimeException); // Amelia Wang virtual css::uno::Any SAL_CALL Names( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); diff --git a/sc/source/ui/vba/vbaworkbooks.cxx b/sc/source/ui/vba/vbaworkbooks.cxx index 40c8370f4aec..1686144b4841 100644 --- a/sc/source/ui/vba/vbaworkbooks.cxx +++ b/sc/source/ui/vba/vbaworkbooks.cxx @@ -56,7 +56,7 @@ #include "vbaglobals.hxx" #include "vbaworkbook.hxx" #include "vbaworkbooks.hxx" -#include "vbahelper.hxx" +#include <vbahelper/vbahelper.hxx> #include <hash_map> #include <osl/file.hxx> @@ -65,180 +65,33 @@ using namespace ::com::sun::star; const sal_Int16 CUSTOM_CHAR = 5; -typedef std::hash_map< rtl::OUString, -sal_Int32, ::rtl::OUStringHash, -::std::equal_to< ::rtl::OUString > > NameIndexHash; - -typedef std::vector < uno::Reference< sheet::XSpreadsheetDocument > > WorkBooks; - -typedef ::cppu::WeakImplHelper1< container::XEnumeration > SpreadSheetDocEnumImpl_BASE; - static uno::Any -getWorkbook( uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< sheet::XSpreadsheetDocument > &xDoc ) +getWorkbook( uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< sheet::XSpreadsheetDocument > &xDoc, const uno::Any& aApplication ) { // FIXME: fine as long as ScVbaWorkbook is stateless ... uno::Reference< frame::XModel > xModel( xDoc, uno::UNO_QUERY ); if( !xModel.is() ) return uno::Any(); - ScVbaWorkbook *pWb = new ScVbaWorkbook( uno::Reference< XHelperInterface >( ScVbaGlobals::getGlobalsImpl( xContext )->getApplication(), uno::UNO_QUERY_THROW ), xContext, xModel ); + ScVbaWorkbook *pWb = new ScVbaWorkbook( uno::Reference< XHelperInterface >( aApplication, uno::UNO_QUERY_THROW ), xContext, xModel ); return uno::Any( uno::Reference< excel::XWorkbook > (pWb) ); } - -// #FIXME clearly this is a candidate for some sort of helper base class as -// this is a copy of SelectedSheetsEnum ( vbawindow.cxx ) - -class SpreadSheetDocEnumImpl : public SpreadSheetDocEnumImpl_BASE -{ - uno::Reference< uno::XComponentContext > m_xContext; - WorkBooks m_books; - WorkBooks::const_iterator m_it; - -public: - SpreadSheetDocEnumImpl( const uno::Reference< uno::XComponentContext >& xContext, const WorkBooks& books ) throw ( uno::RuntimeException ) : m_xContext( xContext ), m_books( books ) - { - m_it = m_books.begin(); - } - SpreadSheetDocEnumImpl( const uno::Reference< uno::XComponentContext >& xContext ) throw ( uno::RuntimeException ) : m_xContext( xContext ) - { - uno::Reference< lang::XMultiComponentFactory > xSMgr( - m_xContext->getServiceManager(), uno::UNO_QUERY_THROW ); - - uno::Reference< frame::XDesktop > xDesktop - (xSMgr->createInstanceWithContext(::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop"), m_xContext), uno::UNO_QUERY_THROW ); - uno::Reference< container::XEnumeration > mxComponents = xDesktop->getComponents()->createEnumeration(); - while( mxComponents->hasMoreElements() ) - { - uno::Reference< sheet::XSpreadsheetDocument > xNext( mxComponents->nextElement(), uno::UNO_QUERY ); - if ( xNext.is() ) - m_books.push_back( xNext ); - } - m_it = m_books.begin(); - } - // XEnumeration - virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) - { - return m_it != m_books.end(); - } - - virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( !hasMoreElements() ) - { - throw container::NoSuchElementException(); - } - return makeAny( *(m_it++) ); - } -}; - class WorkBookEnumImpl : public EnumerationHelperImpl { + uno::Any m_aApplication; public: - WorkBookEnumImpl( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xContext, xEnumeration ){} + WorkBookEnumImpl( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Any& aApplication ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xContext, xEnumeration ), m_aApplication( aApplication ) {} virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) { uno::Reference< sheet::XSpreadsheetDocument > xDoc( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW ); - return getWorkbook( m_xContext, xDoc ); - } - -}; - -// #FIXME clearly this is also a candidate for some sort of helper base class as -// a very similar one is used in vbawindow ( SelectedSheetsEnumAccess ) -// Maybe a template base class that does all of the operations on the hashmap -// and vector only, and the sub-class does everything else -// => ctor, createEnumeration & factory method need be defined ( to be called -// by getByIndex, getByName ) -typedef ::cppu::WeakImplHelper3< container::XEnumerationAccess - , com::sun::star::container::XIndexAccess - , com::sun::star::container::XNameAccess - > WorkBooksAccessImpl_BASE; - -class WorkBooksAccessImpl : public WorkBooksAccessImpl_BASE -{ - uno::Reference< uno::XComponentContext > m_xContext; - WorkBooks m_books; - NameIndexHash namesToIndices; -public: - WorkBooksAccessImpl( const uno::Reference< uno::XComponentContext >& xContext ):m_xContext( xContext ) - { - uno::Reference< container::XEnumeration > xEnum = new SpreadSheetDocEnumImpl( m_xContext ); - sal_Int32 nIndex=0; - while( xEnum->hasMoreElements() ) - { - uno::Reference< sheet::XSpreadsheetDocument > xNext( xEnum->nextElement(), uno::UNO_QUERY ); - if ( xNext.is() ) - { - m_books.push_back( xNext ); - uno::Reference< frame::XModel > xModel( xNext, uno::UNO_QUERY_THROW ); // that the spreadsheetdocument is a xmodel is a given - INetURLObject aURL( xModel->getURL() ); - namesToIndices[ aURL.GetLastName() ] = nIndex++; - } - } - - } - - //XEnumerationAccess - virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) throw (uno::RuntimeException) - { - return new SpreadSheetDocEnumImpl( m_xContext, m_books ); - } - // XIndexAccess - virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException) - { - return m_books.size(); - } - virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw ( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( Index < 0 - || static_cast< WorkBooks::size_type >(Index) >= m_books.size() ) - throw lang::IndexOutOfBoundsException(); - return makeAny( m_books[ Index ] ); // returns xspreadsheetdoc - } - - //XElementAccess - virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) - { - return sheet::XSpreadsheetDocument::static_type(0); - } - - virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) - { - return (m_books.size() > 0); - } - - //XNameAccess - virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - NameIndexHash::const_iterator it = namesToIndices.find( aName ); - if ( it == namesToIndices.end() ) - throw container::NoSuchElementException(); - return makeAny( m_books[ it->second ] ); - - } - - virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (uno::RuntimeException) - { - uno::Sequence< ::rtl::OUString > names( namesToIndices.size() ); - ::rtl::OUString* pString = names.getArray(); - NameIndexHash::const_iterator it = namesToIndices.begin(); - NameIndexHash::const_iterator it_end = namesToIndices.end(); - for ( ; it != it_end; ++it, ++pString ) - *pString = it->first; - return names; - } - - virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (uno::RuntimeException) - { - NameIndexHash::const_iterator it = namesToIndices.find( aName ); - return (it != namesToIndices.end()); + return getWorkbook( m_xContext, xDoc, m_aApplication ); } }; -ScVbaWorkbooks::ScVbaWorkbooks( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< css::uno::XComponentContext >& xContext ) : ScVbaWorkbooks_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new WorkBooksAccessImpl( xContext ) ) ) +ScVbaWorkbooks::ScVbaWorkbooks( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< css::uno::XComponentContext >& xContext ) : ScVbaWorkbooks_BASE( xParent, xContext, VbaDocumentsBase::EXCEL_DOCUMENT ) { } // XEnumerationAccess @@ -254,46 +107,32 @@ ScVbaWorkbooks::createEnumeration() throw (uno::RuntimeException) // the state of this object ( although it should ) would be // safer to create an enumeration based on this objects state // rather than one effectively based of the desktop component - return new WorkBookEnumImpl( mxContext, uno::Reference< container::XEnumeration >( new SpreadSheetDocEnumImpl(mxContext) ) ); + uno::Reference< container::XEnumerationAccess > xEnumerationAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); + return new WorkBookEnumImpl( mxContext, xEnumerationAccess->createEnumeration(), Application() ); } uno::Any ScVbaWorkbooks::createCollectionObject( const css::uno::Any& aSource ) { - uno::Reference< sheet::XSpreadsheetDocument > xDoc( aSource, uno::UNO_QUERY ); - return getWorkbook( mxContext, xDoc ); + uno::Reference< sheet::XSpreadsheetDocument > xDoc( aSource, uno::UNO_QUERY_THROW ); + return getWorkbook( mxContext, xDoc, Application() ); } uno::Any SAL_CALL ScVbaWorkbooks::Add() throw (uno::RuntimeException) { - uno::Reference< lang::XMultiComponentFactory > xSMgr( - mxContext->getServiceManager(), uno::UNO_QUERY_THROW ); - - uno::Reference< frame::XComponentLoader > xLoader( - xSMgr->createInstanceWithContext( - ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop"), - mxContext), uno::UNO_QUERY_THROW ); - uno::Reference< lang::XComponent > xComponent = xLoader->loadComponentFromURL( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("private:factory/scalc") ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("_blank") ), 0, - uno::Sequence< beans::PropertyValue >(0) ); - uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( xComponent, uno::UNO_QUERY_THROW ); + uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( VbaDocumentsBase::Add() , uno::UNO_QUERY_THROW ); if( xSpreadDoc.is() ) - return getWorkbook( mxContext, xSpreadDoc ); + return getWorkbook( mxContext, xSpreadDoc, Application() ); return uno::Any(); } void ScVbaWorkbooks::Close() throw (uno::RuntimeException) { - uno::Reference< lang::XMultiComponentFactory > xSMgr( - mxContext->getServiceManager(), uno::UNO_QUERY_THROW ); - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - rtl::OUString url = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CloseDoc")); - dispatchRequests(xModel,url); + VbaDocumentsBase::Close(); } bool @@ -337,24 +176,15 @@ uno::Any ScVbaWorkbooks::Open( const rtl::OUString& rFileName, const uno::Any& /*UpdateLinks*/, const uno::Any& ReadOnly, const uno::Any& Format, const uno::Any& /*Password*/, const uno::Any& /*WriteResPassword*/, const uno::Any& /*IgnoreReadOnlyRecommended*/, const uno::Any& /*Origin*/, const uno::Any& Delimiter, const uno::Any& /*Editable*/, const uno::Any& /*Notify*/, const uno::Any& /*Converter*/, const uno::Any& /*AddToMru*/ ) throw (uno::RuntimeException) { // we need to detect if this is a URL, if not then assume its a file path - rtl::OUString aURL; - INetURLObject aObj; + rtl::OUString aURL; + INetURLObject aObj; aObj.SetURL( rFileName ); bool bIsURL = aObj.GetProtocol() != INET_PROT_NOT_VALID; if ( bIsURL ) aURL = rFileName; else osl::FileBase::getFileURLFromSystemPath( rFileName, aURL ); - uno::Reference< lang::XMultiComponentFactory > xSMgr( - mxContext->getServiceManager(), uno::UNO_QUERY_THROW ); - uno::Reference< frame::XDesktop > xDesktop - (xSMgr->createInstanceWithContext(::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop") , mxContext), - uno::UNO_QUERY_THROW ); - uno::Reference< frame::XComponentLoader > xLoader( - xSMgr->createInstanceWithContext( - ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop"), - mxContext), - uno::UNO_QUERY_THROW ); + uno::Sequence< beans::PropertyValue > sProps(0); sal_Int32 nIndex = 0; @@ -421,24 +251,8 @@ ScVbaWorkbooks::Open( const rtl::OUString& rFileName, const uno::Any& /*UpdateLi else if ( !isSpreadSheetFile( sType ) ) throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Bad Format")), uno::Reference< uno::XInterface >() ); - if ( ReadOnly.hasValue() ) - { - sal_Bool bIsReadOnly = sal_False; ReadOnly >>= bIsReadOnly; - if ( bIsReadOnly ) - { - static const rtl::OUString sReadOnly( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ); - sProps.realloc( sProps.getLength() + 1 ); - sProps[ nIndex ].Name = sReadOnly; - sProps[ nIndex++ ].Value = uno::makeAny( (sal_Bool)sal_True ); - } - } - - uno::Reference< lang::XComponent > xComponent = xLoader->loadComponentFromURL( aURL, - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("_default") ), - frame::FrameSearchFlag::CREATE, - sProps); - uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( xComponent, uno::UNO_QUERY_THROW ); - uno::Any aRet = getWorkbook( mxContext, xSpreadDoc ); + uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( VbaDocumentsBase::Open( rFileName, ReadOnly, sProps ), uno::UNO_QUERY_THROW ); + uno::Any aRet = getWorkbook( mxContext, xSpreadDoc, Application() ); uno::Reference< excel::XWorkbook > xWBook( aRet, uno::UNO_QUERY ); if ( xWBook.is() ) xWBook->Activate(); diff --git a/sc/source/ui/vba/vbaworkbooks.hxx b/sc/source/ui/vba/vbaworkbooks.hxx index cf766b04e688..9bca55f77999 100644 --- a/sc/source/ui/vba/vbaworkbooks.hxx +++ b/sc/source/ui/vba/vbaworkbooks.hxx @@ -31,21 +31,20 @@ #define SC_VBA_WORKBOOKS_HXX -#include "vbacollectionimpl.hxx" -#include <ooo/vba/XGlobals.hpp> +#include <vbahelper/vbacollectionimpl.hxx> #include <ooo/vba/excel/XWorkbooks.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> -#include "vbahelper.hxx" +#include <vbahelper/vbadocumentsbase.hxx> +#include "excelvbahelper.hxx" class ScModelObj; -typedef CollTestImplHelper< ov::excel::XWorkbooks > ScVbaWorkbooks_BASE; +typedef cppu::ImplInheritanceHelper1< VbaDocumentsBase, ov::excel::XWorkbooks > ScVbaWorkbooks_BASE; class ScVbaWorkbooks : public ScVbaWorkbooks_BASE { private: - css::uno::Reference< ov::XGlobals > getGlobals() throw (css::uno::RuntimeException); rtl::OUString getFileFilterType( const rtl::OUString& rString ); bool isTextFile( const rtl::OUString& rString ); bool isSpreadSheetFile( const rtl::OUString& rString ); diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx index cd75ebd9af40..c382ffeb8afe 100644 --- a/sc/source/ui/vba/vbaworksheet.cxx +++ b/sc/source/ui/vba/vbaworksheet.cxx @@ -27,11 +27,12 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#include "helperdecl.hxx" +#include <vbahelper/helperdecl.hxx> #include <cppuhelper/queryinterface.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XIntrospectionAccess.hpp> +#include <com/sun/star/beans/XIntrospection.hpp> #include <com/sun/star/container/XNamed.hpp> #include <com/sun/star/util/XProtectable.hpp> #include <com/sun/star/table/XCellRange.hpp> @@ -58,6 +59,8 @@ #include <com/sun/star/drawing/XControlShape.hpp> #include <com/sun/star/form/FormComponentType.hpp> #include <com/sun/star/form/XFormsSupplier.hpp> +#include <ooo/vba/excel/XlEnableSelection.hpp> +#include <ooo/vba/XControlProvider.hpp> #include <comphelper/processfactory.hxx> @@ -82,10 +85,9 @@ #include "vbaworksheet.hxx" #include "vbachartobjects.hxx" #include "vbapivottables.hxx" -#include "vbacombobox.hxx" #include "vbaoleobject.hxx" #include "vbaoleobjects.hxx" -#include "vbashapes.hxx" +#include <vbahelper/vbashapes.hxx> #include "vbapagesetup.hxx" #include "vbapagebreaks.hxx" @@ -94,7 +96,7 @@ #define DOESNOTEXIST -1 using namespace com::sun::star; using namespace ooo::vba; -static bool +bool nameExists( uno::Reference <sheet::XSpreadsheetDocument>& xSpreadDoc, ::rtl::OUString & name, SCTAB& nTab ) throw ( lang::IllegalArgumentException ) { if (!xSpreadDoc.is()) @@ -257,6 +259,83 @@ ScVbaWorksheet::getIndex() throw (uno::RuntimeException) return getSheetID() + 1; } +sal_Int32 +ScVbaWorksheet::getEnableSelection() throw (uno::RuntimeException) +{ + uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( getModel(), uno::UNO_QUERY_THROW ); + SCTAB nTab = 0; + rtl::OUString aSheetName = getName(); + bool bSheetExists = nameExists (xSpreadDoc, aSheetName, nTab); + if ( bSheetExists ) + { + uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW ); + ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument(); + ScTableProtection* pProtect = pDoc->GetTabProtection(nTab); + sal_Bool bLockedCells = sal_False; + sal_Bool bUnlockedCells = sal_False; + if( pProtect ) + { + bLockedCells = pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS); + bUnlockedCells = pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS); + } + if( bLockedCells ) + return excel::XlEnableSelection::xlNoRestrictions; + if( bUnlockedCells ) + return excel::XlEnableSelection::xlUnlockedCells; + return excel::XlEnableSelection::xlNoSelection; + } + else + throw uno::RuntimeException(::rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "Sheet Name does not exist. ") ), + uno::Reference< XInterface >() ); + return excel::XlEnableSelection::xlNoSelection; +} + + +void +ScVbaWorksheet::setEnableSelection( sal_Int32 nSelection ) throw (uno::RuntimeException) +{ + if( (nSelection != excel::XlEnableSelection::xlNoRestrictions) && + (nSelection != excel::XlEnableSelection::xlUnlockedCells) && + (nSelection != excel::XlEnableSelection::xlNoSelection) ) + { + DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() ); + } + + uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( getModel(), uno::UNO_QUERY_THROW ); + SCTAB nTab = 0; + rtl::OUString aSheetName = getName(); + bool bSheetExists = nameExists (xSpreadDoc, aSheetName, nTab); + if ( bSheetExists ) + { + uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW ); + ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument(); + ScTableProtection* pProtect = pDoc->GetTabProtection(nTab); + // default is xlNoSelection + sal_Bool bLockedCells = sal_False; + sal_Bool bUnlockedCells = sal_False; + if( nSelection == excel::XlEnableSelection::xlNoRestrictions ) + { + bLockedCells = sal_True; + bUnlockedCells = sal_True; + } + else if( nSelection == excel::XlEnableSelection::xlUnlockedCells ) + { + bUnlockedCells = sal_True; + } + if( pProtect ) + { + pProtect->setOption( ScTableProtection::SELECT_LOCKED_CELLS, bLockedCells ); + pProtect->setOption( ScTableProtection::SELECT_UNLOCKED_CELLS, bUnlockedCells ); + } + } + else + throw uno::RuntimeException(::rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "Sheet Name does not exist. ") ), + uno::Reference< XInterface >() ); + +} + uno::Reference< excel::XRange > ScVbaWorksheet::getUsedRange() throw (uno::RuntimeException) { @@ -292,6 +371,16 @@ ScVbaWorksheet::HPageBreaks( const uno::Any& aIndex ) throw (uno::RuntimeExcepti return uno::makeAny( xHPageBreaks ); } +uno::Any +ScVbaWorksheet::VPageBreaks( const uno::Any& aIndex ) throw ( uno::RuntimeException ) +{ + uno::Reference< sheet::XSheetPageBreak > xSheetPageBreak( getSheet(), uno::UNO_QUERY_THROW ); + uno::Reference< excel::XVPageBreaks > xVPageBreaks( new ScVbaVPageBreaks( this, mxContext, xSheetPageBreak ) ); + if( aIndex.hasValue() ) + return xVPageBreaks->Item( aIndex, uno::Any()); + return uno::makeAny( xVPageBreaks ); +} + sal_Int32 ScVbaWorksheet::getStandardWidth() throw (uno::RuntimeException) { @@ -353,11 +442,11 @@ ScVbaWorksheet::Move( const uno::Any& Before, const uno::Any& After ) throw (uno uno::Reference<excel::XRange> xRange = new ScVbaRange( this, mxContext, xRange1); if (xRange.is()) xRange->Select(); - implnCopy(); + excel::implnCopy(mxModel); uno::Reference<frame::XModel> xModel = openNewDoc(aCurrSheetName); if (xModel.is()) { - implnPaste(); + excel::implnPaste(xModel); Delete(); } return ; @@ -391,11 +480,11 @@ ScVbaWorksheet::Copy( const uno::Any& Before, const uno::Any& After ) throw (uno uno::Reference<excel::XRange> xRange = new ScVbaRange( this, mxContext, xRange1); if (xRange.is()) xRange->Select(); - implnCopy(); + excel::implnCopy(mxModel); uno::Reference<frame::XModel> xModel = openNewDoc(aCurrSheetName); if (xModel.is()) { - implnPaste(); + excel::implnPaste(xModel); } return; } @@ -424,7 +513,7 @@ ScVbaWorksheet::Paste( const uno::Any& Destination, const uno::Any& /*Link*/ ) t uno::Reference<excel::XRange> xRange( Destination, uno::UNO_QUERY ); if ( xRange.is() ) xRange->Select(); - implnPaste(); + excel::implnPaste( mxModel ); } void @@ -624,7 +713,7 @@ ScVbaWorksheet::Shapes( const uno::Any& aIndex ) throw (uno::RuntimeException) uno::Reference< drawing::XShapes > xShapes( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW ); uno::Reference< container::XIndexAccess > xIndexAccess( xShapes, uno::UNO_QUERY_THROW ); - uno::Reference< msforms::XShapes> xVbaShapes( new ScVbaShapes( this, mxContext, xIndexAccess ) ); + uno::Reference< msforms::XShapes> xVbaShapes( new ScVbaShapes( this, mxContext, xIndexAccess, getModel() ) ); if ( aIndex.hasValue() ) return xVbaShapes->Item( aIndex, uno::Any() ); return uno::makeAny( xVbaShapes ); @@ -635,7 +724,7 @@ ScVbaWorksheet::ShowDataForm( ) throw (uno::RuntimeException) { #ifdef VBA_OOBUILD_HACK uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW ); - ScTabViewShell* pTabViewShell = getBestViewShell( xModel ); + ScTabViewShell* pTabViewShell = excel::getBestViewShell( xModel ); ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 @@ -676,16 +765,18 @@ ScVbaWorksheet::invoke( const ::rtl::OUString& aFunctionName, const uno::Sequenc } void SAL_CALL -ScVbaWorksheet::setValue( const ::rtl::OUString& /*aPropertyName*/, const uno::Any& /*aValue*/ ) throw (beans::UnknownPropertyException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException) +ScVbaWorksheet::setValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException) { - throw uno::RuntimeException(); // unsupported operation + setDefaultPropByIntrospection( uno::makeAny( getValue( aPropertyName ) ), aValue ); } uno::Any SAL_CALL ScVbaWorksheet::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::UnknownPropertyException, uno::RuntimeException) { uno::Reference< drawing::XControlShape > xControlShape( getControlShape( aPropertyName ), uno::UNO_QUERY_THROW ); - ScVbaControlFactory controlFactory( mxContext, xControlShape, getModel() ); - uno::Reference< msforms::XControl > xControl( controlFactory.createControl( getModel() ) ); + + uno::Reference<lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_QUERY_THROW ); + uno::Reference< XControlProvider > xControlProvider( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.ControlProvider" ) ), mxContext ), uno::UNO_QUERY_THROW ); + uno::Reference< msforms::XControl > xControl( xControlProvider->createControl( xControlShape, getModel() ) ); return uno::makeAny( xControl ); } @@ -869,10 +960,9 @@ ScVbaWorksheet::PrintOut( const uno::Any& From, const uno::Any& To, const uno::A bSelection = sal_True; uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW ); - PrintOutHelper( From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, xModel, bSelection ); + PrintOutHelper( excel::getBestViewShell( xModel ), From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, bSelection ); } - namespace worksheet { namespace sdecl = comphelper::service_decl; diff --git a/sc/source/ui/vba/vbaworksheet.hxx b/sc/source/ui/vba/vbaworksheet.hxx index 8fdee639c7c1..da88e1c4b06f 100644 --- a/sc/source/ui/vba/vbaworksheet.hxx +++ b/sc/source/ui/vba/vbaworksheet.hxx @@ -44,9 +44,11 @@ #include <ooo/vba/excel/XOutline.hpp> #include <ooo/vba/excel/XPageSetup.hpp> #include <ooo/vba/excel/XHPageBreaks.hpp> +#include <ooo/vba/excel/XVPageBreaks.hpp> #include <ooo/vba/excel/XChartObjects.hpp> -#include "vbahelperinterface.hxx" +#include <vbahelper/vbahelperinterface.hxx> +#include "address.hxx" typedef InheritedHelperInterfaceImpl1< ov::excel::XWorksheet > WorksheetImpl_BASE; @@ -93,9 +95,12 @@ public: virtual css::uno::Reference< ov::excel::XOutline > SAL_CALL Outline( ) throw (css::uno::RuntimeException); virtual css::uno::Reference< ov::excel::XPageSetup > SAL_CALL PageSetup( ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL HPageBreaks( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL VPageBreaks( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); virtual css::uno::Reference< ov::excel::XWorksheet > SAL_CALL getNext() throw (css::uno::RuntimeException); virtual css::uno::Reference< ov::excel::XWorksheet > SAL_CALL getPrevious() throw (css::uno::RuntimeException); virtual sal_Int16 SAL_CALL getIndex() throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getEnableSelection() throw (css::uno::RuntimeException); + virtual void SAL_CALL setEnableSelection( sal_Int32 nSelection ) throw (css::uno::RuntimeException); // Methods virtual void SAL_CALL Activate() throw (css::uno::RuntimeException); diff --git a/sc/source/ui/vba/vbaworksheets.cxx b/sc/source/ui/vba/vbaworksheets.cxx index 546eda854056..4f0607e430f6 100644 --- a/sc/source/ui/vba/vbaworksheets.cxx +++ b/sc/source/ui/vba/vbaworksheets.cxx @@ -209,16 +209,29 @@ ScVbaWorksheets::Add( const uno::Any& Before, const uno::Any& After, Count >>= nNewSheets; Type >>= nType; SCTAB nCount = 0; - Before >>= aStringSheet; - if (!aStringSheet.getLength()) + + uno::Reference< excel::XWorksheet > xBeforeAfterSheet; + + if ( Before.hasValue() ) { - After >>= aStringSheet; + if ( Before >>= xBeforeAfterSheet ) + aStringSheet = xBeforeAfterSheet->getName(); + else + Before >>= aStringSheet; + } + + if (!aStringSheet.getLength() && After.hasValue() ) + { + if ( After >>= xBeforeAfterSheet ) + aStringSheet = xBeforeAfterSheet->getName(); + else + After >>= aStringSheet; bBefore = sal_False; } if (!aStringSheet.getLength()) { - aStringSheet = ScVbaGlobals::getGlobalsImpl( - mxContext )->getApplication()->getActiveWorkbook()->getActiveSheet()->getName(); + uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW ); + aStringSheet = xApplication->getActiveWorkbook()->getActiveSheet()->getName(); bBefore = sal_True; } nCount = static_cast< SCTAB >( m_xIndexAccess->getCount() ); @@ -252,7 +265,9 @@ ScVbaWorksheets::Add( const uno::Any& Before, const uno::Any& After, m_xSheets->insertNewByName(aStringName, nSheetIndex + i); result = getItemByStringIndex( aStringName ); } - + uno::Reference< excel::XWorksheet > xNewSheet( result, uno::UNO_QUERY ); + if ( xNewSheet.is() ) + xNewSheet->Activate(); return result; } @@ -295,7 +310,7 @@ ScVbaWorksheets::PrintOut( const uno::Any& From, const uno::Any& To, const uno:: if ( isSelectedSheets() ) bSelection = sal_True; - PrintOutHelper( From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, mxModel, bSelection ); + PrintOutHelper( excel::getBestViewShell( mxModel ), From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, bSelection ); } uno::Any SAL_CALL @@ -336,7 +351,7 @@ ScVbaWorksheets::setVisible( const uno::Any& _visible ) throw (uno::RuntimeExcep void SAL_CALL ScVbaWorksheets::Select( const uno::Any& Replace ) throw (uno::RuntimeException) { - ScTabViewShell* pViewShell = getBestViewShell( mxModel ); + ScTabViewShell* pViewShell = excel::getBestViewShell( mxModel ); if ( !pViewShell ) throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Cannot obtain view shell" ) ), uno::Reference< uno::XInterface >() ); diff --git a/sc/source/ui/vba/vbaworksheets.hxx b/sc/source/ui/vba/vbaworksheets.hxx index 0cb2a4f33971..e816e8ecf212 100644 --- a/sc/source/ui/vba/vbaworksheets.hxx +++ b/sc/source/ui/vba/vbaworksheets.hxx @@ -36,9 +36,8 @@ #include <com/sun/star/sheet/XSpreadsheets.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/uno/XComponentContext.hpp> -#include <ooo/vba/XGlobals.hpp> -#include "vbacollectionimpl.hxx" +#include <vbahelper/vbacollectionimpl.hxx> class ScModelObj; diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index c3848b76b92b..c3c096a6a666 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -597,68 +597,105 @@ void ScViewData::SetViewShell( ScTabViewShell* pViewSh ) pView = NULL; } } +void ScViewData::CreateTabData( std::vector< SCTAB >& rvTabs ) +{ + std::vector< SCTAB >::iterator it_end = rvTabs.end(); + for ( std::vector< SCTAB >::iterator it = rvTabs.begin(); it != it_end; ++it ) + if ( !pTabData[*it] ) + CreateTabData( *it ); +} -void ScViewData::SetZoomType( SvxZoomType eNew, BOOL bAll ) +void ScViewData::SetZoomType( SvxZoomType eNew, std::vector< SCTAB >& tabs ) { - if ( !bAll ) - CreateSelectedTabData(); // if zoom is set for a table, it must be stored + BOOL bAll = ( tabs.size() == 0 ); - for ( SCTAB i = 0; i <= MAXTAB; i++ ) - if ( pTabData[i] && ( bAll || aMarkData.GetTableSelect(i) ) ) + if ( !bAll ) // create associated table data + CreateTabData( tabs ); + + std::vector< SCTAB >::iterator it_end = tabs.end(); + std::vector< SCTAB >::iterator it = tabs.begin(); + for ( SCTAB i = ( bAll ? 0 : *it ); ( bAll ? i <= MAXTAB : it != it_end ); ++i , ++it ) + { + if ( pTabData[i] ) pTabData[i]->eZoomType = eNew; + } if ( bAll ) eDefZoomType = eNew; } -void ScViewData::SetZoom( const Fraction& rNewX, const Fraction& rNewY, BOOL bAll ) +void ScViewData::SetZoomType( SvxZoomType eNew, BOOL bAll ) { - if ( !bAll ) - CreateSelectedTabData(); // if zoom is set for a table, it must be stored + std::vector< SCTAB > vTabs; // Empty for all tabs + if ( !bAll ) // get selected tabs + { + SCTAB nTabCount = pDoc->GetTableCount(); + for (SCTAB i=0; i<nTabCount; i++) + { + if ( aMarkData.GetTableSelect(i) ) + vTabs.push_back( i ); + } + } + SetZoomType( eNew, vTabs ); +} +void ScViewData::SetZoom( const Fraction& rNewX, const Fraction& rNewY, std::vector< SCTAB >& tabs ) +{ + BOOL bAll = ( tabs.size() == 0 ); + if ( !bAll ) // create associated table data + CreateTabData( tabs ); Fraction aFrac20( 1,5 ); Fraction aFrac400( 4,1 ); Fraction aValidX = rNewX; - if (aValidX<aFrac20) aValidX = aFrac20; - if (aValidX>aFrac400) aValidX = aFrac400; + if (aValidX<aFrac20) + aValidX = aFrac20; + if (aValidX>aFrac400) + aValidX = aFrac400; Fraction aValidY = rNewY; - if (aValidY<aFrac20) aValidY = aFrac20; - if (aValidY>aFrac400) aValidY = aFrac400; + if (aValidY<aFrac20) + aValidY = aFrac20; + if (aValidY>aFrac400) + aValidY = aFrac400; - if ( bPagebreak ) + std::vector< SCTAB >::iterator it_end = tabs.end(); + std::vector< SCTAB >::iterator it = tabs.begin(); + + for ( SCTAB i = ( bAll ? 0 : *it ); ( bAll ? i <= MAXTAB : it != it_end ); ++i , ++it ) { - for ( SCTAB i = 0; i <= MAXTAB; i++ ) - if ( pTabData[i] && ( bAll || aMarkData.GetTableSelect(i) ) ) + if ( pTabData[i] ) + { + if ( bPagebreak ) { pTabData[i]->aPageZoomX = aValidX; pTabData[i]->aPageZoomY = aValidY; } - if ( bAll ) - { - aDefPageZoomX = aValidX; - aDefPageZoomY = aValidY; - } - } - else - { - for ( SCTAB i = 0; i <= MAXTAB; i++ ) - if ( pTabData[i] && ( bAll || aMarkData.GetTableSelect(i) ) ) + else { pTabData[i]->aZoomX = aValidX; pTabData[i]->aZoomY = aValidY; } - if ( bAll ) - { - aDefZoomX = aValidX; - aDefZoomY = aValidY; } } - RefreshZoom(); } +void ScViewData::SetZoom( const Fraction& rNewX, const Fraction& rNewY, BOOL bAll ) +{ + std::vector< SCTAB > vTabs; + if ( !bAll ) // get selected tabs + { + SCTAB nTabCount = pDoc->GetTableCount(); + for (SCTAB i=0; i<nTabCount; i++) + { + if ( aMarkData.GetTableSelect(i) ) + vTabs.push_back( i ); + } + } + SetZoom( rNewX, rNewY, vTabs ); +} + void ScViewData::RefreshZoom() { // recalculate zoom-dependent values (only for current sheet) |