LibreOffice Module sw (master) 1
section.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_INC_SECTION_HXX
21#define INCLUDED_SW_INC_SECTION_HXX
22
23#include <com/sun/star/uno/Sequence.h>
24#include <com/sun/star/text/XTextSection.hpp>
25
26#include <tools/ref.hxx>
27#include <svl/hint.hxx>
28#include <svl/listener.hxx>
29#include <sfx2/lnkbase.hxx>
30#include <sfx2/Metadatable.hxx>
31#include <unotools/weakref.hxx>
32
33#include "frmfmt.hxx"
34#include <vector>
35
36class SwSectionFormat;
37class SwDoc;
38class SwSection;
39class SwSectionNode;
40class SwTOXBase;
41class SwServerObject;
42class SwXTextSection;
43
44typedef std::vector<SwSection*> SwSections;
45
46enum class SectionType { Content,
51 };
52
54{
55 NONE, // Do nothing.
56 Connect, // Connect created link.
57 Update // Connect created link and update it.
58};
59
61{
62private:
64
66 OUString m_sCondition;
68 OUString m_sLinkFilePassword; // Must be changed to Sequence.
69 css::uno::Sequence <sal_Int8> m_Password;
70
72 bool m_bHiddenFlag : 1;
77 bool m_bProtectFlag : 1;
78 // Edit in readonly sections.
80
81 bool m_bHidden : 1;
83 bool m_bConnectFlag : 1; // Connected to server?
84
85public:
86
87 SwSectionData(SectionType const eType, OUString aName);
88 explicit SwSectionData(SwSection const&);
90 SwSectionData & operator=(SwSectionData const&);
91 bool operator==(SwSectionData const&) const;
92
93 const OUString& GetSectionName() const { return m_sSectionName; }
94 void SetSectionName(OUString const& rName){ m_sSectionName = rName; }
95 SectionType GetType() const { return m_eType; }
96 void SetType(SectionType const eNew) { m_eType = eNew; }
97
98 bool IsHidden() const { return m_bHidden; }
99 void SetHidden(bool const bFlag) { m_bHidden = bFlag; }
100
101 bool IsHiddenFlag() const { return m_bHiddenFlag; }
102 SAL_DLLPRIVATE void
103 SetHiddenFlag(bool const bFlag) { m_bHiddenFlag = bFlag; }
104 bool IsProtectFlag() const { return m_bProtectFlag; }
105 SAL_DLLPRIVATE void
106 SetProtectFlag(bool const bFlag) { m_bProtectFlag = bFlag; }
107 bool IsEditInReadonlyFlag() const { return m_bEditInReadonlyFlag; }
108 void SetEditInReadonlyFlag(bool const bFlag)
109 { m_bEditInReadonlyFlag = bFlag; }
110
111 void SetCondHidden(bool const bFlag) { m_bCondHiddenFlag = bFlag; }
112 bool IsCondHidden() const { return m_bCondHiddenFlag; }
113
114 const OUString& GetCondition() const { return m_sCondition; }
115 void SetCondition(OUString const& rNew) { m_sCondition = rNew; }
116
117 const OUString& GetLinkFileName() const { return m_sLinkFileName; }
118 void SetLinkFileName(OUString const& rNew)
119 {
120 m_sLinkFileName = rNew;
121 }
122
123 const OUString& GetLinkFilePassword() const { return m_sLinkFilePassword; }
124 void SetLinkFilePassword(OUString const& rS){ m_sLinkFilePassword = rS; }
125
126 css::uno::Sequence<sal_Int8> const& GetPassword() const
127 { return m_Password; }
128 void SetPassword(css::uno::Sequence<sal_Int8> const& rNew)
129 { m_Password = rNew; }
130 bool IsLinkType() const
132
133 bool IsConnectFlag() const { return m_bConnectFlag; }
134 void SetConnectFlag(bool const bFlag){ m_bConnectFlag = bFlag; }
135
136 void dumpAsXml(xmlTextWriterPtr pWriter) const;
137};
138
140 : public SwClient
141 , public SvtListener // needed for SwClientNotify to be called from SwSectionFormat
142{
143 // In order to correctly maintain the flag when creating/deleting frames.
144 friend class SwSectionNode;
145 // The "read CTOR" of SwSectionFrame have to change the Hiddenflag.
146 friend class SwSectionFrame;
147
148private:
150
153
154 SAL_DLLPRIVATE void ImplSetHiddenFlag(
155 bool const bHidden, bool const bCondition);
156
157protected:
158 virtual void Notify(SfxHint const& rHint) override;
159 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
160
161public:
162
163 SwSection(SectionType const eType, OUString const& rName,
164 SwSectionFormat & rFormat);
165 virtual ~SwSection() override;
166
167 bool DataEquals(SwSectionData const& rCmp) const;
168
169 void SetSectionData(SwSectionData const& rData);
170
171 const OUString& GetSectionName() const { return m_Data.GetSectionName(); }
172 void SetSectionName(OUString const& rName){ m_Data.SetSectionName(rName); }
173 SectionType GetType() const { return m_Data.GetType(); }
174 void SetType(SectionType const eType) { return m_Data.SetType(eType); }
175
176 inline SwSectionFormat* GetFormat();
177 inline SwSectionFormat const * GetFormat() const;
178
179 // Set hidden/protected -> update the whole tree!
180 // (Attributes/flags are set/get.)
181 bool IsHidden() const { return m_Data.IsHidden(); }
182 void SetHidden (bool const bFlag = true);
183 bool IsProtect() const;
184 void SetProtect(bool const bFlag = true);
185 bool IsEditInReadonly() const;
186 void SetEditInReadonly(bool const bFlag = true);
187
188 // Get internal flags (state including parents, not what is
189 // currently set at section!).
190 bool IsHiddenFlag() const { return m_Data.IsHiddenFlag(); }
191 bool IsProtectFlag() const { return m_Data.IsProtectFlag(); }
192 bool IsEditInReadonlyFlag() const { return m_Data.IsEditInReadonlyFlag(); }
193
194 void SetCondHidden(bool const bFlag);
195 bool IsCondHidden() const { return m_Data.IsCondHidden(); }
196 // Query (also for parents) if this section is to be hidden.
197 bool CalcHiddenFlag() const;
198
199 inline SwSection* GetParent() const;
200
201 OUString const & GetCondition() const { return m_Data.GetCondition(); }
202 void SetCondition(OUString const& rNew) { m_Data.SetCondition(rNew); }
203
204 OUString const & GetLinkFileName() const;
205 void SetLinkFileName(OUString const& rNew);
206 // Password of linked file (only valid during runtime!)
207 OUString const & GetLinkFilePassword() const
208 { return m_Data.GetLinkFilePassword(); }
209 void SetLinkFilePassword(OUString const& rS)
210 { m_Data.SetLinkFilePassword(rS); }
211
212 // Get / set password of this section
213 css::uno::Sequence<sal_Int8> const& GetPassword() const
214 { return m_Data.GetPassword(); }
215
216 // Data server methods.
217 void SetRefObject( SwServerObject* pObj );
218 const SwServerObject* GetObject() const { return m_RefObj.get(); }
219 SwServerObject* GetObject() { return m_RefObj.get(); }
220 bool IsServer() const { return m_RefObj.is(); }
221
222 // Methods for linked ranges.
223 SfxLinkUpdateMode GetUpdateType() const { return m_RefLink->GetUpdateMode(); }
225 { m_RefLink->SetUpdateMode(nType); }
226
227 bool IsConnected() const { return m_RefLink.is(); }
228 void UpdateNow() { m_RefLink->Update(); }
229 void Disconnect() { m_RefLink->Disconnect(); }
230
231 const ::sfx2::SvBaseLink& GetBaseLink() const { return *m_RefLink; }
232 ::sfx2::SvBaseLink& GetBaseLink() { return *m_RefLink; }
233
234 void CreateLink( LinkCreateType eType );
235
236 static void MakeChildLinksVisible( const SwSectionNode& rSectNd );
237
238 bool IsLinkType() const { return m_Data.IsLinkType(); }
239
240 // Flags for UI. Did connection work?
241 bool IsConnectFlag() const { return m_Data.IsConnectFlag(); }
242 void SetConnectFlag(bool const bFlag = true)
243 { m_Data.SetConnectFlag(bFlag); }
244
245 // Return the TOX base class if the section is a TOX section
246 const SwTOXBase* GetTOXBase() const;
247
248 void BreakLink();
249
250 void dumpAsXml(xmlTextWriterPtr pWriter) const;
251};
252
253// #i117863#
255{
256 public:
257 SwSectionFrameMoveAndDeleteHint( const bool bSaveContent )
259 , mbSaveContent( bSaveContent )
260 {}
261
262 bool IsSaveContent() const
263 {
264 return mbSaveContent;
265 }
266
267 private:
268 const bool mbSaveContent;
269};
270
271enum class SectionSort { Not, Pos };
272
274 : public SwFrameFormat
275 , public ::sfx2::Metadatable
276{
277 friend class SwDoc;
278
284
285 SAL_DLLPRIVATE void UpdateParent(); // Parent has been changed.
286
287 SwSectionFormat( SwFrameFormat* pDrvdFrame, SwDoc *pDoc );
288 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
289
290public:
291 virtual ~SwSectionFormat() override;
292
293 // Deletes all Frames in aDepend (Frames are recognized via dynamic_cast).
294 virtual void DelFrames() override;
295
296 // Creates views.
297 virtual void MakeFrames() override;
298
299 // Get information from Format.
300 virtual bool GetInfo( SfxPoolItem& ) const override;
301
302 virtual bool IsVisible() const override;
303
304 SwSection* GetSection() const;
305 inline SwSectionFormat* GetParent() const;
306 inline SwSection* GetParentSection() const;
307
308 // All sections that are derived from this one:
309 // - sorted according to name or position or unsorted
310 // - all of them or only those that are in the normal Nodes-array.
311 void GetChildSections( SwSections& rArr,
313 bool bAllSections = true ) const;
314
315 // Query whether section is in Nodes-array or in UndoNodes-array.
316 bool IsInNodesArr() const;
317
318 SwSectionNode* GetSectionNode();
320 { return const_cast<SwSectionFormat *>(this)
321 ->GetSectionNode(); }
322
323 // Is section a valid one for global document?
324 const SwSection* GetGlobalDocSection() const;
325
327 { return m_wXTextSection; }
328 SAL_DLLPRIVATE void SetXTextSection(rtl::Reference<SwXTextSection> const& xTextSection);
329
330 // sfx2::Metadatable
331 virtual ::sfx2::IXmlIdRegistry& GetRegistry() override;
332 virtual bool IsInClipboard() const override;
333 virtual bool IsInUndo() const override;
334 virtual bool IsInContent() const override;
335 virtual css::uno::Reference< css::rdf::XMetadatable > MakeUnoObject() override;
336 virtual bool supportsFullDrawingLayerFillAttributeSet() const override;
337 void dumpAsXml(xmlTextWriterPtr pWriter) const;
338
339};
340
342{
343 return static_cast<SwSectionFormat*>(GetRegisteredIn());
344}
345
347{
348 return static_cast<SwSectionFormat const *>(GetRegisteredIn());
349}
350
352{
353 SwSectionFormat const * pFormat = GetFormat();
354 SwSection* pRet = nullptr;
355 if( pFormat )
356 pRet = pFormat->GetParentSection();
357 return pRet;
358}
359
361{
362 SwSectionFormat* pRet = nullptr;
363 if( GetRegisteredIn() )
364 pRet = const_cast<SwSectionFormat*>(dynamic_cast< const SwSectionFormat* >( GetRegisteredIn() ));
365 return pRet;
366}
367
369{
370 SwSectionFormat* pParent = GetParent();
371 SwSection* pRet = nullptr;
372 if( pParent )
373 {
374 pRet = pParent->GetSection();
375 }
376 return pRet;
377}
378
379#endif /* _ INCLUDED_SW_INC_SECTION_HXX */
380
381/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SwModify * GetRegisteredIn() const
Definition: calbck.hxx:166
Definition: doc.hxx:197
void dumpAsXml(xmlTextWriterPtr=nullptr) const
Dumps the entire nodes structure to the given destination (file nodes.xml in the current directory by...
Definition: docfmt.cxx:1966
Style of a layout element.
Definition: frmfmt.hxx:72
virtual const SwFrameFormat * GetFormat() const
Definition: ssfrm.cxx:401
OUString m_sLinkFileName
Definition: section.hxx:67
bool IsEditInReadonlyFlag() const
Definition: section.hxx:107
bool IsLinkType() const
Definition: section.hxx:130
bool m_bProtectFlag
Flags that correspond to attributes in the format: may have different value than format attribute: fo...
Definition: section.hxx:77
void SetHidden(bool const bFlag)
Definition: section.hxx:99
SAL_DLLPRIVATE void SetProtectFlag(bool const bFlag)
Definition: section.hxx:106
bool m_bHiddenFlag
It seems this flag caches the current final "hidden" state.
Definition: section.hxx:72
void SetEditInReadonlyFlag(bool const bFlag)
Definition: section.hxx:108
void SetConnectFlag(bool const bFlag)
Definition: section.hxx:134
const OUString & GetLinkFilePassword() const
Definition: section.hxx:123
void SetCondHidden(bool const bFlag)
Definition: section.hxx:111
bool IsConnectFlag() const
Definition: section.hxx:133
SectionType m_eType
Definition: section.hxx:63
void SetSectionName(OUString const &rName)
Definition: section.hxx:94
bool IsProtectFlag() const
Definition: section.hxx:104
OUString m_sLinkFilePassword
Definition: section.hxx:68
OUString m_sSectionName
Definition: section.hxx:65
void SetType(SectionType const eNew)
Definition: section.hxx:96
SectionType GetType() const
Definition: section.hxx:95
void SetLinkFilePassword(OUString const &rS)
Definition: section.hxx:124
css::uno::Sequence< sal_Int8 > m_Password
Definition: section.hxx:69
bool m_bCondHiddenFlag
Hide condition evaluated ‘true’.
Definition: section.hxx:82
void SetCondition(OUString const &rNew)
Definition: section.hxx:115
void SetLinkFileName(OUString const &rNew)
Definition: section.hxx:118
bool m_bConnectFlag
Definition: section.hxx:83
SAL_DLLPRIVATE void SetHiddenFlag(bool const bFlag)
Definition: section.hxx:103
bool IsHidden() const
Definition: section.hxx:98
const OUString & GetCondition() const
Definition: section.hxx:114
const OUString & GetLinkFileName() const
Definition: section.hxx:117
OUString m_sCondition
Hide condition.
Definition: section.hxx:66
css::uno::Sequence< sal_Int8 > const & GetPassword() const
Definition: section.hxx:126
void SetPassword(css::uno::Sequence< sal_Int8 > const &rNew)
Definition: section.hxx:128
bool IsCondHidden() const
Definition: section.hxx:112
bool IsHiddenFlag() const
Definition: section.hxx:101
bool m_bEditInReadonlyFlag
Definition: section.hxx:79
const OUString & GetSectionName() const
Definition: section.hxx:93
bool m_bHidden
Section is hidden, unless condition evaluates ‘false’.
Definition: section.hxx:81
SwSection * GetSection() const
Definition: section.cxx:646
unotools::WeakReference< SwXTextSection > m_wXTextSection
Why does this exist in addition to the m_wXObject in SwFrameFormat? in case of an index,...
Definition: section.hxx:283
SwSectionFormat * GetParent() const
Definition: section.hxx:360
const SwSectionNode * GetSectionNode() const
Definition: section.hxx:319
SAL_DLLPRIVATE unotools::WeakReference< SwXTextSection > const & GetXTextSection() const
Definition: section.hxx:326
SwSection * GetParentSection() const
Definition: section.hxx:368
SwSectionFrameMoveAndDeleteHint(const bool bSaveContent)
Definition: section.hxx:257
virtual void dumpAsXml(xmlTextWriterPtr writer=nullptr) const override
Definition: sectfrm.cxx:2959
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: sectfrm.cxx:2603
A section node represents the start of a section on the UI, i.e.
Definition: node.hxx:575
tools::SvRef< SwServerObject > m_RefObj
Definition: section.hxx:151
OUString const & GetCondition() const
Definition: section.hxx:201
void Disconnect()
Definition: section.hxx:229
void UpdateNow()
Definition: section.hxx:228
void SetUpdateType(SfxLinkUpdateMode nType)
Definition: section.hxx:224
bool IsProtectFlag() const
Definition: section.hxx:191
css::uno::Sequence< sal_Int8 > const & GetPassword() const
Definition: section.hxx:213
SwServerObject * GetObject()
Definition: section.hxx:219
bool IsHiddenFlag() const
Definition: section.hxx:190
bool IsHidden() const
Definition: section.hxx:181
SwSection * GetParent() const
Definition: section.hxx:351
SwSectionData m_Data
Definition: section.hxx:149
const OUString & GetSectionName() const
Definition: section.hxx:171
SwSectionFormat * GetFormat()
Definition: section.hxx:341
tools::SvRef< sfx2::SvBaseLink > m_RefLink
Definition: section.hxx:152
void SetType(SectionType const eType)
Definition: section.hxx:174
void SetLinkFilePassword(OUString const &rS)
Definition: section.hxx:209
const SwServerObject * GetObject() const
Definition: section.hxx:218
const ::sfx2::SvBaseLink & GetBaseLink() const
Definition: section.hxx:231
bool IsLinkType() const
Definition: section.hxx:238
OUString const & GetLinkFilePassword() const
Definition: section.hxx:207
SectionType GetType() const
Definition: section.hxx:173
::sfx2::SvBaseLink & GetBaseLink()
Definition: section.hxx:232
SfxLinkUpdateMode GetUpdateType() const
Definition: section.hxx:223
bool IsConnectFlag() const
Definition: section.hxx:241
bool IsCondHidden() const
Definition: section.hxx:195
bool IsConnected() const
Definition: section.hxx:227
void SetCondition(OUString const &rNew)
Definition: section.hxx:202
bool IsEditInReadonlyFlag() const
Definition: section.hxx:192
void SetConnectFlag(bool const bFlag=true)
Definition: section.hxx:242
bool IsServer() const
Definition: section.hxx:220
void SetSectionName(OUString const &rName)
Definition: section.hxx:172
T * get() const
bool is() const
struct _xmlTextWriter * xmlTextWriterPtr
const EnumerationType m_eType
DocumentType eType
void MakeFrames(SwDoc *pDoc, SwNode &rSttIdx, SwNode &rEndIdx)
Definition: frmtool.cxx:2026
void Notify(SwFlyFrame *pFly, SwPageFrame *pOld, const SwRect &rOld, const SwRect *pOldRect=nullptr)
Notify the background based on the difference between old and new rectangle.
Definition: frmtool.cxx:3254
SfxHintId
@ SwSectionFrameMoveAndDelete
SfxLinkUpdateMode
NONE
QPRO_FUNC_TYPE nType
SectionType
Definition: section.hxx:46
SectionSort
Definition: section.hxx:271
LinkCreateType
Definition: section.hxx:54
std::vector< SwSection * > SwSections
Definition: section.hxx:42
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
bool operator==(const XclFontData &rLeft, const XclFontData &rRight)