sc/Library_sc.mk | 1 sc/inc/cell.hxx | 1 sc/inc/celltextwidths.hxx | 37 +++++++++++++++++++++++++++++++++ sc/source/core/data/cell.cxx | 1 sc/source/core/data/celltextwidths.cxx | 35 +++++++++++++++++++++++++++++++ sc/source/core/data/column.cxx | 18 ++-------------- sc/source/core/data/documen8.cxx | 1 sc/source/core/data/table1.cxx | 1 sc/source/core/data/table5.cxx | 2 + 9 files changed, 81 insertions(+), 16 deletions(-)
New commits: commit c3ff0f589a5cd22bda09a8e90e97f3da8810ad3a Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Wed Nov 7 09:30:48 2012 -0500 Let's use a separate class to manage storage of cell text widths. Change-Id: I5c823dea4d2e1fd17fae466be26ebff2aa24ecb6 diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk index 4ac291e..bef4866 100644 --- a/sc/Library_sc.mk +++ b/sc/Library_sc.mk @@ -93,6 +93,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\ sc/source/core/data/bcaslot \ sc/source/core/data/cell \ sc/source/core/data/cell2 \ + sc/source/core/data/celltextwidths \ sc/source/core/data/clipparam \ sc/source/core/data/column \ sc/source/core/data/column2 \ diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx index 79e99db..3ec6084 100644 --- a/sc/inc/cell.hxx +++ b/sc/inc/cell.hxx @@ -47,7 +47,6 @@ #include "scdllapi.h" #define USE_MEMPOOL -#define TEXTWIDTH_DIRTY 0xffff // in addition to SCRIPTTYPE_... flags from scripttypeitem.hxx: // set (in nScriptType) if type has not been determined yet diff --git a/sc/inc/celltextwidths.hxx b/sc/inc/celltextwidths.hxx new file mode 100644 index 0000000..ef4499b --- /dev/null +++ b/sc/inc/celltextwidths.hxx @@ -0,0 +1,37 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef __SC_CELLTEXTWIDTHS_HXX__ +#define __SC_CELLTEXTWIDTHS_HXX__ + +#include "address.hxx" +#include "sal/types.h" + +#include <mdds/multi_type_vector.hpp> +#include <mdds/multi_type_vector_trait.hpp> + +class ScCellTextWidths +{ + typedef mdds::multi_type_vector<mdds::mtv::element_block_func> StoreType; + StoreType maStore; + +public: + static sal_uInt16 Dirty; + + ScCellTextWidths(); + + sal_uInt16 get(SCROW nRow) const; + void set(SCROW nRow, sal_uInt16 nWidth); +}; + +#define TEXTWIDTH_DIRTY ScCellTextWidths::Dirty + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx index e27339e..c4325a5 100644 --- a/sc/source/core/data/cell.cxx +++ b/sc/source/core/data/cell.cxx @@ -49,6 +49,7 @@ #include "externalrefmgr.hxx" #include "macromgr.hxx" #include "dbdata.hxx" +#include "celltextwidths.hxx" #include <editeng/editobj.hxx> #include <svl/intitem.hxx> diff --git a/sc/source/core/data/celltextwidths.cxx b/sc/source/core/data/celltextwidths.cxx new file mode 100644 index 0000000..39240d3 --- /dev/null +++ b/sc/source/core/data/celltextwidths.cxx @@ -0,0 +1,35 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "celltextwidths.hxx" + +sal_uInt16 ScCellTextWidths::Dirty = 0xFFFF; + +ScCellTextWidths::ScCellTextWidths() : + maStore(MAXROWCOUNT) {} + +sal_uInt16 ScCellTextWidths::get(SCROW nRow) const +{ + switch (maStore.get_type(nRow)) + { + case mdds::mtv::element_type_ushort: + return maStore.get<unsigned short>(nRow); + default: + ; + } + return Dirty; +} + +void ScCellTextWidths::set(SCROW nRow, sal_uInt16 nWidth) +{ + // We only use unsigned short type in this container. + maStore.set(nRow, static_cast<unsigned short>(nWidth)); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 8c9c1c2..0323eaf 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -38,6 +38,7 @@ #include "markdata.hxx" #include "detfunc.hxx" // for Notes in Sort/Swap #include "postit.hxx" +#include "celltextwidths.hxx" #include <svl/poolcach.hxx> #include <svl/zforlist.hxx> @@ -45,8 +46,6 @@ #include <cstring> #include <map> -#include <mdds/multi_type_vector.hpp> -#include <mdds/multi_type_vector_trait.hpp> using ::editeng::SvxBorderLine; using namespace formula; @@ -66,11 +65,7 @@ inline bool IsAmbiguousScriptNonZero( sal_uInt8 nScript ) struct ScColumnImpl { - typedef mdds::multi_type_vector<mdds::mtv::element_block_func> TextWidthType; - - TextWidthType maTextWidths; - - ScColumnImpl() : maTextWidths(MAXROWCOUNT) {} + ScCellTextWidths maTextWidths; }; ScNeededSizeOptions::ScNeededSizeOptions() : @@ -2167,14 +2162,7 @@ bool ScColumn::SearchStyleRange( sal_uInt16 ScColumn::GetTextWidth(SCROW nRow) const { - switch (mpImpl->maTextWidths.get_type(nRow)) - { - case mdds::mtv::element_type_ushort: - return mpImpl->maTextWidths.get<unsigned short>(nRow); - default: - ; - } - return TEXTWIDTH_DIRTY; + return mpImpl->maTextWidths.get(nRow); } void ScColumn::SetTextWidth(SCROW nRow, sal_uInt16 nWidth) diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx index 4286cfd..ca97f9e 100644 --- a/sc/source/core/data/documen8.cxx +++ b/sc/source/core/data/documen8.cxx @@ -94,6 +94,7 @@ #include "dpobject.hxx" #include "docuno.hxx" #include "scresid.hxx" +#include "celltextwidths.hxx" #define GET_SCALEVALUE(set,id) ((const SfxUInt16Item&)(set.Get( id ))).GetValue() diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 3d28f54..53b3c23 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -53,6 +53,7 @@ #include "dbdata.hxx" #include "colorscale.hxx" #include "conditio.hxx" +#include "celltextwidths.hxx" #include <vector> diff --git a/sc/source/core/data/table5.cxx b/sc/source/core/data/table5.cxx index 3e244c2..8f7ec5e 100644 --- a/sc/source/core/data/table5.cxx +++ b/sc/source/core/data/table5.cxx @@ -45,6 +45,8 @@ #include "tabprotection.hxx" #include "globstr.hrc" #include "segmenttree.hxx" +#include "celltextwidths.hxx" + #include <com/sun/star/sheet/TablePageBreakData.hpp> #include <algorithm> _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits