1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef SC_EXCEL_VBA_HELPER_HXX
20 #define SC_EXCEL_VBA_HELPER_HXX
22 #include <vbahelper/vbahelper.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>
33 class ScCellRangesBase
;
39 // ============================================================================
41 // nTabs empty means apply zoom to all sheets
42 void implSetZoom( const css::uno::Reference
< css::frame::XModel
>& xModel
, sal_Int16 nZoom
, std::vector
< SCTAB
>& nTabs
);
43 void implnCopy( const css::uno::Reference
< css::frame::XModel
>& xModel
);
44 void implnPaste ( const css::uno::Reference
< css::frame::XModel
>& xModel
);
45 void implnCut( const css::uno::Reference
< css::frame::XModel
>& xModel
);
46 void implnPasteSpecial( const css::uno::Reference
< css::frame::XModel
>& xModel
, sal_uInt16 nFlags
,sal_uInt16 nFunction
,sal_Bool bSkipEmpty
, sal_Bool bTranspose
);
47 ScTabViewShell
* getBestViewShell( const css::uno::Reference
< css::frame::XModel
>& xModel
) ;
48 ScDocShell
* getDocShell( const css::uno::Reference
< css::frame::XModel
>& xModel
) ;
49 ScTabViewShell
* getCurrentBestViewShell( const css::uno::Reference
< css::uno::XComponentContext
>& xContext
);
50 SfxViewFrame
* getViewFrame( const css::uno::Reference
< css::frame::XModel
>& xModel
);
52 css::uno::Reference
< css::sheet::XUnnamedDatabaseRanges
> GetUnnamedDataBaseRanges( ScDocShell
* pShell
) throw ( css::uno::RuntimeException
);
54 css::uno::Reference
< css::sheet::XDatabaseRange
> GetAutoFiltRange( ScDocShell
* pShell
, sal_Int16 nSheet
) throw ( css::uno::RuntimeException
);
55 css::uno::Reference
< ooo::vba::XHelperInterface
> getUnoSheetModuleObj( const css::uno::Reference
< css::sheet::XSpreadsheet
>& xSheet
) throw ( css::uno::RuntimeException
);
56 css::uno::Reference
< ooo::vba::XHelperInterface
> getUnoSheetModuleObj( const css::uno::Reference
< css::sheet::XSheetCellRangeContainer
>& xRanges
) throw ( css::uno::RuntimeException
);
57 css::uno::Reference
< ooo::vba::XHelperInterface
> getUnoSheetModuleObj( const css::uno::Reference
< css::table::XCellRange
>& xRange
) throw ( css::uno::RuntimeException
);
58 css::uno::Reference
< ooo::vba::XHelperInterface
> getUnoSheetModuleObj( const css::uno::Reference
< css::table::XCell
>& xCell
) throw ( css::uno::RuntimeException
);
59 css::uno::Reference
< ooo::vba::XHelperInterface
> getUnoSheetModuleObj( const css::uno::Reference
< css::frame::XModel
>& xModel
, SCTAB nTab
) throw ( css::uno::RuntimeException
);
61 ScDocShell
* GetDocShellFromRange( const css::uno::Reference
< css::uno::XInterface
>& xRange
) throw ( css::uno::RuntimeException
);
62 void setUpDocumentModules( const css::uno::Reference
< css::sheet::XSpreadsheetDocument
>& xDoc
);
64 // ============================================================================
66 class ScVbaCellRangeAccess
69 static SfxItemSet
* GetDataSet( ScCellRangesBase
* pRangeObj
);
72 // Extracts a implementation object ( via XUnoTunnel ) from an uno object
73 // by default will throw if unsuccessful.
74 template < typename ImplObject
>
75 ImplObject
* getImplFromDocModuleWrapper( const css::uno::Reference
< css::uno::XInterface
>& rxWrapperIf
, bool bThrow
= true ) throw (css::uno::RuntimeException
)
77 ImplObject
* pObj
= NULL
;
78 css::uno::Reference
< css::lang::XUnoTunnel
> xTunnel( rxWrapperIf
, css::uno::UNO_QUERY
);
80 pObj
= reinterpret_cast<ImplObject
*>( xTunnel
->getSomething(ImplObject::getUnoTunnelId()));
81 if ( bThrow
&& !pObj
)
82 throw css::uno::RuntimeException("Internal error, can't exctract implementation object", rxWrapperIf
);
85 // ============================================================================
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */