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