importSheet from an external provided document
define a new interface XSpreadsheets2 clean some String in docuno.cxx while i'm at it.
This commit is contained in:
committed by
Kohei Yoshida
parent
364a3d2864
commit
2ee55872eb
@@ -3458,6 +3458,7 @@ $(eval $(call gb_UnoApiTarget_add_idlfiles,offapi,offapi/com/sun/star/sheet,\
|
||||
XSpreadsheetDocument \
|
||||
XSpreadsheetView \
|
||||
XSpreadsheets \
|
||||
XSpreadsheets2 \
|
||||
XSubTotalCalculatable \
|
||||
XSubTotalDescriptor \
|
||||
XSubTotalField \
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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. 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.
|
||||
*
|
||||
*
|
||||
* Author(s): Laurent Godard <lgodard.libre@laposte.net>
|
||||
*
|
||||
* 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_table_XSpreadsheets2_idl__
|
||||
#define __com_sun_star_table_XSpreadsheets2_idl__
|
||||
|
||||
#include <com/sun/star/sheet/XSpreadsheets.idl>
|
||||
#include <com/sun/star/sheet/XSpreadsheetDocument.idl>
|
||||
#include <com/sun/star/lang/IllegalArgumentException.idl>
|
||||
#include <com/sun/star/uno/RuntimeException.idl>
|
||||
|
||||
//=============================================================================
|
||||
|
||||
module com { module sun { module star { module sheet {
|
||||
|
||||
//=============================================================================
|
||||
|
||||
/** extends XSpreadsheets interface to import external sheets.
|
||||
|
||||
@see com::sun::star::sheet::Spreadsheets
|
||||
*/
|
||||
interface XSpreadsheets2: com::sun::star::sheet::XSpreadsheets
|
||||
{
|
||||
/** copies a sheet from a source document.
|
||||
|
||||
@param srcDoc
|
||||
a valid XSpreadsheetDocument reference to source doc
|
||||
|
||||
@param srcName
|
||||
the source sheet name.
|
||||
|
||||
@param nDestPosition
|
||||
the destination sheet position.
|
||||
|
||||
@returns the position of the imported sheet or -1 if not imported
|
||||
|
||||
@throws ::com::sun::star::lang::IllegalArgumentException
|
||||
@throws ::com::sun::star::uno::RuntimeException
|
||||
|
||||
@since LibreOffice 3.5
|
||||
*/
|
||||
long importSheet(
|
||||
[in] com::sun::star::sheet::XSpreadsheetDocument srcDoc,
|
||||
[in] string srcName,
|
||||
[in] long nDestPosition)
|
||||
raises (com::sun::star::lang::IllegalArgumentException,
|
||||
com::sun::star::uno::RuntimeException);
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
|
||||
}; }; }; };
|
||||
|
||||
#endif
|
||||
|
||||
+10
-1
@@ -44,6 +44,7 @@
|
||||
#include <com/sun/star/sheet/XScenarios.hpp>
|
||||
#include <com/sun/star/sheet/XConsolidatable.hpp>
|
||||
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
|
||||
#include <com/sun/star/sheet/XSpreadsheets2.hpp>
|
||||
#include <com/sun/star/sheet/XDocumentAuditing.hpp>
|
||||
#include <com/sun/star/lang/XServiceInfo.hpp>
|
||||
#include <com/sun/star/util/XProtectable.hpp>
|
||||
@@ -371,7 +372,7 @@ public:
|
||||
|
||||
|
||||
class ScTableSheetsObj : public cppu::WeakImplHelper5<
|
||||
com::sun::star::sheet::XSpreadsheets,
|
||||
com::sun::star::sheet::XSpreadsheets2,
|
||||
com::sun::star::sheet::XCellRangesAccess,
|
||||
com::sun::star::container::XEnumerationAccess,
|
||||
com::sun::star::container::XIndexAccess,
|
||||
@@ -399,6 +400,14 @@ public:
|
||||
const ::rtl::OUString& aCopy, sal_Int16 nDestination )
|
||||
throw(::com::sun::star::uno::RuntimeException);
|
||||
|
||||
// XSpreadsheets2
|
||||
virtual sal_Int32 SAL_CALL importSheet(
|
||||
const ::com::sun::star::uno::Reference <
|
||||
::com::sun::star::sheet::XSpreadsheetDocument > & xDocSrc,
|
||||
const rtl::OUString& srcName,
|
||||
const sal_Int32 nDestPosition)
|
||||
throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
|
||||
|
||||
// XCellRangesAccess
|
||||
|
||||
virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCell >
|
||||
|
||||
@@ -2433,8 +2433,7 @@ ScTableSheetObj* ScTableSheetsObj::GetObjectByName_Impl(const rtl::OUString& aNa
|
||||
if (pDocShell)
|
||||
{
|
||||
SCTAB nIndex;
|
||||
String aString(aName);
|
||||
if ( pDocShell->GetDocument()->GetTable( aString, nIndex ) )
|
||||
if ( pDocShell->GetDocument()->GetTable( aName, nIndex ) )
|
||||
return new ScTableSheetObj( pDocShell, nIndex );
|
||||
}
|
||||
return NULL;
|
||||
@@ -2462,9 +2461,8 @@ void SAL_CALL ScTableSheetsObj::moveByName( const rtl::OUString& aName, sal_Int1
|
||||
sal_Bool bDone = false;
|
||||
if (pDocShell)
|
||||
{
|
||||
String aNamStr(aName);
|
||||
SCTAB nSource;
|
||||
if ( pDocShell->GetDocument()->GetTable( aNamStr, nSource ) )
|
||||
if ( pDocShell->GetDocument()->GetTable( aName, nSource ) )
|
||||
bDone = pDocShell->MoveTable( nSource, nDestination, false, sal_True );
|
||||
}
|
||||
if (!bDone)
|
||||
@@ -2479,10 +2477,9 @@ void SAL_CALL ScTableSheetsObj::copyByName( const rtl::OUString& aName,
|
||||
sal_Bool bDone = false;
|
||||
if (pDocShell)
|
||||
{
|
||||
String aNamStr(aName);
|
||||
String aNewStr(aCopy);
|
||||
SCTAB nSource;
|
||||
if ( pDocShell->GetDocument()->GetTable( aNamStr, nSource ) )
|
||||
if ( pDocShell->GetDocument()->GetTable( aName, nSource ) )
|
||||
{
|
||||
bDone = pDocShell->MoveTable( nSource, nDestination, sal_True, sal_True );
|
||||
if (bDone)
|
||||
@@ -2572,14 +2569,14 @@ void SAL_CALL ScTableSheetsObj::replaceByName( const rtl::OUString& aName, const
|
||||
ScTableSheetObj* pSheetObj = ScTableSheetObj::getImplementation( xInterface );
|
||||
if ( pSheetObj && !pSheetObj->GetDocShell() ) // noch nicht eingefuegt?
|
||||
{
|
||||
String aNamStr(aName);
|
||||
SCTAB nPosition;
|
||||
if ( pDocShell->GetDocument()->GetTable( aNamStr, nPosition ) )
|
||||
if ( pDocShell->GetDocument()->GetTable( aName, nPosition ) )
|
||||
{
|
||||
ScDocFunc aFunc(*pDocShell);
|
||||
if ( aFunc.DeleteTable( nPosition, sal_True, sal_True ) )
|
||||
{
|
||||
// InsertTable kann jetzt eigentlich nicht schiefgehen...
|
||||
String aNamStr(aName);
|
||||
bDone = aFunc.InsertTable( nPosition, aNamStr, sal_True, sal_True );
|
||||
if (bDone)
|
||||
pSheetObj->InitInsertSheet( pDocShell, nPosition );
|
||||
@@ -2616,8 +2613,7 @@ void SAL_CALL ScTableSheetsObj::removeByName( const rtl::OUString& aName )
|
||||
if (pDocShell)
|
||||
{
|
||||
SCTAB nIndex;
|
||||
String aString(aName);
|
||||
if ( pDocShell->GetDocument()->GetTable( aString, nIndex ) )
|
||||
if ( pDocShell->GetDocument()->GetTable( aName, nIndex ) )
|
||||
{
|
||||
ScDocFunc aFunc(*pDocShell);
|
||||
bDone = aFunc.DeleteTable( nIndex, sal_True, sal_True );
|
||||
@@ -2633,6 +2629,47 @@ void SAL_CALL ScTableSheetsObj::removeByName( const rtl::OUString& aName )
|
||||
throw uno::RuntimeException(); // NoSuchElementException is handled above
|
||||
}
|
||||
|
||||
sal_Int32 ScTableSheetsObj::importSheet(
|
||||
const uno::Reference < sheet::XSpreadsheetDocument > & xDocSrc,
|
||||
const rtl::OUString& srcName, const sal_Int32 nDestPosition )
|
||||
throw( lang::IllegalArgumentException, uno::RuntimeException )
|
||||
{
|
||||
//pDocShell is the destination
|
||||
ScDocument* pDocDest = pDocShell->GetDocument();
|
||||
|
||||
// Source document docShell
|
||||
if ( !xDocSrc.is() )
|
||||
throw uno::RuntimeException();
|
||||
ScModelObj* pObj = ScModelObj::getImplementation(xDocSrc);
|
||||
ScDocShell* pDocShellSrc = static_cast<ScDocShell*>(pObj->GetEmbeddedObject());
|
||||
|
||||
SCTAB nIndexDest;
|
||||
nIndexDest = -1;
|
||||
|
||||
// SourceSheet Position and does srcName exists ?
|
||||
SCTAB nIndexSrc;
|
||||
if ( !pDocShellSrc->GetDocument()->GetTable( srcName, nIndexSrc ) )
|
||||
throw lang::IllegalArgumentException();
|
||||
|
||||
// control nDestPosition < maxtab
|
||||
SCTAB nCount = pDocDest->GetTableCount();
|
||||
nIndexDest = static_cast<SCTAB>(nDestPosition);
|
||||
if ( nIndexDest > nCount )
|
||||
nIndexDest = nCount;
|
||||
|
||||
// control nDestPosition > 0
|
||||
if ( nIndexDest < 0)
|
||||
nIndexDest = 0;
|
||||
|
||||
// Transfert Tab
|
||||
bool bInsertNew = true;
|
||||
bool bNotifyAndPaint = true;
|
||||
pDocShell->TransferTab(
|
||||
*pDocShellSrc, nIndexSrc, nIndexDest, bInsertNew, bNotifyAndPaint );
|
||||
|
||||
return nIndexDest;
|
||||
}
|
||||
|
||||
// XCellRangesAccess
|
||||
|
||||
uno::Reference< table::XCell > SAL_CALL ScTableSheetsObj::getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow, sal_Int32 nSheet )
|
||||
@@ -2772,7 +2809,7 @@ sal_Bool SAL_CALL ScTableSheetsObj::hasByName( const rtl::OUString& aName )
|
||||
if (pDocShell)
|
||||
{
|
||||
SCTAB nIndex;
|
||||
if ( pDocShell->GetDocument()->GetTable( String(aName), nIndex ) )
|
||||
if ( pDocShell->GetDocument()->GetTable( aName, nIndex ) )
|
||||
return sal_True;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -216,6 +216,7 @@
|
||||
<type>com.sun.star.sheet.XSpreadsheet</type>
|
||||
<type>com.sun.star.sheet.XSpreadsheetDocument</type>
|
||||
<type>com.sun.star.sheet.XSpreadsheets</type>
|
||||
<type>com.sun.star.sheet.XSpreadsheets2</type>
|
||||
<type>com.sun.star.sheet.XSubTotalCalculatable</type>
|
||||
<type>com.sun.star.sheet.XSubTotalDescriptor</type>
|
||||
<type>com.sun.star.sheet.XSubTotalField</type>
|
||||
|
||||
Reference in New Issue
Block a user