/src/libreoffice/editeng/source/outliner/outlobj.cxx
Line | Count | Source |
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 | | #include <editeng/outliner.hxx> |
21 | | #include <editeng/outlobj.hxx> |
22 | | #include <editeng/editobj.hxx> |
23 | | #include <sal/log.hxx> |
24 | | #include <osl/diagnose.h> |
25 | | |
26 | | #include <o3tl/cow_wrapper.hxx> |
27 | | #include <o3tl/safeint.hxx> |
28 | | #include <libxml/xmlwriter.h> |
29 | | |
30 | | |
31 | | |
32 | | OutlinerParaObject::OutlinerParaObject( EditTextObject&& aTextObj ) : |
33 | 1.63M | mpImpl(std::move(aTextObj)) |
34 | 1.63M | { |
35 | 1.63M | } |
36 | | |
37 | | OutlinerParaObject::OutlinerParaObject( const OutlinerParaObject& r ) : |
38 | 249k | mpImpl(r.mpImpl) |
39 | 249k | { |
40 | 249k | } |
41 | | |
42 | | OutlinerParaObject::OutlinerParaObject( OutlinerParaObject&& r ) noexcept : |
43 | 5.31M | mpImpl(std::move(r.mpImpl)) |
44 | 5.31M | { |
45 | 5.31M | } |
46 | | |
47 | | OutlinerParaObject::~OutlinerParaObject() |
48 | 9.03M | { |
49 | 9.03M | } |
50 | | |
51 | | OutlinerParaObject& OutlinerParaObject::operator=( const OutlinerParaObject& r ) |
52 | 0 | { |
53 | 0 | mpImpl = r.mpImpl; |
54 | 0 | return *this; |
55 | 0 | } |
56 | | |
57 | | OutlinerParaObject& OutlinerParaObject::operator=( OutlinerParaObject&& r ) noexcept |
58 | 2.05M | { |
59 | 2.05M | mpImpl = std::move(r.mpImpl); |
60 | 2.05M | return *this; |
61 | 2.05M | } |
62 | | |
63 | | bool OutlinerParaObject::operator==( const OutlinerParaObject& r ) const |
64 | 309 | { |
65 | 309 | return r.mpImpl == mpImpl; |
66 | 309 | } |
67 | | |
68 | | // #i102062# |
69 | | bool OutlinerParaObject::isWrongListEqual( const OutlinerParaObject& r ) const |
70 | 309 | { |
71 | 309 | if (r.mpImpl.same_object(mpImpl)) |
72 | 309 | { |
73 | 309 | return true; |
74 | 309 | } |
75 | | |
76 | 0 | return mpImpl->isWrongListEqual(*r.mpImpl); |
77 | 309 | } |
78 | | |
79 | | OutlinerMode OutlinerParaObject::GetOutlinerMode() const |
80 | 931k | { |
81 | 931k | return mpImpl->GetUserType(); |
82 | 931k | } |
83 | | |
84 | | void OutlinerParaObject::SetOutlinerMode(OutlinerMode nNew) |
85 | 1.63M | { |
86 | | // create a const pointer to avoid an early call to |
87 | | // make_unique() in the dereference of mpImpl |
88 | 1.63M | const ::o3tl::cow_wrapper< EditTextObject >* pImpl = &mpImpl; |
89 | 1.63M | if ( ( *pImpl )->GetUserType() != nNew ) |
90 | 1.63M | { |
91 | 1.63M | mpImpl->SetUserType(nNew); |
92 | 1.63M | } |
93 | 1.63M | } |
94 | | |
95 | | bool OutlinerParaObject::IsEffectivelyVertical() const |
96 | 3.27M | { |
97 | 3.27M | return mpImpl->IsEffectivelyVertical(); |
98 | 3.27M | } |
99 | | |
100 | | bool OutlinerParaObject::GetVertical() const |
101 | 0 | { |
102 | 0 | return mpImpl->GetVertical(); |
103 | 0 | } |
104 | | |
105 | | bool OutlinerParaObject::IsTopToBottom() const |
106 | 19.1k | { |
107 | 19.1k | return mpImpl->IsTopToBottom(); |
108 | 19.1k | } |
109 | | |
110 | | void OutlinerParaObject::SetVertical(bool bNew) |
111 | 13.5k | { |
112 | 13.5k | const ::o3tl::cow_wrapper< EditTextObject >* pImpl = &mpImpl; |
113 | 13.5k | if ( ( *pImpl )->IsEffectivelyVertical() != bNew) |
114 | 2.36k | { |
115 | 2.36k | mpImpl->SetVertical(bNew); |
116 | 2.36k | } |
117 | 13.5k | } |
118 | | void OutlinerParaObject::SetRotation(TextRotation nRotation) |
119 | 0 | { |
120 | 0 | mpImpl->SetRotation(nRotation); |
121 | 0 | } |
122 | | |
123 | | TextRotation OutlinerParaObject::GetRotation() const |
124 | 0 | { |
125 | 0 | return mpImpl->GetRotation(); |
126 | 0 | } |
127 | | |
128 | | sal_Int32 OutlinerParaObject::Count() const |
129 | 3.67M | { |
130 | 3.67M | size_t nSize = mpImpl->GetParagraphCount(); |
131 | 3.67M | if (nSize > o3tl::make_unsigned(EE_PARA_MAX)) |
132 | 0 | { |
133 | 0 | SAL_WARN( "editeng", "OutlinerParaObject::Count - overflow " << nSize); |
134 | 0 | return EE_PARA_MAX; |
135 | 0 | } |
136 | 3.67M | return static_cast<sal_Int32>(nSize); |
137 | 3.67M | } |
138 | | |
139 | | sal_Int16 OutlinerParaObject::GetNumberingDepth(sal_Int32 nPara) const |
140 | 2.73M | { |
141 | 2.73M | return mpImpl->GetNumberingDepth(nPara); |
142 | 2.73M | } |
143 | | |
144 | | sal_Int16 OutlinerParaObject::GetNumberingStartValue(sal_Int32 nPara) const |
145 | 2.73M | { |
146 | 2.73M | return mpImpl->GetNumberingStartValue(nPara); |
147 | 2.73M | } |
148 | | |
149 | | bool OutlinerParaObject::IsNumberingRestart(sal_Int32 nPara) const |
150 | 2.73M | { |
151 | 2.73M | return mpImpl->IsNumberingRestart(nPara); |
152 | 2.73M | } |
153 | | |
154 | | const EditTextObject& OutlinerParaObject::GetTextObject() const |
155 | 2.92M | { |
156 | 2.92M | return *mpImpl; |
157 | 2.92M | } |
158 | | |
159 | | void OutlinerParaObject::ClearPortionInfo() |
160 | 349k | { |
161 | 349k | mpImpl->ClearPortionInfo(); |
162 | 349k | } |
163 | | |
164 | | bool OutlinerParaObject::ChangeStyleSheets(std::u16string_view rOldName, |
165 | | SfxStyleFamily eOldFamily, const OUString& rNewName, SfxStyleFamily eNewFamily) |
166 | 993k | { |
167 | 993k | return mpImpl->ChangeStyleSheets(rOldName, eOldFamily, rNewName, eNewFamily); |
168 | 993k | } |
169 | | |
170 | | void OutlinerParaObject::ChangeStyleSheetName(SfxStyleFamily eFamily, |
171 | | std::u16string_view rOldName, const OUString& rNewName) |
172 | 8.27M | { |
173 | 8.27M | mpImpl->ChangeStyleSheetName(eFamily, rOldName, rNewName); |
174 | 8.27M | } |
175 | | |
176 | | void OutlinerParaObject::SetStyleSheets(sal_uInt16 nLevel, const OUString& rNewName, |
177 | | const SfxStyleFamily& rNewFamily) |
178 | 20 | { |
179 | 20 | const sal_Int32 nCount(Count()); |
180 | | |
181 | 20 | if(nCount) |
182 | 20 | { |
183 | 20 | sal_Int32 nDecrementer(nCount); |
184 | | |
185 | 160 | while(nDecrementer > 0) |
186 | 140 | { |
187 | 140 | if(GetNumberingDepth(--nDecrementer) == nLevel) |
188 | 14 | { |
189 | 14 | mpImpl->SetStyleSheet(nDecrementer, rNewName, rNewFamily); |
190 | 14 | } |
191 | 140 | } |
192 | 20 | } |
193 | 20 | } |
194 | | |
195 | | void OutlinerParaObject::dumpAsXml(xmlTextWriterPtr pWriter) const |
196 | 0 | { |
197 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("OutlinerParaObject")); |
198 | 0 | (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this); |
199 | 0 | mpImpl->dumpAsXml(pWriter); |
200 | 0 | (void)xmlTextWriterEndElement(pWriter); |
201 | 0 | } |
202 | | |
203 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |