LibreOffice Module sw (master) 1
accportions.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_SOURCE_CORE_ACCESS_ACCPORTIONS_HXX
21#define INCLUDED_SW_SOURCE_CORE_ACCESS_ACCPORTIONS_HXX
22
23#include <SwPortionHandler.hxx>
24#include <sal/types.h>
25#include <rtl/ustrbuf.hxx>
26#include <memory>
27#include <vector>
28
29class SwTextFrame;
30struct SwSpecialPos;
31class SwViewOption;
32namespace com::sun::star {
33 namespace i18n { struct Boundary; }
34}
35
40{
41 // the frame this portion is referring to
43
44 // variables used while collecting the data
45 OUStringBuffer m_aBuffer;
48
54
55 // positions array
56 // instances of Position_t must always include the minimum and
57 // maximum positions as first/last elements (to simplify the
58 // algorithms)
59 typedef std::vector<sal_Int32> AccessiblePositions;
60 typedef std::vector<TextFrameIndex> FramePositions;
61
66
67 std::vector<sal_uInt8> m_aPortionAttrs;
68
69 std::unique_ptr<AccessiblePositions> m_pSentences;
70
73
75 static void FillBoundary(css::i18n::Boundary& rBound,
76 const AccessiblePositions& rPositions,
77 size_t nPos );
78
80 bool IsPortionAttrSet( size_t nPortionNo, sal_uInt8 nAttr ) const;
81 bool IsSpecialPortion( size_t nPortionNo ) const;
82 bool IsGrayPortionType( PortionType nType ) const;
83
84 // helper method for GetEditableRange(...):
85 void AdjustAndCheck( sal_Int32 nPos, size_t& nPortionNo,
86 TextFrameIndex& rCorePos, bool& bEdit) const;
87
88public:
89 SwAccessiblePortionData( const SwTextFrame* pTextFrame,
90 const SwViewOption* pViewOpt );
91 virtual ~SwAccessiblePortionData() override;
92
93 // SwPortionHandler methods
94 virtual void Text(TextFrameIndex nLength, PortionType nType) override;
95 virtual void Special(TextFrameIndex nLength, const OUString& rText, PortionType nType) override;
96 virtual void LineBreak() override;
97 virtual void Skip(TextFrameIndex nLength) override;
98 virtual void Finish() override;
99
100 bool FillBoundaryIFDateField( css::i18n::Boundary& rBound, const sal_Int32 nPos );
101 bool IsIndexInFootnode(sal_Int32 nIndex);
102 bool IsInGrayPortion( sal_Int32 nPos );
103 sal_Int32 GetFieldIndex(sal_Int32 nPos) const;
104
106
107 // access to the portion data
108
110 const OUString& GetAccessibleString() const;
111
113 void GetLineBoundary( css::i18n::Boundary& rBound,
114 sal_Int32 nPos ) const;
115
116 // get start and end position of the last line
117 void GetLastLineBoundary( css::i18n::Boundary& rBound ) const;
118
124 bool IsValidCorePosition(TextFrameIndex nPos) const;
127
129 sal_Int32 GetAccessiblePosition(TextFrameIndex nPos) const;
130
131 // #i89175#
132 sal_Int32 GetLineCount() const;
133 sal_Int32 GetLineNo( const sal_Int32 nPos ) const;
134 void GetBoundaryOfLine( const sal_Int32 nLineNo,
135 css::i18n::Boundary& rLineBound );
136
139 TextFrameIndex GetCoreViewPosition(sal_Int32 nPos) const;
140
145 TextFrameIndex FillSpecialPos(sal_Int32 nPos,
146 SwSpecialPos& rPos,
147 SwSpecialPos*& rpPos ) const;
148
149 // get boundaries of words/sentences. The data structures are
150 // created on-demand.
151 void GetSentenceBoundary( css::i18n::Boundary& rBound,
152 sal_Int32 nPos );
153
154 // get (a) boundary for attribute change
155 void GetAttributeBoundary( css::i18n::Boundary& rBound,
156 sal_Int32 nPos ) const;
157
162 bool GetEditableRange( sal_Int32 nStart, sal_Int32 nEnd,
163 TextFrameIndex& rCoreStart, TextFrameIndex& rCoreEnd) const;
164
165private:
166 std::vector< std::pair<sal_Int32,sal_Int32> > m_vecPairPos;
167};
168
169#endif
170
171/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
collect text portion data from the layout through SwPortionHandler interface
Definition: accportions.hxx:40
virtual void Text(TextFrameIndex nLength, PortionType nType) override
(empty) destructor
Definition: accportions.cxx:86
void GetBoundaryOfLine(const sal_Int32 nLineNo, css::i18n::Boundary &rLineBound)
bool FillBoundaryIFDateField(css::i18n::Boundary &rBound, const sal_Int32 nPos)
bool IsIndexInFootnode(sal_Int32 nIndex)
bool IsGrayPortionType(PortionType nType) const
AccessiblePositions m_aAccessiblePositions
position of portion breaks in the core view
Definition: accportions.hxx:64
sal_Int32 GetFieldIndex(sal_Int32 nPos) const
std::unique_ptr< AccessiblePositions > m_pSentences
additional portion attributes
Definition: accportions.hxx:69
void GetSentenceBoundary(css::i18n::Boundary &rBound, sal_Int32 nPos)
AccessiblePositions m_aLineBreaks
Definition: accportions.hxx:62
static void FillBoundary(css::i18n::Boundary &rBound, const AccessiblePositions &rPositions, size_t nPos)
fill the boundary with the values from rPositions[nPos]
void GetAttributeBoundary(css::i18n::Boundary &rBound, sal_Int32 nPos) const
bool IsInGrayPortion(sal_Int32 nPos)
bool GetEditableRange(sal_Int32 nStart, sal_Int32 nEnd, TextFrameIndex &rCoreStart, TextFrameIndex &rCoreEnd) const
Convert start and end positions into core positions.
TextFrameIndex GetCoreViewPosition(sal_Int32 nPos) const
get the position in the core view string for a given (accessibility) position
AccessiblePositions m_aFieldPosition
portion breaks in m_sAccessibleString
Definition: accportions.hxx:65
void GetLineBoundary(css::i18n::Boundary &rBound, sal_Int32 nPos) const
get the start & end positions of the sentence
bool IsSpecialPortion(size_t nPortionNo) const
std::vector< sal_Int32 > AccessiblePositions
Definition: accportions.hxx:59
void GetLastLineBoundary(css::i18n::Boundary &rBound) const
const OUString & GetAccessibleString() const
get the text string, as presented by the layout
std::vector< std::pair< sal_Int32, sal_Int32 > > m_vecPairPos
FramePositions m_ViewPositions
position of line breaks
Definition: accportions.hxx:63
virtual void Finish() override
end of paragraph.
std::vector< sal_uInt8 > m_aPortionAttrs
Definition: accportions.hxx:67
sal_Int32 GetLineCount() const
virtual void Skip(TextFrameIndex nLength) override
skip characters.
sal_Int32 GetAccessiblePosition(TextFrameIndex nPos) const
get the position in the accessibility string for a given view position
OUStringBuffer m_aBuffer
Definition: accportions.hxx:45
TextFrameIndex m_nViewPosition
Definition: accportions.hxx:46
TextFrameIndex FillSpecialPos(sal_Int32 nPos, SwSpecialPos &rPos, SwSpecialPos *&rpPos) const
fill a SwSpecialPos structure, suitable for calling SwTextFrame->GetCharRect Returns the core positio...
TextFrameIndex GetLastValidCorePosition() const
virtual void LineBreak() override
line break.
OUString m_sAccessibleString
the accessible string note that the content is different both from the string in the text node(s) as ...
Definition: accportions.hxx:53
size_t m_nBeforePortions
positions of sentence breaks
Definition: accportions.hxx:71
const SwViewOption * m_pViewOptions
Definition: accportions.hxx:47
SwAccessiblePortionData(const SwTextFrame *pTextFrame, const SwViewOption *pViewOpt)
Definition: accportions.cxx:62
bool IsPortionAttrSet(size_t nPortionNo, sal_uInt8 nAttr) const
Access to portion attributes.
std::vector< TextFrameIndex > FramePositions
Definition: accportions.hxx:60
bool IsValidCorePosition(TextFrameIndex nPos) const
Determine whether this core position is valid for these portions.
TextFrameIndex GetFirstValidCorePosition() const
sal_Int32 GetLineNo(const sal_Int32 nPos) const
void AdjustAndCheck(sal_Int32 nPos, size_t &nPortionNo, TextFrameIndex &rCorePos, bool &bEdit) const
virtual ~SwAccessiblePortionData() override
Definition: accportions.cxx:82
SwTextFrame const * m_pTextFrame
Definition: accportions.hxx:42
virtual void Special(TextFrameIndex nLength, const OUString &rText, PortionType nType) override
special portion.
The SwPortionHandler interface implements a visitor for the layout engine's text portions.
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:168
PortionType
Definition: txttypes.hxx:24
unsigned char sal_uInt8