| 1 |
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* |
| 3 |
* This file is part of the LibreOffice project. |
| 4 |
* |
| 5 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 6 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 7 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 8 |
* |
| 9 |
* This file incorporates work covered by the following license notice: |
| 10 |
* |
| 11 |
* Licensed to the Apache Software Foundation (ASF) under one or more |
| 12 |
* contributor license agreements. See the NOTICE file distributed |
| 13 |
* with this work for additional information regarding copyright |
| 14 |
* ownership. The ASF licenses this file to you under the Apache |
| 15 |
* License, Version 2.0 (the "License"); you may not use this file |
| 16 |
* except in compliance with the License. You may obtain a copy of |
| 17 |
* the License at http://www.apache.org/licenses/LICENSE-2.0 . |
| 18 |
*/ |
| 19 |
|
| 20 |
#pragma once |
| 21 |
|
| 22 |
#include <com/sun/star/uno/Reference.hxx> |
| 23 |
|
| 24 |
#include <memory> |
| 25 |
#include <vector> |
| 26 |
|
| 27 |
namespace com::sun::star::xml::wrapper |
| 28 |
{ |
| 29 |
class XXMLElementWrapper; |
| 30 |
} |
| 31 |
|
| 32 |
class ElementMark; |
| 33 |
class ElementCollector; |
| 34 |
|
| 35 |
class BufferNode final |
| 36 |
/****** buffernode.hxx/CLASS BufferNode *************************************** |
| 37 |
* |
| 38 |
* NAME |
| 39 |
* BufferNode -- Class to maintain the tree of buffered elements |
| 40 |
* |
| 41 |
* FUNCTION |
| 42 |
* One BufferNode object represents a buffered element in the document |
| 43 |
* wrapper component. |
| 44 |
* All BufferNode objects construct a tree which has the same structure |
| 45 |
* of all buffered elements. That is to say, if one buffered element is |
| 46 |
* an ancestor of another buffered element, then the corresponding |
| 47 |
* BufferNode objects are also in ancestor/descendant relationship. |
| 48 |
* This class is used to manipulate the tree of buffered elements. |
| 49 |
******************************************************************************/ |
| 50 |
{ |
| 51 |
private: |
| 52 |
/* the parent BufferNode */ |
| 53 |
BufferNode* m_pParent; |
| 54 |
|
| 55 |
/* all child BufferNodes */ |
| 56 |
std::vector<std::unique_ptr<BufferNode>> m_vChildren; |
| 57 |
|
| 58 |
/* all ElementCollector holding this BufferNode */ |
| 59 |
std::vector<const ElementCollector*> m_vElementCollectors; |
| 60 |
|
| 61 |
/* |
| 62 |
* the blocker holding this BufferNode, one BufferNode can have one |
| 63 |
* blocker at most |
| 64 |
*/ |
| 65 |
ElementMark* m_pBlocker; |
| 66 |
|
| 67 |
/* |
| 68 |
* whether the element has completely buffered by the document wrapper |
| 69 |
* component |
| 70 |
*/ |
| 71 |
bool m_bAllReceived; |
| 72 |
|
| 73 |
/* the XMLElementWrapper of the buffered element */ |
| 74 |
css::uno::Reference<css::xml::wrapper::XXMLElementWrapper> m_xXMLElement; |
| 75 |
|
| 76 |
private: |
| 77 |
bool isECInSubTreeIncluded(sal_Int32 nIgnoredSecurityId) const; |
| 78 |
bool isECOfBeforeModifyInAncestorIncluded(sal_Int32 nIgnoredSecurityId) const; |
| 79 |
bool isBlockerInSubTreeIncluded(sal_Int32 nIgnoredSecurityId) const; |
| 80 |
const BufferNode* getNextChild(const BufferNode* pChild) const; |
| 81 |
|
| 82 |
public: |
| 83 |
explicit BufferNode(css::uno::Reference<css::xml::wrapper::XXMLElementWrapper> xXMLElement); |
| 84 |
|
| 85 |
bool isECOfBeforeModifyIncluded(sal_Int32 nIgnoredSecurityId) const; |
| 86 |
void setReceivedAll(); |
| 87 |
bool isAllReceived() const { return m_bAllReceived; } |
| 88 |
void addElementCollector(const ElementCollector* pElementCollector); |
| 89 |
void removeElementCollector(const ElementCollector* pElementCollector); |
| 90 |
ElementMark* getBlocker() const { return m_pBlocker; } |
| 91 |
void setBlocker(const ElementMark* pBlocker); |
| 92 |
OUString printChildren() const; |
| 93 |
bool hasAnything() const; |
| 94 |
bool hasChildren() const; |
| 95 |
std::vector<std::unique_ptr<BufferNode>> const& getChildren() const; |
| 96 |
std::vector<std::unique_ptr<BufferNode>> releaseChildren(); |
| 97 |
const BufferNode* getFirstChild() const; |
| 98 |
void addChild(std::unique_ptr<BufferNode> pChild, sal_Int32 nPosition); |
| 99 |
void addChild(std::unique_ptr<BufferNode> pChild); |
| 100 |
void removeChild(const BufferNode* pChild); |
| 101 |
sal_Int32 indexOfChild(const BufferNode* pChild) const; |
| 102 |
const BufferNode* getParent() const { return m_pParent; } |
| 103 |
void setParent(const BufferNode* pParent); |
| 104 |
const BufferNode* getNextSibling() const; |
| 105 |
const BufferNode* isAncestor(const BufferNode* pDescendant) const; |
| 106 |
bool isPrevious(const BufferNode* pFollowing) const; |
| 107 |
const BufferNode* getNextNodeByTreeOrder() const; |
| 108 |
const css::uno::Reference<css::xml::wrapper::XXMLElementWrapper>& getXMLElement() const |
| 109 |
{ |
| 110 |
return m_xXMLElement; |
| 111 |
} |
| 112 |
void |
| 113 |
setXMLElement(const css::uno::Reference<css::xml::wrapper::XXMLElementWrapper>& xXMLElement); |
| 114 |
void notifyBranch(); |
| 115 |
void elementCollectorNotify(); |
| 116 |
}; |
| 117 |
|
| 118 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |