summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-12-10 16:06:21 +0100
committerMichael Stahl <mstahl@redhat.com>2014-12-10 16:22:32 +0100
commit06f85d41d02ebef76487b230f35f2ec638c46c8b (patch)
tree2aff7b205beb3b48677f09e96dfc1576b97d9841 /xmloff
parent7a12360e1f2c0a5bc0927131a750740d35cfd1ab (diff)
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
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/text/txtparae.cxx201
1 files changed, 105 insertions, 96 deletions
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index 4d43b3ca604b..cdc468cdc57e 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 );
+ }
}
}
}