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