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 )
}
}
void XclImpChSeries::SetDataFormat( XclImpChDataFormatRef xDataFmt )
void XclImpChSeries::SetDataFormat( const XclImpChDataFormatRef& xDataFmt )
{
if( xDataFmt )
{
XclImpChDataFormatRef* pxDataFmt = GetDataFormatRef( xDataFmt->GetPointPos().mnPointIdx );
// do not overwrite existing data format
if( pxDataFmt && !*pxDataFmt )
if (!xDataFmt)
return;
sal_uInt16 nPointIdx = xDataFmt->GetPointPos().mnPointIdx;
if (nPointIdx == EXC_CHDATAFORMAT_ALLPOINTS)
{
*pxDataFmt = xDataFmt;
// #i51639# register series format index at chart type group
if( (pxDataFmt == &mxSeriesFmt) && !HasParentSeries() )
if( XclImpChTypeGroup* pTypeGroup = GetChartData().GetTypeGroup( mnGroupIdx ).get() )
pTypeGroup->SetUsedFormatIndex( xDataFmt->GetFormatIdx() );
if (mxSeriesFmt)
// Don't overwrite the existing format.
return;
mxSeriesFmt = xDataFmt;
if (HasParentSeries())
return;
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 );
if( pxLabel && !*pxLabel )
*pxLabel = xLabel;
// No object exists at this point index position. Insert it.
itr = maLabels.insert(itr, XclImpChTextMap::value_type(nPointIdx, xLabel));
}
}
......@@ -1911,11 +1937,28 @@ void XclImpChSeries::FinalizeDataFormats()
// set text labels to data formats
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 )
*pxDataFmt = CreateDataFormat( aTIt->first, EXC_CHDATAFORMAT_DEFAULT );
(*pxDataFmt)->SetDataLabel( aTIt->second );
if (!mxSeriesFmt)
mxSeriesFmt = CreateDataFormat(nPointIdx, EXC_CHDATAFORMAT_DEFAULT);
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
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
{
Reference< XRegressionCurveContainer > xRegCurveCont( xDataSeries, UNO_QUERY );
......
......@@ -817,9 +817,9 @@ public:
virtual void ReadSubRecord( XclImpStream& rStrm );
/** 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. */
void SetDataLabel( XclImpChTextRef xLabel );
void SetDataLabel( const XclImpChTextRef& xLabel );
/** Adds error bar settings from the passed series to the own series. */
void AddChildSeries( const XclImpChSeries& rSeries );
/** Updates missing series formatting by using default formatting from axes sets. */
......@@ -866,10 +866,6 @@ private:
/** Creates a new CHDATAFORMAT group with the specified point index. */
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. */
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