summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-03-27 20:35:34 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-03-28 01:12:50 -0400
commit49f9492358944b45cb9878aea0d6158df8301869 (patch)
tree235a79143c5a0815ad2559794f6f594430b26db5 /sc
parentf861f02ac9eadd9b3ab9f0b6c3c42e570805f537 (diff)
attrarray.cxx is now free of ScBaseCell.
Change-Id: I9a323062fc341ef5fc20f2922503a88f3a45ce0d
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/editutil.hxx2
-rw-r--r--sc/source/core/data/attarray.cxx34
-rw-r--r--sc/source/core/data/cell2.cxx19
-rw-r--r--sc/source/core/tool/editutil.cxx22
4 files changed, 45 insertions, 32 deletions
diff --git a/sc/inc/editutil.hxx b/sc/inc/editutil.hxx
index 5f979cbe75aa..f18c094a9079 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 9d1996aac3f2..29522130e0f1 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 cacd5e135b5c..297f8d020f80 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 53f36adedf63..4e1955ce7494 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 )