summaryrefslogtreecommitdiff
path: root/sw/inc
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-02-28 10:59:49 +0100
committerMiklos Vajna <vmiklos@collabora.com>2022-03-25 13:41:45 +0100
commit864e9258ce61842091d7b37ee0a7b1d54b906289 (patch)
tree61cd8827ac272bff032a14a54f25d4db4b1a3e07 /sw/inc
parent4d2d9cf9c3165e2460466cc75e5a8453346610c8 (diff)
sw clearing breaks: add document model
This is meant to represent clearing breaks, as in HTML's <br clear="..."> and DOCX's <w:br w:type="textWrapping" w:clear="...">. The new pool item is in the RES_TXTATR_NOEND section as this property can be only specified on a single document model position: linebreak characters. (cherry picked from commit 24732bb12bfe0124d49733701226a34044c001a8) Change-Id: I6c86097a049e489e1292f42fc8446eb7282c816a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132105 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/inc')
-rw-r--r--sw/inc/formatlinebreak.hxx96
-rw-r--r--sw/inc/hintids.hxx3
-rw-r--r--sw/inc/textlinebreak.hxx45
-rw-r--r--sw/inc/txatbase.hxx8
4 files changed, 151 insertions, 1 deletions
diff --git a/sw/inc/formatlinebreak.hxx b/sw/inc/formatlinebreak.hxx
new file mode 100644
index 000000000000..9e26ab11351f
--- /dev/null
+++ b/sw/inc/formatlinebreak.hxx
@@ -0,0 +1,96 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_INC_FORMATLINEBREAK_HXX
+#define INCLUDED_SW_INC_FORMATLINEBREAK_HXX
+
+#include "swdllapi.h"
+#include <svl/eitem.hxx>
+#include "calbck.hxx"
+
+#include <rtl/ustring.hxx>
+#include <cppuhelper/weakref.hxx>
+#include <com/sun/star/text/XTextContent.hpp>
+
+class SwDoc;
+class SwTextLineBreak;
+
+/// Defines the location of a line break text wrapping restart.
+enum class SwLineBreakClear
+{
+ NONE,
+ LEFT,
+ RIGHT,
+ ALL,
+ LAST = ALL
+};
+
+/// SfxPoolItem subclass that wraps an SwLineBreakClear.
+class SW_DLLPUBLIC SwFormatLineBreak final : public SfxEnumItem<SwLineBreakClear>,
+ public sw::BroadcastingModify
+{
+ /// The SwTextAttr that knows the position of the line break in the doc model.
+ SwTextLineBreak* m_pTextAttr;
+
+ css::uno::WeakReference<css::text::XTextContent> m_wXLineBreak;
+
+ SwFormatLineBreak& operator=(const SwFormatLineBreak& rLineBreak) = delete;
+
+ SwFormatLineBreak(const SwFormatLineBreak&) = delete;
+
+public:
+ SwFormatLineBreak(SwLineBreakClear eClear);
+ virtual ~SwFormatLineBreak() override;
+
+ /// See SfxPoolItem::operator ==().
+ bool operator==(const SfxPoolItem&) const override;
+
+ /// See SfxPoolItem::Clone().
+ SwFormatLineBreak* Clone(SfxItemPool* pPool = nullptr) const override;
+
+ /// See SwModify::SwClientNotify().
+ void SwClientNotify(const SwModify&, const SfxHint&) override;
+
+ sal_uInt16 GetValueCount() const override;
+
+ void InvalidateLineBreak();
+
+ css::uno::Reference<css::text::XTextRange> getAnchor(SwDoc& rDoc) const;
+
+ void SetTextLineBreak(SwTextLineBreak* pTextAttr) { m_pTextAttr = pTextAttr; }
+
+ const SwTextLineBreak* GetTextLineBreak() const { return m_pTextAttr; }
+
+ SwTextLineBreak* GetTextLineBreak() { return m_pTextAttr; }
+
+ css::uno::WeakReference<css::text::XTextContent> const& GetXTextContent() const
+ {
+ return m_wXLineBreak;
+ }
+
+ void SetXLineBreak(css::uno::Reference<css::text::XTextContent> const& xLineBreak)
+ {
+ m_wXLineBreak = xLineBreak;
+ }
+
+ void dumpAsXml(xmlTextWriterPtr pWriter) const override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx
index 1642c094ca27..f446d6ab306b 100644
--- a/sw/inc/hintids.hxx
+++ b/sw/inc/hintids.hxx
@@ -150,6 +150,7 @@ class SwDrawFrameFormat;
class SwFlyFrameFormat;
class SwFormatField;
class SwFormatFootnote;
+class SwFormatLineBreak;
class SwFormatRefMark;
class SwGrfFormatColl;
class SwTextFormatColl;
@@ -282,7 +283,7 @@ constexpr TypedWhichId<SwFormatField> RES_TXTATR_FIELD(RES_TXTATR_NOEND_BEGIN);
constexpr TypedWhichId<SwFormatFlyCnt> RES_TXTATR_FLYCNT(57);
constexpr TypedWhichId<SwFormatFootnote> RES_TXTATR_FTN(58);
constexpr TypedWhichId<SwFormatField> RES_TXTATR_ANNOTATION(59);
-constexpr TypedWhichId<SfxBoolItem> RES_TXTATR_DUMMY3(60);
+constexpr TypedWhichId<SwFormatLineBreak> RES_TXTATR_LINEBREAK(60);
constexpr TypedWhichId<SfxBoolItem> RES_TXTATR_DUMMY1(61);
constexpr TypedWhichId<SfxBoolItem> RES_TXTATR_DUMMY2(62);
constexpr sal_uInt16 RES_TXTATR_NOEND_END(63);
diff --git a/sw/inc/textlinebreak.hxx b/sw/inc/textlinebreak.hxx
new file mode 100644
index 000000000000..c0853aa2bd56
--- /dev/null
+++ b/sw/inc/textlinebreak.hxx
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_INC_TEXTLINEBREAK_HXX
+#define INCLUDED_SW_INC_TEXTLINEBREAK_HXX
+
+#include "txatbase.hxx"
+
+#include "ndindex.hxx"
+
+class SwFormatLineBreak;
+
+/**
+ * SwTextAttr subclass that tracks the location of the wrapped SwFormatLineBreak.
+ *
+ * This text attribute doesn't have an end: it's specified on a new line character of an SwTextNode.
+ */
+class SW_DLLPUBLIC SwTextLineBreak final : public SwTextAttr
+{
+public:
+ SwTextLineBreak(SwFormatLineBreak& rAttr, sal_Int32 nStart);
+
+ ~SwTextLineBreak() override;
+
+ void dumpAsXml(xmlTextWriterPtr pWriter) const override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/inc/txatbase.hxx b/sw/inc/txatbase.hxx
index 8018712eaa23..110e12064c9c 100644
--- a/sw/inc/txatbase.hxx
+++ b/sw/inc/txatbase.hxx
@@ -28,6 +28,7 @@
#include "fmtfld.hxx"
#include "fmtflcnt.hxx"
#include "fmtftn.hxx"
+#include "formatlinebreak.hxx"
#include "fchrfmt.hxx"
#include "tox.hxx"
#include "ndhints.hxx"
@@ -119,6 +120,7 @@ public:
inline const SwFormatAutoFormat &GetAutoFormat() const;
inline const SwFormatField &GetFormatField() const;
inline const SwFormatFootnote &GetFootnote() const;
+ inline const SwFormatLineBreak& GetLineBreak() const;
inline const SwFormatFlyCnt &GetFlyCnt() const;
inline const SwTOXMark &GetTOXMark() const;
inline const SwFormatRefMark &GetRefMark() const;
@@ -207,6 +209,12 @@ inline const SwFormatFootnote& SwTextAttr::GetFootnote() const
return static_cast<const SwFormatFootnote&>(*m_pAttr);
}
+inline const SwFormatLineBreak& SwTextAttr::GetLineBreak() const
+{
+ assert(m_pAttr && m_pAttr->Which() == RES_TXTATR_LINEBREAK);
+ return static_cast<const SwFormatLineBreak&>(*m_pAttr);
+}
+
inline const SwFormatFlyCnt& SwTextAttr::GetFlyCnt() const
{
assert( m_pAttr && m_pAttr->Which() == RES_TXTATR_FLYCNT );