sw/source/core/doc/docbm.cxx | 12 + xmloff/source/chart/PropertyMap.hxx | 12 - xmloff/source/text/XMLTextFrameContext.cxx | 10 + xmloff/source/text/txtimp.cxx | 8 - xmloff/source/text/txtparae.cxx | 201 +++++++++++++++-------------- 5 files changed, 129 insertions(+), 114 deletions(-)
New commits: commit 041694abe6167ba06c89a4be6a732e4c36b86c59 Author: Michael Stahl <mst...@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) diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index 4d43b3c..cdc468c 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -2277,130 +2277,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 ); + } } } } commit 57dda65018847e7c432b60ea218b4ef3e314e5cc Author: Michael Stahl <mst...@redhat.com> Date: Wed Dec 10 14:56:27 2014 +0100 sw: don't assert when SwXBookmark creates duplicate CrossRef*Bookmark The bugdoc of fdo#87110 has a couple such duplicates. Check for it and let SwXBookmark throw an IllegalArgumentException. Change-Id: I460dc3a8d9c554c194a32a73526e13422ddd1c52 (cherry picked from commit 7a12360e1f2c0a5bc0927131a750740d35cfd1ab) diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index 22cef6b..b7487ec 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -373,11 +373,13 @@ namespace sw { namespace mark "MarkManager::makeMark(..)" " - more than USHRT_MAX marks are not supported correctly"); // There should only be one CrossRefBookmark per Textnode per Type - assert(( - (eType != CROSSREF_NUMITEM_BOOKMARK && eType != CROSSREF_HEADING_BOOKMARK) - || (lcl_FindMarkAtPos(m_vBookmarks, *rPaM.GetPoint(), eType) == m_vBookmarks.end())) && - "MarkManager::makeMark(..)" - " - creating duplicate CrossRefBookmark"); + if ((eType == CROSSREF_NUMITEM_BOOKMARK || eType == CROSSREF_HEADING_BOOKMARK) + && (lcl_FindMarkAtPos(m_vBookmarks, *rPaM.GetPoint(), eType) != m_vBookmarks.end())) + { // this can happen via UNO API + SAL_WARN("sw.core", "MarkManager::makeMark(..)" + " - refusing to create duplicate CrossRefBookmark"); + return 0; + } // create mark pMark_t pMark; commit 2b577a316ad000bbc9378e180844c14e31e63706 Author: Michael Stahl <mst...@redhat.com> Date: Wed Dec 10 14:10:16 2014 +0100 fdo#87110: xmloff: don't catch IllegalArgumentException here There are at least 2 callers of InsertTextContent() that have non-trivial catch handlers for this exception, which aren't called now. (regression from bebf8ccfba37f77d6a43c7874249b31736467b17) Change-Id: I085b710dfd5877e9b7e71610951543eddf6a6e46 (cherry picked from commit b86f5530161a417d31e28e75408ee80352fadad7) diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx index bf54f43..baf62f6 100644 --- a/xmloff/source/text/XMLTextFrameContext.cxx +++ b/xmloff/source/text/XMLTextFrameContext.cxx @@ -759,7 +759,15 @@ void XMLTextFrameContext_Impl::Create( bool /*bHRefOrBase64*/ ) XML_TEXT_FRAME_FLOATING_FRAME != nType) { Reference < XTextContent > xTxtCntnt( xPropSet, UNO_QUERY ); - xTextImportHelper->InsertTextContent( xTxtCntnt ); + try + { + xTextImportHelper->InsertTextContent(xTxtCntnt); + } + catch (lang::IllegalArgumentException const& e) + { + SAL_WARN("xmloff.text", "Cannot import part of the text - probably an image in the text frame? " << e.Message); + return; + } } // #107848# diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index d70efff..f985cda 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -1158,12 +1158,8 @@ void XMLTextImportHelper::InsertTextContent( DBG_ASSERT(m_pImpl->m_xCursorAsRange.is(), "no range"); if (m_pImpl->m_xText.is()) { - try { - m_pImpl->m_xText->insertTextContent( m_pImpl->m_xCursorAsRange, xContent, sal_False); - } catch ( const lang::IllegalArgumentException & ) - { - SAL_WARN( "xmloff", "Cannot import part of the text - probably an image in the text frame?" ); - } + // note: this may throw IllegalArgumentException and callers handle it + m_pImpl->m_xText->insertTextContent( m_pImpl->m_xCursorAsRange, xContent, sal_False); } } commit 9b8598fda9667e2b6c92c433d4c76dec6aeeaafb Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Tue Dec 9 23:20:13 2014 +0100 don't write extension elements into ODF namespaces, related fdo#45266 We will still import the old elements but only write them into the lo-ext namespace. Also it will only be exported for ODF 1.2 extended. (cherry picked from commit 88d3931d92bc89519acf95f0510f6f2a6ff7c72c) Signed-off-by: Michael Stahl <mst...@redhat.com> Backpoting the export part of this too since the attributes were added in LO 4.3 so the change has very limited impact. Conflicts: xmloff/source/chart/PropertyMap.hxx Change-Id: I1c41716b8b16e186ec84767b4b3a636d083162b8 diff --git a/xmloff/source/chart/PropertyMap.hxx b/xmloff/source/chart/PropertyMap.hxx index af19843..12393dd 100644 --- a/xmloff/source/chart/PropertyMap.hxx +++ b/xmloff/source/chart/PropertyMap.hxx @@ -137,12 +137,12 @@ const XMLPropertyMapEntry aXMLChartPropMap[] = MAP_ENTRY_ODF12( "StartingAngle", CHART, XML_ANGLE_OFFSET, XML_TYPE_NUMBER ), MAP_ENTRY_ODF12( "MissingValueTreatment", CHART, XML_TREAT_EMPTY_CELLS, XML_SCH_TYPE_MISSING_VALUE_TREATMENT ), // #72304 Chart data table flags - MAP_ENTRY_ODF12( "DataTableHBorder", CHART, XML_CHART_DTABLE_SHOWHORZBORDER, XML_TYPE_BOOL ), - MAP_ENTRY_ODF12( "DataTableVBorder", CHART, XML_CHART_DTABLE_SHOWVERTBORDER, XML_TYPE_BOOL ), - MAP_ENTRY_ODF12( "DataTableOutline", CHART, XML_CHART_DTABLE_SHOWOUTLINE, XML_TYPE_BOOL ), - MAP_ENTRY_ODF_EXT_IMPORT( "DataTableHBorder", LO_EXT, XML_CHART_DTABLE_SHOWHORZBORDER, XML_TYPE_BOOL ), - MAP_ENTRY_ODF_EXT_IMPORT( "DataTableVBorder", LO_EXT, XML_CHART_DTABLE_SHOWVERTBORDER, XML_TYPE_BOOL ), - MAP_ENTRY_ODF_EXT_IMPORT( "DataTableOutline", LO_EXT, XML_CHART_DTABLE_SHOWOUTLINE, XML_TYPE_BOOL ), + MAP_ENTRY_ODF_EXT( "DataTableHBorder", LO_EXT, XML_CHART_DTABLE_SHOWHORZBORDER, XML_TYPE_BOOL ), + MAP_ENTRY_ODF_EXT( "DataTableVBorder", LO_EXT, XML_CHART_DTABLE_SHOWVERTBORDER, XML_TYPE_BOOL ), + MAP_ENTRY_ODF_EXT( "DataTableOutline", LO_EXT, XML_CHART_DTABLE_SHOWOUTLINE, XML_TYPE_BOOL ), + MAP_ENTRY_ODF_EXT_IMPORT( "DataTableHBorder", CHART, XML_CHART_DTABLE_SHOWHORZBORDER, XML_TYPE_BOOL ), + MAP_ENTRY_ODF_EXT_IMPORT( "DataTableVBorder", CHART, XML_CHART_DTABLE_SHOWVERTBORDER, XML_TYPE_BOOL ), + MAP_ENTRY_ODF_EXT_IMPORT( "DataTableOutline", CHART, XML_CHART_DTABLE_SHOWOUTLINE, XML_TYPE_BOOL ), // Chart display units flags MAP_ENTRY_ODF_EXT( "DisplayUnits", LO_EXT, XML_CHART_DUNITS_DISPLAYUNITS, XML_TYPE_BOOL ), MAP_ENTRY_ODF_EXT( "BuiltInUnit", LO_EXT, XML_CHART_DUNITS_BUILTINUNIT, XML_TYPE_STRING ), _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits