[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - xmloff/source

Michael Stahl mstahl at redhat.com
Fri Dec 12 01:12:40 PST 2014


 xmloff/source/text/txtparae.cxx |  201 ++++++++++++++++++++--------------------
 1 file changed, 105 insertions(+), 96 deletions(-)

New commits:
commit 46e59e55eca5a32f9f1b4471809ed182da495a32
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Dec 10 16:06:21 2014 +0100

    xmloff: make the export of the horrible field marks aware of auto-styles
    
    When exporting the .DOC bugdoc of fdo#87110 to ODF, the auto-styles
    export will iterate over the fieldmarks in the page header and add the
    attributes for them but not export the elements, so the first auto-style
    gets a bunch of duplicate attributes.
    
    Change-Id: I3fcf39f03e3d9ae5fca661efa7eb4bbb3eab9f5c
    (cherry picked from commit 06f85d41d02ebef76487b230f35f2ec638c46c8b)
    Reviewed-on: https://gerrit.libreoffice.org/13426
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index 7c91085..00954d6 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -2291,130 +2291,139 @@ void XMLTextParagraphExport::exportTextRangeEnumeration(
                 Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
 
                 /* As of now, textmarks are a proposed extension to the OpenDocument standard. */
-                if ( GetExport().getDefaultVersion() > SvtSaveOptions::ODFVER_012 )
+                if (!bAutoStyles)
                 {
-                    Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
-                    if (xBookmark.is())
+                    if (GetExport().getDefaultVersion() > SvtSaveOptions::ODFVER_012)
                     {
-                        GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xBookmark->getName());
-                    }
-
-                    if (xFormField.is())
-                    {
-                        GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_TYPE, xFormField->getFieldType());
-                    }
-
-                    GetExport().StartElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_START, false);
-                    if (xFormField.is())
-                    {
-                        FieldParamExporter(&GetExport(), xFormField->getParameters()).Export();
-                    }
-                    GetExport().EndElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_START, false);
-                }
-                /* The OpenDocument standard does not include support for TextMarks for now, so use bookmarks instead. */
-                else
-                {
-                    if (xFormField.is())
-                    {
-                        OUString sName;
-                        Reference< ::com::sun::star::container::XNameAccess > xParameters(xFormField->getParameters(), UNO_QUERY);
-                        if (xParameters.is() && xParameters->hasByName("Name"))
+                        Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
+                        if (xBookmark.is())
                         {
-                            const Any aValue = xParameters->getByName("Name");
-                            aValue >>= sName;
+                            GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xBookmark->getName());
                         }
-                        if (sName.isEmpty())
-                        {   // name attribute is mandatory, so have to pull a
-                            // rabbit out of the hat here
-                            sName = sFieldMarkName + OUString::number(
-                                    m_pImpl->AddFieldMarkStart(xFormField));
-                        }
-                        GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME,
-                                sName);
-                        SvXMLElementExport aElem( GetExport(), !bAutoStyles,
-                            XML_NAMESPACE_TEXT, XML_BOOKMARK_START,
-                            false, false );
-                        const OUString sFieldType = xFormField->getFieldType();
-                        if (sFieldType ==  ODF_FORMTEXT)
+
+                        if (xFormField.is())
                         {
-                            openFieldMark = TEXT;
+                            GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_TYPE, xFormField->getFieldType());
                         }
-                        else if (sFieldType == ODF_FORMCHECKBOX)
+
+                        GetExport().StartElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_START, false);
+                        if (xFormField.is())
                         {
-                            openFieldMark = CHECK;
+                            FieldParamExporter(&GetExport(), xFormField->getParameters()).Export();
                         }
-                        else
+                        GetExport().EndElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_START, false);
+                    }
+                    /* The OpenDocument standard does not include support for TextMarks for now, so use bookmarks instead. */
+                    else
+                    {
+                        if (xFormField.is())
                         {
-                            openFieldMark = NONE;
+                            OUString sName;
+                            Reference< ::com::sun::star::container::XNameAccess > xParameters(xFormField->getParameters(), UNO_QUERY);
+                            if (xParameters.is() && xParameters->hasByName("Name"))
+                            {
+                                const Any aValue = xParameters->getByName("Name");
+                                aValue >>= sName;
+                            }
+                            if (sName.isEmpty())
+                            {   // name attribute is mandatory, so have to pull a
+                                // rabbit out of the hat here
+                                sName = sFieldMarkName + OUString::number(
+                                        m_pImpl->AddFieldMarkStart(xFormField));
+                            }
+                            GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME,
+                                    sName);
+                            SvXMLElementExport aElem( GetExport(), !bAutoStyles,
+                                XML_NAMESPACE_TEXT, XML_BOOKMARK_START,
+                                false, false );
+                            const OUString sFieldType = xFormField->getFieldType();
+                            if (sFieldType ==  ODF_FORMTEXT)
+                            {
+                                openFieldMark = TEXT;
+                            }
+                            else if (sFieldType == ODF_FORMCHECKBOX)
+                            {
+                                openFieldMark = CHECK;
+                            }
+                            else
+                            {
+                                openFieldMark = NONE;
+                            }
                         }
                     }
                 }
             }
             else if (sType.equals(sTextFieldEnd))
             {
-                Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
-
-                if ( GetExport().getDefaultVersion() > SvtSaveOptions::ODFVER_012 )
-                {
-                    SvXMLElementExport aElem( GetExport(), !bAutoStyles,
-                        XML_NAMESPACE_FIELD, XML_FIELDMARK_END,
-                        false, false );
-                }
-                else
+                if (!bAutoStyles)
                 {
-                    if (xFormField.is())
+                    Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
+
+                    if ( GetExport().getDefaultVersion() > SvtSaveOptions::ODFVER_012 )
                     {
-                        OUString sName;
-                        Reference< ::com::sun::star::container::XNameAccess > xParameters(xFormField->getParameters(), UNO_QUERY);
-                        if (xParameters.is() && xParameters->hasByName("Name"))
-                        {
-                            const Any aValue = xParameters->getByName("Name");
-                            aValue >>= sName;
-                        }
-                        if (sName.isEmpty())
-                        {   // name attribute is mandatory, so have to pull a
-                            // rabbit out of the hat here
-                            sName = sFieldMarkName + OUString::number(
-                                m_pImpl->GetFieldMarkIndex(xFormField));
-                        }
-                        GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME,
-                                sName);
                         SvXMLElementExport aElem( GetExport(), !bAutoStyles,
-                            XML_NAMESPACE_TEXT, XML_BOOKMARK_END,
+                            XML_NAMESPACE_FIELD, XML_FIELDMARK_END,
                             false, false );
                     }
+                    else
+                    {
+                        if (xFormField.is())
+                        {
+                            OUString sName;
+                            Reference< ::com::sun::star::container::XNameAccess > xParameters(xFormField->getParameters(), UNO_QUERY);
+                            if (xParameters.is() && xParameters->hasByName("Name"))
+                            {
+                                const Any aValue = xParameters->getByName("Name");
+                                aValue >>= sName;
+                            }
+                            if (sName.isEmpty())
+                            {   // name attribute is mandatory, so have to pull a
+                                // rabbit out of the hat here
+                                sName = sFieldMarkName + OUString::number(
+                                    m_pImpl->GetFieldMarkIndex(xFormField));
+                            }
+                            GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME,
+                                    sName);
+                            SvXMLElementExport aElem( GetExport(), !bAutoStyles,
+                                XML_NAMESPACE_TEXT, XML_BOOKMARK_END,
+                                false, false );
+                        }
+                    }
                 }
             }
             else if (sType.equals(sTextFieldStartEnd))
             {
-                if ( GetExport().getDefaultVersion() > SvtSaveOptions::ODFVER_012 )
+                if (!bAutoStyles)
                 {
-                    Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
-                    if (xBookmark.is())
-                    {
-                        GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xBookmark->getName());
-                    }
-                    Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
-                    if (xFormField.is())
+                    if (GetExport().getDefaultVersion() > SvtSaveOptions::ODFVER_012)
                     {
-                        GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_TYPE, xFormField->getFieldType());
-                    }
-                    GetExport().StartElement(XML_NAMESPACE_FIELD, XML_FIELDMARK, false);
-                    if (xFormField.is())
-                    {
-                        FieldParamExporter(&GetExport(), xFormField->getParameters()).Export();
+                        Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
+                        if (xBookmark.is())
+                        {
+                            GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xBookmark->getName());
+                        }
+                        Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
+                        if (xFormField.is())
+                        {
+                            GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_TYPE, xFormField->getFieldType());
+                        }
+                        GetExport().StartElement(XML_NAMESPACE_FIELD, XML_FIELDMARK, false);
+                        if (xFormField.is())
+                        {
+                            FieldParamExporter(&GetExport(), xFormField->getParameters()).Export();
+                        }
+                        GetExport().EndElement(XML_NAMESPACE_FIELD, XML_FIELDMARK, false);
                     }
-                    GetExport().EndElement(XML_NAMESPACE_FIELD, XML_FIELDMARK, false);
-                }
-                else
-                {
-                    Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
-                    if (xBookmark.is())
+                    else
                     {
-                        GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xBookmark->getName());
-                        SvXMLElementExport aElem( GetExport(), !bAutoStyles,
-                            XML_NAMESPACE_TEXT, XML_BOOKMARK,
-                            false, false );
+                        Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
+                        if (xBookmark.is())
+                        {
+                            GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xBookmark->getName());
+                            SvXMLElementExport aElem( GetExport(), !bAutoStyles,
+                                XML_NAMESPACE_TEXT, XML_BOOKMARK,
+                                false, false );
+                        }
                     }
                 }
             }


More information about the Libreoffice-commits mailing list