New UNO API to return currently selected sheets.

Both from the sheet view and preview modes.
This commit is contained in:
Kohei Yoshida 2011-11-28 22:15:03 -05:00
parent ffca779f37
commit 7a16f31752
4 changed files with 97 additions and 3 deletions

View file

@ -3428,6 +3428,7 @@ $(eval $(call gb_UnoApiTarget_add_idlfiles,offapi,offapi/com/sun/star/sheet,\
XScenarioEnhanced \
XScenarios \
XScenariosSupplier \
XSelectedSheetsSupplier \
XSheetAnnotation \
XSheetAnnotationAnchor \
XSheetAnnotationShapeSupplier \

View file

@ -0,0 +1,44 @@
/*
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Major Contributor(s):
* Copyright (C) 2011 Kohei Yoshida <kohei.yoshida@suse.com>
*
* All Rights Reserved.
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
* instead of those above.
*/
#ifndef __com_sun_star_sheet_XSelectedSheetsSupplier_idl__
#define __com_sun_star_sheet_XSelectedSheetsSupplier_idl__
module com { module sun { module star { module sheet {
interface XSelectedSheetsSupplier: com::sun::star::uno::XInterface
{
/**
returns the indices of currently selected sheets. Sheet indices are
0-based.
*/
sequence<long> getSelectedSheets();
};
}; }; }; };
#endif

View file

@ -38,6 +38,7 @@
#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
#include <com/sun/star/sheet/XViewSplitable.hpp>
#include <com/sun/star/sheet/XViewFreezable.hpp>
#include <com/sun/star/sheet/XSelectedSheetsSupplier.hpp>
#include <com/sun/star/sheet/XSpreadsheetView.hpp>
#include <com/sun/star/sheet/XEnhancedMouseClickBroadcaster.hpp>
#include <com/sun/star/sheet/XActivationBroadcaster.hpp>
@ -189,7 +190,8 @@ class ScTabViewObj : public ScViewPaneBase,
public com::sun::star::sheet::XViewFreezable,
public com::sun::star::sheet::XRangeSelection,
public com::sun::star::lang::XUnoTunnel,
public com::sun::star::datatransfer::XTransferableSupplier
public com::sun::star::datatransfer::XTransferableSupplier,
public com::sun::star::sheet::XSelectedSheetsSupplier
{
private:
SfxItemPropertySet aPropSet;
@ -395,19 +397,36 @@ public:
virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
throw(::com::sun::star::uno::RuntimeException);
//XTransferableSupplier
// XTransferableSupplier
virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL getTransferable( ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL insertTransferable( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTrans ) throw (::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::uno::RuntimeException);
// XSelectedSheetsSupplier
virtual ::com::sun::star::uno::Sequence<sal_Int32> SAL_CALL getSelectedSheets()
throw(::com::sun::star::uno::RuntimeException);
};
class ScPreviewObj : public SfxBaseController, SfxListener
class ScPreviewObj : public SfxBaseController,
public SfxListener,
public com::sun::star::sheet::XSelectedSheetsSupplier
{
ScPreviewShell* mpViewShell;
public:
ScPreviewObj(ScPreviewShell* pViewSh);
virtual ~ScPreviewObj();
virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
const ::com::sun::star::uno::Type & rType)
throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL acquire() throw();
virtual void SAL_CALL release() throw();
virtual void Notify(SfxBroadcaster&, const SfxHint& rHint);
// XSelectedSheetsSupplier
virtual ::com::sun::star::uno::Sequence<sal_Int32> SAL_CALL getSelectedSheets()
throw(::com::sun::star::uno::RuntimeException);
};
#endif

View file

@ -614,6 +614,7 @@ uno::Any SAL_CALL ScTabViewObj::queryInterface( const uno::Type& rType )
SC_QUERYINTERFACE( sheet::XRangeSelection )
SC_QUERYINTERFACE( lang::XUnoTunnel )
SC_QUERYINTERFACE( datatransfer::XTransferableSupplier )
SC_QUERYINTERFACE( sheet::XSelectedSheetsSupplier )
uno::Any aRet(ScViewPaneBase::queryInterface( rType ));
if (!aRet.hasValue())
@ -2371,6 +2372,12 @@ void SAL_CALL ScTabViewObj::insertTransferable( const ::com::sun::star::uno::Ref
}
}
uno::Sequence<sal_Int32> ScTabViewObj::getSelectedSheets()
throw (uno::RuntimeException)
{
return uno::Sequence<sal_Int32>();
}
ScPreviewObj::ScPreviewObj(ScPreviewShell* pViewSh) :
SfxBaseController(pViewSh),
mpViewShell(pViewSh)
@ -2385,6 +2392,23 @@ ScPreviewObj::~ScPreviewObj()
EndListening(*mpViewShell);
}
uno::Any ScPreviewObj::queryInterface(const uno::Type& rType)
throw(uno::RuntimeException)
{
SC_QUERYINTERFACE(sheet::XSelectedSheetsSupplier)
return SfxBaseController::queryInterface(rType);
}
void ScPreviewObj::acquire() throw()
{
SfxBaseController::acquire();
}
void ScPreviewObj::release() throw()
{
SfxBaseController::release();
}
void ScPreviewObj::Notify(SfxBroadcaster&, const SfxHint& rHint)
{
const SfxSimpleHint* p = dynamic_cast<const SfxSimpleHint*>(&rHint);
@ -2392,4 +2416,10 @@ void ScPreviewObj::Notify(SfxBroadcaster&, const SfxHint& rHint)
mpViewShell = NULL;
}
uno::Sequence<sal_Int32> ScPreviewObj::getSelectedSheets()
throw (uno::RuntimeException)
{
return uno::Sequence<sal_Int32>();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */