using ::com::sun::star::beans::PropertyValue; using ::com::sun::star::document::XEventsSupplier; using ::com::sun::star::container::XNameReplace; using ::com::sun::star::container::XNameAccess; using ::xmloff::token::XML_EVENT_LISTENERS;
void XMLEventExport::Export( Reference<XNameAccess> const & rAccess, bool bWhitespace)
{ // early out if we don't actually get any events if (!rAccess.is())
{ return;
}
// have we already processed an element? bool bStarted = false;
// iterate over all event types const Sequence<OUString> aNames = rAccess->getElementNames(); for(constauto& rName : aNames)
{ // translate name
NameMap::iterator aIter = m_aNameTranslationMap.find(rName); if (aIter != m_aNameTranslationMap.end())
{ const XMLEventName& rXmlName = aIter->second;
// get PropertyValues for this event
Any aAny = rAccess->getByName( rName );
Sequence<PropertyValue> aValues;
aAny >>= aValues;
// now export the current event
ExportEvent( aValues, rXmlName, bWhitespace, bStarted );
} else
{ // don't proceed further
SAL_WARN("xmloff", "Unknown event name:" << rName );
}
}
// close <script:events> element (if it was opened before) if (bStarted)
{
EndElement(bWhitespace);
}
}
void XMLEventExport::ExportExt( Reference<XNameAccess> const & rAccess )
{ // set bExtNamespace flag to use XML_NAMESPACE_OFFICE_EXT namespace // for events element (not for child elements)
m_bExtNamespace = true;
Export(rAccess);
m_bExtNamespace = false; // reset for future Export calls
}
/// export a singular event and write <office:events> container void XMLEventExport::ExportSingleEvent( const Sequence<PropertyValue>& rEventValues, const OUString& rApiEventName, bool bUseWhitespace )
{ // translate the name
NameMap::iterator aIter = m_aNameTranslationMap.find(rApiEventName); if (aIter != m_aNameTranslationMap.end())
{ const XMLEventName& rXmlName = aIter->second;
// ... and close the container element (if necessary) if (bStarted)
{
EndElement(bUseWhitespace);
}
} else
{ // don't proceed further
SAL_WARN("xmloff", "Unknown event name:" << rApiEventName );
}
}
/// export a single event void XMLEventExport::ExportEvent( const Sequence<PropertyValue>& rEventValues, const XMLEventName& rXmlEventName, bool bUseWhitespace, bool& rExported )
{ // search for EventType value and then delegate to EventHandler const PropertyValue* pValue = std::find_if(rEventValues.begin(), rEventValues.end(),
[](const PropertyValue& rValue) { return u"EventType" == rValue.Name; });
if (pValue == rEventValues.end()) return;
// found! Now find handler and delegate
OUString sType;
pValue->Value >>= sType;
if (m_aHandlerMap.count(sType))
{ if (! rExported)
{ // OK, we have't yet exported the enclosing // element. So we do that now.
rExported = true;
StartElement(bUseWhitespace);
}
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.