LibreOffice Module sw (master) 1
modeltoviewhelper.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_MODELTOVIEWHELPER_HXX
21#define INCLUDED_SW_INC_MODELTOVIEWHELPER_HXX
22
23#include <rtl/ustring.hxx>
24#include <sal/types.h>
26#include <vector>
27
28class SwTextNode;
29class SwRootFrame;
30
66enum class ExpandMode
67{
68 PassThrough = 0x0000,
69 ExpandFields = 0x0001,
70 ExpandFootnote = 0x0002,
71 HideInvisible = 0x0004,
72 HideDeletions = 0x0008,
74 ReplaceMode = 0x0010,
75 HideFieldmarkCommands = 0x0020,
76};
77
78namespace o3tl
79{
80 template<> struct typed_flags<ExpandMode> : is_typed_flags<ExpandMode, 0x003f> {};
81}
82
84{
92 {
93 ConversionMapEntry(sal_Int32 nModelPos, sal_Int32 nViewPos, bool bVisible)
94 : m_nModelPos(nModelPos)
95 , m_nViewPos(nViewPos)
97 {
98 }
99 sal_Int32 m_nModelPos;
100 sal_Int32 m_nViewPos;
102 };
103 typedef std::vector< ConversionMapEntry > ConversionMap;
104
107 std::vector<sal_Int32> m_FieldPositions;
108 std::vector<sal_Int32> m_FootnotePositions;
109
110 OUString m_aRetText;
111
112public:
113
121 {
122 sal_Int32 mnPos;
123 sal_Int32 mnSubPos;
125
126 ModelPosition() : mnPos(0), mnSubPos(0), mbIsField(false) {}
127 };
128
129 ModelToViewHelper(const SwTextNode &rNode, SwRootFrame const* pLayout,
130 // defaults are appropriate for spell/grammar checking
132 ModelToViewHelper() //pass through filter, view == model
133 {
134 }
135
149 sal_Int32 ConvertToViewPosition( sal_Int32 nModelPos ) const;
150
164 ModelPosition ConvertToModelPosition( sal_Int32 nViewPos ) const;
165
166 const OUString& getViewText() const { return m_aRetText; }
167 std::vector<sal_Int32> const& getFieldPositions() const { return m_FieldPositions; }
168 std::vector<sal_Int32> const& getFootnotePositions() const { return m_FootnotePositions;}
169};
170
171#endif
172
173/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ModelPosition ConvertToModelPosition(sal_Int32 nViewPos) const
Converts a view position into a model position.
std::vector< sal_Int32 > m_FieldPositions
store positions of fields and footnotes for grammar checkers
const OUString & getViewText() const
std::vector< sal_Int32 > const & getFootnotePositions() const
sal_Int32 ConvertToViewPosition(sal_Int32 nModelPos) const
Converts a model position into a view position.
std::vector< sal_Int32 > const & getFieldPositions() const
std::vector< ConversionMapEntry > ConversionMap
std::vector< sal_Int32 > m_FootnotePositions
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:111
ExpandMode
Some helpers for converting model strings to view strings.
@ ReplaceMode
do not expand to content, but replace with zwsp
@ HideFieldmarkCommands
For each expanded/hidden portion in the model string, there is an entry in the conversion map.
ConversionMapEntry(sal_Int32 nModelPos, sal_Int32 nViewPos, bool bVisible)
This struct defines a position in the model string.
bool bVisible