|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 #include <frmtlay.h> |
|
18 #include <frmtview.h> |
|
19 #include <tagma.h> |
|
20 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
21 #include <tagmaLayoutAndSource.h> |
|
22 #endif |
|
23 |
|
24 #include "FromCursorModifierUtils.h" |
|
25 |
|
26 TFormCursorModifierUtils::~TFormCursorModifierUtils() |
|
27 { |
|
28 } |
|
29 |
|
30 TFormCursorModifierUtils::TFormCursorModifierUtils(CTextView& aTextView, CTextLayout& aTextLayout) : |
|
31 iTextView(aTextView), |
|
32 iTextLayout(aTextLayout) |
|
33 { |
|
34 } |
|
35 |
|
36 TTmDocPosSpec TFormCursorModifierUtils::DocPos() const |
|
37 { |
|
38 TTmDocPosSpec docPos = TTmDocPosSpec(); |
|
39 TTmDocPos rawDocPos; |
|
40 iTextView.GetCursorPos(rawDocPos); |
|
41 docPos.iPos = rawDocPos.iPos; |
|
42 TTmDocPosSpec::TType docPosType = rawDocPos.iLeadingEdge ? TTmDocPosSpec::ELeading : TTmDocPosSpec::ETrailing; |
|
43 docPos.iType = docPosType; |
|
44 return docPos; |
|
45 } |
|
46 |
|
47 void TFormCursorModifierUtils::SetDocPosL(const TTmDocPosSpec& aDocPos) |
|
48 { |
|
49 iTextView.SetDocPosL(aDocPos); |
|
50 } |
|
51 |
|
52 TBool TFormCursorModifierUtils::IsRightToLeftParagraph(TTmDocPosSpec aPos) |
|
53 { |
|
54 TTmPosInfo2 posInfo; |
|
55 TTmLineInfo lineInfo; |
|
56 iTextLayout.TagmaTextLayout().FindDocPos(aPos, posInfo, lineInfo); |
|
57 return lineInfo.iFlags & TTmLineInfo::EParRightToLeft; |
|
58 } |
|
59 |
|
60 TBool TFormCursorModifierUtils::VisualCursorBetweenOpposingChunks() |
|
61 { |
|
62 TTmDocPosSpec pos = DocPos(); |
|
63 CTmTextLayout::TTmChunkDescription leftChunk; |
|
64 CTmTextLayout::TTmChunkDescription rightChunk; |
|
65 iTextLayout.TagmaTextLayout().FindAdjacentChunks(pos, leftChunk, rightChunk); |
|
66 |
|
67 if (leftChunk.iRightToLeft != rightChunk.iRightToLeft) |
|
68 return ETrue; |
|
69 return EFalse; |
|
70 } |
|
71 |
|
72 |
|
73 void TFormCursorModifierUtils::ToggleVisualDocPosL() |
|
74 { |
|
75 TTmDocPosSpec pos = DocPos(); |
|
76 pos.iType = (pos.iType == TTmDocPosSpec::ETrailing) ? TTmDocPosSpec::ELeading : TTmDocPosSpec::ETrailing; |
|
77 SetDocPosL(pos); |
|
78 } |
|
79 |
|
80 |
|
81 void TFormCursorModifierUtils::ToggleLogicalDocPosL() |
|
82 { |
|
83 TTmDocPosSpec pos = DocPos(); |
|
84 CTmTextLayout::TTmChunkDescription leftChunk; |
|
85 CTmTextLayout::TTmChunkDescription rightChunk; |
|
86 iTextLayout.TagmaTextLayout().FindAdjacentChunks(pos, leftChunk, rightChunk); |
|
87 |
|
88 TBool MoveToLeftChunk = EFalse; |
|
89 TBool MoveToRightChunk = EFalse; |
|
90 |
|
91 if ((!leftChunk.iRightToLeft && pos.iPos == leftChunk.iEnd) || |
|
92 (leftChunk.iRightToLeft && pos.iPos == leftChunk.iStart)) |
|
93 MoveToRightChunk = ETrue; |
|
94 |
|
95 else if ((!rightChunk.iRightToLeft && pos.iPos == rightChunk.iStart) || |
|
96 (rightChunk.iRightToLeft && pos.iPos == rightChunk.iEnd)) |
|
97 MoveToLeftChunk = ETrue; |
|
98 |
|
99 TBool toggleLeadingTrailing = EFalse; |
|
100 if (leftChunk.iRightToLeft == rightChunk.iRightToLeft) |
|
101 toggleLeadingTrailing = ETrue; |
|
102 |
|
103 if (MoveToLeftChunk) |
|
104 { |
|
105 if (toggleLeadingTrailing) |
|
106 pos.iType = (pos.iType == TTmDocPosSpec::ETrailing) ? TTmDocPosSpec::ELeading : TTmDocPosSpec::ETrailing; |
|
107 if (!leftChunk.iRightToLeft) // LTR |
|
108 pos.iPos = leftChunk.iEnd; |
|
109 else //RTL |
|
110 pos.iPos = leftChunk.iStart; |
|
111 } |
|
112 else if (MoveToRightChunk) |
|
113 { |
|
114 if (toggleLeadingTrailing) |
|
115 pos.iType = (pos.iType == TTmDocPosSpec::ETrailing) ? TTmDocPosSpec::ELeading : TTmDocPosSpec::ETrailing; |
|
116 if (!rightChunk.iRightToLeft) // LTR |
|
117 pos.iPos = rightChunk.iStart; |
|
118 else //RTL |
|
119 pos.iPos = rightChunk.iEnd; |
|
120 } |
|
121 SetDocPosL(pos); |
|
122 } |
|
123 |
|
124 |