Line data Source code
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 : #ifndef INCLUDED_SW_INC_EDGLBLDC_HXX
20 : #define INCLUDED_SW_INC_EDGLBLDC_HXX
21 :
22 : #include <o3tl/sorted_vector.hxx>
23 :
24 : class SwSection;
25 : class SwTOXBase;
26 : class SwTOXBaseSection;
27 :
28 : enum GlobalDocContentType {
29 : GLBLDOC_UNKNOWN,
30 : GLBLDOC_TOXBASE,
31 : GLBLDOC_SECTION
32 : };
33 :
34 : class SwGlblDocContent
35 : {
36 : GlobalDocContentType eType;
37 : sal_uLong nDocPos;
38 : union {
39 : const SwTOXBase* pTOX;
40 : const SwSection* pSect;
41 : } PTR;
42 :
43 : public:
44 : SwGlblDocContent( sal_uLong nPos );
45 : SwGlblDocContent( const SwTOXBaseSection* pTOX );
46 : SwGlblDocContent( const SwSection* pSect );
47 :
48 : /// Query contents.
49 0 : GlobalDocContentType GetType() const { return eType; }
50 0 : const SwSection* GetSection() const
51 0 : { return GLBLDOC_SECTION == eType ? PTR.pSect : 0; }
52 0 : const SwTOXBase* GetTOX() const
53 0 : { return GLBLDOC_TOXBASE == eType ? PTR.pTOX : 0; }
54 0 : sal_uLong GetDocPos() const { return nDocPos; }
55 :
56 : /// For sorting.
57 0 : inline bool operator==( const SwGlblDocContent& rCmp ) const
58 0 : { return GetDocPos() == rCmp.GetDocPos(); }
59 0 : inline bool operator<( const SwGlblDocContent& rCmp ) const
60 0 : { return GetDocPos() < rCmp.GetDocPos(); }
61 : };
62 :
63 0 : class SwGlblDocContents : public o3tl::sorted_vector<SwGlblDocContent*, o3tl::less_ptr_to<SwGlblDocContent> > {
64 : public:
65 0 : ~SwGlblDocContents() { DeleteAndDestroyAll(); }
66 : };
67 :
68 : #endif
69 :
70 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|