diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-02-11 11:28:54 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-02-11 22:33:34 -0500 |
commit | 2c255b8bb03d59ccabc07a4f81765f858b46d885 (patch) | |
tree | 93b755cb5ae78613584e61bad267793cd3cd23b1 | |
parent | e4f956a39dd104da8ff04c5a87082a03204cf316 (diff) |
Prepare for the import of cell field items.
And some code to import sheet name fields. But for some reason they
are not being imported. I need to debug this...
Change-Id: I5d10ae27f2f45de2454660884924fd1e0c0dcef0
-rw-r--r-- | sc/source/filter/xml/celltextparacontext.cxx | 105 | ||||
-rw-r--r-- | sc/source/filter/xml/celltextparacontext.hxx | 56 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlcelli.cxx | 13 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlcelli.hxx | 2 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlimprt.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlimprt.hxx | 5 |
6 files changed, 177 insertions, 7 deletions
diff --git a/sc/source/filter/xml/celltextparacontext.cxx b/sc/source/filter/xml/celltextparacontext.cxx index d15b715bbf51..84249b422fcd 100644 --- a/sc/source/filter/xml/celltextparacontext.cxx +++ b/sc/source/filter/xml/celltextparacontext.cxx @@ -24,7 +24,7 @@ ScXMLCellTextParaContext::ScXMLCellTextParaContext( { } -void ScXMLCellTextParaContext::StartElement(const uno::Reference<xml::sax::XAttributeList>& xAttrList) +void ScXMLCellTextParaContext::StartElement(const uno::Reference<xml::sax::XAttributeList>& /*xAttrList*/) { } @@ -42,7 +42,7 @@ void ScXMLCellTextParaContext::Characters(const OUString& rChars) } SvXMLImportContext* ScXMLCellTextParaContext::CreateChildContext( - sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference<xml::sax::XAttributeList>& xAttrList) + sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference<xml::sax::XAttributeList>& /*xAttrList*/) { if (!maContent.isEmpty()) { @@ -55,7 +55,12 @@ SvXMLImportContext* ScXMLCellTextParaContext::CreateChildContext( { case XML_TOK_CELL_TEXT_SPAN: return new ScXMLCellTextSpanContext(GetScImport(), nPrefix, rLocalName, *this); - break; + case XML_TOK_CELL_TEXT_SHEET_NAME: + return new ScXMLCellFieldSheetNameContext(GetScImport(), nPrefix, rLocalName, *this); + case XML_TOK_CELL_TEXT_DATE: + return new ScXMLCellFieldDateContext(GetScImport(), nPrefix, rLocalName, *this); + case XML_TOK_CELL_TEXT_TITLE: + return new ScXMLCellFieldTitleContext(GetScImport(), nPrefix, rLocalName, *this); default: ; } @@ -68,6 +73,19 @@ void ScXMLCellTextParaContext::PushSpan(const OUString& rSpan, const OUString& r mrParentCxt.PushParagraphSpan(rSpan, rStyleName); } +void ScXMLCellTextParaContext::PushFieldSheetName() +{ + mrParentCxt.PushParagraphFieldSheetName(); +} + +void ScXMLCellTextParaContext::PushFieldDate(const OUString& rOutput) +{ +} + +void ScXMLCellTextParaContext::PushFieldTitle(const OUString& rTitle) +{ +} + ScXMLCellTextSpanContext::ScXMLCellTextSpanContext( ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLName, ScXMLCellTextParaContext& rParent) : ScXMLImportContext(rImport, nPrefix, rLName), @@ -116,7 +134,86 @@ void ScXMLCellTextSpanContext::Characters(const OUString& rChars) } SvXMLImportContext* ScXMLCellTextSpanContext::CreateChildContext( - sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference<xml::sax::XAttributeList>& xAttrList) + sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference<xml::sax::XAttributeList>& /*xAttrList*/) +{ + return new SvXMLImportContext(GetImport(), nPrefix, rLocalName); +} + +ScXMLCellFieldSheetNameContext::ScXMLCellFieldSheetNameContext( + ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLName, ScXMLCellTextParaContext& rParent) : + ScXMLImportContext(rImport, nPrefix, rLName), + mrParentCxt(rParent) +{ +} + +void ScXMLCellFieldSheetNameContext::StartElement(const uno::Reference<xml::sax::XAttributeList>& /*xAttrList*/) +{ + // <text:sheet-name> has no attributes (that I'm aware of). +} + +void ScXMLCellFieldSheetNameContext::EndElement() +{ + mrParentCxt.PushFieldSheetName(); +} + +void ScXMLCellFieldSheetNameContext::Characters(const OUString& /*rChars*/) +{ +} + +SvXMLImportContext* ScXMLCellFieldSheetNameContext::CreateChildContext( + sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference<xml::sax::XAttributeList>& /*xAttrList*/) +{ + return new SvXMLImportContext(GetImport(), nPrefix, rLocalName); +} + +ScXMLCellFieldDateContext::ScXMLCellFieldDateContext( + ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLName, ScXMLCellTextParaContext& rParent) : + ScXMLImportContext(rImport, nPrefix, rLName), + mrParentCxt(rParent) +{ +} + +void ScXMLCellFieldDateContext::StartElement(const uno::Reference<xml::sax::XAttributeList>& /*xAttrList*/) +{ +} + +void ScXMLCellFieldDateContext::EndElement() +{ +} + +void ScXMLCellFieldDateContext::Characters(const OUString& rChars) +{ + maDate = rChars; +} + +SvXMLImportContext* ScXMLCellFieldDateContext::CreateChildContext( + sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference<xml::sax::XAttributeList>& /*xAttrList*/) +{ + return new SvXMLImportContext(GetImport(), nPrefix, rLocalName); +} + +ScXMLCellFieldTitleContext::ScXMLCellFieldTitleContext( + ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLName, ScXMLCellTextParaContext& rParent) : + ScXMLImportContext(rImport, nPrefix, rLName), + mrParentCxt(rParent) +{ +} + +void ScXMLCellFieldTitleContext::StartElement(const uno::Reference<xml::sax::XAttributeList>& /*xAttrList*/) +{ +} + +void ScXMLCellFieldTitleContext::EndElement() +{ +} + +void ScXMLCellFieldTitleContext::Characters(const OUString& rChars) +{ + maTitle = rChars; +} + +SvXMLImportContext* ScXMLCellFieldTitleContext::CreateChildContext( + sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference<xml::sax::XAttributeList>& /*xAttrList*/) { return new SvXMLImportContext(GetImport(), nPrefix, rLocalName); } diff --git a/sc/source/filter/xml/celltextparacontext.hxx b/sc/source/filter/xml/celltextparacontext.hxx index 8401c0d77146..7840cd6fc335 100644 --- a/sc/source/filter/xml/celltextparacontext.hxx +++ b/sc/source/filter/xml/celltextparacontext.hxx @@ -32,6 +32,9 @@ public: sal_uInt16 nPrefix, const OUString& rLocalName, const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList>& xAttrList); void PushSpan(const OUString& rSpan, const OUString& rStyleName); + void PushFieldSheetName(); + void PushFieldDate(const OUString& rOutput); + void PushFieldTitle(const OUString& rTitle); }; /** @@ -52,6 +55,59 @@ public: sal_uInt16 nPrefix, const OUString& rLocalName, const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList>& xAttrList); }; +/** + * This context handles <text:sheet-name> element inside <text:p>. + * + */ +class ScXMLCellFieldSheetNameContext : public ScXMLImportContext +{ + ScXMLCellTextParaContext& mrParentCxt; +public: + ScXMLCellFieldSheetNameContext(ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLName, ScXMLCellTextParaContext& rParent); + + virtual void StartElement(const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList>& xAttrList); + virtual void EndElement(); + virtual void Characters(const OUString& rChars); + virtual SvXMLImportContext* CreateChildContext( + sal_uInt16 nPrefix, const OUString& rLocalName, const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList>& xAttrList); +}; + +/** + * This context handles <text:date> element inside <text:p>. + * + */ +class ScXMLCellFieldDateContext : public ScXMLImportContext +{ + ScXMLCellTextParaContext& mrParentCxt; + OUString maDate; +public: + ScXMLCellFieldDateContext(ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLName, ScXMLCellTextParaContext& rParent); + + virtual void StartElement(const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList>& xAttrList); + virtual void EndElement(); + virtual void Characters(const OUString& rChars); + virtual SvXMLImportContext* CreateChildContext( + sal_uInt16 nPrefix, const OUString& rLocalName, const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList>& xAttrList); +}; + +/** + * This context handles <text:title> element inside <text:p>. + * + */ +class ScXMLCellFieldTitleContext : public ScXMLImportContext +{ + ScXMLCellTextParaContext& mrParentCxt; + OUString maTitle; +public: + ScXMLCellFieldTitleContext(ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLName, ScXMLCellTextParaContext& rParent); + + virtual void StartElement(const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList>& xAttrList); + virtual void EndElement(); + virtual void Characters(const OUString& rChars); + virtual SvXMLImportContext* CreateChildContext( + sal_uInt16 nPrefix, const OUString& rLocalName, const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList>& xAttrList); +}; + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index 72de86c54f11..47aa7eeabdbd 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -78,6 +78,7 @@ #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> @@ -145,7 +146,8 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport, bFormulaTextResult(false), mbPossibleErrorCell(false), mbCheckWithCompilerForError(false), - mbEditEngineHasText(false) + mbEditEngineHasText(false), + mbEditEngineHasField(false) { rtl::math::setNan(&fValue); // NaN by default mpEditEngine->Clear(); @@ -550,6 +552,13 @@ void ScXMLTableRowCellContext::PushParagraphSpan(const OUString& rSpan, const OU rFmt.maItemSet.Put(*pPoolItem); } +void ScXMLTableRowCellContext::PushParagraphFieldSheetName() +{ + SvxTableField aField(0); + mpEditEngine->QuickInsertField(SvxFieldItem(aField, EE_FEATURE_FIELD), ESelection(EE_PARA_APPEND, EE_PARA_APPEND)); + mbEditEngineHasField = true; +} + void ScXMLTableRowCellContext::PushParagraphEnd() { // EditEngine always has at least one paragraph even when its content is empty. @@ -989,7 +998,7 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos, pNewCell = ScBaseCell::CreateTextCell( *maStringValue, pDoc ); else if (mbEditEngineHasText) { - if (maFormats.empty() && mpEditEngine->GetParagraphCount() == 1) + if (!mbEditEngineHasField && maFormats.empty() && mpEditEngine->GetParagraphCount() == 1) { // This is a normal text without format runs. pNewCell = new ScStringCell(mpEditEngine->GetText()); diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx index e9d7e2361df8..bdb817ca9007 100644 --- a/sc/source/filter/xml/xmlcelli.hxx +++ b/sc/source/filter/xml/xmlcelli.hxx @@ -76,6 +76,7 @@ class ScXMLTableRowCellContext : public ScXMLImportContext bool mbPossibleErrorCell; bool mbCheckWithCompilerForError; bool mbEditEngineHasText; + bool mbEditEngineHasField; sal_Int16 GetCellType(const rtl::OUString& sOUValue) const; @@ -120,6 +121,7 @@ public: ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); void PushParagraphSpan(const OUString& rSpan, const OUString& rStyleName); + void PushParagraphFieldSheetName(); void PushParagraphEnd(); void SetAnnotation( const ScAddress& rPosition ); diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index 0781667e8ad4..fb5516f8ff02 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -1850,6 +1850,9 @@ const SvXMLTokenMap& ScXMLImport::GetCellTextParaElemTokenMap() static SvXMLTokenMapEntry aMap[] = { { XML_NAMESPACE_TEXT, XML_SPAN, XML_TOK_CELL_TEXT_SPAN }, + { XML_NAMESPACE_TEXT, XML_SHEET_NAME, XML_TOK_CELL_TEXT_SHEET_NAME }, + { XML_NAMESPACE_TEXT, XML_DATE, XML_TOK_CELL_TEXT_DATE }, + { XML_NAMESPACE_TEXT, XML_TITLE, XML_TOK_CELL_TEXT_TITLE }, XML_TOKEN_MAP_END }; diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx index 1aae0b1af012..da35d6408c7b 100644 --- a/sc/source/filter/xml/xmlimprt.hxx +++ b/sc/source/filter/xml/xmlimprt.hxx @@ -687,7 +687,10 @@ enum ScXMLConsolidationAttrTokens */ enum ScXMLCellTextParaElemTokens { - XML_TOK_CELL_TEXT_SPAN + XML_TOK_CELL_TEXT_SPAN, + XML_TOK_CELL_TEXT_SHEET_NAME, + XML_TOK_CELL_TEXT_DATE, + XML_TOK_CELL_TEXT_TITLE }; /** |