diff options
author | obo <obo@openoffice.org> | 2010-06-23 13:54:50 +0200 |
---|---|---|
committer | obo <obo@openoffice.org> | 2010-06-23 13:54:50 +0200 |
commit | 99785733db84e98dbac03d6be0879908955cbc3c (patch) | |
tree | a6e8cecb2a75bb6bcd9542e7fd18ae6b5700c18e /sc/source | |
parent | b3579d71c6536ab1d03cc47249d582a574fd054a (diff) | |
parent | 829b756e967201a2642ba3303aafbaac074037d4 (diff) |
CWS-TOOLING: integrate CWS calc55
Diffstat (limited to 'sc/source')
-rwxr-xr-x[-rw-r--r--] | sc/source/core/data/dpobject.cxx | 8 | ||||
-rwxr-xr-x | sc/source/core/data/dpoutput.cxx | 12 | ||||
-rw-r--r-- | sc/source/core/data/dptabresmember.cxx | 831 | ||||
-rw-r--r-- | sc/source/core/data/dptabresmember.hxx | 161 | ||||
-rw-r--r-- | sc/source/core/tool/addincol.cxx | 5 | ||||
-rw-r--r-- | sc/source/core/tool/compiler.cxx | 46 | ||||
-rw-r--r-- | sc/source/filter/xml/xmldpimp.cxx | 5 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlexprt.cxx | 81 | ||||
-rw-r--r-- | sc/source/ui/dbgui/asciiopt.cxx | 33 | ||||
-rw-r--r-- | sc/source/ui/docshell/dbdocfun.cxx | 7 | ||||
-rwxr-xr-x | sc/source/ui/docshell/docsh.cxx | 59 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh2.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh3.cxx | 10 | ||||
-rwxr-xr-x | sc/source/ui/inc/docsh.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/unoobj/chartuno.cxx | 138 | ||||
-rwxr-xr-x | sc/source/ui/view/dbfunc3.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/view/output2.cxx | 24 |
17 files changed, 379 insertions, 1048 deletions
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index a05b321e33ee..a2a10329cf68 100644..100755 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -2434,6 +2434,14 @@ void ScDPCollection::WriteRefsTo( ScDPCollection& r ) const } } +ScDPObject* ScDPCollection::GetByName(const String& rName) const +{ + for (USHORT i=0; i<nCount; i++) + if (static_cast<const ScDPObject*>(pItems[i])->GetName() == rName) + return static_cast<ScDPObject*>(pItems[i]); + return NULL; +} + String ScDPCollection::CreateNewName( USHORT nMin ) const { String aBase = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("DataPilot")); diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx index 91688c6c0e2a..bdd6fd555b89 100755 --- a/sc/source/core/data/dpoutput.cxx +++ b/sc/source/core/data/dpoutput.cxx @@ -1185,9 +1185,9 @@ void ScDPOutput::GetPositionData(const ScAddress& rPos, DataPilotTablePositionDa Reference<beans::XPropertySet> xPropSet(xSource, UNO_QUERY); if (xPropSet.is()) { - sal_Int32 nDataFieldCount = 0; - Any any = xPropSet->getPropertyValue(rtl::OUString::createFromAscii("DataFieldCount")); - if ((any >>= nDataFieldCount) && nDataFieldCount > 0) + sal_Int32 nDataFieldCount = ScUnoHelpFunctions::GetLongProperty( xPropSet, + rtl::OUString::createFromAscii(SC_UNO_DATAFIELDCOUNT) ); + if (nDataFieldCount > 0) aResData.DataFieldIndex = (nRow - nDataStartRow) % nDataFieldCount; } @@ -1267,9 +1267,9 @@ bool ScDPOutput::GetDataResultPositionData(vector<sheet::DataPilotFieldFilter>& if (!xPropSet.is()) return false; - sal_Int32 nDataFieldCount = 0; - Any any = xPropSet->getPropertyValue(rtl::OUString::createFromAscii("DataFieldCount")); - if (!(any >>= nDataFieldCount) || nDataFieldCount == 0) + sal_Int32 nDataFieldCount = ScUnoHelpFunctions::GetLongProperty( xPropSet, + rtl::OUString::createFromAscii(SC_UNO_DATAFIELDCOUNT) ); + if (nDataFieldCount == 0) // No data field is present in this datapilot table. return false; diff --git a/sc/source/core/data/dptabresmember.cxx b/sc/source/core/data/dptabresmember.cxx deleted file mode 100644 index 8c3b7b164bc3..000000000000 --- a/sc/source/core/data/dptabresmember.cxx +++ /dev/null @@ -1,831 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright IBM Corporation 2009. - * Copyright 2009 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: dptabresmember.cxx,v $ - * $Revision: 1.0 $ - * - * 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 "dptabresmember.hxx" -// ----------------------------------------------------------------------- -ScDPResultMember( const ScDPResultData* pData, const ScDPParentDimData& rParentDimData , - BOOL bForceSub ) : - pResultData( pData ), - aParentDimData( rParentDimData ), - /* pParentDim( pDim ), - pParentLevel( pLev ), - pMemberDesc( pDesc ),*/ - pChildDimension( NULL ), - pDataRoot( NULL ), - bHasElements( FALSE ), - bForceSubTotal( bForceSub ), - bHasHiddenDetails( FALSE ), - bInitialized( FALSE ), - nMemberStep( 1 ), - bAutoHidden( FALSE ) -{ - // pParentLevel/pMemberDesc is 0 for root members -} - -ScDPNormalResultMember::ScDPNormalResultMember( const ScDPResultData* pData, - BOOL bForceSub ) : - pResultData( pData ), - pChildDimension( NULL ), - pDataRoot( NULL ), - bHasElements( FALSE ), - bForceSubTotal( bForceSub ), - bHasHiddenDetails( FALSE ), - bInitialized( FALSE ), - nMemberStep( 1 ), - bAutoHidden( FALSE ) -{ -} - -ScDPNormalResultMember::~ScDPNormalResultMember() -{ - delete pChildDimension; - delete pDataRoot; -} - -String ScDPNormalResultMember::GetName() const -{ -// Wang Xu Ming -- 2009-6-10 -// DataPilot Migration - const ScDPMember* pMemberDesc = GetDPMember(); - // End Comments - if (pMemberDesc) - return pMemberDesc->GetNameStr(); - else - return ScGlobal::GetRscString(STR_PIVOT_TOTAL); // root member -} - -void ScDPNormalResultMember::FillItemData( ScDPItemData& rData ) const -{ -// Wang Xu Ming -- 2009-6-10 -// DataPilot Migration - const ScDPMember* pMemberDesc = GetDPMember(); -// End Comments - if (pMemberDesc) - pMemberDesc->FillItemData( rData ); - else - rData.SetString( ScGlobal::GetRscString(STR_PIVOT_TOTAL) ); // root member -} - -BOOL ScDPNormalResultMember::IsNamedItem( /*const ScDPItemData& r */SCROW nIndex ) const -{ - //! store ScDPMember pointer instead of ScDPMember ??? - const ScDPMember* pMemberDesc = GetDPMember(); - if (pMemberDesc) - return ((ScDPMember*)pMemberDesc)->IsNamedItem(/* r*/ nIndex ); - return FALSE; -} - -// Wang Xu Ming -- 2009-5-27 -// DataPilot Migration -bool ScDPNormalResultMember::IsValidEntry( const vector< SCROW >& aMembers ) const -{ - return GetEntryStatus( aMembers ) != ENTRY_INVALID; -} -// End Comments - -ENTRYSTATUS ScDPNormalResultMember::GetEntryStatus( const vector< SCROW >& aMembers ) const -{ - if ( !IsValid() ) - return ENTRY_INVALID; - - const ScDPResultDimension* pChildDim = GetChildDimension(); - if (pChildDim) - { - if (aMembers.size() < 2) - return ENTRY_INVALID; - - vector</*ScDPItemData*/SCROW>::const_iterator itr = aMembers.begin(); - vector</*ScDPItemData*/SCROW> aChildMembers(++itr, aMembers.end()); - return pChildDim->GetEntryStatus(aChildMembers); - } - else if( bHasHiddenDetails ) - return ENTRY_HASHIDDENDETAIL; - else - return ENTRY_VALID; -} - -void ScDPNormalResultMember::InitFrom( const vector<ScDPDimension*>& ppDim, const vector<ScDPLevel*>& ppLev, - size_t nPos, ScDPInitState& rInitState , - BOOL bInitChild /*= TRUE */) - { - // with LateInit, initialize only those members that have data - if ( pResultData->IsLateInit() ) - return; - - bInitialized = TRUE; - - if (nPos >= ppDim.size() ) - return; - - // skip child dimension if details are not shown - if ( GetDPMember() && !GetDPMember()->getShowDetails() ) - { - // Wang Xu Ming -- 2009-6-16 - // Show DataLayout dimention - nMemberStep = 1; - while ( nPos < ppDim.size() ) - { - if ( ppDim[nPos] ->getIsDataLayoutDimension() ) - { - if ( !pChildDimension ) - pChildDimension = new ScDPResultDimension( pResultData ); - pChildDimension->InitFrom( ppDim, ppLev, nPos, rInitState , FALSE ); - return; - } - else - { //find next dim - nPos ++; - nMemberStep ++; - } - } - // End Comments - bHasHiddenDetails = TRUE; // only if there is a next dimension - return; - } - - if ( bInitChild ) - { - pChildDimension = new ScDPResultDimension( pResultData ); - pChildDimension->InitFrom( ppDim, ppLev, nPos, rInitState, TRUE ); - } -} - -// Wang Xu Ming -- 2009-6-10 -// DataPilot Migration -void ScDPNormalResultMember::LateInitFrom( LateInitParams& rParams/*const vector<ScDPDimension*>& ppDim, const vector<ScDPLevel*>& ppLev*/, - const vector< SCROW >& pItemData, size_t nPos, - ScDPInitState& rInitState ) -// End Comments -{ - // without LateInit, everything has already been initialized - if ( !pResultData->IsLateInit() ) - return; - - bInitialized = TRUE; - - if ( rParams.IsEnd( nPos ) /*nPos >= ppDim.size()*/) - // No next dimension. Bail out. - return; - - // skip child dimension if details are not shown - if ( GetDPMember() && !GetDPMember()->getShowDetails() ) - { - // Wang Xu Ming -- 2009-6-16 - // DataPilot Migration - // Show DataLayout dimention - nMemberStep = 1; - while ( !rParams.IsEnd( nPos ) ) - { - if ( rParams.GetDim( nPos ) ->getIsDataLayoutDimension() ) - { - if ( !pChildDimension ) - pChildDimension = new ScDPResultDimension( pResultData ); - rParams.SetInitChild( FALSE ); - pChildDimension->LateInitFrom( rParams, pItemData, nPos, rInitState ); - return; - } - else - { //find next dim - nPos ++; - nMemberStep ++; - } - } - // End Comments - bHasHiddenDetails = TRUE; // only if there is a next dimension - return; - } - - // LateInitFrom is called several times... - if ( rParams.GetInitChild() ) - { - if ( !pChildDimension ) - pChildDimension = new ScDPResultDimension( pResultData ); - pChildDimension->LateInitFrom( rParams, pItemData, nPos, rInitState ); - } -} - -BOOL ScDPNormalResultMember::IsSubTotalInTitle(long nMeasure) const -{ - BOOL bRet = FALSE; - if ( pChildDimension && /*pParentLevel*/GetParentLevel() && - /*pParentLevel*/GetParentLevel()->IsOutlineLayout() && /*pParentLevel*/GetParentLevel()->IsSubtotalsAtTop() ) - { - long nUserSubStart; - long nSubTotals = GetSubTotalCount( &nUserSubStart ); - nSubTotals -= nUserSubStart; // visible count - if ( nSubTotals ) - { - if ( nMeasure == SC_DPMEASURE_ALL ) - nSubTotals *= pResultData->GetMeasureCount(); // number of subtotals that will be inserted - - // only a single subtotal row will be shown in the outline title row - if ( nSubTotals == 1 ) - bRet = TRUE; - } - } - return bRet; -} - -long ScDPNormalResultMember::GetSize(long nMeasure) const -{ - if ( !IsVisible() ) - return 0; - const ScDPLevel* pParentLevel = GetParentLevel(); - long nExtraSpace = 0; - if ( pParentLevel && pParentLevel->IsAddEmpty() ) - ++nExtraSpace; - - if ( pChildDimension ) - { - // outline layout takes up an extra row for the title only if subtotals aren't shown in that row - if ( pParentLevel && pParentLevel->IsOutlineLayout() && !IsSubTotalInTitle( nMeasure ) ) - ++nExtraSpace; - - long nSize = pChildDimension->GetSize(nMeasure); - long nUserSubStart; - long nUserSubCount = GetSubTotalCount( &nUserSubStart ); - nUserSubCount -= nUserSubStart; // for output size, use visible count - if ( nUserSubCount ) - { - if ( nMeasure == SC_DPMEASURE_ALL ) - nSize += pResultData->GetMeasureCount() * nUserSubCount; - else - nSize += nUserSubCount; - } - return nSize + nExtraSpace; - } - else - { - if ( nMeasure == SC_DPMEASURE_ALL ) - return pResultData->GetMeasureCount() + nExtraSpace; - else - return 1 + nExtraSpace; - } -} - - -BOOL ScDPNormalResultMember::IsVisible() const -{ - // not initialized -> shouldn't be there at all - // (allocated only to preserve ordering) - const ScDPLevel* pParentLevel = GetParentLevel(); - return ( bHasElements || ( pParentLevel && pParentLevel->getShowEmpty() ) ) && IsValid() && bInitialized; -} - -BOOL ScDPNormalResultMember::IsValid() const -{ - // non-Valid members are left out of calculation - - // was member set no invisible at the DataPilotSource? - const ScDPMember* pMemberDesc =GetDPMember(); - if ( pMemberDesc && !pMemberDesc->getIsVisible() ) - return FALSE; - - if ( bAutoHidden ) - return FALSE; - - return TRUE; -} - -BOOL ScDPNormalResultMember::HasHiddenDetails() const -{ - // bHasHiddenDetails is set only if the "show details" flag is off, - // and there was a child dimension to skip - - return bHasHiddenDetails; -} - -long ScDPNormalResultMember::GetSubTotalCount( long* pUserSubStart ) const -{ - if ( pUserSubStart ) - *pUserSubStart = 0; // default - - const ScDPLevel* pParentLevel = GetParentLevel(); - - if ( bForceSubTotal ) // set if needed for root members - return 1; // grand total is always "automatic" - else if ( pParentLevel ) - { - //! direct access via ScDPLevel - - uno::Sequence<sheet::GeneralFunction> aSeq = pParentLevel->getSubTotals(); - long nSequence = aSeq.getLength(); - if ( nSequence && aSeq[0] != sheet::GeneralFunction_AUTO ) - { - // For manual subtotals, always add "automatic" as first function - // (used for calculation, but not for display, needed for sorting, see lcl_GetForceFunc) - - ++nSequence; - if ( pUserSubStart ) - *pUserSubStart = 1; // visible subtotals start at 1 - } - return nSequence; - } - else - return 0; -} - -void ScDPNormalResultMember::ProcessData( const vector< SCROW >& aChildMembers, const ScDPResultDimension* pDataDim, - const vector< SCROW >& aDataMembers, const vector<ScDPValueData>& aValues ) -{ - SetHasElements(); - - if (pChildDimension) - pChildDimension->ProcessData( aChildMembers, pDataDim, aDataMembers, aValues ); - - if ( !pDataRoot ) - { - pDataRoot = new ScDPDataMember( pResultData, NULL ); - if ( pDataDim ) - pDataRoot->InitFrom( pDataDim ); // recursive - } - - ScDPSubTotalState aSubState; // initial state - - long nUserSubCount = GetSubTotalCount(); - - // Calculate at least automatic if no subtotals are selected, - // show only own values if there's no child dimension (innermost). - if ( !nUserSubCount || !pChildDimension ) - nUserSubCount = 1; - - const ScDPLevel* pParentLevel = GetParentLevel(); - - for (long nUserPos=0; nUserPos<nUserSubCount; nUserPos++) // including hidden "automatic" - { - // #i68338# if nUserSubCount is 1 (automatic only), don't set nRowSubTotalFunc - if ( pChildDimension && nUserSubCount > 1 ) - { - aSubState.nRowSubTotalFunc = nUserPos; - aSubState.eRowForce = lcl_GetForceFunc( pParentLevel, nUserPos ); - } - - pDataRoot->ProcessData( aDataMembers, aValues, aSubState ); - } -} - -void ScDPNormalResultMember::FillMemberResults( uno::Sequence<sheet::MemberResult>* pSequences, - long& rPos, long nMeasure, BOOL bRoot, - const String* pMemberName, - const String* pMemberCaption ) -{ - // IsVisible() test is in ScDPResultDimension::FillMemberResults - // (not on data layout dimension) - - long nSize = GetSize(nMeasure); - sheet::MemberResult* pArray = pSequences->getArray(); - DBG_ASSERT( rPos+nSize <= pSequences->getLength(), "bumm" ); - - BOOL bIsNumeric = FALSE; - String aName; - if ( pMemberName ) // if pMemberName != NULL, use instead of real member name - aName = *pMemberName; - else - { - ScDPItemData aItemData; - FillItemData( aItemData ); - aName = aItemData.GetString(); - bIsNumeric = aItemData.IsValue(); - } - const ScDPDimension* pParentDim = GetParentDim(); - if ( bIsNumeric && pParentDim && pResultData->IsNumOrDateGroup( pParentDim->GetDimension() ) ) - { - // Numeric group dimensions use numeric entries for proper sorting, - // but the group titles must be output as text. - bIsNumeric = FALSE; - } - - String aCaption = aName; - if ( pMemberCaption ) // use pMemberCaption if != NULL - aCaption = *pMemberCaption; - if (!aCaption.Len()) - aCaption = ScGlobal::GetRscString(STR_EMPTYDATA); - - if ( !bIsNumeric ) - { - // add a "'" character so a string isn't parsed as value in the output cell - //! have a separate bit in Flags (MemberResultFlags) instead? - aCaption.Insert( (sal_Unicode) '\'', 0 ); - } - - if ( nSize && !bRoot ) // root is overwritten by first dimension - { - pArray[rPos].Name = rtl::OUString(aName); - pArray[rPos].Caption = rtl::OUString(aCaption); - pArray[rPos].Flags |= sheet::MemberResultFlags::HASMEMBER; - - // set "continue" flag (removed for subtotals later) - for (long i=1; i<nSize; i++) - pArray[rPos+i].Flags |= sheet::MemberResultFlags::CONTINUE; - } - - const ScDPLevel* pParentLevel = GetParentLevel(); - long nExtraSpace = 0; - if ( pParentLevel && pParentLevel->IsAddEmpty() ) - ++nExtraSpace; - - BOOL bTitleLine = FALSE; - if ( pParentLevel && pParentLevel->IsOutlineLayout() ) - bTitleLine = TRUE; - - // if the subtotals are shown at the top (title row) in outline layout, - // no extra row for the subtotals is needed - BOOL bSubTotalInTitle = IsSubTotalInTitle( nMeasure ); - - BOOL bHasChild = ( pChildDimension != NULL ); - if (bHasChild) - { - if ( bTitleLine ) // in tabular layout the title is on a separate row - ++rPos; // -> fill child dimension one row below - - if (bRoot) // same sequence for root member - pChildDimension->FillMemberResults( pSequences, rPos, nMeasure ); - else - // Wang Xu Ming -- 2009-6-16 - // DataPilot Migration - // for show details - pChildDimension->FillMemberResults( pSequences + nMemberStep/*1*/, rPos, nMeasure ); - // End Comments - - if ( bTitleLine ) // title row is included in GetSize, so the following - --rPos; // positions are calculated with the normal values - } - - rPos += nSize; - - long nUserSubStart; - long nUserSubCount = GetSubTotalCount(&nUserSubStart); - if ( nUserSubCount && pChildDimension && !bSubTotalInTitle ) - { - long nMemberMeasure = nMeasure; - long nSubSize = pResultData->GetCountForMeasure(nMeasure); - - rPos -= nSubSize * (nUserSubCount - nUserSubStart); // GetSize includes space for SubTotal - rPos -= nExtraSpace; // GetSize includes the empty line - - for (long nUserPos=nUserSubStart; nUserPos<nUserSubCount; nUserPos++) - { - for ( long nSubCount=0; nSubCount<nSubSize; nSubCount++ ) - { - if ( nMeasure == SC_DPMEASURE_ALL ) - nMemberMeasure = nSubCount; - - ScSubTotalFunc eForce = SUBTOTAL_FUNC_NONE; - if (bHasChild) - eForce = lcl_GetForceFunc( pParentLevel, nUserPos ); - - String aSubStr = aName; //! caption? - aSubStr += ' '; - aSubStr += pResultData->GetMeasureString(nMemberMeasure, FALSE, eForce); - - pArray[rPos].Name = rtl::OUString(aName); - pArray[rPos].Caption = rtl::OUString(aSubStr); - pArray[rPos].Flags = ( pArray[rPos].Flags | - ( sheet::MemberResultFlags::HASMEMBER | sheet::MemberResultFlags::SUBTOTAL) ) & - ~sheet::MemberResultFlags::CONTINUE; - - if ( nMeasure == SC_DPMEASURE_ALL ) - { - // data layout dimension is (direct/indirect) child of this. - // data layout dimension must have name for all entries. - - uno::Sequence<sheet::MemberResult>* pLayoutSeq = pSequences; - if (!bRoot) - ++pLayoutSeq; - ScDPResultDimension* pLayoutDim = pChildDimension; - while ( pLayoutDim && !pLayoutDim->IsDataLayout() ) - { - pLayoutDim = pLayoutDim->GetFirstChildDimension(); - ++pLayoutSeq; - } - if ( pLayoutDim ) - { - sheet::MemberResult* pLayoutArray = pLayoutSeq->getArray(); - String aDataName = pResultData->GetMeasureDimensionName(nMemberMeasure); - pLayoutArray[rPos].Name = rtl::OUString(aDataName); - } - } - - rPos += 1; - } - } - - rPos += nExtraSpace; // add again (subtracted above) - } -} - -void ScDPNormalResultMember::FillDataResults( const ScDPResultMember* pRefMember, - uno::Sequence< uno::Sequence<sheet::DataResult> >& rSequence, - long& rRow, long nMeasure ) const -{ - // IsVisible() test is in ScDPResultDimension::FillDataResults - // (not on data layout dimension) - const ScDPLevel* pParentLevel = GetParentLevel(); - long nStartRow = rRow; - - long nExtraSpace = 0; - if ( pParentLevel && pParentLevel->IsAddEmpty() ) - ++nExtraSpace; - - BOOL bTitleLine = FALSE; - if ( pParentLevel && pParentLevel->IsOutlineLayout() ) - bTitleLine = TRUE; - - BOOL bSubTotalInTitle = IsSubTotalInTitle( nMeasure ); - - BOOL bHasChild = ( pChildDimension != NULL ); - if (bHasChild) - { - if ( bTitleLine ) // in tabular layout the title is on a separate row - ++rRow; // -> fill child dimension one row below - - pChildDimension->FillDataResults( pRefMember, rSequence, rRow, nMeasure ); // doesn't modify rRow - rRow += (USHORT) GetSize( nMeasure ); - - if ( bTitleLine ) // title row is included in GetSize, so the following - --rRow; // positions are calculated with the normal values - } - - long nUserSubStart; - long nUserSubCount = GetSubTotalCount(&nUserSubStart); - if ( nUserSubCount || !bHasChild ) - { - // Calculate at least automatic if no subtotals are selected, - // show only own values if there's no child dimension (innermost). - if ( !nUserSubCount || !bHasChild ) - { - nUserSubCount = 1; - nUserSubStart = 0; - } - - long nMemberMeasure = nMeasure; - long nSubSize = pResultData->GetCountForMeasure(nMeasure); - if (bHasChild) - { - rRow -= nSubSize * ( nUserSubCount - nUserSubStart ); // GetSize includes space for SubTotal - rRow -= nExtraSpace; // GetSize includes the empty line - } - - long nMoveSubTotal = 0; - if ( bSubTotalInTitle ) - { - nMoveSubTotal = rRow - nStartRow; // force to first (title) row - rRow = nStartRow; - } - - if ( pDataRoot ) - { - ScDPSubTotalState aSubState; // initial state - - for (long nUserPos=nUserSubStart; nUserPos<nUserSubCount; nUserPos++) - { - if ( bHasChild && nUserSubCount > 1 ) - { - aSubState.nRowSubTotalFunc = nUserPos; - aSubState.eRowForce = lcl_GetForceFunc( /*pParentLevel*/GetParentLevel() , nUserPos ); - } - - for ( long nSubCount=0; nSubCount<nSubSize; nSubCount++ ) - { - if ( nMeasure == SC_DPMEASURE_ALL ) - nMemberMeasure = nSubCount; - else if ( pResultData->GetColStartMeasure() == SC_DPMEASURE_ALL ) - nMemberMeasure = SC_DPMEASURE_ALL; - - DBG_ASSERT( rRow < rSequence.getLength(), "bumm" ); - uno::Sequence<sheet::DataResult>& rSubSeq = rSequence.getArray()[rRow]; - long nSeqCol = 0; - pDataRoot->FillDataRow( pRefMember, rSubSeq, nSeqCol, nMemberMeasure, bHasChild, aSubState ); - - rRow += 1; - } - } - } - else - rRow += nSubSize * ( nUserSubCount - nUserSubStart ); // empty rows occur when ShowEmpty is true - - // add extra space again if subtracted from GetSize above, - // add to own size if no children - rRow += nExtraSpace; - - rRow += nMoveSubTotal; - } -} - -void ScDPNormalResultMember::UpdateDataResults( const ScDPResultMember* pRefMember, long nMeasure ) const -{ - // IsVisible() test is in ScDPResultDimension::FillDataResults - // (not on data layout dimension) - - BOOL bHasChild = ( pChildDimension != NULL ); - - long nUserSubCount = GetSubTotalCount(); - // process subtotals even if not shown -// if ( nUserSubCount || !bHasChild ) - { - // Calculate at least automatic if no subtotals are selected, - // show only own values if there's no child dimension (innermost). - if ( !nUserSubCount || !bHasChild ) - nUserSubCount = 1; - - long nMemberMeasure = nMeasure; - long nSubSize = pResultData->GetCountForMeasure(nMeasure); - - if ( pDataRoot ) - { - ScDPSubTotalState aSubState; // initial state - - for (long nUserPos=0; nUserPos<nUserSubCount; nUserPos++) // including hidden "automatic" - { - if ( bHasChild && nUserSubCount > 1 ) - { - aSubState.nRowSubTotalFunc = nUserPos; - aSubState.eRowForce = lcl_GetForceFunc( /*pParentLevel*/GetParentLevel() , nUserPos ); - } - - for ( long nSubCount=0; nSubCount<nSubSize; nSubCount++ ) - { - if ( nMeasure == SC_DPMEASURE_ALL ) - nMemberMeasure = nSubCount; - else if ( pResultData->GetColStartMeasure() == SC_DPMEASURE_ALL ) - nMemberMeasure = SC_DPMEASURE_ALL; - - pDataRoot->UpdateDataRow( pRefMember, nMemberMeasure, bHasChild, aSubState ); - } - } - } - } - - if (bHasChild) // child dimension must be processed last, so the column total is known - { - pChildDimension->UpdateDataResults( pRefMember, nMeasure ); - } -} - -void ScDPNormalResultMember::SortMembers( ScDPResultMember* pRefMember ) -{ - BOOL bHasChild = ( pChildDimension != NULL ); - if (bHasChild) - pChildDimension->SortMembers( pRefMember ); // sorting is done at the dimension - - if ( IsRoot() && pDataRoot ) - { - // use the row root member to sort columns - // sub total count is always 1 - - pDataRoot->SortMembers( pRefMember ); - } -} - -void ScDPNormalResultMember::DoAutoShow( ScDPResultMember* pRefMember ) -{ - BOOL bHasChild = ( pChildDimension != NULL ); - if (bHasChild) - pChildDimension->DoAutoShow( pRefMember ); // sorting is done at the dimension - - if ( IsRoot()&& pDataRoot ) - { - // use the row root member to sort columns - // sub total count is always 1 - - pDataRoot->DoAutoShow( pRefMember ); - } -} - -void ScDPNormalResultMember::ResetResults( BOOL bRoot ) -{ - if (pDataRoot) - pDataRoot->ResetResults(); - - if (pChildDimension) - pChildDimension->ResetResults(); - -// Wang Xu Ming -- 3/4/2009 -// Dim refresh and filter. SODC_19023 - // if (!bRoot) - // bHasElements = FALSE; -// End Comments -} - -void ScDPNormalResultMember::UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure, - ScDPRunningTotalState& rRunning, ScDPRowTotals& rTotals ) const -{ - // IsVisible() test is in ScDPResultDimension::FillDataResults - // (not on data layout dimension) - - rTotals.SetInColRoot( IsRoot() ); - - BOOL bHasChild = ( pChildDimension != NULL ); - - long nUserSubCount = GetSubTotalCount(); - if ( nUserSubCount || !bHasChild ) - { - // Calculate at least automatic if no subtotals are selected, - // show only own values if there's no child dimension (innermost). - if ( !nUserSubCount || !bHasChild ) - nUserSubCount = 1; - - long nMemberMeasure = nMeasure; - long nSubSize = pResultData->GetCountForMeasure(nMeasure); - - if ( pDataRoot ) - { - ScDPSubTotalState aSubState; // initial state - - for (long nUserPos=0; nUserPos<nUserSubCount; nUserPos++) // including hidden "automatic" - { - if ( bHasChild && nUserSubCount > 1 ) - { - aSubState.nRowSubTotalFunc = nUserPos; - aSubState.eRowForce = lcl_GetForceFunc( /*pParentLevel*/GetParentLevel(), nUserPos ); - } - - for ( long nSubCount=0; nSubCount<nSubSize; nSubCount++ ) - { - if ( nMeasure == SC_DPMEASURE_ALL ) - nMemberMeasure = nSubCount; - else if ( pResultData->GetColStartMeasure() == SC_DPMEASURE_ALL ) - nMemberMeasure = SC_DPMEASURE_ALL; - - pDataRoot->UpdateRunningTotals( pRefMember, nMemberMeasure, - bHasChild, aSubState, rRunning, rTotals, *this ); - } - } - } - } - - if (bHasChild) // child dimension must be processed last, so the column total is known - { - pChildDimension->UpdateRunningTotals( pRefMember, nMeasure, rRunning, rTotals ); - } -} - -void ScDPNormalResultMember::DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const -{ - lcl_DumpRow( String::CreateFromAscii("ScDPResultMember"), GetName(), NULL, pDoc, rPos ); - SCROW nStartRow = rPos.Row(); - - if (pDataRoot) - pDataRoot->DumpState( pRefMember, pDoc, rPos ); - - if (pChildDimension) - pChildDimension->DumpState( pRefMember, pDoc, rPos ); - - lcl_Indent( pDoc, nStartRow, rPos ); -} - -ScDPAggData* ScDPNormalResultMember::GetColTotal( long nMeasure ) const -{ - return lcl_GetChildTotal( const_cast<ScDPAggData*>(&aColTotal), nMeasure ); -} - -void ScDPNormalResultMember::FillVisibilityData(ScDPResultVisibilityData& rData) const -{ - if (pChildDimension) - pChildDimension->FillVisibilityData(rData); -} -// Wang Xu Ming -- 2009-6-10 -// DataPilot Migration -SCROW ScDPNormalResultMember::GetDataId( ) const -{ -// TODO: - const ScDPMember* pMemberDesc = GetDPMember(); - if (pMemberDesc) - return pMemberDesc->GetItemDataId(); - return -1; -} - -// ----------------------------------------------------------------------- -ScDPHideDetailsMember:: ScDPHideDetailsMember( const ScDPResultData* pData, const ScDPParentDimData& rParentDimData, - BOOL bForceSub ):ScDPResultMember(pData,rParentDimData, bForceSub) -{ - pOrigMember = new ScDPNormalResultMember(pData,rParentDimData, bForceSub); - -}
\ No newline at end of file diff --git a/sc/source/core/data/dptabresmember.hxx b/sc/source/core/data/dptabresmember.hxx deleted file mode 100644 index 72657167d07d..000000000000 --- a/sc/source/core/data/dptabresmember.hxx +++ /dev/null @@ -1,161 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright IBM Corporation 2009. - * Copyright 2009 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: dptabresmember.hxx,v $ - * $Revision: 1.0 $ - * - * 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. - * - ************************************************************************/ - -#ifndef DPTABRESMEMBER_HXX -#define DPTABRESMEMBER_HXX - -class ScDPNormalResultMember: public ScDPResultMember -{ -private: - // Wang Xu Ming -- 2009-6-9 - // DataPilot Migration - ScDPParentDimData aParentDimData; - // End Comments - BOOL bHasElements:1; - BOOL bForceSubTotal:1; - BOOL bHasHiddenDetails:1; - BOOL bInitialized:1; - BOOL bAutoHidden:1; - ScDPAggData aColTotal; // to store column totals - -// Wang Xu Ming -- 2009-6-9 -// DataPilot Migration - USHORT nMemberStep; // step to show details -// End Comments -public: - // Wang Xu Ming -- 2009-6-9 - // DataPilot Migration - ScDPNormalResultMember( const ScDPResultData* pData, const ScDPParentDimData& rParentDimData, - BOOL bForceSub ); //! Ref - ScDPNormalResultMember( const ScDPResultData* pData, BOOL bForceSub ); - // End Comments - ~ScDPNormalResultMember(); - - // Wang Xu Ming -- 2009-6-9 - // DataPilot Migration - // Add parameter: BOOL bInitChild - void InitFrom( const ::std::vector<ScDPDimension*>& ppDim, - const ::std::vector<ScDPLevel*>& ppLev, - size_t nPos, - ScDPInitState& rInitState, - BOOL bInitChild = TRUE ); - // End Comments - // Wang Xu Ming -- 2009-6-9 - // DataPilot Migration - void LateInitFrom( - LateInitParams& rParams, - const ::std::vector< SCROW >& pItemData, - size_t nPos, - ScDPInitState& rInitState); - // End Comments - - String GetName() const; - void FillItemData( ScDPItemData& rData ) const; - BOOL IsValid() const; - BOOL IsVisible() const; - long GetSize(long nMeasure) const; - BOOL HasHiddenDetails() const; - BOOL IsSubTotalInTitle(long nMeasure) const; - -// BOOL SubTotalEnabled() const; - long GetSubTotalCount( long* pUserSubStart = NULL ) const; - -// Wang Xu Ming -- 2009-6-9 -// DataPilot Migration -// Use item index -// BOOL IsNamedItem( const ScDPItemData& r ) const; - BOOL IsNamedItem( SCROW nIndex ) const; -// End Comments - bool IsValidEntry( const ::std::vector< SCROW >& aMembers ) const; - ENTRYSTATUS GetEntryStatus( const ::std::vector<SCROW>& aMembers ) const; - - void SetHasElements() { bHasElements = TRUE; } - void SetAutoHidden() { bAutoHidden = TRUE; } - - void ProcessData( const ::std::vector<SCROW>& aChildMembers, - const ScDPResultDimension* pDataDim, - const ::std::vector<SCROW>& aDataMembers, - const ::std::vector<ScDPValueData>& aValues ); - - void FillMemberResults( com::sun::star::uno::Sequence< - com::sun::star::sheet::MemberResult>* pSequences, - long& rPos, long nMeasure, BOOL bRoot, - const String* pMemberName, - const String* pMemberCaption ); - - void FillDataResults( const ScDPResultMember* pRefMember, - com::sun::star::uno::Sequence< - com::sun::star::uno::Sequence< - com::sun::star::sheet::DataResult> >& rSequence, - long& rRow, long nMeasure ) const; - - void UpdateDataResults( const ScDPResultMember* pRefMember, long nMeasure ) const; - void UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure, - ScDPRunningTotalState& rRunning, ScDPRowTotals& rTotals ) const; - - void SortMembers( ScDPResultMember* pRefMember ); - void DoAutoShow( ScDPResultMember* pRefMember ); - - void ResetResults( BOOL bRoot ); - - void DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const; - - // Wang Xu Ming -- 2009-6-9 - // DataPilot Migration - const ScDPDimension* GetParentDim() const { return aParentDimData.mpParentDim; } //! Ref - const ScDPLevel* GetParentLevel() const { return aParentDimData.mpParentLevel; } //! Ref - const ScDPMember* GetDPMember()const { return aParentDimData.mpMemberDesc; } //! Ref - inline SCROW GetOrder() const { return aParentDimData.mnOrder; } //! Ref - inline BOOL IsRoot() const { return GetParentLevel() == NULL; } - // End Comments - - ScDPAggData* GetColTotal( long nMeasure ) const; - - void FillVisibilityData(ScDPResultVisibilityData& rData) const; -// Wang Xu Ming -- 2009-6-10 -// DataPilot Migration - SCROW GetDataId( ) const ; -// End Comments -}; - -class ScDPHideDetailsMember: public ScDPResultMember -{ -private: - ScDPNormalResultMember * pOrigMember; -public: - ScDPHideDetailsMember( const ScDPResultData* pData, const ScDPParentDimData& rParentDimData, - BOOL bForceSub ); - - -}; - - -#endif //DPTABRESMEMBER_HXX diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx index c0ae60f13841..07b79c11b373 100644 --- a/sc/source/core/tool/addincol.cxx +++ b/sc/source/core/tool/addincol.cxx @@ -51,6 +51,7 @@ #include <com/sun/star/table/XCellRange.hpp> #include <com/sun/star/lang/Locale.hpp> #include <com/sun/star/sheet/XCompatibilityNames.hpp> +#include <com/sun/star/sheet/NoConvergenceException.hpp> #include "addincol.hxx" #include "addinhelpid.hxx" @@ -1582,9 +1583,13 @@ void ScUnoAddInCall::ExecuteCallWithArgs(uno::Sequence<uno::Any>& rCallArgs) if ( rWrapped.TargetException.getValueType().equals( getCppuType( (lang::IllegalArgumentException*)0 ) ) ) nErrCode = errIllegalArgument; + else if ( rWrapped.TargetException.getValueType().equals( + getCppuType( (sheet::NoConvergenceException*)0 ) ) ) + nErrCode = errNoConvergence; else nErrCode = errNoValue; } + catch(uno::Exception&) { nErrCode = errNoValue; diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index 5f4b86b7cd18..c28d295275ae 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -121,6 +121,24 @@ enum ScanState ssStop }; +// ODFF names that are not written in the current mapping but to be recognized. +// New names will be written in a future relase, then exchange (!) with the +// names in formula/source/core/resource/core_resource.src to be able to still +// read the old names as well. +struct FunctionName +{ + const sal_Char* pName; + OpCode eOp; +}; +static const FunctionName aOdffAliases[] = { + // Renamed old names: + // XXX none yet. + // Renamed new names: + { "BINOM.DIST.RANGE", ocB }, // B -> BINOM.DIST.RANGE + { "LEGACY.TDIST", ocTDist } // TDIST -> LEGACY.TDIST +}; +static const size_t nOdffAliases = sizeof(aOdffAliases) / sizeof(aOdffAliases[0]); + static const sal_Char* pInternal[ 1 ] = { "TTT" }; using namespace ::com::sun::star::i18n; @@ -2504,7 +2522,21 @@ BOOL ScCompiler::IsOpCode( const String& rName, bool bInArray ) aToken.SetOpCode(eOp); pRawToken = aToken.Clone(); } - else + else if (mxSymbols->isODFF()) + { + for (size_t i=0; i<nOdffAliases; ++i) + { + if (rName.EqualsIgnoreCaseAscii( aOdffAliases[i].pName)) + { + ScRawToken aToken; + aToken.SetOpCode( aOdffAliases[i].eOp); + pRawToken = aToken.Clone(); + bFound = TRUE; + break; // for + } + } + } + if (!bFound) { String aIntName; if (mxSymbols->hasExternals()) @@ -2887,6 +2919,7 @@ BOOL ScCompiler::IsReference( const String& rName ) BOOL ScCompiler::IsMacro( const String& rName ) { + String aName( rName); StarBASIC* pObj = 0; SfxObjectShell* pDocSh = pDoc->GetDocumentShell(); @@ -2898,7 +2931,14 @@ BOOL ScCompiler::IsMacro( const String& rName ) else pObj = pSfxApp->GetBasic(); - SbxMethod* pMeth = (SbxMethod*) pObj->Find( rName, SbxCLASS_METHOD ); + // ODFF recommends to store user-defined functions prefixed with "USER.", + // use only unprefixed name if encountered. BASIC doesn't allow '.' in a + // function name so a function "USER.FOO" could not exist, and macro check + // is assigned the lowest priority in function name check. + if (FormulaGrammar::isODFF( GetGrammar()) && aName.EqualsIgnoreCaseAscii( "USER.", 0, 5)) + aName.Erase( 0, 5); + + SbxMethod* pMeth = (SbxMethod*) pObj->Find( aName, SbxCLASS_METHOD ); if( !pMeth ) { pSfxApp->LeaveBasicCall(); @@ -2913,7 +2953,7 @@ BOOL ScCompiler::IsMacro( const String& rName ) return FALSE; } ScRawToken aToken; - aToken.SetExternal( rName.GetBuffer() ); + aToken.SetExternal( aName.GetBuffer() ); aToken.eOp = ocMacro; pRawToken = aToken.Clone(); pSfxApp->LeaveBasicCall(); diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx index 93e529c4ceca..ba107347b46a 100644 --- a/sc/source/filter/xml/xmldpimp.cxx +++ b/sc/source/filter/xml/xmldpimp.cxx @@ -464,6 +464,11 @@ void ScXMLDataPilotTableContext::EndElement() if (pDoc) { ScDPCollection* pDPCollection = pDoc->GetDPCollection(); + + // #i94570# Names have to be unique, or the tables can't be accessed by API. + if ( pDPCollection->GetByName(pDPObject->GetName()) ) + pDPObject->SetName( String() ); // ignore the invalid name, create a new name in AfterXMLLoading + pDPObject->SetAlive(sal_True); pDPCollection->InsertNewTable(pDPObject); } diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 9053e5395388..0563f6430063 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -3080,32 +3080,69 @@ void ScXMLExport::ExportShape(const uno::Reference < drawing::XShape >& xShape, if ( sCLSID.equalsIgnoreAsciiCase(GetChartExport()->getChartCLSID()) ) { // we have a chart - uno::Reference< frame::XModel > xChartModel; - if( ( xShapeProps->getPropertyValue( sPropModel ) >>= xChartModel ) && - xChartModel.is()) + ::rtl::OUString sRanges; + if ( pDoc ) { - uno::Reference< chart2::XChartDocument > xChartDoc( xChartModel, uno::UNO_QUERY ); - uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartModel, uno::UNO_QUERY ); - if( xChartDoc.is() && xReceiver.is() && - ! xChartDoc->hasInternalDataProvider()) + ::rtl::OUString aChartName; + xShapeProps->getPropertyValue( sPersistName ) >>= aChartName; + ScRange aEmptyRange; + ScChartListener aSearcher( aChartName, pDoc, aEmptyRange ); + USHORT nIndex = 0; + ScChartListenerCollection* pCollection = pDoc->GetChartListenerCollection(); + if ( pCollection && pCollection->Search( &aSearcher, nIndex ) ) { - // we have a chart that gets its data from Calc - bIsChart = true; - uno::Sequence< ::rtl::OUString > aRepresentations( - xReceiver->getUsedRangeRepresentations()); - SvXMLAttributeList* pAttrList = 0; - if(aRepresentations.getLength()) + ScChartListener* pListener = static_cast< ScChartListener* >( pCollection->At( nIndex ) ); + if ( pListener ) { - // add the ranges used by the chart to the shape - // element to be able to start listening after - // load (when the chart is not yet loaded) - uno::Reference< chart2::data::XRangeXMLConversion > xRangeConverter( xChartDoc->getDataProvider(), uno::UNO_QUERY ); - ::rtl::OUString sRanges( lcl_RangeSequenceToString( aRepresentations, xRangeConverter )); - pAttrList = new SvXMLAttributeList(); - pAttrList->AddAttribute( - GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW, GetXMLToken(XML_NOTIFY_ON_UPDATE_OF_RANGES) ), sRanges ); + const ScRangeListRef& rRangeList = pListener->GetRangeList(); + if ( rRangeList.Is() ) + { + ScRangeStringConverter::GetStringFromRangeList( sRanges, rRangeList, pDoc, FormulaGrammar::CONV_OOO ); + if ( sRanges.getLength() > 0 ) + { + bIsChart = true; + SvXMLAttributeList* pAttrList = new SvXMLAttributeList(); + if ( pAttrList ) + { + pAttrList->AddAttribute( + GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW, GetXMLToken( XML_NOTIFY_ON_UPDATE_OF_RANGES ) ), sRanges ); + } + GetShapeExport()->exportShape( xShape, SEF_EXPORT_NO_CHART_DATA | SEF_DEFAULT, pPoint, pAttrList ); + } + } + } + } + } + + if ( sRanges.getLength() == 0 ) + { + uno::Reference< frame::XModel > xChartModel; + if( ( xShapeProps->getPropertyValue( sPropModel ) >>= xChartModel ) && + xChartModel.is()) + { + uno::Reference< chart2::XChartDocument > xChartDoc( xChartModel, uno::UNO_QUERY ); + uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartModel, uno::UNO_QUERY ); + if( xChartDoc.is() && xReceiver.is() && + ! xChartDoc->hasInternalDataProvider()) + { + // we have a chart that gets its data from Calc + bIsChart = true; + uno::Sequence< ::rtl::OUString > aRepresentations( + xReceiver->getUsedRangeRepresentations()); + SvXMLAttributeList* pAttrList = 0; + if(aRepresentations.getLength()) + { + // add the ranges used by the chart to the shape + // element to be able to start listening after + // load (when the chart is not yet loaded) + uno::Reference< chart2::data::XRangeXMLConversion > xRangeConverter( xChartDoc->getDataProvider(), uno::UNO_QUERY ); + sRanges = lcl_RangeSequenceToString( aRepresentations, xRangeConverter ); + pAttrList = new SvXMLAttributeList(); + pAttrList->AddAttribute( + GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW, GetXMLToken(XML_NOTIFY_ON_UPDATE_OF_RANGES) ), sRanges ); + } + GetShapeExport()->exportShape(xShape, SEF_EXPORT_NO_CHART_DATA | SEF_DEFAULT, pPoint, pAttrList); } - GetShapeExport()->exportShape(xShape, SEF_EXPORT_NO_CHART_DATA | SEF_DEFAULT, pPoint, pAttrList); } } diff --git a/sc/source/ui/dbgui/asciiopt.cxx b/sc/source/ui/dbgui/asciiopt.cxx index cd1f85fb99cc..a22953ade25b 100644 --- a/sc/source/ui/dbgui/asciiopt.cxx +++ b/sc/source/ui/dbgui/asciiopt.cxx @@ -253,20 +253,13 @@ void ScAsciiOptions::ReadFromString( const String& rString ) eCharSet = ScGlobal::GetCharsetValue( aToken ); } - // Language - if (nCount >= 4) - { - aToken = rString.GetToken(3, ','); - eLang = static_cast<LanguageType>(aToken.ToInt32()); - } - // // Startzeile // - if ( nCount >= 5 ) + if ( nCount >= 4 ) { - aToken = rString.GetToken(4,','); + aToken = rString.GetToken(3,','); nStartRow = aToken.ToInt32(); } @@ -274,12 +267,12 @@ void ScAsciiOptions::ReadFromString( const String& rString ) // Spalten-Infos // - if ( nCount >= 6 ) + if ( nCount >= 5 ) { delete[] pColStart; delete[] pColFormat; - aToken = rString.GetToken(5,','); + aToken = rString.GetToken(4,','); nSub = aToken.GetTokenCount('/'); nInfoCount = nSub / 2; if (nInfoCount) @@ -299,6 +292,13 @@ void ScAsciiOptions::ReadFromString( const String& rString ) } } + // Language + if (nCount >= 6) + { + aToken = rString.GetToken(5, ','); + eLang = static_cast<LanguageType>(aToken.ToInt32()); + } + // Import quoted field as text. if (nCount >= 7) { @@ -362,10 +362,6 @@ String ScAsciiOptions::WriteToString() const aOutStr += ScGlobal::GetCharsetString( eCharSet ); aOutStr += ','; // Token-Ende - // Language - aOutStr += String::CreateFromInt32(eLang); - aOutStr += ','; - // // Startzeile // @@ -387,6 +383,13 @@ String ScAsciiOptions::WriteToString() const aOutStr += String::CreateFromInt32(pColFormat[nInfo]); } + // #i112025# the options string is used in macros and linked sheets, + // so new options must be added at the end, to remain compatible + + aOutStr += ','; + + // Language + aOutStr += String::CreateFromInt32(eLang); aOutStr += ','; // Import quoted field as text. diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx index e3f94199612a..cf149d258062 100644 --- a/sc/source/ui/docshell/dbdocfun.cxx +++ b/sc/source/ui/docshell/dbdocfun.cxx @@ -1278,6 +1278,13 @@ BOOL ScDBDocFunc::DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pNewOb // output range must be set at pNewObj pDestObj = new ScDPObject( *pNewObj ); + + // #i94570# When changing the output position in the dialog, a new table is created + // with the settings from the old table, including the name. + // So we have to check for duplicate names here (before inserting). + if ( pDoc->GetDPCollection()->GetByName(pDestObj->GetName()) ) + pDestObj->SetName( String() ); // ignore the invalid name, create a new name below + pDestObj->SetAlive(TRUE); if ( !pDoc->GetDPCollection()->InsertNewTable(pDestObj) ) { diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 9c45fc0093a1..a446c86b4d1b 100755 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -69,6 +69,9 @@ #include "chgviset.hxx" #include <sfx2/request.hxx> #include <com/sun/star/document/UpdateDocMode.hpp> +#include <com/sun/star/container/XContentEnumerationAccess.hpp> +#include <com/sun/star/sheet/XSpreadsheetView.hpp> +#include <com/sun/star/task/XJob.hpp> #include "scabstdlg.hxx" //CHINA001 @@ -352,6 +355,20 @@ void ScDocShell::AfterXMLLoading(sal_Bool bRet) // else; nothing has to happen, because it is a user given name } } + + // #i94570# DataPilot table names have to be unique, or the tables can't be accessed by API. + // If no name (or an invalid name, skipped in ScXMLDataPilotTableContext::EndElement) was set, create a new name. + ScDPCollection* pDPCollection = aDocument.GetDPCollection(); + if ( pDPCollection ) + { + USHORT nDPCount = pDPCollection->GetCount(); + for (USHORT nDP=0; nDP<nDPCount; nDP++) + { + ScDPObject* pDPObj = (*pDPCollection)[nDP]; + if ( !pDPObj->GetName().Len() ) + pDPObj->SetName( pDPCollection->CreateNewName() ); + } + } } ScColumn::bDoubleAlloc = sal_False; } @@ -458,7 +475,7 @@ BOOL __EXPORT ScDocShell::Load( SfxMedium& rMedium ) // only the latin script language is loaded // -> initialize the others from options (before loading) - InitOptions(); + InitOptions(true); GetUndoManager()->Clear(); @@ -582,6 +599,46 @@ void __EXPORT ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) } } } + + try + { + uno::Reference< uno::XComponentContext > xContext; + uno::Reference< lang::XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory(); + uno::Reference< beans::XPropertySet > xProp( xServiceManager, uno::UNO_QUERY_THROW ); + xProp->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ) >>= xContext; + if ( xContext.is() ) + { + uno::Reference< container::XContentEnumerationAccess > xEnumAccess( xServiceManager, uno::UNO_QUERY_THROW ); + uno::Reference< container::XEnumeration> xEnum = xEnumAccess->createContentEnumeration( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.SpreadsheetDocumentJob" ) ) ); + if ( xEnum.is() ) + { + while ( xEnum->hasMoreElements() ) + { + uno::Any aAny = xEnum->nextElement(); + uno::Reference< lang::XSingleComponentFactory > xFactory; + aAny >>= xFactory; + if ( xFactory.is() ) + { + uno::Reference< task::XJob > xJob( xFactory->createInstanceWithContext( xContext ), uno::UNO_QUERY_THROW ); + uno::Sequence< beans::NamedValue > aArgsForJob(1); + ScViewData* pViewData = GetViewData(); + SfxViewShell* pViewShell = ( pViewData ? pViewData->GetViewShell() : NULL ); + SfxViewFrame* pViewFrame = ( pViewShell ? pViewShell->GetViewFrame() : NULL ); + SfxFrame* pFrame = ( pViewFrame ? &pViewFrame->GetFrame() : NULL ); + uno::Reference< frame::XController > xController = ( pFrame ? pFrame->GetController() : 0 ); + uno::Reference< sheet::XSpreadsheetView > xSpreadsheetView( xController, uno::UNO_QUERY_THROW ); + aArgsForJob[0] = beans::NamedValue( ::rtl::OUString::createFromAscii( "SpreadsheetView" ), + uno::makeAny( xSpreadsheetView ) ); + xJob->execute( aArgsForJob ); + } + } + } + } + } + catch ( uno::Exception & ) + { + } } break; case SFX_EVENT_SAVEDOC: diff --git a/sc/source/ui/docshell/docsh2.cxx b/sc/source/ui/docshell/docsh2.cxx index 9e3ed217382f..14ff7622818c 100644 --- a/sc/source/ui/docshell/docsh2.cxx +++ b/sc/source/ui/docshell/docsh2.cxx @@ -93,7 +93,7 @@ BOOL __EXPORT ScDocShell::InitNew( const uno::Reference < embed::XStorage >& xSt aDocument.SetDrawDefaults(); // drawing layer defaults that are set only in InitNew // InitOptions sets the document languages, must be called before CreateStandardStyles - InitOptions(); + InitOptions(false); aDocument.GetStyleSheetPool()->CreateStandardStyles(); aDocument.UpdStlShtPtrsFrmNms(); diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx index 4709a065792f..233843935bbd 100644 --- a/sc/source/ui/docshell/docsh3.cxx +++ b/sc/source/ui/docshell/docsh3.cxx @@ -424,7 +424,7 @@ double ScDocShell::GetOutputFactor() const //--------------------------------------------------------------------- -void ScDocShell::InitOptions() // Fortsetzung von InitNew (CLOOKs) +void ScDocShell::InitOptions(bool bForLoading) // called from InitNew and Load { // Einstellungen aus dem SpellCheckCfg kommen in Doc- und ViewOptions @@ -440,6 +440,14 @@ void ScDocShell::InitOptions() // Fortsetzung von InitNew (CLOOKs) // zweistellige Jahreszahleneingabe aus Extras->Optionen->Allgemein->Sonstiges aDocOpt.SetYear2000( sal::static_int_cast<USHORT>( ::utl::MiscCfg().GetYear2000() ) ); + if (bForLoading) + { + // #i112123# No style:decimal-places attribute means automatic decimals, not the configured default, + // so it must not be taken from the global options. + // Calculation settings are handled separately in ScXMLBodyContext::EndElement. + aDocOpt.SetStdPrecision( SvNumberFormatter::UNLIMITED_PRECISION ); + } + aDocument.SetDocOptions( aDocOpt ); aDocument.SetViewOptions( aViewOpt ); diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index e4c02458ec6e..5b4fc6227225 100755 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -125,7 +125,7 @@ class SC_DLLPUBLIC ScDocShell: public SfxObjectShell, public SfxListener SC_DLLPRIVATE void InitItems(); SC_DLLPRIVATE void DoEnterHandler(); - SC_DLLPRIVATE void InitOptions(); + SC_DLLPRIVATE void InitOptions(bool bForLoading); SC_DLLPRIVATE void ResetDrawObjectShell(); // SUNWS needs a forward declared friend, otherwise types and members diff --git a/sc/source/ui/unoobj/chartuno.cxx b/sc/source/ui/unoobj/chartuno.cxx index 3b396d508238..86f59d66a7a4 100644 --- a/sc/source/ui/unoobj/chartuno.cxx +++ b/sc/source/ui/unoobj/chartuno.cxx @@ -31,10 +31,12 @@ #include <com/sun/star/embed/Aspects.hpp> #include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/chart2/data/XDataReceiver.hpp> #include <com/sun/star/chart/ChartDataRowSource.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/embed/Aspects.hpp> +#include <com/sun/star/table/CellRangeAddress.hpp> #include <svx/svditer.hxx> #include <svx/svdoole2.hxx> @@ -54,9 +56,12 @@ #include "chartlis.hxx" #include "unoguard.hxx" #include "chart2uno.hxx" +#include "convuno.hxx" using namespace com::sun::star; +#define PROP_HANDLE_RELATED_CELLRANGES 1 + //------------------------------------------------------------------------ SC_SIMPLE_SERVICE_INFO( ScChartObj, "ScChartObj", "com.sun.star.table.TableChart" ) @@ -451,12 +456,19 @@ sal_Bool SAL_CALL ScChartsObj::hasByName( const rtl::OUString& aName ) //------------------------------------------------------------------------ -ScChartObj::ScChartObj(ScDocShell* pDocSh, SCTAB nT, const String& rN) : - pDocShell( pDocSh ), - nTab( nT ), - aChartName( rN ) +ScChartObj::ScChartObj(ScDocShell* pDocSh, SCTAB nT, const String& rN) + :ScChartObj_Base( m_aMutex ) + ,ScChartObj_PBase( ScChartObj_Base::rBHelper ) + ,pDocShell( pDocSh ) + ,nTab( nT ) + ,aChartName( rN ) { pDocShell->GetDocument()->AddUnoObject(*this); + + uno::Sequence< table::CellRangeAddress > aInitialPropValue; + registerPropertyNoMember( ::rtl::OUString::createFromAscii( "RelatedCellRanges" ), + PROP_HANDLE_RELATED_CELLRANGES, beans::PropertyAttribute::MAYBEVOID, + ::getCppuType( &aInitialPropValue ), &aInitialPropValue ); } ScChartObj::~ScChartObj() @@ -552,6 +564,117 @@ void ScChartObj::Update_Impl( const ScRangeListRef& rRanges, bool bColHeaders, b } } +// ::comphelper::OPropertySetHelper + +::cppu::IPropertyArrayHelper& ScChartObj::getInfoHelper() +{ + return *ScChartObj_PABase::getArrayHelper(); +} + +void ScChartObj::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const uno::Any& rValue ) throw (uno::Exception) +{ + switch ( nHandle ) + { + case PROP_HANDLE_RELATED_CELLRANGES: + { + uno::Sequence< table::CellRangeAddress > aCellRanges; + if ( rValue >>= aCellRanges ) + { + ScRangeListRef rRangeList = new ScRangeList(); + const table::CellRangeAddress* pCellRanges = aCellRanges.getArray(); + sal_Int32 nCount = aCellRanges.getLength(); + for ( sal_Int32 i = 0; i < nCount; ++i ) + { + table::CellRangeAddress aCellRange = pCellRanges[ i ]; + ScRange aRange; + ScUnoConversion::FillScRange( aRange, aCellRange ); + rRangeList->Append( aRange ); + } + ScDocument* pDoc = ( pDocShell ? pDocShell->GetDocument() : NULL ); + ScChartListenerCollection* pCollection = ( pDoc ? pDoc->GetChartListenerCollection() : NULL ); + if ( pCollection ) + { + pCollection->ChangeListening( aChartName, rRangeList ); + } + } + } + break; + default: + { + } + break; + } +} + +void ScChartObj::getFastPropertyValue( uno::Any& rValue, sal_Int32 nHandle ) const +{ + switch ( nHandle ) + { + case PROP_HANDLE_RELATED_CELLRANGES: + { + ScDocument* pDoc = ( pDocShell ? pDocShell->GetDocument() : NULL ); + if ( pDoc ) + { + ScRange aEmptyRange; + USHORT nIndex = 0; + ScChartListener aSearcher( aChartName, pDoc, aEmptyRange ); + ScChartListenerCollection* pCollection = pDoc->GetChartListenerCollection(); + if ( pCollection && pCollection->Search( &aSearcher, nIndex ) ) + { + ScChartListener* pListener = static_cast< ScChartListener* >( pCollection->At( nIndex ) ); + if ( pListener ) + { + const ScRangeListRef& rRangeList = pListener->GetRangeList(); + if ( rRangeList.Is() ) + { + ULONG nCount = rRangeList->Count(); + uno::Sequence< table::CellRangeAddress > aCellRanges( nCount ); + table::CellRangeAddress* pCellRanges = aCellRanges.getArray(); + for ( USHORT i = 0; i < nCount; ++i ) + { + ScRange aRange( *rRangeList->GetObject( i ) ); + table::CellRangeAddress aCellRange; + ScUnoConversion::FillApiRange( aCellRange, aRange ); + pCellRanges[ i ] = aCellRange; + } + rValue <<= aCellRanges; + } + } + } + } + } + break; + default: + { + } + break; + } +} + +// ::comphelper::OPropertyArrayUsageHelper + +::cppu::IPropertyArrayHelper* ScChartObj::createArrayHelper() const +{ + uno::Sequence< beans::Property > aProps; + describeProperties( aProps ); + return new ::cppu::OPropertyArrayHelper( aProps ); +} + +// XInterface + +IMPLEMENT_FORWARD_XINTERFACE2( ScChartObj, ScChartObj_Base, ScChartObj_PBase ) + +// XTypeProvider + +IMPLEMENT_FORWARD_XTYPEPROVIDER2( ScChartObj, ScChartObj_Base, ScChartObj_PBase ) + +// XComponent + +void ScChartObj::disposing() +{ + ScChartObj_Base::disposing(); +} + // XTableChart sal_Bool SAL_CALL ScChartObj::getHasColumnHeaders() throw(uno::RuntimeException) @@ -681,6 +804,13 @@ void SAL_CALL ScChartObj::setName( const rtl::OUString& /* aName */ ) throw(uno: throw uno::RuntimeException(); // name cannot be changed } +// XPropertySet + +uno::Reference< beans::XPropertySetInfo > ScChartObj::getPropertySetInfo() throw (uno::RuntimeException) +{ + return createPropertySetInfo( getInfoHelper() ) ; +} + //------------------------------------------------------------------------ diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx index 35befa8f7a36..dbdeae1ae0b1 100755 --- a/sc/source/ui/view/dbfunc3.cxx +++ b/sc/source/ui/view/dbfunc3.cxx @@ -694,6 +694,9 @@ ULONG RefreshDPObject( ScDPObject *pDPObj, ScDocument *pDoc, ScDocShell *pDocSh, if( !pDPObj ) return STR_PIVOT_NOTFOUND; + if ( pDocSh && !pDoc ) + pDoc = pDocSh->GetDocument(); + if( !pDoc ) return static_cast<ULONG>(-1); diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index ef3c32abf5aa..b0b040f9b5e0 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -114,6 +114,7 @@ class ScDrawStringsVars long nMaxDigitWidth; long nSignWidth; long nDotWidth; + long nExpWidth; ScBaseCell* pLastCell; ULONG nValueFormat; @@ -173,6 +174,7 @@ private: long GetMaxDigitWidth(); long GetSignWidth(); long GetDotWidth(); + long GetExpWidth(); void TextChanged(); long ConvertWidthLogicToPixel( long nWidth ) const; }; @@ -193,6 +195,7 @@ ScDrawStringsVars::ScDrawStringsVars(ScOutputData* pData, BOOL bPTL) : nMaxDigitWidth( 0 ), nSignWidth( 0 ), nDotWidth( 0 ), + nExpWidth( 0 ), pLastCell ( NULL ), nValueFormat( 0 ), bLineBreak ( FALSE ), @@ -262,6 +265,7 @@ void ScDrawStringsVars::SetPattern( const ScPatternAttr* pNew, const SfxItemSet* nMaxDigitWidth = 0; nSignWidth = 0; nDotWidth = 0; + nExpWidth = 0; pPattern = pNew; pCondSet = pSet; @@ -417,6 +421,7 @@ void ScDrawStringsVars::SetPatternSimple( const ScPatternAttr* pNew, const SfxIt nMaxDigitWidth = 0; nSignWidth = 0; nDotWidth = 0; + nExpWidth = 0; // wird gerufen, wenn sich die Font-Variablen nicht aendern (!StringDiffer) pPattern = pNew; @@ -547,7 +552,7 @@ void ScDrawStringsVars::SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth ) // Failed to get output string. Bail out. return; - sal_uInt8 nSignCount = 0, nDecimalCount = 0; + sal_uInt8 nSignCount = 0, nDecimalCount = 0, nExpCount = 0; xub_StrLen nLen = aString.Len(); sal_Unicode cDecSep = ScGlobal::GetpLocaleData()->getLocaleItem().decimalSeparator.getStr()[0]; for (xub_StrLen i = 0; i < nLen; ++i) @@ -557,13 +562,17 @@ void ScDrawStringsVars::SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth ) ++nSignCount; else if (c == cDecSep) ++nDecimalCount; + else if (c == sal_Unicode('E')) + ++nExpCount; } if (nDecimalCount) nWidth += (nMaxDigit - GetDotWidth()) * nDecimalCount; if (nSignCount) nWidth += (nMaxDigit - GetSignWidth()) * nSignCount; + if (nExpCount) + nWidth += (nMaxDigit - GetExpWidth()) * nExpCount; - if (nDecimalCount || nSignCount) + if (nDecimalCount || nSignCount || nExpCount) { // Re-calculate. nNumDigits = static_cast<sal_uInt16>(nWidth / nMaxDigit); @@ -658,6 +667,17 @@ long ScDrawStringsVars::GetDotWidth() return nDotWidth; } +long ScDrawStringsVars::GetExpWidth() +{ + if (nExpWidth > 0) + return nExpWidth; + + nExpWidth = pOutput->pFmtDevice->GetTextWidth(String('E')); + if (bPixelToLogic) + nExpWidth = ConvertWidthLogicToPixel(nExpWidth); + return nExpWidth; +} + void ScDrawStringsVars::TextChanged() { OutputDevice* pRefDevice = pOutput->pRefDevice; |