[Libreoffice-commits] core.git: Branch 'feature/ods-edit-cell-import' - 205 commits - android/sdremote avmedia/Library_avmediagst_0_10.mk basctl/source basctl/uiconfig basic/qa basic/source comphelper/inc comphelper/source compilerplugins/clang compilerplugins/Makefile-clang.mk compilerplugins/README config_host.mk.in configure.ac connectivity/CppunitTest_connectivity_commontools.mk connectivity/inc connectivity/qa connectivity/source cppuhelper/source cui/source cui/uiconfig cui/UI_cui.mk dbaccess/source desktop/inc desktop/source dictionaries distro-configs/LibreOfficeLinux.conf editeng/inc editeng/Package_inc.mk editeng/source embeddedobj/source extensions/source extras/Module_extras.mk extras/Package_wordbook.mk extras/Zip_wordbook.mk fileaccess/source filter/source fontconfig/fontconfig-2.8.0.patch forms/source formula/inc formula/source framework/inc framework/source g helpcontent2 i18npool/source io/source jvmaccess/source l10ntools/source liblangtag/ExternalProject_langtag.mk libr elogo/source libvisio/ExternalProject_libvisio.mk libxml2/ExternalPackage_xml2.mk libxml2/ExternalProject_xml2.mk libxml2/libxml2-configure.patch libxml2/libxml2-vc10.patch libxml2/Makefile libxml2/makefile.mk libxml2/Module_libxml2.mk libxml2/prj libxml2/UnpackedTarball_xml2.mk libxmlsec/ExternalProject_xmlsec.mk libxmlsec/xmlsec1-vc.patch libxslt/ExternalProject_xslt.mk libxslt/libxslt-vc10.patch lingucomponent/source linguistic/source lo.xcent.in Module_tail_build.mk mysqlc/Extension_mysql-connector-ooo.mk mysqlc/Library_mysqlc.mk mysqlc/Module_mysqlc.mk mysqlcppconn/Library_mysqlcppconn.mk mysqlc/Rdb_mysqlc.mk mysqlc/source offapi/com offapi/type_reference offapi/UnoApi_offapi.mk officecfg/registry oovbaapi/ooo oovbaapi/UnoApi_oovbaapi.mk oox/inc oox/source package/inc package/source postprocess/prj postprocess/Rdb_services.mk python3/UnpackedTarball_python3.mk redland/ExternalProject_raptor.mk redland/ExternalProject_rasqal.mk redland/ExternalProject_redland.mk registry /tools reportdesign/source RepositoryExternal.mk Repository.mk RepositoryModule_ooo.mk sal/inc sal/osl sal/rtl sc/inc sc/Library_sc.mk scp2/source sc/qa scripting/source sc/source sc/uiconfig sdext/source sd/sdi sd/source sd/uiconfig setup_native/CustomTarget_mac.mk setup_native/CustomTarget_scripts.mk setup_native/CustomTarget_spell.mk setup_native/CustomTarget_wintools.mk setup_native/Library_getuid.mk setup_native/Library_instooofiltmsi.mk setup_native/Library_jfregca.mk setup_native/Library_qslnkmsi.mk setup_native/Library_reg4allmsdoc.mk setup_native/Library_regactivex.mk setup_native/Library_regpatchactivex.mk setup_native/Library_sdqsmsi.mk setup_native/Library_sellangmsi.mk setup_native/Library_shlxtmsi.mk setup_native/Library_sn_tools.mk setup_native/Library_thidxmsi.mk setup_native/Makefile setup_native/Module_setup_native.mk setup_native/Package_misc.mk setup_native/Package_packinfo.mk setup_native/Package_scripts_generated.mk setup_native/Package_scripts.mk setup _native/Package_spell.mk setup_native/Package_ulf.mk setup_native/Package_wintools.mk setup_native/prj setup_native/scripts setup_native/source setup_native/StaticLibrary_quickstarter.mk setup_native/StaticLibrary_seterror.mk sfx2/inc sfx2/source shell/source slideshow/source solenv/bin solenv/gbuild solenv/gdb starmath/inc starmath/qa starmath/source stoc/source store/inc svtools/inc svtools/source svx/inc svx/source sw/inc sw/qa sw/sdi sw/source sw/uiconfig tail_build/prj tools/inc tools/source ucb/source ucb/workben udkapi/com udkapi/UnoApi_udkapi.mk unotools/source vcl/generic vcl/inc vcl/source vcl/uiconfig vcl/unx vcl/win wizards/com writerfilter/source xmlhelp/source xmloff/inc xmloff/source xmlscript/source xmlsecurity/tools
Kohei Yoshida
kohei.yoshida at gmail.com
Mon Feb 11 14:33:00 PST 2013
Rebased ref, commits from common ancestor:
commit 28bb8edb0745654a7425f397d090166687046464
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Feb 11 17:31:59 2013 -0500
Fix for one of the filter tests.
Occasionally characters are assembled via multiple calls to Characters() esp
when the content includes encoded characters and/or XML comments.
Change-Id: I1b6d1e7490350add77388330b183504c24deaab4
diff --git a/sc/source/filter/xml/celltextparacontext.cxx b/sc/source/filter/xml/celltextparacontext.cxx
index ddc0fc3..4a1520f 100644
--- a/sc/source/filter/xml/celltextparacontext.cxx
+++ b/sc/source/filter/xml/celltextparacontext.cxx
@@ -38,7 +38,7 @@ void ScXMLCellTextParaContext::EndElement()
void ScXMLCellTextParaContext::Characters(const OUString& rChars)
{
- maContent = rChars;
+ maContent += rChars;
}
SvXMLImportContext* ScXMLCellTextParaContext::CreateChildContext(
commit 8ac1dc3fecdd8d350040ae734ca27d3f656b273d
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Feb 11 14:08:01 2013 -0500
Import URL fields as well. Now I'm done.
Also fix Tokem to Token typos.
Change-Id: If22b673f6833f3fd485472b17ec508e616e0d59d
diff --git a/sc/source/filter/xml/celltextparacontext.cxx b/sc/source/filter/xml/celltextparacontext.cxx
index abca9d8..ddc0fc3 100644
--- a/sc/source/filter/xml/celltextparacontext.cxx
+++ b/sc/source/filter/xml/celltextparacontext.cxx
@@ -61,6 +61,8 @@ SvXMLImportContext* ScXMLCellTextParaContext::CreateChildContext(
return new ScXMLCellFieldDateContext(GetScImport(), nPrefix, rLocalName, *this);
case XML_TOK_CELL_TEXT_TITLE:
return new ScXMLCellFieldTitleContext(GetScImport(), nPrefix, rLocalName, *this);
+ case XML_TOK_CELL_TEXT_URL:
+ return new ScXMLCellFieldURLContext(GetScImport(), nPrefix, rLocalName, *this);
default:
;
}
@@ -88,6 +90,11 @@ void ScXMLCellTextParaContext::PushFieldTitle()
mrParentCxt.PushParagraphFieldDocTitle();
}
+void ScXMLCellTextParaContext::PushFieldURL(const OUString& rURL, const OUString& rRep)
+{
+ mrParentCxt.PushParagraphFieldURL(rURL, rRep);
+}
+
ScXMLCellTextSpanContext::ScXMLCellTextSpanContext(
ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLName, ScXMLCellTextParaContext& rParent) :
ScXMLImportContext(rImport, nPrefix, rLName),
@@ -132,7 +139,7 @@ void ScXMLCellTextSpanContext::EndElement()
void ScXMLCellTextSpanContext::Characters(const OUString& rChars)
{
- maContent = rChars;
+ maContent += rChars;
}
SvXMLImportContext* ScXMLCellTextSpanContext::CreateChildContext(
@@ -220,4 +227,57 @@ SvXMLImportContext* ScXMLCellFieldTitleContext::CreateChildContext(
return new SvXMLImportContext(GetImport(), nPrefix, rLocalName);
}
+ScXMLCellFieldURLContext::ScXMLCellFieldURLContext(
+ ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLName, ScXMLCellTextParaContext& rParent) :
+ ScXMLImportContext(rImport, nPrefix, rLName),
+ mrParentCxt(rParent)
+{
+}
+
+void ScXMLCellFieldURLContext::StartElement(const uno::Reference<xml::sax::XAttributeList>& xAttrList)
+{
+ if (!xAttrList.is())
+ return;
+
+ OUString aLocalName;
+ sal_Int16 nAttrCount = xAttrList->getLength();
+
+ const SvXMLTokenMap& rTokenMap = GetScImport().GetCellTextURLAttrTokenMap();
+ for (sal_Int16 i = 0; i < nAttrCount; ++i)
+ {
+ sal_uInt16 nAttrPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(
+ xAttrList->getNameByIndex(i), &aLocalName);
+
+ const OUString& rAttrValue = xAttrList->getValueByIndex(i);
+ sal_uInt16 nToken = rTokenMap.Get(nAttrPrefix, aLocalName);
+ switch (nToken)
+ {
+ case XML_TOK_CELL_TEXT_URL_ATTR_UREF:
+ maURL = rAttrValue;
+ break;
+ case XML_TOK_CELL_TEXT_URL_ATTR_TYPE:
+ // Ignored for now.
+ break;
+ default:
+ ;
+ }
+ }
+}
+
+void ScXMLCellFieldURLContext::EndElement()
+{
+ mrParentCxt.PushFieldURL(maURL, maRep);
+}
+
+void ScXMLCellFieldURLContext::Characters(const OUString& rChars)
+{
+ maRep += rChars;
+}
+
+SvXMLImportContext* ScXMLCellFieldURLContext::CreateChildContext(
+ sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference<xml::sax::XAttributeList>& /*xAttrList*/)
+{
+ return new SvXMLImportContext(GetImport(), nPrefix, rLocalName);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/xml/celltextparacontext.hxx b/sc/source/filter/xml/celltextparacontext.hxx
index e9d11aa..9390a3e 100644
--- a/sc/source/filter/xml/celltextparacontext.hxx
+++ b/sc/source/filter/xml/celltextparacontext.hxx
@@ -35,6 +35,7 @@ public:
void PushFieldSheetName();
void PushFieldDate();
void PushFieldTitle();
+ void PushFieldURL(const OUString& rURL, const OUString& rRep);
};
/**
@@ -57,7 +58,6 @@ public:
/**
* This context handles <text:sheet-name> element inside <text:p>.
- *
*/
class ScXMLCellFieldSheetNameContext : public ScXMLImportContext
{
@@ -74,7 +74,6 @@ public:
/**
* This context handles <text:date> element inside <text:p>.
- *
*/
class ScXMLCellFieldDateContext : public ScXMLImportContext
{
@@ -91,7 +90,6 @@ public:
/**
* This context handles <text:title> element inside <text:p>.
- *
*/
class ScXMLCellFieldTitleContext : public ScXMLImportContext
{
@@ -106,6 +104,24 @@ public:
sal_uInt16 nPrefix, const OUString& rLocalName, const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList>& xAttrList);
};
+/**
+ * This context handles <text:a> element inside <text:p>.
+ */
+class ScXMLCellFieldURLContext : public ScXMLImportContext
+{
+ ScXMLCellTextParaContext& mrParentCxt;
+ OUString maURL;
+ OUString maRep;
+public:
+ ScXMLCellFieldURLContext(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 86a6f04..701e784 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -586,6 +586,11 @@ void ScXMLTableRowCellContext::PushParagraphFieldDocTitle()
PushParagraphField(new SvxFileField);
}
+void ScXMLTableRowCellContext::PushParagraphFieldURL(const OUString& rURL, const OUString& rRep)
+{
+ PushParagraphField(new SvxURLField(rURL, rRep, SVXURLFORMAT_REPR));
+}
+
void ScXMLTableRowCellContext::PushParagraphEnd()
{
// EditEngine always has at least one paragraph even when its content is empty.
diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx
index 9fef82b..e59aa6e 100644
--- a/sc/source/filter/xml/xmlcelli.hxx
+++ b/sc/source/filter/xml/xmlcelli.hxx
@@ -139,6 +139,7 @@ public:
void PushParagraphFieldDate();
void PushParagraphFieldSheetName();
void PushParagraphFieldDocTitle();
+ void PushParagraphFieldURL(const OUString& rURL, const OUString& rRep);
void PushParagraphEnd();
void SetAnnotation( const ScAddress& rPosition );
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index fb5516f..bd5fd4d 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -1845,7 +1845,7 @@ const SvXMLTokenMap& ScXMLImport::GetConsolidationAttrTokenMap()
const SvXMLTokenMap& ScXMLImport::GetCellTextParaElemTokenMap()
{
- if (!pCellTextParaElemTokemMap)
+ if (!pCellTextParaElemTokenMap)
{
static SvXMLTokenMapEntry aMap[] =
{
@@ -1853,17 +1853,18 @@ const SvXMLTokenMap& ScXMLImport::GetCellTextParaElemTokenMap()
{ 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_NAMESPACE_TEXT, XML_A, XML_TOK_CELL_TEXT_URL },
XML_TOKEN_MAP_END
};
- pCellTextParaElemTokemMap = new SvXMLTokenMap(aMap);
+ pCellTextParaElemTokenMap = new SvXMLTokenMap(aMap);
}
- return *pCellTextParaElemTokemMap;
+ return *pCellTextParaElemTokenMap;
}
const SvXMLTokenMap& ScXMLImport::GetCellTextSpanAttrTokenMap()
{
- if (!pCellTextSpanAttrTokemMap)
+ if (!pCellTextSpanAttrTokenMap)
{
static SvXMLTokenMapEntry aMap[] =
{
@@ -1871,9 +1872,25 @@ const SvXMLTokenMap& ScXMLImport::GetCellTextSpanAttrTokenMap()
XML_TOKEN_MAP_END
};
- pCellTextSpanAttrTokemMap = new SvXMLTokenMap(aMap);
+ pCellTextSpanAttrTokenMap = new SvXMLTokenMap(aMap);
}
- return *pCellTextSpanAttrTokemMap;
+ return *pCellTextSpanAttrTokenMap;
+}
+
+const SvXMLTokenMap& ScXMLImport::GetCellTextURLAttrTokenMap()
+{
+ if (!pCellTextURLAttrTokenMap)
+ {
+ static SvXMLTokenMapEntry aMap[] =
+ {
+ { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_CELL_TEXT_URL_ATTR_UREF },
+ { XML_NAMESPACE_XLINK, XML_TYPE, XML_TOK_CELL_TEXT_URL_ATTR_TYPE },
+ XML_TOKEN_MAP_END
+ };
+
+ pCellTextURLAttrTokenMap = new SvXMLTokenMap(aMap);
+ }
+ return *pCellTextURLAttrTokenMap;
}
SvXMLImportContext *ScXMLImport::CreateContext( sal_uInt16 nPrefix,
@@ -1998,8 +2015,9 @@ ScXMLImport::ScXMLImport(
pDataPilotMembersElemTokenMap( 0 ),
pDataPilotMemberAttrTokenMap( 0 ),
pConsolidationAttrTokenMap( 0 ),
- pCellTextParaElemTokemMap(NULL),
- pCellTextSpanAttrTokemMap(NULL),
+ pCellTextParaElemTokenMap(NULL),
+ pCellTextSpanAttrTokenMap(NULL),
+ pCellTextURLAttrTokenMap(NULL),
aTables(*this),
pMyNamedExpressions(NULL),
pMyLabelRanges(NULL),
@@ -2137,8 +2155,9 @@ ScXMLImport::~ScXMLImport() throw()
delete pDataPilotMembersElemTokenMap;
delete pDataPilotMemberAttrTokenMap;
delete pConsolidationAttrTokenMap;
- delete pCellTextParaElemTokemMap;
- delete pCellTextSpanAttrTokemMap;
+ delete pCellTextParaElemTokenMap;
+ delete pCellTextSpanAttrTokenMap;
+ delete pCellTextURLAttrTokenMap;
delete pChangeTrackingImportHelper;
delete pNumberFormatAttributesExportHelper;
diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx
index da35d640..09a3639 100644
--- a/sc/source/filter/xml/xmlimprt.hxx
+++ b/sc/source/filter/xml/xmlimprt.hxx
@@ -690,7 +690,8 @@ enum ScXMLCellTextParaElemTokens
XML_TOK_CELL_TEXT_SPAN,
XML_TOK_CELL_TEXT_SHEET_NAME,
XML_TOK_CELL_TEXT_DATE,
- XML_TOK_CELL_TEXT_TITLE
+ XML_TOK_CELL_TEXT_TITLE,
+ XML_TOK_CELL_TEXT_URL
};
/**
@@ -701,6 +702,12 @@ enum ScXMLCellTextSpanAttrTokens
XML_TOK_CELL_TEXT_SPAN_ATTR_STYLE_NAME
};
+enum ScXMLCellTextURLAttrTokens
+{
+ XML_TOK_CELL_TEXT_URL_ATTR_UREF,
+ XML_TOK_CELL_TEXT_URL_ATTR_TYPE,
+};
+
class SvXMLTokenMap;
class XMLShapeImportHelper;
class ScXMLChangeTrackingImportHelper;
@@ -869,8 +876,9 @@ class ScXMLImport: public SvXMLImport, boost::noncopyable
SvXMLTokenMap *pDataPilotMembersElemTokenMap;
SvXMLTokenMap *pDataPilotMemberAttrTokenMap;
SvXMLTokenMap *pConsolidationAttrTokenMap;
- SvXMLTokenMap *pCellTextParaElemTokemMap;
- SvXMLTokenMap *pCellTextSpanAttrTokemMap;
+ SvXMLTokenMap *pCellTextParaElemTokenMap;
+ SvXMLTokenMap *pCellTextSpanAttrTokenMap;
+ SvXMLTokenMap *pCellTextURLAttrTokenMap;
ScMyTables aTables;
@@ -1038,6 +1046,7 @@ public:
const SvXMLTokenMap& GetConsolidationAttrTokenMap();
const SvXMLTokenMap& GetCellTextParaElemTokenMap();
const SvXMLTokenMap& GetCellTextSpanAttrTokenMap();
+ const SvXMLTokenMap& GetCellTextURLAttrTokenMap();
void AddNamedExpression(ScMyNamedExpression* pMyNamedExpression)
{
commit 4e6c17081919d93be0db513c5dc52722563a9f31
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Feb 11 13:31:26 2013 -0500
Import date fields.
Change-Id: If37f5253e4e201aab30c54ce503b6c8b6d967d92
diff --git a/sc/source/filter/xml/celltextparacontext.cxx b/sc/source/filter/xml/celltextparacontext.cxx
index a4ce72d..abca9d8 100644
--- a/sc/source/filter/xml/celltextparacontext.cxx
+++ b/sc/source/filter/xml/celltextparacontext.cxx
@@ -78,8 +78,9 @@ void ScXMLCellTextParaContext::PushFieldSheetName()
mrParentCxt.PushParagraphFieldSheetName();
}
-void ScXMLCellTextParaContext::PushFieldDate(const OUString& rOutput)
+void ScXMLCellTextParaContext::PushFieldDate()
{
+ mrParentCxt.PushParagraphFieldDate();
}
void ScXMLCellTextParaContext::PushFieldTitle()
@@ -180,11 +181,11 @@ void ScXMLCellFieldDateContext::StartElement(const uno::Reference<xml::sax::XAtt
void ScXMLCellFieldDateContext::EndElement()
{
+ mrParentCxt.PushFieldDate();
}
-void ScXMLCellFieldDateContext::Characters(const OUString& rChars)
+void ScXMLCellFieldDateContext::Characters(const OUString& /*rChars*/)
{
- maDate = rChars;
}
SvXMLImportContext* ScXMLCellFieldDateContext::CreateChildContext(
@@ -209,9 +210,8 @@ void ScXMLCellFieldTitleContext::EndElement()
mrParentCxt.PushFieldTitle();
}
-void ScXMLCellFieldTitleContext::Characters(const OUString& rChars)
+void ScXMLCellFieldTitleContext::Characters(const OUString& /*rChars*/)
{
- maTitle = rChars;
}
SvXMLImportContext* ScXMLCellFieldTitleContext::CreateChildContext(
diff --git a/sc/source/filter/xml/celltextparacontext.hxx b/sc/source/filter/xml/celltextparacontext.hxx
index 55ea8ef..e9d11aa 100644
--- a/sc/source/filter/xml/celltextparacontext.hxx
+++ b/sc/source/filter/xml/celltextparacontext.hxx
@@ -33,7 +33,7 @@ public:
void PushSpan(const OUString& rSpan, const OUString& rStyleName);
void PushFieldSheetName();
- void PushFieldDate(const OUString& rOutput);
+ void PushFieldDate();
void PushFieldTitle();
};
@@ -79,7 +79,6 @@ public:
class ScXMLCellFieldDateContext : public ScXMLImportContext
{
ScXMLCellTextParaContext& mrParentCxt;
- OUString maDate;
public:
ScXMLCellFieldDateContext(ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLName, ScXMLCellTextParaContext& rParent);
@@ -97,7 +96,6 @@ public:
class ScXMLCellFieldTitleContext : public ScXMLImportContext
{
ScXMLCellTextParaContext& mrParentCxt;
- OUString maTitle;
public:
ScXMLCellFieldTitleContext(ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLName, ScXMLCellTextParaContext& rParent);
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 255d5ae..86a6f04 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -570,6 +570,11 @@ void ScXMLTableRowCellContext::PushParagraphField(SvxFieldData* pData)
rField.maSelection.nEndPos = nPos+1;
}
+void ScXMLTableRowCellContext::PushParagraphFieldDate()
+{
+ PushParagraphField(new SvxDateField);
+}
+
void ScXMLTableRowCellContext::PushParagraphFieldSheetName()
{
SCTAB nTab = GetScImport().GetTables().GetCurrentCellPos().Tab();
diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx
index 022d5a2..9fef82b 100644
--- a/sc/source/filter/xml/xmlcelli.hxx
+++ b/sc/source/filter/xml/xmlcelli.hxx
@@ -136,6 +136,7 @@ public:
::com::sun::star::xml::sax::XAttributeList>& xAttrList );
void PushParagraphSpan(const OUString& rSpan, const OUString& rStyleName);
+ void PushParagraphFieldDate();
void PushParagraphFieldSheetName();
void PushParagraphFieldDocTitle();
void PushParagraphEnd();
commit 07a6ca3b0993e0a90f5081249843f55013858b68
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Feb 11 13:25:53 2013 -0500
Import document title field as well.
Change-Id: Iea73d553927ce95afbb9b6e9062b398733228687
diff --git a/sc/source/filter/xml/celltextparacontext.cxx b/sc/source/filter/xml/celltextparacontext.cxx
index 84249b4..a4ce72d 100644
--- a/sc/source/filter/xml/celltextparacontext.cxx
+++ b/sc/source/filter/xml/celltextparacontext.cxx
@@ -82,8 +82,9 @@ void ScXMLCellTextParaContext::PushFieldDate(const OUString& rOutput)
{
}
-void ScXMLCellTextParaContext::PushFieldTitle(const OUString& rTitle)
+void ScXMLCellTextParaContext::PushFieldTitle()
{
+ mrParentCxt.PushParagraphFieldDocTitle();
}
ScXMLCellTextSpanContext::ScXMLCellTextSpanContext(
@@ -205,6 +206,7 @@ void ScXMLCellFieldTitleContext::StartElement(const uno::Reference<xml::sax::XAt
void ScXMLCellFieldTitleContext::EndElement()
{
+ mrParentCxt.PushFieldTitle();
}
void ScXMLCellFieldTitleContext::Characters(const OUString& rChars)
diff --git a/sc/source/filter/xml/celltextparacontext.hxx b/sc/source/filter/xml/celltextparacontext.hxx
index 7840cd6..55ea8ef 100644
--- a/sc/source/filter/xml/celltextparacontext.hxx
+++ b/sc/source/filter/xml/celltextparacontext.hxx
@@ -34,7 +34,7 @@ public:
void PushSpan(const OUString& rSpan, const OUString& rStyleName);
void PushFieldSheetName();
void PushFieldDate(const OUString& rOutput);
- void PushFieldTitle(const OUString& rTitle);
+ void PushFieldTitle();
};
/**
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index aff762f..255d5ae 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -116,11 +116,11 @@ using namespace xmloff::token;
ScXMLTableRowCellContext::ParaFormat::ParaFormat(ScEditEngineDefaulter& rEditEngine) :
maItemSet(rEditEngine.GetEmptyItemSet()) {}
-ScXMLTableRowCellContext::Field::Field() : mpItem(NULL) {}
+ScXMLTableRowCellContext::Field::Field(SvxFieldData* pData) : mpData(pData) {}
ScXMLTableRowCellContext::Field::~Field()
{
- delete mpItem;
+ delete mpData;
}
ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport,
@@ -557,20 +557,30 @@ void ScXMLTableRowCellContext::PushParagraphSpan(const OUString& rSpan, const OU
rFmt.maItemSet.Put(*pPoolItem);
}
-void ScXMLTableRowCellContext::PushParagraphFieldSheetName()
+void ScXMLTableRowCellContext::PushParagraphField(SvxFieldData* pData)
{
- SCTAB nTab = GetScImport().GetTables().GetCurrentCellPos().Tab();
- maFields.push_back(new Field);
+ maFields.push_back(new Field(pData));
Field& rField = maFields.back();
- rField.mpItem = new SvxTableField(nTab);
+
sal_Int32 nPos = maParagraph.getLength();
- maParagraph.append(sal_Unicode('\1'));
+ 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::PushParagraphFieldSheetName()
+{
+ SCTAB nTab = GetScImport().GetTables().GetCurrentCellPos().Tab();
+ PushParagraphField(new SvxTableField(nTab));
+}
+
+void ScXMLTableRowCellContext::PushParagraphFieldDocTitle()
+{
+ PushParagraphField(new SvxFileField);
+}
+
void ScXMLTableRowCellContext::PushParagraphEnd()
{
// EditEngine always has at least one paragraph even when its content is empty.
@@ -1027,7 +1037,7 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos,
{
FieldsType::const_iterator it = maFields.begin(), itEnd = maFields.end();
for (; it != itEnd; ++it)
- mpEditEngine->QuickInsertField(SvxFieldItem(*it->mpItem, EE_FEATURE_FIELD), it->maSelection);
+ mpEditEngine->QuickInsertField(SvxFieldItem(*it->mpData, 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 20f4465..022d5a2 100644
--- a/sc/source/filter/xml/xmlcelli.hxx
+++ b/sc/source/filter/xml/xmlcelli.hxx
@@ -49,10 +49,10 @@ class ScXMLTableRowCellContext : public ScXMLImportContext
struct Field : boost::noncopyable
{
- SvxFieldData* mpItem;
+ SvxFieldData* mpData;
ESelection maSelection;
- Field();
+ Field(SvxFieldData* pData);
~Field();
};
@@ -118,6 +118,8 @@ class ScXMLTableRowCellContext : public ScXMLImportContext
bool IsPossibleErrorString() const;
+ void PushParagraphField(SvxFieldData* pData);
+
public:
ScXMLTableRowCellContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
@@ -135,6 +137,7 @@ public:
void PushParagraphSpan(const OUString& rSpan, const OUString& rStyleName);
void PushParagraphFieldSheetName();
+ void PushParagraphFieldDocTitle();
void PushParagraphEnd();
void SetAnnotation( const ScAddress& rPosition );
commit 897d7b5b5589d99e41d7f68862de8caef9dca66e
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 382921998c160f2fb728de51d6391a5ad7eba08b
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;
commit 907162475e20b3556b1c2506fc1e24afc144d4c5
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Feb 11 11:28:54 2013 -0500
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
diff --git a/sc/source/filter/xml/celltextparacontext.cxx b/sc/source/filter/xml/celltextparacontext.cxx
index d15b715..84249b4 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 8401c0d..7840cd6 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 72de86c..47aa7ee 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 e9d7e23..bdb817c 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 0781667..fb5516f 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 1aae0b1..da35d640 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
};
/**
commit 991bfb5de592471529d93624de5d34aed5889cb7
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 41a310c6111bdb6023b67e910dcd17b1630a4c40
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
commit db0e2744187d547155d03b684da51d2d475469d9
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Feb 8 19:44:53 2013 -0500
We don't need this anymore BTW.
Change-Id: I1a871b6722aaef937aeabb1f1f6f3f0cfe7758c2
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 88f88df..b7206ab 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -99,9 +99,6 @@
using namespace com::sun::star;
using namespace xmloff::token;
-using rtl::OUString;
-
-
ScXMLTableRowCellContext::ParaFormat::ParaFormat(ScEditEngineDefaulter& rEditEngine) :
maItemSet(rEditEngine.GetEmptyItemSet()) {}
commit 99ec529410cf75d36ac3fc353517fa119968fad2
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Feb 8 19:43:22 2013 -0500
Import formatted spans correctly.
There are more format types to cover. I'm not done yet.
Change-Id: I42fab04f65810733e5b25fbbc2c92df7e05c05cf
diff --git a/sc/source/filter/xml/celltextparacontext.cxx b/sc/source/filter/xml/celltextparacontext.cxx
index 66c48e7..d15b715 100644
--- a/sc/source/filter/xml/celltextparacontext.cxx
+++ b/sc/source/filter/xml/celltextparacontext.cxx
@@ -11,6 +11,8 @@
#include "xmlimprt.hxx"
#include "xmlcelli.hxx"
+#include "xmloff/nmspmap.hxx"
+
#include <com/sun/star/xml/sax/XAttributeList.hpp>
using namespace com::sun::star;
@@ -29,7 +31,7 @@ void ScXMLCellTextParaContext::StartElement(const uno::Reference<xml::sax::XAttr
void ScXMLCellTextParaContext::EndElement()
{
if (!maContent.isEmpty())
- mrParentCxt.PushParagraphSpan(maContent);
+ mrParentCxt.PushParagraphSpan(maContent, OUString());
mrParentCxt.PushParagraphEnd();
}
@@ -44,7 +46,7 @@ SvXMLImportContext* ScXMLCellTextParaContext::CreateChildContext(
{
if (!maContent.isEmpty())
{
- mrParentCxt.PushParagraphSpan(maContent);
+ mrParentCxt.PushParagraphSpan(maContent, OUString());
maContent = OUString();
}
@@ -61,9 +63,9 @@ SvXMLImportContext* ScXMLCellTextParaContext::CreateChildContext(
return new SvXMLImportContext(GetImport(), nPrefix, rLocalName);
}
-void ScXMLCellTextParaContext::PushSpan(const OUString& rSpan)
+void ScXMLCellTextParaContext::PushSpan(const OUString& rSpan, const OUString& rStyleName)
{
- mrParentCxt.PushParagraphSpan(rSpan);
+ mrParentCxt.PushParagraphSpan(rSpan, rStyleName);
}
ScXMLCellTextSpanContext::ScXMLCellTextSpanContext(
@@ -75,12 +77,37 @@ ScXMLCellTextSpanContext::ScXMLCellTextSpanContext(
void ScXMLCellTextSpanContext::StartElement(const uno::Reference<xml::sax::XAttributeList>& xAttrList)
{
+ if (!xAttrList.is())
+ return;
+
+ OUString aLocalName;
+ sal_Int16 nAttrCount = xAttrList->getLength();
+
+ const SvXMLTokenMap& rTokenMap = GetScImport().GetCellTextSpanAttrTokenMap();
+ for (sal_Int16 i = 0; i < nAttrCount; ++i)
+ {
+ sal_uInt16 nAttrPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(
+ xAttrList->getNameByIndex(i), &aLocalName);
+
+ const OUString& rAttrValue = xAttrList->getValueByIndex(i);
+ sal_uInt16 nToken = rTokenMap.Get(nAttrPrefix, aLocalName);
+ switch (nToken)
+ {
+ case XML_TOK_CELL_TEXT_SPAN_ATTR_STYLE_NAME:
+ maStyleName = rAttrValue;
+ break;
+ default:
+ ;
+ }
+ }
}
void ScXMLCellTextSpanContext::EndElement()
{
if (!maContent.isEmpty())
- mrParentCxt.PushSpan(maContent);
+ {
+ mrParentCxt.PushSpan(maContent, maStyleName);
+ }
}
void ScXMLCellTextSpanContext::Characters(const OUString& rChars)
diff --git a/sc/source/filter/xml/celltextparacontext.hxx b/sc/source/filter/xml/celltextparacontext.hxx
index 75ce3f8..8401c0d 100644
--- a/sc/source/filter/xml/celltextparacontext.hxx
+++ b/sc/source/filter/xml/celltextparacontext.hxx
@@ -31,7 +31,7 @@ public:
virtual SvXMLImportContext* CreateChildContext(
sal_uInt16 nPrefix, const OUString& rLocalName, const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList>& xAttrList);
- void PushSpan(const OUString& rSpan);
+ void PushSpan(const OUString& rSpan, const OUString& rStyleName);
};
/**
@@ -40,6 +40,7 @@ public:
class ScXMLCellTextSpanContext : public ScXMLImportContext
{
ScXMLCellTextParaContext& mrParentCxt;
+ OUString maStyleName;
OUString maContent;
public:
ScXMLCellTextSpanContext(ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLName, ScXMLCellTextParaContext& rParent);
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 4e13655..88f88df 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -55,10 +55,15 @@
#include <xmloff/families.hxx>
#include <xmloff/numehelp.hxx>
#include <xmloff/xmlnmspe.hxx>
+#include "xmloff/prstylei.hxx"
#include <svl/zforlist.hxx>
#include <svx/svdocapt.hxx>
#include <editeng/outlobj.hxx>
#include <editeng/editobj.hxx>
+#include "editeng/wghtitem.hxx"
+#include "editeng/colritem.hxx"
+#include "editeng/fhgtitem.hxx"
+#include "editeng/postitem.hxx"
#include <svx/unoapi.hxx>
#include <svl/languageoptions.hxx>
#include <sax/tools/converter.hxx>
@@ -96,7 +101,9 @@ using namespace xmloff::token;
using rtl::OUString;
-//------------------------------------------------------------------
+
+ScXMLTableRowCellContext::ParaFormat::ParaFormat(ScEditEngineDefaulter& rEditEngine) :
+ maItemSet(rEditEngine.GetEmptyItemSet()) {}
ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport,
sal_uInt16 nPrfx,
@@ -107,6 +114,7 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport,
const sal_Int32 nTempRepeatedRows ) :
ScXMLImportContext(rImport, nPrfx, rLName),
mpEditEngine(GetScImport().GetEditEngine()),
+ mnCurParagraph(0),
pDetectiveObjVec(NULL),
pCellRangeSource(NULL),
fValue(0.0),
@@ -125,7 +133,8 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport,
bSolarMutexLocked(false),
bFormulaTextResult(false),
mbPossibleErrorCell(false),
- mbCheckWithCompilerForError(false)
+ mbCheckWithCompilerForError(false),
+ mbEditEngineHasText(false)
{
rtl::math::setNan(&fValue); // NaN by default
mpEditEngine->Clear();
@@ -302,15 +311,127 @@ bool cellExists( const ScAddress& rCellPos )
}
-void ScXMLTableRowCellContext::PushParagraphSpan(const OUString& rSpan)
+void ScXMLTableRowCellContext::PushParagraphSpan(const OUString& rSpan, const OUString& rStyleName)
{
+ sal_Int32 nBegin = maParagraph.getLength();
+ sal_Int32 nEnd = nBegin + rSpan.getLength();
maParagraph.append(rSpan);
+
+ if (rStyleName.isEmpty())
+ return;
+
+ // Get the style information from xmloff.
+ UniReference<XMLPropertySetMapper> xMapper = GetImport().GetTextImport()->GetTextImportPropertySetMapper()->getPropertySetMapper();
+ if (!xMapper.is())
+ // We can't do anything without the mapper.
+ return;
+
+ sal_Int32 nEntryCount = xMapper->GetEntryCount();
+
+ SvXMLStylesContext* pAutoStyles = GetImport().GetAutoStyles();
+
+ // Style name for text span corresponds with the name of an automatic style.
+ const XMLPropStyleContext* pStyle = dynamic_cast<const XMLPropStyleContext*>(
+ pAutoStyles->FindStyleChildContext(XML_STYLE_FAMILY_TEXT_TEXT, rStyleName));
+
+ if (!pStyle)
+ // No style by that name found.
+ return;
+
+ const std::vector<XMLPropertyState>& rProps = pStyle->GetProperties();
+ if (rProps.empty())
+ return;
+
+ maFormats.push_back(new ParaFormat(*mpEditEngine));
+ ParaFormat& rFmt = maFormats.back();
+ rFmt.maSelection.nStartPara = rFmt.maSelection.nEndPara = mnCurParagraph;
+ rFmt.maSelection.nStartPos = nBegin;
+ rFmt.maSelection.nEndPos = nEnd;
+
+ 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);
+
+ 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")
+ {
+ SvxColorItem aItem(EE_CHAR_COLOR);
+ aItem.PutValue(it->maValue, 0);
+ rFmt.maItemSet.Put(aItem);
+ }
+ }
}
void ScXMLTableRowCellContext::PushParagraphEnd()
{
- mpEditEngine->InsertParagraph(
- mpEditEngine->GetParagraphCount(), maParagraph.makeStringAndClear());
+ // EditEngine always has at least one paragraph even when its content is empty.
+
+ if (mbEditEngineHasText)
+ mpEditEngine->InsertParagraph(mpEditEngine->GetParagraphCount(), maParagraph.makeStringAndClear());
+ else
+ {
+ mpEditEngine->SetText(maParagraph.makeStringAndClear());
+ mbEditEngineHasText = true;
+ }
+
+ ++mnCurParagraph;
}
SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 nPrefix,
@@ -674,7 +795,7 @@ void ScXMLTableRowCellContext::SetFormulaCell(ScFormulaCell* pFCell) const
}
else if (!rtl::math::isNan(fValue))
{
- if (mpEditEngine->GetParagraphCount())
+ if (mbEditEngineHasText)
pFCell->SetHybridValueString(fValue, mpEditEngine->GetText(0));
else
pFCell->SetHybridDouble(fValue);
@@ -700,7 +821,7 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos,
OUString aCellString;
if (maStringValue)
aCellString = *maStringValue;
- else if (mpEditEngine->GetParagraphCount())
+ else if (mbEditEngineHasText)
aCellString = mpEditEngine->GetText(0);
else if ( nCurrentCol > 0 && pOUText && !pOUText->isEmpty() )
aCellString = *pOUText;
@@ -735,8 +856,23 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos,
ScDocument* pDoc = rXMLImport.GetDocument();
if (maStringValue)
pNewCell = ScBaseCell::CreateTextCell( *maStringValue, pDoc );
- else if (mpEditEngine->GetParagraphCount())
- pNewCell = new ScEditCell(mpEditEngine->CreateTextObject(), pDoc, pDoc->GetEditPool());
+ else if (mbEditEngineHasText)
+ {
+ if (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);
+
+ pNewCell = new ScEditCell(mpEditEngine->CreateTextObject(), pDoc, pDoc->GetEditPool());
+ }
+ }
else if ( nCurrentCol > 0 && pOUText && !pOUText->isEmpty() )
pNewCell = ScBaseCell::CreateTextCell( *pOUText, pDoc );
@@ -942,7 +1078,7 @@ void ScXMLTableRowCellContext::AddNonFormulaCell( const ScAddress& rCellPos )
if( cellExists(rCellPos) && CellsAreRepeated() )
pOUText.reset( getOutputString(rXMLImport.GetDocument(), rCellPos) );
- if (!mpEditEngine->GetParagraphCount() && !pOUText && !maStringValue)
+ if (!mbEditEngineHasText && !pOUText && !maStringValue)
bIsEmpty = true;
}
@@ -1092,7 +1228,7 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos )
// - has an "Err:[###]" (where "[###]" is an error number)
void ScXMLTableRowCellContext::HasSpecialCaseFormulaText()
{
- if (!mpEditEngine->GetParagraphCount())
+ if (!mbEditEngineHasText)
return;
OUString aStr = mpEditEngine->GetText(0);
diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx
index cbd622f..e9d7e23 100644
--- a/sc/source/filter/xml/xmlcelli.hxx
+++ b/sc/source/filter/xml/xmlcelli.hxx
@@ -23,8 +23,12 @@
#include "XMLCellRangeSourceContext.hxx"
#include "importcontext.hxx"
#include "formula/grammar.hxx"
+#include "svl/itemset.hxx"
+#include "editeng/editdata.hxx"
+
#include <boost/optional.hpp>
#include <boost/scoped_ptr.hpp>
+#include <boost/ptr_container/ptr_vector.hpp>
class ScXMLImport;
class ScFormulaCell;
@@ -41,6 +45,17 @@ class ScXMLTableRowCellContext : public ScXMLImportContext
ScEditEngineDefaulter* mpEditEngine;
OUStringBuffer maParagraph;
+ sal_uInt16 mnCurParagraph;
+
+ struct ParaFormat
+ {
+ SfxItemSet maItemSet;
+ ESelection maSelection;
+
+ ParaFormat(ScEditEngineDefaulter& rEditEngine);
+ };
+ typedef boost::ptr_vector<ParaFormat> ParaFormatsType;
+ ParaFormatsType maFormats;
boost::scoped_ptr< ScXMLAnnotationData > mxAnnotationData;
ScMyImpDetectiveObjVec* pDetectiveObjVec;
@@ -58,8 +73,9 @@ class ScXMLTableRowCellContext : public ScXMLImportContext
bool bIsFirstTextImport;
bool bSolarMutexLocked;
bool bFormulaTextResult;
- bool mbPossibleErrorCell;
- bool mbCheckWithCompilerForError;
+ bool mbPossibleErrorCell;
+ bool mbCheckWithCompilerForError;
+ bool mbEditEngineHasText;
sal_Int16 GetCellType(const rtl::OUString& sOUValue) const;
@@ -103,7 +119,7 @@ public:
const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList>& xAttrList );
- void PushParagraphSpan(const OUString& rSpan);
+ void PushParagraphSpan(const OUString& rSpan, 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 e62ec9b..c4a5ff2 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -1857,6 +1857,21 @@ const SvXMLTokenMap& ScXMLImport::GetCellTextParaElemTokenMap()
return *pCellTextParaElemTokemMap;
}
+const SvXMLTokenMap& ScXMLImport::GetCellTextSpanAttrTokenMap()
+{
+ if (!pCellTextSpanAttrTokemMap)
+ {
+ static SvXMLTokenMapEntry aMap[] =
+ {
+ { XML_NAMESPACE_TEXT, XML_STYLE_NAME, XML_TOK_CELL_TEXT_SPAN_ATTR_STYLE_NAME },
+ XML_TOKEN_MAP_END
+ };
+
+ pCellTextSpanAttrTokemMap = new SvXMLTokenMap(aMap);
+ }
+ return *pCellTextSpanAttrTokemMap;
+}
+
SvXMLImportContext *ScXMLImport::CreateContext( sal_uInt16 nPrefix,
const OUString& rLocalName,
const uno::Reference<xml::sax::XAttributeList>& xAttrList )
@@ -1980,6 +1995,7 @@ ScXMLImport::ScXMLImport(
pDataPilotMemberAttrTokenMap( 0 ),
pConsolidationAttrTokenMap( 0 ),
pCellTextParaElemTokemMap(NULL),
+ pCellTextSpanAttrTokemMap(NULL),
aTables(*this),
pMyNamedExpressions(NULL),
pMyLabelRanges(NULL),
@@ -2118,6 +2134,7 @@ ScXMLImport::~ScXMLImport() throw()
delete pDataPilotMemberAttrTokenMap;
delete pConsolidationAttrTokenMap;
delete pCellTextParaElemTokemMap;
+ delete pCellTextSpanAttrTokemMap;
delete pChangeTrackingImportHelper;
delete pNumberFormatAttributesExportHelper;
diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx
index 3ae05c0..fc5ed7a 100644
--- a/sc/source/filter/xml/xmlimprt.hxx
+++ b/sc/source/filter/xml/xmlimprt.hxx
@@ -682,11 +682,22 @@ enum ScXMLConsolidationAttrTokens
XML_TOK_CONSOLIDATION_ATTR_LINK_TO_SOURCE
};
+/**
+ * Tokens for elements that come under <text:p>
+ */
enum ScXMLCellTextParaElemTokens
{
XML_TOK_CELL_TEXT_SPAN
};
+/**
+ * Tokens for attributes for <text:span>
+ */
+enum ScXMLCellTextSpanAttrTokens
+{
+ XML_TOK_CELL_TEXT_SPAN_ATTR_STYLE_NAME
+};
+
class SvXMLTokenMap;
class XMLShapeImportHelper;
class ScXMLChangeTrackingImportHelper;
@@ -854,6 +865,7 @@ class ScXMLImport: public SvXMLImport, boost::noncopyable
SvXMLTokenMap *pDataPilotMemberAttrTokenMap;
SvXMLTokenMap *pConsolidationAttrTokenMap;
SvXMLTokenMap *pCellTextParaElemTokemMap;
+ SvXMLTokenMap *pCellTextSpanAttrTokemMap;
ScMyTables aTables;
@@ -1020,6 +1032,7 @@ public:
const SvXMLTokenMap& GetDataPilotMemberAttrTokenMap();
const SvXMLTokenMap& GetConsolidationAttrTokenMap();
const SvXMLTokenMap& GetCellTextParaElemTokenMap();
+ const SvXMLTokenMap& GetCellTextSpanAttrTokenMap();
void AddNamedExpression(ScMyNamedExpression* pMyNamedExpression)
{
commit b7806cfd3e874b3d40d1cf3e132bc236ecd25d78
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Feb 8 01:10:37 2013 -0500
Use EditEngine to create ScEditCell directly.
Change-Id: I51a37482e793f620cf0dffcf392ce69822652cef
diff --git a/sc/source/filter/xml/importcontext.hxx b/sc/source/filter/xml/importcontext.hxx
index d2db48a..146e7e8 100644
--- a/sc/source/filter/xml/importcontext.hxx
+++ b/sc/source/filter/xml/importcontext.hxx
@@ -7,6 +7,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#ifndef __IMPORTCONTEXT_HXX__
+#define __IMPORTCONTEXT_HXX__
+
#include "xmloff/xmlictxt.hxx"
#include "xmloff/xmlimp.hxx"
@@ -27,3 +30,5 @@ protected:
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+
+#endif
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index e13cb82..4e13655 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -105,7 +105,8 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport,
::com::sun::star::xml::sax::XAttributeList>& xAttrList,
const bool bTempIsCovered,
const sal_Int32 nTempRepeatedRows ) :
- SvXMLImportContext( rImport, nPrfx, rLName ),
+ ScXMLImportContext(rImport, nPrfx, rLName),
+ mpEditEngine(GetScImport().GetEditEngine()),
pDetectiveObjVec(NULL),
pCellRangeSource(NULL),
fValue(0.0),
@@ -127,6 +128,7 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport,
mbCheckWithCompilerForError(false)
{
rtl::math::setNan(&fValue); // NaN by default
+ mpEditEngine->Clear();
rXMLImport.SetRemoveLastChar(false);
rXMLImport.GetTables().AddColumn(bTempIsCovered);
@@ -307,7 +309,8 @@ void ScXMLTableRowCellContext::PushParagraphSpan(const OUString& rSpan)
void ScXMLTableRowCellContext::PushParagraphEnd()
{
- maParagraphs.push_back(maParagraph.makeStringAndClear());
+ mpEditEngine->InsertParagraph(
+ mpEditEngine->GetParagraphCount(), maParagraph.makeStringAndClear());
}
SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 nPrefix,
@@ -671,8 +674,8 @@ void ScXMLTableRowCellContext::SetFormulaCell(ScFormulaCell* pFCell) const
}
else if (!rtl::math::isNan(fValue))
{
- if (!maParagraphs.empty())
- pFCell->SetHybridValueString(fValue, maParagraphs.back());
+ if (mpEditEngine->GetParagraphCount())
+ pFCell->SetHybridValueString(fValue, mpEditEngine->GetText(0));
else
pFCell->SetHybridDouble(fValue);
pFCell->ResetDirty();
@@ -681,27 +684,6 @@ void ScXMLTableRowCellContext::SetFormulaCell(ScFormulaCell* pFCell) const
}
}
-namespace {
-
-ScBaseCell* createEditCell(ScDocument* pDoc, const std::vector<OUString>& rParagraphs)
-{
- // Create edit cell.
- OUStringBuffer aBuf;
- std::vector<OUString>::const_iterator it = rParagraphs.begin(), itEnd = rParagraphs.end();
- bool bFirst = true;
- for (; it != itEnd; ++it)
- {
- if (bFirst)
- bFirst = false;
- else
- aBuf.append('\n');
- aBuf.append(*it);
- }
- return ScBaseCell::CreateTextCell(aBuf.makeStringAndClear(), pDoc);
-}
-
-}
-
void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos,
const SCCOL nCurrentCol, const ::boost::optional< rtl::OUString >& pOUText )
{
@@ -718,8 +700,8 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos,
OUString aCellString;
if (maStringValue)
aCellString = *maStringValue;
- else if (!maParagraphs.empty())
- aCellString = maParagraphs.back();
+ else if (mpEditEngine->GetParagraphCount())
+ aCellString = mpEditEngine->GetText(0);
else if ( nCurrentCol > 0 && pOUText && !pOUText->isEmpty() )
aCellString = *pOUText;
else
@@ -753,8 +735,8 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos,
ScDocument* pDoc = rXMLImport.GetDocument();
if (maStringValue)
pNewCell = ScBaseCell::CreateTextCell( *maStringValue, pDoc );
- else if (!maParagraphs.empty())
- pNewCell = createEditCell(pDoc, maParagraphs);
+ else if (mpEditEngine->GetParagraphCount())
+ pNewCell = new ScEditCell(mpEditEngine->CreateTextObject(), pDoc, pDoc->GetEditPool());
else if ( nCurrentCol > 0 && pOUText && !pOUText->isEmpty() )
pNewCell = ScBaseCell::CreateTextCell( *pOUText, pDoc );
@@ -960,7 +942,7 @@ void ScXMLTableRowCellContext::AddNonFormulaCell( const ScAddress& rCellPos )
if( cellExists(rCellPos) && CellsAreRepeated() )
pOUText.reset( getOutputString(rXMLImport.GetDocument(), rCellPos) );
- if (maParagraphs.empty() && !pOUText && !maStringValue)
+ if (!mpEditEngine->GetParagraphCount() && !pOUText && !maStringValue)
bIsEmpty = true;
}
@@ -1110,14 +1092,14 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos )
// - has an "Err:[###]" (where "[###]" is an error number)
void ScXMLTableRowCellContext::HasSpecialCaseFormulaText()
{
- if (!maParagraphs.empty())
- {
- const OUString& rStr = maParagraphs.back();
- if (rStr.isEmpty() || rStr.startsWith("Err:"))
- mbPossibleErrorCell = true;
- else if (rStr.startsWith("#"))
- mbCheckWithCompilerForError = true;
- }
+ if (!mpEditEngine->GetParagraphCount())
+ return;
+
+ OUString aStr = mpEditEngine->GetText(0);
+ if (aStr.isEmpty() || aStr.startsWith("Err:"))
+ mbPossibleErrorCell = true;
+ else if (aStr.startsWith("#"))
+ mbCheckWithCompilerForError = true;
}
bool ScXMLTableRowCellContext::IsPossibleErrorString() const
@@ -1131,7 +1113,7 @@ void ScXMLTableRowCellContext::EndElement()
HasSpecialCaseFormulaText();
if( bFormulaTextResult && (mbPossibleErrorCell || mbCheckWithCompilerForError) )
{
- maStringValue.reset(maParagraphs.back());
+ maStringValue.reset(mpEditEngine->GetText(0));
nCellType = util::NumberFormat::TEXT;
}
diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx
index cb61ce4..cbd622f 100644
--- a/sc/source/filter/xml/xmlcelli.hxx
+++ b/sc/source/filter/xml/xmlcelli.hxx
@@ -21,18 +21,17 @@
#include "XMLDetectiveContext.hxx"
#include "XMLCellRangeSourceContext.hxx"
-#include <xmloff/xmlictxt.hxx>
-#include <xmloff/xmlimp.hxx>
-
+#include "importcontext.hxx"
#include "formula/grammar.hxx"
#include <boost/optional.hpp>
#include <boost/scoped_ptr.hpp>
class ScXMLImport;
class ScFormulaCell;
+class ScEditEngineDefaulter;
struct ScXMLAnnotationData;
-class ScXMLTableRowCellContext : public SvXMLImportContext
+class ScXMLTableRowCellContext : public ScXMLImportContext
{
typedef std::pair<OUString, OUString> FormulaWithNamespace;
@@ -40,7 +39,7 @@ class ScXMLTableRowCellContext : public SvXMLImportContext
boost::optional<OUString> maStringValue; /// office:string-value attribute
boost::optional<OUString> maContentValidationName;
- std::vector<OUString> maParagraphs;
+ ScEditEngineDefaulter* mpEditEngine;
OUStringBuffer maParagraph;
boost::scoped_ptr< ScXMLAnnotationData > mxAnnotationData;
@@ -62,9 +61,6 @@ class ScXMLTableRowCellContext : public SvXMLImportContext
bool mbPossibleErrorCell;
bool mbCheckWithCompilerForError;
- const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
- ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
-
sal_Int16 GetCellType(const rtl::OUString& sOUValue) const;
void DoMerge(const ScAddress& rScCellPos, const SCCOL nCols, const SCROW nRows);
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index a35b934..e62ec9b 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -40,6 +40,7 @@
#include <svl/zformat.hxx>
#include <svl/languageoptions.hxx>
+#include "editeng/editstat.hxx"
#include "xmlimprt.hxx"
#include "document.hxx"
@@ -63,6 +64,8 @@
#include "postit.hxx"
#include "formulaparserpool.hxx"
#include "externalrefmgr.hxx"
+#include "editutil.hxx"
+
#include <comphelper/extract.hxx>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
@@ -3341,4 +3344,18 @@ bool ScXMLImport::IsFormulaErrorConstant( const OUString& rStr ) const
return mpComp->GetErrorConstant(rStr) > 0;
}
+ScEditEngineDefaulter* ScXMLImport::GetEditEngine()
+{
+ if (!mpEditEngine)
+ {
+ mpEditEngine.reset(new ScEditEngineDefaulter(pDoc->GetEnginePool()));
+ mpEditEngine->SetRefMapMode(MAP_100TH_MM);
+ mpEditEngine->SetEditTextObjectPool(pDoc->GetEditPool());
+ mpEditEngine->SetUpdateMode(false);
+ mpEditEngine->EnableUndo(false);
+ mpEditEngine->SetControlWord(mpEditEngine->GetControlWord() & ~EE_CNTRL_ALLOWBIGOBJS);
+ }
+ return mpEditEngine.get();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list