LibreOffice Module editeng (master) 1
outlobj.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#pragma once
21
24#include <rtl/ustring.hxx>
25#include <svl/poolitem.hxx>
26#include <svl/style.hxx>
27#include <o3tl/cow_wrapper.hxx>
28#include <stdexcept>
29#include <memory>
30
31class EditTextObject;
32enum class OutlinerMode;
33enum class TextRotation;
34
40{
41 // data members
42 std::unique_ptr<EditTextObject> mpEditTextObject;
45
46 // constructor
47 OutlinerParaObjData( std::unique_ptr<EditTextObject> pEditTextObject, ParagraphDataVector&& rParagraphDataVector, bool bIsEditDoc );
48
50
52
53 // assignment operator
55
56 // destructor
58
59 bool operator==(const OutlinerParaObjData& rCandidate) const;
60
61 // #i102062#
62 bool isWrongListEqual(const OutlinerParaObjData& rCompare) const;
63};
64
66{
67friend class std::optional<OutlinerParaObject>;
69
70 OutlinerParaObject(std::nullopt_t) noexcept
71 : mpImpl(std::nullopt) {}
72 OutlinerParaObject( const OutlinerParaObject& other, std::nullopt_t ) noexcept
73 : mpImpl(other.mpImpl, std::nullopt) {}
74
75public:
76 // constructors/destructor
77 OutlinerParaObject(std::unique_ptr<EditTextObject>, ParagraphDataVector&&, bool bIsEditDoc);
78 OutlinerParaObject( std::unique_ptr<EditTextObject> );
82
83 // assignment operator
84 OutlinerParaObject& operator=(const OutlinerParaObject& rCandidate);
85 OutlinerParaObject& operator=(OutlinerParaObject&&) noexcept;
86
87 // compare operator
88 bool operator==(const OutlinerParaObject& rCandidate) const;
89 bool operator!=(const OutlinerParaObject& rCandidate) const { return !operator==(rCandidate); }
90
91 // #i102062#
92 bool isWrongListEqual(const OutlinerParaObject& rCompare) const;
93
94 // outliner mode access
95 OutlinerMode GetOutlinerMode() const;
96 void SetOutlinerMode(OutlinerMode nNew);
97
98 // vertical access
99 bool IsEffectivelyVertical() const;
100 bool GetVertical() const;
101 bool IsTopToBottom() const;
102 void SetVertical(bool bNew);
103 void SetRotation(TextRotation nRotation);
104 TextRotation GetRotation() const;
105
106 // data read access
107 sal_Int32 Count() const;
108 sal_Int16 GetDepth(sal_Int32 nPara) const;
109 const EditTextObject& GetTextObject() const;
110 const ParagraphData& GetParagraphData(sal_Int32 nIndex) const;
111
112 // portion info support
113 void ClearPortionInfo();
114
115 // StyleSheet support
116 bool ChangeStyleSheets(std::u16string_view rOldName, SfxStyleFamily eOldFamily,
117 const OUString& rNewName, SfxStyleFamily eNewFamily);
118 void ChangeStyleSheetName(SfxStyleFamily eFamily, std::u16string_view rOldName,
119 const OUString& rNewName);
120 void SetStyleSheets(sal_uInt16 nLevel, const OUString& rNewName,
121 const SfxStyleFamily& rNewFamily);
122
123 void dumpAsXml(xmlTextWriterPtr pWriter) const;
124};
125
126namespace std
127{
131 template<>
132 class optional<OutlinerParaObject>
133 {
134 public:
135 optional() noexcept : maParaObject(std::nullopt) {}
136 optional(std::nullopt_t) noexcept : maParaObject(std::nullopt) {}
137 optional(const optional& other) :
138 maParaObject(other.maParaObject, std::nullopt) {}
139 optional(optional&& other) noexcept :
140 maParaObject(std::move(other.maParaObject)) {}
141 optional(OutlinerParaObject&& para) noexcept :
142 maParaObject(std::move(para)) {}
143 optional(const OutlinerParaObject& para) noexcept :
144 maParaObject(para) {}
145 template< class... Args >
146 explicit optional( std::in_place_t, Args&&... args ) :
147 maParaObject(std::forward<Args>(args)...) {}
148
149 optional& operator=(optional const & other)
150 {
151 maParaObject = other.maParaObject;
152 return *this;
153 }
154 optional& operator=(optional&& other) noexcept
155 {
156 maParaObject = std::move(other.maParaObject);
157 return *this;
158 }
159 template< class... Args >
160 void emplace(Args&&... args )
161 {
162 maParaObject = OutlinerParaObject(std::forward<Args>(args)...);
163 }
164
165 bool has_value() const noexcept { return !maParaObject.mpImpl.empty(); }
166 explicit operator bool() const noexcept { return !maParaObject.mpImpl.empty(); }
167 void reset() { maParaObject.mpImpl.set_empty(); }
168
170 {
171 throwIfEmpty();
172 return maParaObject;
173 }
175 {
176 throwIfEmpty();
177 return maParaObject;
178 }
180 {
181 throwIfEmpty();
182 return maParaObject;
183 }
185 {
186 throwIfEmpty();
187 return &maParaObject;
188 }
190 {
191 throwIfEmpty();
192 return &maParaObject;
193 }
194 private:
195 void throwIfEmpty() const
196 {
197 if (maParaObject.mpImpl.empty())
198 throw std::logic_error("empty std::optional<OutlinerParaObject>");
199 }
201 };
202};
203
204/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OutlinerParaObject(const OutlinerParaObject &other, std::nullopt_t) noexcept
Definition: outlobj.hxx:72
::o3tl::cow_wrapper< OutlinerParaObjData > mpImpl
Definition: outlobj.hxx:68
OutlinerParaObject(std::nullopt_t) noexcept
Definition: outlobj.hxx:70
optional(std::in_place_t, Args &&... args)
Definition: outlobj.hxx:146
bool has_value() const noexcept
Definition: outlobj.hxx:165
void emplace(Args &&... args)
Definition: outlobj.hxx:160
const OutlinerParaObject & operator*() const
Definition: outlobj.hxx:179
optional(const OutlinerParaObject &para) noexcept
Definition: outlobj.hxx:143
optional(const optional &other)
Definition: outlobj.hxx:137
optional(std::nullopt_t) noexcept
Definition: outlobj.hxx:136
optional(OutlinerParaObject &&para) noexcept
Definition: outlobj.hxx:141
optional(optional &&other) noexcept
Definition: outlobj.hxx:139
OutlinerParaObject maParaObject
Definition: outlobj.hxx:200
optional & operator=(optional const &other)
Definition: outlobj.hxx:149
OutlinerParaObject & operator*()
Definition: outlobj.hxx:174
const OutlinerParaObject * operator->() const
Definition: outlobj.hxx:189
OutlinerParaObject & value()
Definition: outlobj.hxx:169
OutlinerParaObject * operator->()
Definition: outlobj.hxx:184
optional & operator=(optional &&other) noexcept
Definition: outlobj.hxx:154
bool operator==(const EditLine &r1, const EditLine &r2)
Definition: editdoc.cxx:978
#define EDITENG_DLLPUBLIC
Definition: editengdllapi.h:28
TextRotation
Definition: editobj.hxx:55
struct _xmlTextWriter * xmlTextWriterPtr
def forward(n)
args
OutlinerMode
Definition: outliner.hxx:563
::std::vector< ParagraphData > ParagraphDataVector
This is the guts of OutlinerParaObject, refcounted and shared among multiple instances of OutlinerPar...
Definition: outlobj.hxx:40
OutlinerParaObjData(OutlinerParaObjData &&r)=default
ParagraphDataVector maParagraphDataVector
Definition: outlobj.hxx:43
std::unique_ptr< EditTextObject > mpEditTextObject
Definition: outlobj.hxx:42
OutlinerParaObjData & operator=(const OutlinerParaObjData &rCandidate)=delete
SfxStyleFamily
Count