lok: calc - send other views our selection in their co-ordinates.
[LibreOffice.git] / include / codemaker / exceptiontree.hxx
blob389593fd57be062c4fa6171470da57894cee19e6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_CODEMAKER_EXCEPTIONTREE_HXX
21 #define INCLUDED_CODEMAKER_EXCEPTIONTREE_HXX
23 #include <codemaker/global.hxx>
24 #include <rtl/ref.hxx>
25 #include <rtl/string.hxx>
27 #include <memory>
28 #include <vector>
30 class TypeManager;
32 namespace codemaker {
34 /**
35 Represents a node of the hierarchy from the ExceptionTree class.
37 struct ExceptionTreeNode {
38 typedef std::vector< std::unique_ptr<ExceptionTreeNode> > Children;
40 // Internally used by ExceptionTree:
41 ExceptionTreeNode(rtl::OString const & theName):
42 name(theName), present(false) {}
44 // Internally used by ExceptionTree:
45 ~ExceptionTreeNode() { clearChildren(); }
47 // Internally used by ExceptionTree:
48 void setPresent() { present = true; clearChildren(); }
50 // Internally used by ExceptionTree:
51 ExceptionTreeNode * add(rtl::OString const & theName);
53 rtl::OString name;
54 bool present;
55 Children children;
57 private:
58 ExceptionTreeNode(ExceptionTreeNode const &) = delete;
59 ExceptionTreeNode& operator =(ExceptionTreeNode const &) = delete;
61 void clearChildren();
64 /**
65 Represents the hierarchy formed by a set of UNO exception types.
67 The hierarchy is rooted at com.sun.star.uno.Exception. For each exception E
68 from the given set S, the hierarchy from com.sun.star.uno.Exception to the
69 first supertype E' of E which is itself a member of S is represented (i.e.,
70 subtypes that are hidden by supertypes are pruned from the hierarchy). The
71 exception com.sun.star.uno.RuntimeException and its subtypes are pruned
72 completely from the hierarchy. Each node of the hierarchy is represented by
73 an instance of ExceptionTreeNode, where name gives the name of the UNO
74 exception type, present is true iff the given exception type is a member of
75 the set S, and children contains all the relevant direct subtypes of the
76 given exception type, in no particular order (for nodes other than the root
77 node it holds that children is non-empty iff present is false).
79 class ExceptionTree {
80 public:
81 ExceptionTree(): m_root("com.sun.star.uno.Exception") {}
83 /**
84 Builds the exception hierarchy, by adding one exception type at a time.
86 This function can be called more than once for the same exception name.
88 @param name the name of a UNO exception type; it is an error if the given
89 name does not represent a UNO exception type
91 @param manager a type manager, used to resolve type names; it is an error
92 if different calls to this member function use different, incompatible
93 type managers
95 void add(
96 rtl::OString const & name,
97 rtl::Reference< TypeManager > const & manager);
99 /**
100 Gives access to the resultant exception hierarchy.
102 @return a reference to the root of the exception hierarchy, as
103 formed by all previous calls to add; it is an error if any calls to add
104 follow the first call to getRoot
106 ExceptionTreeNode const & getRoot() const { return m_root; }
108 private:
109 ExceptionTree(ExceptionTree const &) = delete;
110 ExceptionTree& operator =(const ExceptionTree&) = delete;
112 ExceptionTreeNode m_root;
117 #endif
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */