[Libreoffice-commits] core.git: 4 commits - editeng/inc editeng/source sc/qa sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Mon Apr 8 16:23:19 PDT 2013
editeng/inc/editeng/editobj.hxx | 2
editeng/source/editeng/editobj.cxx | 40 +++++++++++++
editeng/source/editeng/editobj2.hxx | 2
sc/qa/unit/data/ods/rich-text-cells.ods |binary
sc/qa/unit/subsequent_filters-test.cxx | 36 +++++++++++
sc/source/filter/xml/celltextparacontext.cxx | 82 +++++++++++++++++++++++----
sc/source/filter/xml/celltextparacontext.hxx | 22 +++++--
sc/source/filter/xml/xmlcelli.cxx | 51 +++++++++-------
sc/source/filter/xml/xmlcelli.hxx | 12 ++-
sc/source/filter/xml/xmlimprt.cxx | 20 ++++++
sc/source/filter/xml/xmlimprt.hxx | 13 ++++
11 files changed, 237 insertions(+), 43 deletions(-)
New commits:
commit d64b5cc1c3d232ba42479fe0a3c186ecabd25144
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Apr 8 17:40:32 2013 -0400
fdo#62116: Be sure to convert relative URLs into absolute ones.
Just to preserve the old (and correct) behavior.
Change-Id: I229e0b80097f6d70ff3023072b52576815010b15
diff --git a/editeng/inc/editeng/editobj.hxx b/editeng/inc/editeng/editobj.hxx
index 93a590c..16bc0be 100644
--- a/editeng/inc/editeng/editobj.hxx
+++ b/editeng/inc/editeng/editobj.hxx
@@ -39,6 +39,7 @@ DBG_NAMEEX( EE_EditTextObject )
class SfxItemPool;
class SfxStyleSheetPool;
class SvxFieldItem;
+class SvxFieldData;
namespace editeng {
@@ -99,6 +100,7 @@ public:
bool IsFieldObject() const;
const SvxFieldItem* GetField() const;
+ const SvxFieldData* GetFieldData(size_t nPara, size_t nPos, sal_Int32 nType) const;
bool HasField( sal_Int32 nType = com::sun::star::text::textfield::Type::UNSPECIFIED ) const;
const SfxItemSet& GetParaAttribs(size_t nPara) const;
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index 0433ea5..8231396 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -256,6 +256,11 @@ const SvxFieldItem* EditTextObject::GetField() const
return mpImpl->GetField();
}
+const SvxFieldData* EditTextObject::GetFieldData(size_t nPara, size_t nPos, sal_Int32 nType) const
+{
+ return mpImpl->GetFieldData(nPara, nPos, nType);
+}
+
bool EditTextObject::HasField( sal_Int32 nType ) const
{
return mpImpl->HasField(nType);
@@ -703,6 +708,41 @@ const SvxFieldItem* EditTextObjectImpl::GetField() const
return 0;
}
+const SvxFieldData* EditTextObjectImpl::GetFieldData(size_t nPara, size_t nPos, sal_Int32 nType) const
+{
+ if (nPara >= aContents.size())
+ return NULL;
+
+ const ContentInfo& rC = aContents[nPara];
+ if (nPos >= rC.aAttribs.size())
+ // URL position is out-of-bound.
+ return NULL;
+
+ ContentInfo::XEditAttributesType::const_iterator it = rC.aAttribs.begin(), itEnd = rC.aAttribs.end();
+ size_t nCurPos = 0;
+ for (; it != itEnd; ++it)
+ {
+ const XEditAttribute& rAttr = *it;
+ if (rAttr.GetItem()->Which() != EE_FEATURE_FIELD)
+ // Skip attributes that are not fields.
+ continue;
+
+ const SvxFieldItem* pField = static_cast<const SvxFieldItem*>(rAttr.GetItem());
+ const SvxFieldData* pFldData = pField->GetField();
+ if (nType != text::textfield::Type::UNSPECIFIED && nType != pFldData->GetClassId())
+ // Field type doesn't match. Skip it. UNSPECIFIED matches all field types.
+ continue;
+
+ if (nCurPos == nPos)
+ // Found it!
+ return pFldData;
+
+ ++nCurPos;
+ }
+
+ return NULL; // field not found.
+}
+
bool EditTextObjectImpl::HasField( sal_Int32 nType ) const
{
size_t nParagraphs = aContents.size();
diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx
index 5c59050..c1aa77f 100644
--- a/editeng/source/editeng/editobj2.hxx
+++ b/editeng/source/editeng/editobj2.hxx
@@ -221,6 +221,8 @@ public:
bool IsFieldObject() const;
const SvxFieldItem* GetField() const;
+ const SvxFieldData* GetFieldData(size_t nPara, size_t nPos, sal_Int32 nType) const;
+
bool HasField( sal_Int32 nType = com::sun::star::text::textfield::Type::UNSPECIFIED ) const;
const SfxItemSet& GetParaAttribs(size_t nPara) const;
diff --git a/sc/qa/unit/data/ods/rich-text-cells.ods b/sc/qa/unit/data/ods/rich-text-cells.ods
index a869b0b..da3a1ed 100644
Binary files a/sc/qa/unit/data/ods/rich-text-cells.ods and b/sc/qa/unit/data/ods/rich-text-cells.ods differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index ff09d27..d89d95d 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -48,6 +48,7 @@
#include <editeng/brushitem.hxx>
#include <editeng/justifyitem.hxx>
#include <editeng/borderline.hxx>
+#include "editeng/flditem.hxx"
#include <dbdata.hxx>
#include "validat.hxx"
#include "formulacell.hxx"
@@ -1757,6 +1758,15 @@ void ScFiltersTest::testRichTextContentODS()
CPPUNIT_ASSERT_MESSAGE("Failed to retrieve edit text object.", pEditText);
CPPUNIT_ASSERT_MESSAGE("Date field item not found.", pEditText->HasField(text::textfield::Type::DOCINFO_TITLE));
+ // URL for a file in the same directory. It should be converted into an absolute URL on import.
+ aPos.IncRow();
+ pEditText = pDoc->GetEditText(aPos);
+ CPPUNIT_ASSERT_MESSAGE("Failed to retrieve edit text object.", pEditText);
+ const SvxFieldData* pData = pEditText->GetFieldData(0, 0, text::textfield::Type::URL);
+ CPPUNIT_ASSERT_MESSAGE("Failed to get the URL data.", pData && pData->GetClassId() == text::textfield::Type::URL);
+ const SvxURLField* pURLData = static_cast<const SvxURLField*>(pData);
+ CPPUNIT_ASSERT_MESSAGE("URL is not absolute with respect to the file system.", pURLData->GetURL().startsWith("file:///"));
+
xDocSh->DoClose();
}
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 5f4acb9..b97a245 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -598,7 +598,8 @@ void ScXMLTableRowCellContext::PushParagraphFieldDocTitle(const OUString& rStyle
void ScXMLTableRowCellContext::PushParagraphFieldURL(
const OUString& rURL, const OUString& rRep, const OUString& rStyleName)
{
- PushParagraphField(new SvxURLField(rURL, rRep, SVXURLFORMAT_REPR), rStyleName);
+ OUString aAbsURL = GetScImport().GetAbsoluteReference(rURL);
+ PushParagraphField(new SvxURLField(aAbsURL, rRep, SVXURLFORMAT_REPR), rStyleName);
}
void ScXMLTableRowCellContext::PushParagraphEnd()
commit 11637831312a7a92af9c0148aa6b1e30db4b55b2
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Apr 8 17:24:35 2013 -0400
fdo#62116: Unit test for the fix.
For now, we'll only check whether or not those field items with formats
get imported at all. We should add additional checks for their formats
later.
Change-Id: I5a8f01a6e2594b8c97183a43fc4f3417df6fb561
diff --git a/sc/qa/unit/data/ods/rich-text-cells.ods b/sc/qa/unit/data/ods/rich-text-cells.ods
index 0f24cfd..a869b0b 100644
Binary files a/sc/qa/unit/data/ods/rich-text-cells.ods and b/sc/qa/unit/data/ods/rich-text-cells.ods differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index a00b518..ff09d27 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -1731,6 +1731,32 @@ void ScFiltersTest::testRichTextContentODS()
}
CPPUNIT_ASSERT_MESSAGE("Second line should be underlined.", bHasUnderline);
+ // URL with formats applied. For now, we'll check whether or not the
+ // field objects gets imported. Later we should add checks for the
+ // formats.
+ aPos.IncRow();
+ pEditText = pDoc->GetEditText(aPos);
+ CPPUNIT_ASSERT_MESSAGE("Failed to retrieve edit text object.", pEditText);
+ CPPUNIT_ASSERT_MESSAGE("URL field item not found.", pEditText->HasField(text::textfield::Type::URL));
+
+ // Sheet name with formats applied.
+ aPos.IncRow();
+ pEditText = pDoc->GetEditText(aPos);
+ CPPUNIT_ASSERT_MESSAGE("Failed to retrieve edit text object.", pEditText);
+ CPPUNIT_ASSERT_MESSAGE("Sheet name field item not found.", pEditText->HasField(text::textfield::Type::TABLE));
+
+ // Date with formats applied.
+ aPos.IncRow();
+ pEditText = pDoc->GetEditText(aPos);
+ CPPUNIT_ASSERT_MESSAGE("Failed to retrieve edit text object.", pEditText);
+ CPPUNIT_ASSERT_MESSAGE("Date field item not found.", pEditText->HasField(text::textfield::Type::DATE));
+
+ // Document title with formats applied.
+ aPos.IncRow();
+ pEditText = pDoc->GetEditText(aPos);
+ CPPUNIT_ASSERT_MESSAGE("Failed to retrieve edit text object.", pEditText);
+ CPPUNIT_ASSERT_MESSAGE("Date field item not found.", pEditText->HasField(text::textfield::Type::DOCINFO_TITLE));
+
xDocSh->DoClose();
}
commit 40af04cea332e5311edab8d9c395299c15b7d4ec
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Apr 8 16:34:01 2013 -0400
fdo#62116: Handle field objects with formats correctly.
Field objects can have formats applied to them, and when they do, they
appear inside a <text:span> element.
Change-Id: I7b4346389f393a4ddf708670b2c524a6594128b5
diff --git a/sc/qa/unit/data/ods/rich-text-cells.ods b/sc/qa/unit/data/ods/rich-text-cells.ods
index 2503dce..0f24cfd 100644
Binary files a/sc/qa/unit/data/ods/rich-text-cells.ods and b/sc/qa/unit/data/ods/rich-text-cells.ods differ
diff --git a/sc/source/filter/xml/celltextparacontext.cxx b/sc/source/filter/xml/celltextparacontext.cxx
index 4a1520f..fbbcf6f 100644
--- a/sc/source/filter/xml/celltextparacontext.cxx
+++ b/sc/source/filter/xml/celltextparacontext.cxx
@@ -75,24 +75,25 @@ void ScXMLCellTextParaContext::PushSpan(const OUString& rSpan, const OUString& r
mrParentCxt.PushParagraphSpan(rSpan, rStyleName);
}
-void ScXMLCellTextParaContext::PushFieldSheetName()
+void ScXMLCellTextParaContext::PushFieldSheetName(const OUString& rStyleName)
{
- mrParentCxt.PushParagraphFieldSheetName();
+ mrParentCxt.PushParagraphFieldSheetName(rStyleName);
}
-void ScXMLCellTextParaContext::PushFieldDate()
+void ScXMLCellTextParaContext::PushFieldDate(const OUString& rStyleName)
{
- mrParentCxt.PushParagraphFieldDate();
+ mrParentCxt.PushParagraphFieldDate(rStyleName);
}
-void ScXMLCellTextParaContext::PushFieldTitle()
+void ScXMLCellTextParaContext::PushFieldTitle(const OUString& rStyleName)
{
- mrParentCxt.PushParagraphFieldDocTitle();
+ mrParentCxt.PushParagraphFieldDocTitle(rStyleName);
}
-void ScXMLCellTextParaContext::PushFieldURL(const OUString& rURL, const OUString& rRep)
+void ScXMLCellTextParaContext::PushFieldURL(
+ const OUString& rURL, const OUString& rRep, const OUString& rStyleName)
{
- mrParentCxt.PushParagraphFieldURL(rURL, rRep);
+ mrParentCxt.PushParagraphFieldURL(rURL, rRep, rStyleName);
}
ScXMLCellTextSpanContext::ScXMLCellTextSpanContext(
@@ -145,6 +146,43 @@ void ScXMLCellTextSpanContext::Characters(const OUString& rChars)
SvXMLImportContext* ScXMLCellTextSpanContext::CreateChildContext(
sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference<xml::sax::XAttributeList>& /*xAttrList*/)
{
+ if (!maContent.isEmpty())
+ {
+ mrParentCxt.PushSpan(maContent, maStyleName);
+ maContent = OUString();
+ }
+
+ const SvXMLTokenMap& rTokenMap = GetScImport().GetCellTextSpanElemTokenMap();
+ switch (rTokenMap.Get(nPrefix, rLocalName))
+ {
+ case XML_TOK_CELL_TEXT_SPAN_ELEM_SHEET_NAME:
+ {
+ ScXMLCellFieldSheetNameContext* p = new ScXMLCellFieldSheetNameContext(GetScImport(), nPrefix, rLocalName, mrParentCxt);
+ p->SetStyleName(maStyleName);
+ return p;
+ }
+ case XML_TOK_CELL_TEXT_SPAN_ELEM_DATE:
+ {
+ ScXMLCellFieldDateContext* p = new ScXMLCellFieldDateContext(GetScImport(), nPrefix, rLocalName, mrParentCxt);
+ p->SetStyleName(maStyleName);
+ return p;
+ }
+ case XML_TOK_CELL_TEXT_SPAN_ELEM_TITLE:
+ {
+ ScXMLCellFieldTitleContext* p = new ScXMLCellFieldTitleContext(GetScImport(), nPrefix, rLocalName, mrParentCxt);
+ p->SetStyleName(maStyleName);
+ return p;
+ }
+ case XML_TOK_CELL_TEXT_SPAN_ELEM_URL:
+ {
+ ScXMLCellFieldURLContext* p = new ScXMLCellFieldURLContext(GetScImport(), nPrefix, rLocalName, mrParentCxt);
+ p->SetStyleName(maStyleName);
+ return p;
+ }
+ default:
+ ;
+ }
+
return new SvXMLImportContext(GetImport(), nPrefix, rLocalName);
}
@@ -155,6 +193,11 @@ ScXMLCellFieldSheetNameContext::ScXMLCellFieldSheetNameContext(
{
}
+void ScXMLCellFieldSheetNameContext::SetStyleName(const OUString& rStyleName)
+{
+ maStyleName = rStyleName;
+}
+
void ScXMLCellFieldSheetNameContext::StartElement(const uno::Reference<xml::sax::XAttributeList>& /*xAttrList*/)
{
// <text:sheet-name> has no attributes (that I'm aware of).
@@ -162,7 +205,7 @@ void ScXMLCellFieldSheetNameContext::StartElement(const uno::Reference<xml::sax:
void ScXMLCellFieldSheetNameContext::EndElement()
{
- mrParentCxt.PushFieldSheetName();
+ mrParentCxt.PushFieldSheetName(maStyleName);
}
void ScXMLCellFieldSheetNameContext::Characters(const OUString& /*rChars*/)
@@ -182,13 +225,18 @@ ScXMLCellFieldDateContext::ScXMLCellFieldDateContext(
{
}
+void ScXMLCellFieldDateContext::SetStyleName(const OUString& rStyleName)
+{
+ maStyleName = rStyleName;
+}
+
void ScXMLCellFieldDateContext::StartElement(const uno::Reference<xml::sax::XAttributeList>& /*xAttrList*/)
{
}
void ScXMLCellFieldDateContext::EndElement()
{
- mrParentCxt.PushFieldDate();
+ mrParentCxt.PushFieldDate(maStyleName);
}
void ScXMLCellFieldDateContext::Characters(const OUString& /*rChars*/)
@@ -208,13 +256,18 @@ ScXMLCellFieldTitleContext::ScXMLCellFieldTitleContext(
{
}
+void ScXMLCellFieldTitleContext::SetStyleName(const OUString& rStyleName)
+{
+ maStyleName = rStyleName;
+}
+
void ScXMLCellFieldTitleContext::StartElement(const uno::Reference<xml::sax::XAttributeList>& /*xAttrList*/)
{
}
void ScXMLCellFieldTitleContext::EndElement()
{
- mrParentCxt.PushFieldTitle();
+ mrParentCxt.PushFieldTitle(maStyleName);
}
void ScXMLCellFieldTitleContext::Characters(const OUString& /*rChars*/)
@@ -234,6 +287,11 @@ ScXMLCellFieldURLContext::ScXMLCellFieldURLContext(
{
}
+void ScXMLCellFieldURLContext::SetStyleName(const OUString& rStyleName)
+{
+ maStyleName = rStyleName;
+}
+
void ScXMLCellFieldURLContext::StartElement(const uno::Reference<xml::sax::XAttributeList>& xAttrList)
{
if (!xAttrList.is())
@@ -266,7 +324,7 @@ void ScXMLCellFieldURLContext::StartElement(const uno::Reference<xml::sax::XAttr
void ScXMLCellFieldURLContext::EndElement()
{
- mrParentCxt.PushFieldURL(maURL, maRep);
+ mrParentCxt.PushFieldURL(maURL, maRep, maStyleName);
}
void ScXMLCellFieldURLContext::Characters(const OUString& rChars)
diff --git a/sc/source/filter/xml/celltextparacontext.hxx b/sc/source/filter/xml/celltextparacontext.hxx
index 9390a3e..10e5a23 100644
--- a/sc/source/filter/xml/celltextparacontext.hxx
+++ b/sc/source/filter/xml/celltextparacontext.hxx
@@ -32,10 +32,10 @@ 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();
- void PushFieldTitle();
- void PushFieldURL(const OUString& rURL, const OUString& rRep);
+ void PushFieldSheetName(const OUString& rStyleName);
+ void PushFieldDate(const OUString& rStyleName);
+ void PushFieldTitle(const OUString& rStyleName);
+ void PushFieldURL(const OUString& rURL, const OUString& rRep, const OUString& rStyleName);
};
/**
@@ -62,9 +62,12 @@ public:
class ScXMLCellFieldSheetNameContext : public ScXMLImportContext
{
ScXMLCellTextParaContext& mrParentCxt;
+ OUString maStyleName;
public:
ScXMLCellFieldSheetNameContext(ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLName, ScXMLCellTextParaContext& rParent);
+ void SetStyleName(const OUString& rStyleName);
+
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);
@@ -78,9 +81,12 @@ public:
class ScXMLCellFieldDateContext : public ScXMLImportContext
{
ScXMLCellTextParaContext& mrParentCxt;
+ OUString maStyleName;
public:
ScXMLCellFieldDateContext(ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLName, ScXMLCellTextParaContext& rParent);
+ void SetStyleName(const OUString& rStyleName);
+
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);
@@ -94,9 +100,12 @@ public:
class ScXMLCellFieldTitleContext : public ScXMLImportContext
{
ScXMLCellTextParaContext& mrParentCxt;
+ OUString maStyleName;
public:
ScXMLCellFieldTitleContext(ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLName, ScXMLCellTextParaContext& rParent);
+ void SetStyleName(const OUString& rStyleName);
+
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);
@@ -105,16 +114,19 @@ public:
};
/**
- * This context handles <text:a> element inside <text:p>.
+ * This context handles <text:a> element inside <text:p> or <text:span>.
*/
class ScXMLCellFieldURLContext : public ScXMLImportContext
{
ScXMLCellTextParaContext& mrParentCxt;
+ OUString maStyleName;
OUString maURL;
OUString maRep;
public:
ScXMLCellFieldURLContext(ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLName, ScXMLCellTextParaContext& rParent);
+ void SetStyleName(const OUString& rStyleName);
+
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);
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index d9b5dec..5f4acb9 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -337,6 +337,26 @@ void ScXMLTableRowCellContext::PushParagraphSpan(const OUString& rSpan, const OU
sal_Int32 nEnd = nBegin + rSpan.getLength();
maParagraph.append(rSpan);
+ PushFormat(nBegin, nEnd, rStyleName);
+}
+
+void ScXMLTableRowCellContext::PushParagraphField(SvxFieldData* pData, const OUString& rStyleName)
+{
+ maFields.push_back(new Field(pData));
+ Field& rField = maFields.back();
+
+ sal_Int32 nPos = maParagraph.getLength();
+ maParagraph.append(sal_Unicode('\1')); // Placeholder text for inserted field item.
+ rField.maSelection.nStartPara = mnCurParagraph;
+ rField.maSelection.nEndPara = mnCurParagraph;
+ rField.maSelection.nStartPos = nPos;
+ rField.maSelection.nEndPos = nPos+1;
+
+ PushFormat(nPos, nPos+1, rStyleName);
+}
+
+void ScXMLTableRowCellContext::PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, const OUString& rStyleName)
+{
if (rStyleName.isEmpty())
return;
@@ -559,38 +579,26 @@ void ScXMLTableRowCellContext::PushParagraphSpan(const OUString& rSpan, const OU
rFmt.maItemSet.Put(*pPoolItem);
}
-void ScXMLTableRowCellContext::PushParagraphField(SvxFieldData* pData)
-{
- maFields.push_back(new Field(pData));
- Field& rField = maFields.back();
-
- sal_Int32 nPos = maParagraph.getLength();
- maParagraph.append(sal_Unicode('\1')); // Placeholder text for inserted field item.
- rField.maSelection.nStartPara = mnCurParagraph;
- rField.maSelection.nEndPara = mnCurParagraph;
- rField.maSelection.nStartPos = nPos;
- rField.maSelection.nEndPos = nPos+1;
-}
-
-void ScXMLTableRowCellContext::PushParagraphFieldDate()
+void ScXMLTableRowCellContext::PushParagraphFieldDate(const OUString& rStyleName)
{
- PushParagraphField(new SvxDateField);
+ PushParagraphField(new SvxDateField, rStyleName);
}
-void ScXMLTableRowCellContext::PushParagraphFieldSheetName()
+void ScXMLTableRowCellContext::PushParagraphFieldSheetName(const OUString& rStyleName)
{
SCTAB nTab = GetScImport().GetTables().GetCurrentCellPos().Tab();
- PushParagraphField(new SvxTableField(nTab));
+ PushParagraphField(new SvxTableField(nTab), rStyleName);
}
-void ScXMLTableRowCellContext::PushParagraphFieldDocTitle()
+void ScXMLTableRowCellContext::PushParagraphFieldDocTitle(const OUString& rStyleName)
{
- PushParagraphField(new SvxFileField);
+ PushParagraphField(new SvxFileField, rStyleName);
}
-void ScXMLTableRowCellContext::PushParagraphFieldURL(const OUString& rURL, const OUString& rRep)
+void ScXMLTableRowCellContext::PushParagraphFieldURL(
+ const OUString& rURL, const OUString& rRep, const OUString& rStyleName)
{
- PushParagraphField(new SvxURLField(rURL, rRep, SVXURLFORMAT_REPR));
+ PushParagraphField(new SvxURLField(rURL, rRep, SVXURLFORMAT_REPR), rStyleName);
}
void ScXMLTableRowCellContext::PushParagraphEnd()
diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx
index ac03836..7555a46 100644
--- a/sc/source/filter/xml/xmlcelli.hxx
+++ b/sc/source/filter/xml/xmlcelli.hxx
@@ -118,7 +118,9 @@ class ScXMLTableRowCellContext : public ScXMLImportContext
bool IsPossibleErrorString() const;
- void PushParagraphField(SvxFieldData* pData);
+ void PushParagraphField(SvxFieldData* pData, const OUString& rStyleName);
+
+ void PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, const OUString& rStyleName);
public:
@@ -136,10 +138,10 @@ public:
::com::sun::star::xml::sax::XAttributeList>& xAttrList );
void PushParagraphSpan(const OUString& rSpan, const OUString& rStyleName);
- void PushParagraphFieldDate();
- void PushParagraphFieldSheetName();
- void PushParagraphFieldDocTitle();
- void PushParagraphFieldURL(const OUString& rURL, const OUString& rRep);
+ void PushParagraphFieldDate(const OUString& rStyleName);
+ void PushParagraphFieldSheetName(const OUString& rStyleName);
+ void PushParagraphFieldDocTitle(const OUString& rStyleName);
+ void PushParagraphFieldURL(const OUString& rURL, const OUString& rRep, const OUString& rStyleName);
void PushParagraphEnd();
void SetAnnotation( const ScAddress& rPosition );
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index df3472f..efccaee 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -1860,6 +1860,24 @@ const SvXMLTokenMap& ScXMLImport::GetCellTextParaElemTokenMap()
return *pCellTextParaElemTokenMap;
}
+const SvXMLTokenMap& ScXMLImport::GetCellTextSpanElemTokenMap()
+{
+ if (!pCellTextSpanElemTokenMap)
+ {
+ static SvXMLTokenMapEntry aMap[] =
+ {
+ { XML_NAMESPACE_TEXT, XML_SHEET_NAME, XML_TOK_CELL_TEXT_SPAN_ELEM_SHEET_NAME },
+ { XML_NAMESPACE_TEXT, XML_DATE, XML_TOK_CELL_TEXT_SPAN_ELEM_DATE },
+ { XML_NAMESPACE_TEXT, XML_TITLE, XML_TOK_CELL_TEXT_SPAN_ELEM_TITLE },
+ { XML_NAMESPACE_TEXT, XML_A, XML_TOK_CELL_TEXT_SPAN_ELEM_URL },
+ XML_TOKEN_MAP_END
+ };
+
+ pCellTextSpanElemTokenMap = new SvXMLTokenMap(aMap);
+ }
+ return *pCellTextSpanElemTokenMap;
+}
+
const SvXMLTokenMap& ScXMLImport::GetCellTextSpanAttrTokenMap()
{
if (!pCellTextSpanAttrTokenMap)
@@ -2013,6 +2031,7 @@ ScXMLImport::ScXMLImport(
pDataPilotMemberAttrTokenMap( 0 ),
pConsolidationAttrTokenMap( 0 ),
pCellTextParaElemTokenMap(NULL),
+ pCellTextSpanElemTokenMap(NULL),
pCellTextSpanAttrTokenMap(NULL),
pCellTextURLAttrTokenMap(NULL),
aTables(*this),
@@ -2153,6 +2172,7 @@ ScXMLImport::~ScXMLImport() throw()
delete pDataPilotMemberAttrTokenMap;
delete pConsolidationAttrTokenMap;
delete pCellTextParaElemTokenMap;
+ delete pCellTextSpanElemTokenMap;
delete pCellTextSpanAttrTokenMap;
delete pCellTextURLAttrTokenMap;
diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx
index 52e5b61..0e63909 100644
--- a/sc/source/filter/xml/xmlimprt.hxx
+++ b/sc/source/filter/xml/xmlimprt.hxx
@@ -695,6 +695,17 @@ enum ScXMLCellTextParaElemTokens
};
/**
+ * Tokens for elements that come under <text:span>
+ */
+enum ScXMLCellTextSpanElemTokens
+{
+ XML_TOK_CELL_TEXT_SPAN_ELEM_SHEET_NAME,
+ XML_TOK_CELL_TEXT_SPAN_ELEM_DATE,
+ XML_TOK_CELL_TEXT_SPAN_ELEM_TITLE,
+ XML_TOK_CELL_TEXT_SPAN_ELEM_URL
+};
+
+/**
* Tokens for attributes for <text:span>
*/
enum ScXMLCellTextSpanAttrTokens
@@ -877,6 +888,7 @@ class ScXMLImport: public SvXMLImport, boost::noncopyable
SvXMLTokenMap *pDataPilotMemberAttrTokenMap;
SvXMLTokenMap *pConsolidationAttrTokenMap;
SvXMLTokenMap *pCellTextParaElemTokenMap;
+ SvXMLTokenMap *pCellTextSpanElemTokenMap;
SvXMLTokenMap *pCellTextSpanAttrTokenMap;
SvXMLTokenMap *pCellTextURLAttrTokenMap;
@@ -1045,6 +1057,7 @@ public:
const SvXMLTokenMap& GetDataPilotMemberAttrTokenMap();
const SvXMLTokenMap& GetConsolidationAttrTokenMap();
const SvXMLTokenMap& GetCellTextParaElemTokenMap();
+ const SvXMLTokenMap& GetCellTextSpanElemTokenMap();
const SvXMLTokenMap& GetCellTextSpanAttrTokenMap();
const SvXMLTokenMap& GetCellTextURLAttrTokenMap();
commit 665cd87e5b594a21b4a2f578564efca7b3f653b8
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Apr 8 12:38:11 2013 -0400
fdo#62116: Add failing cell content to the test file.
Change-Id: I8139c5b65f5953ad62047ee87f298b68141086b1
diff --git a/sc/qa/unit/data/ods/rich-text-cells.ods b/sc/qa/unit/data/ods/rich-text-cells.ods
index d60747a..2503dce 100644
Binary files a/sc/qa/unit/data/ods/rich-text-cells.ods and b/sc/qa/unit/data/ods/rich-text-cells.ods differ
More information about the Libreoffice-commits
mailing list