summaryrefslogtreecommitdiff
path: root/sw/inc/formatlinebreak.hxx
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/formatlinebreak.hxx
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/formatlinebreak.hxx')
-rw-r--r--sw/inc/formatlinebreak.hxx96
1 files changed, 96 insertions, 0 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: */