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 : :
30 : : #include <editeng/unolingu.hxx>
31 : :
32 : : #include <unobaseclass.hxx>
33 : : #include <unoflatpara.hxx>
34 : :
35 : : #include <osl/mutex.hxx>
36 : : #include <vcl/svapp.hxx>
37 : : #include <com/sun/star/text/TextMarkupType.hpp>
38 : : #include <unotextmarkup.hxx>
39 : : #include <ndtxt.hxx>
40 : : #include <doc.hxx>
41 : : #include <docsh.hxx>
42 : : #include <viewsh.hxx>
43 : : #include <viewimp.hxx>
44 : : #include <breakit.hxx>
45 : : #include <pam.hxx>
46 : : #include <unotextrange.hxx>
47 : : #include <pagefrm.hxx>
48 : : #include <cntfrm.hxx>
49 : : #include <rootfrm.hxx>
50 : : #include <poolfmt.hxx>
51 : : #include <pagedesc.hxx>
52 : : #include <IGrammarContact.hxx>
53 : : #include <viewopt.hxx>
54 : : #include <comphelper/servicehelper.hxx>
55 : :
56 : : using namespace ::com::sun::star;
57 : :
58 : : /******************************************************************************
59 : : * SwXFlatParagraph
60 : : ******************************************************************************/
61 : :
62 : 4763 : SwXFlatParagraph::SwXFlatParagraph( SwTxtNode& rTxtNode, rtl::OUString aExpandText, const ModelToViewHelper& rMap ) :
63 : : SwXTextMarkup( rTxtNode, rMap ),
64 [ + - ]: 4763 : maExpandText( aExpandText )
65 : : {
66 : 4763 : }
67 : :
68 [ + - ]: 4763 : SwXFlatParagraph::~SwXFlatParagraph()
69 : : {
70 [ - + ]: 9526 : }
71 : :
72 : 0 : uno::Sequence< uno::Type > SwXFlatParagraph::getTypes( ) throw(uno::RuntimeException)
73 : : {
74 : 0 : uno::Sequence< uno::Type > aTypes = SwXTextMarkup::getTypes();
75 [ # # ]: 0 : aTypes.realloc( aTypes.getLength() + 1 );
76 [ # # ][ # # ]: 0 : aTypes[aTypes.getLength()-1] = ::getCppuType((uno::Reference< text::XFlatParagraph >*)0);
77 : 0 : return aTypes;
78 : : }
79 : :
80 : : namespace
81 : : {
82 : : class theSwXFlatParagraphImplementationId : public rtl::Static< UnoTunnelIdInit, theSwXFlatParagraphImplementationId > {};
83 : : }
84 : :
85 : 0 : uno::Sequence< sal_Int8 > SwXFlatParagraph::getImplementationId( ) throw(uno::RuntimeException)
86 : : {
87 : 0 : return theSwXFlatParagraphImplementationId::get().getSeq();
88 : : }
89 : :
90 : 66054 : uno::Any SAL_CALL SwXFlatParagraph::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException)
91 : : {
92 [ + + ]: 66054 : if ( rType == ::getCppuType((uno::Reference< text::XFlatParagraph >*)0) )
93 : : {
94 [ + - ]: 9526 : return uno::makeAny( uno::Reference < text::XFlatParagraph >(this) );
95 : : }
96 : : else
97 : 66054 : return SwXTextMarkup::queryInterface( rType );
98 : : }
99 : :
100 : 149836 : void SAL_CALL SwXFlatParagraph::acquire() throw()
101 : : {
102 : 149836 : SwXTextMarkup::acquire();
103 : 149836 : }
104 : :
105 : 149836 : void SAL_CALL SwXFlatParagraph::release() throw()
106 : : {
107 : 149836 : SwXTextMarkup::release();
108 : 149836 : }
109 : :
110 : 0 : const SwTxtNode* SwXFlatParagraph::getTxtNode() const
111 : : {
112 : 0 : return mpTxtNode;
113 : : }
114 : :
115 : 0 : css::uno::Reference< css::container::XStringKeyMap > SAL_CALL SwXFlatParagraph::getMarkupInfoContainer() throw (css::uno::RuntimeException)
116 : : {
117 : 0 : return SwXTextMarkup::getMarkupInfoContainer();
118 : : }
119 : :
120 : 0 : void SAL_CALL SwXFlatParagraph::commitTextMarkup(::sal_Int32 nType, const ::rtl::OUString & rIdentifier, ::sal_Int32 nStart, ::sal_Int32 nLength, const css::uno::Reference< css::container::XStringKeyMap > & rxMarkupInfoContainer) throw (css::uno::RuntimeException)
121 : : {
122 [ # # ]: 0 : SolarMutexGuard aGuard;
123 [ # # ][ # # ]: 0 : SwXTextMarkup::commitTextMarkup( nType, rIdentifier, nStart, nLength, rxMarkupInfoContainer );
124 : 0 : }
125 : :
126 : : // text::XFlatParagraph:
127 : 4763 : ::rtl::OUString SAL_CALL SwXFlatParagraph::getText() throw (uno::RuntimeException)
128 : : {
129 : 4763 : return maExpandText;
130 : : }
131 : :
132 : : // text::XFlatParagraph:
133 : 2898 : void SAL_CALL SwXFlatParagraph::setChecked( ::sal_Int32 nType, ::sal_Bool bVal ) throw (uno::RuntimeException)
134 : : {
135 [ + - ]: 2898 : SolarMutexGuard aGuard;
136 : :
137 [ + + ]: 2898 : if ( mpTxtNode )
138 : : {
139 [ - + ]: 2880 : if ( text::TextMarkupType::SPELLCHECK == nType )
140 [ # # ]: 0 : mpTxtNode->SetWrongDirty( !bVal );
141 [ - + ]: 2880 : else if ( text::TextMarkupType::SMARTTAG == nType )
142 [ # # ]: 0 : mpTxtNode->SetSmartTagDirty( !bVal );
143 [ + - ]: 2880 : else if( text::TextMarkupType::PROOFREADING == nType )
144 : : {
145 [ + - ]: 2880 : mpTxtNode->SetGrammarCheckDirty( !bVal );
146 [ + - ]: 2880 : if( bVal )
147 [ + - ]: 2880 : ::finishGrammarCheck( *mpTxtNode );
148 : : }
149 [ + - ]: 2898 : }
150 : 2898 : }
151 : :
152 : : // text::XFlatParagraph:
153 : 0 : ::sal_Bool SAL_CALL SwXFlatParagraph::isChecked( ::sal_Int32 nType ) throw (uno::RuntimeException)
154 : : {
155 [ # # ]: 0 : SolarMutexGuard aGuard;
156 [ # # ]: 0 : if ( mpTxtNode )
157 : : {
158 [ # # ]: 0 : if ( text::TextMarkupType::SPELLCHECK == nType )
159 [ # # ]: 0 : return mpTxtNode->IsWrongDirty();
160 [ # # ]: 0 : else if ( text::TextMarkupType::PROOFREADING == nType )
161 [ # # ]: 0 : return mpTxtNode->IsGrammarCheckDirty();
162 [ # # ]: 0 : else if ( text::TextMarkupType::SMARTTAG == nType )
163 [ # # ]: 0 : return mpTxtNode->IsSmartTagDirty();
164 : : }
165 : :
166 [ # # ]: 0 : return sal_False;
167 : : }
168 : :
169 : : // text::XFlatParagraph:
170 : 9407 : ::sal_Bool SAL_CALL SwXFlatParagraph::isModified() throw (uno::RuntimeException)
171 : : {
172 [ + - ]: 9407 : SolarMutexGuard aGuard;
173 [ + - ]: 9407 : return 0 == mpTxtNode;
174 : : }
175 : :
176 : : // text::XFlatParagraph:
177 : 4763 : lang::Locale SAL_CALL SwXFlatParagraph::getLanguageOfText(::sal_Int32 nPos, ::sal_Int32 nLen)
178 : : throw (uno::RuntimeException, lang::IllegalArgumentException)
179 : : {
180 [ + - ]: 4763 : SolarMutexGuard aGuard;
181 [ + + ]: 4763 : if (!mpTxtNode)
182 [ + - ]: 114 : return SvxCreateLocale( LANGUAGE_NONE );
183 : :
184 [ + - ][ + - ]: 4649 : const lang::Locale aLocale( SW_BREAKITER()->GetLocale( mpTxtNode->GetLang( static_cast<sal_uInt16>(nPos), static_cast<sal_uInt16>(nLen) ) ) );
[ + - ]
185 [ + - ]: 4763 : return aLocale;
186 : : }
187 : :
188 : : // text::XFlatParagraph:
189 : 0 : lang::Locale SAL_CALL SwXFlatParagraph::getPrimaryLanguageOfText(::sal_Int32 nPos, ::sal_Int32 nLen)
190 : : throw (uno::RuntimeException, lang::IllegalArgumentException)
191 : : {
192 [ # # ]: 0 : SolarMutexGuard aGuard;
193 : :
194 [ # # ]: 0 : if (!mpTxtNode)
195 [ # # ]: 0 : return SvxCreateLocale( LANGUAGE_NONE );
196 : :
197 [ # # ][ # # ]: 0 : const lang::Locale aLocale( SW_BREAKITER()->GetLocale( mpTxtNode->GetLang( static_cast<sal_uInt16>(nPos), static_cast<sal_uInt16>(nLen) ) ) );
[ # # ]
198 [ # # ]: 0 : return aLocale;
199 : : }
200 : :
201 : : // text::XFlatParagraph:
202 : 0 : void SAL_CALL SwXFlatParagraph::changeText(::sal_Int32 nPos, ::sal_Int32 nLen, const ::rtl::OUString & aNewText, const css::uno::Sequence< css::beans::PropertyValue > & aAttributes) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException)
203 : : {
204 [ # # ]: 0 : SolarMutexGuard aGuard;
205 : :
206 [ # # ]: 0 : if ( !mpTxtNode )
207 : 0 : return;
208 : :
209 : 0 : SwTxtNode* pOldTxtNode = mpTxtNode;
210 : :
211 [ # # ]: 0 : SwPaM aPaM( *mpTxtNode, static_cast<sal_uInt16>(nPos), *mpTxtNode, static_cast<sal_uInt16>(nPos + nLen) );
212 : :
213 [ # # ]: 0 : UnoActionContext aAction( mpTxtNode->GetDoc() );
214 : :
215 : : const uno::Reference< text::XTextRange > xRange =
216 : : SwXTextRange::CreateXTextRange(
217 [ # # ]: 0 : *mpTxtNode->GetDoc(), *aPaM.GetPoint(), aPaM.GetMark() );
218 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xPropSet( xRange, uno::UNO_QUERY );
219 [ # # ]: 0 : if ( xPropSet.is() )
220 : : {
221 [ # # ]: 0 : for ( sal_uInt16 i = 0; i < aAttributes.getLength(); ++i )
222 [ # # ][ # # ]: 0 : xPropSet->setPropertyValue( aAttributes[i].Name, aAttributes[i].Value );
223 : : }
224 : :
225 : 0 : mpTxtNode = pOldTxtNode; // setPropertyValue() modifies this. We restore the old state.
226 : :
227 [ # # ]: 0 : IDocumentContentOperations* pIDCO = mpTxtNode->getIDocumentContentOperations();
228 [ # # ][ # # ]: 0 : pIDCO->ReplaceRange( aPaM, aNewText, false );
[ # # ]
229 : :
230 [ # # ][ # # ]: 0 : mpTxtNode = 0;
[ # # ][ # # ]
231 : : }
232 : :
233 : : // text::XFlatParagraph:
234 : 0 : void SAL_CALL SwXFlatParagraph::changeAttributes(::sal_Int32 nPos, ::sal_Int32 nLen, const css::uno::Sequence< css::beans::PropertyValue > & aAttributes) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException)
235 : : {
236 [ # # ]: 0 : SolarMutexGuard aGuard;
237 : :
238 [ # # ]: 0 : if ( !mpTxtNode )
239 : 0 : return;
240 : :
241 [ # # ]: 0 : SwPaM aPaM( *mpTxtNode, static_cast<sal_uInt16>(nPos), *mpTxtNode, static_cast<sal_uInt16>(nPos + nLen) );
242 : :
243 [ # # ]: 0 : UnoActionContext aAction( mpTxtNode->GetDoc() );
244 : :
245 : : const uno::Reference< text::XTextRange > xRange =
246 : : SwXTextRange::CreateXTextRange(
247 [ # # ]: 0 : *mpTxtNode->GetDoc(), *aPaM.GetPoint(), aPaM.GetMark() );
248 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xPropSet( xRange, uno::UNO_QUERY );
249 [ # # ]: 0 : if ( xPropSet.is() )
250 : : {
251 [ # # ]: 0 : for ( sal_uInt16 i = 0; i < aAttributes.getLength(); ++i )
252 [ # # ][ # # ]: 0 : xPropSet->setPropertyValue( aAttributes[i].Name, aAttributes[i].Value );
253 : : }
254 : :
255 [ # # ][ # # ]: 0 : mpTxtNode = 0;
[ # # ][ # # ]
256 : : }
257 : :
258 : : // text::XFlatParagraph:
259 : 0 : css::uno::Sequence< ::sal_Int32 > SAL_CALL SwXFlatParagraph::getLanguagePortions() throw (css::uno::RuntimeException)
260 : : {
261 [ # # ]: 0 : SolarMutexGuard aGuard;
262 [ # # ][ # # ]: 0 : return css::uno::Sequence< ::sal_Int32>();
263 : : }
264 : :
265 : : namespace
266 : : {
267 : : class theSwXFlatParagraphUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXFlatParagraphUnoTunnelId > {};
268 : : }
269 : :
270 : : const uno::Sequence< sal_Int8 >&
271 : 0 : SwXFlatParagraph::getUnoTunnelId()
272 : : {
273 : 0 : return theSwXFlatParagraphUnoTunnelId::get().getSeq();
274 : : }
275 : :
276 : : sal_Int64 SAL_CALL
277 : 0 : SwXFlatParagraph::getSomething(
278 : : const uno::Sequence< sal_Int8 >& rId)
279 : : throw (uno::RuntimeException)
280 : : {
281 : 0 : return sw::UnoTunnelImpl(rId, this);
282 : : }
283 : :
284 : :
285 : : /******************************************************************************
286 : : * SwXFlatParagraphIterator
287 : : ******************************************************************************/
288 : :
289 : 3755 : SwXFlatParagraphIterator::SwXFlatParagraphIterator( SwDoc& rDoc, sal_Int32 nType, sal_Bool bAutomatic )
290 : : : mpDoc( &rDoc ),
291 : : mnType( nType ),
292 : : mbAutomatic( bAutomatic ),
293 : : mnCurrentNode( 0 ),
294 : : mnStartNode( 0 ),
295 [ + - ]: 3755 : mnEndNode( rDoc.GetNodes().Count() ),
296 [ + - ]: 3755 : mbWrapped( sal_False )
297 : : {
298 : : //mnStartNode = mnCurrentNode = get node from current cursor TODO!
299 : :
300 : : // register as listener and get notified when document is closed
301 [ + - ][ + - ]: 3755 : mpDoc->GetPageDescFromPool( RES_POOLPAGE_STANDARD )->Add(this);
302 : 3755 : }
303 : :
304 [ + - ]: 3755 : SwXFlatParagraphIterator::~SwXFlatParagraphIterator()
305 : : {
306 [ - + ]: 7510 : }
307 : :
308 : :
309 : 43 : void SwXFlatParagraphIterator::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
310 : : {
311 : 43 : ClientModify( this, pOld, pNew );
312 : : // check if document gets closed...
313 [ + - ]: 43 : if(!GetRegisteredIn())
314 : : {
315 [ + - ]: 43 : SolarMutexGuard aGuard;
316 [ + - ]: 43 : mpDoc = 0;
317 : : }
318 : 43 : }
319 : :
320 : :
321 : 3755 : uno::Reference< text::XFlatParagraph > SwXFlatParagraphIterator::getFirstPara()
322 : : throw( uno::RuntimeException )
323 : : {
324 : 3755 : return getNextPara(); // TODO
325 : : }
326 : :
327 : 8518 : uno::Reference< text::XFlatParagraph > SwXFlatParagraphIterator::getNextPara()
328 : : throw( uno::RuntimeException )
329 : : {
330 [ + - ]: 8518 : SolarMutexGuard aGuard;
331 : :
332 : 8518 : uno::Reference< text::XFlatParagraph > xRet;
333 [ + + ]: 8518 : if (!mpDoc)
334 : : return xRet;
335 : :
336 : 8475 : SwTxtNode* pRet = 0;
337 [ + - ]: 8475 : if ( mbAutomatic )
338 : : {
339 : 8475 : ViewShell* pViewShell = 0;
340 [ + - ]: 8475 : mpDoc->GetEditShell( &pViewShell );
341 : :
342 [ + - ][ + - ]: 8475 : SwPageFrm* pCurrentPage = pViewShell ? pViewShell->Imp()->GetFirstVisPage() : 0;
343 : 8475 : SwPageFrm* pStartPage = pCurrentPage;
344 : 8475 : SwPageFrm* pStopPage = 0;
345 : :
346 [ + + ]: 18850 : while ( pCurrentPage != pStopPage )
347 : : {
348 [ - + ][ # # ]: 10375 : if (mnType != text::TextMarkupType::SPELLCHECK || pCurrentPage->IsInvalidSpelling() )
[ + - ]
349 : : {
350 : : // this method is supposed to return an empty paragraph in case Online Checking is disabled
351 [ - + ]: 20750 : if ( ( mnType == text::TextMarkupType::PROOFREADING || mnType == text::TextMarkupType::SPELLCHECK )
[ # # - + ]
[ + - ]
352 : 10375 : && !pViewShell->GetViewOptions()->IsOnlineSpell() )
353 : : return xRet;
354 : :
355 : : // search for invalid content:
356 [ + - ]: 10375 : SwCntntFrm* pCnt = pCurrentPage->ContainsCntnt();
357 : :
358 [ + + ][ + - ]: 41514 : while( pCnt && pCurrentPage->IsAnLower( pCnt ) )
[ + + ][ + + ]
359 : : {
360 : 31139 : SwTxtNode* pTxtNode = dynamic_cast<SwTxtNode*>( pCnt->GetNode()->GetTxtNode() );
361 : :
362 [ - + ][ # # ]: 62278 : if ( pTxtNode &&
[ + - ][ + + ]
[ + + ][ + - ]
363 : : ((mnType == text::TextMarkupType::SPELLCHECK &&
364 [ # # ]: 0 : pTxtNode->IsWrongDirty()) ||
365 : : (mnType == text::TextMarkupType::PROOFREADING &&
366 [ + - ]: 31139 : pTxtNode->IsGrammarCheckDirty())) )
367 : : {
368 : 4763 : pRet = pTxtNode;
369 : 4763 : break;
370 : : }
371 : :
372 [ + - ]: 26376 : pCnt = pCnt->GetNextCntntFrm();
373 : : }
374 : : }
375 : :
376 [ + + ]: 10375 : if ( pRet )
377 : 4763 : break;
378 : :
379 : : // if there is no invalid text node on the current page,
380 : : // we validate the page
381 : 5612 : pCurrentPage->ValidateSpelling();
382 : :
383 : : // proceed with next page, wrap at end of document if required:
384 : 5612 : pCurrentPage = static_cast<SwPageFrm*>(pCurrentPage->GetNext());
385 : :
386 [ + - ][ + + ]: 5612 : if ( !pCurrentPage && !pStopPage )
387 : : {
388 : 4287 : pStopPage = pStartPage;
389 [ + - ]: 4287 : pCurrentPage = static_cast<SwPageFrm*>(pViewShell->GetLayout()->Lower());
390 : : }
391 : : }
392 : : }
393 : : else // non-automatic checking
394 : : {
395 [ # # ]: 0 : const SwNodes& rNodes = mpDoc->GetNodes();
396 : 0 : const sal_uLong nMaxNodes = rNodes.Count();
397 : :
398 [ # # ][ # # ]: 0 : while ( mnCurrentNode < mnEndNode && mnCurrentNode < nMaxNodes )
[ # # ]
399 : : {
400 [ # # ]: 0 : SwNode* pNd = rNodes[ mnCurrentNode ];
401 : :
402 : 0 : ++mnCurrentNode;
403 : :
404 [ # # ]: 0 : pRet = dynamic_cast<SwTxtNode*>(pNd);
405 [ # # ]: 0 : if ( pRet )
406 : 0 : break;
407 : :
408 [ # # ][ # # ]: 0 : if ( mnCurrentNode == mnEndNode && !mbWrapped )
409 : : {
410 : 0 : mnCurrentNode = 0;
411 : 0 : mnEndNode = mnStartNode;
412 : : }
413 : : }
414 : : }
415 : :
416 [ + + ]: 8475 : if ( pRet )
417 : : {
418 : : // Expand the string:
419 [ + - ]: 4763 : const ModelToViewHelper aConversionMap(*pRet);
420 : 4763 : rtl::OUString aExpandText = aConversionMap.getViewText();
421 : :
422 [ + - ][ + - ]: 4763 : xRet = new SwXFlatParagraph( *pRet, aExpandText, aConversionMap );
[ + - ]
423 : : // keep hard references...
424 [ + - ]: 4763 : m_aFlatParaList.insert( xRet );
425 : : }
426 : :
427 [ + - ]: 8518 : return xRet;
428 : : }
429 : :
430 : 0 : uno::Reference< text::XFlatParagraph > SwXFlatParagraphIterator::getLastPara()
431 : : throw( uno::RuntimeException )
432 : : {
433 : 0 : return getNextPara();
434 : : }
435 : :
436 : 0 : uno::Reference< text::XFlatParagraph > SwXFlatParagraphIterator::getParaAfter(const uno::Reference< text::XFlatParagraph > & xPara)
437 : : throw ( uno::RuntimeException, lang::IllegalArgumentException )
438 : : {
439 [ # # ]: 0 : SolarMutexGuard aGuard;
440 : :
441 : 0 : uno::Reference< text::XFlatParagraph > xRet;
442 [ # # ]: 0 : if (!mpDoc)
443 : : return xRet;
444 : :
445 [ # # ]: 0 : const uno::Reference<lang::XUnoTunnel> xFPTunnel(xPara, uno::UNO_QUERY);
446 : : OSL_ASSERT(xFPTunnel.is());
447 [ # # ]: 0 : SwXFlatParagraph* const pFlatParagraph(sw::UnoTunnelGetImplementation<SwXFlatParagraph>(xFPTunnel));
448 : :
449 [ # # ]: 0 : if ( !pFlatParagraph )
450 : : return xRet;
451 : :
452 : 0 : const SwTxtNode* pCurrentNode = pFlatParagraph->getTxtNode();
453 : :
454 [ # # ]: 0 : if ( !pCurrentNode )
455 : : return xRet;
456 : :
457 : 0 : SwTxtNode* pNextTxtNode = 0;
458 [ # # ]: 0 : const SwNodes& rNodes = pCurrentNode->GetDoc()->GetNodes();
459 : :
460 [ # # ]: 0 : for( sal_uLong nCurrentNode = pCurrentNode->GetIndex() + 1; nCurrentNode < rNodes.Count(); ++nCurrentNode )
461 : : {
462 [ # # ]: 0 : SwNode* pNd = rNodes[ nCurrentNode ];
463 [ # # ]: 0 : pNextTxtNode = dynamic_cast<SwTxtNode*>(pNd);
464 [ # # ]: 0 : if ( pNextTxtNode )
465 : 0 : break;
466 : : }
467 : :
468 [ # # ]: 0 : if ( pNextTxtNode )
469 : : {
470 : : // Expand the string:
471 [ # # ]: 0 : const ModelToViewHelper aConversionMap(*pNextTxtNode);
472 : 0 : rtl::OUString aExpandText = aConversionMap.getViewText();
473 : :
474 [ # # ][ # # ]: 0 : xRet = new SwXFlatParagraph( *pNextTxtNode, aExpandText, aConversionMap );
[ # # ]
475 : : // keep hard references...
476 [ # # ]: 0 : m_aFlatParaList.insert( xRet );
477 : : }
478 : :
479 [ # # ]: 0 : return xRet;
480 : : }
481 : :
482 : 0 : uno::Reference< text::XFlatParagraph > SwXFlatParagraphIterator::getParaBefore(const uno::Reference< text::XFlatParagraph > & xPara )
483 : : throw ( uno::RuntimeException, lang::IllegalArgumentException )
484 : : {
485 [ # # ]: 0 : SolarMutexGuard aGuard;
486 : :
487 : 0 : uno::Reference< text::XFlatParagraph > xRet;
488 [ # # ]: 0 : if (!mpDoc)
489 : : return xRet;
490 : :
491 [ # # ]: 0 : const uno::Reference<lang::XUnoTunnel> xFPTunnel(xPara, uno::UNO_QUERY);
492 : : OSL_ASSERT(xFPTunnel.is());
493 [ # # ]: 0 : SwXFlatParagraph* const pFlatParagraph(sw::UnoTunnelGetImplementation<SwXFlatParagraph>(xFPTunnel));
494 : :
495 [ # # ]: 0 : if ( !pFlatParagraph )
496 : : return xRet;
497 : :
498 : 0 : const SwTxtNode* pCurrentNode = pFlatParagraph->getTxtNode();
499 : :
500 [ # # ]: 0 : if ( !pCurrentNode )
501 : : return xRet;
502 : :
503 : 0 : SwTxtNode* pPrevTxtNode = 0;
504 [ # # ]: 0 : const SwNodes& rNodes = pCurrentNode->GetDoc()->GetNodes();
505 : :
506 [ # # ]: 0 : for( sal_uLong nCurrentNode = pCurrentNode->GetIndex() - 1; nCurrentNode > 0; --nCurrentNode )
507 : : {
508 [ # # ]: 0 : SwNode* pNd = rNodes[ nCurrentNode ];
509 [ # # ]: 0 : pPrevTxtNode = dynamic_cast<SwTxtNode*>(pNd);
510 [ # # ]: 0 : if ( pPrevTxtNode )
511 : 0 : break;
512 : : }
513 : :
514 [ # # ]: 0 : if ( pPrevTxtNode )
515 : : {
516 : : // Expand the string:
517 [ # # ]: 0 : const ModelToViewHelper aConversionMap(*pPrevTxtNode);
518 : 0 : rtl::OUString aExpandText = aConversionMap.getViewText();
519 : :
520 [ # # ][ # # ]: 0 : xRet = new SwXFlatParagraph( *pPrevTxtNode, aExpandText, aConversionMap );
[ # # ]
521 : : // keep hard references...
522 [ # # ]: 0 : m_aFlatParaList.insert( xRet );
523 : : }
524 : :
525 [ # # ]: 0 : return xRet;
526 : : }
527 : :
528 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|