From be261b47da03943078f6efcdebf6a9d4d6a8a1fe Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Wed, 2 Jun 2010 16:27:29 +0200 Subject: calc55: #i112025# new csv import options must be at the end of the options string --- sc/source/ui/dbgui/asciiopt.cxx | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/sc/source/ui/dbgui/asciiopt.cxx b/sc/source/ui/dbgui/asciiopt.cxx index 9f48f794d..54bc80746 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(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(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. -- cgit v1.2.3 From eb8f96ee443dac6497ac28358f63b14e1154768f Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Thu, 3 Jun 2010 20:06:50 +0200 Subject: calc55: #i112071# property DataFieldCount is optional --- sc/source/core/data/dpoutput.cxx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx index e3e69cb19..9e045f9c7 100755 --- a/sc/source/core/data/dpoutput.cxx +++ b/sc/source/core/data/dpoutput.cxx @@ -1119,9 +1119,9 @@ void ScDPOutput::GetPositionData(const ScAddress& rPos, DataPilotTablePositionDa Reference 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; } @@ -1201,14 +1201,14 @@ bool ScDPOutput::GetDataResultPositionData(vector& 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; bool bColGrand = bool(); - any = xPropSet->getPropertyValue(rtl::OUString::createFromAscii(SC_UNO_COLGRAND)); + Any any = xPropSet->getPropertyValue(rtl::OUString::createFromAscii(SC_UNO_COLGRAND)); if (!(any >>= bColGrand)) return false; -- cgit v1.2.3 From 68339f9f1013911a226c8d365f258196e890a9df Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Fri, 4 Jun 2010 14:00:08 +0200 Subject: calc55: #i112116# width of 'E' can be different from digits --- sc/source/ui/view/output2.cxx | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index efec05242..216c5d5fa 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(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; -- cgit v1.2.3 From af6ccc27c22a9fd072a324e033a36dc02d46e350 Mon Sep 17 00:00:00 2001 From: Ingrid Halama Date: Fri, 4 Jun 2010 18:22:13 +0200 Subject: calc55: #i112035# loading some old chart document fails --- chart2/source/tools/WrappedPropertySet.cxx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/chart2/source/tools/WrappedPropertySet.cxx b/chart2/source/tools/WrappedPropertySet.cxx index 29db225d4..f66d16d0c 100644 --- a/chart2/source/tools/WrappedPropertySet.cxx +++ b/chart2/source/tools/WrappedPropertySet.cxx @@ -34,6 +34,8 @@ // header for define DELETEZ #include +#include + //............................................................................. namespace chart { @@ -115,7 +117,11 @@ void SAL_CALL WrappedPropertySet::setPropertyValue( const OUString& rPropertyNam else if( xInnerPropertySet.is() ) xInnerPropertySet->setPropertyValue( rPropertyName, rValue ); else - throw beans::UnknownPropertyException(); + { +#if OSL_DEBUG_LEVEL > 1 + DBG_ERROR("found no inner property set to map to"); +#endif + } } catch( beans::UnknownPropertyException& ex ) { @@ -160,7 +166,11 @@ Any SAL_CALL WrappedPropertySet::getPropertyValue( const OUString& rPropertyName else if( xInnerPropertySet.is() ) aRet = xInnerPropertySet->getPropertyValue( rPropertyName ); else - throw beans::UnknownPropertyException(); + { +#if OSL_DEBUG_LEVEL > 1 + DBG_ERROR("found no inner property set to map to"); +#endif + } } catch( beans::UnknownPropertyException& ex ) { -- cgit v1.2.3 From 2efe6e005b73f734d38fe5c2fae770982d07b166 Mon Sep 17 00:00:00 2001 From: Thomas Benisch Date: Fri, 4 Jun 2010 18:43:36 +0200 Subject: calc55: #i112094# chart data table dialog cannot be disabled via UNO API --- .../chartapiwrapper/ChartDocumentWrapper.cxx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx index fba67df65..8c3187234 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -160,7 +160,9 @@ enum PROP_DOCUMENT_BASEDIAGRAM, PROP_DOCUMENT_ADDITIONAL_SHAPES, PROP_DOCUMENT_UPDATE_ADDIN, - PROP_DOCUMENT_NULL_DATE + PROP_DOCUMENT_NULL_DATE, + PROP_DOCUMENT_DISABLE_COMPLEX_CHARTTYPES, + PROP_DOCUMENT_DISABLE_DATATABLE_DIALOG }; void lcl_AddPropertiesToVector( @@ -231,6 +233,19 @@ void lcl_AddPropertiesToVector( PROP_DOCUMENT_NULL_DATE, ::getCppuType( static_cast< const ::com::sun::star::util::DateTime * >(0)), beans::PropertyAttribute::MAYBEVOID )); + + rOutProperties.push_back( + Property( C2U( "DisableComplexChartTypes" ), + PROP_DOCUMENT_DISABLE_COMPLEX_CHARTTYPES, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT ) ); + rOutProperties.push_back( + Property( C2U( "DisableDataTableDialog" ), + PROP_DOCUMENT_DISABLE_DATATABLE_DIALOG, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT ) ); } const uno::Sequence< Property > & lcl_GetPropertySequence() @@ -1570,6 +1585,8 @@ const std::vector< WrappedProperty* > ChartDocumentWrapper::createWrappedPropert aWrappedProperties.push_back( new WrappedAdditionalShapesProperty( *this ) ); aWrappedProperties.push_back( new WrappedRefreshAddInAllowedProperty( *this ) ); aWrappedProperties.push_back( new WrappedIgnoreProperty( C2U("NullDate"),Any() ) ); // i99104 + aWrappedProperties.push_back( new WrappedIgnoreProperty( C2U( "DisableComplexChartTypes" ), uno::makeAny( sal_False ) ) ); + aWrappedProperties.push_back( new WrappedIgnoreProperty( C2U( "DisableDataTableDialog" ), uno::makeAny( sal_False ) ) ); return aWrappedProperties; } -- cgit v1.2.3 From c92f98fc5fca3a8efa0016f84b85a07aee7c5144 Mon Sep 17 00:00:00 2001 From: Thomas Benisch Date: Fri, 4 Jun 2010 18:44:00 +0200 Subject: calc55: #i112094# chart data table dialog cannot be disabled via UNO API --- chart2/source/controller/dialogs/res_ErrorBar.cxx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/chart2/source/controller/dialogs/res_ErrorBar.cxx b/chart2/source/controller/dialogs/res_ErrorBar.cxx index 482286ec8..7a1c337d2 100644 --- a/chart2/source/controller/dialogs/res_ErrorBar.cxx +++ b/chart2/source/controller/dialogs/res_ErrorBar.cxx @@ -37,6 +37,7 @@ #include "RangeSelectionHelper.hxx" // for RANGE_SELECTION_INVALID_RANGE_BACKGROUND_COLOR #include "TabPageNotifiable.hxx" +#include "macros.hxx" #include #include @@ -147,7 +148,8 @@ ErrorBarResources::ErrorBarResources( Window* pParent, Dialog * pParentDialog, m_pParentWindow( pParent ), m_pParentDialog( pParentDialog ), m_pCurrentRangeChoosingField( 0 ), - m_bHasInternalDataProvider( true ) + m_bHasInternalDataProvider( true ), + m_bDisableDataTableDialog( false ) { if( m_bNoneAvailable ) m_aRbNone.SetClickHdl( LINK( this, ErrorBarResources, CategoryChosen )); @@ -197,7 +199,21 @@ void ErrorBarResources::SetChartDocumentForRangeChoosing( const uno::Reference< chart2::XChartDocument > & xChartDocument ) { if( xChartDocument.is()) + { m_bHasInternalDataProvider = xChartDocument->hasInternalDataProvider(); + uno::Reference< beans::XPropertySet > xProps( xChartDocument, uno::UNO_QUERY ); + if ( xProps.is() ) + { + try + { + xProps->getPropertyValue( C2U( "DisableDataTableDialog" ) ) >>= m_bDisableDataTableDialog; + } + catch( uno::Exception& e ) + { + ASSERT_EXCEPTION( e ); + } + } + } m_apRangeSelectionHelper.reset( new RangeSelectionHelper( xChartDocument )); // has internal data provider => rename "cell range" to "from data" @@ -240,6 +256,7 @@ void ErrorBarResources::UpdateControlStates() m_aLbFunction.Enable( bIsFunction ); // range buttons + m_aRbRange.Enable( !m_bHasInternalDataProvider || !m_bDisableDataTableDialog ); bool bShowRange = ( m_aRbRange.IsChecked()); bool bCanChooseRange = ( bShowRange && -- cgit v1.2.3 From 87fe723f239e147a52facb8cb807b466af13e78e Mon Sep 17 00:00:00 2001 From: Thomas Benisch Date: Fri, 4 Jun 2010 18:44:19 +0200 Subject: calc55: #i112094# chart data table dialog cannot be disabled via UNO API --- chart2/source/controller/dialogs/tp_ChartType.cxx | 26 ++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/chart2/source/controller/dialogs/tp_ChartType.cxx b/chart2/source/controller/dialogs/tp_ChartType.cxx index 81a97b750..fbfc9cac9 100644 --- a/chart2/source/controller/dialogs/tp_ChartType.cxx +++ b/chart2/source/controller/dialogs/tp_ChartType.cxx @@ -853,15 +853,35 @@ ChartTypeTabPage::ChartTypeTabPage( Window* pParent bool bIsHighContrast = ( true && GetSettings().GetStyleSettings().GetHighContrastMode() ); + bool bDisableComplexChartTypes = false; + uno::Reference< beans::XPropertySet > xProps( m_xChartModel, uno::UNO_QUERY ); + if ( xProps.is() ) + { + try + { + xProps->getPropertyValue( C2U( "DisableComplexChartTypes" ) ) >>= bDisableComplexChartTypes; + } + catch( uno::Exception& e ) + { + ASSERT_EXCEPTION( e ); + } + } + m_aChartTypeDialogControllerList.push_back(new ColumnChartDialogController() ); m_aChartTypeDialogControllerList.push_back(new BarChartDialogController() ); m_aChartTypeDialogControllerList.push_back(new PieChartDialogController() ); m_aChartTypeDialogControllerList.push_back(new AreaChartDialogController() ); m_aChartTypeDialogControllerList.push_back(new LineChartDialogController() ); - m_aChartTypeDialogControllerList.push_back(new XYChartDialogController() ); - m_aChartTypeDialogControllerList.push_back(new BubbleChartDialogController() ); + if ( !bDisableComplexChartTypes ) + { + m_aChartTypeDialogControllerList.push_back(new XYChartDialogController() ); + m_aChartTypeDialogControllerList.push_back(new BubbleChartDialogController() ); + } m_aChartTypeDialogControllerList.push_back(new NetChartDialogController() ); - m_aChartTypeDialogControllerList.push_back(new StockChartDialogController() ); + if ( !bDisableComplexChartTypes ) + { + m_aChartTypeDialogControllerList.push_back(new StockChartDialogController() ); + } m_aChartTypeDialogControllerList.push_back(new CombiColumnLineChartDialogController() ); ::std::vector< ChartTypeDialogController* >::const_iterator aIter = m_aChartTypeDialogControllerList.begin(); -- cgit v1.2.3 From 67b42548422c5df51a799c78cfbea89fa8612439 Mon Sep 17 00:00:00 2001 From: Thomas Benisch Date: Fri, 4 Jun 2010 18:44:46 +0200 Subject: calc55: #i112094# chart data table dialog cannot be disabled via UNO API --- chart2/source/controller/inc/res_ErrorBar.hxx | 1 + 1 file changed, 1 insertion(+) diff --git a/chart2/source/controller/inc/res_ErrorBar.hxx b/chart2/source/controller/inc/res_ErrorBar.hxx index 94ed46178..f0007199c 100644 --- a/chart2/source/controller/inc/res_ErrorBar.hxx +++ b/chart2/source/controller/inc/res_ErrorBar.hxx @@ -135,6 +135,7 @@ private: m_apRangeSelectionHelper; Edit * m_pCurrentRangeChoosingField; bool m_bHasInternalDataProvider; + bool m_bDisableDataTableDialog; DECL_LINK( CategoryChosen, void * ); DECL_LINK( SynchronizePosAndNeg, void * ); -- cgit v1.2.3 From 415dfb2195079ea24a957b79a003830ed104b7a2 Mon Sep 17 00:00:00 2001 From: Thomas Benisch Date: Fri, 4 Jun 2010 18:45:09 +0200 Subject: calc55: #i112094# chart data table dialog cannot be disabled via UNO API --- .../controller/main/ControllerCommandDispatch.cxx | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/chart2/source/controller/main/ControllerCommandDispatch.cxx b/chart2/source/controller/main/ControllerCommandDispatch.cxx index 3eef0396f..c62de3dfe 100644 --- a/chart2/source/controller/main/ControllerCommandDispatch.cxx +++ b/chart2/source/controller/main/ControllerCommandDispatch.cxx @@ -528,6 +528,23 @@ void ControllerCommandDispatch::updateCommandAvailability() bool bShapeContext = ( m_pChartController ? m_pChartController->isShapeContext() : false ); + bool bDisableDataTableDialog = false; + if ( m_xController.is() ) + { + Reference< beans::XPropertySet > xProps( m_xController->getModel(), uno::UNO_QUERY ); + if ( xProps.is() ) + { + try + { + xProps->getPropertyValue( C2U( "DisableDataTableDialog" ) ) >>= bDisableDataTableDialog; + } + catch( uno::Exception& e ) + { + ASSERT_EXCEPTION( e ); + } + } + } + // edit commands m_aCommandAvailability[ C2U(".uno:Cut")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bIsDeleteableObjectSelected; m_aCommandAvailability[ C2U(".uno:Copy")] = bControllerStateIsValid && m_apControllerState->bHasSelectedObject; @@ -595,7 +612,7 @@ void ControllerCommandDispatch::updateCommandAvailability() // depending on own data m_aCommandAvailability[ C2U(".uno:DataRanges")] = bIsWritable && bModelStateIsValid && (! m_apModelState->bHasOwnData); - m_aCommandAvailability[ C2U(".uno:DiagramData")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasOwnData; + m_aCommandAvailability[ C2U(".uno:DiagramData")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasOwnData && !bDisableDataTableDialog; // titles m_aCommandAvailability[ C2U(".uno:MainTitle")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasMainTitle; @@ -631,9 +648,9 @@ void ControllerCommandDispatch::updateCommandAvailability() // series arrangement m_aCommandAvailability[ C2U(".uno:Forward")] = ( bShapeContext ? isShapeControllerCommandAvailable( C2U( ".uno:Forward" ) ) : - ( bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesForward ) ); + ( bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesForward && !bDisableDataTableDialog ) ); m_aCommandAvailability[ C2U(".uno:Backward")] = ( bShapeContext ? isShapeControllerCommandAvailable( C2U( ".uno:Backward" ) ) : - ( bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesBackward ) ); + ( bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesBackward && !bDisableDataTableDialog ) ); m_aCommandAvailability[ C2U(".uno:InsertDataLabels")] = bIsWritable; m_aCommandAvailability[ C2U(".uno:InsertDataLabel")] = bIsWritable; -- cgit v1.2.3 From 83f4f8b725a029dab48fedc29fd28605b6e9dadc Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Fri, 4 Jun 2010 18:59:28 +0200 Subject: calc55: #i112123# when loading, don't initialize StdPrecision in DocOptions from configuration --- sc/source/ui/docshell/docsh.cxx | 2 +- sc/source/ui/docshell/docsh2.cxx | 2 +- sc/source/ui/docshell/docsh3.cxx | 10 +++++++++- sc/source/ui/inc/docsh.hxx | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 3049f4889..500a92ca6 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -457,7 +457,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(); diff --git a/sc/source/ui/docshell/docsh2.cxx b/sc/source/ui/docshell/docsh2.cxx index a15935128..33bd6fbb1 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 5b2a323cd..2567408bb 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( ::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 beb3e4efd..5187be6e6 100644 --- 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 -- cgit v1.2.3 From 577c42293f4b89ad84048314679b6a3c1e3cb434 Mon Sep 17 00:00:00 2001 From: Thomas Benisch Date: Fri, 4 Jun 2010 20:08:33 +0200 Subject: calc55: #i112084# All charts in a Calc document are loaded when saving the document --- sc/inc/chartuno.hxx | 49 ++++++++++++-- sc/source/filter/xml/xmlexprt.cxx | 81 ++++++++++++++++------ sc/source/ui/docshell/docsh.cxx | 43 ++++++++++++ sc/source/ui/unoobj/chartuno.cxx | 138 ++++++++++++++++++++++++++++++++++++-- 4 files changed, 278 insertions(+), 33 deletions(-) diff --git a/sc/inc/chartuno.hxx b/sc/inc/chartuno.hxx index f5c2b758f..4545ad03f 100644 --- a/sc/inc/chartuno.hxx +++ b/sc/inc/chartuno.hxx @@ -31,7 +31,9 @@ #include "address.hxx" #include #include - +#include +#include + #include #include #include @@ -39,6 +41,7 @@ #include #include #include +#include #include @@ -113,12 +116,20 @@ public: }; -class ScChartObj : public cppu::WeakImplHelper4< - com::sun::star::table::XTableChart, - com::sun::star::document::XEmbeddedObjectSupplier, - com::sun::star::container::XNamed, - com::sun::star::lang::XServiceInfo >, - public SfxListener +typedef ::cppu::WeakComponentImplHelper4< + ::com::sun::star::table::XTableChart, + ::com::sun::star::document::XEmbeddedObjectSupplier, + ::com::sun::star::container::XNamed, + ::com::sun::star::lang::XServiceInfo > ScChartObj_Base; + +typedef ::comphelper::OPropertyContainer ScChartObj_PBase; +typedef ::comphelper::OPropertyArrayUsageHelper< ScChartObj > ScChartObj_PABase; + +class ScChartObj : public ::comphelper::OBaseMutex + ,public ScChartObj_Base + ,public ScChartObj_PBase + ,public ScChartObj_PABase + ,public SfxListener { private: ScDocShell* pDocShell; @@ -128,12 +139,32 @@ private: void Update_Impl( const ScRangeListRef& rRanges, bool bColHeaders, bool bRowHeaders ); void GetData_Impl( ScRangeListRef& rRanges, bool& rColHeaders, bool& rRowHeaders ) const; +protected: + // ::comphelper::OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) + throw (::com::sun::star::uno::Exception); + using ::cppu::OPropertySetHelper::getFastPropertyValue; + virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const; + + // ::comphelper::OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const; + public: ScChartObj(ScDocShell* pDocSh, SCTAB nT, const String& rN); virtual ~ScChartObj(); virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); + // XInterface + DECLARE_XINTERFACE() + + // XTypeProvider + DECLARE_XTYPEPROVIDER() + + // XComponent + virtual void SAL_CALL disposing(); + // XTableChart virtual sal_Bool SAL_CALL getHasColumnHeaders() throw(::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setHasColumnHeaders( sal_Bool bHasColumnHeaders ) @@ -163,6 +194,10 @@ public: throw(::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); }; #endif diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 1f16a6448..648a6a47e 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -3064,32 +3064,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/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 500a92ca6..15766f8d9 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -68,6 +68,9 @@ #include "chgviset.hxx" #include #include +#include +#include +#include #include "scabstdlg.hxx" //CHINA001 @@ -581,6 +584,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/unoobj/chartuno.cxx b/sc/source/ui/unoobj/chartuno.cxx index 6e0ecd21c..2fdbb04e4 100644 --- a/sc/source/ui/unoobj/chartuno.cxx +++ b/sc/source/ui/unoobj/chartuno.cxx @@ -31,10 +31,12 @@ #include #include +#include #include #include #include #include +#include #include #include @@ -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() ) ; +} + //------------------------------------------------------------------------ -- cgit v1.2.3 From bb551c49cfe1a5c922bc4fc3ddf00e1b9c930b82 Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Mon, 7 Jun 2010 13:42:16 +0200 Subject: calc55: #i112185# remove unreferenced files (implementation is in ScDPResultMember) --- sc/source/core/data/dptabresmember.cxx | 831 --------------------------------- sc/source/core/data/dptabresmember.hxx | 161 ------- 2 files changed, 992 deletions(-) delete mode 100644 sc/source/core/data/dptabresmember.cxx delete mode 100644 sc/source/core/data/dptabresmember.hxx diff --git a/sc/source/core/data/dptabresmember.cxx b/sc/source/core/data/dptabresmember.cxx deleted file mode 100644 index f820fdf99..000000000 --- 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 - * - * 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::const_iterator itr = aMembers.begin(); - vector aChildMembers(++itr, aMembers.end()); - return pChildDim->GetEntryStatus(aChildMembers); - } - else if( bHasHiddenDetails ) - return ENTRY_HASHIDDENDETAIL; - else - return ENTRY_VALID; -} - -void ScDPNormalResultMember::InitFrom( const vector& ppDim, const vector& 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& ppDim, const vector& 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 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& 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