Re: tnkk - r31324 - abiword/branches/gsoc2012table_headers/src/text/fmt/xp

From: Hubert Figuière <hfiguiere_at_teaser.fr>
Date: Thu May 31 2012 - 17:33:21 CEST

On 31/05/12 03:51 AM, cvs@abisource.com wrote:
> Modified: abiword/branches/gsoc2012table_headers/src/text/fmt/xp/fl_TableLayout.h
> ===================================================================
> --- abiword/branches/gsoc2012table_headers/src/text/fmt/xp/fl_TableLayout.h 2012-05-31 06:22:16 UTC (rev 31323)
> +++ abiword/branches/gsoc2012table_headers/src/text/fmt/xp/fl_TableLayout.h 2012-05-31 10:51:52 UTC (rev 31324)
> @@ -25,6 +25,7 @@
> #include <stdio.h>
> #endif
>
> +#include <vector>
> #include "ut_types.h"
> #include "ut_vector.h"
> #include "pt_Types.h"
> @@ -216,7 +217,7 @@
> { return m_bDoingDestructor;}
>
> //Table Header
> - UT_sint32 getHeaderRowNos() const { return m_iheaderRowNumber; }
> + std::vector<UT_sint32> getHeaderRowNos() const { return m_vHeaderRowNumber; }

Please return a const ref instead of a copy

> Modified: abiword/branches/gsoc2012table_headers/src/text/fmt/xp/fp_TableContainer.cpp
> ===================================================================
> --- abiword/branches/gsoc2012table_headers/src/text/fmt/xp/fp_TableContainer.cpp 2012-05-31 06:22:16 UTC (rev 31323)
> +++ abiword/branches/gsoc2012table_headers/src/text/fmt/xp/fp_TableContainer.cpp 2012-05-31 10:51:52 UTC (rev 31324)
[...]
> +void fp_TableContainer::populateCells(void)
> +{
> + int i,noOfColumns=getNumCols(),j;
> + std::vector<UT_sint32> headerRowNum = m_pTableHeader->getHeaderRowNos();
> + int totRows = headerRowNum.size();
> + for(j=0;j<totRows;j++)

declare headerRowNum as a const ref as well. No copy (see above for the
other change needed)

[...]

> +void fp_TableContainer::calculateHeaderHeight(void)
> +{
> + std::vector<UT_sint32> headerRowNum = m_pTableHeader->getHeaderRowNos();

Same

> + if(!headerRowNum.empty())
> + {
> + int totRows = headerRowNum.size();
> + int i;
> + fp_TableRowColumn * pRow;
> + for(i=0;i<totRows;i++)
> + {
> + pRow = getNthRow(headerRowNum.back()-1);
> + UT_sint32 iDefaultHeight = pRow->allocation;
> + m_pTableHeader->m_iHeaderHeight += fp_TableContainer::getRowHeight(headerRowNum.back(),iDefaultHeight);
> + headerRowNum.pop_back();

And instead of mutating the vector, just use a reverse iterator.

> Modified: abiword/branches/gsoc2012table_headers/src/text/fmt/xp/fp_TableContainer.h

[...]

> +class fp_TableHeader : public fp_TableContainer
> +{
> +
> +public:
> + fp_TableHeader(fl_SectionLayout *);
> + UT_sint32 getHeaderHeight(void) const
> + { return m_iHeaderHeight; }
> + std::vector<UT_sint32> getHeaderRowNos(void) const
> + { return m_vHeaderRowNumber; }

Again, return a const reference. Not a copy.

Cheers,

Hub
Received on Thu May 31 17:33:40 2012

This archive was generated by hypermail 2.1.8 : Thu May 31 2012 - 17:33:40 CEST