Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <editeng/unoedhlp.hxx>
30 : : #include <editeng/editdata.hxx>
31 : : #include <editeng/editeng.hxx>
32 : :
33 : : //------------------------------------------------------------------------
34 : :
35 [ # # ][ # # ]: 37 : TYPEINIT1( SvxEditSourceHint, TextHint );
36 : :
37 : 0 : SvxEditSourceHint::SvxEditSourceHint( sal_uLong _nId ) :
38 : : TextHint( _nId ),
39 : : mnStart( 0 ),
40 : 0 : mnEnd( 0 )
41 : : {
42 : 0 : }
43 : :
44 : 0 : SvxEditSourceHint::SvxEditSourceHint( sal_uLong _nId, sal_uLong nValue, sal_uLong nStart, sal_uLong nEnd ) :
45 : : TextHint( _nId, nValue ),
46 : : mnStart( nStart),
47 : 0 : mnEnd( nEnd )
48 : : {
49 : 0 : }
50 : :
51 : 0 : sal_uLong SvxEditSourceHint::GetValue() const
52 : : {
53 : 0 : return TextHint::GetValue();
54 : : }
55 : :
56 : 0 : sal_uLong SvxEditSourceHint::GetStartValue() const
57 : : {
58 : 0 : return mnStart;
59 : : }
60 : :
61 : 0 : sal_uLong SvxEditSourceHint::GetEndValue() const
62 : : {
63 : 0 : return mnEnd;
64 : : }
65 : :
66 : : //------------------------------------------------------------------------
67 : :
68 : 15 : ::std::auto_ptr<SfxHint> SvxEditSourceHelper::EENotification2Hint( EENotify* aNotify )
69 : : {
70 [ + - ]: 15 : if( aNotify )
71 : : {
72 [ - - - - : 15 : switch( aNotify->eNotificationType )
+ - - + +
- - - ]
73 : : {
74 : : case EE_NOTIFY_TEXTMODIFIED:
75 [ # # ]: 0 : return ::std::auto_ptr<SfxHint>( new TextHint( TEXT_HINT_MODIFIED, aNotify->nParagraph ) );
76 : :
77 : : case EE_NOTIFY_PARAGRAPHINSERTED:
78 [ # # ]: 0 : return ::std::auto_ptr<SfxHint>( new TextHint( TEXT_HINT_PARAINSERTED, aNotify->nParagraph ) );
79 : :
80 : : case EE_NOTIFY_PARAGRAPHREMOVED:
81 [ # # ]: 0 : return ::std::auto_ptr<SfxHint>( new TextHint( TEXT_HINT_PARAREMOVED, aNotify->nParagraph ) );
82 : :
83 : : case EE_NOTIFY_PARAGRAPHSMOVED:
84 [ # # ]: 0 : return ::std::auto_ptr<SfxHint>( new SvxEditSourceHint( EDITSOURCE_HINT_PARASMOVED, aNotify->nParagraph, aNotify->nParam1, aNotify->nParam2 ) );
85 : :
86 : : case EE_NOTIFY_TEXTHEIGHTCHANGED:
87 [ + - ]: 5 : return ::std::auto_ptr<SfxHint>( new TextHint( TEXT_HINT_TEXTHEIGHTCHANGED, aNotify->nParagraph ) );
88 : :
89 : : case EE_NOTIFY_TEXTVIEWSCROLLED:
90 [ # # ]: 0 : return ::std::auto_ptr<SfxHint>( new TextHint( TEXT_HINT_VIEWSCROLLED ) );
91 : :
92 : : case EE_NOTIFY_TEXTVIEWSELECTIONCHANGED:
93 [ # # ]: 0 : return ::std::auto_ptr<SfxHint>( new SvxEditSourceHint( EDITSOURCE_HINT_SELECTIONCHANGED ) );
94 : :
95 : : case EE_NOTIFY_BLOCKNOTIFICATION_START:
96 [ + - ]: 5 : return ::std::auto_ptr<SfxHint>( new TextHint( TEXT_HINT_BLOCKNOTIFICATION_START, 0 ) );
97 : :
98 : : case EE_NOTIFY_BLOCKNOTIFICATION_END:
99 [ + - ]: 5 : return ::std::auto_ptr<SfxHint>( new TextHint( TEXT_HINT_BLOCKNOTIFICATION_END, 0 ) );
100 : :
101 : : case EE_NOTIFY_INPUT_START:
102 [ # # ]: 0 : return ::std::auto_ptr<SfxHint>( new TextHint( TEXT_HINT_INPUT_START, 0 ) );
103 : :
104 : : case EE_NOTIFY_INPUT_END:
105 [ # # ]: 0 : return ::std::auto_ptr<SfxHint>( new TextHint( TEXT_HINT_INPUT_END, 0 ) );
106 : :
107 : : default:
108 : : OSL_FAIL( "SvxEditSourceHelper::EENotification2Hint unknown notification" );
109 : 0 : break;
110 : : }
111 : : }
112 : :
113 : 15 : return ::std::auto_ptr<SfxHint>( new SfxHint() );
114 : : }
115 : :
116 : 0 : sal_Bool SvxEditSourceHelper::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, const EditEngine& rEE, sal_uInt16 nPara, sal_uInt16 nIndex )
117 : : {
118 [ # # ]: 0 : std::vector<EECharAttrib> aCharAttribs;
119 : :
120 [ # # ]: 0 : rEE.GetCharAttribs( nPara, aCharAttribs );
121 : :
122 : : // find closest index in front of nIndex
123 : : sal_uInt16 nCurrIndex;
124 : 0 : sal_Int32 nClosestStartIndex = 0;
125 [ # # ][ # # ]: 0 : for(std::vector<EECharAttrib>::iterator i = aCharAttribs.begin(); i < aCharAttribs.end(); ++i)
126 : : {
127 : 0 : nCurrIndex = i->nStart;
128 : :
129 [ # # ]: 0 : if( nCurrIndex > nIndex )
130 : 0 : break; // aCharAttribs array is sorted in increasing order for nStart values
131 [ # # ]: 0 : else if( nCurrIndex > nClosestStartIndex )
132 : : {
133 : 0 : nClosestStartIndex = nCurrIndex;
134 : : }
135 : : }
136 : :
137 : : // find closest index behind of nIndex
138 [ # # ]: 0 : sal_Int32 nClosestEndIndex = rEE.GetTextLen(nPara);
139 [ # # ][ # # ]: 0 : for(std::vector<EECharAttrib>::iterator i = aCharAttribs.begin(); i < aCharAttribs.end(); ++i)
140 : : {
141 : 0 : nCurrIndex = i->nEnd;
142 : :
143 [ # # ][ # # ]: 0 : if( nCurrIndex > nIndex && nCurrIndex < nClosestEndIndex )
144 : 0 : nClosestEndIndex = nCurrIndex;
145 : : }
146 : :
147 : 0 : nStartIndex = static_cast<sal_uInt16>( nClosestStartIndex );
148 : 0 : nEndIndex = static_cast<sal_uInt16>( nClosestEndIndex );
149 : :
150 : 0 : return sal_True;
151 : : }
152 : :
153 : 0 : Point SvxEditSourceHelper::EEToUserSpace( const Point& rPoint, const Size& rEESize, bool bIsVertical )
154 : : {
155 [ # # ]: 0 : return bIsVertical ? Point( -rPoint.Y() + rEESize.Height(), rPoint.X() ) : rPoint;
156 : : }
157 : :
158 : 22 : Point SvxEditSourceHelper::UserSpaceToEE( const Point& rPoint, const Size& rEESize, bool bIsVertical )
159 : : {
160 [ - + ]: 22 : return bIsVertical ? Point( rPoint.Y(), -rPoint.X() + rEESize.Height() ) : rPoint;
161 : : }
162 : :
163 : 42 : Rectangle SvxEditSourceHelper::EEToUserSpace( const Rectangle& rRect, const Size& rEESize, bool bIsVertical )
164 : : {
165 [ # # ][ - + ]: 42 : return bIsVertical ? Rectangle( EEToUserSpace(rRect.BottomLeft(), rEESize, bIsVertical),
[ # # ]
166 [ - + ][ # # ]: 84 : EEToUserSpace(rRect.TopRight(), rEESize, bIsVertical) ) : rRect;
[ # # ][ # # ]
[ # # ][ - + ]
[ - + ][ - + ]
[ # # # #
# # ]
167 : : }
168 : :
169 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|