LibreOffice Module sc (master)  1
excelvbahelper.hxx
Go to the documentation of this file.
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 INCLUDED_SC_SOURCE_UI_VBA_EXCELVBAHELPER_HXX
20 #define INCLUDED_SC_SOURCE_UI_VBA_EXCELVBAHELPER_HXX
21 
22 #include <com/sun/star/lang/XUnoTunnel.hpp>
23 #include <vector>
24 #include <global.hxx>
25 
26 namespace com::sun::star::frame { class XModel; }
27 namespace com::sun::star::uno { class XComponentContext; }
28 
29 namespace com::sun::star::sheet { class XDatabaseRange; }
30 namespace com::sun::star::sheet { class XUnnamedDatabaseRanges; }
31 namespace com::sun::star::table { class XCell; }
32 namespace com::sun::star::table { class XCellRange; }
33 namespace com::sun::star::sheet { class XSheetCellRangeContainer; }
34 namespace com::sun::star::sheet { class XSpreadsheet; }
35 namespace com::sun::star::sheet { class XSpreadsheetDocument; }
36 namespace ooo::vba { class XHelperInterface; }
37 
38 class ScCellRangesBase;
39 class ScTabViewShell;
40 class SfxViewFrame;
41 
42 namespace ooo::vba::excel {
43 
44 // nTabs empty means apply zoom to all sheets
45 void implSetZoom( const css::uno::Reference< css::frame::XModel >& xModel, sal_Int16 nZoom, std::vector< SCTAB >& nTabs );
46 void implnCopy( const css::uno::Reference< css::frame::XModel>& xModel );
47 void implnPaste ( const css::uno::Reference< css::frame::XModel>& xModel );
48 void implnCut( const css::uno::Reference< css::frame::XModel>& xModel );
49 void implnPasteSpecial( const css::uno::Reference< css::frame::XModel>& xModel, InsertDeleteFlags nFlags, ScPasteFunc nFunction, bool bSkipEmpty, bool bTranspose);
50 ScTabViewShell* getBestViewShell( const css::uno::Reference< css::frame::XModel>& xModel ) ;
51 ScDocShell* getDocShell( const css::uno::Reference< css::frame::XModel>& xModel ) ;
52 ScTabViewShell* getCurrentBestViewShell( const css::uno::Reference< css::uno::XComponentContext >& xContext );
53 SfxViewFrame* getViewFrame( const css::uno::Reference< css::frame::XModel >& xModel );
54 
56 css::uno::Reference< css::sheet::XUnnamedDatabaseRanges > GetUnnamedDataBaseRanges( const ScDocShell* pShell );
57 
59 css::uno::Reference< css::sheet::XDatabaseRange > GetAutoFiltRange( const ScDocShell* pShell, sal_Int16 nSheet );
61 css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::sheet::XSpreadsheet >& xSheet );
63 css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges );
65 css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::table::XCellRange >& xRange );
67 css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::table::XCell >& xCell );
69 css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::frame::XModel >& xModel, SCTAB nTab );
70 
72 ScDocShell* GetDocShellFromRange( const css::uno::Reference< css::uno::XInterface >& xRange );
73 void setUpDocumentModules( const css::uno::Reference< css::sheet::XSpreadsheetDocument >& xDoc );
74 
76 {
77 public:
78  static SfxItemSet* GetDataSet( ScCellRangesBase* pRangeObj );
79 };
80 
81 // Extracts an implementation object (via XUnoTunnel) from a UNO object.
82 // Will throw if unsuccessful.
84 template < typename ImplObject >
85  ImplObject* getImplFromDocModuleWrapper( const css::uno::Reference< css::uno::XInterface >& rxWrapperIf )
86  {
87  ImplObject* pObj = nullptr;
88  css::uno::Reference< css::lang::XUnoTunnel > xTunnel( rxWrapperIf, css::uno::UNO_QUERY );
89  if ( xTunnel.is() )
90  pObj = reinterpret_cast<ImplObject*>( xTunnel->getSomething(ImplObject::getUnoTunnelId()));
91  if ( !pObj )
92  throw css::uno::RuntimeException("Internal error, can't extract implementation object", rxWrapperIf );
93  return pObj;
94  }
95 
96 } // namespace ooo::vba::excel
97 
98 #endif
99 
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void setUpDocumentModules(const uno::Reference< sheet::XSpreadsheetDocument > &xDoc)
uno::Reference< sheet::XUnnamedDatabaseRanges > GetUnnamedDataBaseRanges(const ScDocShell *pShell)
ScDocShell * GetDocShellFromRange(const uno::Reference< uno::XInterface > &xRange)
ImplObject * getImplFromDocModuleWrapper(const css::uno::Reference< css::uno::XInterface > &rxWrapperIf)
void implnCopy(const uno::Reference< frame::XModel > &xModel)
static SfxItemSet * GetDataSet(ScCellRangesBase *pRangeObj)
uno::Reference< XHelperInterface > getUnoSheetModuleObj(const uno::Reference< table::XCellRange > &xRange)
ScPasteFunc
Definition: global.hxx:190
ScDocShell * getDocShell(const css::uno::Reference< css::frame::XModel > &xModel)
InsertDeleteFlags
Definition: global.hxx:159
SfxViewFrame * getViewFrame(const uno::Reference< frame::XModel > &xModel)
void implnCut(const uno::Reference< frame::XModel > &xModel)
uno::Reference< sheet::XDatabaseRange > GetAutoFiltRange(const ScDocShell *pShell, sal_Int16 nSheet)
ScTabViewShell * getBestViewShell(const css::uno::Reference< css::frame::XModel > &xModel)
void implnPasteSpecial(const uno::Reference< frame::XModel > &xModel, InsertDeleteFlags nFlags, ScPasteFunc nFunction, bool bSkipEmpty, bool bTranspose)
ScTabViewShell * getCurrentBestViewShell(const uno::Reference< uno::XComponentContext > &xContext)
void implnPaste(const uno::Reference< frame::XModel > &xModel)
void implSetZoom(const uno::Reference< frame::XModel > &xModel, sal_Int16 nZoom, std::vector< SCTAB > &nTabs)
sal_Int16 SCTAB
Definition: types.hxx:23