Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef SC_EXCEL_VBA_HELPER_HXX
20 : #define SC_EXCEL_VBA_HELPER_HXX
21 :
22 : #include <vbahelper/vbahelper.hxx>
23 : #include "docsh.hxx"
24 : #include <com/sun/star/sheet/XDatabaseRange.hpp>
25 : #include <com/sun/star/sheet/XUnnamedDatabaseRanges.hpp>
26 : #include <com/sun/star/table/XCellRange.hpp>
27 : #include <com/sun/star/sheet/XSheetCellRangeContainer.hpp>
28 : #include <com/sun/star/sheet/XSpreadsheet.hpp>
29 : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
30 : #include <com/sun/star/lang/XUnoTunnel.hpp>
31 : #include <ooo/vba/XHelperInterface.hpp>
32 :
33 : class ScCellRangesBase;
34 :
35 : namespace ooo {
36 : namespace vba {
37 : namespace excel {
38 :
39 : // nTabs empty means apply zoom to all sheets
40 : void implSetZoom( const css::uno::Reference< css::frame::XModel >& xModel, sal_Int16 nZoom, std::vector< SCTAB >& nTabs );
41 : void implnCopy( const css::uno::Reference< css::frame::XModel>& xModel );
42 : void implnPaste ( const css::uno::Reference< css::frame::XModel>& xModel );
43 : void implnCut( const css::uno::Reference< css::frame::XModel>& xModel );
44 : void implnPasteSpecial( const css::uno::Reference< css::frame::XModel>& xModel, sal_uInt16 nFlags, sal_uInt16 nFunction, bool bSkipEmpty, bool bTranspose);
45 : ScTabViewShell* getBestViewShell( const css::uno::Reference< css::frame::XModel>& xModel ) ;
46 : ScDocShell* getDocShell( const css::uno::Reference< css::frame::XModel>& xModel ) ;
47 : ScTabViewShell* getCurrentBestViewShell( const css::uno::Reference< css::uno::XComponentContext >& xContext );
48 : SfxViewFrame* getViewFrame( const css::uno::Reference< css::frame::XModel >& xModel );
49 :
50 : css::uno::Reference< css::sheet::XUnnamedDatabaseRanges > GetUnnamedDataBaseRanges( ScDocShell* pShell ) throw ( css::uno::RuntimeException );
51 :
52 : css::uno::Reference< css::sheet::XDatabaseRange > GetAutoFiltRange( ScDocShell* pShell, sal_Int16 nSheet ) throw ( css::uno::RuntimeException );
53 : css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::sheet::XSpreadsheet >& xSheet ) throw ( css::uno::RuntimeException );
54 : css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges ) throw ( css::uno::RuntimeException );
55 : css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::table::XCellRange >& xRange ) throw ( css::uno::RuntimeException );
56 : css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::table::XCell >& xCell ) throw ( css::uno::RuntimeException );
57 : css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::frame::XModel >& xModel, SCTAB nTab ) throw ( css::uno::RuntimeException );
58 :
59 : ScDocShell* GetDocShellFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException );
60 : void setUpDocumentModules( const css::uno::Reference< css::sheet::XSpreadsheetDocument >& xDoc );
61 :
62 : class ScVbaCellRangeAccess
63 : {
64 : public:
65 : static SfxItemSet* GetDataSet( ScCellRangesBase* pRangeObj );
66 : };
67 :
68 : // Extracts a implementation object ( via XUnoTunnel ) from an uno object
69 : // by default will throw if unsuccessful.
70 : template < typename ImplObject >
71 0 : ImplObject* getImplFromDocModuleWrapper( const css::uno::Reference< css::uno::XInterface >& rxWrapperIf, bool bThrow = true ) throw (css::uno::RuntimeException)
72 : {
73 0 : ImplObject* pObj = NULL;
74 0 : css::uno::Reference< css::lang::XUnoTunnel > xTunnel( rxWrapperIf, css::uno::UNO_QUERY );
75 0 : if ( xTunnel.is() )
76 0 : pObj = reinterpret_cast<ImplObject*>( xTunnel->getSomething(ImplObject::getUnoTunnelId()));
77 0 : if ( bThrow && !pObj )
78 0 : throw css::uno::RuntimeException("Internal error, can't exctract implementation object", rxWrapperIf );
79 0 : return pObj;
80 : }
81 :
82 :
83 : } // namespace excel
84 : } // namespace vba
85 : } // namespace ooo
86 :
87 : #endif
88 :
89 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|