summaryrefslogtreecommitdiffstats
path: root/sw/source/core/inc/SwPortionHandler.hxx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:54:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:54:39 +0000
commit267c6f2ac71f92999e969232431ba04678e7437e (patch)
tree358c9467650e1d0a1d7227a21dac2e3d08b622b2 /sw/source/core/inc/SwPortionHandler.hxx
parentInitial commit. (diff)
downloadlibreoffice-267c6f2ac71f92999e969232431ba04678e7437e.tar.xz
libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.zip
Adding upstream version 4:24.2.0.upstream/4%24.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sw/source/core/inc/SwPortionHandler.hxx')
-rw-r--r--sw/source/core/inc/SwPortionHandler.hxx98
1 files changed, 98 insertions, 0 deletions
diff --git a/sw/source/core/inc/SwPortionHandler.hxx b/sw/source/core/inc/SwPortionHandler.hxx
new file mode 100644
index 0000000000..29625efbca
--- /dev/null
+++ b/sw/source/core/inc/SwPortionHandler.hxx
@@ -0,0 +1,98 @@
+/* -*- 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_SOURCE_CORE_INC_SWPORTIONHANDLER_HXX
+#define INCLUDED_SW_SOURCE_CORE_INC_SWPORTIONHANDLER_HXX
+
+#include <swdllapi.h>
+#include <rtl/ustring.hxx>
+#include "TextFrameIndex.hxx"
+
+class SwFont;
+enum class PortionType;
+
+/** The SwPortionHandler interface implements a visitor for the layout
+ * engine's text portions. This can be used to gather information of
+ * the on-screen representation of a single paragraph.
+ *
+ * For each text portion, one of the methods text(...) or special(...)
+ * is called, depending on whether it is a 'normal' run of text, or
+ * any other portion. Additionally, the linebreak() method is called
+ * once at the end of every on-screen line.
+ *
+ * All parameters relate to the 'view string', which is the text string
+ * held by the sequence of all corresponding SwTextFrames.
+ *
+ * The SwPortionHandler can be used with the
+ * SwTextFrame::VisitPortions(...) method.
+ */
+class SW_DLLPUBLIC SwPortionHandler
+{
+public:
+
+ virtual ~SwPortionHandler() {} /// (empty) destructor
+
+ /** text portion. A run of nLength characters from the view
+ * string, that contains no special characters like embedded
+ * fields, etc. Thus, the on-screen text of this portion
+ * corresponds exactly to the corresponding characters in the
+ * view string.
+ */
+ virtual void Text(
+ TextFrameIndex nLength, ///< length of this portion in the view string
+ PortionType nType /// type of this portion
+ ) = 0;
+
+ /** special portion. This method is called for every non-text
+ * portion. The parameters describe the length of the
+ * corresponding characters in the view string (often 0 or 1),
+ * the text which is displayed, and the type of the portion.
+ */
+ virtual void Special(
+ TextFrameIndex nLength, ///< length of this portion in the view string
+ const OUString& rText, /// text which is painted on-screen
+ PortionType nType /// type of this portion
+ ) = 0;
+
+ /** line break. This method is called whenever a line break in the
+ * layout occurs.
+ */
+ virtual void LineBreak() = 0;
+
+ /** skip characters. The SwTextFrame may only display partially
+ * display a certain paragraph (e.g. when the paragraph is split
+ * across multiple pages). In this case, the Skip() method must be
+ * called to inform the portion handler to ignore a certain run of
+ * characters in the 'view string'. Skip(), if used at all, must
+ * be called before any of the other methods is called. Calling
+ * Skip() between portions is not allowed.
+ */
+ virtual void Skip(
+ TextFrameIndex nLength /// number of 'view string' characters to be skipped
+ ) = 0;
+
+ /** end of paragraph. This method is to be called when all the
+ * paragraph's portions have been processed.
+ */
+ virtual void Finish() = 0;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */