Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef SC_EXCEL_VBA_HELPER_HXX
29 : : #define SC_EXCEL_VBA_HELPER_HXX
30 : :
31 : : #include <vbahelper/vbahelper.hxx>
32 : : #include "docsh.hxx"
33 : : #include <com/sun/star/sheet/XDatabaseRange.hpp>
34 : : #include <com/sun/star/sheet/XUnnamedDatabaseRanges.hpp>
35 : : #include <com/sun/star/table/XCellRange.hpp>
36 : : #include <com/sun/star/sheet/XSheetCellRangeContainer.hpp>
37 : : #include <com/sun/star/sheet/XSpreadsheet.hpp>
38 : : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
39 : : #include <com/sun/star/lang/XUnoTunnel.hpp>
40 : : #include <ooo/vba/XHelperInterface.hpp>
41 : : #include <formula/grammar.hxx>
42 : :
43 : : class ScCellRangesBase;
44 : :
45 : : namespace ooo {
46 : : namespace vba {
47 : : namespace excel {
48 : :
49 : : // ============================================================================
50 : :
51 : : // nTabs empty means apply zoom to all sheets
52 : : void implSetZoom( const css::uno::Reference< css::frame::XModel >& xModel, sal_Int16 nZoom, std::vector< SCTAB >& nTabs );
53 : : void implnCopy( const css::uno::Reference< css::frame::XModel>& xModel );
54 : : void implnPaste ( const css::uno::Reference< css::frame::XModel>& xModel );
55 : : void implnCut( const css::uno::Reference< css::frame::XModel>& xModel );
56 : : void implnPasteSpecial( const css::uno::Reference< css::frame::XModel>& xModel, sal_uInt16 nFlags,sal_uInt16 nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose);
57 : : bool implnCopyRanges( const css::uno::Reference< css::frame::XModel>& xModel, ScRangeList& rRange );
58 : : bool implnCopyRange( const css::uno::Reference< css::frame::XModel>& xModel, const ScRange& rRange );
59 : : ScTabViewShell* getBestViewShell( const css::uno::Reference< css::frame::XModel>& xModel ) ;
60 : : ScDocShell* getDocShell( const css::uno::Reference< css::frame::XModel>& xModel ) ;
61 : : ScTabViewShell* getCurrentBestViewShell( const css::uno::Reference< css::uno::XComponentContext >& xContext );
62 : :
63 : : sal_Bool IsR1C1ReferFormat( ScDocument* pDoc, const ::rtl::OUString& sRangeStr );
64 : : formula::FormulaGrammar::Grammar GetFormulaGrammar( ScDocument* pDoc, const ScAddress& sAddress, const css::uno::Any& aFormula );
65 : : void CompileExcelFormulaToODF( ScDocument* pDoc, const String& rOldFormula, String& rNewFormula );
66 : : void CompileODFFormulaToExcel( ScDocument* pDoc, const String& rOldFormula, String& rNewFormula, const formula::FormulaGrammar::Grammar eGrammar );
67 : : css::uno::Reference< css::sheet::XUnnamedDatabaseRanges > GetUnnamedDataBaseRanges( ScDocShell* pShell ) throw ( css::uno::RuntimeException );
68 : :
69 : : css::uno::Reference< css::sheet::XDatabaseRange > GetAutoFiltRange( ScDocShell* pShell, sal_Int16 nSheet ) throw ( css::uno::RuntimeException );
70 : : css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::sheet::XSpreadsheet >& xSheet ) throw ( css::uno::RuntimeException );
71 : : css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges ) throw ( css::uno::RuntimeException );
72 : : css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::table::XCellRange >& xRange ) throw ( css::uno::RuntimeException );
73 : : css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::table::XCell >& xCell ) throw ( css::uno::RuntimeException );
74 : : css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::frame::XModel >& xModel, SCTAB nTab ) throw ( css::uno::RuntimeException );
75 : :
76 : : ScDocShell* GetDocShellFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException );
77 : : ScDocShell* GetDocShellFromRanges( const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges ) throw ( css::uno::RuntimeException );
78 : : ScDocument* GetDocumentFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException );
79 : : css::uno::Reference< css::frame::XModel > GetModelFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException );
80 : : void setUpDocumentModules( const css::uno::Reference< css::sheet::XSpreadsheetDocument >& xDoc );
81 : :
82 : : // ============================================================================
83 : :
84 : : class ScVbaCellRangeAccess
85 : : {
86 : : public:
87 : : static SfxItemSet* GetDataSet( ScCellRangesBase* pRangeObj );
88 : : };
89 : :
90 : : // Extracts a implementation object ( via XUnoTunnel ) from an uno object
91 : : // by default will throw if unsuccessful.
92 : : template < typename ImplObject >
93 : 0 : ImplObject* getImplFromDocModuleWrapper( const css::uno::Reference< css::uno::XInterface >& rxWrapperIf, bool bThrow = true ) throw (css::uno::RuntimeException)
94 : : {
95 : 0 : ImplObject* pObj = NULL;
96 [ # # ]: 0 : css::uno::Reference< css::lang::XUnoTunnel > xTunnel( rxWrapperIf, css::uno::UNO_QUERY );
97 [ # # ]: 0 : if ( xTunnel.is() )
98 [ # # ][ # # ]: 0 : pObj = reinterpret_cast<ImplObject*>( xTunnel->getSomething(ImplObject::getUnoTunnelId()));
[ # # ]
99 [ # # ][ # # ]: 0 : if ( bThrow && !pObj )
100 [ # # ][ # # ]: 0 : throw css::uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Internal error, can't exctract implementation object" ) ), rxWrapperIf );
101 : 0 : return pObj;
102 : : }
103 : : // ============================================================================
104 : :
105 : : } // namespace excel
106 : : } // namespace vba
107 : : } // namespace ooo
108 : :
109 : : #endif
110 : :
111 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|