[Libreoffice-commits] core.git: 3 commits - sw/source xmloff/source
Michael Stahl
mstahl at redhat.com
Wed Dec 10 07:28:38 PST 2014
sw/source/core/doc/docbm.cxx | 12 +
xmloff/source/text/XMLTextFrameContext.cxx | 10 +
xmloff/source/text/txtimp.cxx | 8 -
xmloff/source/text/txtparae.cxx | 201 +++++++++++++++--------------
4 files changed, 123 insertions(+), 108 deletions(-)
New commits:
commit 06f85d41d02ebef76487b230f35f2ec638c46c8b
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
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 7a12360e1f2c0a5bc0927131a750740d35cfd1ab
Author: Michael Stahl <mstahl at 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
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index b06097a..d6d3d27 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -374,11 +374,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 b86f5530161a417d31e28e75408ee80352fadad7
Author: Michael Stahl <mstahl at 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
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 9d35a13..e1e4541 100644
--- a/xmloff/source/text/txtimp.cxx
+++ b/xmloff/source/text/txtimp.cxx
@@ -1158,12 +1158,8 @@ void XMLTextImportHelper::InsertTextContent(
assert(m_pImpl->m_xCursorAsRange.is());
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);
}
}
More information about the Libreoffice-commits
mailing list