Update to m13
[ooovba.git] / applied_patches / 0201-sc-speed-html-import-sizing.diff
blobbdee9a5b002610a0e12f9765e1fc3f7f1f3aaf23
1 diff -ur /opt/OpenOffice/svn-HEAD/build/ooo310-m4/sc/source/filter/html/htmlpars.cxx sc/source/filter/html/htmlpars.cxx
2 --- sc/source/filter/html/htmlpars.cxx
3 +++ sc/source/filter/html/htmlpars.cxx
4 @@ -2233,16 +2323,54 @@
6 SCCOLROW ScHTMLTable::GetDocSize( ScHTMLOrient eOrient, SCCOLROW nCellPos ) const
8 - const ScSizeVec& rSizes = maSizes[ eOrient ];
9 - return (static_cast< size_t >( nCellPos ) < rSizes.size()) ? rSizes[ nCellPos ] : 0;
10 + /* const ScSizeVec& rSizes = maSizes[ eOrient ];
11 + SCCOLROW nSize = (static_cast< size_t >( nCellPos ) < rSizes.size()) ? rSizes[ nCellPos ] : 0; */
13 + const ScCumlSizeVec& rCSizes = maCumlSizes[ eOrient ];
15 + if( static_cast< size_t >( nCellPos ) >= rCSizes.size() )
16 + return 0;
18 + SCCOLROW nLastSize = 0;
19 + if( nCellPos > 0 )
20 + nLastSize = rCSizes[ nCellPos - 1 ];
21 + SCCOLROW nRealSize = rCSizes[ nCellPos ] - nLastSize;
22 +/* if( nSize != nRealSize )
23 + {
24 + fprintf (stderr, "Size discrepancy at %d (%d vs %d)\n",
25 + (int)nCellPos, (int) nSize, (int) nRealSize);
26 + fprintf (stderr, "Table: ");
27 + for (size_t i = 0; i < rCSizes.size(); i++)
28 + fprintf (stderr, "%d ", rCSizes[i]);
29 + fprintf (stderr, "\n");
30 + for (size_t i = 0; i < rSizes.size(); i++)
31 + fprintf (stderr, "%d ", rSizes[i]);
32 + fprintf (stderr, "\n");
33 + }*/
34 + return nRealSize;
37 SCCOLROW ScHTMLTable::GetDocSize( ScHTMLOrient eOrient, SCCOLROW nCellBegin, SCCOLROW nCellEnd ) const
39 - SCCOLROW nSize = 0;
40 +/* SCCOLROW nSize = 0;
41 for( SCCOLROW nCellPos = nCellBegin; nCellPos < nCellEnd; ++nCellPos )
42 - nSize += GetDocSize( eOrient, nCellPos );
43 - return nSize;
44 + nSize += GetDocSize( eOrient, nCellPos ); */
46 + const ScCumlSizeVec& rCSizes = maCumlSizes[ eOrient ];
47 + SCCOLROW nFirstSize = 0;
48 + if( nCellBegin > 0 )
49 + nFirstSize = rCSizes[ nCellBegin - 1 ];
50 + SCCOLROW nLastSize = 0;
51 + if( nCellEnd > 0 )
52 + nLastSize = rCSizes[ nCellEnd - 1 ];
53 + SCCOLROW nRealSize = nLastSize - nFirstSize;
55 + /* if( nSize != nRealSize )
56 + {
57 + fprintf (stderr, "Multi-range size discrepancy at %d->before %d (%d vs %d)\n",
58 + (int)nCellBegin, (int)nCellEnd, (int) nSize, (int) nRealSize);
59 + } */
60 + return nRealSize;
63 SCCOLROW ScHTMLTable::GetDocSize( ScHTMLOrient eOrient ) const
64 @@ -2559,11 +2702,49 @@
66 void ScHTMLTable::SetDocSize( ScHTMLOrient eOrient, SCCOLROW nCellPos, SCCOLROW nSize )
68 - ScSizeVec& rSizes = maSizes[ eOrient ];
69 +/* ScSizeVec& rSizes = maSizes[ eOrient ];
70 if( static_cast< size_t >( nCellPos ) >= rSizes.size() )
71 rSizes.resize( static_cast< size_t >( nCellPos + 1 ), 1 ); // expand with minimum height/width == 1
72 if( rSizes[ nCellPos ] < nSize )
73 - rSizes[ nCellPos ] = nSize;
74 + rSizes[ nCellPos ] = nSize; */
76 + ScCumlSizeVec& rCSizes = maCumlSizes[ eOrient ];
77 + size_t oldSize = rCSizes.size();
78 + if( static_cast< size_t >( nCellPos ) >= rCSizes.size() )
79 + {
80 + rCSizes.resize( static_cast< size_t >( nCellPos + 1 ), 1 ); // expand with minimum height/width == 1
82 + // Fill out the expansion with the correct cumulative sizes
83 + SCCOLROW lastSize = 0;
84 + if( oldSize > 0 )
85 + lastSize = rCSizes[ oldSize - 1 ];
86 + for( size_t i = oldSize; i < rCSizes.size(); i++ )
87 + rCSizes[ i ] = ++lastSize;
88 + }
90 + // insert and shuffle everyone along a bit.
91 + // the common case is of no items to shuffle.
92 + {
93 + SCCOLROW nLastSize = 0;
94 + if( nCellPos > 0 )
95 + nLastSize = rCSizes[ nCellPos - 1 ];
97 + SCCOLROW curSize = rCSizes[ nCellPos ] - nLastSize;
98 + if( curSize < nSize )
99 + {
100 + for( size_t i = nCellPos; i < rCSizes.size(); i++ )
101 + rCSizes[ i ] += nSize - curSize;
104 +/* if (getenv ("INSSIZE")) {
105 + fprintf (stderr, "Table: ");
106 + for (size_t i = 0; i < rCSizes.size(); i++)
107 + fprintf (stderr, "%d ", rCSizes[i]);
108 + fprintf (stderr, "\n");
109 + for (size_t i = 0; i < rSizes.size(); i++)
110 + fprintf (stderr, "%d ", rSizes[i]);
111 + fprintf (stderr, "\n");
112 + }*/
115 void ScHTMLTable::CalcNeededDocSize(
117 diff -ur /opt/OpenOffice/svn-HEAD/build/ooo310-m4/sc/source/filter/inc/htmlpars.hxx sc/source/filter/inc/htmlpars.hxx
118 --- sc/source/filter/inc/htmlpars.hxx
119 +++ sc/source/filter/inc/htmlpars.hxx
120 @@ -461,7 +463,8 @@
121 private:
122 typedef ::std::auto_ptr< ScHTMLTableMap > ScHTMLTableMapPtr;
123 typedef ::std::auto_ptr< SfxItemSet > SfxItemSetPtr;
124 - typedef ::std::vector< SCCOLROW > ScSizeVec;
125 +// typedef ::std::vector< SCCOLROW > ScSizeVec;
126 + typedef ::std::vector< SCCOLROW > ScCumlSizeVec;
127 typedef ::std::list< ScHTMLEntry* > ScHTMLEntryList;
128 typedef ::std::map< ScHTMLPos, ScHTMLEntryList > ScHTMLEntryMap;
129 typedef ::std::auto_ptr< ScHTMLEntry > ScHTMLEntryPtr;
130 @@ -543,7 +546,8 @@
131 ScHTMLEntryMap maEntryMap; /// List of entries for each cell.
132 ScHTMLEntryList* mpCurrEntryList; /// Current entry list from map for faster access.
133 ScHTMLEntryPtr mpCurrEntry; /// Working entry, not yet inserted in a list.
134 - ScSizeVec maSizes[ 2 ]; /// Calc cell count of each HTML table column/row.
135 +// ScSizeVec maSizes[ 2 ]; /// non-cumulative cell count of each HTML table column/row.
136 + ScCumlSizeVec maCumlSizes[ 2 ]; /// Cumulative cell count of each HTML table column/row.
137 ScHTMLSize maSize; /// Size of the table.
138 ScHTMLPos maCurrCell; /// Address of current cell to fill.
139 ScHTMLPos maDocBasePos; /// Resulting base address in a Calc document.