[Libreoffice-commits] core.git: Branch 'feature/ods-edit-cell-import' - 2 commits - sc/Library_sc.mk sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Fri Feb 8 23:16:18 PST 2013
sc/Library_sc.mk | 1
sc/source/filter/xml/editattributemap.cxx | 95 +++++++++++
sc/source/filter/xml/editattributemap.hxx | 43 +++++
sc/source/filter/xml/importcontext.hxx | 4
sc/source/filter/xml/xmlcelli.cxx | 248 +++++++++++++++++++++++-------
sc/source/filter/xml/xmlimprt.cxx | 8
sc/source/filter/xml/xmlimprt.hxx | 3
7 files changed, 343 insertions(+), 59 deletions(-)
New commits:
commit 24037651cdd66c3a2a2d6682f5260ea9f686ed92
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Sat Feb 9 02:16:27 2013 -0500
Import all possible text format properties.
Change-Id: I4bbe93450d16a26e9b882041e0d21cf1c4140253
diff --git a/sc/source/filter/xml/editattributemap.cxx b/sc/source/filter/xml/editattributemap.cxx
index 3580cc0..174f508 100644
--- a/sc/source/filter/xml/editattributemap.cxx
+++ b/sc/source/filter/xml/editattributemap.cxx
@@ -16,19 +16,57 @@ namespace {
struct {
const char* mpXMLName;
+ const char* mpAPIName;
sal_uInt16 mnItemID;
sal_uInt8 mnFlag;
+
} Entries[] = {
- { "color", EE_CHAR_COLOR, 0 },
- { "font-weight", EE_CHAR_WEIGHT, MID_WEIGHT },
- { "font-weight-asian", EE_CHAR_WEIGHT_CJK, MID_WEIGHT },
- { "font-weight-complex", EE_CHAR_WEIGHT_CTL, MID_WEIGHT },
- { "font-size", EE_CHAR_FONTHEIGHT, MID_FONTHEIGHT },
- { "font-size-asian", EE_CHAR_FONTHEIGHT_CJK, MID_FONTHEIGHT },
- { "font-size-complex", EE_CHAR_FONTHEIGHT_CTL, MID_FONTHEIGHT },
- { "font-style", EE_CHAR_ITALIC, MID_POSTURE },
- { "font-style-asian", EE_CHAR_ITALIC_CJK, MID_POSTURE },
- { "font-style-complex", EE_CHAR_ITALIC_CTL, MID_POSTURE },
+
+ { "color", "CharColor", EE_CHAR_COLOR, 0 },
+ { "font-charset", "CharFontCharSet", EE_CHAR_FONTINFO, MID_FONT_CHAR_SET },
+ { "font-charset-asian", "CharFontCharSetAsian", EE_CHAR_FONTINFO_CJK, MID_FONT_CHAR_SET },
+ { "font-charset-complex", "CharFontCharSetComplex", EE_CHAR_FONTINFO_CTL, MID_FONT_CHAR_SET },
+ { "font-family", "CharFontName", EE_CHAR_FONTINFO, MID_FONT_FAMILY_NAME },
+ { "font-family-asian", "CharFontNameAsian", EE_CHAR_FONTINFO_CJK, MID_FONT_FAMILY_NAME },
+ { "font-family-complex", "CharFontNameAsian", EE_CHAR_FONTINFO_CTL, MID_FONT_FAMILY_NAME },
+ { "font-family-generic", "CharFontFamily", EE_CHAR_FONTINFO, MID_FONT_FAMILY },
+ { "font-family-generic-asian", "CharFontFamilyAsian", EE_CHAR_FONTINFO_CJK, MID_FONT_FAMILY },
+ { "font-family-generic-complex", "CharFontFamilyComplex", EE_CHAR_FONTINFO_CTL, MID_FONT_FAMILY },
+ { "font-pitch", "CharFontPitch", EE_CHAR_FONTINFO, MID_FONT_PITCH },
+ { "font-pitch-asian", "CharFontPitchAsian", EE_CHAR_FONTINFO_CJK, MID_FONT_PITCH },
+ { "font-pitch-complex", "CharFontPitchComplex", EE_CHAR_FONTINFO_CTL, MID_FONT_PITCH },
+ { "font-size", "CharHeight", EE_CHAR_FONTHEIGHT, MID_FONTHEIGHT },
+ { "font-size-asian", "CharHeightAsian", EE_CHAR_FONTHEIGHT_CJK, MID_FONTHEIGHT },
+ { "font-size-complex", "CharHeightComplex", EE_CHAR_FONTHEIGHT_CTL, MID_FONTHEIGHT },
+ { "font-style", "CharPosture", EE_CHAR_ITALIC, MID_POSTURE },
+ { "font-style-asian", "CharPostureAsian", EE_CHAR_ITALIC_CJK, MID_POSTURE },
+ { "font-style-complex", "CharPostureComplex", EE_CHAR_ITALIC_CTL, MID_POSTURE },
+ { "font-style-name", "CharFontStyleName", EE_CHAR_FONTINFO, MID_FONT_STYLE_NAME },
+ { "font-style-name-asian", "CharFontStyleNameAsian", EE_CHAR_FONTINFO_CJK, MID_FONT_STYLE_NAME },
+ { "font-style-name-complex", "CharFontStyleNameComplex", EE_CHAR_FONTINFO_CTL, MID_FONT_STYLE_NAME },
+ { "font-weight", "CharWeight", EE_CHAR_WEIGHT, MID_WEIGHT },
+ { "font-weight-asian", "CharWeightAsian", EE_CHAR_WEIGHT_CJK, MID_WEIGHT },
+ { "font-weight-complex", "CharWeightComplex", EE_CHAR_WEIGHT_CTL, MID_WEIGHT },
+ { "text-overline-width", "CharOverline", EE_CHAR_OVERLINE, MID_TL_STYLE },
+ { "text-overline-color", "CharOverlineColor", EE_CHAR_OVERLINE, MID_TL_COLOR },
+ { "text-overline-color", "CharOverlineHasColor", EE_CHAR_OVERLINE, MID_TL_HASCOLOR },
+ { "text-underline-width", "CharUnderline", EE_CHAR_UNDERLINE, MID_TL_STYLE },
+ { "text-underline-color", "CharUnderlineColor", EE_CHAR_UNDERLINE, MID_TL_COLOR },
+ { "text-underline-color", "CharUnderlineHasColor", EE_CHAR_UNDERLINE, MID_TL_HASCOLOR },
+ { "text-line-through-mode", "CharWordMode", EE_CHAR_WLM, 0 },
+ { "text-line-through-type", "CharStrikeout", EE_CHAR_STRIKEOUT, MID_CROSS_OUT },
+ { "font-relief", "CharRelief", EE_CHAR_RELIEF, MID_RELIEF },
+ { "text-outline", "CharContoured", EE_CHAR_OUTLINE, 0 },
+ { "text-shadow", "CharShadowed", EE_CHAR_SHADOW, 0 },
+ { "letter-spacing", "CharKerning", EE_CHAR_KERNING, 0 },
+ { "letter-kerning", "CharAutoKerning", EE_CHAR_PAIRKERNING, 0 },
+ { "text-scale", "CharScaleWidth", EE_CHAR_FONTWIDTH, 0 },
+ { "text-position", "CharEscapement", EE_CHAR_ESCAPEMENT, MID_ESC },
+ { "text-position", "CharEscapementHeight", EE_CHAR_ESCAPEMENT, MID_ESC_HEIGHT },
+ { "text-emphasize", "CharEmphasis", EE_CHAR_EMPHASISMARK, MID_EMPHASIS },
+ { "country", "CharLocale", EE_CHAR_LANGUAGE, MID_LANG_LOCALE },
+ { "country-asian", "CharLocaleAsian", EE_CHAR_LANGUAGE_CJK, MID_LANG_LOCALE },
+ { "country-complex", "CharLocaleComplex", EE_CHAR_LANGUAGE_CTL, MID_LANG_LOCALE },
};
}
@@ -43,7 +81,7 @@ ScXMLEditAttributeMap::ScXMLEditAttributeMap()
{
maEntries.insert(
EntriesType::value_type(
- OUString::createFromAscii(Entries[i].mpXMLName),
+ OUString::createFromAscii(Entries[i].mpAPIName),
Entry(Entries[i].mnItemID, Entries[i].mnFlag)));
}
}
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index cba7fdb..72de86c 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -65,6 +65,19 @@
#include "editeng/colritem.hxx"
#include "editeng/fhgtitem.hxx"
#include "editeng/postitem.hxx"
+#include "editeng/fontitem.hxx"
+#include "editeng/udlnitem.hxx"
+#include "editeng/wrlmitem.hxx"
+#include "editeng/crsditem.hxx"
+#include "editeng/charreliefitem.hxx"
+#include "editeng/charscaleitem.hxx"
+#include "editeng/cntritem.hxx"
+#include "editeng/shdditem.hxx"
+#include "editeng/kernitem.hxx"
+#include "editeng/akrnitem.hxx"
+#include "editeng/escpitem.hxx"
+#include "editeng/emphitem.hxx"
+#include "editeng/langitem.hxx"
#include <svx/unoapi.hxx>
#include <svl/languageoptions.hxx>
#include <sax/tools/converter.hxx>
@@ -348,57 +361,193 @@ void ScXMLTableRowCellContext::PushParagraphSpan(const OUString& rSpan, const OU
rFmt.maSelection.nStartPos = nBegin;
rFmt.maSelection.nEndPos = nEnd;
+ boost::scoped_ptr<SfxPoolItem> pPoolItem;
+ sal_uInt16 nLastItemID = EE_CHAR_END + 1;
+
std::vector<XMLPropertyState>::const_iterator it = rProps.begin(), itEnd = rProps.end();
for (; it != itEnd; ++it)
{
if (it->mnIndex == -1 || it->mnIndex >= nEntryCount)
continue;
- const OUString& rName = xMapper->GetEntryXMLName(it->mnIndex);
+ const OUString& rName = xMapper->GetEntryAPIName(it->mnIndex);
const ScXMLEditAttributeMap::Entry* pEntry = rEditAttrMap.getEntry(rName);
if (!pEntry)
continue;
+ if (nLastItemID != pEntry->mnItemID && pPoolItem)
+ {
+ // Flush the last item when the item ID changes.
+ rFmt.maItemSet.Put(*pPoolItem);
+ pPoolItem.reset();
+ }
+
switch (pEntry->mnItemID)
{
+ case EE_CHAR_FONTINFO:
+ case EE_CHAR_FONTINFO_CJK:
+ case EE_CHAR_FONTINFO_CTL:
+ {
+ // Font properties need to be consolidated into a single item.
+ if (!pPoolItem)
+ pPoolItem.reset(new SvxFontItem(pEntry->mnItemID));
+
+ pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ }
+ break;
case EE_CHAR_WEIGHT:
case EE_CHAR_WEIGHT_CJK:
case EE_CHAR_WEIGHT_CTL:
{
- SvxWeightItem aItem(WEIGHT_NORMAL, pEntry->mnItemID);
- aItem.PutValue(it->maValue, pEntry->mnFlag);
- rFmt.maItemSet.Put(aItem);
+ if (!pPoolItem)
+ pPoolItem.reset(new SvxWeightItem(WEIGHT_NORMAL, pEntry->mnItemID));
+
+ pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
}
break;
case EE_CHAR_FONTHEIGHT:
case EE_CHAR_FONTHEIGHT_CJK:
case EE_CHAR_FONTHEIGHT_CTL:
{
- SvxFontHeightItem aItem(240, 100, pEntry->mnItemID);
- aItem.PutValue(it->maValue, pEntry->mnFlag);
- rFmt.maItemSet.Put(aItem);
+ if (!pPoolItem)
+ pPoolItem.reset(new SvxFontHeightItem(240, 100, pEntry->mnItemID));
+
+ pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
}
break;
case EE_CHAR_ITALIC:
case EE_CHAR_ITALIC_CJK:
case EE_CHAR_ITALIC_CTL:
{
- SvxPostureItem aItem(ITALIC_NONE, pEntry->mnItemID);
- aItem.PutValue(it->maValue, pEntry->mnFlag);
- rFmt.maItemSet.Put(aItem);
+ if (!pPoolItem)
+ pPoolItem.reset(new SvxPostureItem(ITALIC_NONE, pEntry->mnItemID));
+
+ pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ }
+ break;
+ case EE_CHAR_UNDERLINE:
+ {
+ if (!pPoolItem)
+ pPoolItem.reset(new SvxUnderlineItem(UNDERLINE_NONE, pEntry->mnItemID));
+
+ pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ }
+ break;
+ case EE_CHAR_OVERLINE:
+ {
+ if (!pPoolItem)
+ pPoolItem.reset(new SvxOverlineItem(UNDERLINE_NONE, pEntry->mnItemID));
+
+ pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
}
break;
case EE_CHAR_COLOR:
{
- SvxColorItem aItem(pEntry->mnItemID);
- aItem.PutValue(it->maValue, pEntry->mnFlag);
- rFmt.maItemSet.Put(aItem);
+ if (!pPoolItem)
+ pPoolItem.reset(new SvxColorItem(pEntry->mnItemID));
+
+ pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ }
+ break;
+ case EE_CHAR_WLM:
+ {
+ if (!pPoolItem)
+ pPoolItem.reset(new SvxWordLineModeItem(false, pEntry->mnItemID));
+
+ pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ }
+ break;
+ case EE_CHAR_STRIKEOUT:
+ {
+ if (!pPoolItem)
+ pPoolItem.reset(new SvxCrossedOutItem(STRIKEOUT_NONE, pEntry->mnItemID));
+
+ pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ }
+ break;
+ case EE_CHAR_RELIEF:
+ {
+ if (!pPoolItem)
+ pPoolItem.reset(new SvxCharReliefItem(RELIEF_NONE, pEntry->mnItemID));
+
+ pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ }
+ break;
+ case EE_CHAR_OUTLINE:
+ {
+ if (!pPoolItem)
+ pPoolItem.reset(new SvxContourItem(false, pEntry->mnItemID));
+
+ pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ }
+ break;
+ case EE_CHAR_SHADOW:
+ {
+ if (!pPoolItem)
+ pPoolItem.reset(new SvxShadowedItem(false, pEntry->mnItemID));
+
+ pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ }
+ break;
+ case EE_CHAR_KERNING:
+ {
+ if (!pPoolItem)
+ pPoolItem.reset(new SvxKerningItem(0, pEntry->mnItemID));
+
+ pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ }
+ break;
+ case EE_CHAR_PAIRKERNING:
+ {
+ if (!pPoolItem)
+ pPoolItem.reset(new SvxAutoKernItem(false, pEntry->mnItemID));
+
+ pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ }
+ break;
+ case EE_CHAR_FONTWIDTH:
+ {
+ if (!pPoolItem)
+ pPoolItem.reset(new SvxCharScaleWidthItem(100, pEntry->mnItemID));
+
+ pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ }
+ break;
+ case EE_CHAR_ESCAPEMENT:
+ {
+ if (!pPoolItem)
+ pPoolItem.reset(new SvxEscapementItem(pEntry->mnItemID));
+
+ pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ }
+ break;
+ case EE_CHAR_EMPHASISMARK:
+ {
+ if (!pPoolItem)
+ pPoolItem.reset(new SvxEmphasisMarkItem(EMPHASISMARK_NONE, pEntry->mnItemID));
+
+ pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ }
+ break;
+ case EE_CHAR_LANGUAGE:
+ case EE_CHAR_LANGUAGE_CJK:
+ case EE_CHAR_LANGUAGE_CTL:
+ {
+ if (!pPoolItem)
+ pPoolItem.reset(new SvxLanguageItem(LANGUAGE_DONTKNOW, pEntry->mnItemID));
+
+ pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
}
break;
default:
;
}
+
+ nLastItemID = pEntry->mnItemID;
}
+
+ if (pPoolItem)
+ rFmt.maItemSet.Put(*pPoolItem);
}
void ScXMLTableRowCellContext::PushParagraphEnd()
commit bc7d65cbf8983c04e1698f569c651e9faf0fce69
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Feb 8 21:17:54 2013 -0500
Use hash map to avoid repetitious string comparisons.
Change-Id: I374f5393bf714752037e9cf416fea9667bb80e71
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index a0d4bf8..d205b4a 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -269,6 +269,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/filter/xml/XMLTrackedChangesContext \
sc/source/filter/xml/cachedattraccess \
sc/source/filter/xml/celltextparacontext \
+ sc/source/filter/xml/editattributemap \
sc/source/filter/xml/importcontext \
sc/source/filter/xml/sheetdata \
sc/source/filter/xml/xmlannoi \
diff --git a/sc/source/filter/xml/editattributemap.cxx b/sc/source/filter/xml/editattributemap.cxx
new file mode 100644
index 0000000..3580cc0
--- /dev/null
+++ b/sc/source/filter/xml/editattributemap.cxx
@@ -0,0 +1,57 @@
+/* -*- 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/.
+ */
+
+#include "editattributemap.hxx"
+
+#include "editeng/eeitem.hxx"
+#include "editeng/memberids.hrc"
+
+namespace {
+
+struct {
+ const char* mpXMLName;
+ sal_uInt16 mnItemID;
+ sal_uInt8 mnFlag;
+} Entries[] = {
+ { "color", EE_CHAR_COLOR, 0 },
+ { "font-weight", EE_CHAR_WEIGHT, MID_WEIGHT },
+ { "font-weight-asian", EE_CHAR_WEIGHT_CJK, MID_WEIGHT },
+ { "font-weight-complex", EE_CHAR_WEIGHT_CTL, MID_WEIGHT },
+ { "font-size", EE_CHAR_FONTHEIGHT, MID_FONTHEIGHT },
+ { "font-size-asian", EE_CHAR_FONTHEIGHT_CJK, MID_FONTHEIGHT },
+ { "font-size-complex", EE_CHAR_FONTHEIGHT_CTL, MID_FONTHEIGHT },
+ { "font-style", EE_CHAR_ITALIC, MID_POSTURE },
+ { "font-style-asian", EE_CHAR_ITALIC_CJK, MID_POSTURE },
+ { "font-style-complex", EE_CHAR_ITALIC_CTL, MID_POSTURE },
+};
+
+}
+
+ScXMLEditAttributeMap::Entry::Entry(sal_uInt16 nItemID, sal_uInt8 nFlag) :
+ mnItemID(nItemID), mnFlag(nFlag) {}
+
+ScXMLEditAttributeMap::ScXMLEditAttributeMap()
+{
+ size_t n = sizeof(Entries) / sizeof(Entries[0]);
+ for (size_t i = 0; i < n; ++i)
+ {
+ maEntries.insert(
+ EntriesType::value_type(
+ OUString::createFromAscii(Entries[i].mpXMLName),
+ Entry(Entries[i].mnItemID, Entries[i].mnFlag)));
+ }
+}
+
+const ScXMLEditAttributeMap::Entry* ScXMLEditAttributeMap::getEntry(const OUString& rXMLName) const
+{
+ EntriesType::const_iterator it = maEntries.find(rXMLName);
+ return it == maEntries.end() ? NULL : &it->second;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/xml/editattributemap.hxx b/sc/source/filter/xml/editattributemap.hxx
new file mode 100644
index 0000000..fb981df
--- /dev/null
+++ b/sc/source/filter/xml/editattributemap.hxx
@@ -0,0 +1,43 @@
+/* -*- 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 __SC_XML_EDITATTRIBUTEMAP_HXX__
+#define __SC_XML_EDITATTRIBUTEMAP_HXX__
+
+#include "rtl/ustring.hxx"
+
+#include <boost/unordered_map.hpp>
+
+/**
+ * Provide mapping from ODF text formatting styles to EditEngine's, for
+ * rich-text cell content import.
+ */
+class ScXMLEditAttributeMap
+{
+public:
+ struct Entry
+ {
+ sal_uInt16 mnItemID;
+ sal_uInt8 mnFlag;
+
+ Entry(sal_uInt16 nItemID, sal_uInt8 nFlag);
+ };
+
+ ScXMLEditAttributeMap();
+
+ const Entry* getEntry(const OUString& rXMLName) const;
+
+private:
+ typedef boost::unordered_map<OUString, Entry, OUStringHash> EntriesType;
+ EntriesType maEntries;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/xml/importcontext.hxx b/sc/source/filter/xml/importcontext.hxx
index 146e7e8..878bb97 100644
--- a/sc/source/filter/xml/importcontext.hxx
+++ b/sc/source/filter/xml/importcontext.hxx
@@ -7,8 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#ifndef __IMPORTCONTEXT_HXX__
-#define __IMPORTCONTEXT_HXX__
+#ifndef __SC_XML_IMPORTCONTEXT_HXX__
+#define __SC_XML_IMPORTCONTEXT_HXX__
#include "xmloff/xmlictxt.hxx"
#include "xmloff/xmlimp.hxx"
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index b7206ab..cba7fdb 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -47,6 +47,7 @@
#include "scerrors.hxx"
#include "editutil.hxx"
#include "cell.hxx"
+#include "editattributemap.hxx"
#include <xmloff/xmltkmap.hxx>
#include <xmloff/xmltoken.hxx>
@@ -339,6 +340,8 @@ void ScXMLTableRowCellContext::PushParagraphSpan(const OUString& rSpan, const OU
if (rProps.empty())
return;
+ const ScXMLEditAttributeMap& rEditAttrMap = GetScImport().GetEditAttributeMap();
+
maFormats.push_back(new ParaFormat(*mpEditEngine));
ParaFormat& rFmt = maFormats.back();
rFmt.maSelection.nStartPara = rFmt.maSelection.nEndPara = mnCurParagraph;
@@ -352,66 +355,48 @@ void ScXMLTableRowCellContext::PushParagraphSpan(const OUString& rSpan, const OU
continue;
const OUString& rName = xMapper->GetEntryXMLName(it->mnIndex);
+ const ScXMLEditAttributeMap::Entry* pEntry = rEditAttrMap.getEntry(rName);
+ if (!pEntry)
+ continue;
- if (rName == "font-weight")
- {
- SvxWeightItem aItem(WEIGHT_NORMAL, EE_CHAR_WEIGHT);
- aItem.PutValue(it->maValue, MID_WEIGHT);
- rFmt.maItemSet.Put(aItem);
- }
- else if (rName == "font-weight-asian")
- {
- SvxWeightItem aItem(WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK);
- aItem.PutValue(it->maValue, MID_WEIGHT);
- rFmt.maItemSet.Put(aItem);
- }
- else if (rName == "font-weight-complex")
- {
- SvxWeightItem aItem(WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL);
- aItem.PutValue(it->maValue, MID_WEIGHT);
- rFmt.maItemSet.Put(aItem);
- }
- else if (rName == "font-size")
- {
- SvxFontHeightItem aItem(240, 100, EE_CHAR_FONTHEIGHT);
- aItem.PutValue(it->maValue, MID_FONTHEIGHT);
- rFmt.maItemSet.Put(aItem);
- }
- else if (rName == "font-size-asian")
- {
- SvxFontHeightItem aItem(240, 100, EE_CHAR_FONTHEIGHT_CJK);
- aItem.PutValue(it->maValue, MID_FONTHEIGHT);
- rFmt.maItemSet.Put(aItem);
- }
- else if (rName == "font-size-complex")
- {
- SvxFontHeightItem aItem(240, 100, EE_CHAR_FONTHEIGHT_CTL);
- aItem.PutValue(it->maValue, MID_FONTHEIGHT);
- rFmt.maItemSet.Put(aItem);
- }
- else if (rName == "font-style")
- {
- SvxPostureItem aItem(ITALIC_NONE, EE_CHAR_ITALIC);
- aItem.PutValue(it->maValue, MID_POSTURE);
- rFmt.maItemSet.Put(aItem);
- }
- else if (rName == "font-style-asian")
- {
- SvxPostureItem aItem(ITALIC_NONE, EE_CHAR_ITALIC_CJK);
- aItem.PutValue(it->maValue, MID_POSTURE);
- rFmt.maItemSet.Put(aItem);
- }
- else if (rName == "font-style-complex")
- {
- SvxPostureItem aItem(ITALIC_NONE, EE_CHAR_ITALIC_CTL);
- aItem.PutValue(it->maValue, MID_POSTURE);
- rFmt.maItemSet.Put(aItem);
- }
- else if (rName == "color")
+ switch (pEntry->mnItemID)
{
- SvxColorItem aItem(EE_CHAR_COLOR);
- aItem.PutValue(it->maValue, 0);
- rFmt.maItemSet.Put(aItem);
+ case EE_CHAR_WEIGHT:
+ case EE_CHAR_WEIGHT_CJK:
+ case EE_CHAR_WEIGHT_CTL:
+ {
+ SvxWeightItem aItem(WEIGHT_NORMAL, pEntry->mnItemID);
+ aItem.PutValue(it->maValue, pEntry->mnFlag);
+ rFmt.maItemSet.Put(aItem);
+ }
+ break;
+ case EE_CHAR_FONTHEIGHT:
+ case EE_CHAR_FONTHEIGHT_CJK:
+ case EE_CHAR_FONTHEIGHT_CTL:
+ {
+ SvxFontHeightItem aItem(240, 100, pEntry->mnItemID);
+ aItem.PutValue(it->maValue, pEntry->mnFlag);
+ rFmt.maItemSet.Put(aItem);
+ }
+ break;
+ case EE_CHAR_ITALIC:
+ case EE_CHAR_ITALIC_CJK:
+ case EE_CHAR_ITALIC_CTL:
+ {
+ SvxPostureItem aItem(ITALIC_NONE, pEntry->mnItemID);
+ aItem.PutValue(it->maValue, pEntry->mnFlag);
+ rFmt.maItemSet.Put(aItem);
+ }
+ break;
+ case EE_CHAR_COLOR:
+ {
+ SvxColorItem aItem(pEntry->mnItemID);
+ aItem.PutValue(it->maValue, pEntry->mnFlag);
+ rFmt.maItemSet.Put(aItem);
+ }
+ break;
+ default:
+ ;
}
}
}
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index c4a5ff2..0781667 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -65,6 +65,7 @@
#include "formulaparserpool.hxx"
#include "externalrefmgr.hxx"
#include "editutil.hxx"
+#include "editattributemap.hxx"
#include <comphelper/extract.hxx>
@@ -3375,4 +3376,11 @@ ScEditEngineDefaulter* ScXMLImport::GetEditEngine()
return mpEditEngine.get();
}
+const ScXMLEditAttributeMap& ScXMLImport::GetEditAttributeMap() const
+{
+ if (!mpEditAttrMap)
+ mpEditAttrMap.reset(new ScXMLEditAttributeMap);
+ return *mpEditAttrMap;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx
index fc5ed7a..1aae0b1 100644
--- a/sc/source/filter/xml/xmlimprt.hxx
+++ b/sc/source/filter/xml/xmlimprt.hxx
@@ -758,6 +758,7 @@ struct ScMyImportValidation
typedef std::vector<ScMyImportValidation> ScMyImportValidations;
typedef std::list<SvXMLImportContext*> ScMyViewContextList;
class ScMyStylesImportHelper;
+class ScXMLEditAttributeMap;
class ScXMLImport: public SvXMLImport, boost::noncopyable
{
@@ -769,6 +770,7 @@ class ScXMLImport: public SvXMLImport, boost::noncopyable
ScDocument* pDoc;
boost::scoped_ptr<ScCompiler> mpComp; // For error-checking of cached string cell values.
boost::scoped_ptr<ScEditEngineDefaulter> mpEditEngine;
+ mutable boost::scoped_ptr<ScXMLEditAttributeMap> mpEditAttrMap;
ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
ScMyViewContextList aViewContextList;
ScMyStylesImportHelper* pStylesImportHelper;
@@ -1180,6 +1182,7 @@ public:
bool IsFormulaErrorConstant( const OUString& rStr ) const;
ScEditEngineDefaulter* GetEditEngine();
+ const ScXMLEditAttributeMap& GetEditAttributeMap() const;
};
#endif
More information about the Libreoffice-commits
mailing list