[Libreoffice-commits] core.git: Branch 'feature/ods-edit-cell-import' - 2 commits - editeng/inc editeng/Package_inc.mk editeng/source sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Mon Feb 11 10:06:56 PST 2013
editeng/Package_inc.mk | 1
editeng/inc/editeng/editobj.hxx | 5 ++++
editeng/inc/editeng/flditem.hxx | 2 +
editeng/inc/editeng/macros.hxx | 17 ++++++++++++++
editeng/source/editeng/editobj.cxx | 42 ++++++++++++++++++++++++++++++++++++
editeng/source/editeng/editobj2.hxx | 8 ++++++
sc/source/filter/xml/xmlcelli.cxx | 42 ++++++++++++++++++++++++++----------
sc/source/filter/xml/xmlcelli.hxx | 31 ++++++++++++++++++--------
8 files changed, 128 insertions(+), 20 deletions(-)
New commits:
commit f922487c98acfcb614d83fa62255523f76bf1d3d
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Feb 11 13:07:15 2013 -0500
Add Dump() method to dump content of EditTextObject.
Useful during debugging. Turned off in the default build.
Change-Id: Ia0b280337707f762b90d1d80c04671f2e8c21b01
diff --git a/editeng/Package_inc.mk b/editeng/Package_inc.mk
index 5b107ca..2978ec1 100644
--- a/editeng/Package_inc.mk
+++ b/editeng/Package_inc.mk
@@ -83,6 +83,7 @@ $(eval $(call gb_Package_add_file,editeng_inc,inc/editeng/langitem.hxx,editeng/l
$(eval $(call gb_Package_add_file,editeng_inc,inc/editeng/lcolitem.hxx,editeng/lcolitem.hxx))
$(eval $(call gb_Package_add_file,editeng_inc,inc/editeng/lrspitem.hxx,editeng/lrspitem.hxx))
$(eval $(call gb_Package_add_file,editeng_inc,inc/editeng/lspcitem.hxx,editeng/lspcitem.hxx))
+$(eval $(call gb_Package_add_file,editeng_inc,inc/editeng/macros.hxx,editeng/macros.hxx))
$(eval $(call gb_Package_add_file,editeng_inc,inc/editeng/measfld.hxx,editeng/measfld.hxx))
$(eval $(call gb_Package_add_file,editeng_inc,inc/editeng/memberids.hrc,editeng/memberids.hrc))
$(eval $(call gb_Package_add_file,editeng_inc,inc/editeng/mutxhelp.hxx,editeng/mutxhelp.hxx))
diff --git a/editeng/inc/editeng/editobj.hxx b/editeng/inc/editeng/editobj.hxx
index 985b7c4..271a39b 100644
--- a/editeng/inc/editeng/editobj.hxx
+++ b/editeng/inc/editeng/editobj.hxx
@@ -28,6 +28,7 @@
#include <editeng/eeitem.hxx>
#include <editeng/editdata.hxx>
#include "editeng/editengdllapi.h"
+#include "editeng/macros.hxx"
#include <com/sun/star/text/textfield/Type.hpp>
@@ -118,6 +119,10 @@ public:
bool isWrongListEqual(const EditTextObject& rCompare) const;
virtual void ObjectInDestruction(const SfxItemPool& rSfxItemPool);
+
+#if DEBUG_EDIT_ENGINE
+ void Dump() const;
+#endif
};
#endif // _EDITOBJ_HXX
diff --git a/editeng/inc/editeng/flditem.hxx b/editeng/inc/editeng/flditem.hxx
index 1ced8ec..d3f2b36 100644
--- a/editeng/inc/editeng/flditem.hxx
+++ b/editeng/inc/editeng/flditem.hxx
@@ -28,6 +28,8 @@
#include <com/sun/star/text/textfield/Type.hpp>
+#include <boost/noncopyable.hpp>
+
namespace com { namespace sun { namespace star { namespace text {
class XTextContent;
diff --git a/editeng/inc/editeng/macros.hxx b/editeng/inc/editeng/macros.hxx
new file mode 100644
index 0000000..c667cfd
--- /dev/null
+++ b/editeng/inc/editeng/macros.hxx
@@ -0,0 +1,17 @@
+/* -*- 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 __EDITENGINE_MACROS_HXX__
+#define __EDITENGINE_MACROS_HXX__
+
+#define DEBUG_EDIT_ENGINE 0
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index 5f400be..2449787 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -27,6 +27,7 @@
#include <tools/stream.hxx>
#include "editeng/fieldupdater.hxx"
+#include "editeng/macros.hxx"
#include <editobj2.hxx>
#include <editeng/editdata.hxx>
#include <editattr.hxx>
@@ -39,11 +40,18 @@
#include <editeng/bulitem.hxx>
#include <editeng/numitem.hxx>
#include <editeng/brshitem.hxx>
+
#include <vcl/graph.hxx>
#include <svl/intitem.hxx>
#include <unotools/fontcvt.hxx>
#include <tools/tenccvt.hxx>
+#if DEBUG_EDIT_ENGINE
+#include <iostream>
+using std::cout;
+using std::endl;
+#endif
+
using namespace com::sun::star;
DBG_NAME( EE_EditTextObject )
@@ -154,6 +162,24 @@ bool ContentInfo::isWrongListEqual(const ContentInfo& rCompare) const
return (*GetWrongList() == *rCompare.GetWrongList());
}
+#if DEBUG_EDIT_ENGINE
+void ContentInfo::Dump() const
+{
+ cout << "--" << endl;
+ cout << "text: '" << aText << "'" << endl;
+ cout << "style: '" << aStyle << "'" << endl;
+
+ XEditAttributesType::const_iterator it = aAttribs.begin(), itEnd = aAttribs.end();
+ for (; it != itEnd; ++it)
+ {
+ const XEditAttribute& rAttr = *it;
+ cout << "attribute: " << endl;
+ cout << " span: [begin=" << rAttr.GetStart() << ", end=" << rAttr.GetEnd() << "]" << endl;
+ cout << " feature: " << (rAttr.IsFeature() ? "yes":"no") << endl;
+ }
+}
+#endif
+
bool ContentInfo::operator==( const ContentInfo& rCompare ) const
{
if( (aText == rCompare.aText) &&
@@ -393,6 +419,13 @@ void EditTextObject::ObjectInDestruction(const SfxItemPool& rSfxItemPool)
mpImpl->ObjectInDestruction(rSfxItemPool);
}
+#if DEBUG_EDIT_ENGINE
+void EditTextObject::Dump() const
+{
+ mpImpl->Dump();
+}
+#endif
+
// from SfxItemPoolUser
void EditTextObjectImpl::ObjectInDestruction(const SfxItemPool& rSfxItemPool)
{
@@ -422,6 +455,15 @@ void EditTextObjectImpl::ObjectInDestruction(const SfxItemPool& rSfxItemPool)
}
}
+#if DEBUG_EDIT_ENGINE
+void EditTextObjectImpl::Dump() const
+{
+ ContentInfosType::const_iterator it = aContents.begin(), itEnd = aContents.end();
+ for (; it != itEnd; ++it)
+ it->Dump();
+}
+#endif
+
EditEngineItemPool* getEditEngineItemPool(SfxItemPool* pPool)
{
EditEngineItemPool* pRetval = dynamic_cast< EditEngineItemPool* >(pPool);
diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx
index 4d8923f..ef213f0 100644
--- a/editeng/source/editeng/editobj2.hxx
+++ b/editeng/source/editeng/editobj2.hxx
@@ -149,6 +149,10 @@ public:
// #i102062#
bool isWrongListEqual(const ContentInfo& rCompare) const;
+
+#if DEBUG_EDIT_ENGINE
+ void Dump() const;
+#endif
};
class EditTextObjectImpl : boost::noncopyable
@@ -245,6 +249,10 @@ public:
// from SfxItemPoolUser
void ObjectInDestruction(const SfxItemPool& rSfxItemPool);
+
+#if DEBUG_EDIT_ENGINE
+ void Dump() const;
+#endif
};
#endif // _EDITOBJ2_HXX
commit 112feca1715b70b9dc896ff654e977b14dadb156
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Feb 11 13:06:03 2013 -0500
Fix sheet name field import.
Change-Id: Idcdabe026dfb775b4bf1fca6c7cb3c58c242d647
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 47aa7ee..aff762f 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -78,7 +78,6 @@
#include "editeng/escpitem.hxx"
#include "editeng/emphitem.hxx"
#include "editeng/langitem.hxx"
-#include "editeng/flditem.hxx"
#include <svx/unoapi.hxx>
#include <svl/languageoptions.hxx>
#include <sax/tools/converter.hxx>
@@ -117,6 +116,13 @@ using namespace xmloff::token;
ScXMLTableRowCellContext::ParaFormat::ParaFormat(ScEditEngineDefaulter& rEditEngine) :
maItemSet(rEditEngine.GetEmptyItemSet()) {}
+ScXMLTableRowCellContext::Field::Field() : mpItem(NULL) {}
+
+ScXMLTableRowCellContext::Field::~Field()
+{
+ delete mpItem;
+}
+
ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport,
sal_uInt16 nPrfx,
const ::rtl::OUString& rLName,
@@ -146,8 +152,7 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport,
bFormulaTextResult(false),
mbPossibleErrorCell(false),
mbCheckWithCompilerForError(false),
- mbEditEngineHasText(false),
- mbEditEngineHasField(false)
+ mbEditEngineHasText(false)
{
rtl::math::setNan(&fValue); // NaN by default
mpEditEngine->Clear();
@@ -554,9 +559,16 @@ void ScXMLTableRowCellContext::PushParagraphSpan(const OUString& rSpan, const OU
void ScXMLTableRowCellContext::PushParagraphFieldSheetName()
{
- SvxTableField aField(0);
- mpEditEngine->QuickInsertField(SvxFieldItem(aField, EE_FEATURE_FIELD), ESelection(EE_PARA_APPEND, EE_PARA_APPEND));
- mbEditEngineHasField = true;
+ SCTAB nTab = GetScImport().GetTables().GetCurrentCellPos().Tab();
+ maFields.push_back(new Field);
+ Field& rField = maFields.back();
+ rField.mpItem = new SvxTableField(nTab);
+ sal_Int32 nPos = maParagraph.getLength();
+ maParagraph.append(sal_Unicode('\1'));
+ rField.maSelection.nStartPara = mnCurParagraph;
+ rField.maSelection.nEndPara = mnCurParagraph;
+ rField.maSelection.nStartPos = nPos;
+ rField.maSelection.nEndPos = nPos+1;
}
void ScXMLTableRowCellContext::PushParagraphEnd()
@@ -998,17 +1010,25 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos,
pNewCell = ScBaseCell::CreateTextCell( *maStringValue, pDoc );
else if (mbEditEngineHasText)
{
- if (!mbEditEngineHasField && maFormats.empty() && mpEditEngine->GetParagraphCount() == 1)
+ if (maFields.empty() && maFormats.empty() && mpEditEngine->GetParagraphCount() == 1)
{
// This is a normal text without format runs.
pNewCell = new ScStringCell(mpEditEngine->GetText());
}
else
{
- // This text either has format runs, or consists of multiple lines.
- ParaFormatsType::const_iterator it = maFormats.begin(), itEnd = maFormats.end();
- for (; it != itEnd; ++it)
- mpEditEngine->QuickSetAttribs(it->maItemSet, it->maSelection);
+ // This text either has format runs, has field(s), or consists of multiple lines.
+ {
+ ParaFormatsType::const_iterator it = maFormats.begin(), itEnd = maFormats.end();
+ for (; it != itEnd; ++it)
+ mpEditEngine->QuickSetAttribs(it->maItemSet, it->maSelection);
+ }
+
+ {
+ FieldsType::const_iterator it = maFields.begin(), itEnd = maFields.end();
+ for (; it != itEnd; ++it)
+ mpEditEngine->QuickInsertField(SvxFieldItem(*it->mpItem, EE_FEATURE_FIELD), it->maSelection);
+ }
pNewCell = new ScEditCell(mpEditEngine->CreateTextObject(), pDoc, pDoc->GetEditPool());
}
diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx
index bdb817c..20f4465 100644
--- a/sc/source/filter/xml/xmlcelli.hxx
+++ b/sc/source/filter/xml/xmlcelli.hxx
@@ -25,10 +25,12 @@
#include "formula/grammar.hxx"
#include "svl/itemset.hxx"
#include "editeng/editdata.hxx"
+#include "editeng/flditem.hxx"
#include <boost/optional.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
+#include <boost/noncopyable.hpp>
class ScXMLImport;
class ScFormulaCell;
@@ -37,6 +39,25 @@ struct ScXMLAnnotationData;
class ScXMLTableRowCellContext : public ScXMLImportContext
{
+ struct ParaFormat
+ {
+ SfxItemSet maItemSet;
+ ESelection maSelection;
+
+ ParaFormat(ScEditEngineDefaulter& rEditEngine);
+ };
+
+ struct Field : boost::noncopyable
+ {
+ SvxFieldData* mpItem;
+ ESelection maSelection;
+
+ Field();
+ ~Field();
+ };
+
+ typedef boost::ptr_vector<ParaFormat> ParaFormatsType;
+ typedef boost::ptr_vector<Field> FieldsType;
typedef std::pair<OUString, OUString> FormulaWithNamespace;
boost::optional<FormulaWithNamespace> maFormula; /// table:formula attribute
@@ -47,15 +68,8 @@ class ScXMLTableRowCellContext : public ScXMLImportContext
OUStringBuffer maParagraph;
sal_uInt16 mnCurParagraph;
- struct ParaFormat
- {
- SfxItemSet maItemSet;
- ESelection maSelection;
-
- ParaFormat(ScEditEngineDefaulter& rEditEngine);
- };
- typedef boost::ptr_vector<ParaFormat> ParaFormatsType;
ParaFormatsType maFormats;
+ FieldsType maFields;
boost::scoped_ptr< ScXMLAnnotationData > mxAnnotationData;
ScMyImpDetectiveObjVec* pDetectiveObjVec;
@@ -76,7 +90,6 @@ class ScXMLTableRowCellContext : public ScXMLImportContext
bool mbPossibleErrorCell;
bool mbCheckWithCompilerForError;
bool mbEditEngineHasText;
- bool mbEditEngineHasField;
sal_Int16 GetCellType(const rtl::OUString& sOUValue) const;
More information about the Libreoffice-commits
mailing list