/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
namespace
{ /// Walks up the parent chain of xText and returns the topmost text.
uno::Reference<text::XText> GetToplevelText(const uno::Reference<text::XText>& xText)
{
uno::Reference<text::XText> xRet = xText; while (true)
{
uno::Reference<beans::XPropertySet> xPropertySet(xRet, uno::UNO_QUERY); if (!xPropertySet.is()) return xRet;
if (!xPropertySet->getPropertySetInfo()->hasPropertyByName(u"ParentText"_ustr)) return xRet;
/// get the field ID (as in FieldIDEnum) from XTextField enum FieldIdEnum XMLTextFieldExport::GetFieldID( const Reference<XTextField> & rTextField, const Reference<XPropertySet> & xPropSet)
{ // get service names for rTextField (via XServiceInfo service)
Reference<XServiceInfo> xService(rTextField, UNO_QUERY); const Sequence<OUString> aServices = xService->getSupportedServiceNames();
OUString sFieldName; // service name postfix of current field
// search for TextField service name const OUString* pNames = std::find_if(aServices.begin(), aServices.end(),
[](const OUString& rName) { return rName.matchIgnoreAsciiCase(gsServicePrefix); }); if (pNames != aServices.end())
{ // TextField found => postfix is field type!
sFieldName = pNames->copy(gsServicePrefix.getLength());
}
// if this is not a normal text field, check if it's a presentation text field if( sFieldName.isEmpty() )
{ // search for TextField service name
pNames = std::find_if(aServices.begin(), aServices.end(),
[](const OUString& rName) { return rName.startsWith(gsPresentationServicePrefix); }); if (pNames != aServices.end())
{ // TextField found => postfix is field type!
sFieldName = pNames->copy(gsPresentationServicePrefix.getLength());
}
// map postfix of service name to field ID
DBG_ASSERT(!sFieldName.isEmpty(), "no TextField service found!"); return MapFieldName(sFieldName, xPropSet);
}
enum FieldIdEnum XMLTextFieldExport::MapFieldName(
std::u16string_view sFieldName, // field (master) name const Reference<XPropertySet> & xPropSet) // for subtype
{ // we'll proceed in 2 steps: // a) map service name to preliminary FIELD_ID // b) map those prelim. FIELD_IDs that correspond to several field types // (in our (XML) world) to final FIELD IDs
// a) find prelim. FIELD_ID via aFieldServiceMapping
// check for non-empty service name
DBG_ASSERT(!sFieldName.empty(), "no valid service name!"); enum FieldIdEnum nToken = FIELD_ID_UNKNOWN; if (!sFieldName.empty())
{ // map name to prelim. ID bool bRet = SvXMLUnitConverter::convertEnum(
nToken, sFieldName, aFieldServiceNameMapping);
// check return
DBG_ASSERT(bRet, "Unknown field service name encountered!");
}
// b) map prelim. to final FIELD_IDs switch (nToken) { case FIELD_ID_VARIABLE_SET: if (GetBoolProperty(gsPropertyIsInput, xPropSet))
{
nToken = FIELD_ID_VARIABLE_INPUT;
} else
{ switch (GetIntProperty(gsPropertySubType, xPropSet))
{ case SetVariableType::STRING: // text field case SetVariableType::VAR: // num field
nToken = FIELD_ID_VARIABLE_SET; break; case SetVariableType::SEQUENCE:
nToken = FIELD_ID_SEQUENCE; break; case SetVariableType::FORMULA: default:
nToken = FIELD_ID_UNKNOWN; break;
}
} break;
case FIELD_ID_VARIABLE_GET: switch (GetIntProperty(gsPropertySubType, xPropSet))
{ case SetVariableType::STRING: // text field case SetVariableType::VAR: // num field
nToken = FIELD_ID_VARIABLE_GET; break; case SetVariableType::FORMULA:
nToken = FIELD_ID_EXPRESSION; break; case SetVariableType::SEQUENCE: default:
nToken = FIELD_ID_UNKNOWN; break;
} break;
case FIELD_ID_TIME: if (GetBoolProperty(gsPropertyIsDate, xPropSet))
{
nToken = FIELD_ID_DATE;
} break;
case FIELD_ID_PAGENUMBER: // NumberingType not available in non-Writer apps if (xPropSet->getPropertySetInfo()->
hasPropertyByName(gsPropertyNumberingType))
{ if (NumberingType::CHAR_SPECIAL == GetIntProperty(
gsPropertyNumberingType, xPropSet))
{
nToken = FIELD_ID_PAGESTRING;
}
} break;
case FIELD_ID_DOCINFO_CREATION_TIME: if (GetBoolProperty(gsPropertyIsDate, xPropSet))
{
nToken = FIELD_ID_DOCINFO_CREATION_DATE;
} break;
case FIELD_ID_DOCINFO_PRINT_TIME: if (GetBoolProperty(gsPropertyIsDate, xPropSet))
{
nToken = FIELD_ID_DOCINFO_PRINT_DATE;
} break;
case FIELD_ID_DOCINFO_SAVE_TIME: if (GetBoolProperty(gsPropertyIsDate, xPropSet))
{
nToken = FIELD_ID_DOCINFO_SAVE_DATE;
} break;
case FIELD_ID_REF_REFERENCE: switch (GetInt16Property(gsPropertyReferenceFieldSource, xPropSet))
{ case ReferenceFieldSource::REFERENCE_MARK:
nToken = FIELD_ID_REF_REFERENCE; break; case ReferenceFieldSource::SEQUENCE_FIELD:
nToken = FIELD_ID_REF_SEQUENCE; break; case ReferenceFieldSource::BOOKMARK:
nToken = FIELD_ID_REF_BOOKMARK; break; case ReferenceFieldSource::FOOTNOTE:
nToken = FIELD_ID_REF_FOOTNOTE; break; case ReferenceFieldSource::ENDNOTE:
nToken = FIELD_ID_REF_ENDNOTE; break; case ReferenceFieldSource::STYLE:
nToken = FIELD_ID_REF_STYLE; break; default:
nToken = FIELD_ID_UNKNOWN; break;
} break;
case FIELD_ID_COMBINED_CHARACTERS: case FIELD_ID_SCRIPT: case FIELD_ID_ANNOTATION: case FIELD_ID_BIBLIOGRAPHY: case FIELD_ID_DDE: case FIELD_ID_MACRO: case FIELD_ID_REFPAGE_SET: case FIELD_ID_REFPAGE_GET: case FIELD_ID_COUNT_PAGES: case FIELD_ID_COUNT_PAGES_RANGE: case FIELD_ID_COUNT_PARAGRAPHS: case FIELD_ID_COUNT_WORDS: case FIELD_ID_COUNT_CHARACTERS: case FIELD_ID_COUNT_TABLES: case FIELD_ID_COUNT_GRAPHICS: case FIELD_ID_COUNT_OBJECTS: case FIELD_ID_CONDITIONAL_TEXT: case FIELD_ID_HIDDEN_TEXT: case FIELD_ID_HIDDEN_PARAGRAPH: case FIELD_ID_DOCINFO_CREATION_AUTHOR: case FIELD_ID_DOCINFO_DESCRIPTION: case FIELD_ID_DOCINFO_CUSTOM: case FIELD_ID_DOCINFO_PRINT_AUTHOR: case FIELD_ID_DOCINFO_TITLE: case FIELD_ID_DOCINFO_SUBJECT: case FIELD_ID_DOCINFO_KEYWORDS: case FIELD_ID_DOCINFO_REVISION: case FIELD_ID_DOCINFO_EDIT_DURATION: case FIELD_ID_DOCINFO_SAVE_AUTHOR: case FIELD_ID_TEXT_INPUT: case FIELD_ID_USER_INPUT: case FIELD_ID_AUTHOR: case FIELD_ID_SENDER: case FIELD_ID_PLACEHOLDER: case FIELD_ID_USER_GET: case FIELD_ID_DATABASE_NEXT: case FIELD_ID_DATABASE_SELECT: case FIELD_ID_DATABASE_DISPLAY: case FIELD_ID_DATABASE_NAME: case FIELD_ID_DATABASE_NUMBER: case FIELD_ID_TEMPLATE_NAME: case FIELD_ID_CHAPTER: case FIELD_ID_FILE_NAME: case FIELD_ID_META: case FIELD_ID_SHEET_NAME: case FIELD_ID_PAGENAME: case FIELD_ID_MEASURE: case FIELD_ID_URL: case FIELD_ID_TABLE_FORMULA: case FIELD_ID_DROP_DOWN:
; // these field IDs are final break;
default:
nToken = FIELD_ID_UNKNOWN;
}
// ... and return final FIELD_ID return nToken;
}
// is string or numeric field? bool XMLTextFieldExport::IsStringField(
FieldIdEnum nFieldType, const Reference<XPropertySet> & xPropSet)
{ switch (nFieldType) {
case FIELD_ID_VARIABLE_GET: case FIELD_ID_VARIABLE_SET: case FIELD_ID_VARIABLE_INPUT:
{ // depends on field sub type return ( GetIntProperty(gsPropertySubType, xPropSet) ==
SetVariableType::STRING );
}
case FIELD_ID_USER_GET: case FIELD_ID_USER_INPUT:
{
Reference<XTextField> xTextField(xPropSet, UNO_QUERY);
DBG_ASSERT(xTextField.is(), "field is no XTextField!"); bool bRet = GetBoolProperty(gsPropertyIsExpression,
GetMasterPropertySet(xTextField)); return !bRet;
}
case FIELD_ID_META: return 0 > GetIntProperty(gsPropertyNumberFormat, xPropSet);
case FIELD_ID_DATABASE_DISPLAY: // TODO: depends on... ??? // workaround #no-bug#: no data type return 5100 == GetIntProperty(gsPropertyNumberFormat, xPropSet);
case FIELD_ID_TABLE_FORMULA: // legacy field: always a number field (because it always has // a number format) returnfalse;
case FIELD_ID_COUNT_PAGES: case FIELD_ID_COUNT_PAGES_RANGE: case FIELD_ID_COUNT_PARAGRAPHS: case FIELD_ID_COUNT_WORDS: case FIELD_ID_COUNT_CHARACTERS: case FIELD_ID_COUNT_TABLES: case FIELD_ID_COUNT_GRAPHICS: case FIELD_ID_COUNT_OBJECTS: case FIELD_ID_DOCINFO_SAVE_TIME: case FIELD_ID_DOCINFO_SAVE_DATE: case FIELD_ID_DOCINFO_CREATION_DATE: case FIELD_ID_DOCINFO_CREATION_TIME: case FIELD_ID_DOCINFO_PRINT_TIME: case FIELD_ID_DOCINFO_PRINT_DATE: case FIELD_ID_DOCINFO_EDIT_DURATION: case FIELD_ID_DOCINFO_REVISION: case FIELD_ID_DATABASE_NUMBER: case FIELD_ID_EXPRESSION: case FIELD_ID_SEQUENCE: case FIELD_ID_DATE: case FIELD_ID_TIME: case FIELD_ID_PAGENUMBER: case FIELD_ID_REFPAGE_SET: case FIELD_ID_REFPAGE_GET: case FIELD_ID_DOCINFO_CUSTOM: // always number returnfalse;
case FIELD_ID_COMBINED_CHARACTERS: case FIELD_ID_BIBLIOGRAPHY: case FIELD_ID_DDE: case FIELD_ID_REF_REFERENCE: case FIELD_ID_REF_SEQUENCE: case FIELD_ID_REF_BOOKMARK: case FIELD_ID_REF_FOOTNOTE: case FIELD_ID_REF_ENDNOTE: case FIELD_ID_REF_STYLE: case FIELD_ID_MACRO: case FIELD_ID_TEMPLATE_NAME: case FIELD_ID_CHAPTER: case FIELD_ID_FILE_NAME: case FIELD_ID_CONDITIONAL_TEXT: case FIELD_ID_HIDDEN_TEXT: case FIELD_ID_HIDDEN_PARAGRAPH: case FIELD_ID_DOCINFO_CREATION_AUTHOR: case FIELD_ID_DOCINFO_DESCRIPTION: case FIELD_ID_DOCINFO_PRINT_AUTHOR: case FIELD_ID_DOCINFO_TITLE: case FIELD_ID_DOCINFO_SUBJECT: case FIELD_ID_DOCINFO_KEYWORDS: case FIELD_ID_DOCINFO_SAVE_AUTHOR: case FIELD_ID_DATABASE_NAME: case FIELD_ID_TEXT_INPUT: case FIELD_ID_SENDER: case FIELD_ID_AUTHOR: case FIELD_ID_PAGENAME: case FIELD_ID_PAGESTRING: case FIELD_ID_SHEET_NAME: case FIELD_ID_MEASURE: case FIELD_ID_URL: case FIELD_ID_DROP_DOWN: // always string: returntrue;
case FIELD_ID_SCRIPT: case FIELD_ID_ANNOTATION: case FIELD_ID_DATABASE_NEXT: case FIELD_ID_DATABASE_SELECT: case FIELD_ID_PLACEHOLDER: case FIELD_ID_UNKNOWN: case FIELD_ID_DRAW_HEADER: case FIELD_ID_DRAW_FOOTER: case FIELD_ID_DRAW_DATE_TIME: default:
OSL_FAIL("unknown field type/field has no content"); returntrue; // invalid info; string in case of doubt
}
}
/// export the styles needed by the given field. Called on first pass /// through document void XMLTextFieldExport::ExportFieldAutoStyle( const Reference<XTextField> & rTextField, constbool bProgress )
{ // get property set
Reference<XPropertySet> xPropSet(rTextField, UNO_QUERY);
// add field master to list of used field masters (if desired) if (moUsedMasters)
{
Reference<XDependentTextField> xDepField(rTextField, UNO_QUERY); if (xDepField.is())
{ // The direct parent may be just the table cell, while we want the topmost parent, e.g. // a header text.
Reference<XText> xOurText = GetToplevelText(rTextField->getAnchor()->getText());
// insert a list for our XText (if necessary) auto aMapIter = moUsedMasters->try_emplace(xOurText).first;
assert(aMapIter != moUsedMasters->end());
// insert this text field master
OUString sFieldMasterName = GetStringProperty(
gsPropertyInstanceName, xDepField->getTextFieldMaster()); if (!sFieldMasterName.isEmpty())
aMapIter->second.insert( sFieldMasterName );
} // else: no dependent field -> no master -> ignore
}
// get Field ID
FieldIdEnum nToken = GetFieldID(rTextField, xPropSet);
// export the character style for all fields // with one exception: combined character fields export their own // text style below
Reference <XPropertySet> xRangePropSet(rTextField->getAnchor(), UNO_QUERY); if (FIELD_ID_COMBINED_CHARACTERS != nToken)
{
GetExport().GetTextParagraphExport()->Add(
XmlStyleFamily::TEXT_TEXT, xRangePropSet);
}
// process special styles for each field (e.g. data styles) switch (nToken) {
case FIELD_ID_DATABASE_DISPLAY:
{
sal_Int32 nFormat = GetIntProperty(gsPropertyNumberFormat, xPropSet); // workaround: #no-bug#; see IsStringField(...) if ( (5100 != nFormat) &&
!GetBoolProperty(gsPropertyIsDataBaseFormat, xPropSet) )
{
GetExport().addDataStyle(nFormat);
} break;
}
case FIELD_ID_DATE: case FIELD_ID_TIME:
{ // date and time fields are always number fields, but the // NumberFormat property is optional (e.g. Calc doesn't // support it)
Reference<XPropertySetInfo> xPropSetInfo(
xPropSet->getPropertySetInfo() ); if ( xPropSetInfo->hasPropertyByName( gsPropertyNumberFormat ) )
{
sal_Int32 nFormat =
GetIntProperty(gsPropertyNumberFormat, xPropSet);
// nFormat may be -1 for numeric fields that display their // variable name. (Maybe this should be a field type, then?) if (nFormat != -1)
{ if( ! GetOptionalBoolProperty(
gsPropertyIsFixedLanguage,
xPropSet, xPropSetInfo, false ) )
{
nFormat =
GetExport().dataStyleForceSystemLanguage(nFormat);
}
case FIELD_ID_META: // recurse into content (does not export element, so can be done first)
{ bool dummy_for_autostyles(true);
ExportMetaField(xPropSet, true, bProgress, dummy_for_autostyles);
}
[[fallthrough]]; case FIELD_ID_DOCINFO_PRINT_TIME: case FIELD_ID_DOCINFO_PRINT_DATE: case FIELD_ID_DOCINFO_CREATION_DATE: case FIELD_ID_DOCINFO_CREATION_TIME: case FIELD_ID_DOCINFO_SAVE_TIME: case FIELD_ID_DOCINFO_SAVE_DATE: case FIELD_ID_DOCINFO_EDIT_DURATION: case FIELD_ID_VARIABLE_SET: case FIELD_ID_VARIABLE_GET: case FIELD_ID_VARIABLE_INPUT: case FIELD_ID_USER_GET: case FIELD_ID_EXPRESSION: case FIELD_ID_TABLE_FORMULA: case FIELD_ID_DOCINFO_CUSTOM: // register number format, if this is a numeric field if (! IsStringField(nToken, xPropSet)) {
// nFormat may be -1 for numeric fields that display their // variable name. (Maybe this should be a field type, then?) if (nFormat != -1)
{ // handle formats for fixed language fields // for all these fields (except table formula) if( ( nToken != FIELD_ID_TABLE_FORMULA ) &&
! GetOptionalBoolProperty(
gsPropertyIsFixedLanguage,
xPropSet, xPropSet->getPropertySetInfo(), false ) )
{
nFormat =
GetExport().dataStyleForceSystemLanguage(nFormat);
}
GetExport().addDataStyle(nFormat);
}
} break;
case FIELD_ID_COMBINED_CHARACTERS:
{ // export text style with the addition of the combined characters
DBG_ASSERT(nullptr != pCombinedCharactersPropertyState, "need proper PropertyState for combined characters");
std::span<XMLPropertyState> aStates( pCombinedCharactersPropertyState.get(), 1 );
GetExport().GetTextParagraphExport()->Add(
XmlStyleFamily::TEXT_TEXT, xRangePropSet,
aStates); break;
}
case FIELD_ID_ANNOTATION: if (auto xText = XTextFromTextRangeProp(xPropSet))
GetExport().GetTextParagraphExport()->collectTextAutoStyles(xText, bProgress); break;
case FIELD_ID_SCRIPT: case FIELD_ID_BIBLIOGRAPHY: case FIELD_ID_DDE: case FIELD_ID_REF_REFERENCE: case FIELD_ID_REF_SEQUENCE: case FIELD_ID_REF_BOOKMARK: case FIELD_ID_REF_FOOTNOTE: case FIELD_ID_REF_ENDNOTE: case FIELD_ID_REF_STYLE: case FIELD_ID_MACRO: case FIELD_ID_REFPAGE_SET: case FIELD_ID_REFPAGE_GET: case FIELD_ID_COUNT_PAGES: case FIELD_ID_COUNT_PAGES_RANGE: case FIELD_ID_COUNT_PARAGRAPHS: case FIELD_ID_COUNT_WORDS: case FIELD_ID_COUNT_CHARACTERS: case FIELD_ID_COUNT_TABLES: case FIELD_ID_COUNT_GRAPHICS: case FIELD_ID_COUNT_OBJECTS: case FIELD_ID_CONDITIONAL_TEXT: case FIELD_ID_HIDDEN_TEXT: case FIELD_ID_HIDDEN_PARAGRAPH: case FIELD_ID_DOCINFO_CREATION_AUTHOR: case FIELD_ID_DOCINFO_DESCRIPTION: case FIELD_ID_DOCINFO_PRINT_AUTHOR: case FIELD_ID_DOCINFO_TITLE: case FIELD_ID_DOCINFO_SUBJECT: case FIELD_ID_DOCINFO_KEYWORDS: case FIELD_ID_DOCINFO_REVISION: case FIELD_ID_DOCINFO_SAVE_AUTHOR: case FIELD_ID_SEQUENCE: case FIELD_ID_PAGENAME: case FIELD_ID_PAGENUMBER: case FIELD_ID_PAGESTRING: case FIELD_ID_AUTHOR: case FIELD_ID_SENDER: case FIELD_ID_PLACEHOLDER: case FIELD_ID_USER_INPUT: case FIELD_ID_TEXT_INPUT: case FIELD_ID_DATABASE_NEXT: case FIELD_ID_DATABASE_SELECT: case FIELD_ID_DATABASE_NAME: case FIELD_ID_DATABASE_NUMBER: case FIELD_ID_TEMPLATE_NAME: case FIELD_ID_CHAPTER: case FIELD_ID_FILE_NAME: case FIELD_ID_SHEET_NAME: case FIELD_ID_MEASURE: case FIELD_ID_URL: case FIELD_ID_DROP_DOWN: case FIELD_ID_DRAW_DATE_TIME: case FIELD_ID_DRAW_FOOTER: case FIELD_ID_DRAW_HEADER:
; // no formats for these fields! break;
case FIELD_ID_UNKNOWN: default:
OSL_FAIL("unknown field type!"); // ignore -> no format for unknown break;
}
}
/// export the given field to XML. Called on second pass through document void XMLTextFieldExport::ExportField( const Reference<XTextField> & rTextField, bool bProgress, bool & rPrevCharIsSpace)
{ // get property set
Reference<XPropertySet> xPropSet(rTextField, UNO_QUERY);
// get property set of range (for the attributes)
Reference <XPropertySet> xRangePropSet(rTextField->getAnchor(), UNO_QUERY);
// get Field ID enum FieldIdEnum nToken = GetFieldID(rTextField, xPropSet);
// special treatment for combined characters field, because it is // exported as a style const XMLPropertyState* aStates[] = { pCombinedCharactersPropertyState.get(), nullptr }; const XMLPropertyState **pStates =
FIELD_ID_COMBINED_CHARACTERS == nToken
? aStates
: nullptr;
// find out whether we need to set the style bool bIsUICharStyle; bool bHasAutoStyle;
OUString sStyle = GetExport().GetTextParagraphExport()->
FindTextStyle( xRangePropSet, bIsUICharStyle, bHasAutoStyle, pStates ); bool bHasStyle = !sStyle.isEmpty();
// finally, export the field itself
ExportFieldHelper( rTextField, xPropSet, xRangePropSet, nToken,
bProgress, rPrevCharIsSpace);
}
}
/// export the given field to XML. Called on second pass through document void XMLTextFieldExport::ExportFieldHelper( const Reference<XTextField> & rTextField, const Reference<XPropertySet> & rPropSet, const Reference<XPropertySet> &, enum FieldIdEnum nToken, bool bProgress, bool & rPrevCharIsSpace)
{ // get property set info (because some attributes are not support // in all implementations)
Reference<XPropertySetInfo> xPropSetInfo(rPropSet->getPropertySetInfo());
// process each field type switch (nToken) { case FIELD_ID_AUTHOR: // author field: fixed, field (sub-)type if (xPropSetInfo->hasPropertyByName(gsPropertyIsFixed))
{
GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_FIXED,
(GetBoolProperty(gsPropertyIsFixed, rPropSet) ? XML_TRUE : XML_FALSE) );
}
ExportElement(MapAuthorFieldName(rPropSet), sPresentation); break;
case FIELD_ID_SENDER: // sender field: fixed, field (sub-)type
ProcessBoolean(XML_FIXED,
GetBoolProperty(gsPropertyIsFixed, rPropSet), true);
ExportElement(MapSenderFieldName(rPropSet), sPresentation); break;
case FIELD_ID_TEXT_INPUT: // text input field: description and string-value
ProcessString(XML_DESCRIPTION,
GetStringProperty(gsPropertyHint, rPropSet));
ProcessString(XML_HELP,
GetStringProperty(gsPropertyHelp, rPropSet), true);
ProcessString(XML_HINT,
GetStringProperty(gsPropertyTooltip, rPropSet), true);
ExportElement(XML_TEXT_INPUT, sPresentation); break;
case FIELD_ID_TIME: // all properties (except IsDate) are optional! if (xPropSetInfo->hasPropertyByName(gsPropertyNumberFormat))
{
ProcessValueAndType(false,
GetIntProperty(gsPropertyNumberFormat,rPropSet),
u""_ustr, u"", 0.0, // not used false, false, true,
! GetOptionalBoolProperty(
gsPropertyIsFixedLanguage,
rPropSet, xPropSetInfo, false ), true);
} if (xPropSetInfo->hasPropertyByName(gsPropertyDateTimeValue))
{ // no value -> current time
ProcessTimeOrDateTime(XML_TIME_VALUE,
GetDateTimeProperty(gsPropertyDateTimeValue,
rPropSet));
} if (xPropSetInfo->hasPropertyByName(gsPropertyDateTime))
{ // no value -> current time
ProcessTimeOrDateTime(XML_TIME_VALUE,
GetDateTimeProperty(gsPropertyDateTime,rPropSet));
} if (xPropSetInfo->hasPropertyByName(gsPropertyIsFixed))
{
ProcessBoolean(XML_FIXED,
GetBoolProperty(gsPropertyIsFixed, rPropSet), false);
} if (xPropSetInfo->hasPropertyByName(gsPropertyAdjust))
{ // adjust value given as integer in minutes
ProcessDateTime(XML_TIME_ADJUST,
GetIntProperty(gsPropertyAdjust, rPropSet), false, true);
}
ExportElement(XML_TIME, sPresentation); break;
case FIELD_ID_DATE: // all properties (except IsDate) are optional! if (xPropSetInfo->hasPropertyByName(gsPropertyNumberFormat))
{
ProcessValueAndType(false,
GetIntProperty(gsPropertyNumberFormat,rPropSet),
u""_ustr, u"", 0.0, // not used false, false, true,
! GetOptionalBoolProperty(
gsPropertyIsFixedLanguage,
rPropSet, xPropSetInfo, false ) );
} if (xPropSetInfo->hasPropertyByName(gsPropertyDateTimeValue))
{ // no value -> current date
ProcessDateTime(XML_DATE_VALUE,
GetDateTimeProperty(gsPropertyDateTimeValue,
rPropSet));
} // TODO: remove double-handling after SRC614 elseif (xPropSetInfo->hasPropertyByName(gsPropertyDateTime))
{
ProcessDateTime(XML_DATE_VALUE,
GetDateTimeProperty(gsPropertyDateTime,rPropSet));
} if (xPropSetInfo->hasPropertyByName(gsPropertyIsFixed))
{
ProcessBoolean(XML_FIXED,
GetBoolProperty(gsPropertyIsFixed, rPropSet), false);
} if (xPropSetInfo->hasPropertyByName(gsPropertyAdjust))
{ // adjust value given as number of days
ProcessDateTime(XML_DATE_ADJUST,
GetIntProperty(gsPropertyAdjust, rPropSet), true, true);
}
ExportElement(XML_DATE, sPresentation); break;
case FIELD_ID_PAGENUMBER: // all properties are optional if (xPropSetInfo->hasPropertyByName(gsPropertyNumberingType))
{
ProcessNumberingType(GetInt16Property(gsPropertyNumberingType,
rPropSet));
} if (xPropSetInfo->hasPropertyByName(gsPropertyOffset))
{
sal_Int32 nAdjust = GetIntProperty(gsPropertyOffset, rPropSet);
if (xPropSetInfo->hasPropertyByName(gsPropertySubType))
{ // property SubType used in MapPageNumberName
ProcessString(XML_SELECT_PAGE,
MapPageNumberName(rPropSet, nAdjust));
}
ProcessIntegerDef(XML_PAGE_ADJUST, nAdjust, 0);
}
ExportElement(XML_PAGE_NUMBER, sPresentation); break;
case FIELD_ID_PAGESTRING:
{
ProcessString(XML_STRING_VALUE,
GetStringProperty(gsPropertyUserText, rPropSet),
sPresentation);
sal_Int32 nDummy = 0; // MapPageNumberName need int
ProcessString(XML_SELECT_PAGE, MapPageNumberName(rPropSet, nDummy));
ExportElement(XML_PAGE_CONTINUATION, sPresentation); break;
}
case FIELD_ID_DATABASE_DISPLAY:
{ // get database, table and column name from field master const Reference<XPropertySet> xMaster = GetMasterPropertySet(rTextField);
ProcessString(XML_TABLE_NAME,
GetStringProperty(gsPropertyDataTableName, xMaster));
ProcessCommandType(GetIntProperty(gsPropertyDataCommandType, xMaster));
ProcessString(XML_COLUMN_NAME,
GetStringProperty(gsPropertyDataColumnName, xMaster)); // export number format if available (happens only for numbers!) if (!GetBoolProperty(gsPropertyIsDataBaseFormat, rPropSet))
{
ProcessValueAndType(false, // doesn't happen for text
GetIntProperty(gsPropertyNumberFormat,rPropSet),
u""_ustr, u"", 0.0, // not used false, false, true, false);
}
ProcessDisplay(GetBoolProperty(gsPropertyIsVisible, rPropSet), false);
ExportDataBaseElement(XML_DATABASE_DISPLAY, sPresentation,
xMaster, xMaster->getPropertySetInfo()); break;
}
case FIELD_ID_DOCINFO_REVISION:
ProcessBoolean(XML_FIXED,
GetBoolProperty(gsPropertyIsFixed, rPropSet), false);
ExportElement(MapDocInfoFieldName(nToken), sPresentation); break;
case FIELD_ID_DOCINFO_EDIT_DURATION: case FIELD_ID_DOCINFO_SAVE_TIME: case FIELD_ID_DOCINFO_CREATION_TIME: case FIELD_ID_DOCINFO_PRINT_TIME: case FIELD_ID_DOCINFO_SAVE_DATE: case FIELD_ID_DOCINFO_CREATION_DATE: case FIELD_ID_DOCINFO_PRINT_DATE:
ProcessValueAndType(false,
GetIntProperty(gsPropertyNumberFormat, rPropSet),
u""_ustr, u"", 0.0, false, false, true,
! GetOptionalBoolProperty(
gsPropertyIsFixedLanguage,
rPropSet, xPropSetInfo, false ) );
// todo: export date/time value, but values not available -> core bug
ProcessBoolean(XML_FIXED,
GetBoolProperty(gsPropertyIsFixed, rPropSet), false);
ExportElement(MapDocInfoFieldName(nToken), sPresentation); break;
case FIELD_ID_DOCINFO_CREATION_AUTHOR: case FIELD_ID_DOCINFO_DESCRIPTION: case FIELD_ID_DOCINFO_PRINT_AUTHOR: case FIELD_ID_DOCINFO_TITLE: case FIELD_ID_DOCINFO_SUBJECT: case FIELD_ID_DOCINFO_KEYWORDS: case FIELD_ID_DOCINFO_SAVE_AUTHOR: if (xPropSetInfo->hasPropertyByName(gsPropertyIsFixed))
{
ProcessBoolean(XML_FIXED,
GetBoolProperty(gsPropertyIsFixed, rPropSet), false);
}
ExportElement(MapDocInfoFieldName(nToken), sPresentation); break;
case FIELD_ID_DOCINFO_CUSTOM:
{
ProcessValueAndType(false, // doesn't happen for text
GetIntProperty(gsPropertyNumberFormat,rPropSet),
u""_ustr, u"", 0.0, // not used false, false, true,
! GetOptionalBoolProperty(
gsPropertyIsFixedLanguage,
rPropSet, xPropSetInfo, false ));
uno::Any aAny = rPropSet->getPropertyValue( gsPropertyName );
OUString sName;
aAny >>= sName;
ProcessString(XML_NAME, sName);
ProcessBoolean(XML_FIXED, GetBoolProperty(gsPropertyIsFixed, rPropSet), false);
ExportElement(XML_USER_DEFINED, sPresentation); break;
}
case FIELD_ID_COUNT_PAGES: case FIELD_ID_COUNT_PARAGRAPHS: case FIELD_ID_COUNT_WORDS: case FIELD_ID_COUNT_CHARACTERS: case FIELD_ID_COUNT_TABLES: case FIELD_ID_COUNT_GRAPHICS: case FIELD_ID_COUNT_OBJECTS: // all properties optional (applies to pages only, but I'll do // it for all for sake of common implementation) if (xPropSetInfo->hasPropertyByName(gsPropertyNumberingType))
{
ProcessNumberingType(GetInt16Property(gsPropertyNumberingType,
rPropSet));
}
ExportElement(MapCountFieldName(nToken), sPresentation, XML_NAMESPACE_TEXT); break;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.