/* -*- 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 .
*/
using ::com::sun::star::beans::XPropertySet; using ::com::sun::star::beans::PropertyValues; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Any; using ::com::sun::star::container::XIndexReplace;
XMLIndexTemplateContext::XMLIndexTemplateContext(
SvXMLImport& rImport,
Reference<XPropertySet> & rPropSet, const SvXMLEnumMapEntry<sal_uInt16>* pLevelNameMap, enum XMLTokenEnum eLevelAttrName,
std::span<const OUString> pLevelStylePropMap, constbool* pAllowedTokenTypes, bool bT )
: SvXMLImportContext(rImport)
, pOutlineLevelNameMap(pLevelNameMap)
, eOutlineLevelAttrName(eLevelAttrName)
, pOutlineLevelStylePropMap(pLevelStylePropMap)
, pAllowedTokenTypesMap(pAllowedTokenTypes)
, nOutlineLevel(1) // all indices have level 1 (0 is for header)
, bStyleNameOK(false)
, bOutlineLevelOK(false)
, bTOC( bT )
, rPropertySet(rPropSet)
{
DBG_ASSERT( ((XML_TOKEN_INVALID != eLevelAttrName) && (nullptr != pLevelNameMap))
|| ((XML_TOKEN_INVALID == eLevelAttrName) && (nullptr == pLevelNameMap)), "need both, attribute name and value map, or neither" );
SAL_WARN_IF( nullptr == pAllowedTokenTypes, "xmloff", "need allowed tokens map" );
// no map for outline-level? then use 1 if (nullptr == pLevelNameMap)
{
nOutlineLevel = 1;
bOutlineLevelOK = true;
}
}
if (IsTokenInNamespace(nElement, XML_NAMESPACE_TEXT) || IsTokenInNamespace(nElement, XML_NAMESPACE_LO_EXT))
{
TemplateTokenType nToken; if (SvXMLUnitConverter::convertEnum(nToken, SvXMLImport::getNameFromToken(nElement),
aTemplateTokenTypeMap))
{ // can this index accept this kind of token? if (pAllowedTokenTypesMap[nToken])
{ switch (nToken)
{ case XML_TOK_INDEX_TYPE_ENTRY_TEXT:
pContext = new XMLIndexSimpleEntryContext(
GetImport(), u"TokenEntryText"_ustr, *this); break;
case XML_TOK_INDEX_TYPE_PAGE_NUMBER:
pContext = new XMLIndexSimpleEntryContext(
GetImport(), u"TokenPageNumber"_ustr, *this); break;
case XML_TOK_INDEX_TYPE_LINK_START:
pContext = new XMLIndexSimpleEntryContext(
GetImport(), u"TokenHyperlinkStart"_ustr, *this); break;
case XML_TOK_INDEX_TYPE_LINK_END:
pContext = new XMLIndexSimpleEntryContext(
GetImport(), u"TokenHyperlinkEnd"_ustr, *this); break;
case XML_TOK_INDEX_TYPE_TEXT:
pContext = new XMLIndexSpanEntryContext(
GetImport(), *this); break;
case XML_TOK_INDEX_TYPE_TAB_STOP:
pContext = new XMLIndexTabStopEntryContext(
GetImport(), *this); break;
case XML_TOK_INDEX_TYPE_BIBLIOGRAPHY:
pContext = new XMLIndexBibliographyEntryContext(
GetImport(), *this); break;
case XML_TOK_INDEX_TYPE_CHAPTER:
pContext = new XMLIndexChapterInfoEntryContext(
GetImport(), *this, bTOC ); break;
default: // ignore! break;
}
}
}
}
// ignore unknown return pContext;
}
// maps for the XMLIndexTemplateContext constructor
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.