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 <com/sun/star/table/TableSortField.hpp>
30 : : #include <comphelper/string.hxx>
31 : : #include <osl/endian.h>
32 : : #include <rtl/ustrbuf.hxx>
33 : : #include <unotools/collatorwrapper.hxx>
34 : : #include <swtypes.hxx>
35 : : #include <hintids.hxx>
36 : : #include <cmdid.h>
37 : : #include <hints.hxx>
38 : : #include <IMark.hxx>
39 : : #include <frmfmt.hxx>
40 : : #include <doc.hxx>
41 : : #include <IDocumentUndoRedo.hxx>
42 : : #include <istyleaccess.hxx>
43 : : #include <ndtxt.hxx>
44 : : #include <ndnotxt.hxx>
45 : : #include <unocrsr.hxx>
46 : : #include <unocrsrhelper.hxx>
47 : : #include <swundo.hxx>
48 : : #include <rootfrm.hxx>
49 : : #include <flyfrm.hxx>
50 : : #include <ftnidx.hxx>
51 : : #include <sfx2/linkmgr.hxx>
52 : : #include <docary.hxx>
53 : : #include <paratr.hxx>
54 : : #include <pam.hxx>
55 : : #include <tools/cachestr.hxx>
56 : : #include <shellio.hxx>
57 : : #include <swerror.h>
58 : : #include <swtblfmt.hxx>
59 : : #include <fmtruby.hxx>
60 : : #include <docsh.hxx>
61 : : #include <docstyle.hxx>
62 : : #include <charfmt.hxx>
63 : : #include <txtfld.hxx>
64 : : #include <fmtfld.hxx>
65 : : #include <fmtpdsc.hxx>
66 : : #include <pagedesc.hxx>
67 : : #include <poolfmt.hrc>
68 : : #include <poolfmt.hxx>
69 : : #include <edimp.hxx>
70 : : #include <fchrfmt.hxx>
71 : : #include <fmtautofmt.hxx>
72 : : #include <cntfrm.hxx>
73 : : #include <pagefrm.hxx>
74 : : #include <doctxm.hxx>
75 : : #include <sfx2/docfilt.hxx>
76 : : #include <sfx2/docfile.hxx>
77 : : #include <sfx2/fcontnr.hxx>
78 : : #include <fmtrfmrk.hxx>
79 : : #include <txtrfmrk.hxx>
80 : : #include <unotextrange.hxx>
81 : : #include <unotextcursor.hxx>
82 : : #include <unomap.hxx>
83 : : #include <unosett.hxx>
84 : : #include <unoprnms.hxx>
85 : : #include <unotbl.hxx>
86 : : #include <unodraw.hxx>
87 : : #include <unocoll.hxx>
88 : : #include <unostyle.hxx>
89 : : #include <unofield.hxx>
90 : : #include <unometa.hxx>
91 : : #include <fmtanchr.hxx>
92 : : #include <editeng/flstitem.hxx>
93 : : #include <svtools/ctrltool.hxx>
94 : : #include <flypos.hxx>
95 : : #include <txtftn.hxx>
96 : : #include <fmtftn.hxx>
97 : : #include <com/sun/star/text/WrapTextMode.hpp>
98 : : #include <com/sun/star/text/TextContentAnchorType.hpp>
99 : : #include <com/sun/star/style/PageStyleLayout.hpp>
100 : : #include <com/sun/star/text/XTextDocument.hpp>
101 : : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
102 : : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
103 : : #include <unoidx.hxx>
104 : : #include <unoframe.hxx>
105 : : #include <fmthdft.hxx>
106 : : #include <osl/mutex.hxx>
107 : : #include <vcl/svapp.hxx>
108 : : #include <fmtflcnt.hxx>
109 : : #include <editeng/brshitem.hxx>
110 : : #include <editeng/unolingu.hxx>
111 : : #include <fmtclds.hxx>
112 : : #include <dcontact.hxx>
113 : : #include <SwStyleNameMapper.hxx>
114 : : #include <crsskip.hxx>
115 : : #include <sortopt.hxx>
116 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
117 : : #include <memory>
118 : : #include <unoparaframeenum.hxx>
119 : : #include <unoparagraph.hxx>
120 : : #include <comphelper/servicehelper.hxx>
121 : :
122 : :
123 : : using namespace ::com::sun::star;
124 : : using ::rtl::OUString;
125 : : using ::rtl::OUStringBuffer;
126 : :
127 : : /****************************************************************************
128 : : Hilfsklassen
129 : : ****************************************************************************/
130 : 16492 : SwUnoInternalPaM::SwUnoInternalPaM(SwDoc& rDoc) :
131 [ + - ]: 16492 : SwPaM(rDoc.GetNodes())
132 : : {
133 : 16492 : }
134 : :
135 : 16492 : SwUnoInternalPaM::~SwUnoInternalPaM()
136 : : {
137 [ - + ]: 16492 : while( GetNext() != this)
138 : : {
139 [ # # ][ # # ]: 0 : delete GetNext();
140 : : }
141 [ - + ]: 16590 : }
142 : :
143 : 0 : SwUnoInternalPaM& SwUnoInternalPaM::operator=(const SwPaM& rPaM)
144 : : {
145 : 0 : const SwPaM* pTmp = &rPaM;
146 : 0 : *GetPoint() = *rPaM.GetPoint();
147 [ # # ]: 0 : if(rPaM.HasMark())
148 : : {
149 : 0 : SetMark();
150 : 0 : *GetMark() = *rPaM.GetMark();
151 : : }
152 : : else
153 : 0 : DeleteMark();
154 [ # # ]: 0 : while(&rPaM != (pTmp = (const SwPaM*)pTmp->GetNext()))
155 : : {
156 [ # # ]: 0 : if(pTmp->HasMark())
157 [ # # ]: 0 : new SwPaM(*pTmp->GetMark(), *pTmp->GetPoint(), this);
158 : : else
159 [ # # ]: 0 : new SwPaM(*pTmp->GetPoint(), this);
160 : : }
161 : 0 : return *this;
162 : : }
163 : :
164 : 29120 : void SwUnoCursorHelper::SelectPam(SwPaM & rPam, const bool bExpand)
165 : : {
166 [ + + ]: 29120 : if (bExpand)
167 : : {
168 [ + + ]: 18664 : if (!rPam.HasMark())
169 : : {
170 : 18203 : rPam.SetMark();
171 : : }
172 : : }
173 [ + + ]: 10456 : else if (rPam.HasMark())
174 : : {
175 : 2808 : rPam.DeleteMark();
176 : : }
177 : 29120 : }
178 : :
179 : 10473 : void SwUnoCursorHelper::GetTextFromPam(SwPaM & rPam, OUString & rBuffer)
180 : : {
181 [ + + ]: 10473 : if (!rPam.HasMark())
182 : : {
183 : 10473 : return;
184 : : }
185 [ + - ]: 10463 : SvCacheStream aStream( 20480 );
186 : : #ifdef OSL_BIGENDIAN
187 : : aStream.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
188 : : #else
189 [ + - ]: 10463 : aStream.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
190 : : #endif
191 : 10463 : WriterRef xWrt;
192 : : // TODO/MBA: looks like a BaseURL doesn't make sense here
193 [ + - ][ + - ]: 10463 : SwReaderWriter::GetWriter( rtl::OUString(FILTER_TEXT_DLG), String(), xWrt );
[ + - ][ + - ]
[ + - ]
194 [ + - ]: 10463 : if( xWrt.Is() )
195 : : {
196 [ + - ]: 10463 : SwWriter aWriter( aStream, rPam );
197 : 10463 : xWrt->bASCII_NoLastLineEnd = sal_True;
198 : 10463 : xWrt->bExportPargraphNumbering = sal_False;
199 [ + - ]: 10463 : SwAsciiOptions aOpt = xWrt->GetAsciiOptions();
200 : 10463 : aOpt.SetCharSet( RTL_TEXTENCODING_UNICODE );
201 [ + - ]: 10463 : xWrt->SetAsciiOptions( aOpt );
202 : 10463 : xWrt->bUCS2_WithStartChar = sal_False;
203 : : // #i68522#
204 : 10463 : const sal_Bool bOldShowProgress = xWrt->bShowProgress;
205 : 10463 : xWrt->bShowProgress = sal_False;
206 : :
207 : : long lLen;
208 [ + - ][ + - ]: 20926 : if( !IsError( aWriter.Write( xWrt ) ) &&
[ + - ][ + - ]
209 [ + - ]: 10463 : 0x7ffffff > (( lLen = aStream.GetSize() )
210 : : / sizeof( sal_Unicode )) + 1 )
211 : : {
212 [ + - ]: 10463 : aStream << (sal_Unicode)'\0';
213 : :
214 [ + - ]: 10463 : aStream.Seek( 0 );
215 [ + - ]: 10463 : aStream.ResetError();
216 : :
217 : 10463 : long lUniLen = (lLen / sizeof( sal_Unicode ));
218 [ + - ]: 10463 : rtl_uString *pStr = comphelper::string::rtl_uString_alloc(lUniLen);
219 [ + - ]: 10463 : aStream.Read(pStr->buffer, lUniLen * sizeof(sal_Unicode));
220 : 10463 : rBuffer = rtl::OUString(pStr, SAL_NO_ACQUIRE);
221 : : }
222 [ + - ][ + - ]: 10463 : xWrt->bShowProgress = bOldShowProgress;
223 [ + - ][ + - ]: 10473 : }
224 : : }
225 : :
226 : : static void
227 : 19 : lcl_setCharStyle(SwDoc *const pDoc, const uno::Any & rValue, SfxItemSet & rSet)
228 : : throw (lang::IllegalArgumentException)
229 : : {
230 : 19 : SwDocShell *const pDocSh = pDoc->GetDocShell();
231 [ + - ]: 19 : if(pDocSh)
232 : : {
233 : 19 : OUString uStyle;
234 [ - + ]: 19 : if (!(rValue >>= uStyle))
235 : : {
236 [ # # ]: 0 : throw lang::IllegalArgumentException();
237 : : }
238 [ + - ]: 19 : String sStyle;
239 : : SwStyleNameMapper::FillUIName(uStyle, sStyle,
240 [ + - ][ + - ]: 19 : nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True);
[ + - ]
241 : : SwDocStyleSheet *const pStyle = static_cast<SwDocStyleSheet*>(
242 [ + - ][ + - ]: 19 : pDocSh->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR));
243 [ - + ]: 19 : if (!pStyle)
244 : : {
245 [ # # ]: 0 : throw lang::IllegalArgumentException();
246 : : }
247 [ + - ][ + - ]: 19 : const SwFmtCharFmt aFmt(pStyle->GetCharFmt());
248 [ + - ][ + - ]: 19 : rSet.Put(aFmt);
[ + - ]
249 : : }
250 : 19 : };
251 : :
252 : : static void
253 : 164 : lcl_setAutoStyle(IStyleAccess & rStyleAccess, const uno::Any & rValue,
254 : : SfxItemSet & rSet, const bool bPara)
255 : : throw (lang::IllegalArgumentException)
256 : : {
257 : 164 : OUString uStyle;
258 [ - + ]: 164 : if (!(rValue >>= uStyle))
259 : : {
260 [ # # ]: 0 : throw lang::IllegalArgumentException();
261 : : }
262 : : StylePool::SfxItemSet_Pointer_t pStyle = bPara ?
263 : 145 : rStyleAccess.getByName(uStyle, IStyleAccess::AUTO_STYLE_PARA ):
264 [ + + ][ + - ]: 164 : rStyleAccess.getByName(uStyle, IStyleAccess::AUTO_STYLE_CHAR );
[ + - ]
265 [ + - ]: 164 : if(pStyle.get())
266 : : {
267 : : SwFmtAutoFmt aFmt( (bPara)
268 : 145 : ? sal::static_int_cast< sal_uInt16 >(RES_AUTO_STYLE)
269 [ + + ][ + - ]: 309 : : sal::static_int_cast< sal_uInt16 >(RES_TXTATR_AUTOFMT) );
270 [ + - ][ + - ]: 164 : aFmt.SetStyleHandle( pStyle );
[ + - ]
271 [ + - ][ + - ]: 164 : rSet.Put(aFmt);
272 : : }
273 : : else
274 : : {
275 [ # # ]: 0 : throw lang::IllegalArgumentException();
276 [ + - ]: 164 : }
277 : 164 : };
278 : :
279 : : void
280 : 2307 : SwUnoCursorHelper::SetTxtFmtColl(const uno::Any & rAny, SwPaM & rPaM)
281 : : throw (lang::IllegalArgumentException)
282 : : {
283 : 2307 : SwDoc *const pDoc = rPaM.GetDoc();
284 : 2307 : SwDocShell *const pDocSh = pDoc->GetDocShell();
285 [ + - ]: 2307 : if(!pDocSh)
286 : 2307 : return;
287 : 2307 : OUString uStyle;
288 : 2307 : rAny >>= uStyle;
289 [ + - ]: 2307 : String sStyle;
290 : : SwStyleNameMapper::FillUIName(uStyle, sStyle,
291 [ + - ][ + - ]: 2307 : nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True );
[ + - ]
292 : : SwDocStyleSheet *const pStyle = static_cast<SwDocStyleSheet*>(
293 [ + - ][ + - ]: 2307 : pDocSh->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_PARA));
294 [ - + ]: 2307 : if (!pStyle)
295 : : {
296 [ # # ]: 0 : throw lang::IllegalArgumentException();
297 : : }
298 : :
299 [ + - ]: 2307 : SwTxtFmtColl *const pLocal = pStyle->GetCollection();
300 [ + - ]: 2307 : UnoActionContext aAction(pDoc);
301 [ + - ][ + - ]: 2307 : pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
302 : 2307 : SwPaM *pTmpCrsr = &rPaM;
303 [ - + ]: 2307 : do {
304 [ + - ]: 2307 : pDoc->SetTxtFmtColl(*pTmpCrsr, pLocal);
305 : 2307 : pTmpCrsr = static_cast<SwPaM*>(pTmpCrsr->GetNext());
306 : : } while ( pTmpCrsr != &rPaM );
307 [ + - ][ + - ]: 2307 : pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
[ + - ][ + - ]
308 : : }
309 : :
310 : : bool
311 : 505 : SwUnoCursorHelper::SetPageDesc(
312 : : const uno::Any& rValue, SwDoc & rDoc, SfxItemSet & rSet)
313 : : {
314 : 505 : OUString uDescName;
315 [ - + ]: 505 : if (!(rValue >>= uDescName))
316 : : {
317 : 0 : return false;
318 : : }
319 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
320 : 505 : ::std::auto_ptr<SwFmtPageDesc> pNewDesc;
321 : : SAL_WNODEPRECATED_DECLARATIONS_POP
322 : : const SfxPoolItem* pItem;
323 [ + + ][ + - ]: 505 : if(SFX_ITEM_SET == rSet.GetItemState( RES_PAGEDESC, sal_True, &pItem ) )
324 : : {
325 : : pNewDesc.reset(new SwFmtPageDesc(
326 [ + - ][ + - ]: 18 : *static_cast<const SwFmtPageDesc*>(pItem)));
327 : : }
328 [ + + ]: 505 : if (!pNewDesc.get())
329 : : {
330 [ + - ][ + - ]: 487 : pNewDesc.reset(new SwFmtPageDesc());
331 : : }
332 [ + - ]: 505 : String sDescName;
333 : : SwStyleNameMapper::FillUIName(uDescName, sDescName,
334 [ + - ][ + - ]: 505 : nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True);
[ + - ]
335 [ - + ][ # # ]: 505 : if (!pNewDesc->GetPageDesc() ||
[ + - ]
336 [ # # ]: 0 : (pNewDesc->GetPageDesc()->GetName() != sDescName))
337 : : {
338 : 505 : sal_Bool bPut = sal_False;
339 [ + - ]: 505 : if(sDescName.Len())
340 : : {
341 : : SwPageDesc *const pPageDesc =
342 [ + - ]: 505 : ::GetPageDescByName_Impl(rDoc, sDescName);
343 [ - + ]: 505 : if (!pPageDesc)
344 : : {
345 [ # # ]: 0 : throw lang::IllegalArgumentException();
346 : : }
347 [ + - ]: 505 : pNewDesc.get()->RegisterToPageDesc( *pPageDesc );
348 : 505 : bPut = sal_True;
349 : : }
350 [ - + ]: 505 : if(!bPut)
351 : : {
352 [ # # ]: 0 : rSet.ClearItem(RES_BREAK);
353 [ # # ][ # # ]: 0 : rSet.Put(SwFmtPageDesc());
[ # # ]
354 : : }
355 : : else
356 : : {
357 [ + - ]: 505 : rSet.Put(*pNewDesc);
358 : : }
359 : : }
360 [ + - ][ + - ]: 505 : return true;
361 : : }
362 : :
363 : : static void
364 : 2 : lcl_SetNodeNumStart(SwPaM & rCrsr, uno::Any const& rValue)
365 : : {
366 : 2 : sal_Int16 nTmp = 1;
367 : 2 : rValue >>= nTmp;
368 [ + - ]: 2 : sal_uInt16 nStt = (nTmp < 0 ? USHRT_MAX : (sal_uInt16)nTmp);
369 : 2 : SwDoc* pDoc = rCrsr.GetDoc();
370 [ + - ]: 2 : UnoActionContext aAction(pDoc);
371 : :
372 [ - + ]: 2 : if( rCrsr.GetNext() != &rCrsr ) // Mehrfachselektion ?
373 : : {
374 [ # # ][ # # ]: 0 : pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
375 [ # # ]: 0 : SwPamRanges aRangeArr( rCrsr );
376 [ # # ]: 0 : SwPaM aPam( *rCrsr.GetPoint() );
377 [ # # ]: 0 : for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n )
378 : : {
379 [ # # ][ # # ]: 0 : pDoc->SetNumRuleStart(*aRangeArr.SetPam( n, aPam ).GetPoint());
380 [ # # ]: 0 : pDoc->SetNodeNumStart(*aRangeArr.SetPam( n, aPam ).GetPoint(),
381 [ # # ]: 0 : nStt );
382 : : }
383 [ # # ][ # # ]: 0 : pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
[ # # ]
384 : : }
385 : : else
386 : : {
387 [ + - ]: 2 : pDoc->SetNumRuleStart( *rCrsr.GetPoint());
388 [ + - ]: 2 : pDoc->SetNodeNumStart( *rCrsr.GetPoint(), nStt );
389 [ + - ]: 2 : }
390 : 2 : }
391 : :
392 : : static bool
393 : 4 : lcl_setCharFmtSequence(SwPaM & rPam, uno::Any const& rValue)
394 : : {
395 [ + - ]: 4 : uno::Sequence<OUString> aCharStyles;
396 [ + - ][ - + ]: 4 : if (!(rValue >>= aCharStyles))
397 : : {
398 : 0 : return false;
399 : : }
400 : :
401 [ + + ]: 8 : for (sal_Int32 nStyle = 0; nStyle < aCharStyles.getLength(); nStyle++)
402 : : {
403 : 4 : uno::Any aStyle;
404 [ + - ][ + - ]: 4 : rPam.GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_START, NULL);
405 [ + - ]: 4 : aStyle <<= aCharStyles.getConstArray()[nStyle];
406 : : // create a local set and apply each format directly
407 : 4 : SfxItemSet aSet(rPam.GetDoc()->GetAttrPool(),
408 [ + - ]: 4 : RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT);
409 [ + - ]: 4 : lcl_setCharStyle(rPam.GetDoc(), aStyle, aSet);
410 : : // the first style should replace the current attributes,
411 : : // all other have to be added
412 : : SwUnoCursorHelper::SetCrsrAttr(rPam, aSet, (nStyle)
413 : : ? nsSetAttrMode::SETATTR_DONTREPLACE
414 [ - + ][ + - ]: 4 : : nsSetAttrMode::SETATTR_DEFAULT);
415 [ + - ][ + - ]: 4 : rPam.GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_START, NULL);
416 [ + - ]: 4 : }
417 [ + - ]: 4 : return true;
418 : : }
419 : :
420 : : static void
421 : 0 : lcl_setDropcapCharStyle(SwPaM & rPam, SfxItemSet & rItemSet,
422 : : uno::Any const& rValue)
423 : : {
424 : 0 : OUString uStyle;
425 [ # # ]: 0 : if (!(rValue >>= uStyle))
426 : : {
427 [ # # ]: 0 : throw lang::IllegalArgumentException();
428 : : }
429 [ # # ]: 0 : String sStyle;
430 : : SwStyleNameMapper::FillUIName(uStyle, sStyle,
431 [ # # ][ # # ]: 0 : nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True);
[ # # ]
432 : 0 : SwDoc *const pDoc = rPam.GetDoc();
433 : : //default character style must not be set as default format
434 : : SwDocStyleSheet *const pStyle = static_cast<SwDocStyleSheet*>(
435 : 0 : pDoc->GetDocShell()
436 [ # # ][ # # ]: 0 : ->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR));
437 [ # # # # ]: 0 : if (!pStyle ||
[ # # ]
438 [ # # ]: 0 : (static_cast<SwDocStyleSheet*>(pStyle)->GetCharFmt() ==
439 : 0 : pDoc->GetDfltCharFmt()))
440 : : {
441 [ # # ]: 0 : throw lang::IllegalArgumentException();
442 : : }
443 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
444 : 0 : ::std::auto_ptr<SwFmtDrop> pDrop;
445 : : SAL_WNODEPRECATED_DECLARATIONS_POP
446 : 0 : SfxPoolItem const* pItem(0);
447 [ # # ]: 0 : if (SFX_ITEM_SET ==
448 [ # # ]: 0 : rItemSet.GetItemState(RES_PARATR_DROP, sal_True, &pItem))
449 : : {
450 [ # # ][ # # ]: 0 : pDrop.reset(new SwFmtDrop(*static_cast<const SwFmtDrop*>(pItem)));
451 : : }
452 [ # # ]: 0 : if (!pDrop.get())
453 : : {
454 [ # # ][ # # ]: 0 : pDrop.reset(new SwFmtDrop);
455 : : }
456 [ # # ]: 0 : const rtl::Reference<SwDocStyleSheet> xStyle(new SwDocStyleSheet(*pStyle));
457 [ # # ][ # # ]: 0 : pDrop->SetCharFmt(xStyle->GetCharFmt());
458 [ # # ][ # # ]: 0 : rItemSet.Put(*pDrop);
[ # # ]
459 : 0 : }
460 : :
461 : : static void
462 : 8 : lcl_setRubyCharstyle(SfxItemSet & rItemSet, uno::Any const& rValue)
463 : : {
464 : 8 : OUString sTmp;
465 [ - + ]: 8 : if (!(rValue >>= sTmp))
466 : : {
467 [ # # ]: 0 : throw lang::IllegalArgumentException();
468 : : }
469 : :
470 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
471 : 8 : ::std::auto_ptr<SwFmtRuby> pRuby;
472 : : SAL_WNODEPRECATED_DECLARATIONS_POP
473 : : const SfxPoolItem* pItem;
474 [ + - ]: 8 : if (SFX_ITEM_SET ==
475 [ + - ]: 8 : rItemSet.GetItemState(RES_TXTATR_CJK_RUBY, sal_True, &pItem))
476 : : {
477 [ + - ][ + - ]: 8 : pRuby.reset(new SwFmtRuby(*static_cast<const SwFmtRuby*>(pItem)));
478 : : }
479 [ - + ]: 8 : if (!pRuby.get())
480 : : {
481 [ # # ][ # # ]: 0 : pRuby.reset(new SwFmtRuby(aEmptyStr));
482 : : }
483 [ + - ]: 8 : String sStyle;
484 : : SwStyleNameMapper::FillUIName(sTmp, sStyle,
485 [ + - ][ + - ]: 8 : nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True );
[ + - ]
486 [ + - ]: 8 : pRuby->SetCharFmtName(sStyle);
487 : 8 : pRuby->SetCharFmtId(0);
488 [ + - ]: 8 : if (sStyle.Len() > 0)
489 : : {
490 : : const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(
491 [ + - ]: 8 : sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT);
492 : 8 : pRuby->SetCharFmtId(nId);
493 : : }
494 [ + - ][ + - ]: 8 : rItemSet.Put(*pRuby);
[ + - ]
495 : 8 : }
496 : :
497 : : bool
498 : 16675 : SwUnoCursorHelper::SetCursorPropertyValue(
499 : : SfxItemPropertySimpleEntry const& rEntry, const uno::Any& rValue,
500 : : SwPaM & rPam, SfxItemSet & rItemSet)
501 : : throw (lang::IllegalArgumentException)
502 : : {
503 [ + + - + ]: 16711 : if (!(rEntry.nFlags & beans::PropertyAttribute::MAYBEVOID) &&
[ - + ]
504 : 36 : (rValue.getValueType() == ::getCppuVoidType()))
505 : : {
506 : 0 : return false;
507 : : }
508 : 16675 : bool bRet = true;
509 [ + + + + : 16675 : switch (rEntry.nWID)
+ - + + +
+ - + +
+ ]
510 : : {
511 : : case RES_TXTATR_CHARFMT:
512 : 15 : lcl_setCharStyle(rPam.GetDoc(), rValue, rItemSet);
513 : 15 : break;
514 : : case RES_TXTATR_AUTOFMT:
515 : 19 : lcl_setAutoStyle(rPam.GetDoc()->GetIStyleAccess(),
516 : 19 : rValue, rItemSet, false);
517 : 19 : break;
518 : : case FN_UNO_CHARFMT_SEQUENCE:
519 : 4 : lcl_setCharFmtSequence(rPam, rValue);
520 : 4 : break;
521 : : case FN_UNO_PARA_STYLE :
522 : 2307 : SwUnoCursorHelper::SetTxtFmtColl(rValue, rPam);
523 : 2307 : break;
524 : : case RES_AUTO_STYLE:
525 : 145 : lcl_setAutoStyle(rPam.GetDoc()->GetIStyleAccess(),
526 : 145 : rValue, rItemSet, true);
527 : 145 : break;
528 : : case FN_UNO_PAGE_STYLE:
529 : : //FIXME nothing here?
530 : 0 : break;
531 : : case FN_UNO_NUM_START_VALUE:
532 : 2 : lcl_SetNodeNumStart( rPam, rValue );
533 : 2 : break;
534 : : case FN_UNO_NUM_LEVEL:
535 : : // #i91601#
536 : : case FN_UNO_LIST_ID:
537 : : case FN_UNO_IS_NUMBER:
538 : : {
539 : : // multi selection is not considered
540 : 180 : SwTxtNode *const pTxtNd = rPam.GetNode()->GetTxtNode();
541 [ + + ]: 180 : if (FN_UNO_NUM_LEVEL == rEntry.nWID)
542 : : {
543 : 117 : sal_Int16 nLevel = 0;
544 [ + - ]: 117 : if (rValue >>= nLevel)
545 : : {
546 [ + - ]: 117 : pTxtNd->SetAttrListLevel(nLevel);
547 : : }
548 : : }
549 : : // #i91601#
550 [ + - ]: 63 : else if (FN_UNO_LIST_ID == rEntry.nWID)
551 : : {
552 : 63 : ::rtl::OUString sListId;
553 [ + - ]: 63 : if (rValue >>= sListId)
554 : : {
555 [ + - ][ + - ]: 63 : pTxtNd->SetListId( sListId );
[ + - ]
556 : 63 : }
557 : : }
558 [ # # ]: 0 : else if (FN_UNO_IS_NUMBER == rEntry.nWID)
559 : : {
560 : 0 : sal_Bool bIsNumber(sal_False);
561 [ # # ]: 0 : if (rValue >>= bIsNumber)
562 : : {
563 [ # # ]: 0 : if (!bIsNumber)
564 : : {
565 [ # # ]: 0 : pTxtNd->SetCountedInList( false );
566 : : }
567 : : }
568 : : }
569 : : //PROPERTY_MAYBEVOID!
570 : : }
571 : 180 : break;
572 : : case FN_NUMBER_NEWSTART:
573 : : {
574 : 2 : sal_Bool bVal = sal_False;
575 [ - + ]: 2 : if (!(rValue >>= bVal))
576 : : {
577 [ # # ]: 0 : throw lang::IllegalArgumentException();
578 : : }
579 [ + - ]: 2 : rPam.GetDoc()->SetNumRuleStart(*rPam.GetPoint(), bVal);
580 : : }
581 : 2 : break;
582 : : case FN_UNO_NUM_RULES:
583 : 129 : SwUnoCursorHelper::setNumberingProperty(rValue, rPam);
584 : 129 : break;
585 : : case RES_PARATR_DROP:
586 : : {
587 [ # # ]: 0 : if (MID_DROPCAP_CHAR_STYLE_NAME == rEntry.nMemberId)
588 : : {
589 : 0 : lcl_setDropcapCharStyle(rPam, rItemSet, rValue);
590 : : }
591 : : else
592 : : {
593 : 0 : bRet = false;
594 : : }
595 : : }
596 : 0 : break;
597 : : case RES_TXTATR_CJK_RUBY:
598 : : {
599 [ + + ]: 176 : if (MID_RUBY_CHARSTYLE == rEntry.nMemberId)
600 : : {
601 : 8 : lcl_setRubyCharstyle(rItemSet, rValue);
602 : : }
603 : : else
604 : : {
605 : 168 : bRet = false;
606 : : }
607 : : }
608 : 176 : break;
609 : : case RES_PAGEDESC:
610 : : {
611 [ + - ]: 505 : if (MID_PAGEDESC_PAGEDESCNAME == rEntry.nMemberId)
612 : : {
613 : : SwUnoCursorHelper::SetPageDesc(
614 : 505 : rValue, *rPam.GetDoc(), rItemSet);
615 : : }
616 : : else
617 : : {
618 : 0 : bRet = false;
619 : : }
620 : : }
621 : 505 : break;
622 : : default:
623 : 13191 : bRet = false;
624 : : }
625 : 16675 : return bRet;
626 : : }
627 : :
628 : : SwFmtColl *
629 : 4 : SwUnoCursorHelper::GetCurTxtFmtColl(SwPaM & rPaM, const bool bConditional)
630 : : {
631 : : static const sal_uInt16 nMaxLookup = 1000;
632 : 4 : SwFmtColl *pFmt = 0;
633 : :
634 : : // if ( GetCrsrCnt() > nMaxLookup )
635 : : // return 0;
636 : 4 : bool bError = false;
637 : 4 : SwPaM *pTmpCrsr = &rPaM;
638 [ - + ]: 4 : do
639 : : {
640 : 4 : const sal_uLong nSttNd = pTmpCrsr->Start()->nNode.GetIndex();
641 : 4 : const sal_uLong nEndNd = pTmpCrsr->End()->nNode.GetIndex();
642 : :
643 [ - + ]: 4 : if( nEndNd - nSttNd >= nMaxLookup )
644 : : {
645 : 0 : pFmt = 0;
646 : 0 : break;
647 : : }
648 : :
649 : 4 : const SwNodes& rNds = rPaM.GetDoc()->GetNodes();
650 [ + + ]: 8 : for( sal_uLong n = nSttNd; n <= nEndNd; ++n )
651 : : {
652 : 4 : SwTxtNode const*const pNd = rNds[ n ]->GetTxtNode();
653 [ + - ]: 4 : if( pNd )
654 : : {
655 : : SwFmtColl *const pNdFmt = (bConditional)
656 [ - + ]: 4 : ? pNd->GetFmtColl() : &pNd->GetAnyFmtColl();
657 [ + - ]: 4 : if( !pFmt )
658 : : {
659 : 4 : pFmt = pNdFmt;
660 : : }
661 [ # # ]: 0 : else if( pFmt != pNdFmt )
662 : : {
663 : 0 : bError = true;
664 : 0 : break;
665 : : }
666 : : }
667 : : }
668 : :
669 : 4 : pTmpCrsr = static_cast<SwPaM*>(pTmpCrsr->GetNext());
670 : : } while ( pTmpCrsr != &rPaM );
671 [ - + ]: 4 : return (bError) ? 0 : pFmt;
672 : : }
673 : :
674 : : /* --------------------------------------------------
675 : : * Hilfsfunktion fuer PageDesc
676 : : * --------------------------------------------------*/
677 : 518 : SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const String& rName)
678 : : {
679 : 518 : SwPageDesc* pRet = 0;
680 : 518 : sal_uInt16 nDCount = rDoc.GetPageDescCnt();
681 : : sal_uInt16 i;
682 : :
683 [ + + ]: 614 : for( i = 0; i < nDCount; i++ )
684 : : {
685 : 609 : SwPageDesc* pDsc = &rDoc.GetPageDesc( i );
686 [ + + ]: 609 : if(pDsc->GetName() == rName)
687 : : {
688 : 513 : pRet = pDsc;
689 : 513 : break;
690 : : }
691 : : }
692 [ + + ]: 518 : if(!pRet)
693 : : {
694 [ + - ]: 29 : for(i = RC_POOLPAGEDESC_BEGIN; i <= STR_POOLPAGE_LANDSCAPE; ++i)
695 : : {
696 [ + - ]: 24 : const String aFmtName(SW_RES(i));
697 [ + - ][ + + ]: 24 : if(aFmtName == rName)
698 : : {
699 : : pRet = rDoc.GetPageDescFromPool( static_cast< sal_uInt16 >(
700 [ + - ]: 24 : RES_POOLPAGE_BEGIN + i - RC_POOLPAGEDESC_BEGIN) );
701 : : break;
702 : : }
703 [ + - ][ + + ]: 24 : }
704 : : }
705 : :
706 : 518 : return pRet;
707 : : }
708 : :
709 : : /******************************************************************
710 : : * SwXTextCursor
711 : : ******************************************************************/
712 : : class SwXTextCursor::Impl
713 : : : public SwClient
714 : : {
715 : :
716 : : public:
717 : :
718 : : const SfxItemPropertySet & m_rPropSet;
719 : : const enum CursorType m_eType;
720 : : const uno::Reference< text::XText > m_xParentText;
721 : : SwEventListenerContainer m_ListenerContainer;
722 : : bool m_bIsDisposed;
723 : :
724 : 13846 : Impl( SwXTextCursor & rThis,
725 : : SwDoc & rDoc,
726 : : const enum CursorType eType,
727 : : uno::Reference<text::XText> xParent,
728 : : SwPosition const& rPoint, SwPosition const*const pMark)
729 : 13846 : : SwClient(rDoc.CreateUnoCrsr(rPoint, sal_False))
730 [ + - ]: 13846 : , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR))
731 : : , m_eType(eType)
732 : : , m_xParentText(xParent)
733 : : , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis))
734 [ + - ]: 27692 : , m_bIsDisposed(false)
735 : : {
736 [ + + ]: 13846 : if (pMark)
737 : : {
738 [ + - ]: 3617 : GetCursor()->SetMark();
739 [ + - ]: 3617 : *GetCursor()->GetMark() = *pMark;
740 : : }
741 : 13846 : }
742 : :
743 [ + - ]: 13846 : ~Impl() {
744 : : // Impl owns the cursor; delete it here: SolarMutex is locked
745 [ + + ][ + - ]: 13846 : delete GetRegisteredIn();
746 [ - + ]: 27692 : }
747 : :
748 : 121802 : SwUnoCrsr * GetCursor() {
749 : : return (m_bIsDisposed) ? 0 :
750 [ - + ]: 121802 : static_cast<SwUnoCrsr*>(const_cast<SwModify*>(GetRegisteredIn()));
751 : : }
752 : :
753 : 37592 : SwUnoCrsr & GetCursorOrThrow() {
754 : 37592 : SwUnoCrsr *const pUnoCursor( GetCursor() );
755 [ - + ]: 37592 : if (!pUnoCursor) {
756 : : throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM(
757 [ # # ][ # # ]: 0 : "SwXTextCursor: disposed or invalid")), 0);
[ # # ]
758 : : }
759 : 37592 : return *pUnoCursor;
760 : : }
761 : :
762 : 14191 : void Invalidate() {
763 : 14191 : m_bIsDisposed = true;
764 : 14191 : m_ListenerContainer.Disposing();
765 : 14191 : }
766 : : protected:
767 : : // SwClient
768 : : virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew);
769 : :
770 : : };
771 : :
772 : 14191 : void SwXTextCursor::Impl::Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew)
773 : : {
774 : 14191 : ClientModify(this, pOld, pNew);
775 : :
776 [ + - + - ]: 14536 : if (!GetRegisteredIn() ||
[ + - ][ + + ]
777 : : // if the cursor leaves its designated section, it becomes invalid
778 : 345 : ((pOld != NULL) && (pOld->Which() == RES_UNOCURSOR_LEAVES_SECTION)))
779 : : {
780 : 14191 : Invalidate();
781 : : }
782 : 14191 : }
783 : :
784 : 0 : SwUnoCrsr const* SwXTextCursor::GetCursor() const
785 : : {
786 : 0 : return m_pImpl->GetCursor();
787 : : }
788 : :
789 : 2384 : SwUnoCrsr * SwXTextCursor::GetCursor()
790 : : {
791 : 2384 : return m_pImpl->GetCursor();
792 : : }
793 : :
794 : 0 : SwPaM const* SwXTextCursor::GetPaM() const
795 : : {
796 [ # # ]: 0 : return m_pImpl->GetCursor();
797 : : }
798 : :
799 : 17841 : SwPaM * SwXTextCursor::GetPaM()
800 : : {
801 [ + - ]: 17841 : return m_pImpl->GetCursor();
802 : : }
803 : :
804 : 0 : SwDoc const* SwXTextCursor::GetDoc() const
805 : : {
806 [ # # ]: 0 : return m_pImpl->GetCursor() ? m_pImpl->GetCursor()->GetDoc() : 0;
807 : : }
808 : :
809 : 24398 : SwDoc * SwXTextCursor::GetDoc()
810 : : {
811 [ + - ]: 24398 : return m_pImpl->GetCursor() ? m_pImpl->GetCursor()->GetDoc() : 0;
812 : : }
813 : :
814 : 13840 : SwXTextCursor::SwXTextCursor(
815 : : SwDoc & rDoc,
816 : : uno::Reference< text::XText > const& xParent,
817 : : const enum CursorType eType,
818 : : const SwPosition& rPos,
819 : : SwPosition const*const pMark)
820 : : : m_pImpl( new SwXTextCursor::Impl(*this, rDoc, eType, xParent,
821 [ + - ][ + - ]: 13840 : rPos, pMark ) )
822 : : {
823 : 13840 : }
824 : :
825 : 6 : SwXTextCursor::SwXTextCursor(uno::Reference< text::XText > const& xParent,
826 : : SwPaM const& rSourceCursor, const enum CursorType eType)
827 : : : m_pImpl( new SwXTextCursor::Impl(*this, *rSourceCursor.GetDoc(), eType,
828 : : xParent, *rSourceCursor.GetPoint(),
829 [ + - ][ + - ]: 6 : rSourceCursor.HasMark() ? rSourceCursor.GetMark() : 0) )
[ + - ]
830 : : {
831 : 6 : }
832 : :
833 [ + - ]: 13846 : SwXTextCursor::~SwXTextCursor()
834 : : {
835 [ - + ]: 27692 : }
836 : :
837 : 7806 : void SwXTextCursor::DeleteAndInsert(const ::rtl::OUString& rText,
838 : : const bool bForceExpandHints)
839 : : {
840 : 7806 : SwUnoCrsr *const pUnoCrsr = m_pImpl->GetCursor();
841 [ + - ]: 7806 : if(pUnoCrsr)
842 : : {
843 : : // Start/EndAction
844 : 7806 : SwDoc* pDoc = pUnoCrsr->GetDoc();
845 [ + - ]: 7806 : UnoActionContext aAction(pDoc);
846 : 7806 : const xub_StrLen nTxtLen = rText.getLength();
847 [ + - ][ + - ]: 7806 : pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL);
848 [ + - ]: 7806 : SwCursor * pCurrent = pUnoCrsr;
849 [ - + ][ + - ]: 7806 : do
850 : : {
851 [ + + ]: 7806 : if (pCurrent->HasMark())
852 : : {
853 [ + - ]: 2422 : pDoc->DeleteAndJoin(*pCurrent);
854 : : }
855 [ + + ]: 7806 : if(nTxtLen)
856 : : {
857 : : const bool bSuccess(
858 : : SwUnoCursorHelper::DocInsertStringSplitCR(
859 [ + - ][ + - ]: 5566 : *pDoc, *pCurrent, rText, bForceExpandHints ) );
[ + - ]
860 : : OSL_ENSURE( bSuccess, "Doc->Insert(Str) failed." );
861 : : (void) bSuccess;
862 : :
863 [ + - ]: 5566 : SwUnoCursorHelper::SelectPam(*pUnoCrsr, true);
864 : 5566 : pCurrent->Left(rText.getLength(),
865 [ + - ]: 5566 : CRSR_SKIP_CHARS, sal_False, sal_False);
866 : : }
867 : 7806 : pCurrent = static_cast<SwCursor *>(pCurrent->GetNext());
868 : : } while (pCurrent != pUnoCrsr);
869 [ + - ][ + - ]: 7806 : pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL);
[ + - ]
870 : : }
871 : 7806 : }
872 : :
873 : : enum ForceIntoMetaMode { META_CHECK_BOTH, META_INIT_START, META_INIT_END };
874 : :
875 : : static sal_Bool
876 : 438 : lcl_ForceIntoMeta(SwPaM & rCursor,
877 : : uno::Reference<text::XText> const & xParentText,
878 : : const enum ForceIntoMetaMode eMode)
879 : : {
880 : 438 : sal_Bool bRet( sal_True ); // means not forced in META_CHECK_BOTH
881 [ + - ][ + - ]: 438 : SwXMeta const * const pXMeta( dynamic_cast<SwXMeta*>(xParentText.get()) );
882 : : OSL_ENSURE(pXMeta, "no parent?");
883 [ - + ]: 438 : if (!pXMeta)
884 [ # # ]: 0 : throw uno::RuntimeException();
885 : : SwTxtNode * pTxtNode;
886 : : xub_StrLen nStart;
887 : : xub_StrLen nEnd;
888 [ + - ]: 438 : const bool bSuccess( pXMeta->SetContentRange(pTxtNode, nStart, nEnd) );
889 : : OSL_ENSURE(bSuccess, "no pam?");
890 [ - + ]: 438 : if (!bSuccess)
891 [ # # ]: 0 : throw uno::RuntimeException();
892 : : // force the cursor back into the meta if it has moved outside
893 [ + - ]: 438 : SwPosition start(*pTxtNode, nStart);
894 [ + - ]: 438 : SwPosition end(*pTxtNode, nEnd);
895 [ + + + - ]: 438 : switch (eMode)
896 : : {
897 : : case META_INIT_START:
898 [ + - ]: 150 : *rCursor.GetPoint() = start;
899 : 150 : break;
900 : : case META_INIT_END:
901 [ + - ]: 228 : *rCursor.GetPoint() = end;
902 : 228 : break;
903 : : case META_CHECK_BOTH:
904 [ + - ][ + - ]: 60 : if (*rCursor.Start() < start)
[ + + ]
905 : : {
906 [ + - ][ + - ]: 12 : *rCursor.Start() = start;
907 : 12 : bRet = sal_False;
908 : : }
909 [ + - ][ + - ]: 60 : if (*rCursor.End() > end)
[ + + ]
910 : : {
911 [ + - ][ + - ]: 10 : *rCursor.End() = end;
912 : 10 : bRet = sal_False;
913 : : }
914 : 60 : break;
915 : : }
916 [ + - ][ + - ]: 438 : return bRet;
917 : : }
918 : :
919 : 354 : bool SwXTextCursor::IsAtEndOfMeta() const
920 : : {
921 [ + + ]: 354 : if (CURSOR_META == m_pImpl->m_eType)
922 : : {
923 : 106 : SwUnoCrsr const * const pCursor( m_pImpl->GetCursor() );
924 : : SwXMeta const*const pXMeta(
925 [ + - ]: 106 : dynamic_cast<SwXMeta*>(m_pImpl->m_xParentText.get()) );
926 : : OSL_ENSURE(pXMeta, "no meta?");
927 [ + - ][ + - ]: 106 : if (pCursor && pXMeta)
928 : : {
929 : : SwTxtNode * pTxtNode;
930 : : xub_StrLen nStart;
931 : : xub_StrLen nEnd;
932 : : const bool bSuccess(
933 [ + - ]: 106 : pXMeta->SetContentRange(pTxtNode, nStart, nEnd) );
934 : : OSL_ENSURE(bSuccess, "no pam?");
935 [ + - ]: 106 : if (bSuccess)
936 : : {
937 [ + - ]: 106 : const SwPosition end(*pTxtNode, nEnd);
938 [ + - ][ + + ]: 152 : if ( (*pCursor->GetPoint() == end)
[ - + ][ + + ]
939 [ + - ]: 46 : || (*pCursor->GetMark() == end))
940 : : {
941 : 106 : return true;
942 [ + - ][ + + ]: 106 : }
943 : : }
944 : : }
945 : : }
946 : 354 : return false;
947 : : }
948 : :
949 : 0 : OUString SwXTextCursor::getImplementationName() throw (uno::RuntimeException)
950 : : {
951 : 0 : return C2U("SwXTextCursor");
952 : : }
953 : :
954 : : static char const*const g_ServicesTextCursor[] =
955 : : {
956 : : "com.sun.star.text.TextCursor",
957 : : "com.sun.star.style.CharacterProperties",
958 : : "com.sun.star.style.CharacterPropertiesAsian",
959 : : "com.sun.star.style.CharacterPropertiesComplex",
960 : : "com.sun.star.style.ParagraphProperties",
961 : : "com.sun.star.style.ParagraphPropertiesAsian",
962 : : "com.sun.star.style.ParagraphPropertiesComplex",
963 : : "com.sun.star.text.TextSortable",
964 : : };
965 : :
966 : : static const size_t g_nServicesTextCursor(
967 : : sizeof(g_ServicesTextCursor)/sizeof(g_ServicesTextCursor[0]));
968 : :
969 : 8 : sal_Bool SAL_CALL SwXTextCursor::supportsService(const OUString& rServiceName)
970 : : throw (uno::RuntimeException)
971 : : {
972 : : return ::sw::SupportsServiceImpl(
973 : 8 : g_nServicesTextCursor, g_ServicesTextCursor, rServiceName);
974 : : }
975 : :
976 : : uno::Sequence< OUString > SAL_CALL
977 : 0 : SwXTextCursor::getSupportedServiceNames() throw (uno::RuntimeException)
978 : : {
979 : : return ::sw::GetSupportedServiceNamesImpl(
980 : 0 : g_nServicesTextCursor, g_ServicesTextCursor);
981 : : }
982 : :
983 : : namespace
984 : : {
985 : : class theSwXTextCursorUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextCursorUnoTunnelId > {};
986 : : }
987 : :
988 : 79363 : const uno::Sequence< sal_Int8 > & SwXTextCursor::getUnoTunnelId()
989 : : {
990 : 79363 : return theSwXTextCursorUnoTunnelId::get().getSeq();
991 : : }
992 : :
993 : : sal_Int64 SAL_CALL
994 : 77934 : SwXTextCursor::getSomething(const uno::Sequence< sal_Int8 >& rId)
995 : : throw (uno::RuntimeException)
996 : : {
997 : 77934 : const sal_Int64 nRet( ::sw::UnoTunnelImpl<SwXTextCursor>(rId, this) );
998 [ + + ]: 77934 : return (nRet) ? nRet : OTextCursorHelper::getSomething(rId);
999 : : }
1000 : :
1001 : 2 : void SAL_CALL SwXTextCursor::collapseToStart() throw (uno::RuntimeException)
1002 : : {
1003 [ + - ]: 2 : SolarMutexGuard aGuard;
1004 : :
1005 [ + - ]: 2 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1006 : :
1007 [ + - ]: 2 : if (rUnoCursor.HasMark())
1008 : : {
1009 [ + - ][ + - ]: 2 : if (*rUnoCursor.GetPoint() > *rUnoCursor.GetMark())
1010 : : {
1011 : 2 : rUnoCursor.Exchange();
1012 : : }
1013 [ + - ]: 2 : rUnoCursor.DeleteMark();
1014 [ + - ]: 2 : }
1015 : 2 : }
1016 : :
1017 : 4 : void SAL_CALL SwXTextCursor::collapseToEnd() throw (uno::RuntimeException)
1018 : : {
1019 [ + - ]: 4 : SolarMutexGuard aGuard;
1020 : :
1021 [ + - ]: 4 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1022 : :
1023 [ + + ]: 4 : if (rUnoCursor.HasMark())
1024 : : {
1025 [ + - ][ - + ]: 2 : if (*rUnoCursor.GetPoint() < *rUnoCursor.GetMark())
1026 : : {
1027 : 0 : rUnoCursor.Exchange();
1028 : : }
1029 [ + - ]: 2 : rUnoCursor.DeleteMark();
1030 [ + - ]: 4 : }
1031 : 4 : }
1032 : :
1033 : 43 : sal_Bool SAL_CALL SwXTextCursor::isCollapsed() throw (uno::RuntimeException)
1034 : : {
1035 [ + - ]: 43 : SolarMutexGuard aGuard;
1036 : :
1037 : 43 : sal_Bool bRet = sal_True;
1038 : 43 : SwUnoCrsr *const pUnoCrsr = m_pImpl->GetCursor();
1039 [ + - ][ + - ]: 43 : if(pUnoCrsr && pUnoCrsr->GetMark())
[ + - ]
1040 : : {
1041 [ + - ]: 43 : bRet = (*pUnoCrsr->GetPoint() == *pUnoCrsr->GetMark());
1042 : : }
1043 [ + - ]: 43 : return bRet;
1044 : : }
1045 : :
1046 : : sal_Bool SAL_CALL
1047 : 2210 : SwXTextCursor::goLeft(sal_Int16 nCount, sal_Bool Expand)
1048 : : throw (uno::RuntimeException)
1049 : : {
1050 [ + - ]: 2210 : SolarMutexGuard aGuard;
1051 : :
1052 [ + - ]: 2210 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1053 : :
1054 [ + - ]: 2210 : SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1055 [ + - ]: 2210 : sal_Bool bRet = rUnoCursor.Left( nCount, CRSR_SKIP_CHARS, sal_False, sal_False);
1056 [ + + ]: 2210 : if (CURSOR_META == m_pImpl->m_eType)
1057 : : {
1058 : 8 : bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText,
1059 [ + - ]: 8 : META_CHECK_BOTH)
1060 [ + + ][ + - ]: 8 : && bRet;
1061 : : }
1062 [ + - ]: 2210 : return bRet;
1063 : : }
1064 : :
1065 : : sal_Bool SAL_CALL
1066 : 4434 : SwXTextCursor::goRight(sal_Int16 nCount, sal_Bool Expand)
1067 : : throw (uno::RuntimeException)
1068 : : {
1069 [ + - ]: 4434 : SolarMutexGuard aGuard;
1070 : :
1071 [ + - ]: 4434 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1072 : :
1073 [ + - ]: 4434 : SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1074 [ + - ]: 4434 : sal_Bool bRet = rUnoCursor.Right(nCount, CRSR_SKIP_CHARS, sal_False, sal_False);
1075 [ + + ]: 4434 : if (CURSOR_META == m_pImpl->m_eType)
1076 : : {
1077 : 8 : bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText,
1078 [ + - ]: 8 : META_CHECK_BOTH)
1079 [ + + ][ + - ]: 8 : && bRet;
1080 : : }
1081 [ + - ]: 4434 : return bRet;
1082 : : }
1083 : :
1084 : : void SAL_CALL
1085 : 2408 : SwXTextCursor::gotoStart(sal_Bool Expand) throw (uno::RuntimeException)
1086 : : {
1087 [ + - ]: 2408 : SolarMutexGuard aGuard;
1088 : :
1089 [ + - ]: 2408 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1090 : :
1091 [ + - ]: 2408 : SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1092 [ + + ]: 2408 : if (CURSOR_BODY == m_pImpl->m_eType)
1093 : : {
1094 [ + - ]: 2217 : rUnoCursor.Move( fnMoveBackward, fnGoDoc );
1095 : : //check, that the cursor is not in a table
1096 [ + - ]: 2217 : SwTableNode * pTblNode = rUnoCursor.GetNode()->FindTableNode();
1097 : 2217 : SwCntntNode * pCNode = 0;
1098 [ - + ]: 2217 : while (pTblNode)
1099 : : {
1100 [ # # ]: 0 : rUnoCursor.GetPoint()->nNode = *pTblNode->EndOfSectionNode();
1101 [ # # ][ # # ]: 0 : pCNode = GetDoc()->GetNodes().GoNext(&rUnoCursor.GetPoint()->nNode);
[ # # ]
1102 [ # # ][ # # ]: 0 : pTblNode = (pCNode) ? pCNode->FindTableNode() : 0;
1103 : : }
1104 [ - + ]: 2217 : if (pCNode)
1105 : : {
1106 [ # # ][ # # ]: 0 : rUnoCursor.GetPoint()->nContent.Assign(pCNode, 0);
1107 : : }
1108 : : SwStartNode const*const pTmp =
1109 : 2217 : rUnoCursor.GetNode()->StartOfSectionNode();
1110 [ + + ]: 2217 : if (pTmp->IsSectionNode())
1111 : : {
1112 : : SwSectionNode const*const pSectionStartNode =
1113 : 14 : static_cast<SwSectionNode const*>(pTmp);
1114 [ - + ]: 14 : if (pSectionStartNode->GetSection().IsHiddenFlag())
1115 : : {
1116 [ # # ][ # # ]: 0 : pCNode = GetDoc()->GetNodes().GoNextSection(
1117 [ # # ]: 0 : &rUnoCursor.GetPoint()->nNode, sal_True, sal_False);
1118 [ # # ]: 0 : if (pCNode)
1119 : : {
1120 [ # # ][ # # ]: 0 : rUnoCursor.GetPoint()->nContent.Assign(pCNode, 0);
1121 : : }
1122 : : }
1123 : : }
1124 : : }
1125 [ + + + + : 1019 : else if ( (CURSOR_FRAME == m_pImpl->m_eType)
+ + + - +
+ - + ]
[ + + ]
1126 : 181 : || (CURSOR_TBLTEXT == m_pImpl->m_eType)
1127 : 173 : || (CURSOR_HEADER == m_pImpl->m_eType)
1128 : 162 : || (CURSOR_FOOTER == m_pImpl->m_eType)
1129 : 162 : || (CURSOR_FOOTNOTE== m_pImpl->m_eType)
1130 : 150 : || (CURSOR_REDLINE == m_pImpl->m_eType))
1131 : : {
1132 [ + - ]: 41 : rUnoCursor.MoveSection(fnSectionCurr, fnSectionStart);
1133 : : }
1134 [ + - ]: 150 : else if (CURSOR_META == m_pImpl->m_eType)
1135 : : {
1136 [ + - ]: 150 : lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, META_INIT_START);
1137 [ + - ]: 2408 : }
1138 : 2408 : }
1139 : :
1140 : : void SAL_CALL
1141 : 5213 : SwXTextCursor::gotoEnd(sal_Bool Expand) throw (uno::RuntimeException)
1142 : : {
1143 [ + - ]: 5213 : SolarMutexGuard aGuard;
1144 : :
1145 [ + - ]: 5213 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1146 : :
1147 [ + - ]: 5213 : SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1148 [ + + ]: 5213 : if (CURSOR_BODY == m_pImpl->m_eType)
1149 : : {
1150 [ + - ]: 4055 : rUnoCursor.Move( fnMoveForward, fnGoDoc );
1151 : : }
1152 [ + + + + : 3571 : else if ( (CURSOR_FRAME == m_pImpl->m_eType)
+ + + + +
+ - + ]
[ + + ]
1153 : 1076 : || (CURSOR_TBLTEXT == m_pImpl->m_eType)
1154 : 474 : || (CURSOR_HEADER == m_pImpl->m_eType)
1155 : 331 : || (CURSOR_FOOTER == m_pImpl->m_eType)
1156 : 304 : || (CURSOR_FOOTNOTE== m_pImpl->m_eType)
1157 : 228 : || (CURSOR_REDLINE == m_pImpl->m_eType))
1158 : : {
1159 [ + - ]: 930 : rUnoCursor.MoveSection( fnSectionCurr, fnSectionEnd);
1160 : : }
1161 [ + - ]: 228 : else if (CURSOR_META == m_pImpl->m_eType)
1162 : : {
1163 [ + - ]: 228 : lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, META_INIT_END);
1164 [ + - ]: 5213 : }
1165 : 5213 : }
1166 : :
1167 : : void SAL_CALL
1168 : 3165 : SwXTextCursor::gotoRange(
1169 : : const uno::Reference< text::XTextRange > & xRange, sal_Bool bExpand)
1170 : : throw (uno::RuntimeException)
1171 : : {
1172 [ + - ]: 3165 : SolarMutexGuard aGuard;
1173 : :
1174 [ + + ]: 3165 : if (!xRange.is())
1175 : : {
1176 [ + - ]: 2 : throw uno::RuntimeException();
1177 : : }
1178 : :
1179 [ + - ]: 3163 : SwUnoCrsr & rOwnCursor( m_pImpl->GetCursorOrThrow() );
1180 : :
1181 [ + - ]: 3163 : uno::Reference<lang::XUnoTunnel> xRangeTunnel( xRange, uno::UNO_QUERY);
1182 : 3163 : SwXTextRange* pRange = 0;
1183 : 3163 : OTextCursorHelper* pCursor = 0;
1184 [ + - ]: 3163 : if(xRangeTunnel.is())
1185 : : {
1186 [ + - ]: 3163 : pRange = ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel);
1187 : : pCursor =
1188 [ + - ]: 3163 : ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel);
1189 : : }
1190 : :
1191 [ + + ][ - + ]: 3163 : if (!pRange && !pCursor)
1192 : : {
1193 [ # # ]: 0 : throw uno::RuntimeException();
1194 : : }
1195 : :
1196 : 3163 : SwStartNodeType eSearchNodeType = SwNormalStartNode;
1197 [ + + + + : 3163 : switch (m_pImpl->m_eType)
+ + ]
1198 : : {
1199 : 4 : case CURSOR_FRAME: eSearchNodeType = SwFlyStartNode; break;
1200 : 345 : case CURSOR_TBLTEXT: eSearchNodeType = SwTableBoxStartNode; break;
1201 : 9 : case CURSOR_FOOTNOTE: eSearchNodeType = SwFootnoteStartNode; break;
1202 : 12 : case CURSOR_HEADER: eSearchNodeType = SwHeaderStartNode; break;
1203 : 15 : case CURSOR_FOOTER: eSearchNodeType = SwFooterStartNode; break;
1204 : : //case CURSOR_INVALID:
1205 : : //case CURSOR_BODY:
1206 : : default:
1207 : : ;
1208 : : }
1209 : : const SwStartNode* pOwnStartNode =
1210 [ + - ]: 3163 : rOwnCursor.GetNode()->FindSttNodeByType(eSearchNodeType);
1211 : :
1212 [ + - ][ + - ]: 3163 : SwPaM aPam(GetDoc()->GetNodes());
[ + - ][ + - ]
[ + - ]
1213 : 3163 : const SwPaM * pPam(0);
1214 [ + + ]: 3163 : if (pCursor)
1215 : : {
1216 [ + - ]: 68 : pPam = pCursor->GetPaM();
1217 : : }
1218 [ + - ]: 3095 : else if (pRange)
1219 : : {
1220 [ + - ][ + - ]: 3095 : if (pRange->GetPositions(aPam))
1221 : : {
1222 : 3095 : pPam = & aPam;
1223 : : }
1224 : : }
1225 : :
1226 [ - + ]: 3163 : if (!pPam)
1227 : : {
1228 [ # # ]: 0 : throw uno::RuntimeException();
1229 : : }
1230 : : const SwStartNode* pTmp =
1231 [ + - ]: 3163 : pPam->GetNode()->FindSttNodeByType(eSearchNodeType);
1232 : :
1233 : : //SectionNodes ueberspringen
1234 [ + - ][ + + ]: 3262 : while(pTmp && pTmp->IsSectionNode())
[ + + ]
1235 : : {
1236 : 99 : pTmp = pTmp->StartOfSectionNode();
1237 : : }
1238 [ + - ][ + + ]: 3262 : while(pOwnStartNode && pOwnStartNode->IsSectionNode())
[ + + ]
1239 : : {
1240 : 99 : pOwnStartNode = pOwnStartNode->StartOfSectionNode();
1241 : : }
1242 [ - + ]: 3163 : if(pOwnStartNode != pTmp)
1243 : : {
1244 [ # # ]: 0 : throw uno::RuntimeException();
1245 : : }
1246 : :
1247 [ + + ]: 3163 : if (CURSOR_META == m_pImpl->m_eType)
1248 : : {
1249 [ + - ]: 10 : SwPaM CopyPam(*pPam->GetMark(), *pPam->GetPoint());
1250 : : const bool bNotForced( lcl_ForceIntoMeta(
1251 [ + - ]: 10 : CopyPam, m_pImpl->m_xParentText, META_CHECK_BOTH) );
1252 [ + + ]: 10 : if (!bNotForced)
1253 : : {
1254 : : throw uno::RuntimeException(
1255 : : C2U("gotoRange: parameter range not contained in nesting"
1256 : : " text content for which this cursor was created"),
1257 [ + - ][ + - ]: 2 : static_cast<text::XWordCursor*>(this));
[ + - ]
1258 [ + - ]: 10 : }
1259 : : }
1260 : :
1261 : : //jetzt muss die Selektion erweitert werden
1262 [ + + ]: 3161 : if(bExpand)
1263 : : {
1264 : : // der Cursor soll alles einschliessen, was bisher von ihm und dem uebergebenen
1265 : : // Range eingeschlossen wurde
1266 [ + - ][ + - ]: 3035 : const SwPosition aOwnLeft(*rOwnCursor.Start());
1267 [ + - ][ + - ]: 3035 : const SwPosition aOwnRight(*rOwnCursor.End());
1268 [ + - ]: 3035 : SwPosition const& rParamLeft = *pPam->Start();
1269 [ + - ]: 3035 : SwPosition const& rParamRight = *pPam->End();
1270 : :
1271 : : // jetzt sind vier SwPositions da, zwei davon werden gebraucht, also welche?
1272 [ + - ]: 3035 : *rOwnCursor.GetPoint() = (aOwnRight > rParamRight)
1273 [ + + ][ + - ]: 3035 : ? aOwnRight : *rOwnCursor.GetPoint() = rParamRight;
[ + - ]
1274 [ + - ]: 3035 : rOwnCursor.SetMark();
1275 [ + - ]: 3035 : *rOwnCursor.GetMark() = (aOwnLeft < rParamLeft)
1276 [ + + ][ + - ]: 3035 : ? aOwnLeft : *rOwnCursor.GetMark() = rParamLeft;
[ + - ][ + - ]
[ + - ]
1277 : : }
1278 : : else
1279 : : {
1280 : : // cursor should be the given range
1281 [ + - ]: 126 : *rOwnCursor.GetPoint() = *pPam->GetPoint();
1282 [ - + ]: 126 : if (pPam->HasMark())
1283 : : {
1284 [ # # ]: 0 : rOwnCursor.SetMark();
1285 [ # # ]: 0 : *rOwnCursor.GetMark() = *pPam->GetMark();
1286 : : }
1287 : : else
1288 : : {
1289 [ + - ]: 126 : rOwnCursor.DeleteMark();
1290 : : }
1291 [ + - ][ + - ]: 3165 : }
1292 : 3161 : }
1293 : :
1294 : 2 : sal_Bool SAL_CALL SwXTextCursor::isStartOfWord() throw (uno::RuntimeException)
1295 : : {
1296 [ + - ]: 2 : SolarMutexGuard aGuard;
1297 : :
1298 [ + - ]: 2 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1299 : :
1300 : : const sal_Bool bRet =
1301 [ + - ]: 2 : rUnoCursor.IsStartWordWT( i18n::WordType::DICTIONARY_WORD );
1302 [ + - ]: 2 : return bRet;
1303 : : }
1304 : :
1305 : 2 : sal_Bool SAL_CALL SwXTextCursor::isEndOfWord() throw (uno::RuntimeException)
1306 : : {
1307 [ + - ]: 2 : SolarMutexGuard aGuard;
1308 : :
1309 [ + - ]: 2 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1310 : :
1311 : : const sal_Bool bRet =
1312 [ + - ]: 2 : rUnoCursor.IsEndWordWT( i18n::WordType::DICTIONARY_WORD );
1313 [ + - ]: 2 : return bRet;
1314 : : }
1315 : :
1316 : : sal_Bool SAL_CALL
1317 : 8 : SwXTextCursor::gotoNextWord(sal_Bool Expand) throw (uno::RuntimeException)
1318 : : {
1319 [ + - ]: 8 : SolarMutexGuard aGuard;
1320 : :
1321 [ + - ]: 8 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1322 : :
1323 : : //Probleme gibt's noch mit einem Absatzanfang, an dem kein Wort beginnt.
1324 : 8 : sal_Bool bRet = sal_False;
1325 : : // remember old position to check if cursor has moved
1326 : : // since the called functions are sometimes a bit unreliable
1327 : : // in specific cases...
1328 : 8 : SwPosition *const pPoint = rUnoCursor.GetPoint();
1329 : 8 : SwNode *const pOldNode = &pPoint->nNode.GetNode();
1330 : 8 : xub_StrLen const nOldIndex = pPoint->nContent.GetIndex();
1331 : :
1332 [ + - ]: 8 : SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1333 : : // end of paragraph
1334 [ + - - + ]: 16 : if (rUnoCursor.GetCntntNode() &&
[ - + ]
1335 [ + - ]: 8 : (pPoint->nContent == rUnoCursor.GetCntntNode()->Len()))
1336 : : {
1337 [ # # ]: 0 : rUnoCursor.Right(1, CRSR_SKIP_CHARS, sal_False, sal_False);
1338 : : }
1339 : : else
1340 : : {
1341 : : const bool bTmp =
1342 [ + - ]: 8 : rUnoCursor.GoNextWordWT( i18n::WordType::DICTIONARY_WORD );
1343 : : // if there is no next word within the current paragraph
1344 : : // try to go to the start of the next paragraph
1345 [ - + ]: 8 : if (!bTmp)
1346 : : {
1347 [ # # ]: 0 : rUnoCursor.MovePara(fnParaNext, fnParaStart);
1348 : : }
1349 : : }
1350 : :
1351 : : // return true if cursor has moved
1352 : 8 : bRet = (&pPoint->nNode.GetNode() != pOldNode) ||
1353 [ + - ][ + - ]: 8 : (pPoint->nContent.GetIndex() != nOldIndex);
1354 [ + - ][ + + ]: 8 : if (bRet && (CURSOR_META == m_pImpl->m_eType))
[ + + ]
1355 : : {
1356 : 4 : bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText,
1357 [ + - ]: 4 : META_CHECK_BOTH);
1358 : : }
1359 : :
1360 [ + - ]: 8 : return bRet;
1361 : : }
1362 : :
1363 : : sal_Bool SAL_CALL
1364 : 10 : SwXTextCursor::gotoPreviousWord(sal_Bool Expand) throw (uno::RuntimeException)
1365 : : {
1366 [ + - ]: 10 : SolarMutexGuard aGuard;
1367 : :
1368 [ + - ]: 10 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1369 : :
1370 : : // hier machen Leerzeichen am Absatzanfang Probleme
1371 : 10 : sal_Bool bRet = sal_False;
1372 : 10 : SwPosition *const pPoint = rUnoCursor.GetPoint();
1373 : 10 : SwNode *const pOldNode = &pPoint->nNode.GetNode();
1374 : 10 : xub_StrLen const nOldIndex = pPoint->nContent.GetIndex();
1375 : :
1376 [ + - ]: 10 : SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1377 : : // start of paragraph?
1378 [ - + ]: 10 : if (pPoint->nContent == 0)
1379 : : {
1380 [ # # ]: 0 : rUnoCursor.Left(1, CRSR_SKIP_CHARS, sal_False, sal_False);
1381 : : }
1382 : : else
1383 : : {
1384 [ + - ]: 10 : rUnoCursor.GoPrevWordWT( i18n::WordType::DICTIONARY_WORD );
1385 [ + + ]: 10 : if (pPoint->nContent == 0)
1386 : : {
1387 [ + - ]: 4 : rUnoCursor.Left(1, CRSR_SKIP_CHARS, sal_False, sal_False);
1388 : : }
1389 : : }
1390 : :
1391 : : // return true if cursor has moved
1392 : 10 : bRet = (&pPoint->nNode.GetNode() != pOldNode) ||
1393 [ + - ][ + + ]: 10 : (pPoint->nContent.GetIndex() != nOldIndex);
1394 [ + - ][ + + ]: 10 : if (bRet && (CURSOR_META == m_pImpl->m_eType))
[ + + ]
1395 : : {
1396 : 6 : bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText,
1397 [ + - ]: 6 : META_CHECK_BOTH);
1398 : : }
1399 : :
1400 [ + - ]: 10 : return bRet;
1401 : : }
1402 : :
1403 : : sal_Bool SAL_CALL
1404 : 24 : SwXTextCursor::gotoEndOfWord(sal_Bool Expand) throw (uno::RuntimeException)
1405 : : {
1406 [ + - ]: 24 : SolarMutexGuard aGuard;
1407 : :
1408 [ + - ]: 24 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1409 : :
1410 : 24 : sal_Bool bRet = sal_False;
1411 : 24 : SwPosition *const pPoint = rUnoCursor.GetPoint();
1412 : 24 : SwNode & rOldNode = pPoint->nNode.GetNode();
1413 : 24 : xub_StrLen const nOldIndex = pPoint->nContent.GetIndex();
1414 : :
1415 : 24 : const sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD;
1416 [ + - ]: 24 : SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1417 [ + - ][ + - ]: 24 : if (!rUnoCursor.IsEndWordWT( nWordType ))
1418 : : {
1419 [ + - ]: 24 : rUnoCursor.GoEndWordWT( nWordType );
1420 : : }
1421 : :
1422 : : // restore old cursor if we are not at the end of a word by now
1423 : : // otherwise use current one
1424 [ + - ]: 24 : bRet = rUnoCursor.IsEndWordWT( nWordType );
1425 [ - + ]: 24 : if (!bRet)
1426 : : {
1427 [ # # ]: 0 : pPoint->nNode = rOldNode;
1428 [ # # ]: 0 : pPoint->nContent = nOldIndex;
1429 : : }
1430 [ + + ]: 24 : else if (CURSOR_META == m_pImpl->m_eType)
1431 : : {
1432 : 4 : bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText,
1433 [ + - ]: 4 : META_CHECK_BOTH);
1434 : : }
1435 : :
1436 [ + - ]: 24 : return bRet;
1437 : : }
1438 : :
1439 : : sal_Bool SAL_CALL
1440 : 12 : SwXTextCursor::gotoStartOfWord(sal_Bool Expand) throw (uno::RuntimeException)
1441 : : {
1442 [ + - ]: 12 : SolarMutexGuard aGuard;
1443 : :
1444 [ + - ]: 12 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1445 : :
1446 : 12 : sal_Bool bRet = sal_False;
1447 : 12 : SwPosition *const pPoint = rUnoCursor.GetPoint();
1448 : 12 : SwNode & rOldNode = pPoint->nNode.GetNode();
1449 : 12 : xub_StrLen const nOldIndex = pPoint->nContent.GetIndex();
1450 : :
1451 : 12 : const sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD;
1452 [ + - ]: 12 : SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1453 [ + - ][ + + ]: 12 : if (!rUnoCursor.IsStartWordWT( nWordType ))
1454 : : {
1455 [ + - ]: 10 : rUnoCursor.GoStartWordWT( nWordType );
1456 : : }
1457 : :
1458 : : // restore old cursor if we are not at the start of a word by now
1459 : : // otherwise use current one
1460 [ + - ]: 12 : bRet = rUnoCursor.IsStartWordWT( nWordType );
1461 [ - + ]: 12 : if (!bRet)
1462 : : {
1463 [ # # ]: 0 : pPoint->nNode = rOldNode;
1464 [ # # ]: 0 : pPoint->nContent = nOldIndex;
1465 : : }
1466 [ + + ]: 12 : else if (CURSOR_META == m_pImpl->m_eType)
1467 : : {
1468 : 4 : bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText,
1469 [ + - ]: 4 : META_CHECK_BOTH);
1470 : : }
1471 : :
1472 [ + - ]: 12 : return bRet;
1473 : : }
1474 : :
1475 : : sal_Bool SAL_CALL
1476 : 2 : SwXTextCursor::isStartOfSentence() throw (uno::RuntimeException)
1477 : : {
1478 [ + - ]: 2 : SolarMutexGuard aGuard;
1479 : :
1480 [ + - ]: 2 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1481 : :
1482 : : // start of paragraph?
1483 : 2 : sal_Bool bRet = rUnoCursor.GetPoint()->nContent == 0;
1484 : : // with mark ->no sentence start
1485 : : // (check if cursor is no selection, i.e. it does not have
1486 : : // a mark or else point and mark are identical)
1487 [ # # ][ # # ]: 2 : if (!bRet && (!rUnoCursor.HasMark() ||
[ - + ][ - + ]
1488 [ # # ]: 0 : *rUnoCursor.GetPoint() == *rUnoCursor.GetMark()))
1489 : : {
1490 [ # # ]: 0 : SwCursor aCrsr(*rUnoCursor.GetPoint(),0,false);
1491 [ # # ]: 0 : SwPosition aOrigPos = *aCrsr.GetPoint();
1492 [ # # ]: 0 : aCrsr.GoSentence(SwCursor::START_SENT );
1493 [ # # ][ # # ]: 0 : bRet = aOrigPos == *aCrsr.GetPoint();
[ # # ]
1494 : : }
1495 [ + - ]: 2 : return bRet;
1496 : : }
1497 : :
1498 : : sal_Bool SAL_CALL
1499 : 12 : SwXTextCursor::isEndOfSentence() throw (uno::RuntimeException)
1500 : : {
1501 [ + - ]: 12 : SolarMutexGuard aGuard;
1502 : :
1503 [ + - ]: 12 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1504 : :
1505 : : // end of paragraph?
1506 : 12 : sal_Bool bRet = rUnoCursor.GetCntntNode() &&
1507 [ + - ][ + + ]: 12 : (rUnoCursor.GetPoint()->nContent == rUnoCursor.GetCntntNode()->Len());
[ + - ]
1508 : : // with mark->no sentence end
1509 : : // (check if cursor is no selection, i.e. it does not have
1510 : : // a mark or else point and mark are identical)
1511 [ + + ][ + + ]: 14 : if (!bRet && (!rUnoCursor.HasMark() ||
[ - + ][ + + ]
1512 [ + - ]: 2 : *rUnoCursor.GetPoint() == *rUnoCursor.GetMark()))
1513 : : {
1514 [ + - ]: 6 : SwCursor aCrsr(*rUnoCursor.GetPoint(), 0, false);
1515 [ + - ]: 6 : SwPosition aOrigPos = *aCrsr.GetPoint();
1516 [ + - ]: 6 : aCrsr.GoSentence(SwCursor::END_SENT);
1517 [ + - ][ + - ]: 6 : bRet = aOrigPos == *aCrsr.GetPoint();
[ + - ]
1518 : : }
1519 [ + - ]: 12 : return bRet;
1520 : : }
1521 : :
1522 : : sal_Bool SAL_CALL
1523 : 10 : SwXTextCursor::gotoNextSentence(sal_Bool Expand) throw (uno::RuntimeException)
1524 : : {
1525 [ + - ]: 10 : SolarMutexGuard aGuard;
1526 : :
1527 [ + - ]: 10 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1528 : :
1529 [ + - ]: 10 : const bool bWasEOS = isEndOfSentence();
1530 [ + - ]: 10 : SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1531 [ + - ]: 10 : sal_Bool bRet = rUnoCursor.GoSentence(SwCursor::NEXT_SENT);
1532 [ - + ]: 10 : if (!bRet)
1533 : : {
1534 [ # # ]: 0 : bRet = rUnoCursor.MovePara(fnParaNext, fnParaStart);
1535 : : }
1536 : :
1537 : : // if at the end of the sentence (i.e. at the space after the '.')
1538 : : // advance to next word in order for GoSentence to work properly
1539 : : // next time and have isStartOfSentence return true after this call
1540 [ + - ][ + + ]: 10 : if (!rUnoCursor.IsStartWord())
1541 : : {
1542 [ + - ]: 6 : const bool bNextWord = rUnoCursor.GoNextWord();
1543 [ + + ][ + - ]: 6 : if (bWasEOS && !bNextWord)
1544 : : {
1545 : 4 : bRet = sal_False;
1546 : : }
1547 : : }
1548 [ + + ]: 10 : if (CURSOR_META == m_pImpl->m_eType)
1549 : : {
1550 : 4 : bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText,
1551 [ + - ]: 4 : META_CHECK_BOTH)
1552 [ + + ][ + - ]: 4 : && bRet;
1553 : : }
1554 [ + - ]: 10 : return bRet;
1555 : : }
1556 : :
1557 : : sal_Bool SAL_CALL
1558 : 10 : SwXTextCursor::gotoPreviousSentence(sal_Bool Expand)
1559 : : throw (uno::RuntimeException)
1560 : : {
1561 [ + - ]: 10 : SolarMutexGuard aGuard;
1562 : :
1563 [ + - ]: 10 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1564 : :
1565 [ + - ]: 10 : SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1566 [ + - ]: 10 : sal_Bool bRet = rUnoCursor.GoSentence(SwCursor::PREV_SENT);
1567 [ + + ]: 10 : if (!bRet)
1568 : : {
1569 [ + - ]: 2 : bRet = rUnoCursor.MovePara(fnParaPrev, fnParaStart);
1570 [ + - ]: 2 : if (bRet)
1571 : : {
1572 [ + - ]: 2 : rUnoCursor.MovePara(fnParaCurr, fnParaEnd);
1573 : : // at the end of a paragraph move to the sentence end again
1574 [ + - ]: 2 : rUnoCursor.GoSentence(SwCursor::PREV_SENT);
1575 : : }
1576 : : }
1577 [ + + ]: 10 : if (CURSOR_META == m_pImpl->m_eType)
1578 : : {
1579 : 4 : bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText,
1580 [ + - ]: 4 : META_CHECK_BOTH)
1581 [ + + ][ + - ]: 4 : && bRet;
1582 : : }
1583 [ + - ]: 10 : return bRet;
1584 : : }
1585 : :
1586 : : sal_Bool SAL_CALL
1587 : 8 : SwXTextCursor::gotoStartOfSentence(sal_Bool Expand)
1588 : : throw (uno::RuntimeException)
1589 : : {
1590 [ + - ]: 8 : SolarMutexGuard aGuard;
1591 : :
1592 [ + - ]: 8 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1593 : :
1594 : 8 : sal_Bool bRet = sal_False;
1595 [ + - ]: 8 : SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1596 : : // if we're at the para start then we wont move
1597 : : // but bRet is also true if GoSentence failed but
1598 : : // the start of the sentence is reached
1599 : 8 : bRet = SwUnoCursorHelper::IsStartOfPara(rUnoCursor)
1600 [ + - ]: 8 : || rUnoCursor.GoSentence(SwCursor::START_SENT)
1601 [ - + ][ # # ]: 16 : || SwUnoCursorHelper::IsStartOfPara(rUnoCursor);
[ + - ]
1602 [ + + ]: 8 : if (CURSOR_META == m_pImpl->m_eType)
1603 : : {
1604 : 4 : bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText,
1605 [ + - ]: 4 : META_CHECK_BOTH)
1606 [ + + ][ + - ]: 4 : && bRet;
1607 : : }
1608 [ + - ]: 8 : return bRet;
1609 : : }
1610 : :
1611 : : sal_Bool SAL_CALL
1612 : 8 : SwXTextCursor::gotoEndOfSentence(sal_Bool Expand) throw (uno::RuntimeException)
1613 : : {
1614 [ + - ]: 8 : SolarMutexGuard aGuard;
1615 : :
1616 [ + - ]: 8 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1617 : :
1618 : 8 : sal_Bool bRet = sal_False;
1619 [ + - ]: 8 : SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1620 : : // bRet is true if GoSentence() succeeded or if the
1621 : : // MovePara() succeeded while the end of the para is
1622 : : // not reached already
1623 [ + - ]: 8 : sal_Bool bAlreadyParaEnd = SwUnoCursorHelper::IsEndOfPara(rUnoCursor);
1624 : : bRet = !bAlreadyParaEnd
1625 [ + - ]: 8 : && (rUnoCursor.GoSentence(SwCursor::END_SENT)
1626 [ + - ][ - + ]: 16 : || rUnoCursor.MovePara(fnParaCurr, fnParaEnd));
[ # # ][ # # ]
1627 [ + + ]: 8 : if (CURSOR_META == m_pImpl->m_eType)
1628 : : {
1629 : 4 : bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText,
1630 [ + - ]: 4 : META_CHECK_BOTH)
1631 [ + + ][ + - ]: 4 : && bRet;
1632 : : }
1633 [ + - ]: 8 : return bRet;
1634 : : }
1635 : :
1636 : : sal_Bool SAL_CALL
1637 : 2 : SwXTextCursor::isStartOfParagraph() throw (uno::RuntimeException)
1638 : : {
1639 [ + - ]: 2 : SolarMutexGuard aGuard;
1640 : :
1641 [ + - ]: 2 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1642 : :
1643 : 2 : const sal_Bool bRet = SwUnoCursorHelper::IsStartOfPara(rUnoCursor);
1644 [ + - ]: 2 : return bRet;
1645 : : }
1646 : :
1647 : : sal_Bool SAL_CALL
1648 : 6 : SwXTextCursor::isEndOfParagraph() throw (uno::RuntimeException)
1649 : : {
1650 [ + - ]: 6 : SolarMutexGuard aGuard;
1651 : :
1652 [ + - ]: 6 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1653 : :
1654 [ + - ]: 6 : const sal_Bool bRet = SwUnoCursorHelper::IsEndOfPara(rUnoCursor);
1655 [ + - ]: 6 : return bRet;
1656 : : }
1657 : :
1658 : : sal_Bool SAL_CALL
1659 : 402 : SwXTextCursor::gotoStartOfParagraph(sal_Bool Expand)
1660 : : throw (uno::RuntimeException)
1661 : : {
1662 [ + - ]: 402 : SolarMutexGuard aGuard;
1663 : :
1664 [ + - ]: 402 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1665 : :
1666 [ + + ]: 402 : if (CURSOR_META == m_pImpl->m_eType)
1667 : : {
1668 : 2 : return sal_False;
1669 : : }
1670 [ + - ]: 400 : SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1671 : 400 : sal_Bool bRet = SwUnoCursorHelper::IsStartOfPara(rUnoCursor);
1672 [ + + ]: 400 : if (!bRet)
1673 : : {
1674 [ + - ]: 158 : bRet = rUnoCursor.MovePara(fnParaCurr, fnParaStart);
1675 : : }
1676 : :
1677 : : // since MovePara(fnParaCurr, fnParaStart) only returns false
1678 : : // if we were already at the start of the paragraph this function
1679 : : // should always complete successfully.
1680 : : OSL_ENSURE( bRet, "gotoStartOfParagraph failed" );
1681 [ + - ]: 402 : return bRet;
1682 : : }
1683 : :
1684 : : sal_Bool SAL_CALL
1685 : 542 : SwXTextCursor::gotoEndOfParagraph(sal_Bool Expand) throw (uno::RuntimeException)
1686 : : {
1687 [ + - ]: 542 : SolarMutexGuard aGuard;
1688 : :
1689 [ + - ]: 542 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1690 : :
1691 [ + + ]: 542 : if (CURSOR_META == m_pImpl->m_eType)
1692 : : {
1693 : 2 : return sal_False;
1694 : : }
1695 [ + - ]: 540 : SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1696 [ + - ]: 540 : sal_Bool bRet = SwUnoCursorHelper::IsEndOfPara(rUnoCursor);
1697 [ + + ]: 540 : if (!bRet)
1698 : : {
1699 [ + - ]: 172 : bRet = rUnoCursor.MovePara(fnParaCurr, fnParaEnd);
1700 : : }
1701 : :
1702 : : // since MovePara(fnParaCurr, fnParaEnd) only returns false
1703 : : // if we were already at the end of the paragraph this function
1704 : : // should always complete successfully.
1705 : : OSL_ENSURE( bRet, "gotoEndOfParagraph failed" );
1706 [ + - ]: 542 : return bRet;
1707 : : }
1708 : :
1709 : : sal_Bool SAL_CALL
1710 : 8 : SwXTextCursor::gotoNextParagraph(sal_Bool Expand) throw (uno::RuntimeException)
1711 : : {
1712 [ + - ]: 8 : SolarMutexGuard aGuard;
1713 : :
1714 [ + - ]: 8 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1715 : :
1716 [ + + ]: 8 : if (CURSOR_META == m_pImpl->m_eType)
1717 : : {
1718 : 2 : return sal_False;
1719 : : }
1720 [ + - ]: 6 : SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1721 [ + - ]: 6 : const sal_Bool bRet = rUnoCursor.MovePara(fnParaNext, fnParaStart);
1722 [ + - ]: 8 : return bRet;
1723 : : }
1724 : :
1725 : : sal_Bool SAL_CALL
1726 : 16 : SwXTextCursor::gotoPreviousParagraph(sal_Bool Expand)
1727 : : throw (uno::RuntimeException)
1728 : : {
1729 [ + - ]: 16 : SolarMutexGuard aGuard;
1730 : :
1731 [ + - ]: 16 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1732 : :
1733 [ + + ]: 16 : if (CURSOR_META == m_pImpl->m_eType)
1734 : : {
1735 : 2 : return sal_False;
1736 : : }
1737 [ + - ]: 14 : SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1738 [ + - ]: 14 : const sal_Bool bRet = rUnoCursor.MovePara(fnParaPrev, fnParaStart);
1739 [ + - ]: 16 : return bRet;
1740 : : }
1741 : :
1742 : : uno::Reference< text::XText > SAL_CALL
1743 : 7304 : SwXTextCursor::getText() throw (uno::RuntimeException)
1744 : : {
1745 [ + - ]: 7304 : SolarMutexGuard g;
1746 : :
1747 [ + - ]: 7304 : return m_pImpl->m_xParentText;
1748 : : }
1749 : :
1750 : : uno::Reference< text::XTextRange > SAL_CALL
1751 : 6615 : SwXTextCursor::getStart() throw (uno::RuntimeException)
1752 : : {
1753 [ + - ]: 6615 : SolarMutexGuard aGuard;
1754 : :
1755 [ + - ]: 6615 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1756 : :
1757 : 6615 : uno::Reference< text::XTextRange > xRet;
1758 [ + - ][ + - ]: 6615 : SwPaM aPam(*rUnoCursor.Start());
1759 [ + - ]: 6615 : const uno::Reference< text::XText > xParent = getText();
1760 [ + + ]: 6615 : if (CURSOR_META == m_pImpl->m_eType)
1761 : : {
1762 : : // return cursor to prevent modifying SwXTextRange for META
1763 : : SwXTextCursor * const pXCursor(
1764 : 52 : new SwXTextCursor(*rUnoCursor.GetDoc(), xParent, CURSOR_META,
1765 [ + - ]: 52 : *rUnoCursor.GetPoint()) );
1766 [ + - ]: 52 : pXCursor->gotoStart(sal_False);
1767 [ + - ][ + - ]: 52 : xRet = static_cast<text::XWordCursor*>(pXCursor);
1768 : : }
1769 : : else
1770 : : {
1771 [ + - ][ + - ]: 6563 : xRet = new SwXTextRange(aPam, xParent);
[ + - ]
1772 : : }
1773 [ + - ][ + - ]: 6615 : return xRet;
1774 : : }
1775 : :
1776 : : uno::Reference< text::XTextRange > SAL_CALL
1777 : 22 : SwXTextCursor::getEnd() throw (uno::RuntimeException)
1778 : : {
1779 [ + - ]: 22 : SolarMutexGuard aGuard;
1780 : :
1781 [ + - ]: 22 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1782 : :
1783 : 22 : uno::Reference< text::XTextRange > xRet;
1784 [ + - ][ + - ]: 22 : SwPaM aPam(*rUnoCursor.End());
1785 [ + - ]: 22 : const uno::Reference< text::XText > xParent = getText();
1786 [ - + ]: 22 : if (CURSOR_META == m_pImpl->m_eType)
1787 : : {
1788 : : // return cursor to prevent modifying SwXTextRange for META
1789 : : SwXTextCursor * const pXCursor(
1790 : 0 : new SwXTextCursor(*rUnoCursor.GetDoc(), xParent, CURSOR_META,
1791 [ # # ]: 0 : *rUnoCursor.GetPoint()) );
1792 [ # # ]: 0 : pXCursor->gotoEnd(sal_False);
1793 [ # # ][ # # ]: 0 : xRet = static_cast<text::XWordCursor*>(pXCursor);
1794 : : }
1795 : : else
1796 : : {
1797 [ + - ][ + - ]: 22 : xRet = new SwXTextRange(aPam, xParent);
[ + - ]
1798 : : }
1799 [ + - ][ + - ]: 22 : return xRet;
1800 : : }
1801 : :
1802 : 682 : OUString SAL_CALL SwXTextCursor::getString() throw (uno::RuntimeException)
1803 : : {
1804 [ + - ]: 682 : SolarMutexGuard aGuard;
1805 : :
1806 [ + - ]: 682 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1807 : :
1808 : 682 : OUString aTxt;
1809 [ + - ]: 682 : SwUnoCursorHelper::GetTextFromPam(rUnoCursor, aTxt);
1810 [ + - ]: 682 : return aTxt;
1811 : : }
1812 : :
1813 : : void SAL_CALL
1814 : 7627 : SwXTextCursor::setString(const OUString& aString) throw (uno::RuntimeException)
1815 : : {
1816 [ + - ]: 7627 : SolarMutexGuard aGuard;
1817 : :
1818 [ + - ]: 7627 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1819 : : (void) rUnoCursor; // just to check if valid
1820 : :
1821 : 7627 : const bool bForceExpandHints( (CURSOR_META != m_pImpl->m_eType)
1822 : : ? false
1823 [ + - ]: 62 : : dynamic_cast<SwXMeta*>(m_pImpl->m_xParentText.get())
1824 [ + - ][ - + ]: 7689 : ->CheckForOwnMemberMeta(*GetPaM(), true) );
[ + - ][ + + ]
1825 [ + - ][ + - ]: 7627 : DeleteAndInsert(aString, bForceExpandHints);
1826 : 7627 : }
1827 : :
1828 : 2671 : uno::Any SwUnoCursorHelper::GetPropertyValue(
1829 : : SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
1830 : : const OUString& rPropertyName)
1831 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
1832 : : uno::RuntimeException)
1833 : : {
1834 : 2671 : uno::Any aAny;
1835 : : SfxItemPropertySimpleEntry const*const pEntry =
1836 [ + - ]: 2671 : rPropSet.getPropertyMap().getByName(rPropertyName);
1837 : :
1838 [ - + ]: 2671 : if (!pEntry)
1839 : : {
1840 : : throw beans::UnknownPropertyException(
1841 : : OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
1842 [ # # ][ # # ]: 0 : + rPropertyName, static_cast<cppu::OWeakObject *>(0));
[ # # ]
1843 : : }
1844 : :
1845 : : beans::PropertyState eTemp;
1846 : : const sal_Bool bDone = SwUnoCursorHelper::getCrsrPropertyValue(
1847 [ + - ]: 2671 : *pEntry, rPaM, &aAny, eTemp );
1848 : :
1849 [ + + ]: 2671 : if (!bDone)
1850 : : {
1851 : 796 : SfxItemSet aSet(rPaM.GetDoc()->GetAttrPool(),
1852 : : RES_CHRATR_BEGIN, RES_FRMATR_END - 1,
1853 : : RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER,
1854 : : RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER,
1855 [ + - ]: 796 : 0L);
1856 [ + - ]: 796 : SwUnoCursorHelper::GetCrsrAttr(rPaM, aSet);
1857 : :
1858 [ + - ][ + - ]: 2671 : rPropSet.getPropertyValue(*pEntry, aSet, aAny);
1859 : : }
1860 : :
1861 : 2671 : return aAny;
1862 : : }
1863 : :
1864 : 16397 : void SwUnoCursorHelper::SetPropertyValue(
1865 : : SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
1866 : : const OUString& rPropertyName,
1867 : : const uno::Any& rValue,
1868 : : const SetAttrMode nAttrMode, const bool bTableMode)
1869 : : throw (beans::UnknownPropertyException, beans::PropertyVetoException,
1870 : : lang::IllegalArgumentException, lang::WrappedTargetException,
1871 : : uno::RuntimeException)
1872 : : {
1873 : 16397 : SwDoc *const pDoc = rPaM.GetDoc();
1874 : : SfxItemPropertySimpleEntry const*const pEntry =
1875 [ + - ]: 16397 : rPropSet.getPropertyMap().getByName(rPropertyName);
1876 [ - + ]: 16397 : if (!pEntry)
1877 : : {
1878 : : throw beans::UnknownPropertyException(
1879 : : OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
1880 : : + rPropertyName,
1881 [ # # ][ # # ]: 0 : static_cast<cppu::OWeakObject *>(0));
[ # # ]
1882 : : }
1883 : :
1884 [ - + ]: 16397 : if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
1885 : : {
1886 : : throw beans::PropertyVetoException(
1887 : : OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: "))
1888 : : + rPropertyName,
1889 [ # # ][ # # ]: 0 : static_cast<cppu::OWeakObject *>(0));
[ # # ]
1890 : : }
1891 : :
1892 [ + - ]: 16397 : SfxItemSet aItemSet( pDoc->GetAttrPool(), pEntry->nWID, pEntry->nWID );
1893 [ + - ]: 16397 : SwUnoCursorHelper::GetCrsrAttr( rPaM, aItemSet );
1894 : :
1895 [ + + ]: 16397 : if (!SwUnoCursorHelper::SetCursorPropertyValue(
1896 [ + - ]: 16397 : *pEntry, rValue, rPaM, aItemSet))
1897 : : {
1898 [ + - ]: 13085 : rPropSet.setPropertyValue(*pEntry, rValue, aItemSet );
1899 : : }
1900 [ + - ][ + - ]: 16397 : SwUnoCursorHelper::SetCrsrAttr(rPaM, aItemSet, nAttrMode, bTableMode);
1901 : 16397 : }
1902 : :
1903 : : uno::Sequence< beans::PropertyState >
1904 : 3879 : SwUnoCursorHelper::GetPropertyStates(
1905 : : SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
1906 : : const uno::Sequence< OUString >& rPropertyNames,
1907 : : const SwGetPropertyStatesCaller eCaller)
1908 : : throw (beans::UnknownPropertyException, uno::RuntimeException)
1909 : : {
1910 : 3879 : const OUString* pNames = rPropertyNames.getConstArray();
1911 [ + - ]: 3879 : uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength());
1912 [ + - ]: 3879 : beans::PropertyState* pStates = aRet.getArray();
1913 : 3879 : const SfxItemPropertyMap &rMap = rPropSet.getPropertyMap();
1914 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
1915 : 3879 : ::std::auto_ptr<SfxItemSet> pSet;
1916 : 3879 : ::std::auto_ptr<SfxItemSet> pSetParent;
1917 : : SAL_WNODEPRECATED_DECLARATIONS_POP
1918 : :
1919 [ + + ]: 246960 : for (sal_Int32 i = 0, nEnd = rPropertyNames.getLength(); i < nEnd; i++)
1920 : : {
1921 : : SfxItemPropertySimpleEntry const*const pEntry =
1922 [ + - ]: 243081 : rMap.getByName( pNames[i] );
1923 [ + + ]: 243081 : if(!pEntry)
1924 : : {
1925 [ + - ][ + - ]: 12 : if (pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) ||
[ + + + - ]
[ + - ]
1926 [ + - ][ + - ]: 4 : pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT)))
1927 : : {
1928 : 8 : pStates[i] = beans::PropertyState_DEFAULT_VALUE;
1929 : 8 : continue;
1930 : : }
1931 [ # # ]: 0 : else if (SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT ==
1932 : : eCaller)
1933 : : {
1934 : : //this values marks the element as unknown property
1935 : 0 : pStates[i] = beans::PropertyState_MAKE_FIXED_SIZE;
1936 : 0 : continue;
1937 : : }
1938 : : else
1939 : : {
1940 : : throw beans::UnknownPropertyException(
1941 : : OUString( RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
1942 : 0 : + pNames[i],
1943 [ # # ][ # # ]: 0 : static_cast<cppu::OWeakObject *>(0));
[ # # ]
1944 : : }
1945 : : }
1946 [ + - ][ + + ]: 243073 : if (((SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION == eCaller) ||
[ + - ][ - + ]
[ # # ][ # # ]
1947 : : (SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT == eCaller)) &&
1948 : : pEntry->nWID < FN_UNO_RANGE_BEGIN &&
1949 : : pEntry->nWID > FN_UNO_RANGE_END &&
1950 : : pEntry->nWID < RES_CHRATR_BEGIN &&
1951 : : pEntry->nWID > RES_TXTATR_END )
1952 : : {
1953 : 0 : pStates[i] = beans::PropertyState_DEFAULT_VALUE;
1954 : : }
1955 : : else
1956 : : {
1957 [ + + ][ + - ]: 243073 : if ( pEntry->nWID >= FN_UNO_RANGE_BEGIN &&
1958 : : pEntry->nWID <= FN_UNO_RANGE_END )
1959 : : {
1960 : : SwUnoCursorHelper::getCrsrPropertyValue(
1961 [ + - ]: 38 : *pEntry, rPaM, 0, pStates[i] );
1962 : : }
1963 : : else
1964 : : {
1965 [ + + ]: 243035 : if (!pSet.get())
1966 : : {
1967 [ + + + ]: 3877 : switch ( eCaller )
1968 : : {
1969 : : case SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT:
1970 : : case SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION:
1971 : : pSet.reset(
1972 : 3815 : new SfxItemSet( rPaM.GetDoc()->GetAttrPool(),
1973 [ + - ][ + - ]: 3815 : RES_CHRATR_BEGIN, RES_TXTATR_END ));
1974 : 3815 : break;
1975 : : case SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY:
1976 : : pSet.reset(
1977 : 6 : new SfxItemSet( rPaM.GetDoc()->GetAttrPool(),
1978 [ + - ][ + - ]: 6 : pEntry->nWID, pEntry->nWID ));
1979 : 6 : break;
1980 : : default:
1981 : : pSet.reset( new SfxItemSet(
1982 : 56 : rPaM.GetDoc()->GetAttrPool(),
1983 : : RES_CHRATR_BEGIN, RES_FRMATR_END - 1,
1984 : : RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER,
1985 : : RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER,
1986 [ + - ][ + - ]: 56 : 0L ));
1987 : : }
1988 : : // #i63870#
1989 [ + - ]: 3877 : SwUnoCursorHelper::GetCrsrAttr( rPaM, *pSet );
1990 : : }
1991 : :
1992 : 243035 : pStates[i] = ( pSet->Count() )
1993 : 6261 : ? rPropSet.getPropertyState( *pEntry, *pSet )
1994 [ + + ]: 249296 : : beans::PropertyState_DEFAULT_VALUE;
1995 : :
1996 : : //try again to find out if a value has been inherited
1997 [ + + ]: 243035 : if( beans::PropertyState_DIRECT_VALUE == pStates[i] )
1998 : : {
1999 [ + + ]: 321 : if (!pSetParent.get())
2000 : : {
2001 [ + - ]: 39 : pSetParent.reset( pSet->Clone( sal_False ) );
2002 : : // #i63870#
2003 : : SwUnoCursorHelper::GetCrsrAttr(
2004 [ + - ]: 39 : rPaM, *pSetParent, sal_True, sal_False );
2005 : : }
2006 : :
2007 : 321 : pStates[i] = ( (pSetParent)->Count() )
2008 : 12 : ? rPropSet.getPropertyState( *pEntry, *pSetParent )
2009 [ + + ]: 333 : : beans::PropertyState_DEFAULT_VALUE;
2010 : : }
2011 : : }
2012 : : }
2013 : : }
2014 [ + - ][ + - ]: 3879 : return aRet;
2015 : : }
2016 : :
2017 : 6 : beans::PropertyState SwUnoCursorHelper::GetPropertyState(
2018 : : SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
2019 : : const OUString& rPropertyName)
2020 : : throw (beans::UnknownPropertyException, uno::RuntimeException)
2021 : : {
2022 [ + - ]: 6 : uno::Sequence< OUString > aStrings ( 1 );
2023 [ + - ]: 6 : aStrings[0] = rPropertyName;
2024 : : uno::Sequence< beans::PropertyState > aSeq =
2025 : : GetPropertyStates(rPaM, rPropSet, aStrings,
2026 [ + - ]: 6 : SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY );
2027 [ + - ][ + - ]: 6 : return aSeq[0];
[ + - ]
2028 : : }
2029 : :
2030 : : static void
2031 : 2 : lcl_SelectParaAndReset( SwPaM &rPaM, SwDoc & rDoc,
2032 : : std::set<sal_uInt16> const &rWhichIds )
2033 : : {
2034 : : // if we are reseting paragraph attributes, we need to select the full paragraph first
2035 [ + - ][ + - ]: 2 : SwPosition aStart = *rPaM.Start();
2036 [ + - ][ + - ]: 2 : SwPosition aEnd = *rPaM.End();
2037 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
2038 [ + - ]: 2 : ::std::auto_ptr< SwUnoCrsr > pTemp ( rDoc.CreateUnoCrsr(aStart, sal_False) );
2039 : : SAL_WNODEPRECATED_DECLARATIONS_POP
2040 [ + - ]: 2 : if(!SwUnoCursorHelper::IsStartOfPara(*pTemp))
2041 : : {
2042 [ + - ]: 2 : pTemp->MovePara(fnParaCurr, fnParaStart);
2043 : : }
2044 [ + - ]: 2 : pTemp->SetMark();
2045 [ + - ]: 2 : *pTemp->GetPoint() = aEnd;
2046 [ + - ]: 2 : SwUnoCursorHelper::SelectPam(*pTemp, true);
2047 [ + - ][ - + ]: 2 : if(!SwUnoCursorHelper::IsEndOfPara(*pTemp))
2048 : : {
2049 [ # # ]: 0 : pTemp->MovePara(fnParaCurr, fnParaEnd);
2050 : : }
2051 [ + - ][ + - ]: 2 : rDoc.ResetAttrs(*pTemp, sal_True, rWhichIds);
[ + - ][ + - ]
2052 : 2 : }
2053 : :
2054 : 4 : void SwUnoCursorHelper::SetPropertyToDefault(
2055 : : SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
2056 : : const OUString& rPropertyName)
2057 : : throw (beans::UnknownPropertyException, uno::RuntimeException)
2058 : : {
2059 : 4 : SwDoc & rDoc = *rPaM.GetDoc();
2060 : : SfxItemPropertySimpleEntry const*const pEntry =
2061 : 4 : rPropSet.getPropertyMap().getByName(rPropertyName);
2062 [ - + ]: 4 : if (!pEntry)
2063 : : {
2064 : : throw beans::UnknownPropertyException(
2065 : : OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
2066 [ # # ][ # # ]: 0 : + rPropertyName, static_cast<cppu::OWeakObject *>(0));
[ # # ]
2067 : : }
2068 : :
2069 [ - + ]: 4 : if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
2070 : : {
2071 : : throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM(
2072 : : "setPropertyToDefault: property is read-only: "))
2073 [ # # ][ # # ]: 0 : + rPropertyName, 0);
[ # # ]
2074 : : }
2075 : :
2076 [ + - ]: 4 : if (pEntry->nWID < RES_FRMATR_END)
2077 : : {
2078 [ + - ]: 4 : std::set<sal_uInt16> aWhichIds;
2079 [ + - ]: 4 : aWhichIds.insert( pEntry->nWID );
2080 [ + - ]: 4 : if (pEntry->nWID < RES_PARATR_BEGIN)
2081 : : {
2082 [ + - ]: 4 : rDoc.ResetAttrs(rPaM, sal_True, aWhichIds);
2083 : : }
2084 : : else
2085 : : {
2086 [ # # ]: 0 : lcl_SelectParaAndReset ( rPaM, rDoc, aWhichIds );
2087 : 4 : }
2088 : : }
2089 : : else
2090 : : {
2091 : 0 : SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, rPaM);
2092 : : }
2093 : 4 : }
2094 : :
2095 : 4 : uno::Any SwUnoCursorHelper::GetPropertyDefault(
2096 : : SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
2097 : : const OUString& rPropertyName)
2098 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
2099 : : uno::RuntimeException)
2100 : : {
2101 : : SfxItemPropertySimpleEntry const*const pEntry =
2102 : 4 : rPropSet.getPropertyMap().getByName(rPropertyName);
2103 [ - + ]: 4 : if (!pEntry)
2104 : : {
2105 : : throw beans::UnknownPropertyException(
2106 : : OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
2107 [ # # ][ # # ]: 0 : + rPropertyName, static_cast<cppu::OWeakObject *>(0));
[ # # ]
2108 : : }
2109 : :
2110 : 4 : uno::Any aRet;
2111 [ + - ]: 4 : if (pEntry->nWID < RES_FRMATR_END)
2112 : : {
2113 : 4 : SwDoc & rDoc = *rPaM.GetDoc();
2114 : : const SfxPoolItem& rDefItem =
2115 [ + - ]: 4 : rDoc.GetAttrPool().GetDefaultItem(pEntry->nWID);
2116 [ + - ]: 4 : rDefItem.QueryValue(aRet, pEntry->nMemberId);
2117 : : }
2118 : 4 : return aRet;
2119 : : }
2120 : :
2121 : : uno::Reference< beans::XPropertySetInfo > SAL_CALL
2122 : 1724 : SwXTextCursor::getPropertySetInfo() throw (uno::RuntimeException)
2123 : : {
2124 [ + - ]: 1724 : SolarMutexGuard g;
2125 : :
2126 [ + + ][ + - ]: 1724 : static uno::Reference< beans::XPropertySetInfo > xRef;
2127 [ + + ]: 1724 : if(!xRef.is())
2128 : : {
2129 : : static SfxItemPropertyMapEntry aCrsrExtMap_Impl[] =
2130 : : {
2131 [ + - ][ + - ]: 33 : { SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT), FN_SKIP_HIDDEN_TEXT, &::getBooleanCppuType(), PROPERTY_NONE, 0},
[ + - ]
2132 [ + - ][ + - ]: 33 : { SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT), FN_SKIP_PROTECTED_TEXT, &::getBooleanCppuType(), PROPERTY_NONE, 0},
[ + - ]
2133 : : {0,0,0,0,0,0}
2134 [ + - ][ + - ]: 66 : };
[ # # ]
2135 : : const uno::Reference< beans::XPropertySetInfo > xInfo =
2136 [ + - ]: 33 : m_pImpl->m_rPropSet.getPropertySetInfo();
2137 : : // PropertySetInfo verlaengern!
2138 [ + - ][ + - ]: 33 : const uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties();
2139 : : xRef = new SfxExtItemPropertySetInfo(
2140 : : aCrsrExtMap_Impl,
2141 [ + - ][ + - ]: 33 : aPropSeq );
[ + - ][ + - ]
2142 : : }
2143 [ + - ]: 1724 : return xRef;
2144 : : }
2145 : :
2146 : : void SAL_CALL
2147 : 1570 : SwXTextCursor::setPropertyValue(
2148 : : const OUString& rPropertyName, const uno::Any& rValue)
2149 : : throw (beans::UnknownPropertyException, beans::PropertyVetoException,
2150 : : lang::IllegalArgumentException, lang::WrappedTargetException,
2151 : : uno::RuntimeException)
2152 : : {
2153 [ + - ]: 1570 : SolarMutexGuard aGuard;
2154 : :
2155 [ + - ]: 1570 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2156 : :
2157 [ + - ][ + - ]: 1570 : if (rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)))
[ - + ]
2158 : : {
2159 : 0 : sal_Bool bSet(sal_False);
2160 [ # # ]: 0 : if (!(rValue >>= bSet))
2161 : : {
2162 [ # # ]: 0 : throw lang::IllegalArgumentException();
2163 : : }
2164 : 0 : rUnoCursor.SetSkipOverHiddenSections(bSet);
2165 : : }
2166 [ - + ]: 1570 : else if (rPropertyName.equalsAsciiL(
2167 [ + - ][ + - ]: 1570 : SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT)))
2168 : : {
2169 : 0 : sal_Bool bSet(sal_False);
2170 [ # # ]: 0 : if (!(rValue >>= bSet))
2171 : : {
2172 [ # # ]: 0 : throw lang::IllegalArgumentException();
2173 : : }
2174 : 0 : rUnoCursor.SetSkipOverProtectSections(bSet);
2175 : : }
2176 : : else
2177 : : {
2178 : : SwUnoCursorHelper::SetPropertyValue(rUnoCursor,
2179 [ + - ]: 1570 : m_pImpl->m_rPropSet, rPropertyName, rValue);
2180 [ + - ]: 1570 : }
2181 : 1570 : }
2182 : :
2183 : : uno::Any SAL_CALL
2184 : 2084 : SwXTextCursor::getPropertyValue(const OUString& rPropertyName)
2185 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
2186 : : uno::RuntimeException)
2187 : : {
2188 [ + - ]: 2084 : SolarMutexGuard aGuard;
2189 : :
2190 [ + - ]: 2084 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2191 : :
2192 : 2084 : uno::Any aAny;
2193 [ + - ][ - + ]: 2084 : if (rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)))
[ + - ]
2194 : : {
2195 [ # # ]: 0 : const sal_Bool bSet = rUnoCursor.IsSkipOverHiddenSections();
2196 [ # # ]: 0 : aAny <<= bSet;
2197 : : }
2198 [ - + ]: 2084 : else if (rPropertyName.equalsAsciiL(
2199 [ + - ][ + - ]: 2084 : SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT)))
2200 : : {
2201 [ # # ]: 0 : const sal_Bool bSet = rUnoCursor.IsSkipOverProtectSections();
2202 [ # # ]: 0 : aAny <<= bSet;
2203 : : }
2204 : : else
2205 : : {
2206 : : aAny = SwUnoCursorHelper::GetPropertyValue(rUnoCursor,
2207 [ + - ]: 2084 : m_pImpl->m_rPropSet, rPropertyName);
2208 : : }
2209 [ + - ]: 2084 : return aAny;
2210 : : }
2211 : :
2212 : : void SAL_CALL
2213 : 0 : SwXTextCursor::addPropertyChangeListener(
2214 : : const ::rtl::OUString& /*rPropertyName*/,
2215 : : const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
2216 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
2217 : : uno::RuntimeException)
2218 : : {
2219 : : OSL_FAIL("SwXTextCursor::addPropertyChangeListener(): not implemented");
2220 : 0 : }
2221 : :
2222 : : void SAL_CALL
2223 : 0 : SwXTextCursor::removePropertyChangeListener(
2224 : : const ::rtl::OUString& /*rPropertyName*/,
2225 : : const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
2226 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
2227 : : uno::RuntimeException)
2228 : : {
2229 : : OSL_FAIL("SwXTextCursor::removePropertyChangeListener(): not implemented");
2230 : 0 : }
2231 : :
2232 : : void SAL_CALL
2233 : 0 : SwXTextCursor::addVetoableChangeListener(
2234 : : const ::rtl::OUString& /*rPropertyName*/,
2235 : : const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
2236 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
2237 : : uno::RuntimeException)
2238 : : {
2239 : : OSL_FAIL("SwXTextCursor::addVetoableChangeListener(): not implemented");
2240 : 0 : }
2241 : :
2242 : : void SAL_CALL
2243 : 0 : SwXTextCursor::removeVetoableChangeListener(
2244 : : const ::rtl::OUString& /*rPropertyName*/,
2245 : : const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
2246 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
2247 : : uno::RuntimeException)
2248 : : {
2249 : : OSL_FAIL("SwXTextCursor::removeVetoableChangeListener(): not implemented");
2250 : 0 : }
2251 : :
2252 : : beans::PropertyState SAL_CALL
2253 : 2 : SwXTextCursor::getPropertyState(const OUString& rPropertyName)
2254 : : throw (beans::UnknownPropertyException, uno::RuntimeException)
2255 : : {
2256 [ + - ]: 2 : SolarMutexGuard aGuard;
2257 : :
2258 [ + - ]: 2 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2259 : :
2260 : : const beans::PropertyState eRet = SwUnoCursorHelper::GetPropertyState(
2261 [ + - ]: 2 : rUnoCursor, m_pImpl->m_rPropSet, rPropertyName);
2262 [ + - ]: 2 : return eRet;
2263 : : }
2264 : :
2265 : : uno::Sequence< beans::PropertyState > SAL_CALL
2266 : 8 : SwXTextCursor::getPropertyStates(
2267 : : const uno::Sequence< OUString >& rPropertyNames)
2268 : : throw (beans::UnknownPropertyException, uno::RuntimeException)
2269 : : {
2270 [ + - ]: 8 : SolarMutexGuard aGuard;
2271 : :
2272 [ + - ]: 8 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2273 : :
2274 : : return SwUnoCursorHelper::GetPropertyStates(
2275 [ + - ][ + - ]: 8 : rUnoCursor, m_pImpl->m_rPropSet, rPropertyNames);
2276 : : }
2277 : :
2278 : : void SAL_CALL
2279 : 2 : SwXTextCursor::setPropertyToDefault(const OUString& rPropertyName)
2280 : : throw (beans::UnknownPropertyException, uno::RuntimeException)
2281 : : {
2282 : : // forward: need no solar mutex here
2283 [ + - ]: 2 : uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
2284 [ + - ][ + - ]: 2 : setPropertiesToDefault ( aSequence );
2285 : 2 : }
2286 : :
2287 : : uno::Any SAL_CALL
2288 : 2 : SwXTextCursor::getPropertyDefault(const OUString& rPropertyName)
2289 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
2290 : : uno::RuntimeException)
2291 : : {
2292 : : // forward: need no solar mutex here
2293 [ + - ]: 2 : const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
2294 [ + - ][ + - ]: 2 : return getPropertyDefaults ( aSequence ).getConstArray()[0];
[ + - ]
2295 : : }
2296 : :
2297 : : // para specific attribut ranges
2298 : : static sal_uInt16 g_ParaResetableSetRange[] = {
2299 : : RES_FRMATR_BEGIN, RES_FRMATR_END-1,
2300 : : RES_PARATR_BEGIN, RES_PARATR_END-1,
2301 : : RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1,
2302 : : RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
2303 : : 0
2304 : : };
2305 : :
2306 : : // selection specific attribut ranges
2307 : : static sal_uInt16 g_ResetableSetRange[] = {
2308 : : RES_CHRATR_BEGIN, RES_CHRATR_END-1,
2309 : : RES_TXTATR_INETFMT, RES_TXTATR_INETFMT,
2310 : : RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT,
2311 : : RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY,
2312 : : RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER,
2313 : : 0
2314 : : };
2315 : :
2316 : : static void
2317 : 4 : lcl_EnumerateIds(sal_uInt16 const* pIdRange, std::set<sal_uInt16> &rWhichIds)
2318 : : {
2319 [ + + ]: 22 : while (*pIdRange)
2320 : : {
2321 : 18 : const sal_uInt16 nStart = sal::static_int_cast<sal_uInt16>(*pIdRange++);
2322 : 18 : const sal_uInt16 nEnd = sal::static_int_cast<sal_uInt16>(*pIdRange++);
2323 [ + + ]: 218 : for (sal_uInt16 nId = nStart + 1; nId <= nEnd; ++nId)
2324 : : {
2325 [ + - ]: 200 : rWhichIds.insert( rWhichIds.end(), nId );
2326 : : }
2327 : : }
2328 : 4 : }
2329 : :
2330 : : void SAL_CALL
2331 : 2 : SwXTextCursor::setAllPropertiesToDefault()
2332 : : throw (uno::RuntimeException)
2333 : : {
2334 [ + - ]: 2 : SolarMutexGuard aGuard;
2335 : :
2336 [ + - ]: 2 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2337 : :
2338 [ + - ]: 2 : std::set<sal_uInt16> aParaWhichIds;
2339 [ + - ]: 2 : std::set<sal_uInt16> aWhichIds;
2340 [ + - ]: 2 : lcl_EnumerateIds(g_ParaResetableSetRange, aParaWhichIds);
2341 [ + - ]: 2 : lcl_EnumerateIds(g_ResetableSetRange, aWhichIds);
2342 [ + - ]: 2 : if (!aParaWhichIds.empty())
2343 : : {
2344 : 2 : lcl_SelectParaAndReset(rUnoCursor, *rUnoCursor.GetDoc(),
2345 [ + - ]: 2 : aParaWhichIds);
2346 : : }
2347 [ + - ]: 2 : if (!aWhichIds.empty())
2348 : : {
2349 [ + - ]: 2 : rUnoCursor.GetDoc()->ResetAttrs(rUnoCursor, sal_True, aWhichIds);
2350 [ + - ]: 2 : }
2351 : 2 : }
2352 : :
2353 : : void SAL_CALL
2354 : 4 : SwXTextCursor::setPropertiesToDefault(
2355 : : const uno::Sequence< OUString >& rPropertyNames)
2356 : : throw (beans::UnknownPropertyException, uno::RuntimeException)
2357 : : {
2358 [ + - ]: 4 : SolarMutexGuard aGuard;
2359 : :
2360 [ + - ]: 4 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2361 : :
2362 : 4 : const sal_Int32 nCount = rPropertyNames.getLength();
2363 [ + - ]: 4 : if ( nCount )
2364 : : {
2365 : 4 : SwDoc & rDoc = *rUnoCursor.GetDoc();
2366 : 4 : const OUString * pNames = rPropertyNames.getConstArray();
2367 [ + - ]: 4 : std::set<sal_uInt16> aWhichIds;
2368 [ + - ]: 4 : std::set<sal_uInt16> aParaWhichIds;
2369 [ + + ]: 8 : for (sal_Int32 i = 0; i < nCount; i++)
2370 : : {
2371 : : SfxItemPropertySimpleEntry const*const pEntry =
2372 [ + - ]: 4 : m_pImpl->m_rPropSet.getPropertyMap().getByName( pNames[i] );
2373 [ - + ]: 4 : if (!pEntry)
2374 : : {
2375 [ # # ]: 0 : if (pNames[i].equalsAsciiL(
[ # # # # ]
2376 [ # # ][ # # ]: 0 : SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) ||
2377 : : pNames[i].equalsAsciiL(
2378 [ # # ][ # # ]: 0 : SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT)))
2379 : : {
2380 : 0 : continue;
2381 : : }
2382 : : throw beans::UnknownPropertyException(
2383 : : OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
2384 : 0 : + pNames[i],
2385 [ # # ][ # # ]: 0 : static_cast<cppu::OWeakObject *>(this));
[ # # ]
2386 : : }
2387 [ - + ]: 4 : if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
2388 : : {
2389 : : throw uno::RuntimeException(
2390 : : OUString(RTL_CONSTASCII_USTRINGPARAM(
2391 : : "setPropertiesToDefault: property is read-only: "))
2392 : 0 : + pNames[i],
2393 [ # # ][ # # ]: 0 : static_cast<cppu::OWeakObject *>(this));
[ # # ]
2394 : : }
2395 : :
2396 [ + + ]: 4 : if (pEntry->nWID < RES_FRMATR_END)
2397 : : {
2398 [ + - ]: 2 : if (pEntry->nWID < RES_PARATR_BEGIN)
2399 : : {
2400 [ + - ]: 2 : aWhichIds.insert( pEntry->nWID );
2401 : : }
2402 : : else
2403 : : {
2404 [ # # ]: 0 : aParaWhichIds.insert( pEntry->nWID );
2405 : : }
2406 : : }
2407 [ + - ]: 2 : else if (pEntry->nWID == FN_UNO_NUM_START_VALUE)
2408 : : {
2409 [ + - ]: 2 : SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, rUnoCursor);
2410 : : }
2411 : : }
2412 : :
2413 [ - + ]: 4 : if (!aParaWhichIds.empty())
2414 : : {
2415 [ # # ]: 0 : lcl_SelectParaAndReset(rUnoCursor, rDoc, aParaWhichIds);
2416 : : }
2417 [ + + ]: 4 : if (!aWhichIds.empty())
2418 : : {
2419 [ + - ]: 2 : rDoc.ResetAttrs(rUnoCursor, sal_True, aWhichIds);
2420 : 4 : }
2421 [ + - ]: 4 : }
2422 : 4 : }
2423 : :
2424 : : uno::Sequence< uno::Any > SAL_CALL
2425 : 4 : SwXTextCursor::getPropertyDefaults(
2426 : : const uno::Sequence< OUString >& rPropertyNames)
2427 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
2428 : : uno::RuntimeException)
2429 : : {
2430 [ + - ]: 4 : SolarMutexGuard aGuard;
2431 : :
2432 [ + - ]: 4 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2433 : :
2434 : 4 : const sal_Int32 nCount = rPropertyNames.getLength();
2435 [ + - ]: 4 : uno::Sequence< uno::Any > aRet(nCount);
2436 [ + - ]: 4 : if ( nCount )
2437 : : {
2438 : 4 : SwDoc & rDoc = *rUnoCursor.GetDoc();
2439 : 4 : const OUString *pNames = rPropertyNames.getConstArray();
2440 [ + - ]: 4 : uno::Any *pAny = aRet.getArray();
2441 [ + + ]: 284 : for (sal_Int32 i = 0; i < nCount; i++)
2442 : : {
2443 : : SfxItemPropertySimpleEntry const*const pEntry =
2444 [ + - ]: 280 : m_pImpl->m_rPropSet.getPropertyMap().getByName( pNames[i] );
2445 [ + + ]: 280 : if (!pEntry)
2446 : : {
2447 [ + - ]: 6 : if (pNames[i].equalsAsciiL(
[ + + + - ]
2448 [ + - ][ + - ]: 4 : SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) ||
2449 : : pNames[i].equalsAsciiL(
2450 [ + - ][ + - ]: 2 : SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT)))
2451 : : {
2452 : 4 : continue;
2453 : : }
2454 : : throw beans::UnknownPropertyException(
2455 : : OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
2456 : 0 : + pNames[i],
2457 [ # # ][ # # ]: 0 : static_cast<cppu::OWeakObject *>(0));
[ # # ]
2458 : : }
2459 [ + + ]: 276 : if (pEntry->nWID < RES_FRMATR_END)
2460 : : {
2461 : : const SfxPoolItem& rDefItem =
2462 [ + - ]: 256 : rDoc.GetAttrPool().GetDefaultItem(pEntry->nWID);
2463 [ + - ]: 256 : rDefItem.QueryValue(pAny[i], pEntry->nMemberId);
2464 : : }
2465 : : }
2466 : : }
2467 [ + - ]: 4 : return aRet;
2468 : : }
2469 : :
2470 : : void SAL_CALL
2471 : 0 : SwXTextCursor::makeRedline(
2472 : : const ::rtl::OUString& rRedlineType,
2473 : : const uno::Sequence< beans::PropertyValue >& rRedlineProperties)
2474 : : throw (lang::IllegalArgumentException, uno::RuntimeException)
2475 : : {
2476 [ # # ]: 0 : SolarMutexGuard aGuard;
2477 : :
2478 [ # # ]: 0 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2479 : :
2480 [ # # ][ # # ]: 0 : SwUnoCursorHelper::makeRedline(rUnoCursor, rRedlineType, rRedlineProperties);
2481 : 0 : }
2482 : :
2483 : 0 : void SAL_CALL SwXTextCursor::insertDocumentFromURL(const OUString& rURL,
2484 : : const uno::Sequence< beans::PropertyValue >& rOptions)
2485 : : throw (lang::IllegalArgumentException, io::IOException,
2486 : : uno::RuntimeException)
2487 : : {
2488 [ # # ]: 0 : SolarMutexGuard aGuard;
2489 : :
2490 [ # # ]: 0 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2491 : :
2492 [ # # ][ # # ]: 0 : SwUnoCursorHelper::InsertFile(&rUnoCursor, rURL, rOptions);
[ # # ][ # # ]
2493 : 0 : }
2494 : :
2495 : : uno::Sequence< beans::PropertyValue >
2496 : 4 : SwUnoCursorHelper::CreateSortDescriptor(const bool bFromTable)
2497 : : {
2498 [ + - ]: 4 : uno::Sequence< beans::PropertyValue > aRet(5);
2499 [ + - ]: 4 : beans::PropertyValue* pArray = aRet.getArray();
2500 : :
2501 : 4 : uno::Any aVal;
2502 [ + - ]: 4 : aVal.setValue( &bFromTable, ::getCppuBooleanType());
2503 : : pArray[0] = beans::PropertyValue(C2U("IsSortInTable"), -1, aVal,
2504 [ + - ]: 4 : beans::PropertyState_DIRECT_VALUE);
2505 : :
2506 [ + - ]: 4 : aVal <<= sal_Unicode(' ');
2507 : : pArray[1] = beans::PropertyValue(C2U("Delimiter"), -1, aVal,
2508 [ + - ]: 4 : beans::PropertyState_DIRECT_VALUE);
2509 : :
2510 [ + - ]: 4 : aVal <<= (sal_Bool) sal_False;
2511 : : pArray[2] = beans::PropertyValue(C2U("IsSortColumns"), -1, aVal,
2512 [ + - ]: 4 : beans::PropertyState_DIRECT_VALUE);
2513 : :
2514 [ + - ]: 4 : aVal <<= (sal_Int32) 3;
2515 : : pArray[3] = beans::PropertyValue(C2U("MaxSortFieldsCount"), -1, aVal,
2516 [ + - ]: 4 : beans::PropertyState_DIRECT_VALUE);
2517 : :
2518 [ + - ]: 4 : uno::Sequence< table::TableSortField > aFields(3);
2519 [ + - ]: 4 : table::TableSortField* pFields = aFields.getArray();
2520 : :
2521 [ + - ]: 4 : lang::Locale aLang( SvxCreateLocale( LANGUAGE_SYSTEM ) );
2522 : : // get collator algorithm to be used for the locale
2523 : : uno::Sequence< OUString > aSeq(
2524 [ + - ][ + - ]: 4 : GetAppCollator().listCollatorAlgorithms( aLang ) );
2525 : 4 : const sal_Int32 nLen = aSeq.getLength();
2526 : : OSL_ENSURE( nLen > 0, "list of collator algorithms is empty!");
2527 : 4 : OUString aCollAlg;
2528 [ + - ]: 4 : if (nLen > 0)
2529 : : {
2530 : 4 : aCollAlg = aSeq.getConstArray()[0];
2531 : : }
2532 : :
2533 : : #if OSL_DEBUG_LEVEL > 1
2534 : : const OUString *pTxt = aSeq.getConstArray();
2535 : : (void)pTxt;
2536 : : #endif
2537 : :
2538 : 4 : pFields[0].Field = 1;
2539 : 4 : pFields[0].IsAscending = sal_True;
2540 : 4 : pFields[0].IsCaseSensitive = sal_False;
2541 : 4 : pFields[0].FieldType = table::TableSortFieldType_ALPHANUMERIC;
2542 : 4 : pFields[0].CollatorLocale = aLang;
2543 : 4 : pFields[0].CollatorAlgorithm = aCollAlg;
2544 : :
2545 : 4 : pFields[1].Field = 1;
2546 : 4 : pFields[1].IsAscending = sal_True;
2547 : 4 : pFields[1].IsCaseSensitive = sal_False;
2548 : 4 : pFields[1].FieldType = table::TableSortFieldType_ALPHANUMERIC;
2549 : 4 : pFields[1].CollatorLocale = aLang;
2550 : 4 : pFields[1].CollatorAlgorithm = aCollAlg;
2551 : :
2552 : 4 : pFields[2].Field = 1;
2553 : 4 : pFields[2].IsAscending = sal_True;
2554 : 4 : pFields[2].IsCaseSensitive = sal_False;
2555 : 4 : pFields[2].FieldType = table::TableSortFieldType_ALPHANUMERIC;
2556 : 4 : pFields[2].CollatorLocale = aLang;
2557 : 4 : pFields[2].CollatorAlgorithm = aCollAlg;
2558 : :
2559 [ + - ]: 4 : aVal <<= aFields;
2560 : : pArray[4] = beans::PropertyValue(C2U("SortFields"), -1, aVal,
2561 [ + - ]: 4 : beans::PropertyState_DIRECT_VALUE);
2562 : :
2563 [ + - ][ + - ]: 4 : return aRet;
2564 : : }
2565 : :
2566 : : uno::Sequence< beans::PropertyValue > SAL_CALL
2567 : 2 : SwXTextCursor::createSortDescriptor() throw (uno::RuntimeException)
2568 : : {
2569 [ + - ]: 2 : SolarMutexGuard aGuard;
2570 : :
2571 [ + - ][ + - ]: 2 : return SwUnoCursorHelper::CreateSortDescriptor(false);
2572 : : }
2573 : :
2574 : 16 : sal_Bool SwUnoCursorHelper::ConvertSortProperties(
2575 : : const uno::Sequence< beans::PropertyValue >& rDescriptor,
2576 : : SwSortOptions& rSortOpt)
2577 : : {
2578 : 16 : sal_Bool bRet = sal_True;
2579 : 16 : const beans::PropertyValue* pProperties = rDescriptor.getConstArray();
2580 : :
2581 : 16 : rSortOpt.bTable = sal_False;
2582 : 16 : rSortOpt.cDeli = ' ';
2583 : 16 : rSortOpt.eDirection = SRT_COLUMNS; //!! UI text may be contrary though !!
2584 : :
2585 [ + - ][ + - ]: 16 : SwSortKey* pKey1 = new SwSortKey;
2586 : 16 : pKey1->nColumnId = USHRT_MAX;
2587 : 16 : pKey1->bIsNumeric = sal_True;
2588 : 16 : pKey1->eSortOrder = SRT_ASCENDING;
2589 : :
2590 [ + - ][ + - ]: 16 : SwSortKey* pKey2 = new SwSortKey;
2591 : 16 : pKey2->nColumnId = USHRT_MAX;
2592 : 16 : pKey2->bIsNumeric = sal_True;
2593 : 16 : pKey2->eSortOrder = SRT_ASCENDING;
2594 : :
2595 [ + - ][ + - ]: 16 : SwSortKey* pKey3 = new SwSortKey;
2596 : 16 : pKey3->nColumnId = USHRT_MAX;
2597 : 16 : pKey3->bIsNumeric = sal_True;
2598 : 16 : pKey3->eSortOrder = SRT_ASCENDING;
2599 : 16 : SwSortKey* aKeys[3] = {pKey1, pKey2, pKey3};
2600 : :
2601 : 16 : sal_Bool bOldSortdescriptor(sal_False);
2602 : 16 : sal_Bool bNewSortdescriptor(sal_False);
2603 : :
2604 [ + + ]: 96 : for (sal_Int32 n = 0; n < rDescriptor.getLength(); ++n)
2605 : : {
2606 : 80 : uno::Any aValue( pProperties[n].Value );
2607 : : // String sPropName = pProperties[n].Name;
2608 : 80 : const OUString& rPropName = pProperties[n].Name;
2609 : :
2610 : : // old and new sortdescriptor
2611 [ + + ]: 80 : if ( rPropName == "IsSortInTable" )
2612 : : {
2613 [ + - ][ + - ]: 16 : if (aValue.getValueType() == ::getBooleanCppuType())
2614 : : {
2615 : 16 : rSortOpt.bTable = *(sal_Bool*)aValue.getValue();
2616 : : }
2617 : : else
2618 : : {
2619 : 0 : bRet = sal_False;
2620 : : }
2621 : : }
2622 [ + + ]: 64 : else if ( rPropName == "Delimiter" )
2623 : : {
2624 : 16 : sal_Unicode uChar = sal_Unicode();
2625 [ + - ]: 16 : if (aValue >>= uChar)
2626 : : {
2627 : 16 : rSortOpt.cDeli = uChar;
2628 : : }
2629 : : else
2630 : : {
2631 : 16 : bRet = sal_False;
2632 : : }
2633 : : }
2634 : : // old sortdescriptor
2635 [ - + ]: 48 : else if ( rPropName == "SortColumns" )
2636 : : {
2637 : 0 : bOldSortdescriptor = sal_True;
2638 : 0 : sal_Bool bTemp(sal_False);
2639 [ # # ]: 0 : if (aValue >>= bTemp)
2640 : : {
2641 : 0 : rSortOpt.eDirection = bTemp ? SRT_COLUMNS : SRT_ROWS;
2642 : : }
2643 : : else
2644 : : {
2645 : 0 : bRet = sal_False;
2646 : : }
2647 : : }
2648 [ - + ]: 48 : else if ( rPropName == "IsCaseSensitive" )
2649 : : {
2650 : 0 : bOldSortdescriptor = sal_True;
2651 : 0 : sal_Bool bTemp(sal_False);
2652 [ # # ]: 0 : if (aValue >>= bTemp)
2653 : : {
2654 : 0 : rSortOpt.bIgnoreCase = !bTemp;
2655 : : }
2656 : : else
2657 : : {
2658 : 0 : bRet = sal_False;
2659 : : }
2660 : : }
2661 [ - + ]: 48 : else if ( rPropName == "CollatorLocale" )
2662 : : {
2663 : 0 : bOldSortdescriptor = sal_True;
2664 : 0 : lang::Locale aLocale;
2665 [ # # ][ # # ]: 0 : if (aValue >>= aLocale)
2666 : : {
2667 [ # # ]: 0 : rSortOpt.nLanguage = SvxLocaleToLanguage( aLocale );
2668 : : }
2669 : : else
2670 : : {
2671 : 0 : bRet = sal_False;
2672 : 0 : }
2673 : : }
2674 [ - + # # : 48 : else if (rPropName.matchAsciiL("CollatorAlgorithm", 17) &&
# # # # ]
[ - + ]
2675 : 0 : rPropName.getLength() == 18 &&
2676 : 0 : (rPropName.getStr()[17] >= '0' && rPropName.getStr()[17] <= '9'))
2677 : : {
2678 : 0 : bOldSortdescriptor = sal_True;
2679 : 0 : sal_uInt16 nIndex = rPropName.getStr()[17];
2680 : 0 : nIndex -= '0';
2681 : 0 : OUString aTxt;
2682 [ # # ][ # # ]: 0 : if ((aValue >>= aTxt) && nIndex < 3)
[ # # ]
2683 : : {
2684 [ # # ]: 0 : aKeys[nIndex]->sSortType = aTxt;
2685 : : }
2686 : : else
2687 : : {
2688 : 0 : bRet = sal_False;
2689 : 0 : }
2690 : : }
2691 [ - + # # : 48 : else if (rPropName.matchAsciiL("SortRowOrColumnNo", 17) &&
# # # # ]
[ - + ]
2692 : 0 : rPropName.getLength() == 18 &&
2693 : 0 : (rPropName.getStr()[17] >= '0' && rPropName.getStr()[17] <= '9'))
2694 : : {
2695 : 0 : bOldSortdescriptor = sal_True;
2696 : 0 : sal_uInt16 nIndex = rPropName.getStr()[17];
2697 : 0 : nIndex -= '0';
2698 : 0 : sal_Int16 nCol = -1;
2699 [ # # ][ # # ]: 0 : if (aValue.getValueType() == ::getCppuType((const sal_Int16*)0)
[ # # ][ # # ]
2700 : : && nIndex < 3)
2701 : : {
2702 : 0 : aValue >>= nCol;
2703 : : }
2704 [ # # ]: 0 : if (nCol >= 0)
2705 : : {
2706 : 0 : aKeys[nIndex]->nColumnId = nCol;
2707 : : }
2708 : : else
2709 : : {
2710 : 0 : bRet = sal_False;
2711 : : }
2712 : : }
2713 [ + - ][ - + : 48 : else if (0 == rPropName.indexOf(C2U("IsSortNumeric")) &&
# # # # #
# ][ + - ]
[ - + # # ]
2714 : 0 : rPropName.getLength() == 14 &&
2715 : 0 : (rPropName.getStr()[13] >= '0' && rPropName.getStr()[13] <= '9'))
2716 : : {
2717 : 0 : bOldSortdescriptor = sal_True;
2718 : 0 : sal_uInt16 nIndex = rPropName.getStr()[13];
2719 : 0 : nIndex = nIndex - '0';
2720 [ # # ][ # # ]: 0 : if (aValue.getValueType() == ::getBooleanCppuType() && nIndex < 3)
[ # # ][ # # ]
2721 : : {
2722 : 0 : sal_Bool bTemp = *(sal_Bool*)aValue.getValue();
2723 : 0 : aKeys[nIndex]->bIsNumeric = bTemp;
2724 : : }
2725 : : else
2726 : : {
2727 : 0 : bRet = sal_False;
2728 : : }
2729 : : }
2730 [ + - ][ - + : 48 : else if (0 == rPropName.indexOf(C2U("IsSortAscending")) &&
# # # # #
# ][ + - ]
[ - + # # ]
2731 : 0 : rPropName.getLength() == 16 &&
2732 : 0 : (rPropName.getStr()[15] >= '0' && rPropName.getStr()[15] <= '9'))
2733 : : {
2734 : 0 : bOldSortdescriptor = sal_True;
2735 : 0 : sal_uInt16 nIndex = rPropName.getStr()[15];
2736 : 0 : nIndex -= '0';
2737 [ # # ][ # # ]: 0 : if (aValue.getValueType() == ::getBooleanCppuType() && nIndex < 3)
[ # # ][ # # ]
2738 : : {
2739 : 0 : sal_Bool bTemp = *(sal_Bool*)aValue.getValue();
2740 : 0 : aKeys[nIndex]->eSortOrder = (bTemp)
2741 : 0 : ? SRT_ASCENDING : SRT_DESCENDING;
2742 : : }
2743 : : else
2744 : : {
2745 : 0 : bRet = sal_False;
2746 : : }
2747 : : }
2748 : : // new sortdescriptor
2749 [ + + ]: 48 : else if ( rPropName == "IsSortColumns" )
2750 : : {
2751 : 16 : bNewSortdescriptor = sal_True;
2752 [ + - ][ + - ]: 16 : if (aValue.getValueType() == ::getBooleanCppuType())
2753 : : {
2754 : 16 : sal_Bool bTemp = *(sal_Bool*)aValue.getValue();
2755 : 16 : rSortOpt.eDirection = bTemp ? SRT_COLUMNS : SRT_ROWS;
2756 : : }
2757 : : else
2758 : : {
2759 : 0 : bRet = sal_False;
2760 : : }
2761 : : }
2762 [ + + ]: 32 : else if ( rPropName == "SortFields" )
2763 : : {
2764 : 16 : bNewSortdescriptor = sal_True;
2765 [ + - ]: 16 : uno::Sequence < table::TableSortField > aFields;
2766 [ + - ][ + - ]: 16 : if (aValue >>= aFields)
2767 : : {
2768 : 16 : sal_Int32 nCount(aFields.getLength());
2769 [ + - ]: 16 : if (nCount <= 3)
2770 : : {
2771 [ + - ]: 16 : table::TableSortField* pFields = aFields.getArray();
2772 [ + + ]: 64 : for (sal_Int32 i = 0; i < nCount; ++i)
2773 : : {
2774 : 48 : rSortOpt.bIgnoreCase = !pFields[i].IsCaseSensitive;
2775 : : rSortOpt.nLanguage =
2776 [ + - ]: 48 : SvxLocaleToLanguage( pFields[i].CollatorLocale );
2777 [ + - ]: 48 : aKeys[i]->sSortType = pFields[i].CollatorAlgorithm;
2778 : 48 : aKeys[i]->nColumnId =
2779 : 48 : static_cast<sal_uInt16>(pFields[i].Field);
2780 : 48 : aKeys[i]->bIsNumeric = (pFields[i].FieldType ==
2781 : 48 : table::TableSortFieldType_NUMERIC);
2782 : 48 : aKeys[i]->eSortOrder = (pFields[i].IsAscending)
2783 : 48 : ? SRT_ASCENDING : SRT_DESCENDING;
2784 : : }
2785 : : }
2786 : : else
2787 : : {
2788 : 0 : bRet = sal_False;
2789 : : }
2790 : : }
2791 : : else
2792 : : {
2793 : 0 : bRet = sal_False;
2794 [ + - ]: 16 : }
2795 : : }
2796 : 80 : }
2797 : :
2798 [ + - ][ - + ]: 16 : if (bNewSortdescriptor && bOldSortdescriptor)
2799 : : {
2800 : : OSL_FAIL("someone tried to set the old deprecated and "
2801 : : "the new sortdescriptor");
2802 : 0 : bRet = sal_False;
2803 : : }
2804 : :
2805 [ + - ]: 16 : if (pKey1->nColumnId != USHRT_MAX)
2806 : : {
2807 [ + - ]: 16 : rSortOpt.aKeys.push_back(pKey1);
2808 : : }
2809 [ + - ]: 16 : if (pKey2->nColumnId != USHRT_MAX)
2810 : : {
2811 [ + - ]: 16 : rSortOpt.aKeys.push_back(pKey2);
2812 : : }
2813 [ + - ]: 16 : if (pKey3->nColumnId != USHRT_MAX)
2814 : : {
2815 [ + - ]: 16 : rSortOpt.aKeys.push_back(pKey3);
2816 : : }
2817 : :
2818 [ + - ][ + - ]: 16 : return bRet && !rSortOpt.aKeys.empty();
2819 : : }
2820 : :
2821 : : void SAL_CALL
2822 : 8 : SwXTextCursor::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor)
2823 : : throw (uno::RuntimeException)
2824 : : {
2825 [ + - ]: 8 : SolarMutexGuard aGuard;
2826 : :
2827 [ + - ]: 8 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2828 : :
2829 [ + - ]: 8 : if (rUnoCursor.HasMark())
2830 : : {
2831 [ + - ]: 8 : SwSortOptions aSortOpt;
2832 [ + - ][ - + ]: 8 : if (!SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt))
2833 : : {
2834 [ # # ]: 0 : throw uno::RuntimeException();
2835 : : }
2836 [ + - ]: 8 : UnoActionContext aContext( rUnoCursor.GetDoc() );
2837 : :
2838 [ + - ]: 8 : SwPosition & rStart = *rUnoCursor.Start();
2839 [ + - ]: 8 : SwPosition & rEnd = *rUnoCursor.End();
2840 : :
2841 [ + - ]: 8 : SwNodeIndex aPrevIdx( rStart.nNode, -1 );
2842 : 8 : const sal_uLong nOffset = rEnd.nNode.GetIndex() - rStart.nNode.GetIndex();
2843 : 8 : const xub_StrLen nCntStt = rStart.nContent.GetIndex();
2844 : :
2845 [ + - ]: 8 : rUnoCursor.GetDoc()->SortText(rUnoCursor, aSortOpt);
2846 : :
2847 : : // Selektion wieder setzen
2848 [ + - ]: 8 : rUnoCursor.DeleteMark();
2849 [ + - ]: 8 : rUnoCursor.GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 );
2850 : 8 : SwCntntNode *const pCNd = rUnoCursor.GetCntntNode();
2851 [ + - ]: 8 : xub_StrLen nLen = pCNd->Len();
2852 [ + + ]: 8 : if (nLen > nCntStt)
2853 : : {
2854 : 6 : nLen = nCntStt;
2855 : : }
2856 [ + - ][ + - ]: 8 : rUnoCursor.GetPoint()->nContent.Assign(pCNd, nLen );
2857 [ + - ]: 8 : rUnoCursor.SetMark();
2858 : :
2859 [ + - ]: 8 : rUnoCursor.GetPoint()->nNode += nOffset;
2860 : 8 : SwCntntNode *const pCNd2 = rUnoCursor.GetCntntNode();
2861 [ + - ][ + - ]: 8 : rUnoCursor.GetPoint()->nContent.Assign( pCNd2, pCNd2->Len() );
[ + - ][ + - ]
[ + - ][ + - ]
2862 [ + - ]: 8 : }
2863 : 8 : }
2864 : :
2865 : : uno::Reference< container::XEnumeration > SAL_CALL
2866 : 2 : SwXTextCursor::createContentEnumeration(const OUString& rServiceName)
2867 : : throw (uno::RuntimeException)
2868 : : {
2869 [ + - ]: 2 : SolarMutexGuard g;
2870 : :
2871 [ - + ]: 2 : if (!rServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.TextContent")))
2872 : : {
2873 [ # # ]: 0 : throw uno::RuntimeException();
2874 : : }
2875 : :
2876 [ + - ]: 2 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2877 : :
2878 : : uno::Reference< container::XEnumeration > xRet =
2879 [ + - ][ + - ]: 2 : new SwXParaFrameEnumeration(rUnoCursor, PARAFRAME_PORTION_TEXTRANGE);
[ + - ]
2880 [ + - ]: 2 : return xRet;
2881 : : }
2882 : :
2883 : : uno::Reference< container::XEnumeration > SAL_CALL
2884 : 444 : SwXTextCursor::createEnumeration() throw (uno::RuntimeException)
2885 : : {
2886 [ + - ]: 444 : SolarMutexGuard g;
2887 : :
2888 [ + - ]: 444 : SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2889 : :
2890 : : const uno::Reference<lang::XUnoTunnel> xTunnel(
2891 [ + - ]: 444 : m_pImpl->m_xParentText, uno::UNO_QUERY);
2892 : 444 : SwXText* pParentText = 0;
2893 [ + - ]: 444 : if (xTunnel.is())
2894 : : {
2895 [ + - ]: 444 : pParentText = ::sw::UnoTunnelGetImplementation<SwXText>(xTunnel);
2896 : : }
2897 : : OSL_ENSURE(pParentText, "parent is not a SwXText");
2898 [ - + ]: 444 : if (!pParentText)
2899 : : {
2900 [ # # ]: 0 : throw uno::RuntimeException();
2901 : : }
2902 : :
2903 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
2904 : : ::std::auto_ptr<SwUnoCrsr> pNewCrsr(
2905 [ + - ]: 444 : rUnoCursor.GetDoc()->CreateUnoCrsr(*rUnoCursor.GetPoint()) );
2906 : : SAL_WNODEPRECATED_DECLARATIONS_POP
2907 [ + + ]: 444 : if (rUnoCursor.HasMark())
2908 : : {
2909 [ + - ]: 72 : pNewCrsr->SetMark();
2910 [ + - ]: 72 : *pNewCrsr->GetMark() = *rUnoCursor.GetMark();
2911 : : }
2912 : 444 : const CursorType eSetType = (CURSOR_TBLTEXT == m_pImpl->m_eType)
2913 [ + + ]: 444 : ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION;
2914 : 444 : SwTableNode const*const pStartNode( (CURSOR_TBLTEXT == m_pImpl->m_eType)
2915 : 345 : ? rUnoCursor.GetPoint()->nNode.GetNode().FindTableNode()
2916 [ + + + - ]: 789 : : 0);
2917 : : SwTable const*const pTable(
2918 [ + + ]: 444 : (pStartNode) ? & pStartNode->GetTable() : 0 );
2919 : : const uno::Reference< container::XEnumeration > xRet =
2920 : : new SwXParagraphEnumeration(
2921 [ + - ][ + - ]: 444 : pParentText, pNewCrsr, eSetType, pStartNode, pTable);
[ + - ][ + - ]
[ + - ][ + - ]
2922 : :
2923 [ + - ][ + - ]: 444 : return xRet;
2924 : : }
2925 : :
2926 : : uno::Type SAL_CALL
2927 : 0 : SwXTextCursor::getElementType() throw (uno::RuntimeException)
2928 : : {
2929 : 0 : return text::XTextRange::static_type();
2930 : : }
2931 : :
2932 : 0 : sal_Bool SAL_CALL SwXTextCursor::hasElements() throw (uno::RuntimeException)
2933 : : {
2934 : 0 : return sal_True;
2935 : : }
2936 : :
2937 : : uno::Sequence< OUString > SAL_CALL
2938 : 2 : SwXTextCursor::getAvailableServiceNames() throw (uno::RuntimeException)
2939 : : {
2940 : 2 : uno::Sequence< OUString > aRet(1);
2941 [ + - ]: 2 : OUString* pArray = aRet.getArray();
2942 [ + - ]: 2 : pArray[0] = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextContent"));
2943 : 2 : return aRet;
2944 : : }
2945 : :
2946 : 151054 : IMPLEMENT_FORWARD_REFCOUNT( SwXTextCursor,SwXTextCursor_Base )
2947 : :
2948 : : uno::Any SAL_CALL
2949 : 36689 : SwXTextCursor::queryInterface(const uno::Type& rType)
2950 : : throw (uno::RuntimeException)
2951 : : {
2952 : 36689 : return (rType == lang::XUnoTunnel::static_type())
2953 : : ? OTextCursorHelper::queryInterface(rType)
2954 [ + + ]: 36689 : : SwXTextCursor_Base::queryInterface(rType);
2955 : : }
2956 : :
2957 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|