LibreOffice Module sw (master)  1
swcont.hxx
Go to the documentation of this file.
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 #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_SWCONT_HXX
21 #define INCLUDED_SW_SOURCE_UIBASE_INC_SWCONT_HXX
22 
23 #include <rtl/ustring.hxx>
24 #include <tools/long.hxx>
25 #include <vcl/naturalsort.hxx>
26 
27 class SwContentType;
28 
29 enum class ContentTypeId
30 {
31  OUTLINE = 0,
32  TABLE = 1,
33  FRAME = 2,
34  GRAPHIC = 3,
35  OLE = 4,
36  BOOKMARK = 5,
37  REGION = 6,
38  URLFIELD = 7,
39  REFERENCE = 8,
40  INDEX = 9,
41  POSTIT = 10,
42  DRAWOBJECT = 11,
43  TEXTFIELD = 12,
44  FOOTNOTE = 13,
45  LAST = FOOTNOTE,
46  UNKNOWN = -1
47 };
48 
49 // strings for context menus
50 #define CONTEXT_COUNT 17
51 #define GLOBAL_CONTEXT_COUNT 14
52 
53 // modes for Drag 'n Drop
54 enum class RegionMode
55 {
56  NONE = 0,
57  LINK = 1,
58  EMBEDDED = 2
59 };
60 
61 //mini rtti
63 {
65 
66  public:
67  SwTypeNumber(sal_uInt8 nId) :nTypeId(nId){}
68  virtual ~SwTypeNumber();
69 
70  sal_uInt8 GetTypeId() const { return nTypeId;}
71 };
72 
73 class SwContent : public SwTypeNumber
74 {
76  OUString sContentName;
78  // some subclasses appear to use this for a tools/gen.hxx-style
79  // geometric Y position, while e.g. SwOutlineContent wants to store
80  // the index in its subtree
81  bool bInvisible;
82 public:
83  SwContent(const SwContentType* pCnt, const OUString& rName, tools::Long nYPos );
84 
85  virtual bool IsProtect() const;
86  const SwContentType* GetParent() const {return pParent;}
87  const OUString& GetName() const {return sContentName;}
88  bool operator==(const SwContent& /*rCont*/) const
89  {
90  // they're never equal, otherwise they'd fall out of the array
91  return false;
92  }
93  bool operator<(const SwContent& rCont) const
94  {
95  // at first sort by position and then by name
96  if (nYPosition != rCont.nYPosition)
97  return nYPosition < rCont.nYPosition;
98  return vcl::NaturalSortCompare(sContentName, rCont.sContentName) < 0;
99  }
100 
101  bool IsInvisible() const {return bInvisible;}
102  void SetInvisible(){ bInvisible = true;}
103 };
104 
105 #endif
106 
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ContentTypeId
Definition: swcont.hxx:29
sal_Int32 NaturalSortCompare(const OUString &rA, const OUString &rB)
bool bInvisible
Definition: swcont.hxx:81
SwContent(const SwContentType *pCnt, const OUString &rName, tools::Long nYPos)
Definition: content.cxx:209
long Long
SwTypeNumber(sal_uInt8 nId)
Definition: swcont.hxx:67
bool operator==(const SwContent &) const
Definition: swcont.hxx:88
OUString sContentName
Definition: swcont.hxx:76
tools::Long nYPosition
Definition: swcont.hxx:77
bool operator<(const SwContent &rCont) const
Definition: swcont.hxx:93
sal_uInt8 nTypeId
Definition: swcont.hxx:64
virtual ~SwTypeNumber()
Definition: content.cxx:219
const SwContentType * GetParent() const
Definition: swcont.hxx:86
const SwContentType * pParent
Definition: swcont.hxx:75
RegionMode
Definition: swcont.hxx:54
Content type, knows it's contents and the WrtShell.
Definition: content.hxx:171
virtual bool IsProtect() const
Definition: content.cxx:223
sal_uInt8 GetTypeId() const
Definition: swcont.hxx:70
const OUString & GetName() const
Definition: swcont.hxx:87
unsigned char sal_uInt8
void SetInvisible()
Definition: swcont.hxx:102
bool IsInvisible() const
Definition: swcont.hxx:101