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 <rtl/ustrbuf.hxx>
30 : : #include <swtypes.hxx>
31 : : #include <hintids.hxx>
32 : : #include <cmdid.h>
33 : : #include <hints.hxx>
34 : : #include <IMark.hxx>
35 : : #include <bookmrk.hxx>
36 : : #include <frmfmt.hxx>
37 : : #include <doc.hxx>
38 : : #include <IDocumentUndoRedo.hxx>
39 : : #include <ndtxt.hxx>
40 : : #include <ndnotxt.hxx>
41 : : #include <unocrsr.hxx>
42 : : #include <swundo.hxx>
43 : : #include <rootfrm.hxx>
44 : : #include <flyfrm.hxx>
45 : : #include <ftnidx.hxx>
46 : : #include <sfx2/linkmgr.hxx>
47 : : #include <docary.hxx>
48 : : #include <paratr.hxx>
49 : : #include <pam.hxx>
50 : : #include <tools/cachestr.hxx>
51 : : #include <shellio.hxx>
52 : : #include <swerror.h>
53 : : #include <swtblfmt.hxx>
54 : : #include <docsh.hxx>
55 : : #include <docstyle.hxx>
56 : : #include <charfmt.hxx>
57 : : #include <txtfld.hxx>
58 : : #include <fmtfld.hxx>
59 : : #include <fmtpdsc.hxx>
60 : : #include <pagedesc.hxx>
61 : : #include <poolfmt.hrc>
62 : : #include <poolfmt.hxx>
63 : : #include <edimp.hxx>
64 : : #include <fchrfmt.hxx>
65 : : #include <cntfrm.hxx>
66 : : #include <pagefrm.hxx>
67 : : #include <doctxm.hxx>
68 : : #include <sfx2/docfilt.hxx>
69 : : #include <sfx2/docfile.hxx>
70 : : #include <sfx2/fcontnr.hxx>
71 : : #include <fmtrfmrk.hxx>
72 : : #include <txtrfmrk.hxx>
73 : : #include <unoparaframeenum.hxx>
74 : : #include <unofootnote.hxx>
75 : : #include <unotextbodyhf.hxx>
76 : : #include <unotextrange.hxx>
77 : : #include <unoparagraph.hxx>
78 : : #include <unomap.hxx>
79 : : #include <unoport.hxx>
80 : : #include <unocrsrhelper.hxx>
81 : : #include <unosett.hxx>
82 : : #include <unoprnms.hxx>
83 : : #include <unotbl.hxx>
84 : : #include <unodraw.hxx>
85 : : #include <unocoll.hxx>
86 : : #include <unostyle.hxx>
87 : : #include <unofield.hxx>
88 : : #include <fmtanchr.hxx>
89 : : #include <editeng/flstitem.hxx>
90 : : #include <editeng/unolingu.hxx>
91 : : #include <svtools/ctrltool.hxx>
92 : : #include <flypos.hxx>
93 : : #include <txtftn.hxx>
94 : : #include <fmtftn.hxx>
95 : : #include <fmtcntnt.hxx>
96 : : #include <com/sun/star/text/WrapTextMode.hpp>
97 : : #include <com/sun/star/text/TextContentAnchorType.hpp>
98 : : #include <com/sun/star/style/PageStyleLayout.hpp>
99 : : #include <com/sun/star/text/XTextDocument.hpp>
100 : : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
101 : : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
102 : : #include <unoidx.hxx>
103 : : #include <unoframe.hxx>
104 : : #include <fmthdft.hxx>
105 : : #include <osl/mutex.hxx>
106 : : #include <vcl/svapp.hxx>
107 : : #include <fmtflcnt.hxx>
108 : : #include <editeng/brshitem.hxx>
109 : : #include <fmtclds.hxx>
110 : : #include <dcontact.hxx>
111 : : #include <dflyobj.hxx>
112 : : #include <crsskip.hxx>
113 : : #include <vector>
114 : : #include <sortedobjs.hxx>
115 : : #include <sortopt.hxx>
116 : : #include <algorithm>
117 : : #include <iterator>
118 : : #include <boost/bind.hpp>
119 : : #include <switerator.hxx>
120 : : #include <comphelper/servicehelper.hxx>
121 : :
122 : : using namespace ::com::sun::star;
123 : : using ::rtl::OUString;
124 : :
125 : : namespace sw {
126 : :
127 : 569 : sal_Bool SupportsServiceImpl(
128 : : size_t const nServices, char const*const pServices[],
129 : : ::rtl::OUString const & rServiceName)
130 : : {
131 [ + + ]: 2782 : for (size_t i = 0; i < nServices; ++i)
132 : : {
133 [ + + ]: 2528 : if (rServiceName.equalsAscii(pServices[i]))
134 : : {
135 : 315 : return sal_True;
136 : : }
137 : : }
138 : 569 : return sal_False;
139 : : }
140 : :
141 : : uno::Sequence< ::rtl::OUString >
142 : 40 : GetSupportedServiceNamesImpl(
143 : : size_t const nServices, char const*const pServices[])
144 : : {
145 : 40 : uno::Sequence< ::rtl::OUString > ret(nServices);
146 [ + + ]: 160 : for (size_t i = 0; i < nServices; ++i)
147 : : {
148 [ + - ]: 120 : ret[i] = rtl::OUString::createFromAscii(pServices[i]);
149 : : }
150 : 40 : return ret;
151 : : }
152 : :
153 : : } // namespace sw
154 : :
155 : : namespace sw {
156 : :
157 : 8 : void DeepCopyPaM(SwPaM const & rSource, SwPaM & rTarget)
158 : : {
159 : 8 : rTarget = rSource;
160 : :
161 [ + + ]: 8 : if (rSource.GetNext() != &rSource)
162 : : {
163 : 4 : SwPaM *pPam = static_cast<SwPaM *>(rSource.GetNext());
164 [ + + ]: 70 : do
165 : : {
166 : : // create new PaM
167 [ + - ]: 70 : SwPaM *const pNew = new SwPaM(*pPam);
168 : : // insert into ring
169 : 70 : pNew->MoveTo(&rTarget);
170 : 70 : pPam = static_cast<SwPaM *>(pPam->GetNext());
171 : : }
172 : : while (pPam != &rSource);
173 : : }
174 : 8 : }
175 : :
176 : : } // namespace sw
177 : :
178 : : struct FrameDependSortListLess
179 : : {
180 : 0 : bool operator() (FrameDependSortListEntry const& r1,
181 : : FrameDependSortListEntry const& r2) const
182 : : {
183 : : return (r1.nIndex < r2.nIndex)
184 [ # # ][ # # ]: 0 : || ((r1.nIndex == r2.nIndex) && (r1.nOrder < r2.nOrder));
[ # # ]
185 : : }
186 : : };
187 : :
188 : : // OD 2004-05-07 #i28701# - adjust 4th parameter
189 : 966 : void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx,
190 : : FrameDependSortList_t & rFrames,
191 : : const bool _bAtCharAnchoredObjs )
192 : : {
193 : : // _bAtCharAnchoredObjs:
194 : : // <sal_True>: at-character anchored objects are collected
195 : : // <sal_False>: at-paragraph anchored objects are collected
196 : :
197 : : // alle Rahmen, Grafiken und OLEs suchen, die an diesem Absatz
198 : : // gebunden sind
199 : 966 : SwDoc* pDoc = rIdx.GetNode().GetDoc();
200 : :
201 : : sal_uInt16 nChkType = static_cast< sal_uInt16 >((_bAtCharAnchoredObjs)
202 [ + + ]: 966 : ? FLY_AT_CHAR : FLY_AT_PARA);
203 : : const SwCntntFrm* pCFrm;
204 : : const SwCntntNode* pCNd;
205 [ + + + - : 2890 : if( pDoc->GetCurrentViewShell() && //swmod 071108//swmod 071225
+ - ][ + + ]
206 : 962 : 0 != (pCNd = rIdx.GetNode().GetCntntNode()) &&
207 : 962 : 0 != (pCFrm = pCNd->getLayoutFrm( pDoc->GetCurrentLayout())) )
208 : : {
209 : 962 : const SwSortedObjs *pObjs = pCFrm->GetDrawObjs();
210 [ + + ]: 962 : if( pObjs )
211 [ + + ]: 850 : for( sal_uInt16 i = 0; i < pObjs->Count(); ++i )
212 : : {
213 : 606 : SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
214 : 606 : SwFrmFmt& rFmt = pAnchoredObj->GetFrmFmt();
215 [ + + ]: 606 : if ( rFmt.GetAnchor().GetAnchorId() == nChkType )
216 : : {
217 : : // create SwDepend and insert into array
218 [ + - ][ + - ]: 46 : SwDepend* pNewDepend = new SwDepend( &rClnt, &rFmt );
219 : : xub_StrLen idx =
220 [ + - ][ + - ]: 46 : rFmt.GetAnchor().GetCntntAnchor()->nContent.GetIndex();
221 [ + - ][ + - ]: 46 : sal_uInt32 nOrder = rFmt.GetAnchor().GetOrder();
222 : :
223 : : // OD 2004-05-07 #i28701# - sorting no longer needed,
224 : : // because list <SwSortedObjs> is already sorted.
225 [ + - ]: 46 : FrameDependSortListEntry entry(idx, nOrder, pNewDepend);
226 [ + - ][ + - ]: 46 : rFrames.push_back(entry);
227 : : }
228 : : }
229 : : }
230 : : else
231 : : {
232 : 4 : const SwFrmFmts& rFmts = *pDoc->GetSpzFrmFmts();
233 : 4 : sal_uInt16 nSize = rFmts.size();
234 [ - + ]: 4 : for ( sal_uInt16 i = 0; i < nSize; i++)
235 : : {
236 : 0 : const SwFrmFmt* pFmt = rFmts[ i ];
237 : 0 : const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
238 : : const SwPosition* pAnchorPos;
239 [ # # # # ]: 0 : if( rAnchor.GetAnchorId() == nChkType &&
[ # # ][ # # ]
240 : : 0 != (pAnchorPos = rAnchor.GetCntntAnchor()) &&
241 : 0 : pAnchorPos->nNode == rIdx )
242 : : {
243 : : //jetzt einen SwDepend anlegen und in das Array einfuegen
244 [ # # ][ # # ]: 0 : SwDepend* pNewDepend = new SwDepend( &rClnt, (SwFrmFmt*)pFmt);
245 : :
246 : : // OD 2004-05-07 #i28701# - determine insert position for
247 : : // sorted <rFrameArr>
248 : 0 : xub_StrLen nIndex = pAnchorPos->nContent.GetIndex();
249 [ # # ]: 0 : sal_uInt32 nOrder = rAnchor.GetOrder();
250 : :
251 [ # # ]: 0 : FrameDependSortListEntry entry(nIndex, nOrder, pNewDepend);
252 [ # # ][ # # ]: 0 : rFrames.push_back(entry);
253 : : }
254 : : }
255 [ + - ]: 4 : ::std::sort(rFrames.begin(), rFrames.end(), FrameDependSortListLess());
256 : : }
257 : 966 : }
258 : :
259 : : /****************************************************************************
260 : : ActionContext
261 : : ****************************************************************************/
262 : 39020 : UnoActionContext::UnoActionContext(SwDoc *const pDoc)
263 : 39020 : : m_pDoc(pDoc)
264 : : {
265 : 39020 : SwRootFrm *const pRootFrm = m_pDoc->GetCurrentLayout();
266 [ + + ]: 39020 : if (pRootFrm)
267 : : {
268 : 13008 : pRootFrm->StartAllAction();
269 : : }
270 : 39020 : }
271 : :
272 : 39020 : UnoActionContext::~UnoActionContext()
273 : : {
274 : : // Doc may already have been removed here
275 [ + - ]: 39020 : if (m_pDoc)
276 : : {
277 : 39020 : SwRootFrm *const pRootFrm = m_pDoc->GetCurrentLayout();
278 [ + + ]: 39020 : if (pRootFrm)
279 : : {
280 : 13008 : pRootFrm->EndAllAction();
281 : : }
282 : : }
283 : 39020 : }
284 : :
285 : : /****************************************************************************
286 : : ActionRemoveContext
287 : : ****************************************************************************/
288 : 309 : UnoActionRemoveContext::UnoActionRemoveContext(SwDoc *const pDoc)
289 : 309 : : m_pDoc(pDoc)
290 : : {
291 : 309 : SwRootFrm *const pRootFrm = m_pDoc->GetCurrentLayout();
292 [ + - ]: 309 : if (pRootFrm)
293 : : {
294 : 309 : pRootFrm->UnoRemoveAllActions();
295 : : }
296 : 309 : }
297 : :
298 : 309 : UnoActionRemoveContext::~UnoActionRemoveContext()
299 : : {
300 : 309 : SwRootFrm *const pRootFrm = m_pDoc->GetCurrentLayout();
301 [ + - ]: 309 : if (pRootFrm)
302 : : {
303 : 309 : pRootFrm->UnoRestoreAllActions();
304 : : }
305 : 309 : }
306 : :
307 : 56946 : void ClientModify(SwClient* pClient, const SfxPoolItem *pOld, const SfxPoolItem *pNew)
308 : : {
309 [ + + ]: 56946 : switch( pOld ? pOld->Which() : 0 )
[ + + + ]
310 : : {
311 : : case RES_REMOVE_UNO_OBJECT:
312 : : case RES_OBJECTDYING:
313 [ + + ]: 49993 : if( (void*)pClient->GetRegisteredIn() == ((SwPtrMsgPoolItem *)pOld)->pObject )
314 : 49915 : ((SwModify*)pClient->GetRegisteredIn())->Remove(pClient);
315 : 49993 : break;
316 : :
317 : : case RES_FMT_CHG:
318 : : // wurden wir an das neue umgehaengt und wird das alte geloscht?
319 [ + + + + ]: 1525 : if( ((SwFmtChg*)pNew)->pChangedFmt == pClient->GetRegisteredIn() &&
[ + + ]
320 : 711 : ((SwFmtChg*)pOld)->pChangedFmt->IsFmtInDTOR() )
321 : 705 : ((SwModify*)pClient->GetRegisteredIn())->Remove(pClient);
322 : 814 : break;
323 : : }
324 : 56946 : }
325 : :
326 : 16677 : void SwUnoCursorHelper::SetCrsrAttr(SwPaM & rPam,
327 : : const SfxItemSet& rSet,
328 : : const SetAttrMode nAttrMode, const bool bTableMode)
329 : : {
330 : 16677 : const SetAttrMode nFlags = nAttrMode | nsSetAttrMode::SETATTR_APICALL;
331 : 16677 : SwDoc* pDoc = rPam.GetDoc();
332 : : //StartEndAction
333 [ + - ]: 16677 : UnoActionContext aAction(pDoc);
334 [ + + ]: 16677 : if (rPam.GetNext() != &rPam) // Ring of Cursors
335 : : {
336 [ + - ][ + - ]: 126 : pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSATTR, NULL);
337 : :
338 : 126 : SwPaM *pCurrent = &rPam;
339 [ + + ]: 2520 : do
340 : : {
341 [ + - ][ - + ]: 2520 : if (pCurrent->HasMark() &&
[ # # ][ + - ]
342 : : ( (bTableMode) ||
343 [ # # ]: 0 : (*pCurrent->GetPoint() != *pCurrent->GetMark()) ))
344 : : {
345 [ + - ]: 2520 : pDoc->InsertItemSet(*pCurrent, rSet, nFlags);
346 : : }
347 : 2520 : pCurrent= static_cast<SwPaM *>(pCurrent->GetNext());
348 : : } while (pCurrent != &rPam);
349 : :
350 [ + - ][ + - ]: 126 : pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSATTR, NULL);
351 : : }
352 : : else
353 : : {
354 : : // if( !HasSelection() )
355 : : // UpdateAttr();
356 [ + - ]: 16551 : pDoc->InsertItemSet( rPam, rSet, nFlags );
357 : : }
358 : : //#outline level,add by zhaojianwei
359 [ + - ][ - + ]: 16677 : if( rSet.GetItemState( RES_PARATR_OUTLINELEVEL, false ) >= SFX_ITEM_AVAILABLE )
360 : : {
361 : 0 : SwTxtNode * pTmpNode = rPam.GetNode()->GetTxtNode();
362 [ # # ]: 0 : if ( pTmpNode )
363 : : {
364 [ # # ][ # # ]: 0 : rPam.GetDoc()->GetNodes().UpdateOutlineNode( *pTmpNode );
365 : : }
366 [ + - ]: 16677 : }
367 : : //<-end,zhaojianwei
368 : 16677 : }
369 : :
370 : : // #i63870#
371 : : // split third parameter <bCurrentAttrOnly> into new parameters <bOnlyTxtAttr>
372 : : // and <bGetFromChrFmt> to get better control about resulting <SfxItemSet>
373 : 22950 : void SwUnoCursorHelper::GetCrsrAttr(SwPaM & rPam,
374 : : SfxItemSet & rSet, const bool bOnlyTxtAttr, const bool bGetFromChrFmt)
375 : : {
376 : : static const sal_uInt16 nMaxLookup = 1000;
377 [ + - ]: 22950 : SfxItemSet aSet( *rSet.GetPool(), rSet.GetRanges() );
378 : 22950 : SfxItemSet *pSet = &rSet;
379 : 22950 : SwPaM *pCurrent = & rPam;
380 [ + + ]: 30246 : do
381 : : {
382 [ + - ]: 30246 : SwPosition const & rStart( *pCurrent->Start() );
383 [ + - ]: 30246 : SwPosition const & rEnd( *pCurrent->End() );
384 : 30246 : const sal_uLong nSttNd = rStart.nNode.GetIndex();
385 : 30246 : const sal_uLong nEndNd = rEnd .nNode.GetIndex();
386 : :
387 [ - + ]: 30246 : if (nEndNd - nSttNd >= nMaxLookup)
388 : : {
389 [ # # ]: 0 : rSet.ClearItem();
390 [ # # ]: 0 : rSet.InvalidateAllItems();
391 : 22950 : return;// uno::Any();
392 : : }
393 : :
394 : : // the first node inserts the values into the get set
395 : : // all other nodes merge their values into the get set
396 [ + + ]: 60600 : for (sal_uLong n = nSttNd; n <= nEndNd; ++n)
397 : : {
398 [ + - ][ + - ]: 30354 : SwNode *const pNd = rPam.GetDoc()->GetNodes()[ n ];
399 [ + - - ]: 30354 : switch (pNd->GetNodeType())
400 : : {
401 : : case ND_TEXTNODE:
402 : : {
403 : : const xub_StrLen nStart = (n == nSttNd)
404 [ + + ]: 30354 : ? rStart.nContent.GetIndex() : 0;
405 : : const xub_StrLen nEnd = (n == nEndNd)
406 : 30246 : ? rEnd.nContent.GetIndex()
407 [ + + ][ + - ]: 30354 : : static_cast<SwTxtNode*>(pNd)->GetTxt().Len();
408 : : static_cast<SwTxtNode*>(pNd)->GetAttr(
409 [ + - ][ + - ]: 30354 : *pSet, nStart, nEnd, bOnlyTxtAttr, bGetFromChrFmt);
410 : : }
411 : 30354 : break;
412 : : case ND_GRFNODE:
413 : : case ND_OLENODE:
414 [ # # ][ # # ]: 0 : static_cast<SwCntntNode*>(pNd)->GetAttr( *pSet );
415 : 0 : break;
416 : :
417 : : default:
418 : 0 : continue; // skip this node
419 : : }
420 : :
421 [ + + ]: 30354 : if (pSet != &rSet)
422 : : {
423 [ + - ]: 7404 : rSet.MergeValues( aSet );
424 : : }
425 : : else
426 : : {
427 : 22950 : pSet = &aSet;
428 : : }
429 : :
430 [ + + ]: 30354 : if (aSet.Count())
431 : : {
432 [ + - ]: 5875 : aSet.ClearItem();
433 : : }
434 : : }
435 : 30246 : pCurrent= static_cast<SwPaM *>(pCurrent->GetNext());
436 [ + - ][ + - ]: 22950 : } while ( pCurrent != &rPam );
437 : : }
438 : :
439 : : /******************************************************************
440 : : * SwXParagraphEnumeration
441 : : ******************************************************************/
442 : : class SwXParagraphEnumeration::Impl
443 : : : public SwClient
444 : : {
445 : :
446 : : public:
447 : :
448 : : uno::Reference< text::XText > const m_xParentText;
449 : : const CursorType m_eCursorType;
450 : : /// Start node of the cell _or_ table the enumeration belongs to.
451 : : /// Used to restrict the movement of the UNO cursor to the cell and its
452 : : /// embedded tables.
453 : : SwStartNode const*const m_pOwnStartNode;
454 : : SwTable const*const m_pOwnTable;
455 : : const sal_uLong m_nEndIndex;
456 : : sal_Int32 m_nFirstParaStart;
457 : : sal_Int32 m_nLastParaEnd;
458 : : bool m_bFirstParagraph;
459 : : uno::Reference< text::XTextContent > m_xNextPara;
460 : :
461 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
462 : 1596 : Impl( uno::Reference< text::XText > const& xParent,
463 : : ::std::auto_ptr<SwUnoCrsr> pCursor,
464 : : const CursorType eType,
465 : : SwStartNode const*const pStartNode, SwTable const*const pTable)
466 : 1596 : : SwClient( pCursor.release() )
467 : : , m_xParentText( xParent )
468 : : , m_eCursorType( eType )
469 : : // remember table and start node for later travelling
470 : : // (used in export of tables in tables)
471 : : , m_pOwnStartNode( pStartNode )
472 : : // for import of tables in tables we have to remember the actual
473 : : // table and start node of the current position in the enumeration.
474 : : , m_pOwnTable( pTable )
475 [ + - ]: 1596 : , m_nEndIndex( GetCursor()->End()->nNode.GetIndex() )
476 : : , m_nFirstParaStart( -1 )
477 : : , m_nLastParaEnd( -1 )
478 : 3192 : , m_bFirstParagraph( true )
479 : : {
480 : : OSL_ENSURE(m_xParentText.is(), "SwXParagraphEnumeration: no parent?");
481 : : OSL_ENSURE(GetRegisteredIn(), "SwXParagraphEnumeration: no cursor?");
482 : : OSL_ENSURE( !((CURSOR_SELECTION_IN_TABLE == eType) ||
483 : : (CURSOR_TBLTEXT == eType))
484 : : || (m_pOwnTable && m_pOwnStartNode),
485 : : "SwXParagraphEnumeration: table type but no start node or table?");
486 : :
487 [ + + ][ + + ]: 1596 : if ((CURSOR_SELECTION == m_eCursorType) ||
488 : : (CURSOR_SELECTION_IN_TABLE == m_eCursorType))
489 : : {
490 : 444 : SwUnoCrsr & rCursor = *GetCursor();
491 [ + - ]: 444 : rCursor.Normalize();
492 : 444 : m_nFirstParaStart = rCursor.GetPoint()->nContent.GetIndex();
493 : 444 : m_nLastParaEnd = rCursor.GetMark()->nContent.GetIndex();
494 [ + - ]: 444 : rCursor.DeleteMark();
495 : : }
496 : 1596 : }
497 : : SAL_WNODEPRECATED_DECLARATIONS_POP
498 : :
499 : 1596 : ~Impl() {
500 : : // Impl owns the cursor; delete it here: SolarMutex is locked
501 [ + + ][ + - ]: 1596 : delete GetRegisteredIn();
502 [ - + ]: 3192 : }
503 : :
504 : 6296 : SwUnoCrsr * GetCursor() {
505 : : return static_cast<SwUnoCrsr*>(
506 : 6296 : const_cast<SwModify*>(GetRegisteredIn()));
507 : : }
508 : :
509 : : uno::Reference< text::XTextContent > NextElement_Impl()
510 : : throw (container::NoSuchElementException, lang::WrappedTargetException,
511 : : uno::RuntimeException);
512 : : protected:
513 : : // SwClient
514 : : virtual void Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew);
515 : :
516 : : };
517 : :
518 : 1596 : void SwXParagraphEnumeration::Impl::Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew)
519 : : {
520 : 1596 : ClientModify(this, pOld, pNew);
521 : 1596 : }
522 : :
523 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
524 : 1596 : SwXParagraphEnumeration::SwXParagraphEnumeration(
525 : : uno::Reference< text::XText > const& xParent,
526 : : ::std::auto_ptr<SwUnoCrsr> pCursor,
527 : : const CursorType eType,
528 : : SwStartNode const*const pStartNode, SwTable const*const pTable)
529 : : : m_pImpl( new SwXParagraphEnumeration::Impl(xParent, pCursor, eType,
530 [ + - ][ + - ]: 1596 : pStartNode, pTable) )
[ + - ]
531 : : {
532 : 1596 : }
533 : : SAL_WNODEPRECATED_DECLARATIONS_POP
534 : :
535 [ + - ]: 1596 : SwXParagraphEnumeration::~SwXParagraphEnumeration()
536 : : {
537 [ - + ]: 3192 : }
538 : :
539 : : OUString SAL_CALL
540 : 0 : SwXParagraphEnumeration::getImplementationName() throw (uno::RuntimeException)
541 : : {
542 : 0 : return C2U("SwXParagraphEnumeration");
543 : : }
544 : :
545 : : static char const*const g_ServicesParagraphEnum[] =
546 : : {
547 : : "com.sun.star.text.ParagraphEnumeration",
548 : : };
549 : :
550 : : static const size_t g_nServicesParagraphEnum(
551 : : sizeof(g_ServicesParagraphEnum)/sizeof(g_ServicesParagraphEnum[0]));
552 : :
553 : : sal_Bool SAL_CALL
554 : 0 : SwXParagraphEnumeration::supportsService(const OUString& rServiceName)
555 : : throw (uno::RuntimeException)
556 : : {
557 : : return ::sw::SupportsServiceImpl(
558 : 0 : g_nServicesParagraphEnum, g_ServicesParagraphEnum, rServiceName);
559 : : }
560 : :
561 : : uno::Sequence< OUString > SAL_CALL
562 : 0 : SwXParagraphEnumeration::getSupportedServiceNames()
563 : : throw (uno::RuntimeException)
564 : : {
565 : : return ::sw::GetSupportedServiceNamesImpl(
566 : 0 : g_nServicesParagraphEnum, g_ServicesParagraphEnum);
567 : : }
568 : :
569 : : sal_Bool SAL_CALL
570 : 1007 : SwXParagraphEnumeration::hasMoreElements() throw (uno::RuntimeException)
571 : : {
572 [ + - ]: 1007 : SolarMutexGuard aGuard;
573 : :
574 [ + + ][ + - ]: 1007 : return (m_pImpl->m_bFirstParagraph) ? sal_True : m_pImpl->m_xNextPara.is();
575 : : }
576 : :
577 : : //!! compare to SwShellTableCrsr::FillRects() in viscrs.cxx
578 : : static SwTableNode *
579 : 5855 : lcl_FindTopLevelTable(
580 : : SwTableNode *const pTblNode, SwTable const*const pOwnTable)
581 : : {
582 : : // find top-most table in current context (section) level
583 : :
584 : 5855 : SwTableNode * pLast = pTblNode;
585 [ + + + + ]: 6919 : for (SwTableNode* pTmp = pLast;
[ + + ]
586 : 880 : pTmp != NULL && &pTmp->GetTable() != pOwnTable; /* we must not go up higher than the own table! */
587 : 184 : pTmp = pTmp->StartOfSectionNode()->FindTableNode() )
588 : : {
589 : 184 : pLast = pTmp;
590 : : }
591 : 5855 : return pLast;
592 : : }
593 : :
594 : : static bool
595 : 6117 : lcl_CursorIsInSection(
596 : : SwUnoCrsr const*const pUnoCrsr, SwStartNode const*const pOwnStartNode)
597 : : {
598 : : // returns true if the cursor is in the section (or in a sub section!)
599 : : // represented by pOwnStartNode
600 : :
601 : 6117 : bool bRes = true;
602 [ + - ][ + + ]: 6117 : if (pUnoCrsr && pOwnStartNode)
603 : : {
604 : 1044 : const SwEndNode * pOwnEndNode = pOwnStartNode->EndOfSectionNode();
605 : 1044 : bRes = pOwnStartNode->GetIndex() <= pUnoCrsr->Start()->nNode.GetIndex() &&
606 [ + + ][ + - ]: 1044 : pUnoCrsr->End()->nNode.GetIndex() <= pOwnEndNode->GetIndex();
607 : : }
608 : 6117 : return bRes;
609 : : }
610 : :
611 : : uno::Reference< text::XTextContent >
612 : 4256 : SwXParagraphEnumeration::Impl::NextElement_Impl()
613 : : throw (container::NoSuchElementException, lang::WrappedTargetException,
614 : : uno::RuntimeException)
615 : : {
616 : 4256 : SwUnoCrsr *const pUnoCrsr = GetCursor();
617 [ - + ]: 4256 : if (!pUnoCrsr)
618 : : {
619 [ # # ]: 0 : throw uno::RuntimeException();
620 : : }
621 : :
622 : : // check for exceeding selections
623 [ + + ][ + + ]: 4256 : if (!m_bFirstParagraph &&
[ + + ]
624 : : ((CURSOR_SELECTION == m_eCursorType) ||
625 : : (CURSOR_SELECTION_IN_TABLE == m_eCursorType)))
626 : : {
627 [ + - ]: 444 : SwPosition* pStart = pUnoCrsr->Start();
628 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
629 : : const ::std::auto_ptr<SwUnoCrsr> aNewCrsr(
630 [ + - ]: 444 : pUnoCrsr->GetDoc()->CreateUnoCrsr(*pStart, sal_False) );
631 : : SAL_WNODEPRECATED_DECLARATIONS_POP
632 : : // one may also go into tables here
633 [ + + ][ + - ]: 444 : if ((CURSOR_TBLTEXT != m_eCursorType) &&
634 : : (CURSOR_SELECTION_IN_TABLE != m_eCursorType))
635 : : {
636 : 99 : aNewCrsr->SetRemainInSection( sal_False );
637 : : }
638 : :
639 : : // os 2005-01-14: This part is only necessary to detect movements out
640 : : // of a selection; if there is no selection we don't have to care
641 [ + - ]: 444 : SwTableNode *const pTblNode = aNewCrsr->GetNode()->FindTableNode();
642 [ + - ][ + + ]: 444 : if (((CURSOR_TBLTEXT != m_eCursorType) &&
[ - + ]
643 : : (CURSOR_SELECTION_IN_TABLE != m_eCursorType)) && pTblNode)
644 : : {
645 [ # # ]: 0 : aNewCrsr->GetPoint()->nNode = pTblNode->EndOfSectionIndex();
646 [ # # ]: 0 : aNewCrsr->Move(fnMoveForward, fnGoNode);
647 : : }
648 : : else
649 : : {
650 [ + - ]: 444 : aNewCrsr->MovePara(fnParaNext, fnParaStart);
651 : : }
652 [ + - ][ + + ]: 444 : if (m_nEndIndex < aNewCrsr->Start()->nNode.GetIndex())
653 : : {
654 [ + - ]: 444 : return 0;
655 [ + - ][ + + ]: 444 : }
656 : : }
657 : :
658 : 4184 : sal_Bool bInTable = sal_False;
659 [ + + ]: 4184 : if (!m_bFirstParagraph)
660 : : {
661 : 2598 : pUnoCrsr->SetRemainInSection( sal_False );
662 : : // what to do if already in a table?
663 [ + - ]: 2598 : SwTableNode * pTblNode = pUnoCrsr->GetNode()->FindTableNode();
664 [ + - ]: 2598 : pTblNode = lcl_FindTopLevelTable( pTblNode, m_pOwnTable );
665 [ + + ][ + + ]: 2598 : if (pTblNode && (&pTblNode->GetTable() != m_pOwnTable))
[ + + ]
666 : : {
667 : : // this is a foreign table: go to end
668 [ + - ]: 86 : pUnoCrsr->GetPoint()->nNode = pTblNode->EndOfSectionIndex();
669 [ + - ][ - + ]: 86 : if (!pUnoCrsr->Move(fnMoveForward, fnGoNode))
670 : : {
671 [ # # ]: 0 : return 0;
672 : : }
673 : 86 : bInTable = sal_True;
674 : : }
675 : : }
676 : :
677 : 4184 : uno::Reference< text::XTextContent > xRef;
678 : : // the cursor must remain in the current section or a subsection
679 : : // before AND after the movement...
680 [ + - ][ + + ]: 8629 : if (lcl_CursorIsInSection( pUnoCrsr, m_pOwnStartNode ) &&
[ + + ][ + + ]
[ + + ][ + + ]
[ + - ]
681 : : (m_bFirstParagraph || bInTable ||
682 [ + - ]: 2512 : (pUnoCrsr->MovePara(fnParaNext, fnParaStart) &&
683 [ + - ]: 1933 : lcl_CursorIsInSection( pUnoCrsr, m_pOwnStartNode ))))
684 : : {
685 [ + - ]: 3257 : SwPosition* pStart = pUnoCrsr->Start();
686 : : const sal_Int32 nFirstContent =
687 [ + + ]: 3257 : (m_bFirstParagraph) ? m_nFirstParaStart : -1;
688 : : const sal_Int32 nLastContent =
689 [ + + ]: 3257 : (m_nEndIndex == pStart->nNode.GetIndex()) ? m_nLastParaEnd : -1;
690 : :
691 : : // position in a table, or in a simple paragraph?
692 [ + - ]: 3257 : SwTableNode * pTblNode = pUnoCrsr->GetNode()->FindTableNode();
693 [ + - ]: 3257 : pTblNode = lcl_FindTopLevelTable( pTblNode, m_pOwnTable );
694 [ + + + + ]: 3703 : if (/*CURSOR_TBLTEXT != eCursorType && CURSOR_SELECTION_IN_TABLE != eCursorType && */
[ + + ]
695 : 446 : pTblNode && (&pTblNode->GetTable() != m_pOwnTable))
696 : : {
697 : : // this is a foreign table
698 : : SwFrmFmt* pTableFmt =
699 : 98 : static_cast<SwFrmFmt*>(pTblNode->GetTable().GetFrmFmt());
700 : : text::XTextTable *const pTable =
701 [ + - ]: 98 : SwXTextTables::GetObject( *pTableFmt );
702 : : xRef = static_cast<text::XTextContent*>(
703 [ + - ][ + - ]: 98 : static_cast<SwXTextTable*>(pTable));
[ + - ][ + - ]
704 : : }
705 : : else
706 : : {
707 [ + - ]: 3159 : text::XText *const pText = m_xParentText.get();
708 : 3159 : xRef = SwXParagraph::CreateXParagraph(*pUnoCrsr->GetDoc(),
709 : 3159 : *pStart->nNode.GetNode().GetTxtNode(),
710 [ + - ][ + - ]: 6318 : static_cast<SwXText*>(pText), nFirstContent, nLastContent);
[ + - ]
[ + - + - ]
[ + - ]
711 : : }
712 : : }
713 : :
714 : 4256 : return xRef;
715 : : }
716 : :
717 : 2672 : uno::Any SAL_CALL SwXParagraphEnumeration::nextElement()
718 : : throw (container::NoSuchElementException, lang::WrappedTargetException,
719 : : uno::RuntimeException)
720 : : {
721 [ + - ]: 2672 : SolarMutexGuard aGuard;
722 : :
723 [ + + ]: 2672 : if (m_pImpl->m_bFirstParagraph)
724 : : {
725 [ + - ][ + - ]: 1586 : m_pImpl->m_xNextPara = m_pImpl->NextElement_Impl();
726 : 1586 : m_pImpl->m_bFirstParagraph = false;
727 : : }
728 : 2672 : const uno::Reference< text::XTextContent > xRef = m_pImpl->m_xNextPara;
729 [ + + ]: 2672 : if (!xRef.is())
730 : : {
731 [ + - ]: 2 : throw container::NoSuchElementException();
732 : : }
733 [ + - ][ + - ]: 2670 : m_pImpl->m_xNextPara = m_pImpl->NextElement_Impl();
734 : :
735 : 2670 : uno::Any aRet;
736 [ + - ]: 2670 : aRet <<= xRef;
737 [ + - ]: 2672 : return aRet;
738 : : }
739 : :
740 : : /******************************************************************
741 : : * SwXTextRange
742 : : ******************************************************************/
743 : : class SwXTextRange::Impl
744 : : : public SwClient
745 : : {
746 : :
747 : : public:
748 : :
749 : : const SfxItemPropertySet & m_rPropSet;
750 : : const enum RangePosition m_eRangePosition;
751 : : SwDoc & m_rDoc;
752 : : uno::Reference<text::XText> m_xParentText;
753 : : SwDepend m_ObjectDepend; // register at format of table or frame
754 : : ::sw::mark::IMark * m_pMark;
755 : :
756 : 20284 : Impl( SwDoc & rDoc, const enum RangePosition eRange,
757 : : SwFrmFmt *const pTblFmt = 0,
758 : : const uno::Reference< text::XText > & xParent = 0)
759 : : : SwClient()
760 [ + - ]: 20284 : , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR))
761 : : , m_eRangePosition(eRange)
762 : : , m_rDoc(rDoc)
763 : : , m_xParentText(xParent)
764 : : , m_ObjectDepend(this, pTblFmt)
765 [ + - ]: 40568 : , m_pMark(0)
766 : : {
767 : 20284 : }
768 : :
769 : 40568 : ~Impl()
770 [ + - ]: 20284 : {
771 : : // Impl owns the bookmark; delete it here: SolarMutex is locked
772 [ + - ]: 20284 : Invalidate();
773 [ - + ]: 40568 : }
774 : :
775 : 40629 : void Invalidate()
776 : : {
777 [ + + ]: 40629 : if (m_pMark)
778 : : {
779 : 19575 : m_rDoc.getIDocumentMarkAccess()->deleteMark(m_pMark);
780 : 19575 : m_pMark = 0;
781 : : }
782 : 40629 : }
783 : :
784 : 20350 : const ::sw::mark::IMark * GetBookmark() const { return m_pMark; }
785 : : protected:
786 : : // SwClient
787 : : virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew);
788 : :
789 : : };
790 : :
791 : 20329 : void SwXTextRange::Impl::Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew)
792 : : {
793 : 20329 : const bool bAlreadyRegistered = 0 != GetRegisteredIn();
794 : 20329 : ClientModify(this, pOld, pNew);
795 [ + + ]: 20329 : if (m_ObjectDepend.GetRegisteredIn())
796 : : {
797 : 85 : ClientModify(&m_ObjectDepend, pOld, pNew);
798 : : // if the depend was removed then the range must be removed too
799 [ # # ][ - + ]: 85 : if (!m_ObjectDepend.GetRegisteredIn() && GetRegisteredIn())
[ - + ]
800 : : {
801 : 0 : const_cast<SwModify*>(GetRegisteredIn())->Remove(this);
802 : : }
803 : : // or if the range has been removed but the depend ist still
804 : : // connected then the depend must be removed
805 [ + - ]: 159 : else if (bAlreadyRegistered && !GetRegisteredIn() &&
[ + + + - ]
[ + + ]
806 : 74 : m_ObjectDepend.GetRegisteredIn())
807 : : {
808 : 74 : const_cast<SwModify*>(m_ObjectDepend.GetRegisteredIn())
809 : 74 : ->Remove(& m_ObjectDepend);
810 : : }
811 : : }
812 [ + + ]: 20329 : if (!GetRegisteredIn())
813 : : {
814 : 20318 : m_pMark = 0;
815 : : }
816 : 20329 : }
817 : :
818 : 20210 : SwXTextRange::SwXTextRange(SwPaM& rPam,
819 : : const uno::Reference< text::XText > & xParent,
820 : : const enum RangePosition eRange)
821 [ + - ][ + - ]: 20210 : : m_pImpl( new SwXTextRange::Impl(*rPam.GetDoc(), eRange, 0, xParent) )
822 : : {
823 [ + - ]: 20210 : SetPositions(rPam);
824 : 20210 : }
825 : :
826 : 74 : SwXTextRange::SwXTextRange(SwFrmFmt& rTblFmt)
827 : : : m_pImpl(
828 [ + - ][ + - ]: 74 : new SwXTextRange::Impl(*rTblFmt.GetDoc(), RANGE_IS_TABLE, &rTblFmt) )
[ + - ]
829 : : {
830 [ + - ]: 74 : SwTable *const pTable = SwTable::FindTable( &rTblFmt );
831 [ + - ]: 74 : SwTableNode *const pTblNode = pTable->GetTableNode();
832 [ + - ]: 74 : SwPosition aPosition( *pTblNode );
833 [ + - ]: 74 : SwPaM aPam( aPosition );
834 : :
835 [ + - ][ + - ]: 74 : SetPositions( aPam );
[ + - ]
836 : 74 : }
837 : :
838 [ + - ]: 20284 : SwXTextRange::~SwXTextRange()
839 : : {
840 [ - + ]: 40568 : }
841 : :
842 : 0 : const SwDoc * SwXTextRange::GetDoc() const
843 : : {
844 : 0 : return & m_pImpl->m_rDoc;
845 : : }
846 : :
847 : 17637 : SwDoc * SwXTextRange::GetDoc()
848 : : {
849 : 17637 : return & m_pImpl->m_rDoc;
850 : : }
851 : :
852 : 27 : void SwXTextRange::Invalidate()
853 : : {
854 : 27 : m_pImpl->Invalidate();
855 : 27 : }
856 : :
857 : 20318 : void SwXTextRange::SetPositions(const SwPaM& rPam)
858 : : {
859 : 20318 : m_pImpl->Invalidate();
860 : 20318 : IDocumentMarkAccess* const pMA = m_pImpl->m_rDoc.getIDocumentMarkAccess();
861 : 20318 : m_pImpl->m_pMark = pMA->makeMark(rPam, ::rtl::OUString(),
862 [ + - ]: 20318 : IDocumentMarkAccess::UNO_BOOKMARK);
863 : 20318 : m_pImpl->m_pMark->Add(m_pImpl.get());
864 : 20318 : }
865 : :
866 : 34 : void SwXTextRange::DeleteAndInsert(
867 : : const ::rtl::OUString& rText, const bool bForceExpandHints)
868 : : throw (uno::RuntimeException)
869 : : {
870 [ - + ]: 34 : if (RANGE_IS_TABLE == m_pImpl->m_eRangePosition)
871 : : {
872 : : // setString on table not allowed
873 [ # # ]: 0 : throw uno::RuntimeException();
874 : : }
875 : :
876 [ + - ][ + - ]: 34 : const SwPosition aPos(GetDoc()->GetNodes().GetEndOfContent());
[ + - ]
877 [ + - ]: 34 : SwCursor aCursor(aPos, 0, false);
878 [ + - ][ + - ]: 34 : if (GetPositions(aCursor))
879 : : {
880 [ + - ]: 34 : UnoActionContext aAction(& m_pImpl->m_rDoc);
881 [ + - ][ + - ]: 34 : m_pImpl->m_rDoc.GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL);
882 [ + + ]: 34 : if (aCursor.HasMark())
883 : : {
884 [ + - ]: 18 : m_pImpl->m_rDoc.DeleteAndJoin(aCursor);
885 : : }
886 : :
887 [ + + ]: 34 : if (!rText.isEmpty())
888 : : {
889 : : SwUnoCursorHelper::DocInsertStringSplitCR(
890 [ + - ][ + - ]: 22 : m_pImpl->m_rDoc, aCursor, rText, bForceExpandHints);
[ + - ]
891 : :
892 [ + - ]: 22 : SwUnoCursorHelper::SelectPam(aCursor, true);
893 [ + - ]: 22 : aCursor.Left(rText.getLength(), CRSR_SKIP_CHARS, sal_False, sal_False);
894 : : }
895 [ + - ]: 34 : SetPositions(aCursor);
896 [ + - ][ + - ]: 34 : m_pImpl->m_rDoc.GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL);
[ + - ]
897 [ + - ][ + - ]: 34 : }
898 : 34 : }
899 : :
900 : : namespace
901 : : {
902 : : class theSwXTextRangeUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextRangeUnoTunnelId > {};
903 : : }
904 : :
905 : 69954 : const uno::Sequence< sal_Int8 > & SwXTextRange::getUnoTunnelId()
906 : : {
907 : 69954 : return theSwXTextRangeUnoTunnelId::get().getSeq();
908 : : }
909 : :
910 : : // XUnoTunnel
911 : : sal_Int64 SAL_CALL
912 : 37895 : SwXTextRange::getSomething(const uno::Sequence< sal_Int8 >& rId)
913 : : throw (uno::RuntimeException)
914 : : {
915 : 37895 : return ::sw::UnoTunnelImpl<SwXTextRange>(rId, this);
916 : : }
917 : :
918 : : OUString SAL_CALL
919 : 6 : SwXTextRange::getImplementationName() throw (uno::RuntimeException)
920 : : {
921 : 6 : return OUString(RTL_CONSTASCII_USTRINGPARAM("SwXTextRange"));
922 : : }
923 : :
924 : : static char const*const g_ServicesTextRange[] =
925 : : {
926 : : "com.sun.star.text.TextRange",
927 : : "com.sun.star.style.CharacterProperties",
928 : : "com.sun.star.style.CharacterPropertiesAsian",
929 : : "com.sun.star.style.CharacterPropertiesComplex",
930 : : "com.sun.star.style.ParagraphProperties",
931 : : "com.sun.star.style.ParagraphPropertiesAsian",
932 : : "com.sun.star.style.ParagraphPropertiesComplex",
933 : : };
934 : :
935 : : static const size_t g_nServicesTextRange(
936 : : sizeof(g_ServicesTextRange)/sizeof(g_ServicesTextRange[0]));
937 : :
938 : 10 : sal_Bool SAL_CALL SwXTextRange::supportsService(const OUString& rServiceName)
939 : : throw (uno::RuntimeException)
940 : : {
941 : : return ::sw::SupportsServiceImpl(
942 : 10 : g_nServicesTextRange, g_ServicesTextRange, rServiceName);
943 : : }
944 : :
945 : : uno::Sequence< OUString > SAL_CALL
946 : 0 : SwXTextRange::getSupportedServiceNames() throw (uno::RuntimeException)
947 : : {
948 : : return ::sw::GetSupportedServiceNamesImpl(
949 : 0 : g_nServicesTextRange, g_ServicesTextRange);
950 : : }
951 : :
952 : : uno::Reference< text::XText > SAL_CALL
953 : 4230 : SwXTextRange::getText() throw (uno::RuntimeException)
954 : : {
955 [ + - ]: 4230 : SolarMutexGuard aGuard;
956 : :
957 [ - + ]: 4230 : if (!m_pImpl->m_xParentText.is())
958 : : {
959 [ # # # # ]: 0 : if (m_pImpl->m_eRangePosition == RANGE_IS_TABLE &&
[ # # ]
960 : 0 : m_pImpl->m_ObjectDepend.GetRegisteredIn())
961 : : {
962 : : SwFrmFmt const*const pTblFmt = static_cast<SwFrmFmt const*>(
963 : 0 : m_pImpl->m_ObjectDepend.GetRegisteredIn());
964 [ # # ]: 0 : SwTable const*const pTable = SwTable::FindTable( pTblFmt );
965 [ # # ]: 0 : SwTableNode const*const pTblNode = pTable->GetTableNode();
966 [ # # ]: 0 : const SwPosition aPosition( *pTblNode );
967 : 0 : m_pImpl->m_xParentText =
968 [ # # # # ]: 0 : ::sw::CreateParentXText(m_pImpl->m_rDoc, aPosition);
[ # # ]
969 : : }
970 : : }
971 : : OSL_ENSURE(m_pImpl->m_xParentText.is(), "SwXTextRange::getText: no text");
972 [ + - ]: 4230 : return m_pImpl->m_xParentText;
973 : : }
974 : :
975 : : uno::Reference< text::XTextRange > SAL_CALL
976 : 553 : SwXTextRange::getStart() throw (uno::RuntimeException)
977 : : {
978 [ + - ]: 553 : SolarMutexGuard aGuard;
979 : :
980 : 553 : uno::Reference< text::XTextRange > xRet;
981 : 553 : ::sw::mark::IMark const * const pBkmk = m_pImpl->GetBookmark();
982 [ - + ]: 553 : if (!m_pImpl->m_xParentText.is())
983 : : {
984 [ # # ]: 0 : getText();
985 : : }
986 [ + - ]: 553 : if(pBkmk)
987 : : {
988 [ + - ][ + - ]: 553 : SwPaM aPam(pBkmk->GetMarkStart());
989 [ + - ][ + - ]: 553 : xRet = new SwXTextRange(aPam, m_pImpl->m_xParentText);
[ + - ][ + - ]
990 : : }
991 [ # # ]: 0 : else if (RANGE_IS_TABLE == m_pImpl->m_eRangePosition)
992 : : {
993 : : // start and end are this, if its a table
994 [ # # ]: 0 : xRet = this;
995 : : }
996 : : else
997 : : {
998 [ # # ]: 0 : throw uno::RuntimeException();
999 : : }
1000 [ + - ]: 553 : return xRet;
1001 : : }
1002 : :
1003 : : uno::Reference< text::XTextRange > SAL_CALL
1004 : 2 : SwXTextRange::getEnd() throw (uno::RuntimeException)
1005 : : {
1006 [ + - ]: 2 : SolarMutexGuard aGuard;
1007 : :
1008 : 2 : uno::Reference< text::XTextRange > xRet;
1009 : 2 : ::sw::mark::IMark const * const pBkmk = m_pImpl->GetBookmark();
1010 [ - + ]: 2 : if (!m_pImpl->m_xParentText.is())
1011 : : {
1012 [ # # ]: 0 : getText();
1013 : : }
1014 [ + - ]: 2 : if(pBkmk)
1015 : : {
1016 [ + - ][ + - ]: 2 : SwPaM aPam(pBkmk->GetMarkEnd());
1017 [ + - ][ + - ]: 2 : xRet = new SwXTextRange(aPam, m_pImpl->m_xParentText);
[ + - ][ + - ]
1018 : : }
1019 [ # # ]: 0 : else if (RANGE_IS_TABLE == m_pImpl->m_eRangePosition)
1020 : : {
1021 : : // start and end are this, if its a table
1022 [ # # ]: 0 : xRet = this;
1023 : : }
1024 : : else
1025 : : {
1026 [ # # ]: 0 : throw uno::RuntimeException();
1027 : : }
1028 [ + - ]: 2 : return xRet;
1029 : : }
1030 : :
1031 : 9680 : OUString SAL_CALL SwXTextRange::getString() throw (uno::RuntimeException)
1032 : : {
1033 [ + - ]: 9680 : SolarMutexGuard aGuard;
1034 : :
1035 : 9680 : OUString sRet;
1036 : : // for tables there is no bookmark, thus also no text
1037 : : // one could export the table as ASCII here maybe?
1038 [ + - ][ + - ]: 9680 : SwPaM aPaM(GetDoc()->GetNodes());
[ + - ][ + - ]
[ + - ]
1039 [ + - ][ + - ]: 9680 : if (GetPositions(aPaM) && aPaM.HasMark())
[ + + ][ + + ]
1040 : : {
1041 [ + - ]: 9678 : SwUnoCursorHelper::GetTextFromPam(aPaM, sRet);
1042 : : }
1043 [ + - ][ + - ]: 9680 : return sRet;
1044 : : }
1045 : :
1046 : 34 : void SAL_CALL SwXTextRange::setString(const OUString& rString)
1047 : : throw (uno::RuntimeException)
1048 : : {
1049 [ + - ]: 34 : SolarMutexGuard aGuard;
1050 : :
1051 [ + - ][ + - ]: 34 : DeleteAndInsert(rString, false);
1052 : 34 : }
1053 : :
1054 : 19259 : bool SwXTextRange::GetPositions(SwPaM& rToFill) const
1055 : : {
1056 : 19259 : ::sw::mark::IMark const * const pBkmk = m_pImpl->GetBookmark();
1057 [ + - ]: 19259 : if(pBkmk)
1058 : : {
1059 : 19259 : *rToFill.GetPoint() = pBkmk->GetMarkPos();
1060 [ + + ]: 19259 : if(pBkmk->IsExpanded())
1061 : : {
1062 : 10101 : rToFill.SetMark();
1063 : 10101 : *rToFill.GetMark() = pBkmk->GetOtherMarkPos();
1064 : : }
1065 : : else
1066 : : {
1067 : 9158 : rToFill.DeleteMark();
1068 : : }
1069 : 19259 : return true;
1070 : : }
1071 : 19259 : return false;
1072 : : }
1073 : :
1074 : : namespace sw {
1075 : :
1076 : 16492 : bool XTextRangeToSwPaM( SwUnoInternalPaM & rToFill,
1077 : : const uno::Reference< text::XTextRange > & xTextRange)
1078 : : {
1079 : 16492 : bool bRet = false;
1080 : :
1081 [ + - ]: 16492 : uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
1082 : 16492 : SwXTextRange* pRange = 0;
1083 : 16492 : OTextCursorHelper* pCursor = 0;
1084 : 16492 : SwXTextPortion* pPortion = 0;
1085 : 16492 : SwXText* pText = 0;
1086 : 16492 : SwXParagraph* pPara = 0;
1087 [ + + ]: 16492 : if(xRangeTunnel.is())
1088 : : {
1089 [ + - ]: 16490 : pRange = ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel);
1090 : : pCursor =
1091 [ + - ]: 16490 : ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel);
1092 : : pPortion=
1093 [ + - ]: 16490 : ::sw::UnoTunnelGetImplementation<SwXTextPortion>(xRangeTunnel);
1094 [ + - ]: 16490 : pText = ::sw::UnoTunnelGetImplementation<SwXText>(xRangeTunnel);
1095 [ + - ]: 16490 : pPara = ::sw::UnoTunnelGetImplementation<SwXParagraph>(xRangeTunnel);
1096 : : }
1097 : :
1098 : : // if it's a text then create a temporary cursor there and re-use
1099 : : // the pCursor variable
1100 : : // #i108489#: Reference in outside scope to keep cursor alive
1101 : 16492 : uno::Reference< text::XTextCursor > xTextCursor;
1102 [ - + ]: 16492 : if (pText)
1103 : : {
1104 [ # # ][ # # ]: 0 : xTextCursor.set( pText->CreateCursor() );
1105 [ # # ][ # # ]: 0 : xTextCursor->gotoEnd(sal_True);
1106 : : const uno::Reference<lang::XUnoTunnel> xCrsrTunnel(
1107 [ # # ]: 0 : xTextCursor, uno::UNO_QUERY);
1108 : : pCursor =
1109 [ # # ]: 0 : ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xCrsrTunnel);
1110 : : }
1111 [ + + ][ + - ]: 16492 : if(pRange && pRange->GetDoc() == rToFill.GetDoc())
[ + - ][ + + ]
1112 : : {
1113 [ + - ]: 5912 : bRet = pRange->GetPositions(rToFill);
1114 : : }
1115 : : else
1116 : : {
1117 [ - + ]: 10580 : if (pPara)
1118 : : {
1119 [ # # ]: 0 : bRet = pPara->SelectPaM(rToFill);
1120 : : }
1121 : : else
1122 : : {
1123 : 10578 : SwDoc* const pDoc = (pCursor) ? pCursor->GetDoc()
1124 [ + + ][ + - ]: 10580 : : ((pPortion) ? pPortion->GetCursor()->GetDoc() : 0);
[ - + ]
1125 : 10578 : const SwPaM* const pUnoCrsr = (pCursor) ? pCursor->GetPaM()
1126 [ + + ][ + - ]: 10580 : : ((pPortion) ? pPortion->GetCursor() : 0);
[ - + ][ - + ]
1127 [ + + ][ + - ]: 10580 : if (pUnoCrsr && pDoc == rToFill.GetDoc())
[ + + ]
1128 : : {
1129 : : OSL_ENSURE((SwPaM*)pUnoCrsr->GetNext() == pUnoCrsr,
1130 : : "what to do about rings?");
1131 : 10578 : bRet = true;
1132 [ + - ]: 10578 : *rToFill.GetPoint() = *pUnoCrsr->GetPoint();
1133 [ + + ]: 10578 : if (pUnoCrsr->HasMark())
1134 : : {
1135 [ + - ]: 8771 : rToFill.SetMark();
1136 [ + - ]: 8771 : *rToFill.GetMark() = *pUnoCrsr->GetMark();
1137 : : }
1138 : : else
1139 [ + - ]: 1807 : rToFill.DeleteMark();
1140 : : }
1141 : : }
1142 : : }
1143 : 16492 : return bRet;
1144 : : }
1145 : :
1146 : : static bool
1147 : 0 : lcl_IsStartNodeInFormat(const bool bHeader, SwStartNode *const pSttNode,
1148 : : SwFrmFmt const*const pFrmFmt, SwFrmFmt*& rpFormat)
1149 : : {
1150 : 0 : bool bRet = false;
1151 : 0 : const SfxItemSet& rSet = pFrmFmt->GetAttrSet();
1152 : : const SfxPoolItem* pItem;
1153 [ # # ]: 0 : if (SFX_ITEM_SET == rSet.GetItemState(
1154 : : static_cast<sal_uInt16>(bHeader ? RES_HEADER : RES_FOOTER),
1155 [ # # ][ # # ]: 0 : sal_True, &pItem))
1156 : : {
1157 : 0 : SfxPoolItem *const pItemNonConst(const_cast<SfxPoolItem *>(pItem));
1158 : : SwFrmFmt *const pHeadFootFmt = (bHeader) ?
1159 : : static_cast<SwFmtHeader*>(pItemNonConst)->GetHeaderFmt() :
1160 [ # # ]: 0 : static_cast<SwFmtFooter*>(pItemNonConst)->GetFooterFmt();
1161 [ # # ]: 0 : if (pHeadFootFmt)
1162 : : {
1163 [ # # ]: 0 : const SwFmtCntnt& rFlyCntnt = pHeadFootFmt->GetCntnt();
1164 : 0 : const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode();
1165 : : SwStartNode const*const pCurSttNode = rNode.FindSttNodeByType(
1166 [ # # ][ # # ]: 0 : (bHeader) ? SwHeaderStartNode : SwFooterStartNode);
1167 [ # # ][ # # ]: 0 : if (pCurSttNode && (pCurSttNode == pSttNode))
1168 : : {
1169 : 0 : rpFormat = pHeadFootFmt;
1170 : 0 : bRet = true;
1171 : : }
1172 : : }
1173 : : }
1174 : 0 : return bRet;
1175 : : }
1176 : :
1177 : : } // namespace sw
1178 : :
1179 : : uno::Reference< text::XTextRange >
1180 : 10206 : SwXTextRange::CreateXTextRange(
1181 : : SwDoc & rDoc, const SwPosition& rPos, const SwPosition *const pMark)
1182 : : {
1183 : : const uno::Reference<text::XText> xParentText(
1184 [ + - ]: 10206 : ::sw::CreateParentXText(rDoc, rPos));
1185 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
1186 : : const ::std::auto_ptr<SwUnoCrsr> pNewCrsr(
1187 [ + - ]: 10206 : rDoc.CreateUnoCrsr(rPos, sal_False));
1188 : : SAL_WNODEPRECATED_DECLARATIONS_POP
1189 [ + + ]: 10206 : if(pMark)
1190 : : {
1191 [ + - ]: 9842 : pNewCrsr->SetMark();
1192 [ + - ]: 9842 : *pNewCrsr->GetMark() = *pMark;
1193 : : }
1194 [ + - ][ + - ]: 10206 : const bool isCell( dynamic_cast<SwXCell*>(xParentText.get()) );
[ + + ]
1195 : : const uno::Reference< text::XTextRange > xRet(
1196 : 10206 : new SwXTextRange(*pNewCrsr, xParentText,
1197 [ + - ][ + - ]: 10206 : isCell ? RANGE_IN_CELL : RANGE_IN_TEXT) );
[ + - ][ + + ]
1198 [ + - ]: 10206 : return xRet;
1199 : : }
1200 : :
1201 : : namespace sw {
1202 : :
1203 : : uno::Reference< text::XText >
1204 : 10416 : CreateParentXText(SwDoc & rDoc, const SwPosition& rPos)
1205 : : {
1206 : 10416 : uno::Reference< text::XText > xParentText;
1207 : 10416 : SwStartNode* pSttNode = rPos.nNode.GetNode().StartOfSectionNode();
1208 [ + - ][ + + ]: 10456 : while(pSttNode && pSttNode->IsSectionNode())
[ + + ]
1209 : : {
1210 : 40 : pSttNode = pSttNode->StartOfSectionNode();
1211 : : }
1212 : 10416 : SwStartNodeType eType = pSttNode->GetStartNodeType();
1213 [ + - - - : 10416 : switch(eType)
+ ]
1214 : : {
1215 : : case SwTableBoxStartNode:
1216 : : {
1217 [ + - ]: 344 : SwTableNode const*const pTblNode = pSttNode->FindTableNode();
1218 : : SwFrmFmt *const pTableFmt =
1219 : 344 : static_cast<SwFrmFmt*>(pTblNode->GetTable().GetFrmFmt());
1220 [ + - ]: 344 : SwTableBox *const pBox = pSttNode->GetTblBox();
1221 : :
1222 : : xParentText = (pBox)
1223 : : ? SwXCell::CreateXCell( pTableFmt, pBox )
1224 [ + - ][ + - ]: 344 : : new SwXCell( pTableFmt, *pSttNode );
[ # # ][ + - ]
[ + - ]
1225 : : }
1226 : 344 : break;
1227 : : case SwFlyStartNode:
1228 : : {
1229 [ # # ]: 0 : SwFrmFmt *const pFmt = pSttNode->GetFlyFmt();
1230 [ # # ]: 0 : if (0 != pFmt)
1231 : : {
1232 [ # # ]: 0 : SwXTextFrame* pFrame = SwIterator<SwXTextFrame,SwFmt>::FirstElement( *pFmt );
1233 [ # # ][ # # ]: 0 : xParentText = pFrame ? pFrame : new SwXTextFrame( *pFmt );
[ # # ][ # # ]
[ # # ]
1234 : : }
1235 : : }
1236 : 0 : break;
1237 : : case SwHeaderStartNode:
1238 : : case SwFooterStartNode:
1239 : : {
1240 : 0 : const bool bHeader = (SwHeaderStartNode == eType);
1241 : 0 : const sal_uInt16 nPDescCount = rDoc.GetPageDescCnt();
1242 [ # # ]: 0 : for(sal_uInt16 i = 0; i < nPDescCount; i++)
1243 : : {
1244 [ # # ]: 0 : const SwPageDesc& rDesc = rDoc.GetPageDesc( i );
1245 : 0 : const SwFrmFmt* pFrmFmtMaster = &rDesc.GetMaster();
1246 : 0 : const SwFrmFmt* pFrmFmtLeft = &rDesc.GetLeft();
1247 : :
1248 : 0 : SwFrmFmt* pHeadFootFmt = 0;
1249 [ # # ]: 0 : if (!lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrmFmtMaster,
1250 [ # # ]: 0 : pHeadFootFmt))
1251 : : {
1252 : : lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrmFmtLeft,
1253 [ # # ]: 0 : pHeadFootFmt);
1254 : : }
1255 : :
1256 [ # # ]: 0 : if (pHeadFootFmt)
1257 : : {
1258 : : xParentText = SwXHeadFootText::CreateXHeadFootText(
1259 [ # # ][ # # ]: 0 : *pHeadFootFmt, bHeader);
1260 : : }
1261 : : }
1262 : : }
1263 : 0 : break;
1264 : : case SwFootnoteStartNode:
1265 : : {
1266 : 0 : const sal_uInt16 nFtnCnt = rDoc.GetFtnIdxs().size();
1267 : 0 : uno::Reference< text::XFootnote > xRef;
1268 [ # # ]: 0 : for (sal_uInt16 n = 0; n < nFtnCnt; ++n )
1269 : : {
1270 [ # # ]: 0 : const SwTxtFtn* pTxtFtn = rDoc.GetFtnIdxs()[ n ];
1271 : 0 : const SwFmtFtn& rFtn = pTxtFtn->GetFtn();
1272 : 0 : pTxtFtn = rFtn.GetTxtFtn();
1273 : : #if OSL_DEBUG_LEVEL > 1
1274 : : const SwStartNode* pTmpSttNode =
1275 : : pTxtFtn->GetStartNode()->GetNode().
1276 : : FindSttNodeByType(SwFootnoteStartNode);
1277 : : (void)pTmpSttNode;
1278 : : #endif
1279 : :
1280 [ # # ]: 0 : if (pSttNode == pTxtFtn->GetStartNode()->GetNode().
1281 [ # # ]: 0 : FindSttNodeByType(SwFootnoteStartNode))
1282 : : {
1283 [ # # ][ # # ]: 0 : xParentText = SwXFootnote::CreateXFootnote(rDoc, rFtn);
[ # # ]
1284 : 0 : break;
1285 : : }
1286 : 0 : }
1287 : : }
1288 : 0 : break;
1289 : : default:
1290 : : {
1291 : : // then it is the body text
1292 : : const uno::Reference<frame::XModel> xModel =
1293 [ + - ]: 10072 : rDoc.GetDocShell()->GetBaseModel();
1294 : : const uno::Reference< text::XTextDocument > xDoc(
1295 [ + - ]: 10072 : xModel, uno::UNO_QUERY);
1296 [ + - ][ + - ]: 10072 : xParentText = xDoc->getText();
[ + - ]
1297 : : }
1298 : : }
1299 : : OSL_ENSURE(xParentText.is(), "no parent text?");
1300 : 10416 : return xParentText;
1301 : : }
1302 : :
1303 : : } // namespace sw
1304 : :
1305 : : uno::Reference< container::XEnumeration > SAL_CALL
1306 : 2 : SwXTextRange::createContentEnumeration(const OUString& rServiceName)
1307 : : throw (uno::RuntimeException)
1308 : : {
1309 [ + - ]: 2 : SolarMutexGuard g;
1310 : :
1311 [ - + ]: 2 : if ( rServiceName != "com.sun.star.text.TextContent" )
1312 : : {
1313 [ # # ]: 0 : throw uno::RuntimeException();
1314 : : }
1315 : :
1316 [ + - ][ + - ]: 2 : if (!GetDoc() || !m_pImpl->GetBookmark())
[ - + ][ - + ]
1317 : : {
1318 [ # # ]: 0 : throw uno::RuntimeException();
1319 : : }
1320 [ + - ][ + - ]: 2 : const SwPosition aPos(GetDoc()->GetNodes().GetEndOfContent());
[ + - ]
1321 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
1322 : : const ::std::auto_ptr<SwUnoCrsr> pNewCrsr(
1323 [ + - ]: 2 : m_pImpl->m_rDoc.CreateUnoCrsr(aPos, sal_False));
1324 : : SAL_WNODEPRECATED_DECLARATIONS_POP
1325 [ - + ][ + - ]: 2 : if (!GetPositions(*pNewCrsr))
1326 : : {
1327 [ # # ]: 0 : throw uno::RuntimeException();
1328 : : }
1329 : :
1330 : : const uno::Reference< container::XEnumeration > xRet =
1331 [ + - ][ + - ]: 2 : new SwXParaFrameEnumeration(*pNewCrsr, PARAFRAME_PORTION_TEXTRANGE);
[ + - ]
1332 [ + - ][ + - ]: 2 : return xRet;
[ + - ]
1333 : : }
1334 : :
1335 : : uno::Reference< container::XEnumeration > SAL_CALL
1336 : 0 : SwXTextRange::createEnumeration() throw (uno::RuntimeException)
1337 : : {
1338 [ # # ]: 0 : SolarMutexGuard g;
1339 : :
1340 [ # # ][ # # ]: 0 : if (!GetDoc() || !m_pImpl->GetBookmark())
[ # # ][ # # ]
1341 : : {
1342 [ # # ]: 0 : throw uno::RuntimeException();
1343 : : }
1344 [ # # ][ # # ]: 0 : const SwPosition aPos(GetDoc()->GetNodes().GetEndOfContent());
[ # # ]
1345 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
1346 : : ::std::auto_ptr<SwUnoCrsr> pNewCrsr(
1347 [ # # ]: 0 : m_pImpl->m_rDoc.CreateUnoCrsr(aPos, sal_False));
1348 : : SAL_WNODEPRECATED_DECLARATIONS_POP
1349 [ # # ][ # # ]: 0 : if (!GetPositions(*pNewCrsr))
1350 : : {
1351 [ # # ]: 0 : throw uno::RuntimeException();
1352 : : }
1353 [ # # ]: 0 : if (!m_pImpl->m_xParentText.is())
1354 : : {
1355 [ # # ]: 0 : getText();
1356 : : }
1357 : :
1358 : 0 : const CursorType eSetType = (RANGE_IN_CELL == m_pImpl->m_eRangePosition)
1359 [ # # ]: 0 : ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION;
1360 : : const uno::Reference< container::XEnumeration > xRet =
1361 [ # # ][ # # ]: 0 : new SwXParagraphEnumeration(m_pImpl->m_xParentText, pNewCrsr, eSetType);
[ # # ][ # # ]
1362 [ # # ][ # # ]: 0 : return xRet;
[ # # ]
1363 : : }
1364 : :
1365 : 0 : uno::Type SAL_CALL SwXTextRange::getElementType() throw (uno::RuntimeException)
1366 : : {
1367 : 0 : return text::XTextRange::static_type();
1368 : : }
1369 : :
1370 : 0 : sal_Bool SAL_CALL SwXTextRange::hasElements() throw (uno::RuntimeException)
1371 : : {
1372 : 0 : return sal_True;
1373 : : }
1374 : :
1375 : : uno::Sequence< OUString > SAL_CALL
1376 : 2 : SwXTextRange::getAvailableServiceNames() throw (uno::RuntimeException)
1377 : : {
1378 : 2 : uno::Sequence< OUString > aRet(1);
1379 [ + - ]: 2 : OUString* pArray = aRet.getArray();
1380 [ + - ]: 2 : pArray[0] = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextContent"));
1381 : 2 : return aRet;
1382 : : }
1383 : :
1384 : : uno::Reference< beans::XPropertySetInfo > SAL_CALL
1385 : 338 : SwXTextRange::getPropertySetInfo() throw (uno::RuntimeException)
1386 : : {
1387 [ + - ]: 338 : SolarMutexGuard aGuard;
1388 : :
1389 : : static uno::Reference< beans::XPropertySetInfo > xRef =
1390 [ + + ][ + - ]: 338 : m_pImpl->m_rPropSet.getPropertySetInfo();
[ + - ][ # # ]
1391 [ + - ]: 338 : return xRef;
1392 : : }
1393 : :
1394 : : void SAL_CALL
1395 : 188 : SwXTextRange::setPropertyValue(
1396 : : const OUString& rPropertyName, const uno::Any& rValue)
1397 : : throw (beans::UnknownPropertyException, beans::PropertyVetoException,
1398 : : lang::IllegalArgumentException, lang::WrappedTargetException,
1399 : : uno::RuntimeException)
1400 : : {
1401 [ + - ]: 188 : SolarMutexGuard aGuard;
1402 : :
1403 [ + - ][ + - ]: 188 : if (!GetDoc() || !m_pImpl->GetBookmark())
[ - + ][ - + ]
1404 : : {
1405 [ # # ]: 0 : throw uno::RuntimeException();
1406 : : }
1407 [ + - ][ + - ]: 188 : SwPaM aPaM(GetDoc()->GetNodes());
[ + - ][ + - ]
[ + - ]
1408 [ + - ]: 188 : GetPositions(aPaM);
1409 : 188 : SwUnoCursorHelper::SetPropertyValue(aPaM, m_pImpl->m_rPropSet,
1410 [ + - ][ + - ]: 188 : rPropertyName, rValue);
[ + - ]
1411 : 188 : }
1412 : :
1413 : : uno::Any SAL_CALL
1414 : 292 : SwXTextRange::getPropertyValue(const OUString& rPropertyName)
1415 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
1416 : : uno::RuntimeException)
1417 : : {
1418 [ + - ]: 292 : SolarMutexGuard aGuard;
1419 : :
1420 [ + - ][ + - ]: 292 : if (!GetDoc() || !m_pImpl->GetBookmark())
[ - + ][ - + ]
1421 : : {
1422 [ # # ]: 0 : throw uno::RuntimeException();
1423 : : }
1424 [ + - ][ + - ]: 292 : SwPaM aPaM(GetDoc()->GetNodes());
[ + - ][ + - ]
[ + - ]
1425 [ + - ]: 292 : GetPositions(aPaM);
1426 : 292 : return SwUnoCursorHelper::GetPropertyValue(aPaM, m_pImpl->m_rPropSet,
1427 [ + - ][ + - ]: 292 : rPropertyName);
[ + - ]
1428 : : }
1429 : :
1430 : : void SAL_CALL
1431 : 0 : SwXTextRange::addPropertyChangeListener(
1432 : : const ::rtl::OUString& /*rPropertyName*/,
1433 : : const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
1434 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
1435 : : uno::RuntimeException)
1436 : : {
1437 : : OSL_FAIL("SwXTextRange::addPropertyChangeListener(): not implemented");
1438 : 0 : }
1439 : :
1440 : : void SAL_CALL
1441 : 0 : SwXTextRange::removePropertyChangeListener(
1442 : : const ::rtl::OUString& /*rPropertyName*/,
1443 : : const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
1444 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
1445 : : uno::RuntimeException)
1446 : : {
1447 : : OSL_FAIL("SwXTextRange::removePropertyChangeListener(): not implemented");
1448 : 0 : }
1449 : :
1450 : : void SAL_CALL
1451 : 0 : SwXTextRange::addVetoableChangeListener(
1452 : : const ::rtl::OUString& /*rPropertyName*/,
1453 : : const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
1454 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
1455 : : uno::RuntimeException)
1456 : : {
1457 : : OSL_FAIL("SwXTextRange::addVetoableChangeListener(): not implemented");
1458 : 0 : }
1459 : :
1460 : : void SAL_CALL
1461 : 0 : SwXTextRange::removeVetoableChangeListener(
1462 : : const ::rtl::OUString& /*rPropertyName*/,
1463 : : const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
1464 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
1465 : : uno::RuntimeException)
1466 : : {
1467 : : OSL_FAIL("SwXTextRange::removeVetoableChangeListener(): not implemented");
1468 : 0 : }
1469 : :
1470 : : beans::PropertyState SAL_CALL
1471 : 2 : SwXTextRange::getPropertyState(const OUString& rPropertyName)
1472 : : throw (beans::UnknownPropertyException, uno::RuntimeException)
1473 : : {
1474 [ + - ]: 2 : SolarMutexGuard aGuard;
1475 : :
1476 [ + - ][ + - ]: 2 : if (!GetDoc() || !m_pImpl->GetBookmark())
[ - + ][ - + ]
1477 : : {
1478 [ # # ]: 0 : throw uno::RuntimeException();
1479 : : }
1480 [ + - ][ + - ]: 2 : SwPaM aPaM(GetDoc()->GetNodes());
[ + - ][ + - ]
[ + - ]
1481 [ + - ]: 2 : GetPositions(aPaM);
1482 : 2 : return SwUnoCursorHelper::GetPropertyState(aPaM, m_pImpl->m_rPropSet,
1483 [ + - ][ + - ]: 2 : rPropertyName);
[ + - ]
1484 : : }
1485 : :
1486 : : uno::Sequence< beans::PropertyState > SAL_CALL
1487 : 48 : SwXTextRange::getPropertyStates(const uno::Sequence< OUString >& rPropertyName)
1488 : : throw (beans::UnknownPropertyException, uno::RuntimeException)
1489 : : {
1490 [ + - ]: 48 : SolarMutexGuard g;
1491 : :
1492 [ + - ][ + - ]: 48 : if (!GetDoc() || !m_pImpl->GetBookmark())
[ - + ][ - + ]
1493 : : {
1494 [ # # ]: 0 : throw uno::RuntimeException();
1495 : : }
1496 [ + - ][ + - ]: 48 : SwPaM aPaM(GetDoc()->GetNodes());
[ + - ][ + - ]
[ + - ]
1497 [ + - ]: 48 : GetPositions(aPaM);
1498 : 48 : return SwUnoCursorHelper::GetPropertyStates(aPaM, m_pImpl->m_rPropSet,
1499 [ + - ][ + - ]: 48 : rPropertyName);
[ + - ]
1500 : : }
1501 : :
1502 : 2 : void SAL_CALL SwXTextRange::setPropertyToDefault(const OUString& rPropertyName)
1503 : : throw (beans::UnknownPropertyException, uno::RuntimeException)
1504 : : {
1505 [ + - ]: 2 : SolarMutexGuard aGuard;
1506 : :
1507 [ + - ][ + - ]: 2 : if (!GetDoc() || !m_pImpl->GetBookmark())
[ - + ][ - + ]
1508 : : {
1509 [ # # ]: 0 : throw uno::RuntimeException();
1510 : : }
1511 [ + - ][ + - ]: 2 : SwPaM aPaM(GetDoc()->GetNodes());
[ + - ][ + - ]
[ + - ]
1512 [ + - ]: 2 : GetPositions(aPaM);
1513 : 2 : SwUnoCursorHelper::SetPropertyToDefault(aPaM, m_pImpl->m_rPropSet,
1514 [ + - ][ + - ]: 2 : rPropertyName);
[ + - ]
1515 : 2 : }
1516 : :
1517 : : uno::Any SAL_CALL
1518 : 2 : SwXTextRange::getPropertyDefault(const OUString& rPropertyName)
1519 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
1520 : : uno::RuntimeException)
1521 : : {
1522 [ + - ]: 2 : SolarMutexGuard aGuard;
1523 : :
1524 [ + - ][ + - ]: 2 : if (!GetDoc() || !m_pImpl->GetBookmark())
[ - + ][ - + ]
1525 : : {
1526 [ # # ]: 0 : throw uno::RuntimeException();
1527 : : }
1528 [ + - ][ + - ]: 2 : SwPaM aPaM(GetDoc()->GetNodes());
[ + - ][ + - ]
[ + - ]
1529 [ + - ]: 2 : GetPositions(aPaM);
1530 : 2 : return SwUnoCursorHelper::GetPropertyDefault(aPaM, m_pImpl->m_rPropSet,
1531 [ + - ][ + - ]: 2 : rPropertyName);
[ + - ]
1532 : : }
1533 : :
1534 : : void SAL_CALL
1535 : 0 : SwXTextRange::makeRedline(
1536 : : const ::rtl::OUString& rRedlineType,
1537 : : const uno::Sequence< beans::PropertyValue >& rRedlineProperties )
1538 : : throw (lang::IllegalArgumentException, uno::RuntimeException)
1539 : : {
1540 [ # # ]: 0 : SolarMutexGuard aGuard;
1541 : :
1542 [ # # ][ # # ]: 0 : if (!GetDoc() || !m_pImpl->GetBookmark())
[ # # ][ # # ]
1543 : : {
1544 [ # # ]: 0 : throw uno::RuntimeException();
1545 : : }
1546 [ # # ][ # # ]: 0 : SwPaM aPaM(GetDoc()->GetNodes());
[ # # ][ # # ]
[ # # ]
1547 [ # # ]: 0 : SwXTextRange::GetPositions(aPaM);
1548 [ # # ][ # # ]: 0 : SwUnoCursorHelper::makeRedline( aPaM, rRedlineType, rRedlineProperties );
[ # # ]
1549 : 0 : }
1550 : :
1551 : : /******************************************************************
1552 : : * SwXTextRanges
1553 : : ******************************************************************/
1554 : : class SwXTextRanges::Impl
1555 : : : public SwClient
1556 : : {
1557 : :
1558 : : public:
1559 : :
1560 : : ::std::vector< uno::Reference< text::XTextRange > > m_Ranges;
1561 : :
1562 : 8 : Impl(SwPaM *const pPaM)
1563 : : : SwClient( (pPaM)
1564 : 8 : ? pPaM->GetDoc()->CreateUnoCrsr(*pPaM->GetPoint())
1565 [ + - ][ + - ]: 16 : : 0 )
1566 : : {
1567 [ + - ]: 8 : if (pPaM)
1568 : : {
1569 [ + - ]: 8 : ::sw::DeepCopyPaM(*pPaM, *GetCursor());
1570 : : }
1571 [ + - ]: 8 : MakeRanges();
1572 : 8 : }
1573 : :
1574 : 8 : ~Impl() {
1575 : : // Impl owns the cursor; delete it here: SolarMutex is locked
1576 [ - + ][ # # ]: 8 : delete GetRegisteredIn();
1577 [ - + ]: 16 : }
1578 : :
1579 : 16 : SwUnoCrsr * GetCursor() {
1580 : : return static_cast<SwUnoCrsr*>(
1581 : 16 : const_cast<SwModify*>(GetRegisteredIn()));
1582 : : }
1583 : :
1584 : : void MakeRanges();
1585 : : protected:
1586 : : // SwClient
1587 : : virtual void Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew);
1588 : :
1589 : : };
1590 : :
1591 : 8 : void SwXTextRanges::Impl::Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew)
1592 : : {
1593 : 8 : ClientModify(this, pOld, pNew);
1594 : 8 : }
1595 : :
1596 : 8 : void SwXTextRanges::Impl::MakeRanges()
1597 : : {
1598 : 8 : SwUnoCrsr *const pCursor = GetCursor();
1599 [ + - ]: 8 : if (pCursor)
1600 : : {
1601 [ + - ]: 8 : SwPaM *pTmpCursor = pCursor;
1602 [ + + ][ + - ]: 78 : do {
1603 : : const uno::Reference< text::XTextRange > xRange(
1604 : : SwXTextRange::CreateXTextRange(
1605 : 78 : *pTmpCursor->GetDoc(),
1606 [ + - ]: 156 : *pTmpCursor->GetPoint(), pTmpCursor->GetMark()));
1607 [ + - ]: 78 : if (xRange.is())
1608 : : {
1609 [ + - ]: 78 : m_Ranges.push_back(xRange);
1610 : : }
1611 : 78 : pTmpCursor = static_cast<SwPaM*>(pTmpCursor->GetNext());
1612 : : }
1613 : : while (pTmpCursor != pCursor);
1614 : : }
1615 : 8 : }
1616 : :
1617 : 0 : const SwUnoCrsr* SwXTextRanges::GetCursor() const
1618 : : {
1619 : 0 : return m_pImpl->GetCursor();
1620 : : }
1621 : :
1622 : 8 : SwXTextRanges::SwXTextRanges(SwPaM *const pPaM)
1623 [ + - ][ + - ]: 8 : : m_pImpl( new SwXTextRanges::Impl(pPaM) )
1624 : : {
1625 : 8 : }
1626 : :
1627 [ + - ]: 8 : SwXTextRanges::~SwXTextRanges()
1628 : : {
1629 [ - + ]: 16 : }
1630 : :
1631 : : namespace
1632 : : {
1633 : : class theSwXTextRangesUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextRangesUnoTunnelId > {};
1634 : : }
1635 : :
1636 : 0 : const uno::Sequence< sal_Int8 > & SwXTextRanges::getUnoTunnelId()
1637 : : {
1638 : 0 : return theSwXTextRangesUnoTunnelId::get().getSeq();
1639 : : }
1640 : :
1641 : : sal_Int64 SAL_CALL
1642 : 0 : SwXTextRanges::getSomething(const uno::Sequence< sal_Int8 >& rId)
1643 : : throw (uno::RuntimeException)
1644 : : {
1645 : 0 : return ::sw::UnoTunnelImpl<SwXTextRanges>(rId, this);
1646 : : }
1647 : :
1648 : : /****************************************************************************
1649 : : * Text positions
1650 : : * Bis zum ersten Zugriff auf eine TextPosition wird ein SwCursor gehalten,
1651 : : * danach wird ein Array mit uno::Reference< XTextPosition > angelegt
1652 : : *
1653 : : ****************************************************************************/
1654 : : OUString SAL_CALL
1655 : 0 : SwXTextRanges::getImplementationName() throw (uno::RuntimeException)
1656 : : {
1657 : 0 : return C2U("SwXTextRanges");
1658 : : }
1659 : :
1660 : : static char const*const g_ServicesTextRanges[] =
1661 : : {
1662 : : "com.sun.star.text.TextRanges",
1663 : : };
1664 : :
1665 : : static const size_t g_nServicesTextRanges(
1666 : : sizeof(g_ServicesTextRanges)/sizeof(g_ServicesTextRanges[0]));
1667 : :
1668 : 0 : sal_Bool SAL_CALL SwXTextRanges::supportsService(const OUString& rServiceName)
1669 : : throw (uno::RuntimeException)
1670 : : {
1671 : : return ::sw::SupportsServiceImpl(
1672 : 0 : g_nServicesTextRanges, g_ServicesTextRanges, rServiceName);
1673 : : }
1674 : :
1675 : : uno::Sequence< OUString > SAL_CALL
1676 : 0 : SwXTextRanges::getSupportedServiceNames() throw (uno::RuntimeException)
1677 : : {
1678 : : return ::sw::GetSupportedServiceNamesImpl(
1679 : 0 : g_nServicesTextRanges, g_ServicesTextRanges);
1680 : : }
1681 : :
1682 : 8 : sal_Int32 SAL_CALL SwXTextRanges::getCount() throw (uno::RuntimeException)
1683 : : {
1684 [ + - ]: 8 : SolarMutexGuard aGuard;
1685 : :
1686 [ + - ]: 8 : return static_cast<sal_Int32>(m_pImpl->m_Ranges.size());
1687 : : }
1688 : :
1689 : 10 : uno::Any SAL_CALL SwXTextRanges::getByIndex(sal_Int32 nIndex)
1690 : : throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException,
1691 : : uno::RuntimeException)
1692 : : {
1693 [ + - ]: 10 : SolarMutexGuard aGuard;
1694 : :
1695 [ + - + + ]: 20 : if ((nIndex < 0) ||
[ + + ]
1696 : 10 : (static_cast<size_t>(nIndex) >= m_pImpl->m_Ranges.size()))
1697 : : {
1698 [ + - ]: 2 : throw lang::IndexOutOfBoundsException();
1699 : : }
1700 : 8 : uno::Any ret;
1701 [ + - ][ + - ]: 8 : ret <<= (m_pImpl->m_Ranges.at(nIndex));
1702 [ + - ]: 10 : return ret;
1703 : : }
1704 : :
1705 : : uno::Type SAL_CALL
1706 : 2 : SwXTextRanges::getElementType() throw (uno::RuntimeException)
1707 : : {
1708 : 2 : return text::XTextRange::static_type();
1709 : : }
1710 : :
1711 : 2 : sal_Bool SAL_CALL SwXTextRanges::hasElements() throw (uno::RuntimeException)
1712 : : {
1713 : : // no mutex necessary: getCount() does locking
1714 : 2 : return getCount() > 0;
1715 : : }
1716 : :
1717 : 16 : void SwUnoCursorHelper::SetString(SwCursor & rCursor, const OUString& rString)
1718 : : {
1719 : : // Start/EndAction
1720 : 16 : SwDoc *const pDoc = rCursor.GetDoc();
1721 [ + - ]: 16 : UnoActionContext aAction(pDoc);
1722 [ + - ][ + - ]: 16 : pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL);
1723 [ + + ]: 16 : if (rCursor.HasMark())
1724 : : {
1725 [ + - ]: 14 : pDoc->DeleteAndJoin(rCursor);
1726 : : }
1727 [ + - ]: 16 : if (!rString.isEmpty())
1728 : : {
1729 [ + - ]: 16 : String aText(rString);
1730 : : const bool bSuccess( SwUnoCursorHelper::DocInsertStringSplitCR(
1731 [ + - ]: 16 : *pDoc, rCursor, aText, false ) );
1732 : : OSL_ENSURE( bSuccess, "DocInsertStringSplitCR" );
1733 : : (void) bSuccess;
1734 [ + - ]: 16 : SwUnoCursorHelper::SelectPam(rCursor, true);
1735 [ + - ][ + - ]: 16 : rCursor.Left(rString.getLength(), CRSR_SKIP_CHARS, sal_False, sal_False);
1736 : : }
1737 [ + - ][ + - ]: 16 : pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL);
[ + - ]
1738 : 16 : }
1739 : :
1740 : : /******************************************************************
1741 : : * SwXParaFrameEnumeration
1742 : : ******************************************************************/
1743 : : class SwXParaFrameEnumeration::Impl
1744 : : : public SwClient
1745 : : {
1746 : :
1747 : : public:
1748 : :
1749 : : // created by hasMoreElements
1750 : : uno::Reference< text::XTextContent > m_xNextObject;
1751 : : FrameDependList_t m_Frames;
1752 : :
1753 : 454 : Impl(SwPaM const & rPaM)
1754 [ + - ]: 454 : : SwClient(rPaM.GetDoc()->CreateUnoCrsr(*rPaM.GetPoint(), sal_False))
1755 : : {
1756 [ + + ]: 454 : if (rPaM.HasMark())
1757 : : {
1758 [ + - ]: 275 : GetCursor()->SetMark();
1759 [ + - ]: 275 : *GetCursor()->GetMark() = *rPaM.GetMark();
1760 : : }
1761 : 454 : }
1762 : :
1763 : 454 : ~Impl() {
1764 : : // Impl owns the cursor; delete it here: SolarMutex is locked
1765 [ + + ][ + - ]: 454 : delete GetRegisteredIn();
1766 [ - + ]: 908 : }
1767 : :
1768 : 1883 : SwUnoCrsr * GetCursor() {
1769 : : return static_cast<SwUnoCrsr*>(
1770 : 1883 : const_cast<SwModify*>(GetRegisteredIn()));
1771 : : }
1772 : : protected:
1773 : : // SwClient
1774 : : virtual void Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew);
1775 : :
1776 : : };
1777 : :
1778 : : struct InvalidFrameDepend {
1779 : 0 : bool operator() (::boost::shared_ptr<SwDepend> const & rEntry)
1780 : 0 : { return !rEntry->GetRegisteredIn(); }
1781 : : };
1782 : :
1783 : 454 : void SwXParaFrameEnumeration::Impl::Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew)
1784 : : {
1785 : 454 : ClientModify(this, pOld, pNew);
1786 [ + - ]: 454 : if(!GetRegisteredIn())
1787 : : {
1788 : 454 : m_Frames.clear();
1789 : 454 : m_xNextObject = 0;
1790 : : }
1791 : : else
1792 : : {
1793 : : // check if any frame went away...
1794 : : FrameDependList_t::iterator const iter =
1795 : : ::std::remove_if(m_Frames.begin(), m_Frames.end(),
1796 [ # # ]: 0 : InvalidFrameDepend());
1797 [ # # ]: 0 : m_Frames.erase(iter, m_Frames.end());
1798 : : }
1799 : 454 : }
1800 : :
1801 : : static sal_Bool
1802 : 516 : lcl_CreateNextObject(SwUnoCrsr& i_rUnoCrsr,
1803 : : uno::Reference<text::XTextContent> & o_rNextObject,
1804 : : FrameDependList_t & i_rFrames)
1805 : : {
1806 [ + + ]: 516 : if (!i_rFrames.size())
1807 : 243 : return sal_False;
1808 : :
1809 : : SwFrmFmt *const pFormat = static_cast<SwFrmFmt*>(const_cast<SwModify*>(
1810 : 273 : i_rFrames.front()->GetRegisteredIn()));
1811 : 273 : i_rFrames.pop_front();
1812 : : // the format should be valid here, otherwise the client
1813 : : // would have been removed in ::Modify
1814 : : // check for a shape first
1815 : 273 : SwDrawContact* const pContact = SwIterator<SwDrawContact,SwFmt>::FirstElement( *pFormat );
1816 [ - + ]: 273 : if (pContact)
1817 : : {
1818 : 0 : SdrObject * const pSdr = pContact->GetMaster();
1819 [ # # ]: 0 : if (pSdr)
1820 : : {
1821 [ # # ]: 0 : o_rNextObject.set(pSdr->getUnoShape(), uno::UNO_QUERY);
1822 : : }
1823 : : }
1824 : : else
1825 : : {
1826 [ + - ]: 273 : const SwNodeIndex* pIdx = pFormat->GetCntnt().GetCntntIdx();
1827 : : OSL_ENSURE(pIdx, "where is the index?");
1828 : : SwNode const*const pNd =
1829 [ + - ][ + - ]: 273 : i_rUnoCrsr.GetDoc()->GetNodes()[ pIdx->GetIndex() + 1 ];
1830 : :
1831 : 273 : const FlyCntType eType = (!pNd->IsNoTxtNode()) ? FLYCNTTYPE_FRM
1832 [ - + ][ + + ]: 273 : : ( (pNd->IsGrfNode()) ? FLYCNTTYPE_GRF : FLYCNTTYPE_OLE );
1833 : :
1834 : : const uno::Reference< container::XNamed > xFrame =
1835 [ + - ][ + - ]: 273 : SwXFrames::GetObject(*pFormat, eType);
[ + - ]
1836 [ + - ]: 273 : o_rNextObject.set(xFrame, uno::UNO_QUERY);
1837 : : }
1838 : :
1839 : 516 : return o_rNextObject.is();
1840 : : }
1841 : :
1842 : : /* ---------------------------------------------------------------------------
1843 : : Description: Search for a FLYCNT text attribute at the cursor point
1844 : : and fill the frame into the array
1845 : : ---------------------------------------------------------------------------*/
1846 : : static void
1847 : 231 : lcl_FillFrame(SwClient & rEnum, SwUnoCrsr& rUnoCrsr,
1848 : : FrameDependList_t & rFrames)
1849 : : {
1850 : : // search for objects at the cursor - anchored at/as char
1851 : : SwTxtAttr const*const pTxtAttr =
1852 : : rUnoCrsr.GetNode()->GetTxtNode()->GetTxtAttrForCharAt(
1853 : 231 : rUnoCrsr.GetPoint()->nContent.GetIndex(), RES_TXTATR_FLYCNT);
1854 [ + + ]: 231 : if (pTxtAttr)
1855 : : {
1856 : 227 : const SwFmtFlyCnt& rFlyCnt = pTxtAttr->GetFlyCnt();
1857 : 227 : SwFrmFmt * const pFrmFmt = rFlyCnt.GetFrmFmt();
1858 [ + - ]: 227 : SwDepend * const pNewDepend = new SwDepend(&rEnum, pFrmFmt);
1859 [ + - ]: 227 : rFrames.push_back( ::boost::shared_ptr<SwDepend>(pNewDepend) );
1860 : : }
1861 : 231 : }
1862 : :
1863 : 454 : SwXParaFrameEnumeration::SwXParaFrameEnumeration(
1864 : : const SwPaM& rPaM, const enum ParaFrameMode eParaFrameMode,
1865 : : SwFrmFmt *const pFmt)
1866 [ + - ][ + - ]: 454 : : m_pImpl( new SwXParaFrameEnumeration::Impl(rPaM) )
1867 : : {
1868 [ + + ]: 454 : if (PARAFRAME_PORTION_PARAGRAPH == eParaFrameMode)
1869 : : {
1870 [ + - ]: 177 : FrameDependSortList_t frames;
1871 : 177 : ::CollectFrameAtNode(*m_pImpl.get(), rPaM.GetPoint()->nNode,
1872 [ + - ]: 177 : frames, false);
1873 : : ::std::transform(frames.begin(), frames.end(),
1874 : 177 : ::std::back_inserter(m_pImpl->m_Frames),
1875 [ + - + - ]: 354 : ::boost::bind(&FrameDependSortListEntry::pFrameDepend, _1));
[ + - ]
1876 : : }
1877 [ + + ]: 277 : else if (pFmt)
1878 : : {
1879 : : // create SwDepend for frame and insert into array
1880 [ + - ][ + - ]: 46 : SwDepend *const pNewDepend = new SwDepend(m_pImpl.get(), pFmt);
1881 [ + - ][ + - ]: 46 : m_pImpl->m_Frames.push_back(::boost::shared_ptr<SwDepend>(pNewDepend));
[ + - ]
1882 : : }
1883 [ + + ][ + - ]: 231 : else if ((PARAFRAME_PORTION_CHAR == eParaFrameMode) ||
1884 : : (PARAFRAME_PORTION_TEXTRANGE == eParaFrameMode))
1885 : : {
1886 [ + + ]: 231 : if (PARAFRAME_PORTION_TEXTRANGE == eParaFrameMode)
1887 : : {
1888 [ + - ]: 4 : SwPosFlyFrms aFlyFrms;
1889 : : //get all frames that are bound at paragraph or at character
1890 [ + - ][ + - ]: 4 : rPaM.GetDoc()->GetAllFlyFmts(aFlyFrms, m_pImpl->GetCursor(), sal_False, sal_True);
1891 [ # # ][ + - ]: 4 : for(SwPosFlyFrms::iterator it = aFlyFrms.begin(); it != aFlyFrms.end(); ++it)
[ - + ]
1892 : : {
1893 [ # # ]: 0 : SwPosFlyFrm* pPosFly = *it;
1894 : : SwFrmFmt *const pFrmFmt =
1895 : 0 : const_cast<SwFrmFmt*>(&pPosFly->GetFmt());
1896 : : // create SwDepend for frame and insert into array
1897 : : SwDepend *const pNewDepend =
1898 [ # # ][ # # ]: 0 : new SwDepend(m_pImpl.get(), pFrmFmt);
1899 : 0 : m_pImpl->m_Frames.push_back(
1900 [ # # # # ]: 0 : ::boost::shared_ptr<SwDepend>(pNewDepend) );
[ # # ]
1901 : 4 : }
1902 : : }
1903 [ + - ]: 231 : lcl_FillFrame(*m_pImpl.get(), *m_pImpl->GetCursor(), m_pImpl->m_Frames);
1904 : : }
1905 : 454 : }
1906 : :
1907 [ + - ]: 454 : SwXParaFrameEnumeration::~SwXParaFrameEnumeration()
1908 : : {
1909 [ - + ]: 908 : }
1910 : :
1911 : : sal_Bool SAL_CALL
1912 : 309 : SwXParaFrameEnumeration::hasMoreElements() throw (uno::RuntimeException)
1913 : : {
1914 [ + - ]: 309 : SolarMutexGuard aGuard;
1915 : :
1916 [ - + ]: 309 : if (!m_pImpl->GetCursor())
1917 [ # # ]: 0 : throw uno::RuntimeException();
1918 : :
1919 : 309 : return (m_pImpl->m_xNextObject.is())
1920 : : ? sal_True
1921 : 309 : : lcl_CreateNextObject(*m_pImpl->GetCursor(),
1922 [ + - ][ + - ]: 618 : m_pImpl->m_xNextObject, m_pImpl->m_Frames);
[ + - ]
1923 : : }
1924 : :
1925 : 273 : uno::Any SAL_CALL SwXParaFrameEnumeration::nextElement()
1926 : : throw (container::NoSuchElementException,
1927 : : lang::WrappedTargetException, uno::RuntimeException)
1928 : : {
1929 [ + - ]: 273 : SolarMutexGuard aGuard;
1930 : :
1931 [ - + ]: 273 : if (!m_pImpl->GetCursor())
1932 : : {
1933 [ # # ]: 0 : throw uno::RuntimeException();
1934 : : }
1935 : :
1936 [ + + ][ + - ]: 273 : if (!m_pImpl->m_xNextObject.is() && m_pImpl->m_Frames.size())
[ + + ]
1937 : : {
1938 : 207 : lcl_CreateNextObject(*m_pImpl->GetCursor(),
1939 [ + - ]: 414 : m_pImpl->m_xNextObject, m_pImpl->m_Frames);
1940 : : }
1941 [ - + ]: 273 : if (!m_pImpl->m_xNextObject.is())
1942 : : {
1943 [ # # ]: 0 : throw container::NoSuchElementException();
1944 : : }
1945 : 273 : uno::Any aRet;
1946 [ + - ]: 273 : aRet <<= m_pImpl->m_xNextObject;
1947 [ + - ]: 273 : m_pImpl->m_xNextObject = 0;
1948 [ + - ]: 273 : return aRet;
1949 : : }
1950 : :
1951 : : OUString SAL_CALL
1952 : 0 : SwXParaFrameEnumeration::getImplementationName() throw (uno::RuntimeException)
1953 : : {
1954 : 0 : return C2U("SwXParaFrameEnumeration");
1955 : : }
1956 : :
1957 : : static char const*const g_ServicesParaFrameEnum[] =
1958 : : {
1959 : : "com.sun.star.util.ContentEnumeration",
1960 : : };
1961 : :
1962 : : static const size_t g_nServicesParaFrameEnum(
1963 : : sizeof(g_ServicesParaFrameEnum)/sizeof(g_ServicesParaFrameEnum[0]));
1964 : :
1965 : : sal_Bool SAL_CALL
1966 : 0 : SwXParaFrameEnumeration::supportsService(const OUString& rServiceName)
1967 : : throw (uno::RuntimeException)
1968 : : {
1969 : : return ::sw::SupportsServiceImpl(
1970 : 0 : g_nServicesParaFrameEnum, g_ServicesParaFrameEnum, rServiceName);
1971 : : }
1972 : :
1973 : : uno::Sequence< OUString > SAL_CALL
1974 : 0 : SwXParaFrameEnumeration::getSupportedServiceNames()
1975 : : throw (uno::RuntimeException)
1976 : : {
1977 : : return ::sw::GetSupportedServiceNamesImpl(
1978 : 0 : g_nServicesParaFrameEnum, g_ServicesParaFrameEnum);
1979 [ + - ][ + - ]: 219 : }
1980 : :
1981 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|