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 <unotextmarkup.hxx>
30 : :
31 : : #include <osl/mutex.hxx>
32 : : #include <vcl/svapp.hxx>
33 : : #include <SwSmartTagMgr.hxx>
34 : : #include <com/sun/star/text/TextMarkupType.hpp>
35 : : #include <com/sun/star/text/TextMarkupDescriptor.hpp>
36 : : #include <com/sun/star/container/XStringKeyMap.hpp>
37 : : #include <ndtxt.hxx>
38 : : #include <SwGrammarMarkUp.hxx>
39 : :
40 : : #include <IGrammarContact.hxx>
41 : :
42 : : using namespace ::com::sun::star;
43 : :
44 : : /*
45 : : * SwXTextMarkup
46 : : */
47 : 4763 : SwXTextMarkup::SwXTextMarkup( SwTxtNode& rTxtNode, const ModelToViewHelper& rMap )
48 [ + - ]: 4763 : : mpTxtNode( &rTxtNode ), maConversionMap( rMap )
49 : : {
50 : : // FME 2007-07-16 #i79641# SwXTextMarkup is allowed to be removed ...
51 : 4763 : SetIsAllowedToBeRemovedInModifyCall(true);
52 [ + - ]: 4763 : mpTxtNode->Add(this);
53 : 4763 : }
54 : :
55 [ + - ]: 4763 : SwXTextMarkup::~SwXTextMarkup()
56 : : {
57 [ - + ]: 4763 : }
58 : :
59 : 0 : uno::Reference< container::XStringKeyMap > SAL_CALL SwXTextMarkup::getMarkupInfoContainer() throw (uno::RuntimeException)
60 : : {
61 [ # # ]: 0 : SolarMutexGuard aGuard;
62 : :
63 [ # # ][ # # ]: 0 : uno::Reference< container::XStringKeyMap > xProp = new SwXStringKeyMap;
[ # # ]
64 [ # # ]: 0 : return xProp;
65 : : }
66 : :
67 : 0 : void SAL_CALL SwXTextMarkup::commitTextMarkup(
68 : : ::sal_Int32 nType,
69 : : const ::rtl::OUString & rIdentifier,
70 : : ::sal_Int32 nStart,
71 : : ::sal_Int32 nLength,
72 : : const uno::Reference< container::XStringKeyMap > & xMarkupInfoContainer)
73 : : throw (uno::RuntimeException)
74 : : {
75 [ # # ]: 0 : SolarMutexGuard aGuard;
76 : :
77 : : // paragraph already dead or modified?
78 [ # # ][ # # ]: 0 : if ( !mpTxtNode || nLength <= 0 )
79 : : return;
80 : :
81 [ # # ][ # # ]: 0 : if ( nType == text::TextMarkupType::SMARTTAG &&
[ # # ]
82 [ # # ][ # # ]: 0 : !SwSmartTagMgr::Get().IsSmartTagTypeEnabled( rIdentifier ) )
83 : : return;
84 : :
85 : : // get appropriate list to use...
86 : 0 : SwWrongList* pWList = 0;
87 : 0 : bool bRepaint = false;
88 [ # # ]: 0 : if ( nType == text::TextMarkupType::SPELLCHECK )
89 : : {
90 [ # # ]: 0 : pWList = mpTxtNode->GetWrong();
91 [ # # ]: 0 : if ( !pWList )
92 : : {
93 [ # # ][ # # ]: 0 : pWList = new SwWrongList( WRONGLIST_SPELL );
94 [ # # ]: 0 : mpTxtNode->SetWrong( pWList );
95 : : }
96 : : }
97 [ # # ][ # # ]: 0 : else if ( nType == text::TextMarkupType::PROOFREADING || nType == text::TextMarkupType::SENTENCE )
98 : : {
99 [ # # ]: 0 : IGrammarContact *pGrammarContact = getGrammarContact( *mpTxtNode );
100 [ # # ]: 0 : if( pGrammarContact )
101 : : {
102 [ # # ]: 0 : pWList = pGrammarContact->getGrammarCheck( *mpTxtNode, true );
103 : : OSL_ENSURE( pWList, "GrammarContact _has_ to deliver a wrong list" );
104 : : }
105 : : else
106 : : {
107 [ # # ]: 0 : pWList = mpTxtNode->GetGrammarCheck();
108 [ # # ]: 0 : if ( !pWList )
109 : : {
110 [ # # ][ # # ]: 0 : mpTxtNode->SetGrammarCheck( new SwGrammarMarkUp() );
[ # # ]
111 [ # # ]: 0 : pWList = mpTxtNode->GetGrammarCheck();
112 : : }
113 : : }
114 [ # # ]: 0 : bRepaint = pWList == mpTxtNode->GetGrammarCheck();
115 [ # # ]: 0 : if( pWList->GetBeginInv() < STRING_LEN )
116 [ # # ]: 0 : ((SwGrammarMarkUp*)pWList)->ClearGrammarList();
117 : : }
118 [ # # ]: 0 : else if ( nType == text::TextMarkupType::SMARTTAG )
119 : : {
120 [ # # ]: 0 : pWList = mpTxtNode->GetSmartTags();
121 [ # # ]: 0 : if ( !pWList )
122 : : {
123 [ # # ][ # # ]: 0 : pWList = new SwWrongList( WRONGLIST_SMARTTAG );
124 [ # # ]: 0 : mpTxtNode->SetSmartTags( pWList );
125 : : }
126 : : }
127 : : else
128 : : {
129 : : OSL_FAIL( "Unknown mark-up type" );
130 : : return;
131 : : }
132 : :
133 : :
134 : : const ModelToViewHelper::ModelPosition aStartPos =
135 [ # # ]: 0 : maConversionMap.ConvertToModelPosition( nStart );
136 : : const ModelToViewHelper::ModelPosition aEndPos =
137 [ # # ]: 0 : maConversionMap.ConvertToModelPosition( nStart + nLength - 1);
138 : :
139 : 0 : const bool bStartInField = aStartPos.mbIsField;
140 : 0 : const bool bEndInField = aEndPos.mbIsField;
141 : 0 : bool bCommit = false;
142 : :
143 [ # # ][ # # ]: 0 : if ( bStartInField && bEndInField && aStartPos.mnPos == aEndPos.mnPos )
[ # # ]
144 : : {
145 : 0 : nStart = aStartPos.mnSubPos;
146 : 0 : const xub_StrLen nFieldPosModel = static_cast< xub_StrLen >(aStartPos.mnPos);
147 [ # # ]: 0 : const sal_uInt16 nInsertPos = pWList->GetWrongPos( nFieldPosModel );
148 : :
149 [ # # ]: 0 : SwWrongList* pSubList = pWList->SubList( nInsertPos );
150 [ # # ]: 0 : if ( !pSubList )
151 : : {
152 [ # # ][ # # ]: 0 : if( nType == text::TextMarkupType::PROOFREADING || nType == text::TextMarkupType::SENTENCE )
153 [ # # ][ # # ]: 0 : pSubList = new SwGrammarMarkUp();
154 : : else
155 [ # # ][ # # ]: 0 : pSubList = new SwWrongList( pWList->GetWrongListType() );
156 [ # # ]: 0 : pWList->InsertSubList( nFieldPosModel, 1, nInsertPos, pSubList );
157 : : }
158 : :
159 : 0 : pWList = pSubList;
160 : 0 : bCommit = true;
161 : : }
162 [ # # ][ # # ]: 0 : else if ( !bStartInField && !bEndInField )
163 : : {
164 : 0 : nStart = aStartPos.mnPos;
165 : 0 : bCommit = true;
166 : 0 : nLength = aEndPos.mnPos + 1 - aStartPos.mnPos;
167 : : }
168 [ # # ][ # # ]: 0 : else if( nType == text::TextMarkupType::PROOFREADING || nType == text::TextMarkupType::SENTENCE )
169 : : {
170 : 0 : bCommit = true;
171 : 0 : nStart = aStartPos.mnPos;
172 : 0 : sal_Int32 nEnd = aEndPos.mnPos;
173 [ # # ][ # # ]: 0 : if( bStartInField && nType != text::TextMarkupType::SENTENCE )
174 : : {
175 : 0 : const xub_StrLen nFieldPosModel = static_cast< xub_StrLen >(aStartPos.mnPos);
176 [ # # ]: 0 : const sal_uInt16 nInsertPos = pWList->GetWrongPos( nFieldPosModel );
177 [ # # ]: 0 : SwWrongList* pSubList = pWList->SubList( nInsertPos );
178 [ # # ]: 0 : if ( !pSubList )
179 : : {
180 [ # # ][ # # ]: 0 : pSubList = new SwGrammarMarkUp();
181 [ # # ]: 0 : pWList->InsertSubList( nFieldPosModel, 1, nInsertPos, pSubList );
182 : : }
183 [ # # ]: 0 : const sal_uInt32 nTmpStart = maConversionMap.ConvertToViewPosition( aStartPos.mnPos );
184 [ # # ]: 0 : const sal_uInt32 nTmpLen = maConversionMap.ConvertToViewPosition( aStartPos.mnPos + 1 )
185 : 0 : - nTmpStart - aStartPos.mnSubPos;
186 [ # # ]: 0 : if( nTmpLen > 0 )
187 : : {
188 [ # # ]: 0 : if( nType == text::TextMarkupType::SENTENCE )
189 : : {
190 [ # # ]: 0 : ((SwGrammarMarkUp*)pSubList)->setSentence( static_cast< xub_StrLen >(aStartPos.mnSubPos) );
191 : 0 : bCommit = false;
192 : : }
193 : : else
194 : : pSubList->Insert( rIdentifier, xMarkupInfoContainer,
195 [ # # ]: 0 : static_cast< xub_StrLen >(aStartPos.mnSubPos), static_cast< xub_StrLen >(nTmpLen) );
196 : : }
197 : 0 : ++nStart;
198 : : }
199 [ # # ][ # # ]: 0 : if( bEndInField && nType != text::TextMarkupType::SENTENCE )
200 : : {
201 : 0 : const xub_StrLen nFieldPosModel = static_cast< xub_StrLen >(aEndPos.mnPos);
202 [ # # ]: 0 : const sal_uInt16 nInsertPos = pWList->GetWrongPos( nFieldPosModel );
203 [ # # ]: 0 : SwWrongList* pSubList = pWList->SubList( nInsertPos );
204 [ # # ]: 0 : if ( !pSubList )
205 : : {
206 [ # # ][ # # ]: 0 : pSubList = new SwGrammarMarkUp();
207 [ # # ]: 0 : pWList->InsertSubList( nFieldPosModel, 1, nInsertPos, pSubList );
208 : : }
209 : 0 : const sal_uInt32 nTmpLen = aEndPos.mnSubPos + 1;
210 [ # # ]: 0 : pSubList->Insert( rIdentifier, xMarkupInfoContainer, 0, static_cast< xub_StrLen >(nTmpLen) );
211 : : }
212 : : else
213 : 0 : ++nEnd;
214 [ # # ]: 0 : if( nEnd > nStart )
215 : 0 : nLength = nEnd - nStart;
216 : : else
217 : 0 : bCommit = false;
218 : : }
219 : :
220 [ # # ]: 0 : if ( bCommit )
221 : : {
222 [ # # ]: 0 : if( nType == text::TextMarkupType::SENTENCE )
223 [ # # ]: 0 : ((SwGrammarMarkUp*)pWList)->setSentence( static_cast< xub_StrLen >(nStart) );
224 : : else
225 : : pWList->Insert( rIdentifier, xMarkupInfoContainer,
226 [ # # ]: 0 : static_cast< xub_StrLen >(nStart), static_cast< xub_StrLen >(nLength) );
227 : : }
228 : :
229 [ # # ]: 0 : if( bRepaint )
230 [ # # ][ # # ]: 0 : finishGrammarCheck( *mpTxtNode );
[ # # ]
231 : : }
232 : :
233 : :
234 : 3085 : void lcl_commitGrammarMarkUp(
235 : : const ModelToViewHelper& rConversionMap,
236 : : SwGrammarMarkUp* pWList,
237 : : ::sal_Int32 nType,
238 : : const ::rtl::OUString & rIdentifier,
239 : : ::sal_Int32 nStart,
240 : : ::sal_Int32 nLength,
241 : : const uno::Reference< container::XStringKeyMap > & xMarkupInfoContainer)
242 : : {
243 : : OSL_ENSURE( nType == text::TextMarkupType::PROOFREADING || nType == text::TextMarkupType::SENTENCE, "Wrong mark-up type" );
244 : : const ModelToViewHelper::ModelPosition aStartPos =
245 [ + - ]: 3085 : rConversionMap.ConvertToModelPosition( nStart );
246 : : const ModelToViewHelper::ModelPosition aEndPos =
247 [ + - ]: 3085 : rConversionMap.ConvertToModelPosition( nStart + nLength - 1);
248 : :
249 : 3085 : const bool bStartInField = aStartPos.mbIsField;
250 : 3085 : const bool bEndInField = aEndPos.mbIsField;
251 : 3085 : bool bCommit = false;
252 : :
253 [ + + ][ + + ]: 3085 : if ( bStartInField && bEndInField && aStartPos.mnPos == aEndPos.mnPos )
[ + - ]
254 : : {
255 : 21 : nStart = aStartPos.mnSubPos;
256 : 21 : const xub_StrLen nFieldPosModel = static_cast< xub_StrLen >(aStartPos.mnPos);
257 [ + - ]: 21 : const sal_uInt16 nInsertPos = pWList->GetWrongPos( nFieldPosModel );
258 : :
259 [ + - ]: 21 : SwGrammarMarkUp* pSubList = (SwGrammarMarkUp*)pWList->SubList( nInsertPos );
260 [ + - ]: 21 : if ( !pSubList )
261 : : {
262 [ + - ][ + - ]: 21 : pSubList = new SwGrammarMarkUp();
263 [ + - ]: 21 : pWList->InsertSubList( nFieldPosModel, 1, nInsertPos, pSubList );
264 : : }
265 : :
266 : 21 : pWList = pSubList;
267 : 21 : bCommit = true;
268 : : }
269 [ + + ][ + + ]: 3064 : else if ( !bStartInField && !bEndInField )
270 : : {
271 : 3045 : nStart = aStartPos.mnPos;
272 : 3045 : bCommit = true;
273 : 3045 : nLength = aEndPos.mnPos + 1 - aStartPos.mnPos;
274 : : }
275 : : else
276 : : {
277 : 19 : bCommit = true;
278 : 19 : nStart = aStartPos.mnPos;
279 : 19 : sal_Int32 nEnd = aEndPos.mnPos;
280 [ + + ][ - + ]: 19 : if( bStartInField && nType != text::TextMarkupType::SENTENCE )
281 : : {
282 : 0 : const xub_StrLen nFieldPosModel = static_cast< xub_StrLen >(aStartPos.mnPos);
283 [ # # ]: 0 : const sal_uInt16 nInsertPos = pWList->GetWrongPos( nFieldPosModel );
284 [ # # ]: 0 : SwGrammarMarkUp* pSubList = (SwGrammarMarkUp*)pWList->SubList( nInsertPos );
285 [ # # ]: 0 : if ( !pSubList )
286 : : {
287 [ # # ][ # # ]: 0 : pSubList = new SwGrammarMarkUp();
288 [ # # ]: 0 : pWList->InsertSubList( nFieldPosModel, 1, nInsertPos, pSubList );
289 : : }
290 [ # # ]: 0 : const sal_uInt32 nTmpStart = rConversionMap.ConvertToViewPosition( aStartPos.mnPos );
291 [ # # ]: 0 : const sal_uInt32 nTmpLen = rConversionMap.ConvertToViewPosition( aStartPos.mnPos + 1 )
292 : 0 : - nTmpStart - aStartPos.mnSubPos;
293 [ # # ]: 0 : if( nTmpLen > 0 )
294 : : pSubList->Insert( rIdentifier, xMarkupInfoContainer,
295 [ # # ]: 0 : static_cast< xub_StrLen >(aStartPos.mnSubPos), static_cast< xub_StrLen >(nTmpLen) );
296 : 0 : ++nStart;
297 : : }
298 [ + + ][ - + ]: 19 : if( bEndInField && nType != text::TextMarkupType::SENTENCE )
299 : : {
300 : 0 : const xub_StrLen nFieldPosModel = static_cast< xub_StrLen >(aEndPos.mnPos);
301 [ # # ]: 0 : const sal_uInt16 nInsertPos = pWList->GetWrongPos( nFieldPosModel );
302 [ # # ]: 0 : SwGrammarMarkUp* pSubList = (SwGrammarMarkUp*)pWList->SubList( nInsertPos );
303 [ # # ]: 0 : if ( !pSubList )
304 : : {
305 [ # # ][ # # ]: 0 : pSubList = new SwGrammarMarkUp();
306 [ # # ]: 0 : pWList->InsertSubList( nFieldPosModel, 1, nInsertPos, pSubList );
307 : : }
308 : 0 : const sal_uInt32 nTmpLen = aEndPos.mnSubPos + 1;
309 [ # # ]: 0 : pSubList->Insert( rIdentifier, xMarkupInfoContainer, 0, static_cast< xub_StrLen >(nTmpLen) );
310 : : }
311 : : else
312 : 19 : ++nEnd;
313 [ + - ]: 19 : if( nEnd > nStart )
314 : 19 : nLength = nEnd - nStart;
315 : : else
316 : 0 : bCommit = false;
317 : : }
318 : :
319 [ + - ]: 3085 : if ( bCommit )
320 : : {
321 [ + + ]: 3085 : if( nType == text::TextMarkupType::SENTENCE )
322 [ + - ]: 2892 : ((SwGrammarMarkUp*)pWList)->setSentence( static_cast< xub_StrLen >(nStart+nLength) );
323 : : else
324 : : pWList->Insert( rIdentifier, xMarkupInfoContainer,
325 [ + - ]: 193 : static_cast< xub_StrLen >(nStart), static_cast< xub_StrLen >(nLength) );
326 : : }
327 : 3085 : }
328 : :
329 : :
330 : 2898 : void SAL_CALL SwXTextMarkup::commitMultiTextMarkup(
331 : : const uno::Sequence< text::TextMarkupDescriptor > &rMarkups )
332 : : throw (lang::IllegalArgumentException, uno::RuntimeException)
333 : : {
334 [ + - ]: 2898 : SolarMutexGuard aGuard;
335 : :
336 : : // paragraph already dead or modified?
337 [ + + ]: 2898 : if ( !mpTxtNode )
338 : : return;
339 : :
340 : : // check for equal length of all sequnces
341 : 2892 : sal_Int32 nLen = rMarkups.getLength();
342 : :
343 : : // for grammar checking there should be exactly one sentence markup
344 : : // and 0..n grammar markups.
345 : : // Different markups are not expected but may be applied anyway since
346 : : // that should be no problem...
347 : : // but it has to be implemented, at the moment only this function is for
348 : : // grammar markups and sentence markup only!
349 : 2892 : sal_Int32 nSentenceMarkUpIndex = -1;
350 : 2892 : const text::TextMarkupDescriptor *pMarkups = rMarkups.getConstArray();
351 : : sal_Int32 i;
352 [ + + ]: 5977 : for( i = 0; i < nLen; ++i )
353 : : {
354 [ + + ]: 3085 : if (pMarkups[i].nType == text::TextMarkupType::SENTENCE)
355 : : {
356 [ + - ]: 2892 : if (nSentenceMarkUpIndex == -1)
357 : 2892 : nSentenceMarkUpIndex = i;
358 : : else // there is already one sentence markup
359 [ # # ]: 0 : throw lang::IllegalArgumentException();
360 : : }
361 [ + - ]: 193 : else if( pMarkups[i].nType != text::TextMarkupType::PROOFREADING )
362 : : return;
363 : : }
364 : :
365 [ + - ]: 2892 : if( nSentenceMarkUpIndex == -1 )
366 : : return;
367 : :
368 : : // get appropriate list to use...
369 : 2892 : SwGrammarMarkUp* pWList = 0;
370 : 2892 : bool bRepaint = false;
371 [ + - ]: 2892 : IGrammarContact *pGrammarContact = getGrammarContact( *mpTxtNode );
372 [ + - ]: 2892 : if( pGrammarContact )
373 : : {
374 [ + - ]: 2892 : pWList = pGrammarContact->getGrammarCheck( *mpTxtNode, true );
375 : : OSL_ENSURE( pWList, "GrammarContact _has_ to deliver a wrong list" );
376 : : }
377 : : else
378 : : {
379 [ # # ]: 0 : pWList = mpTxtNode->GetGrammarCheck();
380 [ # # ]: 0 : if ( !pWList )
381 : : {
382 [ # # ][ # # ]: 0 : mpTxtNode->SetGrammarCheck( new SwGrammarMarkUp() );
[ # # ]
383 [ # # ]: 0 : pWList = mpTxtNode->GetGrammarCheck();
384 [ # # ]: 0 : pWList->SetInvalid( 0, STRING_LEN );
385 : : }
386 : : }
387 [ + - ]: 2892 : bRepaint = pWList == mpTxtNode->GetGrammarCheck();
388 : :
389 : 2892 : bool bAcceptGrammarError = false;
390 [ + - ]: 2892 : if( pWList->GetBeginInv() < STRING_LEN )
391 : : {
392 : : const ModelToViewHelper::ModelPosition aSentenceEnd =
393 : : maConversionMap.ConvertToModelPosition(
394 [ + - ]: 2892 : pMarkups[nSentenceMarkUpIndex].nOffset + pMarkups[nSentenceMarkUpIndex].nLength );
395 : 2892 : bAcceptGrammarError = (xub_StrLen)aSentenceEnd.mnPos > pWList->GetBeginInv();
396 [ + - ]: 2892 : pWList->ClearGrammarList( (xub_StrLen)aSentenceEnd.mnPos );
397 : : }
398 : :
399 [ + + ]: 2892 : if( bAcceptGrammarError )
400 : : {
401 [ + + ]: 3627 : for( i = 0; i < nLen; ++i )
402 : : {
403 : 1910 : const text::TextMarkupDescriptor &rDesc = pMarkups[i];
404 : : lcl_commitGrammarMarkUp( maConversionMap, pWList, rDesc.nType,
405 [ + - ]: 1910 : rDesc.aIdentifier, rDesc.nOffset, rDesc.nLength, rDesc.xMarkupInfoContainer );
406 : : }
407 : : }
408 : : else
409 : : {
410 : 1175 : bRepaint = false;
411 : 1175 : i = nSentenceMarkUpIndex;
412 : 1175 : const text::TextMarkupDescriptor &rDesc = pMarkups[i];
413 : : lcl_commitGrammarMarkUp( maConversionMap, pWList, rDesc.nType,
414 [ + - ]: 1175 : rDesc.aIdentifier, rDesc.nOffset, rDesc.nLength, rDesc.xMarkupInfoContainer );
415 : : }
416 : :
417 [ + + ]: 2892 : if( bRepaint )
418 [ + - ]: 805 : finishGrammarCheck( *mpTxtNode );
419 : :
420 [ + - ]: 2898 : return;
421 : : }
422 : :
423 : :
424 : 2187 : void SwXTextMarkup::Modify( const SfxPoolItem* /*pOld*/, const SfxPoolItem* /*pNew*/ )
425 : : {
426 : : // FME 2007-07-16 #i79641# In my opinion this is perfectly legal,
427 : : // therefore I remove the assertion in SwModify::_Remove()
428 [ + - ]: 2187 : if ( GetRegisteredIn() )
429 [ + - ]: 2187 : GetRegisteredInNonConst()->Remove( this );
430 : :
431 [ + - ]: 2187 : SolarMutexGuard aGuard;
432 [ + - ]: 2187 : mpTxtNode = 0;
433 : 2187 : }
434 : :
435 : : /*
436 : : * SwXStringKeyMap
437 : : */
438 [ # # ]: 0 : SwXStringKeyMap::SwXStringKeyMap()
439 : : {
440 : 0 : }
441 : :
442 : 0 : uno::Any SAL_CALL SwXStringKeyMap::getValue(const ::rtl::OUString & aKey) throw (uno::RuntimeException, container::NoSuchElementException)
443 : : {
444 [ # # ]: 0 : std::map< rtl::OUString, uno::Any >::const_iterator aIter = maMap.find( aKey );
445 [ # # ]: 0 : if ( aIter == maMap.end() )
446 [ # # ]: 0 : throw container::NoSuchElementException();
447 : :
448 : 0 : return (*aIter).second;
449 : : }
450 : :
451 : 0 : ::sal_Bool SAL_CALL SwXStringKeyMap::hasValue(const ::rtl::OUString & aKey) throw (uno::RuntimeException)
452 : : {
453 [ # # ]: 0 : return maMap.find( aKey ) != maMap.end();
454 : : }
455 : :
456 : 0 : void SAL_CALL SwXStringKeyMap::insertValue(const ::rtl::OUString & aKey, const uno::Any & aValue) throw (uno::RuntimeException, lang::IllegalArgumentException, container::ElementExistException)
457 : : {
458 [ # # ]: 0 : std::map< rtl::OUString, uno::Any >::const_iterator aIter = maMap.find( aKey );
459 [ # # ]: 0 : if ( aIter != maMap.end() )
460 [ # # ]: 0 : throw container::ElementExistException();
461 : :
462 [ # # ]: 0 : maMap[ aKey ] = aValue;
463 : 0 : }
464 : :
465 : 0 : ::sal_Int32 SAL_CALL SwXStringKeyMap::getCount() throw (uno::RuntimeException)
466 : : {
467 : 0 : return maMap.size();
468 : : }
469 : :
470 : 0 : ::rtl::OUString SAL_CALL SwXStringKeyMap::getKeyByIndex(::sal_Int32 nIndex) throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
471 : : {
472 [ # # ]: 0 : if ( (sal_uInt32)nIndex >= maMap.size() )
473 [ # # ]: 0 : throw lang::IndexOutOfBoundsException();
474 : :
475 : 0 : return ::rtl::OUString();
476 : : }
477 : :
478 : 0 : uno::Any SAL_CALL SwXStringKeyMap::getValueByIndex(::sal_Int32 nIndex) throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
479 : : {
480 [ # # ]: 0 : if ( (sal_uInt32)nIndex >= maMap.size() )
481 [ # # ]: 0 : throw lang::IndexOutOfBoundsException();
482 : :
483 : 0 : return uno::Any();
484 : : }
485 : :
486 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|