/* -*- 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 .
*/
usingnamespace css::uno; usingnamespace css::xml::dom; usingnamespace css::xml::dom::events; namespace DOM { class CElementListImpl; }
namespace DOM
{ class WeakEventListener : public ::cppu::WeakImplHelper<css::xml::dom::events::XEventListener>
{ private:
unotools::WeakReference<DOM::CElementListImpl> mxOwner;
void CElementListImpl::buildlist(xmlNodePtr pNode, bool start)
{ // bail out if no rebuild is needed if (start) { if (!m_bRebuild)
{ return;
} else {
m_nodevector.clear();
m_bRebuild = false; // don't rebuild until tree is mutated
}
}
while (pNode != nullptr )
{ if (pNode->type == XML_ELEMENT_NODE &&
(strcmp(reinterpret_cast<charconst *>(pNode->name), reinterpret_cast<char*>(m_pName.get())) == 0))
{ if (!m_pURI) {
m_nodevector.push_back(pNode);
} else { if (pNode->ns != nullptr && (0 ==
strcmp(reinterpret_cast<charconst *>(pNode->ns->href), reinterpret_cast<char*>(m_pURI.get()))))
{
m_nodevector.push_back(pNode);
}
}
} if (pNode->children != nullptr) buildlist(pNode->children, false);
if (!start) pNode = pNode->next; elsebreak; // fold back
}
}
/** The number of nodes in the list.
*/
sal_Int32 SAL_CALL CElementListImpl::getLength()
{
::osl::MutexGuard const g(m_rMutex);
if (!m_pElement.is()) { return 0; }
// this has to be 'live'
buildlist(m_pElement->GetNodePtr()); return m_nodevector.size();
} /** Returns the indexth item in the collection.
*/
Reference< XNode > SAL_CALL CElementListImpl::item(sal_Int32 index)
{ if (index < 0) throw RuntimeException();
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.