LibreOffice Module sw (master)
1
sw
inc
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
HideFieldmarkCommands
= 0x0020,
76
};
77
78
namespace
o3tl
79
{
80
template
<>
struct
typed_flags
<
ExpandMode
> :
is_typed_flags
<ExpandMode, 0x003f> {};
81
}
82
83
class
ModelToViewHelper
84
{
91
struct
ConversionMapEntry
92
{
93
ConversionMapEntry
(sal_Int32 nModelPos, sal_Int32 nViewPos,
bool
bVisible)
94
:
m_nModelPos
(nModelPos)
95
,
m_nViewPos
(nViewPos)
96
,
m_bVisible
(
bVisible
)
97
{
98
}
99
sal_Int32
m_nModelPos
;
100
sal_Int32
m_nViewPos
;
101
bool
m_bVisible
;
102
};
103
typedef
std::vector< ConversionMapEntry >
ConversionMap
;
104
105
ConversionMap
m_aMap
;
107
std::vector<sal_Int32>
m_FieldPositions
;
108
std::vector<sal_Int32>
m_FootnotePositions
;
109
110
OUString
m_aRetText
;
111
112
public
:
113
120
struct
ModelPosition
121
{
122
sal_Int32
mnPos
;
123
sal_Int32
mnSubPos
;
124
bool
mbIsField
;
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
131
ExpandMode
eMode =
ExpandMode::ExpandFields
|
ExpandMode::ExpandFootnote
|
ExpandMode::HideFieldmarkCommands
|
ExpandMode::ReplaceMode
);
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: */
ModelToViewHelper
Definition:
modeltoviewhelper.hxx:84
ModelToViewHelper::ConvertToModelPosition
ModelPosition ConvertToModelPosition(sal_Int32 nViewPos) const
Converts a view position into a model position.
Definition:
modeltoviewhelper.cxx:422
ModelToViewHelper::m_FieldPositions
std::vector< sal_Int32 > m_FieldPositions
store positions of fields and footnotes for grammar checkers
Definition:
modeltoviewhelper.hxx:107
ModelToViewHelper::getViewText
const OUString & getViewText() const
Definition:
modeltoviewhelper.hxx:166
ModelToViewHelper::m_aMap
ConversionMap m_aMap
Definition:
modeltoviewhelper.hxx:105
ModelToViewHelper::ModelToViewHelper
ModelToViewHelper()
Definition:
modeltoviewhelper.hxx:132
ModelToViewHelper::getFootnotePositions
std::vector< sal_Int32 > const & getFootnotePositions() const
Definition:
modeltoviewhelper.hxx:168
ModelToViewHelper::m_aRetText
OUString m_aRetText
Definition:
modeltoviewhelper.hxx:110
ModelToViewHelper::ConvertToViewPosition
sal_Int32 ConvertToViewPosition(sal_Int32 nModelPos) const
Converts a model position into a view position.
Definition:
modeltoviewhelper.cxx:398
ModelToViewHelper::getFieldPositions
std::vector< sal_Int32 > const & getFieldPositions() const
Definition:
modeltoviewhelper.hxx:167
ModelToViewHelper::ConversionMap
std::vector< ConversionMapEntry > ConversionMap
Definition:
modeltoviewhelper.hxx:103
ModelToViewHelper::m_FootnotePositions
std::vector< sal_Int32 > m_FootnotePositions
Definition:
modeltoviewhelper.hxx:108
SwRootFrame
The root element of a Writer document layout.
Definition:
rootfrm.hxx:85
SwTextNode
SwTextNode is a paragraph in the document model.
Definition:
ndtxt.hxx:112
ExpandMode
ExpandMode
Some helpers for converting model strings to view strings.
Definition:
modeltoviewhelper.hxx:67
ExpandMode::HideDeletions
@ HideDeletions
ExpandMode::ReplaceMode
@ ReplaceMode
do not expand to content, but replace with zwsp
ExpandMode::HideFieldmarkCommands
@ HideFieldmarkCommands
ExpandMode::HideInvisible
@ HideInvisible
ExpandMode::ExpandFootnote
@ ExpandFootnote
ExpandMode::ExpandFields
@ ExpandFields
ExpandMode::PassThrough
@ PassThrough
o3tl
ModelToViewHelper::ConversionMapEntry
For each expanded/hidden portion in the model string, there is an entry in the conversion map.
Definition:
modeltoviewhelper.hxx:92
ModelToViewHelper::ConversionMapEntry::m_bVisible
bool m_bVisible
Definition:
modeltoviewhelper.hxx:101
ModelToViewHelper::ConversionMapEntry::m_nModelPos
sal_Int32 m_nModelPos
Definition:
modeltoviewhelper.hxx:99
ModelToViewHelper::ConversionMapEntry::m_nViewPos
sal_Int32 m_nViewPos
Definition:
modeltoviewhelper.hxx:100
ModelToViewHelper::ConversionMapEntry::ConversionMapEntry
ConversionMapEntry(sal_Int32 nModelPos, sal_Int32 nViewPos, bool bVisible)
Definition:
modeltoviewhelper.hxx:93
ModelToViewHelper::ModelPosition
This struct defines a position in the model string.
Definition:
modeltoviewhelper.hxx:121
ModelToViewHelper::ModelPosition::mnSubPos
sal_Int32 mnSubPos
Definition:
modeltoviewhelper.hxx:123
ModelToViewHelper::ModelPosition::mnPos
sal_Int32 mnPos
Definition:
modeltoviewhelper.hxx:122
ModelToViewHelper::ModelPosition::ModelPosition
ModelPosition()
Definition:
modeltoviewhelper.hxx:126
ModelToViewHelper::ModelPosition::mbIsField
bool mbIsField
Definition:
modeltoviewhelper.hxx:124
o3tl::is_typed_flags
o3tl::typed_flags
bVisible
bool bVisible
typed_flags_set.hxx
types.h
Generated on Sun Jul 30 2023 04:28:01 for LibreOffice Module sw (master) by
1.9.3