Kaydet (Commit) ba8918ae authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Untangled the code a bit.

üst 654a5bdd
...@@ -1830,30 +1830,56 @@ void XclImpChSeries::ReadSubRecord( XclImpStream& rStrm ) ...@@ -1830,30 +1830,56 @@ void XclImpChSeries::ReadSubRecord( XclImpStream& rStrm )
} }
} }
void XclImpChSeries::SetDataFormat( XclImpChDataFormatRef xDataFmt ) void XclImpChSeries::SetDataFormat( const XclImpChDataFormatRef& xDataFmt )
{ {
if( xDataFmt ) if (!xDataFmt)
return;
sal_uInt16 nPointIdx = xDataFmt->GetPointPos().mnPointIdx;
if (nPointIdx == EXC_CHDATAFORMAT_ALLPOINTS)
{ {
XclImpChDataFormatRef* pxDataFmt = GetDataFormatRef( xDataFmt->GetPointPos().mnPointIdx ); if (mxSeriesFmt)
// do not overwrite existing data format // Don't overwrite the existing format.
if( pxDataFmt && !*pxDataFmt ) return;
{
*pxDataFmt = xDataFmt; mxSeriesFmt = xDataFmt;
// #i51639# register series format index at chart type group if (HasParentSeries())
if( (pxDataFmt == &mxSeriesFmt) && !HasParentSeries() ) return;
if( XclImpChTypeGroup* pTypeGroup = GetChartData().GetTypeGroup( mnGroupIdx ).get() )
pTypeGroup->SetUsedFormatIndex( xDataFmt->GetFormatIdx() ); XclImpChTypeGroupRef pTypeGroup = GetChartData().GetTypeGroup(mnGroupIdx);
} if (pTypeGroup)
pTypeGroup->SetUsedFormatIndex(xDataFmt->GetFormatIdx());
return;
}
if (nPointIdx >= EXC_CHDATAFORMAT_MAXPOINTCOUNT)
// Above the max point count. Bail out.
return;
XclImpChDataFormatMap::iterator itr = maPointFmts.lower_bound(nPointIdx);
if (itr == maPointFmts.end() || maPointFmts.key_comp()(nPointIdx, itr->first))
{
// No object exists at this point index position. Insert it.
itr = maPointFmts.insert(itr, XclImpChDataFormatMap::value_type(nPointIdx, xDataFmt));
} }
} }
void XclImpChSeries::SetDataLabel( XclImpChTextRef xLabel ) void XclImpChSeries::SetDataLabel( const XclImpChTextRef& xLabel )
{ {
if( xLabel ) if (!xLabel)
return;
sal_uInt16 nPointIdx = xLabel->GetPointPos().mnPointIdx;
if ((nPointIdx != EXC_CHDATAFORMAT_ALLPOINTS) && (nPointIdx >= EXC_CHDATAFORMAT_MAXPOINTCOUNT))
// Above the maximum allowed data points. Bail out.
return;
XclImpChTextMap::iterator itr = maLabels.lower_bound(nPointIdx);
if (itr == maLabels.end() || maLabels.key_comp()(nPointIdx, itr->first))
{ {
XclImpChTextRef* pxLabel = GetDataLabelRef( xLabel->GetPointPos().mnPointIdx ); // No object exists at this point index position. Insert it.
if( pxLabel && !*pxLabel ) itr = maLabels.insert(itr, XclImpChTextMap::value_type(nPointIdx, xLabel));
*pxLabel = xLabel;
} }
} }
...@@ -1911,11 +1937,28 @@ void XclImpChSeries::FinalizeDataFormats() ...@@ -1911,11 +1937,28 @@ void XclImpChSeries::FinalizeDataFormats()
// set text labels to data formats // set text labels to data formats
for( XclImpChTextMap::iterator aTIt = maLabels.begin(), aTEnd = maLabels.end(); aTIt != aTEnd; ++aTIt ) for( XclImpChTextMap::iterator aTIt = maLabels.begin(), aTEnd = maLabels.end(); aTIt != aTEnd; ++aTIt )
{ {
if( XclImpChDataFormatRef* pxDataFmt = GetDataFormatRef( aTIt->first ) ) sal_uInt16 nPointIdx = aTIt->first;
if (nPointIdx == EXC_CHDATAFORMAT_ALLPOINTS)
{ {
if( !*pxDataFmt ) if (!mxSeriesFmt)
*pxDataFmt = CreateDataFormat( aTIt->first, EXC_CHDATAFORMAT_DEFAULT ); mxSeriesFmt = CreateDataFormat(nPointIdx, EXC_CHDATAFORMAT_DEFAULT);
(*pxDataFmt)->SetDataLabel( aTIt->second ); mxSeriesFmt->SetDataLabel(aTIt->second);
}
else if (nPointIdx < EXC_CHDATAFORMAT_MAXPOINTCOUNT)
{
XclImpChDataFormatRef p;
XclImpChDataFormatMap::iterator itr = maPointFmts.lower_bound(nPointIdx);
if (itr == maPointFmts.end() || maPointFmts.key_comp()(nPointIdx, itr->first))
{
// No object exists at this point index position. Insert
// a new one.
p = CreateDataFormat(nPointIdx, EXC_CHDATAFORMAT_DEFAULT);
itr = maPointFmts.insert(
itr, XclImpChDataFormatMap::value_type(nPointIdx, p));
}
else
p = itr->second;
p->SetDataLabel(aTIt->second);
} }
} }
...@@ -2108,43 +2151,6 @@ XclImpChDataFormatRef XclImpChSeries::CreateDataFormat( sal_uInt16 nPointIdx, sa ...@@ -2108,43 +2151,6 @@ XclImpChDataFormatRef XclImpChSeries::CreateDataFormat( sal_uInt16 nPointIdx, sa
return xDataFmt; return xDataFmt;
} }
XclImpChDataFormatRef* XclImpChSeries::GetDataFormatRef( sal_uInt16 nPointIdx )
{
if( nPointIdx == EXC_CHDATAFORMAT_ALLPOINTS )
return &mxSeriesFmt;
if (nPointIdx < EXC_CHDATAFORMAT_MAXPOINTCOUNT)
{
XclImpChDataFormatMap::iterator itr = maPointFmts.lower_bound(nPointIdx);
if (itr == maPointFmts.end() || maPointFmts.key_comp()(nPointIdx, itr->first))
{
// No object exists at this point index position. Insert a new
// placeholder.
XclImpChDataFormatRef p;
itr = maPointFmts.insert(itr, XclImpChDataFormatMap::value_type(nPointIdx, p));
}
return &itr->second;
}
return 0;
}
XclImpChTextRef* XclImpChSeries::GetDataLabelRef( sal_uInt16 nPointIdx )
{
if ((nPointIdx == EXC_CHDATAFORMAT_ALLPOINTS) || (nPointIdx < EXC_CHDATAFORMAT_MAXPOINTCOUNT))
{
XclImpChTextMap::iterator itr = maLabels.lower_bound(nPointIdx);
if (itr == maLabels.end() || maLabels.key_comp()(nPointIdx, itr->first))
{
// No object exists at this point index position. Insert a new
// placeholder.
XclImpChTextRef p;
itr = maLabels.insert(itr, XclImpChTextMap::value_type(nPointIdx, p));
}
return &itr->second;
}
return 0;
}
void XclImpChSeries::ConvertTrendLines( Reference< XDataSeries > xDataSeries ) const void XclImpChSeries::ConvertTrendLines( Reference< XDataSeries > xDataSeries ) const
{ {
Reference< XRegressionCurveContainer > xRegCurveCont( xDataSeries, UNO_QUERY ); Reference< XRegressionCurveContainer > xRegCurveCont( xDataSeries, UNO_QUERY );
......
...@@ -817,9 +817,9 @@ public: ...@@ -817,9 +817,9 @@ public:
virtual void ReadSubRecord( XclImpStream& rStrm ); virtual void ReadSubRecord( XclImpStream& rStrm );
/** Sets a data point or series format (CHDATAFORMAT group) for this series. */ /** Sets a data point or series format (CHDATAFORMAT group) for this series. */
void SetDataFormat( XclImpChDataFormatRef xDataFmt ); void SetDataFormat( const XclImpChDataFormatRef& xDataFmt );
/** Sets a label text (CHTEXT group) attached to a series or data point. */ /** Sets a label text (CHTEXT group) attached to a series or data point. */
void SetDataLabel( XclImpChTextRef xLabel ); void SetDataLabel( const XclImpChTextRef& xLabel );
/** Adds error bar settings from the passed series to the own series. */ /** Adds error bar settings from the passed series to the own series. */
void AddChildSeries( const XclImpChSeries& rSeries ); void AddChildSeries( const XclImpChSeries& rSeries );
/** Updates missing series formatting by using default formatting from axes sets. */ /** Updates missing series formatting by using default formatting from axes sets. */
...@@ -866,10 +866,6 @@ private: ...@@ -866,10 +866,6 @@ private:
/** Creates a new CHDATAFORMAT group with the specified point index. */ /** Creates a new CHDATAFORMAT group with the specified point index. */
XclImpChDataFormatRef CreateDataFormat( sal_uInt16 nPointIdx, sal_uInt16 nFormatIdx ); XclImpChDataFormatRef CreateDataFormat( sal_uInt16 nPointIdx, sal_uInt16 nFormatIdx );
/** Returns the pointer to a CHDATAFORMAT group reference or 0 for invalid pointer index. */
XclImpChDataFormatRef* GetDataFormatRef( sal_uInt16 nPointIdx );
/** Returns the pointer to a CHTEXT group reference or 0 for invalid pointer index. */
XclImpChTextRef* GetDataLabelRef( sal_uInt16 nPointIdx );
/** Converts all trend lines and inserts them into the passed API data series object. */ /** Converts all trend lines and inserts them into the passed API data series object. */
void ConvertTrendLines( XDataSeriesRef xDataSeries ) const; void ConvertTrendLines( XDataSeriesRef xDataSeries ) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment