0554b3bf93
2009-04-08 13:23:56 +0200 dr r270638 : #i100534# reverted 2009-04-08 10:14:55 +0200 dr r270621 : CWS-TOOLING: rebase CWS dr67 to trunk@270033 (milestone: DEV300:m45) 2009-04-07 21:06:33 +0200 dr r270610 : #i100534# sc does not link in debug mode 2009-03-12 11:20:09 +0100 dr r269375 : #i10000# wae 2009-03-11 19:43:55 +0100 dr r269351 : #i10000# adjust oox namespace ids according to oox/inc/oox/core/namespaces.hxx 2009-03-11 15:38:52 +0100 dr r269339 : CWS-TOOLING: rebase CWS dr67 to trunk@269297 (milestone: DEV300:m43) 2009-02-27 15:20:21 +0100 dr r268598 : CWS-TOOLING: rebase CWS dr67 to trunk@268395 (milestone: DEV300:m42) 2009-02-19 13:32:17 +0100 dr r268277 : moved hf parser into page settings 2009-02-19 12:25:15 +0100 dr r268272 : renamed some structs according to chart filter 2009-02-16 15:51:31 +0100 dr r267823 : #i97873# import autosort settings from BIFF8/OOBIN/OOXML 2009-02-06 17:09:29 +0100 dr r267477 : #i97873# minor changes 2009-02-06 16:38:56 +0100 dr r267473 : #i97873# import date grouping settings from BIFF5/BIFF8/OOBIN/OOXML 2009-02-06 16:38:11 +0100 dr r267472 : #i97873# check min/max/step of passed GroupInfo 2009-02-06 16:35:13 +0100 dr r267471 : #i97873# more doc for createDategroup() 2009-02-06 13:53:42 +0100 dr r267459 : #i97873# make XDataPilotGrouping::createDateGroup() implementation working and robust against wrong input data 2009-02-06 13:52:16 +0100 dr r267458 : #i97873# fix and extend IDL doc for datapilot grouping 2009-02-06 12:35:49 +0100 dr r267453 : fix other IDLC warnings in sheet module 2009-02-06 12:05:19 +0100 dr r267448 : #i97873# fix and extend IDL doc for datapilot grouping 2009-02-02 17:58:46 +0100 dr r267284 : #i10000# rebase errors 2009-02-02 17:52:21 +0100 dr r267282 : #i10000# rebase errors 2009-02-02 17:35:58 +0100 dr r267280 : #i10000# rebase errors 2009-02-02 15:58:04 +0100 dr r267274 : CWS-TOOLING: rebase CWS dr67 to trunk@267171 (milestone: DEV300:m41) 2009-02-02 09:16:32 +0100 dr r267247 : #i97873# typo 2009-01-30 17:09:09 +0100 dr r267215 : #i97873# import numeric grouping settings for datapilot fields from BIFF5/BIFF8/OOBIN/OOXML 2009-01-29 16:36:24 +0100 dr r267154 : #i97873# import datapilot discrete grouping from BIFF5/BIFF8/OOBIN/OOXLS 2009-01-29 16:33:37 +0100 dr r267152 : #i97873# do not kill _all_ the other group fields when writing back DataPilotField::GroupInfo property 2009-01-29 14:15:45 +0100 dr r267133 : #i93839# remove ScChengeTrack::Load and ::Store, adapt xls export filter 2009-01-28 13:30:37 +0100 dr r267056 : #i98397# enhance DataPilot API: allow to rename groups and items in a group field 2009-01-28 12:09:05 +0100 dr r267051 : #i98397# enhance DataPilot API: allow to rename groups and items in a group field 2009-01-27 16:13:58 +0100 dr r267005 : #i97873# minor changes in DataPilot API implementation as preparation for additional changes needed for OOX import filter 2009-01-27 10:08:01 +0100 dr r266961 : #i97873# changing orientation of a DP field moves it to last position in new dimension 2009-01-27 10:06:50 +0100 dr r266960 : #i97873# changing orientation of a DP field moves it to last position in new dimension 2009-01-23 12:52:31 +0100 dr r266808 : #i97873# DP documentation extended 2009-01-21 20:07:15 +0100 dr r266702 : #i97873# this trivial patch adds BIFF5/BIFF8 pivot table import to the oox filter 2009-01-20 16:06:23 +0100 dr r266592 : select BIFF filter via env.var 2009-01-16 18:51:01 +0100 dr r266452 : #i97873# import page fields 2009-01-16 15:05:36 +0100 dr r266420 : #i97873# field item settings (collapsed/hidden), settings of hidden fields 2009-01-15 16:01:17 +0100 dr r266377 : #i97873# import OOXML7/OOBIN7 autoshow settings 2009-01-14 15:24:27 +0100 dr r266310 : #i97873# import auto show settings generated by MSO2003 2009-01-14 12:29:44 +0100 dr r266281 : #i97873# set global dp settings 2009-01-13 15:04:30 +0100 dr r266229 : #i98029# SdrGroupObj does not remember predefined bounding rectangle anymore 2009-01-13 14:46:50 +0100 dr r266225 : #i98029# SdrGroupObj does not remember predefined bounding rectangle anymore 2009-01-12 15:04:22 +0100 dr r266161 : #i97873# remove misleading hasDataLayoutField() 2009-01-12 15:03:42 +0100 dr r266160 : #i97873# remove misleading hasDataLayoutField() 2009-01-12 14:57:33 +0100 dr r266159 : #i97900# reverted previous change, adjusted code to new EnableRTL() behaviour 2009-01-12 14:52:43 +0100 dr r266158 : #i97900# reverted previous change, adjusted code to new EnableRTL() behaviour 2009-01-09 16:34:55 +0100 dr r266098 : #i97900# RTL handling in TabBar changed with CWS rtlcontrols 2009-01-09 16:32:16 +0100 dr r266097 : #i97900# RTL handling in TabBar changed with CWS rtlcontrols 2009-01-09 12:02:39 +0100 dr r266072 : #i97623# RTL handling changed after CWS rtlcontrols 2009-01-09 09:48:53 +0100 dr r266050 : #i158444# SXLI must be filled completely before starting CONTINUE 2009-01-08 18:50:08 +0100 dr r266032 : #158444# allow to disable dump of record positions 2009-01-08 15:46:45 +0100 dr r266020 : #i97873# data layout field handling 2009-01-08 15:45:45 +0100 dr r266019 : #i97873# data layout field handling 2009-01-08 15:42:25 +0100 dr r266018 : #i97873# data layout field handling 2009-01-02 17:28:32 +0100 dr r265844 : #i10000# unxmacxi warning 2009-01-02 16:59:13 +0100 dr r265842 : #i10000# rebase corrections 2009-01-02 16:44:44 +0100 dr r265838 : #i10000# rebase corrections 2009-01-02 11:32:44 +0100 dr r265834 : CWS-TOOLING: rebase CWS dr67 to trunk@265758 (milestone: DEV300:m38) 2008-12-29 16:55:40 +0100 dr r265822 : more pivot table import, field layout settings 2008-12-29 14:27:35 +0100 dr r265817 : more pivot table import, additions for data field settings 2008-12-26 14:39:21 +0100 dr r265805 : updates 2008-12-19 16:31:39 +0100 dr r265734 : typo 2008-12-19 16:30:00 +0100 dr r265733 : add API for sequence of DP field subtotal functions 2008-12-19 16:29:43 +0100 dr r265732 : add API for sequence of DP field subtotal functions 2008-12-19 16:29:07 +0100 dr r265731 : add API for sequence of DP field subtotal functions 2008-12-18 18:07:58 +0100 dr r265710 : #i96758# try to cache row default formatting and apply it at row ranges instead of single rows 2008-12-18 16:00:25 +0100 dr r265698 : more additions to pivot import 2008-12-17 13:38:19 +0100 dr r265599 : do not assert HIDDEN orientation 2008-12-12 13:51:29 +0100 dr r265415 : minor typos 2008-12-12 10:15:04 +0100 dr r265394 : pivot cache import extended to XLSB, added creation of cache data for missing/external sheets 2008-12-04 13:16:16 +0100 dr r264837 : #i96860# remove old dumper files 2008-12-04 12:17:38 +0100 dr r264834 : #i96858# XTO broken, if textbox is empty but contains formatting 2008-12-04 12:16:38 +0100 dr r264833 : #i96858# XTO broken, if textbox is empty but contains formatting 2008-12-03 14:51:05 +0100 dr r264784 : #i10000# warnings 2008-12-03 14:32:46 +0100 dr r264778 : #i10000# warning 2008-12-03 11:28:38 +0100 dr r264758 : #i96758# ignore zero-sized objects 2008-12-03 10:09:34 +0100 dr r264748 : #i96758# change ::oox::Property(Set|Map) keys to sal_Int32 property identifiers, to save construction of property names 2008-12-01 16:09:02 +0100 dr r264615 : #i96758# headerdoc 2008-12-01 14:49:04 +0100 dr r264607 : #i96758# import performance of formatted documents 2008-11-26 17:08:15 +0100 dr r264424 : make it more simple 2008-11-26 16:31:41 +0100 dr r264419 : c:crossesAt is for crossing axis, not for own axis. This is different to BIFF 2008-11-26 13:55:55 +0100 dr r264382 : #i86346# import of MissingValueTreatment from XLSX 2008-11-26 12:49:38 +0100 dr r264370 : #i86346# import/export of MissingValueTreatment from/to XLS 2008-11-25 17:48:59 +0100 dr r264320 : update row height with single progress bar when using 'IsAdjustHeightEnabled' document property 2008-11-25 17:24:26 +0100 dr r264319 : #i96438# disable importing comment text until API is fixed 2008-11-25 17:11:30 +0100 dr r264318 : #i90124# set control tooltips, patch from npower 2008-11-25 15:09:28 +0100 dr r264309 : #i94028# #i94991# update drawing objects when changing row height 2008-11-24 15:21:35 +0100 dr r264224 : prevent ::rtl::OUString::copy assertion 2008-11-24 15:19:39 +0100 dr r264223 : #i95183# #158573# handle non-ascii characters in sheet names in OOXML import 2008-11-24 12:54:30 +0100 dr r264221 : #i94157# support ESC key to leave full-screen in page preview 2008-11-21 18:15:17 +0100 dr r264165 : #i90360# disable chart perspective if it is set to 0 2008-11-21 18:14:41 +0100 dr r264164 : #i90360# disable chart perspective if it is set to 0 2008-11-21 17:43:26 +0100 dr r264155 : #i96140# missing parenth 2008-11-21 17:36:35 +0100 dr r264154 : #i96438# first steps of note import 2008-11-20 15:15:03 +0100 dr r264059 : get rid of ContextWrapper 2008-11-18 11:39:52 +0100 dr r263755 : #i78476# moved to CWS dr67
218 lines
8.4 KiB
C++
218 lines
8.4 KiB
C++
/*************************************************************************
|
|
*
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
*
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
|
*
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
*
|
|
* $RCSfile: sharedformulabuffer.cxx,v $
|
|
* $Revision: 1.4.20.1 $
|
|
*
|
|
* This file is part of OpenOffice.org.
|
|
*
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
* only, as published by the Free Software Foundation.
|
|
*
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Lesser General Public License version 3 for more details
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
* <http://www.openoffice.org/license.html>
|
|
* for a copy of the LGPLv3 License.
|
|
*
|
|
************************************************************************/
|
|
|
|
#include "oox/xls/sharedformulabuffer.hxx"
|
|
#include <rtl/ustrbuf.hxx>
|
|
#include <com/sun/star/sheet/XFormulaTokens.hpp>
|
|
#include "properties.hxx"
|
|
#include "oox/helper/propertyset.hxx"
|
|
#include "oox/helper/recordinputstream.hxx"
|
|
#include "oox/xls/addressconverter.hxx"
|
|
#include "oox/xls/biffinputstream.hxx"
|
|
#include "oox/xls/formulaparser.hxx"
|
|
|
|
using ::rtl::OUString;
|
|
using ::rtl::OUStringBuffer;
|
|
using ::com::sun::star::uno::Reference;
|
|
using ::com::sun::star::uno::Exception;
|
|
using ::com::sun::star::uno::UNO_QUERY;
|
|
using ::com::sun::star::table::CellAddress;
|
|
using ::com::sun::star::table::CellRangeAddress;
|
|
using ::com::sun::star::sheet::XFormulaTokens;
|
|
using ::com::sun::star::sheet::XNamedRange;
|
|
|
|
namespace oox {
|
|
namespace xls {
|
|
|
|
// ============================================================================
|
|
|
|
namespace {
|
|
|
|
bool operator==( const CellAddress& rAddr1, const CellAddress& rAddr2 )
|
|
{
|
|
return
|
|
(rAddr1.Sheet == rAddr2.Sheet) &&
|
|
(rAddr1.Column == rAddr2.Column) &&
|
|
(rAddr1.Row == rAddr2.Row);
|
|
}
|
|
|
|
bool lclContains( const CellRangeAddress& rRange, const CellAddress& rAddr )
|
|
{
|
|
return
|
|
(rRange.Sheet == rAddr.Sheet) &&
|
|
(rRange.StartColumn <= rAddr.Column) && (rAddr.Column <= rRange.EndColumn) &&
|
|
(rRange.StartRow <= rAddr.Row) && (rAddr.Row <= rRange.EndRow);
|
|
}
|
|
|
|
} // namespace
|
|
|
|
// ============================================================================
|
|
|
|
ExtCellFormulaContext::ExtCellFormulaContext( const WorksheetHelper& rHelper,
|
|
const Reference< XFormulaTokens >& rxTokens, const CellAddress& rCellPos ) :
|
|
SimpleFormulaContext( rxTokens, false, false ),
|
|
WorksheetHelper( rHelper )
|
|
{
|
|
setBaseAddress( rCellPos );
|
|
}
|
|
|
|
void ExtCellFormulaContext::setSharedFormula( const CellAddress& rBaseAddr )
|
|
{
|
|
getSharedFormulas().setSharedFormulaCell( *this, rBaseAddr );
|
|
}
|
|
|
|
// ============================================================================
|
|
|
|
SharedFormulaBuffer::SharedFormulaBuffer( const WorksheetHelper& rHelper ) :
|
|
WorksheetHelper( rHelper )
|
|
{
|
|
}
|
|
|
|
void SharedFormulaBuffer::importSharedFmla( const OUString& rFormula, const OUString& rSharedRange, sal_Int32 nSharedId, const CellAddress& rBaseAddr )
|
|
{
|
|
CellRangeAddress aFmlaRange;
|
|
if( getAddressConverter().convertToCellRange( aFmlaRange, rSharedRange, getSheetIndex(), true, true ) )
|
|
{
|
|
// create the defined name representing the shared formula
|
|
OSL_ENSURE( lclContains( aFmlaRange, rBaseAddr ), "SharedFormulaBuffer::importSharedFmla - invalid range for shared formula" );
|
|
BinAddress aMapKey( nSharedId, 0 );
|
|
Reference< XNamedRange > xNamedRange = createDefinedName( aMapKey );
|
|
// convert the formula definition
|
|
Reference< XFormulaTokens > xTokens( xNamedRange, UNO_QUERY );
|
|
if( xTokens.is() )
|
|
{
|
|
SimpleFormulaContext aContext( xTokens, true, false );
|
|
aContext.setBaseAddress( rBaseAddr );
|
|
getFormulaParser().importFormula( aContext, rFormula );
|
|
updateCachedCell( rBaseAddr, aMapKey );
|
|
}
|
|
}
|
|
}
|
|
|
|
void SharedFormulaBuffer::importSharedFmla( RecordInputStream& rStrm, const CellAddress& rBaseAddr )
|
|
{
|
|
BinRange aRange;
|
|
rStrm >> aRange;
|
|
CellRangeAddress aFmlaRange;
|
|
if( getAddressConverter().convertToCellRange( aFmlaRange, aRange, getSheetIndex(), true, true ) )
|
|
{
|
|
// create the defined name representing the shared formula
|
|
OSL_ENSURE( lclContains( aFmlaRange, rBaseAddr ), "SharedFormulaBuffer::importSharedFmla - invalid range for shared formula" );
|
|
BinAddress aMapKey( rBaseAddr );
|
|
Reference< XNamedRange > xNamedRange = createDefinedName( aMapKey );
|
|
// load the formula definition
|
|
Reference< XFormulaTokens > xTokens( xNamedRange, UNO_QUERY );
|
|
if( xTokens.is() )
|
|
{
|
|
SimpleFormulaContext aContext( xTokens, true, false );
|
|
aContext.setBaseAddress( rBaseAddr );
|
|
getFormulaParser().importFormula( aContext, rStrm );
|
|
updateCachedCell( rBaseAddr, aMapKey );
|
|
}
|
|
}
|
|
}
|
|
|
|
void SharedFormulaBuffer::importSharedFmla( BiffInputStream& rStrm, const CellAddress& rBaseAddr )
|
|
{
|
|
BinRange aRange;
|
|
aRange.read( rStrm, false ); // always 8bit column indexes
|
|
CellRangeAddress aFmlaRange;
|
|
if( getAddressConverter().convertToCellRange( aFmlaRange, aRange, getSheetIndex(), true, true ) )
|
|
{
|
|
// create the defined name representing the shared formula
|
|
OSL_ENSURE( lclContains( aFmlaRange, rBaseAddr ), "SharedFormulaBuffer::importSharedFmla - invalid range for shared formula" );
|
|
BinAddress aMapKey( rBaseAddr );
|
|
Reference< XNamedRange > xNamedRange = createDefinedName( aMapKey );
|
|
// load the formula definition
|
|
Reference< XFormulaTokens > xTokens( xNamedRange, UNO_QUERY );
|
|
if( xTokens.is() )
|
|
{
|
|
rStrm.skip( 2 ); // flags
|
|
SimpleFormulaContext aContext( xTokens, true, false );
|
|
aContext.setBaseAddress( rBaseAddr );
|
|
getFormulaParser().importFormula( aContext, rStrm );
|
|
updateCachedCell( rBaseAddr, aMapKey );
|
|
}
|
|
}
|
|
}
|
|
|
|
void SharedFormulaBuffer::setSharedFormulaCell( ExtCellFormulaContext& rContext, const CellAddress& rBaseAddr )
|
|
{
|
|
if( !implSetSharedFormulaCell( rContext, BinAddress( rBaseAddr ) ) )
|
|
if( rContext.getBaseAddress() == rBaseAddr )
|
|
mxLastContext.reset( new ExtCellFormulaContext( rContext ) );
|
|
}
|
|
|
|
void SharedFormulaBuffer::setSharedFormulaCell( ExtCellFormulaContext& rContext, sal_Int32 nSharedId )
|
|
{
|
|
implSetSharedFormulaCell( rContext, BinAddress( nSharedId, 0 ) );
|
|
}
|
|
|
|
Reference< XNamedRange > SharedFormulaBuffer::createDefinedName( const BinAddress& rMapKey )
|
|
{
|
|
OSL_ENSURE( maIndexMap.count( rMapKey ) == 0, "SharedFormulaBuffer::createDefinedName - shared formula exists already" );
|
|
// create the defined name representing the shared formula
|
|
OUString aName = OUStringBuffer().appendAscii( "__shared_" ).
|
|
append( static_cast< sal_Int32 >( getSheetIndex() + 1 ) ).
|
|
append( sal_Unicode( '_' ) ).append( rMapKey.mnRow ).
|
|
append( sal_Unicode( '_' ) ).append( rMapKey.mnCol ).makeStringAndClear();
|
|
Reference< XNamedRange > xNamedRange = createNamedRangeObject( aName );
|
|
PropertySet aNameProps( xNamedRange );
|
|
aNameProps.setProperty( PROP_IsSharedFormula, true );
|
|
sal_Int32 nTokenIndex = -1;
|
|
if( aNameProps.getProperty( nTokenIndex, PROP_TokenIndex ) && (nTokenIndex >= 0) )
|
|
maIndexMap[ rMapKey ] = nTokenIndex;
|
|
return xNamedRange;
|
|
}
|
|
|
|
bool SharedFormulaBuffer::implSetSharedFormulaCell( ExtCellFormulaContext& rContext, const BinAddress& rMapKey )
|
|
{
|
|
TokenIndexMap::const_iterator aIt = maIndexMap.find( rMapKey );
|
|
sal_Int32 nTokenIndex = (aIt == maIndexMap.end()) ? -1 : aIt->second;
|
|
if( nTokenIndex >= 0 )
|
|
{
|
|
getFormulaParser().convertNameToFormula( rContext, nTokenIndex );
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void SharedFormulaBuffer::updateCachedCell( const CellAddress& rBaseAddr, const BinAddress& rMapKey )
|
|
{
|
|
if( mxLastContext.get() && (mxLastContext->getBaseAddress() == rBaseAddr) )
|
|
implSetSharedFormulaCell( *mxLastContext, rMapKey );
|
|
mxLastContext.reset();
|
|
}
|
|
|
|
// ============================================================================
|
|
|
|
} // namespace xls
|
|
} // namespace oox
|
|
|