[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Wed Mar 27 17:35:51 PDT 2013
sc/inc/editutil.hxx | 2 ++
sc/source/core/data/attarray.cxx | 34 ++++++++++++++++++++--------------
sc/source/core/data/cell2.cxx | 19 +------------------
sc/source/core/tool/editutil.cxx | 22 ++++++++++++++++++++++
4 files changed, 45 insertions(+), 32 deletions(-)
New commits:
commit 9eac784a55158f6e51818d93fe94ae2bd4fef24e
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Wed Mar 27 20:35:34 2013 -0400
attrarray.cxx is now free of ScBaseCell.
Change-Id: I9a323062fc341ef5fc20f2922503a88f3a45ce0d
diff --git a/sc/inc/editutil.hxx b/sc/inc/editutil.hxx
index 5f979cb..f18c094 100644
--- a/sc/inc/editutil.hxx
+++ b/sc/inc/editutil.hxx
@@ -64,6 +64,8 @@ public:
static EditTextObject* CreateURLObjectFromURL(
ScDocument& rDoc, const OUString& rURL, const OUString& rText );
+ static void RemoveCharAttribs( EditTextObject& rEditText, const ScPatternAttr& rAttr );
+
public:
ScEditUtil( ScDocument* pDocument, SCCOL nX, SCROW nY, SCTAB nZ,
const Point& rScrPosPixel,
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 9d1996a..29522130 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include "attarray.hxx"
#include "scitems.hxx"
#include <svx/algitem.hxx>
#include <editeng/boxitem.hxx>
@@ -29,7 +30,6 @@
#include <editeng/fontitem.hxx>
#include <unotools/fontcvt.hxx>
-#include "attarray.hxx"
#include "global.hxx"
#include "document.hxx"
#include "docpool.hxx"
@@ -41,6 +41,8 @@
#include "globstr.hrc"
#include "segmenttree.hxx"
#include "cell.hxx"
+#include "cellvalue.hxx"
+#include "editutil.hxx"
#include <rtl/strbuf.hxx>
// STATIC DATA -----------------------------------------------------------
@@ -352,20 +354,24 @@ void ScAttrArray::RemoveCellCharAttribs( SCROW nStartRow, SCROW nEndRow,
{
for (SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow)
{
- ScBaseCell* pCell;
- pDocument->GetCell(nCol, nRow, nTab, pCell);
- if (pCell && pCell->GetCellType() == CELLTYPE_EDIT)
+ ScAddress aPos(nCol, nRow, nTab);
+ ScRefCellValue aCell;
+ aCell.assign(*pDocument, aPos);
+ if (aCell.meType != CELLTYPE_EDIT || !aCell.mpEditText)
+ continue;
+
+ EditTextObject* pOldData = NULL;
+ if (pDataArray)
+ pOldData = aCell.mpEditText->Clone();
+
+ // Direct modification of cell content - something to watch out for if
+ // we decide to share edit text instances in the future.
+ ScEditUtil::RemoveCharAttribs(const_cast<EditTextObject&>(*aCell.mpEditText), *pPattern);
+
+ if (pDataArray)
{
- EditTextObject* pOldData = NULL;
- ScEditCell* pEditCell = static_cast<ScEditCell*>(pCell);
- if (pDataArray)
- pOldData = pEditCell->GetData()->Clone();
- pEditCell->RemoveCharAttribs(*pPattern);
- if (pDataArray)
- {
- EditTextObject* pNewData = pEditCell->GetData()->Clone();
- pDataArray->AddItem(nTab, nCol, nRow, pOldData, pNewData);
- }
+ EditTextObject* pNewData = aCell.mpEditText->Clone();
+ pDataArray->AddItem(nTab, nCol, nRow, pOldData, pNewData);
}
}
}
diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx
index cacd5e1..297f8d0 100644
--- a/sc/source/core/data/cell2.cxx
+++ b/sc/source/core/data/cell2.cxx
@@ -146,24 +146,7 @@ const EditTextObject* ScEditCell::GetData() const
void ScEditCell::RemoveCharAttribs( const ScPatternAttr& rAttr )
{
- const struct {
- sal_uInt16 nAttrType;
- sal_uInt16 nCharType;
- } AttrTypeMap[] = {
- { ATTR_FONT, EE_CHAR_FONTINFO },
- { ATTR_FONT_HEIGHT, EE_CHAR_FONTHEIGHT },
- { ATTR_FONT_WEIGHT, EE_CHAR_WEIGHT },
- { ATTR_FONT_COLOR, EE_CHAR_COLOR }
- };
- sal_uInt16 nMapCount = sizeof (AttrTypeMap) / sizeof (AttrTypeMap[0]);
-
- const SfxItemSet& rSet = rAttr.GetItemSet();
- const SfxPoolItem* pItem;
- for (sal_uInt16 i = 0; i < nMapCount; ++i)
- {
- if ( rSet.GetItemState(AttrTypeMap[i].nAttrType, false, &pItem) == SFX_ITEM_SET )
- mpData->RemoveCharAttribs(AttrTypeMap[i].nCharType);
- }
+ ScEditUtil::RemoveCharAttribs(*mpData, rAttr);
}
void ScEditCell::UpdateFields(SCTAB nTab)
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx
index 53f36ad..4e1955c 100644
--- a/sc/source/core/tool/editutil.cxx
+++ b/sc/source/core/tool/editutil.cxx
@@ -114,6 +114,28 @@ EditTextObject* ScEditUtil::CreateURLObjectFromURL( ScDocument& rDoc, const OUSt
return rEE.CreateTextObject();
}
+void ScEditUtil::RemoveCharAttribs( EditTextObject& rEditText, const ScPatternAttr& rAttr )
+{
+ const struct {
+ sal_uInt16 nAttrType;
+ sal_uInt16 nCharType;
+ } AttrTypeMap[] = {
+ { ATTR_FONT, EE_CHAR_FONTINFO },
+ { ATTR_FONT_HEIGHT, EE_CHAR_FONTHEIGHT },
+ { ATTR_FONT_WEIGHT, EE_CHAR_WEIGHT },
+ { ATTR_FONT_COLOR, EE_CHAR_COLOR }
+ };
+ sal_uInt16 nMapCount = sizeof (AttrTypeMap) / sizeof (AttrTypeMap[0]);
+
+ const SfxItemSet& rSet = rAttr.GetItemSet();
+ const SfxPoolItem* pItem;
+ for (sal_uInt16 i = 0; i < nMapCount; ++i)
+ {
+ if ( rSet.GetItemState(AttrTypeMap[i].nAttrType, false, &pItem) == SFX_ITEM_SET )
+ rEditText.RemoveCharAttribs(AttrTypeMap[i].nCharType);
+ }
+}
+
//------------------------------------------------------------------------
Rectangle ScEditUtil::GetEditArea( const ScPatternAttr* pPattern, sal_Bool bForceToTop )
More information about the Libreoffice-commits
mailing list