[Libreoffice-commits] core.git: 2 commits - xmloff/source

Michael Stahl mstahl at redhat.com
Fri Dec 5 09:23:45 PST 2014


 xmloff/source/text/XMLTextMarkImportContext.cxx |   51 ++++++++++++++++--------
 1 file changed, 34 insertions(+), 17 deletions(-)

New commits:
commit 5831405c8cf55fae64e88d1fc139d449e011e003
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Dec 5 18:17:02 2014 +0100

    xmloff: remove pointless branch that does the same as the next one
    
    Change-Id: Ib39ec9c045461590767a29ccdd28f39b2a623e88

diff --git a/xmloff/source/text/XMLTextMarkImportContext.cxx b/xmloff/source/text/XMLTextMarkImportContext.cxx
index b4e5e15..0c312d1 100644
--- a/xmloff/source/text/XMLTextMarkImportContext.cxx
+++ b/xmloff/source/text/XMLTextMarkImportContext.cxx
@@ -150,8 +150,6 @@ static OUString lcl_getFieldmarkName(OUString const& name)
     if (name.equalsAscii("msoffice.field.FORMTEXT") ||
             name.equalsAscii("ecma.office-open-xml.field.FORMTEXT") )
         return OUString::createFromAscii(sFormtext);
-    else if (name.equalsAscii(ODF_FORMTEXT) )
-        return OUString::createFromAscii(sFormtext);
     else
         return name;
 }
commit 25fd11e78279aef5a6b7656347758e5c67a9c45a
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Dec 5 18:04:39 2014 +0100

    fdo#86795: xmloff: ODF import: do not import checkbox fieldmark ...
    
    ... if it has start/end, because Writer will become grumpy and crash.
    
    Change-Id: I6024051249eeac6ed9e43856fa77db969287f888

diff --git a/xmloff/source/text/XMLTextMarkImportContext.cxx b/xmloff/source/text/XMLTextMarkImportContext.cxx
index 63bb7e2..b4e5e15 100644
--- a/xmloff/source/text/XMLTextMarkImportContext.cxx
+++ b/xmloff/source/text/XMLTextMarkImportContext.cxx
@@ -144,7 +144,7 @@ static const char *lcl_getFormFieldmarkName(OUString &name)
         return NULL;
 }
 
-static OUString lcl_getFieldmarkName(OUString &name)
+static OUString lcl_getFieldmarkName(OUString const& name)
 {
     static const char sFormtext[]=ODF_FORMTEXT;
     if (name.equalsAscii("msoffice.field.FORMTEXT") ||
@@ -289,19 +289,40 @@ void XMLTextMarkImportContext::EndElement()
 
                             bool bImportAsField=((lcl_MarkType)nTmp==TypeFieldmarkEnd && m_rHelper.hasCurrentFieldCtx());
 
-                            // insert reference
-                            const Reference<XInterface> xContent(
-                                CreateAndInsertMark(GetImport(),
-                                                (bImportAsField ? OUString(sAPI_fieldmark) : OUString(sAPI_bookmark)),
-                                    m_sBookmarkName,
-                                    xInsertionCursor,
-                                    m_sXmlId) );
-                            if (pRDFaAttributes)
+                            // fdo#86795 check if it's actually a checkbox first
+                            bool isInvalid(false);
+                            OUString fieldmarkTypeName;
+                            if (bImportAsField && m_rHelper.hasCurrentFieldCtx())
                             {
-                                const Reference<rdf::XMetadatable>
-                                    xMeta(xContent, UNO_QUERY);
-                                GetImport().GetRDFaImportHelper().AddRDFa(
-                                    xMeta, pRDFaAttributes);
+
+                                OUString const type(m_rHelper.getCurrentFieldType());
+                                fieldmarkTypeName = lcl_getFieldmarkName(type);
+                                if (fieldmarkTypeName == ODF_FORMCHECKBOX ||
+                                    fieldmarkTypeName == ODF_FORMDROPDOWN)
+                                {   // sw can't handle checkbox with start+end
+                                    SAL_INFO("xmloff.text", "invalid fieldmark-start/fieldmark-end ignored");
+                                    isInvalid = true;
+                                }
+                            }
+
+                            Reference<XInterface> xContent;
+                            if (!isInvalid)
+                            {
+                                // insert reference
+                                xContent = CreateAndInsertMark(GetImport(),
+                                        (bImportAsField
+                                            ? OUString(sAPI_fieldmark)
+                                            : OUString(sAPI_bookmark)),
+                                        m_sBookmarkName,
+                                        xInsertionCursor,
+                                        m_sXmlId);
+                                if (pRDFaAttributes)
+                                {
+                                    const Reference<rdf::XMetadatable>
+                                        xMeta(xContent, UNO_QUERY);
+                                    GetImport().GetRDFaImportHelper().AddRDFa(
+                                        xMeta, pRDFaAttributes);
+                                }
                             }
 
                             if ((lcl_MarkType)nTmp==TypeFieldmarkEnd) {
@@ -309,8 +330,6 @@ void XMLTextMarkImportContext::EndElement()
                                     // setup fieldmark...
                                     Reference< ::com::sun::star::text::XFormField> xFormField(xContent, UNO_QUERY);
                                     if (xFormField.is() && m_rHelper.hasCurrentFieldCtx()) {
-                                        OUString givenTypeName=m_rHelper.getCurrentFieldType();
-                                        OUString fieldmarkTypeName=lcl_getFieldmarkName(givenTypeName);
 
                                         xFormField->setFieldType(fieldmarkTypeName);
                                         m_rHelper.setCurrentFieldParamsTo(xFormField);


More information about the Libreoffice-commits mailing list