diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-02-11 13:06:03 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-02-11 22:33:34 -0500 |
commit | bc2fdbeba39aa5598d7b084481d1c4c1b291ffee (patch) | |
tree | 94316ad189380b58889b61092ce8f4ddcefc22e9 | |
parent | 2c255b8bb03d59ccabc07a4f81765f858b46d885 (diff) |
Fix sheet name field import.
Change-Id: Idcdabe026dfb775b4bf1fca6c7cb3c58c242d647
-rw-r--r-- | sc/source/filter/xml/xmlcelli.cxx | 42 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlcelli.hxx | 31 |
2 files changed, 53 insertions, 20 deletions
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index 47aa7eeabdbd..aff762ff36a7 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 bdb817ca9007..20f4465ae98c 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; |