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 <stdlib.h>
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include <memory>
30cdf0e10cSrcweir #include <iostream>
31cdf0e10cSrcweir
32cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
33cdf0e10cSrcweir #include <com/sun/star/text/ControlCharacter.hpp>
34cdf0e10cSrcweir #include <com/sun/star/text/TableColumnSeparator.hpp>
35cdf0e10cSrcweir
36cdf0e10cSrcweir #include <rtl/uuid.h>
37cdf0e10cSrcweir
38cdf0e10cSrcweir #include <vos/mutex.hxx>
39cdf0e10cSrcweir #include <vcl/svapp.hxx>
40cdf0e10cSrcweir #include <comphelper/sequence.hxx>
41cdf0e10cSrcweir
42cdf0e10cSrcweir #include <cmdid.h>
43cdf0e10cSrcweir #include <unotextbodyhf.hxx>
44cdf0e10cSrcweir #include <unotext.hxx>
45cdf0e10cSrcweir #include <unotextrange.hxx>
46cdf0e10cSrcweir #include <unotextcursor.hxx>
47cdf0e10cSrcweir #include <unosection.hxx>
48cdf0e10cSrcweir #include <unobookmark.hxx>
49cdf0e10cSrcweir #include <unorefmark.hxx>
50cdf0e10cSrcweir #include <unoport.hxx>
51cdf0e10cSrcweir #include <unotbl.hxx>
52cdf0e10cSrcweir #include <unoidx.hxx>
53cdf0e10cSrcweir #include <unoframe.hxx>
54cdf0e10cSrcweir #include <unofield.hxx>
55cdf0e10cSrcweir #include <unometa.hxx>
56cdf0e10cSrcweir #include <unodraw.hxx>
57cdf0e10cSrcweir #include <unoredline.hxx>
58cdf0e10cSrcweir #include <unomap.hxx>
59cdf0e10cSrcweir #include <unoprnms.hxx>
60cdf0e10cSrcweir #include <unoparagraph.hxx>
61cdf0e10cSrcweir #include <unocrsrhelper.hxx>
62cdf0e10cSrcweir #include <docsh.hxx>
63cdf0e10cSrcweir #include <docary.hxx>
64cdf0e10cSrcweir #include <doc.hxx>
65cdf0e10cSrcweir #include <IDocumentUndoRedo.hxx>
66cdf0e10cSrcweir #include <redline.hxx>
67cdf0e10cSrcweir #include <swundo.hxx>
68cdf0e10cSrcweir #include <section.hxx>
69cdf0e10cSrcweir #include <IMark.hxx>
70cdf0e10cSrcweir #include <fmtanchr.hxx>
71cdf0e10cSrcweir #include <fmtcntnt.hxx>
72cdf0e10cSrcweir #include <crsskip.hxx>
73cdf0e10cSrcweir #include <ndtxt.hxx>
74cdf0e10cSrcweir
75cdf0e10cSrcweir
76cdf0e10cSrcweir using namespace ::com::sun::star;
77cdf0e10cSrcweir using ::rtl::OUString;
78cdf0e10cSrcweir
79cdf0e10cSrcweir
80cdf0e10cSrcweir const sal_Char cInvalidObject[] = "this object is invalid";
81cdf0e10cSrcweir
82cdf0e10cSrcweir /******************************************************************
83cdf0e10cSrcweir * SwXText
84cdf0e10cSrcweir ******************************************************************/
85cdf0e10cSrcweir
86cdf0e10cSrcweir class SwXText::Impl
87cdf0e10cSrcweir {
88cdf0e10cSrcweir
89cdf0e10cSrcweir public:
90cdf0e10cSrcweir SwXText & m_rThis;
91cdf0e10cSrcweir SfxItemPropertySet const& m_rPropSet;
92cdf0e10cSrcweir const enum CursorType m_eType;
93cdf0e10cSrcweir SwDoc * m_pDoc;
94cdf0e10cSrcweir bool m_bIsValid;
95cdf0e10cSrcweir
Impl(SwXText & rThis,SwDoc * const pDoc,const enum CursorType eType)96cdf0e10cSrcweir Impl( SwXText & rThis,
97cdf0e10cSrcweir SwDoc *const pDoc, const enum CursorType eType)
98cdf0e10cSrcweir : m_rThis(rThis)
99cdf0e10cSrcweir , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT))
100cdf0e10cSrcweir , m_eType(eType)
101cdf0e10cSrcweir , m_pDoc(pDoc)
102cdf0e10cSrcweir , m_bIsValid(0 != pDoc)
103cdf0e10cSrcweir {
104cdf0e10cSrcweir }
105cdf0e10cSrcweir
106cdf0e10cSrcweir uno::Reference< text::XTextRange >
107cdf0e10cSrcweir finishOrAppendParagraph(
108cdf0e10cSrcweir const bool bFinish,
109cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >&
110cdf0e10cSrcweir rCharacterAndParagraphProperties)
111cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException);
112cdf0e10cSrcweir
113cdf0e10cSrcweir sal_Int16 ComparePositions(
114cdf0e10cSrcweir const uno::Reference<text::XTextRange>& xPos1,
115cdf0e10cSrcweir const uno::Reference<text::XTextRange>& xPos2)
116cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException);
117cdf0e10cSrcweir
118cdf0e10cSrcweir bool CheckForOwnMember(const SwPaM & rPaM)
119cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException);
120cdf0e10cSrcweir
121cdf0e10cSrcweir void ConvertCell(
122cdf0e10cSrcweir const bool bFirstCell,
123cdf0e10cSrcweir const uno::Sequence< uno::Reference< text::XTextRange > > & rCell,
124cdf0e10cSrcweir ::std::vector<SwNodeRange> & rRowNodes,
125cdf0e10cSrcweir ::std::auto_ptr< SwPaM > & rpFirstPaM,
126cdf0e10cSrcweir SwPaM & rLastPaM,
127cdf0e10cSrcweir bool & rbExcept);
128cdf0e10cSrcweir
129cdf0e10cSrcweir };
130cdf0e10cSrcweir
131cdf0e10cSrcweir /* -----------------------------15.03.2002 12:39------------------------------
132cdf0e10cSrcweir
133cdf0e10cSrcweir ---------------------------------------------------------------------------*/
SwXText(SwDoc * const pDoc,const enum CursorType eType)134cdf0e10cSrcweir SwXText::SwXText(SwDoc *const pDoc, const enum CursorType eType)
135cdf0e10cSrcweir : m_pImpl( new SwXText::Impl(*this, pDoc, eType) )
136cdf0e10cSrcweir {
137cdf0e10cSrcweir }
138cdf0e10cSrcweir /*-- 09.12.98 12:43:55---------------------------------------------------
139cdf0e10cSrcweir
140cdf0e10cSrcweir -----------------------------------------------------------------------*/
~SwXText()141cdf0e10cSrcweir SwXText::~SwXText()
142cdf0e10cSrcweir {
143cdf0e10cSrcweir }
144cdf0e10cSrcweir
145cdf0e10cSrcweir /*-- 09.12.98 12:44:07---------------------------------------------------
146cdf0e10cSrcweir
147cdf0e10cSrcweir -----------------------------------------------------------------------*/
148cdf0e10cSrcweir
GetDoc() const149cdf0e10cSrcweir const SwDoc * SwXText::GetDoc() const
150cdf0e10cSrcweir {
151cdf0e10cSrcweir return m_pImpl->m_pDoc;
152cdf0e10cSrcweir }
GetDoc()153cdf0e10cSrcweir SwDoc * SwXText::GetDoc()
154cdf0e10cSrcweir {
155cdf0e10cSrcweir return m_pImpl->m_pDoc;
156cdf0e10cSrcweir }
157cdf0e10cSrcweir
IsValid() const158cdf0e10cSrcweir bool SwXText::IsValid() const
159cdf0e10cSrcweir {
160cdf0e10cSrcweir return m_pImpl->m_bIsValid;
161cdf0e10cSrcweir }
162cdf0e10cSrcweir
Invalidate()163cdf0e10cSrcweir void SwXText::Invalidate()
164cdf0e10cSrcweir {
165cdf0e10cSrcweir m_pImpl->m_bIsValid = false;
166cdf0e10cSrcweir }
167cdf0e10cSrcweir
SetDoc(SwDoc * const pDoc)168cdf0e10cSrcweir void SwXText::SetDoc(SwDoc *const pDoc)
169cdf0e10cSrcweir {
170cdf0e10cSrcweir OSL_ENSURE(!m_pImpl->m_pDoc || !pDoc,
171cdf0e10cSrcweir "SwXText::SetDoc: already have a doc?");
172cdf0e10cSrcweir m_pImpl->m_pDoc = pDoc;
173cdf0e10cSrcweir m_pImpl->m_bIsValid = (0 != pDoc);
174cdf0e10cSrcweir }
175cdf0e10cSrcweir
176cdf0e10cSrcweir void
PrepareForAttach(uno::Reference<text::XTextRange> &,const SwPaM &)177cdf0e10cSrcweir SwXText::PrepareForAttach(uno::Reference< text::XTextRange > &, const SwPaM &)
178cdf0e10cSrcweir {
179cdf0e10cSrcweir }
180cdf0e10cSrcweir
CheckForOwnMemberMeta(const SwPaM &,const bool)181cdf0e10cSrcweir bool SwXText::CheckForOwnMemberMeta(const SwPaM &, const bool)
182cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException)
183cdf0e10cSrcweir {
184cdf0e10cSrcweir ASSERT(CURSOR_META != m_pImpl->m_eType, "should not be called!");
185cdf0e10cSrcweir return false;
186cdf0e10cSrcweir }
187cdf0e10cSrcweir
GetStartNode() const188cdf0e10cSrcweir const SwStartNode *SwXText::GetStartNode() const
189cdf0e10cSrcweir {
190cdf0e10cSrcweir return GetDoc()->GetNodes().GetEndOfContent().StartOfSectionNode();
191cdf0e10cSrcweir }
192cdf0e10cSrcweir
193cdf0e10cSrcweir uno::Reference< text::XTextCursor >
CreateCursor()194cdf0e10cSrcweir SwXText::CreateCursor() throw (uno::RuntimeException)
195cdf0e10cSrcweir {
196cdf0e10cSrcweir uno::Reference< text::XTextCursor > xRet;
197cdf0e10cSrcweir if(IsValid())
198cdf0e10cSrcweir {
199cdf0e10cSrcweir SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent();
200cdf0e10cSrcweir SwPosition aPos(rNode);
201cdf0e10cSrcweir xRet = static_cast<text::XWordCursor*>(
202cdf0e10cSrcweir new SwXTextCursor(*GetDoc(), this, m_pImpl->m_eType, aPos));
203cdf0e10cSrcweir xRet->gotoStart(sal_False);
204cdf0e10cSrcweir }
205cdf0e10cSrcweir return xRet;
206cdf0e10cSrcweir }
207cdf0e10cSrcweir
208cdf0e10cSrcweir /*-- 09.12.98 12:43:02---------------------------------------------------
209cdf0e10cSrcweir
210cdf0e10cSrcweir -----------------------------------------------------------------------*/
211cdf0e10cSrcweir uno::Any SAL_CALL
queryInterface(const uno::Type & rType)212cdf0e10cSrcweir SwXText::queryInterface(const uno::Type& rType) throw (uno::RuntimeException)
213cdf0e10cSrcweir {
214cdf0e10cSrcweir uno::Any aRet;
215cdf0e10cSrcweir if (rType == text::XText::static_type())
216cdf0e10cSrcweir {
217cdf0e10cSrcweir aRet <<= uno::Reference< text::XText >(this);
218cdf0e10cSrcweir }
219cdf0e10cSrcweir else if (rType == text::XSimpleText::static_type())
220cdf0e10cSrcweir {
221cdf0e10cSrcweir aRet <<= uno::Reference< text::XSimpleText >(this);
222cdf0e10cSrcweir }
223cdf0e10cSrcweir else if (rType == text::XTextRange::static_type())
224cdf0e10cSrcweir {
225cdf0e10cSrcweir aRet <<= uno::Reference< text::XTextRange>(this);
226cdf0e10cSrcweir }
227cdf0e10cSrcweir else if (rType == text::XTextRangeCompare::static_type())
228cdf0e10cSrcweir {
229cdf0e10cSrcweir aRet <<= uno::Reference< text::XTextRangeCompare >(this);
230cdf0e10cSrcweir }
231cdf0e10cSrcweir else if (rType == lang::XTypeProvider::static_type())
232cdf0e10cSrcweir {
233cdf0e10cSrcweir aRet <<= uno::Reference< lang::XTypeProvider >(this);
234cdf0e10cSrcweir }
235cdf0e10cSrcweir else if (rType == text::XRelativeTextContentInsert::static_type())
236cdf0e10cSrcweir {
237cdf0e10cSrcweir aRet <<= uno::Reference< text::XRelativeTextContentInsert >(this);
238cdf0e10cSrcweir }
239cdf0e10cSrcweir else if (rType == text::XRelativeTextContentRemove::static_type())
240cdf0e10cSrcweir {
241cdf0e10cSrcweir aRet <<= uno::Reference< text::XRelativeTextContentRemove >(this);
242cdf0e10cSrcweir }
243cdf0e10cSrcweir else if (rType == beans::XPropertySet::static_type())
244cdf0e10cSrcweir {
245cdf0e10cSrcweir aRet <<= uno::Reference< beans::XPropertySet >(this);
246cdf0e10cSrcweir }
247cdf0e10cSrcweir else if (rType == lang::XUnoTunnel::static_type())
248cdf0e10cSrcweir {
249cdf0e10cSrcweir aRet <<= uno::Reference< lang::XUnoTunnel >(this);
250cdf0e10cSrcweir }
251cdf0e10cSrcweir else if (rType == text::XTextAppendAndConvert::static_type())
252cdf0e10cSrcweir {
253cdf0e10cSrcweir aRet <<= uno::Reference< text::XTextAppendAndConvert >(this);
254cdf0e10cSrcweir }
255cdf0e10cSrcweir else if (rType == text::XTextAppend::static_type())
256cdf0e10cSrcweir {
257cdf0e10cSrcweir aRet <<= uno::Reference< text::XTextAppend >(this);
258cdf0e10cSrcweir }
259cdf0e10cSrcweir else if (rType == text::XTextPortionAppend::static_type())
260cdf0e10cSrcweir {
261cdf0e10cSrcweir aRet <<= uno::Reference< text::XTextPortionAppend >(this);
262cdf0e10cSrcweir }
263cdf0e10cSrcweir else if (rType == text::XParagraphAppend::static_type())
264cdf0e10cSrcweir {
265cdf0e10cSrcweir aRet <<= uno::Reference< text::XParagraphAppend >(this);
266cdf0e10cSrcweir }
267cdf0e10cSrcweir else if (rType == text::XTextConvert::static_type() )
268cdf0e10cSrcweir {
269cdf0e10cSrcweir aRet <<= uno::Reference< text::XTextConvert >(this);
270cdf0e10cSrcweir }
271cdf0e10cSrcweir else if (rType == text::XTextContentAppend::static_type())
272cdf0e10cSrcweir {
273cdf0e10cSrcweir aRet <<= uno::Reference< text::XTextContentAppend >(this);
274cdf0e10cSrcweir }
275cdf0e10cSrcweir else if(rType == text::XTextCopy::static_type())
276cdf0e10cSrcweir {
277cdf0e10cSrcweir aRet <<= uno::Reference< text::XTextCopy >( this );
278cdf0e10cSrcweir }
279cdf0e10cSrcweir return aRet;
280cdf0e10cSrcweir }
281cdf0e10cSrcweir /* -----------------------------15.03.00 17:42--------------------------------
282cdf0e10cSrcweir
283cdf0e10cSrcweir ---------------------------------------------------------------------------*/
284cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL
getTypes()285cdf0e10cSrcweir SwXText::getTypes() throw (uno::RuntimeException)
286cdf0e10cSrcweir {
287cdf0e10cSrcweir uno::Sequence< uno::Type > aRet(12);
288cdf0e10cSrcweir uno::Type* pTypes = aRet.getArray();
289cdf0e10cSrcweir pTypes[0] = text::XText::static_type();
290cdf0e10cSrcweir pTypes[1] = text::XTextRangeCompare::static_type();
291cdf0e10cSrcweir pTypes[2] = text::XRelativeTextContentInsert::static_type();
292cdf0e10cSrcweir pTypes[3] = text::XRelativeTextContentRemove::static_type();
293cdf0e10cSrcweir pTypes[4] = lang::XUnoTunnel::static_type();
294cdf0e10cSrcweir pTypes[5] = beans::XPropertySet::static_type();
295cdf0e10cSrcweir pTypes[6] = text::XTextPortionAppend::static_type();
296cdf0e10cSrcweir pTypes[7] = text::XParagraphAppend::static_type();
297cdf0e10cSrcweir pTypes[8] = text::XTextContentAppend::static_type();
298cdf0e10cSrcweir pTypes[9] = text::XTextConvert::static_type();
299cdf0e10cSrcweir pTypes[10] = text::XTextAppend::static_type();
300cdf0e10cSrcweir pTypes[11] = text::XTextAppendAndConvert::static_type();
301cdf0e10cSrcweir
302cdf0e10cSrcweir return aRet;
303cdf0e10cSrcweir }
304cdf0e10cSrcweir
305cdf0e10cSrcweir // belongs the range in the text ? insert it then.
306cdf0e10cSrcweir void SAL_CALL
insertString(const uno::Reference<text::XTextRange> & xTextRange,const OUString & rString,sal_Bool bAbsorb)307cdf0e10cSrcweir SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange,
308cdf0e10cSrcweir const OUString& rString, sal_Bool bAbsorb)
309cdf0e10cSrcweir throw (uno::RuntimeException)
310cdf0e10cSrcweir {
311cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
312cdf0e10cSrcweir
313cdf0e10cSrcweir if (!xTextRange.is())
314cdf0e10cSrcweir {
315cdf0e10cSrcweir throw uno::RuntimeException();
316cdf0e10cSrcweir }
317cdf0e10cSrcweir if (!GetDoc())
318cdf0e10cSrcweir {
319cdf0e10cSrcweir throw uno::RuntimeException();
320cdf0e10cSrcweir }
321cdf0e10cSrcweir const uno::Reference<lang::XUnoTunnel> xRangeTunnel(xTextRange,
322cdf0e10cSrcweir uno::UNO_QUERY);
323cdf0e10cSrcweir SwXTextRange *const pRange =
324cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel);
325cdf0e10cSrcweir OTextCursorHelper *const pCursor =
326cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel);
327cdf0e10cSrcweir if ((!pRange || pRange ->GetDoc() != GetDoc()) &&
328cdf0e10cSrcweir (!pCursor || pCursor->GetDoc() != GetDoc()))
329cdf0e10cSrcweir {
330cdf0e10cSrcweir throw uno::RuntimeException();
331cdf0e10cSrcweir }
332cdf0e10cSrcweir
333cdf0e10cSrcweir const SwStartNode *const pOwnStartNode = GetStartNode();
334cdf0e10cSrcweir SwPaM aPam(GetDoc()->GetNodes());
335cdf0e10cSrcweir const SwPaM * pPam(0);
336cdf0e10cSrcweir if (pCursor)
337cdf0e10cSrcweir {
338cdf0e10cSrcweir pPam = pCursor->GetPaM();
339cdf0e10cSrcweir }
340cdf0e10cSrcweir else // pRange
341cdf0e10cSrcweir {
342cdf0e10cSrcweir if (pRange->GetPositions(aPam))
343cdf0e10cSrcweir {
344cdf0e10cSrcweir pPam = &aPam;
345cdf0e10cSrcweir }
346cdf0e10cSrcweir }
347cdf0e10cSrcweir if (!pPam)
348cdf0e10cSrcweir {
349cdf0e10cSrcweir throw uno::RuntimeException();
350cdf0e10cSrcweir }
351cdf0e10cSrcweir
352cdf0e10cSrcweir const SwStartNode* pTmp(pPam->GetNode()->StartOfSectionNode());
353cdf0e10cSrcweir while (pTmp && pTmp->IsSectionNode())
354cdf0e10cSrcweir {
355cdf0e10cSrcweir pTmp = pTmp->StartOfSectionNode();
356cdf0e10cSrcweir }
357cdf0e10cSrcweir if (!pOwnStartNode || (pOwnStartNode != pTmp))
358cdf0e10cSrcweir {
359cdf0e10cSrcweir throw uno::RuntimeException();
360cdf0e10cSrcweir }
361cdf0e10cSrcweir
362cdf0e10cSrcweir bool bForceExpandHints( false );
363cdf0e10cSrcweir if (CURSOR_META == m_pImpl->m_eType)
364cdf0e10cSrcweir {
365cdf0e10cSrcweir try
366cdf0e10cSrcweir {
367cdf0e10cSrcweir bForceExpandHints = CheckForOwnMemberMeta(*pPam, bAbsorb);
368cdf0e10cSrcweir }
369cdf0e10cSrcweir catch (lang::IllegalArgumentException & iae)
370cdf0e10cSrcweir {
371cdf0e10cSrcweir // stupid method not allowed to throw iae
372cdf0e10cSrcweir throw uno::RuntimeException(iae.Message, 0);
373cdf0e10cSrcweir }
374cdf0e10cSrcweir }
375cdf0e10cSrcweir if (bAbsorb)
376cdf0e10cSrcweir {
377cdf0e10cSrcweir //!! scan for CR characters and inserting the paragraph breaks
378cdf0e10cSrcweir //!! has to be done in the called function.
379cdf0e10cSrcweir //!! Implemented in SwXTextRange::DeleteAndInsert
380cdf0e10cSrcweir if (pCursor)
381cdf0e10cSrcweir {
382cdf0e10cSrcweir SwXTextCursor * const pTextCursor(
383cdf0e10cSrcweir dynamic_cast<SwXTextCursor*>(pCursor) );
384cdf0e10cSrcweir if (pTextCursor)
385cdf0e10cSrcweir {
386cdf0e10cSrcweir pTextCursor->DeleteAndInsert(rString, bForceExpandHints);
387cdf0e10cSrcweir }
388cdf0e10cSrcweir else
389cdf0e10cSrcweir {
390cdf0e10cSrcweir xTextRange->setString(rString);
391cdf0e10cSrcweir }
392cdf0e10cSrcweir }
393cdf0e10cSrcweir else
394cdf0e10cSrcweir {
395cdf0e10cSrcweir pRange->DeleteAndInsert(rString, bForceExpandHints);
396cdf0e10cSrcweir }
397cdf0e10cSrcweir }
398cdf0e10cSrcweir else
399cdf0e10cSrcweir {
400cdf0e10cSrcweir // create a PaM positioned before the parameter PaM,
401cdf0e10cSrcweir // so the text is inserted before
402cdf0e10cSrcweir UnoActionContext aContext(GetDoc());
403cdf0e10cSrcweir SwPaM aInsertPam(*pPam->Start());
404cdf0e10cSrcweir ::sw::GroupUndoGuard const undoGuard(GetDoc()->GetIDocumentUndoRedo());
405cdf0e10cSrcweir SwUnoCursorHelper::DocInsertStringSplitCR(
406cdf0e10cSrcweir *GetDoc(), aInsertPam, rString, bForceExpandHints );
407cdf0e10cSrcweir }
408cdf0e10cSrcweir }
409cdf0e10cSrcweir
410cdf0e10cSrcweir /*-- 09.12.98 12:43:16---------------------------------------------------
411cdf0e10cSrcweir
412cdf0e10cSrcweir -----------------------------------------------------------------------*/
413cdf0e10cSrcweir void SAL_CALL
insertControlCharacter(const uno::Reference<text::XTextRange> & xTextRange,sal_Int16 nControlCharacter,sal_Bool bAbsorb)414cdf0e10cSrcweir SwXText::insertControlCharacter(
415cdf0e10cSrcweir const uno::Reference< text::XTextRange > & xTextRange,
416cdf0e10cSrcweir sal_Int16 nControlCharacter, sal_Bool bAbsorb)
417cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException)
418cdf0e10cSrcweir {
419cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
420cdf0e10cSrcweir
421cdf0e10cSrcweir if (!xTextRange.is())
422cdf0e10cSrcweir {
423cdf0e10cSrcweir throw lang::IllegalArgumentException();
424cdf0e10cSrcweir }
425cdf0e10cSrcweir if (!GetDoc())
426cdf0e10cSrcweir {
427cdf0e10cSrcweir throw uno::RuntimeException();
428cdf0e10cSrcweir }
429cdf0e10cSrcweir
430cdf0e10cSrcweir SwUnoInternalPaM aPam(*GetDoc());
431cdf0e10cSrcweir if (!::sw::XTextRangeToSwPaM(aPam, xTextRange))
432cdf0e10cSrcweir {
433cdf0e10cSrcweir throw uno::RuntimeException();
434cdf0e10cSrcweir }
435cdf0e10cSrcweir const bool bForceExpandHints(CheckForOwnMemberMeta(aPam, bAbsorb));
436cdf0e10cSrcweir
437cdf0e10cSrcweir const enum IDocumentContentOperations::InsertFlags nInsertFlags =
438cdf0e10cSrcweir (bForceExpandHints)
439cdf0e10cSrcweir ? static_cast<IDocumentContentOperations::InsertFlags>(
440cdf0e10cSrcweir IDocumentContentOperations::INS_FORCEHINTEXPAND |
441cdf0e10cSrcweir IDocumentContentOperations::INS_EMPTYEXPAND)
442cdf0e10cSrcweir : IDocumentContentOperations::INS_EMPTYEXPAND;
443cdf0e10cSrcweir
444cdf0e10cSrcweir SwPaM aTmp(*aPam.Start());
445cdf0e10cSrcweir if (bAbsorb && aPam.HasMark())
446cdf0e10cSrcweir {
447cdf0e10cSrcweir m_pImpl->m_pDoc->DeleteAndJoin(aPam);
448cdf0e10cSrcweir }
449cdf0e10cSrcweir
450cdf0e10cSrcweir sal_Unicode cIns = 0;
451cdf0e10cSrcweir switch (nControlCharacter)
452cdf0e10cSrcweir {
453cdf0e10cSrcweir case text::ControlCharacter::PARAGRAPH_BREAK :
454cdf0e10cSrcweir // a table cell now becomes an ordinary text cell!
455cdf0e10cSrcweir m_pImpl->m_pDoc->ClearBoxNumAttrs( aTmp.GetPoint()->nNode );
456cdf0e10cSrcweir m_pImpl->m_pDoc->SplitNode( *aTmp.GetPoint(), sal_False );
457cdf0e10cSrcweir break;
458cdf0e10cSrcweir case text::ControlCharacter::APPEND_PARAGRAPH:
459cdf0e10cSrcweir {
460cdf0e10cSrcweir m_pImpl->m_pDoc->ClearBoxNumAttrs( aTmp.GetPoint()->nNode );
461cdf0e10cSrcweir m_pImpl->m_pDoc->AppendTxtNode( *aTmp.GetPoint() );
462cdf0e10cSrcweir
463cdf0e10cSrcweir const uno::Reference<lang::XUnoTunnel> xRangeTunnel(
464cdf0e10cSrcweir xTextRange, uno::UNO_QUERY);
465cdf0e10cSrcweir SwXTextRange *const pRange =
466cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel);
467cdf0e10cSrcweir OTextCursorHelper *const pCursor =
468cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(
469cdf0e10cSrcweir xRangeTunnel);
470cdf0e10cSrcweir if (pRange)
471cdf0e10cSrcweir {
472cdf0e10cSrcweir pRange->SetPositions(aTmp);
473cdf0e10cSrcweir }
474cdf0e10cSrcweir else if (pCursor)
475cdf0e10cSrcweir {
476cdf0e10cSrcweir SwPaM *const pCrsr = pCursor->GetPaM();
477cdf0e10cSrcweir *pCrsr->GetPoint() = *aTmp.GetPoint();
478cdf0e10cSrcweir pCrsr->DeleteMark();
479cdf0e10cSrcweir }
480cdf0e10cSrcweir }
481cdf0e10cSrcweir break;
482cdf0e10cSrcweir case text::ControlCharacter::LINE_BREAK: cIns = 10; break;
483cdf0e10cSrcweir case text::ControlCharacter::SOFT_HYPHEN: cIns = CHAR_SOFTHYPHEN; break;
484cdf0e10cSrcweir case text::ControlCharacter::HARD_HYPHEN: cIns = CHAR_HARDHYPHEN; break;
485cdf0e10cSrcweir case text::ControlCharacter::HARD_SPACE: cIns = CHAR_HARDBLANK; break;
486cdf0e10cSrcweir }
487cdf0e10cSrcweir if (cIns)
488cdf0e10cSrcweir {
489cdf0e10cSrcweir m_pImpl->m_pDoc->InsertString( aTmp, cIns, nInsertFlags );
490cdf0e10cSrcweir }
491cdf0e10cSrcweir
492cdf0e10cSrcweir if (bAbsorb)
493cdf0e10cSrcweir {
494cdf0e10cSrcweir const uno::Reference<lang::XUnoTunnel> xRangeTunnel(
495cdf0e10cSrcweir xTextRange, uno::UNO_QUERY);
496cdf0e10cSrcweir SwXTextRange *const pRange =
497cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel);
498cdf0e10cSrcweir OTextCursorHelper *const pCursor =
499cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel);
500cdf0e10cSrcweir
501cdf0e10cSrcweir SwCursor aCrsr(*aTmp.GetPoint(),0,false);
502cdf0e10cSrcweir SwUnoCursorHelper::SelectPam(aCrsr, true);
503cdf0e10cSrcweir aCrsr.Left(1, CRSR_SKIP_CHARS, sal_False, sal_False);
504cdf0e10cSrcweir //hier muss der uebergebene PaM umgesetzt werden:
505cdf0e10cSrcweir if (pRange)
506cdf0e10cSrcweir {
507cdf0e10cSrcweir pRange->SetPositions(aCrsr);
508cdf0e10cSrcweir }
509cdf0e10cSrcweir else
510cdf0e10cSrcweir {
511cdf0e10cSrcweir SwPaM *const pUnoCrsr = pCursor->GetPaM();
512cdf0e10cSrcweir *pUnoCrsr->GetPoint() = *aCrsr.GetPoint();
513cdf0e10cSrcweir if (aCrsr.HasMark())
514cdf0e10cSrcweir {
515cdf0e10cSrcweir pUnoCrsr->SetMark();
516cdf0e10cSrcweir *pUnoCrsr->GetMark() = *aCrsr.GetMark();
517cdf0e10cSrcweir }
518cdf0e10cSrcweir else
519cdf0e10cSrcweir {
520cdf0e10cSrcweir pUnoCrsr->DeleteMark();
521cdf0e10cSrcweir }
522cdf0e10cSrcweir }
523cdf0e10cSrcweir }
524cdf0e10cSrcweir }
525cdf0e10cSrcweir
526cdf0e10cSrcweir /*-- 09.12.98 12:43:17---------------------------------------------------
527cdf0e10cSrcweir
528cdf0e10cSrcweir -----------------------------------------------------------------------*/
529cdf0e10cSrcweir void SAL_CALL
insertTextContent(const uno::Reference<text::XTextRange> & xRange,const uno::Reference<text::XTextContent> & xContent,sal_Bool bAbsorb)530cdf0e10cSrcweir SwXText::insertTextContent(
531cdf0e10cSrcweir const uno::Reference< text::XTextRange > & xRange,
532cdf0e10cSrcweir const uno::Reference< text::XTextContent > & xContent,
533cdf0e10cSrcweir sal_Bool bAbsorb)
534cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException)
535cdf0e10cSrcweir {
536cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
537cdf0e10cSrcweir
538cdf0e10cSrcweir if (!xRange.is())
539cdf0e10cSrcweir {
540cdf0e10cSrcweir lang::IllegalArgumentException aIllegal;
541cdf0e10cSrcweir aIllegal.Message = C2U("first parameter invalid;");
542cdf0e10cSrcweir throw aIllegal;
543cdf0e10cSrcweir }
544cdf0e10cSrcweir if (!xContent.is())
545cdf0e10cSrcweir {
546cdf0e10cSrcweir lang::IllegalArgumentException aIllegal;
547cdf0e10cSrcweir aIllegal.Message += C2U("second parameter invalid");
548cdf0e10cSrcweir throw aIllegal;
549cdf0e10cSrcweir }
550cdf0e10cSrcweir if(!GetDoc())
551cdf0e10cSrcweir {
552cdf0e10cSrcweir uno::RuntimeException aRuntime;
553cdf0e10cSrcweir aRuntime.Message = C2U(cInvalidObject);
554cdf0e10cSrcweir throw aRuntime;
555cdf0e10cSrcweir }
556cdf0e10cSrcweir
557cdf0e10cSrcweir SwUnoInternalPaM aPam(*GetDoc());
558cdf0e10cSrcweir if (!::sw::XTextRangeToSwPaM(aPam, xRange))
559cdf0e10cSrcweir {
560cdf0e10cSrcweir lang::IllegalArgumentException aIllegal;
561cdf0e10cSrcweir aIllegal.Message = C2U("first parameter invalid");
562cdf0e10cSrcweir throw aIllegal;
563cdf0e10cSrcweir }
564cdf0e10cSrcweir // first test if the range is at the right position, then call
565cdf0e10cSrcweir // xContent->attach
566cdf0e10cSrcweir const SwStartNode* pOwnStartNode = GetStartNode();
567cdf0e10cSrcweir SwStartNodeType eSearchNodeType = SwNormalStartNode;
568cdf0e10cSrcweir switch (m_pImpl->m_eType)
569cdf0e10cSrcweir {
570cdf0e10cSrcweir case CURSOR_FRAME: eSearchNodeType = SwFlyStartNode; break;
571cdf0e10cSrcweir case CURSOR_TBLTEXT: eSearchNodeType = SwTableBoxStartNode; break;
572cdf0e10cSrcweir case CURSOR_FOOTNOTE: eSearchNodeType = SwFootnoteStartNode; break;
573cdf0e10cSrcweir case CURSOR_HEADER: eSearchNodeType = SwHeaderStartNode; break;
574cdf0e10cSrcweir case CURSOR_FOOTER: eSearchNodeType = SwFooterStartNode; break;
575cdf0e10cSrcweir //case CURSOR_INVALID:
576cdf0e10cSrcweir //case CURSOR_BODY:
577cdf0e10cSrcweir default:
578cdf0e10cSrcweir break;
579cdf0e10cSrcweir }
580cdf0e10cSrcweir
581cdf0e10cSrcweir const SwStartNode* pTmp =
582cdf0e10cSrcweir aPam.GetNode()->FindSttNodeByType(eSearchNodeType);
583cdf0e10cSrcweir
584cdf0e10cSrcweir // ignore SectionNodes
585cdf0e10cSrcweir while (pTmp && pTmp->IsSectionNode())
586cdf0e10cSrcweir {
587cdf0e10cSrcweir pTmp = pTmp->StartOfSectionNode();
588cdf0e10cSrcweir }
589cdf0e10cSrcweir // if the document starts with a section
590cdf0e10cSrcweir while (pOwnStartNode->IsSectionNode())
591cdf0e10cSrcweir {
592cdf0e10cSrcweir pOwnStartNode = pOwnStartNode->StartOfSectionNode();
593cdf0e10cSrcweir }
594cdf0e10cSrcweir // this checks if (this) and xRange are in the same text::XText interface
595cdf0e10cSrcweir if (pOwnStartNode != pTmp)
596cdf0e10cSrcweir {
597cdf0e10cSrcweir uno::RuntimeException aRunException;
598cdf0e10cSrcweir aRunException.Message = C2U("text interface and cursor not related");
599cdf0e10cSrcweir throw aRunException;
600cdf0e10cSrcweir }
601cdf0e10cSrcweir
602cdf0e10cSrcweir const bool bForceExpandHints(CheckForOwnMemberMeta(aPam, bAbsorb));
603cdf0e10cSrcweir
604cdf0e10cSrcweir // special treatment for Contents that do not replace the range, but
605cdf0e10cSrcweir // instead are "overlaid"
606cdf0e10cSrcweir const uno::Reference<lang::XUnoTunnel> xContentTunnel(xContent,
607cdf0e10cSrcweir uno::UNO_QUERY);
608cdf0e10cSrcweir if (!xContentTunnel.is())
609cdf0e10cSrcweir {
610cdf0e10cSrcweir lang::IllegalArgumentException aArgException;
611cdf0e10cSrcweir aArgException.Message =
612cdf0e10cSrcweir C2U("text content does not support lang::XUnoTunnel");
613cdf0e10cSrcweir throw aArgException;
614cdf0e10cSrcweir }
615cdf0e10cSrcweir SwXDocumentIndexMark *const pDocumentIndexMark =
616cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<SwXDocumentIndexMark>(xContentTunnel);
617cdf0e10cSrcweir SwXTextSection *const pSection =
618cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<SwXTextSection>(xContentTunnel);
619cdf0e10cSrcweir SwXBookmark *const pBookmark =
620cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<SwXBookmark>(xContentTunnel);
621cdf0e10cSrcweir SwXReferenceMark *const pReferenceMark =
622cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<SwXReferenceMark>(xContentTunnel);
623cdf0e10cSrcweir SwXMeta *const pMeta =
624cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<SwXMeta>(xContentTunnel);
625*3b32dd21SOliver-Rainer Wittmann SwXTextField* pTextField =
626*3b32dd21SOliver-Rainer Wittmann ::sw::UnoTunnelGetImplementation<SwXTextField>(xContentTunnel);
627*3b32dd21SOliver-Rainer Wittmann if ( pTextField
628*3b32dd21SOliver-Rainer Wittmann && pTextField->GetServiceId() != SW_SERVICE_FIELDTYPE_ANNOTATION )
629*3b32dd21SOliver-Rainer Wittmann {
630*3b32dd21SOliver-Rainer Wittmann pTextField = 0;
631*3b32dd21SOliver-Rainer Wittmann }
632cdf0e10cSrcweir
633*3b32dd21SOliver-Rainer Wittmann const bool bAttribute =
634*3b32dd21SOliver-Rainer Wittmann pBookmark || pDocumentIndexMark || pSection || pReferenceMark || pMeta || pTextField;
635cdf0e10cSrcweir
636cdf0e10cSrcweir if (bAbsorb && !bAttribute)
637cdf0e10cSrcweir {
638cdf0e10cSrcweir xRange->setString(aEmptyStr);
639cdf0e10cSrcweir }
640cdf0e10cSrcweir uno::Reference< text::XTextRange > xTempRange =
641cdf0e10cSrcweir (bAttribute && bAbsorb) ? xRange : xRange->getStart();
642cdf0e10cSrcweir if (bForceExpandHints)
643cdf0e10cSrcweir {
644cdf0e10cSrcweir // if necessary, replace xTempRange with a new SwXTextCursor
645cdf0e10cSrcweir PrepareForAttach(xTempRange, aPam);
646cdf0e10cSrcweir }
647cdf0e10cSrcweir xContent->attach(xTempRange);
648cdf0e10cSrcweir }
649cdf0e10cSrcweir
650cdf0e10cSrcweir /* -----------------------------10.07.00 15:40--------------------------------
651cdf0e10cSrcweir
652cdf0e10cSrcweir ---------------------------------------------------------------------------*/
653cdf0e10cSrcweir void SAL_CALL
insertTextContentBefore(const uno::Reference<text::XTextContent> & xNewContent,const uno::Reference<text::XTextContent> & xSuccessor)654cdf0e10cSrcweir SwXText::insertTextContentBefore(
655cdf0e10cSrcweir const uno::Reference< text::XTextContent>& xNewContent,
656cdf0e10cSrcweir const uno::Reference< text::XTextContent>& xSuccessor)
657cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException)
658cdf0e10cSrcweir {
659cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
660cdf0e10cSrcweir
661cdf0e10cSrcweir if(!GetDoc())
662cdf0e10cSrcweir {
663cdf0e10cSrcweir uno::RuntimeException aRuntime;
664cdf0e10cSrcweir aRuntime.Message = C2U(cInvalidObject);
665cdf0e10cSrcweir throw aRuntime;
666cdf0e10cSrcweir }
667cdf0e10cSrcweir
668cdf0e10cSrcweir const uno::Reference<lang::XUnoTunnel> xParaTunnel(xNewContent,
669cdf0e10cSrcweir uno::UNO_QUERY);
670cdf0e10cSrcweir SwXParagraph *const pPara =
671cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<SwXParagraph>(xParaTunnel);
672cdf0e10cSrcweir if (!pPara || !pPara->IsDescriptor() || !xSuccessor.is())
673cdf0e10cSrcweir {
674cdf0e10cSrcweir throw lang::IllegalArgumentException();
675cdf0e10cSrcweir }
676cdf0e10cSrcweir
677cdf0e10cSrcweir sal_Bool bRet = sal_False;
678cdf0e10cSrcweir const uno::Reference<lang::XUnoTunnel> xSuccTunnel(xSuccessor,
679cdf0e10cSrcweir uno::UNO_QUERY);
680cdf0e10cSrcweir SwXTextSection *const pXSection =
681cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<SwXTextSection>(xSuccTunnel);
682cdf0e10cSrcweir SwXTextTable *const pXTable =
683cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<SwXTextTable>(xSuccTunnel);
684cdf0e10cSrcweir SwFrmFmt *const pTableFmt = (pXTable) ? pXTable->GetFrmFmt() : 0;
685cdf0e10cSrcweir SwTxtNode * pTxtNode = 0;
686cdf0e10cSrcweir if(pTableFmt && pTableFmt->GetDoc() == GetDoc())
687cdf0e10cSrcweir {
688cdf0e10cSrcweir SwTable *const pTable = SwTable::FindTable( pTableFmt );
689cdf0e10cSrcweir SwTableNode *const pTblNode = pTable->GetTableNode();
690cdf0e10cSrcweir
691cdf0e10cSrcweir const SwNodeIndex aTblIdx( *pTblNode, -1 );
692cdf0e10cSrcweir SwPosition aBefore(aTblIdx);
693cdf0e10cSrcweir bRet = GetDoc()->AppendTxtNode( aBefore );
694cdf0e10cSrcweir pTxtNode = aBefore.nNode.GetNode().GetTxtNode();
695cdf0e10cSrcweir }
696cdf0e10cSrcweir else if (pXSection && pXSection->GetFmt() &&
697cdf0e10cSrcweir pXSection->GetFmt()->GetDoc() == GetDoc())
698cdf0e10cSrcweir {
699cdf0e10cSrcweir SwSectionFmt *const pSectFmt = pXSection->GetFmt();
700cdf0e10cSrcweir SwSectionNode *const pSectNode = pSectFmt->GetSectionNode();
701cdf0e10cSrcweir
702cdf0e10cSrcweir const SwNodeIndex aSectIdx( *pSectNode, -1 );
703cdf0e10cSrcweir SwPosition aBefore(aSectIdx);
704cdf0e10cSrcweir bRet = GetDoc()->AppendTxtNode( aBefore );
705cdf0e10cSrcweir pTxtNode = aBefore.nNode.GetNode().GetTxtNode();
706cdf0e10cSrcweir }
707cdf0e10cSrcweir if (!bRet || !pTxtNode)
708cdf0e10cSrcweir {
709cdf0e10cSrcweir throw lang::IllegalArgumentException();
710cdf0e10cSrcweir }
711cdf0e10cSrcweir pPara->attachToText(*this, *pTxtNode);
712cdf0e10cSrcweir }
713cdf0e10cSrcweir
714cdf0e10cSrcweir /* -----------------------------10.07.00 15:40--------------------------------
715cdf0e10cSrcweir
716cdf0e10cSrcweir ---------------------------------------------------------------------------*/
717cdf0e10cSrcweir void SAL_CALL
insertTextContentAfter(const uno::Reference<text::XTextContent> & xNewContent,const uno::Reference<text::XTextContent> & xPredecessor)718cdf0e10cSrcweir SwXText::insertTextContentAfter(
719cdf0e10cSrcweir const uno::Reference< text::XTextContent>& xNewContent,
720cdf0e10cSrcweir const uno::Reference< text::XTextContent>& xPredecessor)
721cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException)
722cdf0e10cSrcweir {
723cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
724cdf0e10cSrcweir
725cdf0e10cSrcweir if(!GetDoc())
726cdf0e10cSrcweir {
727cdf0e10cSrcweir throw uno::RuntimeException();
728cdf0e10cSrcweir }
729cdf0e10cSrcweir
730cdf0e10cSrcweir const uno::Reference<lang::XUnoTunnel> xParaTunnel(xNewContent,
731cdf0e10cSrcweir uno::UNO_QUERY);
732cdf0e10cSrcweir SwXParagraph *const pPara =
733cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<SwXParagraph>(xParaTunnel);
734cdf0e10cSrcweir if(!pPara || !pPara->IsDescriptor() || !xPredecessor.is())
735cdf0e10cSrcweir {
736cdf0e10cSrcweir throw lang::IllegalArgumentException();
737cdf0e10cSrcweir }
738cdf0e10cSrcweir
739cdf0e10cSrcweir const uno::Reference<lang::XUnoTunnel> xPredTunnel(xPredecessor,
740cdf0e10cSrcweir uno::UNO_QUERY);
741cdf0e10cSrcweir SwXTextSection *const pXSection =
742cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<SwXTextSection>(xPredTunnel);
743cdf0e10cSrcweir SwXTextTable *const pXTable =
744cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<SwXTextTable>(xPredTunnel);
745cdf0e10cSrcweir SwFrmFmt *const pTableFmt = (pXTable) ? pXTable->GetFrmFmt() : 0;
746cdf0e10cSrcweir sal_Bool bRet = sal_False;
747cdf0e10cSrcweir SwTxtNode * pTxtNode = 0;
748cdf0e10cSrcweir if(pTableFmt && pTableFmt->GetDoc() == GetDoc())
749cdf0e10cSrcweir {
750cdf0e10cSrcweir SwTable *const pTable = SwTable::FindTable( pTableFmt );
751cdf0e10cSrcweir SwTableNode *const pTblNode = pTable->GetTableNode();
752cdf0e10cSrcweir
753cdf0e10cSrcweir SwEndNode *const pTableEnd = pTblNode->EndOfSectionNode();
754cdf0e10cSrcweir SwPosition aTableEnd(*pTableEnd);
755cdf0e10cSrcweir bRet = GetDoc()->AppendTxtNode( aTableEnd );
756cdf0e10cSrcweir pTxtNode = aTableEnd.nNode.GetNode().GetTxtNode();
757cdf0e10cSrcweir }
758cdf0e10cSrcweir else if (pXSection && pXSection->GetFmt() &&
759cdf0e10cSrcweir pXSection->GetFmt()->GetDoc() == GetDoc())
760cdf0e10cSrcweir {
761cdf0e10cSrcweir SwSectionFmt *const pSectFmt = pXSection->GetFmt();
762cdf0e10cSrcweir SwSectionNode *const pSectNode = pSectFmt->GetSectionNode();
763cdf0e10cSrcweir SwEndNode *const pEnd = pSectNode->EndOfSectionNode();
764cdf0e10cSrcweir SwPosition aEnd(*pEnd);
765cdf0e10cSrcweir bRet = GetDoc()->AppendTxtNode( aEnd );
766cdf0e10cSrcweir pTxtNode = aEnd.nNode.GetNode().GetTxtNode();
767cdf0e10cSrcweir }
768cdf0e10cSrcweir if (!bRet || !pTxtNode)
769cdf0e10cSrcweir {
770cdf0e10cSrcweir throw lang::IllegalArgumentException();
771cdf0e10cSrcweir }
772cdf0e10cSrcweir pPara->attachToText(*this, *pTxtNode);
773cdf0e10cSrcweir }
774cdf0e10cSrcweir
775cdf0e10cSrcweir /* -----------------------------10.07.00 15:40--------------------------------
776cdf0e10cSrcweir
777cdf0e10cSrcweir ---------------------------------------------------------------------------*/
778cdf0e10cSrcweir void SAL_CALL
removeTextContentBefore(const uno::Reference<text::XTextContent> & xSuccessor)779cdf0e10cSrcweir SwXText::removeTextContentBefore(
780cdf0e10cSrcweir const uno::Reference< text::XTextContent>& xSuccessor)
781cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException)
782cdf0e10cSrcweir {
783cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
784cdf0e10cSrcweir
785cdf0e10cSrcweir if(!GetDoc())
786cdf0e10cSrcweir {
787cdf0e10cSrcweir uno::RuntimeException aRuntime;
788cdf0e10cSrcweir aRuntime.Message = C2U(cInvalidObject);
789cdf0e10cSrcweir throw aRuntime;
790cdf0e10cSrcweir }
791cdf0e10cSrcweir
792cdf0e10cSrcweir sal_Bool bRet = sal_False;
793cdf0e10cSrcweir const uno::Reference<lang::XUnoTunnel> xSuccTunnel(xSuccessor,
794cdf0e10cSrcweir uno::UNO_QUERY);
795cdf0e10cSrcweir SwXTextSection *const pXSection =
796cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<SwXTextSection>(xSuccTunnel);
797cdf0e10cSrcweir SwXTextTable *const pXTable =
798cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<SwXTextTable>(xSuccTunnel);
799cdf0e10cSrcweir SwFrmFmt *const pTableFmt = (pXTable) ? pXTable->GetFrmFmt() : 0;
800cdf0e10cSrcweir if(pTableFmt && pTableFmt->GetDoc() == GetDoc())
801cdf0e10cSrcweir {
802cdf0e10cSrcweir SwTable *const pTable = SwTable::FindTable( pTableFmt );
803cdf0e10cSrcweir SwTableNode *const pTblNode = pTable->GetTableNode();
804cdf0e10cSrcweir
805cdf0e10cSrcweir const SwNodeIndex aTblIdx( *pTblNode, -1 );
806cdf0e10cSrcweir if(aTblIdx.GetNode().IsTxtNode())
807cdf0e10cSrcweir {
808cdf0e10cSrcweir SwPaM aBefore(aTblIdx);
809cdf0e10cSrcweir bRet = GetDoc()->DelFullPara( aBefore );
810cdf0e10cSrcweir }
811cdf0e10cSrcweir }
812cdf0e10cSrcweir else if (pXSection && pXSection->GetFmt() &&
813cdf0e10cSrcweir pXSection->GetFmt()->GetDoc() == GetDoc())
814cdf0e10cSrcweir {
815cdf0e10cSrcweir SwSectionFmt *const pSectFmt = pXSection->GetFmt();
816cdf0e10cSrcweir SwSectionNode *const pSectNode = pSectFmt->GetSectionNode();
817cdf0e10cSrcweir
818cdf0e10cSrcweir const SwNodeIndex aSectIdx( *pSectNode, -1 );
819cdf0e10cSrcweir if(aSectIdx.GetNode().IsTxtNode())
820cdf0e10cSrcweir {
821cdf0e10cSrcweir SwPaM aBefore(aSectIdx);
822cdf0e10cSrcweir bRet = GetDoc()->DelFullPara( aBefore );
823cdf0e10cSrcweir }
824cdf0e10cSrcweir }
825cdf0e10cSrcweir if(!bRet)
826cdf0e10cSrcweir {
827cdf0e10cSrcweir throw lang::IllegalArgumentException();
828cdf0e10cSrcweir }
829cdf0e10cSrcweir }
830cdf0e10cSrcweir
831cdf0e10cSrcweir /* -----------------------------10.07.00 15:40--------------------------------
832cdf0e10cSrcweir
833cdf0e10cSrcweir ---------------------------------------------------------------------------*/
834cdf0e10cSrcweir void SAL_CALL
removeTextContentAfter(const uno::Reference<text::XTextContent> & xPredecessor)835cdf0e10cSrcweir SwXText::removeTextContentAfter(
836cdf0e10cSrcweir const uno::Reference< text::XTextContent>& xPredecessor)
837cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException)
838cdf0e10cSrcweir {
839cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
840cdf0e10cSrcweir
841cdf0e10cSrcweir if(!GetDoc())
842cdf0e10cSrcweir {
843cdf0e10cSrcweir uno::RuntimeException aRuntime;
844cdf0e10cSrcweir aRuntime.Message = C2U(cInvalidObject);
845cdf0e10cSrcweir throw aRuntime;
846cdf0e10cSrcweir }
847cdf0e10cSrcweir
848cdf0e10cSrcweir sal_Bool bRet = sal_False;
849cdf0e10cSrcweir const uno::Reference<lang::XUnoTunnel> xPredTunnel(xPredecessor,
850cdf0e10cSrcweir uno::UNO_QUERY);
851cdf0e10cSrcweir SwXTextSection *const pXSection =
852cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<SwXTextSection>(xPredTunnel);
853cdf0e10cSrcweir SwXTextTable *const pXTable =
854cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<SwXTextTable>(xPredTunnel);
855cdf0e10cSrcweir SwFrmFmt *const pTableFmt = (pXTable) ? pXTable->GetFrmFmt() : 0;
856cdf0e10cSrcweir if(pTableFmt && pTableFmt->GetDoc() == GetDoc())
857cdf0e10cSrcweir {
858cdf0e10cSrcweir SwTable *const pTable = SwTable::FindTable( pTableFmt );
859cdf0e10cSrcweir SwTableNode *const pTblNode = pTable->GetTableNode();
860cdf0e10cSrcweir SwEndNode *const pTableEnd = pTblNode->EndOfSectionNode();
861cdf0e10cSrcweir
862cdf0e10cSrcweir const SwNodeIndex aTblIdx( *pTableEnd, 1 );
863cdf0e10cSrcweir if(aTblIdx.GetNode().IsTxtNode())
864cdf0e10cSrcweir {
865cdf0e10cSrcweir SwPaM aPaM(aTblIdx);
866cdf0e10cSrcweir bRet = GetDoc()->DelFullPara( aPaM );
867cdf0e10cSrcweir }
868cdf0e10cSrcweir }
869cdf0e10cSrcweir else if (pXSection && pXSection->GetFmt() &&
870cdf0e10cSrcweir pXSection->GetFmt()->GetDoc() == GetDoc())
871cdf0e10cSrcweir {
872cdf0e10cSrcweir SwSectionFmt *const pSectFmt = pXSection->GetFmt();
873cdf0e10cSrcweir SwSectionNode *const pSectNode = pSectFmt->GetSectionNode();
874cdf0e10cSrcweir SwEndNode *const pEnd = pSectNode->EndOfSectionNode();
875cdf0e10cSrcweir const SwNodeIndex aSectIdx( *pEnd, 1 );
876cdf0e10cSrcweir if(aSectIdx.GetNode().IsTxtNode())
877cdf0e10cSrcweir {
878cdf0e10cSrcweir SwPaM aAfter(aSectIdx);
879cdf0e10cSrcweir bRet = GetDoc()->DelFullPara( aAfter );
880cdf0e10cSrcweir }
881cdf0e10cSrcweir }
882cdf0e10cSrcweir if(!bRet)
883cdf0e10cSrcweir {
884cdf0e10cSrcweir throw lang::IllegalArgumentException();
885cdf0e10cSrcweir }
886cdf0e10cSrcweir }
887cdf0e10cSrcweir
888cdf0e10cSrcweir /*-- 09.12.98 12:43:19---------------------------------------------------
889cdf0e10cSrcweir
890cdf0e10cSrcweir -----------------------------------------------------------------------*/
891cdf0e10cSrcweir void SAL_CALL
removeTextContent(const uno::Reference<text::XTextContent> & xContent)892cdf0e10cSrcweir SwXText::removeTextContent(
893cdf0e10cSrcweir const uno::Reference< text::XTextContent > & xContent)
894cdf0e10cSrcweir throw (container::NoSuchElementException, uno::RuntimeException)
895cdf0e10cSrcweir {
896cdf0e10cSrcweir // forward: need no solar mutex here
897cdf0e10cSrcweir if(!xContent.is())
898cdf0e10cSrcweir {
899cdf0e10cSrcweir uno::RuntimeException aRuntime;
900cdf0e10cSrcweir aRuntime.Message = C2U("first parameter invalid");
901cdf0e10cSrcweir throw aRuntime;
902cdf0e10cSrcweir }
903cdf0e10cSrcweir xContent->dispose();
904cdf0e10cSrcweir }
905cdf0e10cSrcweir
906cdf0e10cSrcweir /*-- 09.12.98 12:43:22---------------------------------------------------
907cdf0e10cSrcweir
908cdf0e10cSrcweir -----------------------------------------------------------------------*/
909cdf0e10cSrcweir uno::Reference< text::XText > SAL_CALL
getText()910cdf0e10cSrcweir SwXText::getText() throw (uno::RuntimeException)
911cdf0e10cSrcweir {
912cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
913cdf0e10cSrcweir
914cdf0e10cSrcweir const uno::Reference< text::XText > xRet(this);
915cdf0e10cSrcweir return xRet;
916cdf0e10cSrcweir }
917cdf0e10cSrcweir
918cdf0e10cSrcweir /*-- 09.12.98 12:43:24---------------------------------------------------
919cdf0e10cSrcweir
920cdf0e10cSrcweir -----------------------------------------------------------------------*/
921cdf0e10cSrcweir uno::Reference< text::XTextRange > SAL_CALL
getStart()922cdf0e10cSrcweir SwXText::getStart() throw (uno::RuntimeException)
923cdf0e10cSrcweir {
924cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
925cdf0e10cSrcweir
926cdf0e10cSrcweir const uno::Reference< text::XTextCursor > xRef = CreateCursor();
927cdf0e10cSrcweir if(!xRef.is())
928cdf0e10cSrcweir {
929cdf0e10cSrcweir uno::RuntimeException aRuntime;
930cdf0e10cSrcweir aRuntime.Message = C2U(cInvalidObject);
931cdf0e10cSrcweir throw aRuntime;
932cdf0e10cSrcweir }
933cdf0e10cSrcweir xRef->gotoStart(sal_False);
934cdf0e10cSrcweir const uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY);
935cdf0e10cSrcweir return xRet;
936cdf0e10cSrcweir }
937cdf0e10cSrcweir /*-- 09.12.98 12:43:27---------------------------------------------------
938cdf0e10cSrcweir
939cdf0e10cSrcweir -----------------------------------------------------------------------*/
940cdf0e10cSrcweir uno::Reference< text::XTextRange > SAL_CALL
getEnd()941cdf0e10cSrcweir SwXText::getEnd() throw (uno::RuntimeException)
942cdf0e10cSrcweir {
943cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
944cdf0e10cSrcweir
945cdf0e10cSrcweir const uno::Reference< text::XTextCursor > xRef = CreateCursor();
946cdf0e10cSrcweir if(!xRef.is())
947cdf0e10cSrcweir {
948cdf0e10cSrcweir uno::RuntimeException aRuntime;
949cdf0e10cSrcweir aRuntime.Message = C2U(cInvalidObject);
950cdf0e10cSrcweir throw aRuntime;
951cdf0e10cSrcweir }
952cdf0e10cSrcweir xRef->gotoEnd(sal_False);
953cdf0e10cSrcweir const uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY);
954cdf0e10cSrcweir return xRet;
955cdf0e10cSrcweir }
956cdf0e10cSrcweir
957cdf0e10cSrcweir /*-- 09.12.98 12:43:29---------------------------------------------------
958cdf0e10cSrcweir
959cdf0e10cSrcweir -----------------------------------------------------------------------*/
getString()960cdf0e10cSrcweir OUString SAL_CALL SwXText::getString() throw (uno::RuntimeException)
961cdf0e10cSrcweir {
962cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
963cdf0e10cSrcweir
964cdf0e10cSrcweir const uno::Reference< text::XTextCursor > xRet = CreateCursor();
965cdf0e10cSrcweir if(!xRet.is())
966cdf0e10cSrcweir {
967cdf0e10cSrcweir uno::RuntimeException aRuntime;
968cdf0e10cSrcweir aRuntime.Message = C2U(cInvalidObject);
969cdf0e10cSrcweir throw aRuntime;
970cdf0e10cSrcweir }
971cdf0e10cSrcweir xRet->gotoEnd(sal_True);
972cdf0e10cSrcweir return xRet->getString();
973cdf0e10cSrcweir }
974cdf0e10cSrcweir /*-- 09.12.98 12:43:30---------------------------------------------------
975cdf0e10cSrcweir
976cdf0e10cSrcweir -----------------------------------------------------------------------*/
977cdf0e10cSrcweir void SAL_CALL
setString(const OUString & rString)978cdf0e10cSrcweir SwXText::setString(const OUString& rString) throw (uno::RuntimeException)
979cdf0e10cSrcweir {
980cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
981cdf0e10cSrcweir
982cdf0e10cSrcweir if (!GetDoc())
983cdf0e10cSrcweir {
984cdf0e10cSrcweir uno::RuntimeException aRuntime;
985cdf0e10cSrcweir aRuntime.Message = C2U(cInvalidObject);
986cdf0e10cSrcweir throw aRuntime;
987cdf0e10cSrcweir }
988cdf0e10cSrcweir
989cdf0e10cSrcweir const SwStartNode* pStartNode = GetStartNode();
990cdf0e10cSrcweir if (!pStartNode)
991cdf0e10cSrcweir {
992cdf0e10cSrcweir throw uno::RuntimeException();
993cdf0e10cSrcweir }
994cdf0e10cSrcweir
995cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_START, NULL);
996cdf0e10cSrcweir //insert an empty paragraph at the start and at the end to ensure that
997cdf0e10cSrcweir //all tables and sections can be removed by the selecting text::XTextCursor
998cdf0e10cSrcweir if (CURSOR_META != m_pImpl->m_eType)
999cdf0e10cSrcweir {
1000cdf0e10cSrcweir SwPosition aStartPos(*pStartNode);
1001cdf0e10cSrcweir const SwEndNode* pEnd = pStartNode->EndOfSectionNode();
1002cdf0e10cSrcweir SwNodeIndex aEndIdx(*pEnd);
1003cdf0e10cSrcweir aEndIdx--;
1004cdf0e10cSrcweir //the inserting of nodes should only be done if really necessary
1005cdf0e10cSrcweir //to prevent #97924# (removes paragraph attributes when setting the text
1006cdf0e10cSrcweir //e.g. of a table cell
1007cdf0e10cSrcweir sal_Bool bInsertNodes = sal_False;
1008cdf0e10cSrcweir SwNodeIndex aStartIdx(*pStartNode);
1009cdf0e10cSrcweir do
1010cdf0e10cSrcweir {
1011cdf0e10cSrcweir aStartIdx++;
1012cdf0e10cSrcweir SwNode& rCurrentNode = aStartIdx.GetNode();
1013cdf0e10cSrcweir if(rCurrentNode.GetNodeType() == ND_SECTIONNODE
1014cdf0e10cSrcweir ||rCurrentNode.GetNodeType() == ND_TABLENODE)
1015cdf0e10cSrcweir {
1016cdf0e10cSrcweir bInsertNodes = sal_True;
1017cdf0e10cSrcweir break;
1018cdf0e10cSrcweir }
1019cdf0e10cSrcweir }
1020cdf0e10cSrcweir while(aStartIdx < aEndIdx);
1021cdf0e10cSrcweir if(bInsertNodes)
1022cdf0e10cSrcweir {
1023cdf0e10cSrcweir GetDoc()->AppendTxtNode( aStartPos );
1024cdf0e10cSrcweir SwPosition aEndPos(aEndIdx.GetNode());
1025cdf0e10cSrcweir SwPaM aPam(aEndPos);
1026cdf0e10cSrcweir GetDoc()->AppendTxtNode( *aPam.Start() );
1027cdf0e10cSrcweir }
1028cdf0e10cSrcweir }
1029cdf0e10cSrcweir
1030cdf0e10cSrcweir const uno::Reference< text::XTextCursor > xRet = CreateCursor();
1031cdf0e10cSrcweir if(!xRet.is())
1032cdf0e10cSrcweir {
1033cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_END, NULL);
1034cdf0e10cSrcweir uno::RuntimeException aRuntime;
1035cdf0e10cSrcweir aRuntime.Message = C2U(cInvalidObject);
1036cdf0e10cSrcweir throw aRuntime;
1037cdf0e10cSrcweir }
1038cdf0e10cSrcweir xRet->gotoEnd(sal_True);
1039cdf0e10cSrcweir xRet->setString(rString);
1040cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_END, NULL);
1041cdf0e10cSrcweir }
1042cdf0e10cSrcweir
1043cdf0e10cSrcweir //FIXME why is CheckForOwnMember duplicated in some insert methods?
1044cdf0e10cSrcweir // Description: Checks if pRange/pCursor are member of the same text interface.
1045cdf0e10cSrcweir // Only one of the pointers has to be set!
CheckForOwnMember(const SwPaM & rPaM)1046cdf0e10cSrcweir bool SwXText::Impl::CheckForOwnMember(
1047cdf0e10cSrcweir const SwPaM & rPaM)
1048cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException)
1049cdf0e10cSrcweir {
1050cdf0e10cSrcweir const uno::Reference<text::XTextCursor> xOwnCursor(m_rThis.CreateCursor());
1051cdf0e10cSrcweir
1052cdf0e10cSrcweir const uno::Reference<lang::XUnoTunnel> xTunnel(xOwnCursor, uno::UNO_QUERY);
1053cdf0e10cSrcweir OTextCursorHelper *const pOwnCursor =
1054cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xTunnel);
1055cdf0e10cSrcweir DBG_ASSERT(pOwnCursor, "OTextCursorHelper::getUnoTunnelId() ??? ");
1056cdf0e10cSrcweir const SwStartNode* pOwnStartNode =
1057cdf0e10cSrcweir pOwnCursor->GetPaM()->GetNode()->StartOfSectionNode();
1058cdf0e10cSrcweir SwStartNodeType eSearchNodeType = SwNormalStartNode;
1059cdf0e10cSrcweir switch (m_eType)
1060cdf0e10cSrcweir {
1061cdf0e10cSrcweir case CURSOR_FRAME: eSearchNodeType = SwFlyStartNode; break;
1062cdf0e10cSrcweir case CURSOR_TBLTEXT: eSearchNodeType = SwTableBoxStartNode; break;
1063cdf0e10cSrcweir case CURSOR_FOOTNOTE: eSearchNodeType = SwFootnoteStartNode; break;
1064cdf0e10cSrcweir case CURSOR_HEADER: eSearchNodeType = SwHeaderStartNode; break;
1065cdf0e10cSrcweir case CURSOR_FOOTER: eSearchNodeType = SwFooterStartNode; break;
1066cdf0e10cSrcweir //case CURSOR_INVALID:
1067cdf0e10cSrcweir //case CURSOR_BODY:
1068cdf0e10cSrcweir default:
1069cdf0e10cSrcweir ;
1070cdf0e10cSrcweir }
1071cdf0e10cSrcweir
1072cdf0e10cSrcweir SwNode const*const pSrcNode(rPaM.GetNode());
1073cdf0e10cSrcweir if (!pSrcNode) { return false; }
1074cdf0e10cSrcweir const SwStartNode* pTmp = pSrcNode->FindSttNodeByType(eSearchNodeType);
1075cdf0e10cSrcweir
1076cdf0e10cSrcweir //SectionNodes ueberspringen
1077cdf0e10cSrcweir while(pTmp && pTmp->IsSectionNode())
1078cdf0e10cSrcweir {
1079cdf0e10cSrcweir pTmp = pTmp->StartOfSectionNode();
1080cdf0e10cSrcweir }
1081cdf0e10cSrcweir
1082cdf0e10cSrcweir //if the document starts with a section
1083cdf0e10cSrcweir while(pOwnStartNode->IsSectionNode())
1084cdf0e10cSrcweir {
1085cdf0e10cSrcweir pOwnStartNode = pOwnStartNode->StartOfSectionNode();
1086cdf0e10cSrcweir }
1087cdf0e10cSrcweir
1088cdf0e10cSrcweir //this checks if (this) and xRange are in the same text::XText interface
1089cdf0e10cSrcweir return (pOwnStartNode == pTmp);
1090cdf0e10cSrcweir }
1091cdf0e10cSrcweir
1092cdf0e10cSrcweir sal_Int16
ComparePositions(const uno::Reference<text::XTextRange> & xPos1,const uno::Reference<text::XTextRange> & xPos2)1093cdf0e10cSrcweir SwXText::Impl::ComparePositions(
1094cdf0e10cSrcweir const uno::Reference<text::XTextRange>& xPos1,
1095cdf0e10cSrcweir const uno::Reference<text::XTextRange>& xPos2)
1096cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException)
1097cdf0e10cSrcweir {
1098cdf0e10cSrcweir SwUnoInternalPaM aPam1(*m_pDoc);
1099cdf0e10cSrcweir SwUnoInternalPaM aPam2(*m_pDoc);
1100cdf0e10cSrcweir
1101cdf0e10cSrcweir if (!::sw::XTextRangeToSwPaM(aPam1, xPos1) ||
1102cdf0e10cSrcweir !::sw::XTextRangeToSwPaM(aPam2, xPos2))
1103cdf0e10cSrcweir {
1104cdf0e10cSrcweir throw lang::IllegalArgumentException();
1105cdf0e10cSrcweir }
1106cdf0e10cSrcweir if (!CheckForOwnMember(aPam1) || !CheckForOwnMember(aPam2))
1107cdf0e10cSrcweir {
1108cdf0e10cSrcweir throw lang::IllegalArgumentException();
1109cdf0e10cSrcweir }
1110cdf0e10cSrcweir
1111cdf0e10cSrcweir sal_Int16 nCompare = 0;
1112cdf0e10cSrcweir SwPosition const*const pStart1 = aPam1.Start();
1113cdf0e10cSrcweir SwPosition const*const pStart2 = aPam2.Start();
1114cdf0e10cSrcweir if (*pStart1 < *pStart2)
1115cdf0e10cSrcweir {
1116cdf0e10cSrcweir nCompare = 1;
1117cdf0e10cSrcweir }
1118cdf0e10cSrcweir else if (*pStart1 > *pStart2)
1119cdf0e10cSrcweir {
1120cdf0e10cSrcweir nCompare = -1;
1121cdf0e10cSrcweir }
1122cdf0e10cSrcweir else
1123cdf0e10cSrcweir {
1124cdf0e10cSrcweir DBG_ASSERT(*pStart1 == *pStart2,
1125cdf0e10cSrcweir "SwPositions should be equal here");
1126cdf0e10cSrcweir nCompare = 0;
1127cdf0e10cSrcweir }
1128cdf0e10cSrcweir
1129cdf0e10cSrcweir return nCompare;
1130cdf0e10cSrcweir }
1131cdf0e10cSrcweir
1132cdf0e10cSrcweir /*-- 28.03.00 10:37:22---------------------------------------------------
1133cdf0e10cSrcweir
1134cdf0e10cSrcweir -----------------------------------------------------------------------*/
1135cdf0e10cSrcweir sal_Int16 SAL_CALL
compareRegionStarts(const uno::Reference<text::XTextRange> & xRange1,const uno::Reference<text::XTextRange> & xRange2)1136cdf0e10cSrcweir SwXText::compareRegionStarts(
1137cdf0e10cSrcweir const uno::Reference<text::XTextRange>& xRange1,
1138cdf0e10cSrcweir const uno::Reference<text::XTextRange>& xRange2)
1139cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException)
1140cdf0e10cSrcweir {
1141cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1142cdf0e10cSrcweir
1143cdf0e10cSrcweir if (!xRange1.is() || !xRange2.is())
1144cdf0e10cSrcweir {
1145cdf0e10cSrcweir throw lang::IllegalArgumentException();
1146cdf0e10cSrcweir }
1147cdf0e10cSrcweir const uno::Reference<text::XTextRange> xStart1 = xRange1->getStart();
1148cdf0e10cSrcweir const uno::Reference<text::XTextRange> xStart2 = xRange2->getStart();
1149cdf0e10cSrcweir
1150cdf0e10cSrcweir return m_pImpl->ComparePositions(xStart1, xStart2);
1151cdf0e10cSrcweir }
1152cdf0e10cSrcweir /*-- 28.03.00 10:37:25---------------------------------------------------
1153cdf0e10cSrcweir
1154cdf0e10cSrcweir -----------------------------------------------------------------------*/
1155cdf0e10cSrcweir sal_Int16 SAL_CALL
compareRegionEnds(const uno::Reference<text::XTextRange> & xRange1,const uno::Reference<text::XTextRange> & xRange2)1156cdf0e10cSrcweir SwXText::compareRegionEnds(
1157cdf0e10cSrcweir const uno::Reference<text::XTextRange>& xRange1,
1158cdf0e10cSrcweir const uno::Reference<text::XTextRange>& xRange2)
1159cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException)
1160cdf0e10cSrcweir {
1161cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1162cdf0e10cSrcweir
1163cdf0e10cSrcweir if (!xRange1.is() || !xRange2.is())
1164cdf0e10cSrcweir {
1165cdf0e10cSrcweir throw lang::IllegalArgumentException();
1166cdf0e10cSrcweir }
1167cdf0e10cSrcweir uno::Reference<text::XTextRange> xEnd1 = xRange1->getEnd();
1168cdf0e10cSrcweir uno::Reference<text::XTextRange> xEnd2 = xRange2->getEnd();
1169cdf0e10cSrcweir
1170cdf0e10cSrcweir return m_pImpl->ComparePositions(xEnd1, xEnd2);
1171cdf0e10cSrcweir }
1172cdf0e10cSrcweir
1173cdf0e10cSrcweir /*-- 15.03.2002 12:30:40---------------------------------------------------
1174cdf0e10cSrcweir
1175cdf0e10cSrcweir -----------------------------------------------------------------------*/
1176cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo()1177cdf0e10cSrcweir SwXText::getPropertySetInfo() throw(uno::RuntimeException)
1178cdf0e10cSrcweir {
1179cdf0e10cSrcweir vos::OGuard g(Application::GetSolarMutex());
1180cdf0e10cSrcweir
1181cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xInfo =
1182cdf0e10cSrcweir m_pImpl->m_rPropSet.getPropertySetInfo();
1183cdf0e10cSrcweir return xInfo;
1184cdf0e10cSrcweir }
1185cdf0e10cSrcweir
1186cdf0e10cSrcweir /*-- 15.03.2002 12:30:42---------------------------------------------------
1187cdf0e10cSrcweir
1188cdf0e10cSrcweir -----------------------------------------------------------------------*/
1189cdf0e10cSrcweir void SAL_CALL
setPropertyValue(const::rtl::OUString &,const uno::Any &)1190cdf0e10cSrcweir SwXText::setPropertyValue(const ::rtl::OUString& /*aPropertyName*/,
1191cdf0e10cSrcweir const uno::Any& /*aValue*/)
1192cdf0e10cSrcweir throw (beans::UnknownPropertyException, beans::PropertyVetoException,
1193cdf0e10cSrcweir lang::IllegalArgumentException, lang::WrappedTargetException,
1194cdf0e10cSrcweir uno::RuntimeException)
1195cdf0e10cSrcweir {
1196cdf0e10cSrcweir throw lang::IllegalArgumentException();
1197cdf0e10cSrcweir }
1198cdf0e10cSrcweir /*-- 15.03.2002 12:30:42---------------------------------------------------
1199cdf0e10cSrcweir
1200cdf0e10cSrcweir -----------------------------------------------------------------------*/
1201cdf0e10cSrcweir uno::Any SAL_CALL
getPropertyValue(const::rtl::OUString & rPropertyName)1202cdf0e10cSrcweir SwXText::getPropertyValue(
1203cdf0e10cSrcweir const ::rtl::OUString& rPropertyName)
1204cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException,
1205cdf0e10cSrcweir uno::RuntimeException)
1206cdf0e10cSrcweir {
1207cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1208cdf0e10cSrcweir
1209cdf0e10cSrcweir if(!IsValid())
1210cdf0e10cSrcweir {
1211cdf0e10cSrcweir throw uno::RuntimeException();
1212cdf0e10cSrcweir }
1213cdf0e10cSrcweir
1214cdf0e10cSrcweir SfxItemPropertySimpleEntry const*const pEntry =
1215cdf0e10cSrcweir m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName);
1216cdf0e10cSrcweir if (!pEntry)
1217cdf0e10cSrcweir {
1218cdf0e10cSrcweir beans::UnknownPropertyException aExcept;
1219cdf0e10cSrcweir aExcept.Message = C2U("Unknown property: ");
1220cdf0e10cSrcweir aExcept.Message += rPropertyName;
1221cdf0e10cSrcweir throw aExcept;
1222cdf0e10cSrcweir }
1223cdf0e10cSrcweir
1224cdf0e10cSrcweir uno::Any aRet;
1225cdf0e10cSrcweir switch (pEntry->nWID)
1226cdf0e10cSrcweir {
1227cdf0e10cSrcweir // no code necessary - the redline is always located at the end node
1228cdf0e10cSrcweir // case FN_UNO_REDLINE_NODE_START:
1229cdf0e10cSrcweir // break;
1230cdf0e10cSrcweir case FN_UNO_REDLINE_NODE_END:
1231cdf0e10cSrcweir {
1232cdf0e10cSrcweir const SwRedlineTbl& rRedTbl = GetDoc()->GetRedlineTbl();
1233cdf0e10cSrcweir const sal_uInt16 nRedTblCount = rRedTbl.Count();
1234cdf0e10cSrcweir if (nRedTblCount > 0)
1235cdf0e10cSrcweir {
1236cdf0e10cSrcweir SwStartNode const*const pStartNode = GetStartNode();
1237cdf0e10cSrcweir const sal_uLong nOwnIndex = pStartNode->EndOfSectionIndex();
1238cdf0e10cSrcweir for (sal_uInt16 nRed = 0; nRed < nRedTblCount; nRed++)
1239cdf0e10cSrcweir {
1240cdf0e10cSrcweir SwRedline const*const pRedline = rRedTbl[nRed];
1241cdf0e10cSrcweir SwPosition const*const pRedStart = pRedline->Start();
1242cdf0e10cSrcweir const SwNodeIndex nRedNode = pRedStart->nNode;
1243cdf0e10cSrcweir if (nOwnIndex == nRedNode.GetIndex())
1244cdf0e10cSrcweir {
1245cdf0e10cSrcweir aRet <<= SwXRedlinePortion::CreateRedlineProperties(
1246cdf0e10cSrcweir *pRedline, sal_True);
1247cdf0e10cSrcweir break;
1248cdf0e10cSrcweir }
1249cdf0e10cSrcweir }
1250cdf0e10cSrcweir }
1251cdf0e10cSrcweir }
1252cdf0e10cSrcweir break;
1253cdf0e10cSrcweir }
1254cdf0e10cSrcweir return aRet;
1255cdf0e10cSrcweir }
1256cdf0e10cSrcweir
1257cdf0e10cSrcweir /*-- 15.03.2002 12:30:42---------------------------------------------------
1258cdf0e10cSrcweir
1259cdf0e10cSrcweir -----------------------------------------------------------------------*/
1260cdf0e10cSrcweir void SAL_CALL
addPropertyChangeListener(const::rtl::OUString &,const uno::Reference<beans::XPropertyChangeListener> &)1261cdf0e10cSrcweir SwXText::addPropertyChangeListener(
1262cdf0e10cSrcweir const ::rtl::OUString& /*rPropertyName*/,
1263cdf0e10cSrcweir const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
1264cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException,
1265cdf0e10cSrcweir uno::RuntimeException)
1266cdf0e10cSrcweir {
1267cdf0e10cSrcweir OSL_ENSURE(false,
1268cdf0e10cSrcweir "SwXText::addPropertyChangeListener(): not implemented");
1269cdf0e10cSrcweir }
1270cdf0e10cSrcweir /*-- 15.03.2002 12:30:43---------------------------------------------------
1271cdf0e10cSrcweir
1272cdf0e10cSrcweir -----------------------------------------------------------------------*/
1273cdf0e10cSrcweir void SAL_CALL
removePropertyChangeListener(const::rtl::OUString &,const uno::Reference<beans::XPropertyChangeListener> &)1274cdf0e10cSrcweir SwXText::removePropertyChangeListener(
1275cdf0e10cSrcweir const ::rtl::OUString& /*rPropertyName*/,
1276cdf0e10cSrcweir const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
1277cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException,
1278cdf0e10cSrcweir uno::RuntimeException)
1279cdf0e10cSrcweir {
1280cdf0e10cSrcweir OSL_ENSURE(false,
1281cdf0e10cSrcweir "SwXText::removePropertyChangeListener(): not implemented");
1282cdf0e10cSrcweir }
1283cdf0e10cSrcweir /*-- 15.03.2002 12:30:43---------------------------------------------------
1284cdf0e10cSrcweir
1285cdf0e10cSrcweir -----------------------------------------------------------------------*/
1286cdf0e10cSrcweir void SAL_CALL
addVetoableChangeListener(const::rtl::OUString &,const uno::Reference<beans::XVetoableChangeListener> &)1287cdf0e10cSrcweir SwXText::addVetoableChangeListener(
1288cdf0e10cSrcweir const ::rtl::OUString& /*rPropertyName*/,
1289cdf0e10cSrcweir const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
1290cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException,
1291cdf0e10cSrcweir uno::RuntimeException)
1292cdf0e10cSrcweir {
1293cdf0e10cSrcweir OSL_ENSURE(false,
1294cdf0e10cSrcweir "SwXText::addVetoableChangeListener(): not implemented");
1295cdf0e10cSrcweir }
1296cdf0e10cSrcweir /*-- 15.03.2002 12:30:43---------------------------------------------------
1297cdf0e10cSrcweir
1298cdf0e10cSrcweir -----------------------------------------------------------------------*/
1299cdf0e10cSrcweir void SAL_CALL
removeVetoableChangeListener(const::rtl::OUString &,const uno::Reference<beans::XVetoableChangeListener> &)1300cdf0e10cSrcweir SwXText::removeVetoableChangeListener(
1301cdf0e10cSrcweir const ::rtl::OUString& /*rPropertyName*/,
1302cdf0e10cSrcweir const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
1303cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException,
1304cdf0e10cSrcweir uno::RuntimeException)
1305cdf0e10cSrcweir {
1306cdf0e10cSrcweir OSL_ENSURE(false,
1307cdf0e10cSrcweir "SwXText::removeVetoableChangeListener(): not implemented");
1308cdf0e10cSrcweir }
1309cdf0e10cSrcweir
1310cdf0e10cSrcweir /* -----------------------------08.01.01 09:07--------------------------------
1311cdf0e10cSrcweir
1312cdf0e10cSrcweir ---------------------------------------------------------------------------*/
getUnoTunnelId()1313cdf0e10cSrcweir const uno::Sequence< sal_Int8 > & SwXText::getUnoTunnelId()
1314cdf0e10cSrcweir {
1315cdf0e10cSrcweir static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
1316cdf0e10cSrcweir return aSeq;
1317cdf0e10cSrcweir }
1318cdf0e10cSrcweir /* -----------------------------08.01.01 09:07--------------------------------
1319cdf0e10cSrcweir
1320cdf0e10cSrcweir ---------------------------------------------------------------------------*/
1321cdf0e10cSrcweir sal_Int64 SAL_CALL
getSomething(const uno::Sequence<sal_Int8> & rId)1322cdf0e10cSrcweir SwXText::getSomething(const uno::Sequence< sal_Int8 >& rId)
1323cdf0e10cSrcweir throw (uno::RuntimeException)
1324cdf0e10cSrcweir {
1325cdf0e10cSrcweir return ::sw::UnoTunnelImpl<SwXText>(rId, this);
1326cdf0e10cSrcweir }
1327cdf0e10cSrcweir
1328cdf0e10cSrcweir /*-- 23.06.2006 08:56:30---------------------------------------------------
1329cdf0e10cSrcweir
1330cdf0e10cSrcweir -----------------------------------------------------------------------*/
1331cdf0e10cSrcweir uno::Reference< text::XTextRange > SAL_CALL
appendParagraph(const uno::Sequence<beans::PropertyValue> & rProperties)1332cdf0e10cSrcweir SwXText::appendParagraph(
1333cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue > & rProperties)
1334cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException)
1335cdf0e10cSrcweir {
1336cdf0e10cSrcweir vos::OGuard g(Application::GetSolarMutex());
1337cdf0e10cSrcweir
1338cdf0e10cSrcweir return m_pImpl->finishOrAppendParagraph(false, rProperties);
1339cdf0e10cSrcweir }
1340cdf0e10cSrcweir /*-- 23.06.2006 08:56:22---------------------------------------------------
1341cdf0e10cSrcweir
1342cdf0e10cSrcweir -----------------------------------------------------------------------*/
1343cdf0e10cSrcweir uno::Reference< text::XTextRange > SAL_CALL
finishParagraph(const uno::Sequence<beans::PropertyValue> & rProperties)1344cdf0e10cSrcweir SwXText::finishParagraph(
1345cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue > & rProperties)
1346cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException)
1347cdf0e10cSrcweir {
1348cdf0e10cSrcweir vos::OGuard g(Application::GetSolarMutex());
1349cdf0e10cSrcweir
1350cdf0e10cSrcweir return m_pImpl->finishOrAppendParagraph(true, rProperties);
1351cdf0e10cSrcweir }
1352cdf0e10cSrcweir
1353cdf0e10cSrcweir /*-- 08.05.2006 13:26:26---------------------------------------------------
1354cdf0e10cSrcweir
1355cdf0e10cSrcweir -----------------------------------------------------------------------*/
1356cdf0e10cSrcweir uno::Reference< text::XTextRange >
finishOrAppendParagraph(const bool bFinish,const uno::Sequence<beans::PropertyValue> & rProperties)1357cdf0e10cSrcweir SwXText::Impl::finishOrAppendParagraph(
1358cdf0e10cSrcweir const bool bFinish,
1359cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue > & rProperties)
1360cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException)
1361cdf0e10cSrcweir {
1362cdf0e10cSrcweir if (!m_bIsValid)
1363cdf0e10cSrcweir {
1364cdf0e10cSrcweir throw uno::RuntimeException();
1365cdf0e10cSrcweir }
1366cdf0e10cSrcweir
1367cdf0e10cSrcweir const SwStartNode* pStartNode = m_rThis.GetStartNode();
1368cdf0e10cSrcweir if(!pStartNode)
1369cdf0e10cSrcweir {
1370cdf0e10cSrcweir throw uno::RuntimeException();
1371cdf0e10cSrcweir }
1372cdf0e10cSrcweir
1373cdf0e10cSrcweir uno::Reference< text::XTextRange > xRet;
1374cdf0e10cSrcweir bool bIllegalException = false;
1375cdf0e10cSrcweir bool bRuntimeException = false;
1376cdf0e10cSrcweir ::rtl::OUString sMessage;
1377cdf0e10cSrcweir m_pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_START , NULL);
1378cdf0e10cSrcweir // find end node, go backward - don't skip tables because the new
1379cdf0e10cSrcweir // paragraph has to be the last node
1380cdf0e10cSrcweir //aPam.Move( fnMoveBackward, fnGoNode );
1381cdf0e10cSrcweir SwPosition aInsertPosition(
1382cdf0e10cSrcweir SwNodeIndex( *pStartNode->EndOfSectionNode(), -1 ) );
1383cdf0e10cSrcweir SwPaM aPam(aInsertPosition);
1384cdf0e10cSrcweir m_pDoc->AppendTxtNode( *aPam.GetPoint() );
1385cdf0e10cSrcweir // remove attributes from the previous paragraph
1386cdf0e10cSrcweir m_pDoc->ResetAttrs(aPam);
1387cdf0e10cSrcweir // in case of finishParagraph the PaM needs to be moved to the
1388cdf0e10cSrcweir // previous paragraph
1389cdf0e10cSrcweir if (bFinish)
1390cdf0e10cSrcweir {
1391cdf0e10cSrcweir aPam.Move( fnMoveBackward, fnGoNode );
1392cdf0e10cSrcweir }
1393cdf0e10cSrcweir if (rProperties.getLength())
1394cdf0e10cSrcweir {
1395cdf0e10cSrcweir // now set the properties
1396cdf0e10cSrcweir SfxItemPropertySet const*const pParaPropSet =
1397cdf0e10cSrcweir aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH);
1398cdf0e10cSrcweir SfxItemPropertyMap const*const pParagraphMap =
1399cdf0e10cSrcweir pParaPropSet->getPropertyMap();
1400cdf0e10cSrcweir
1401cdf0e10cSrcweir const beans::PropertyValue* pValues = rProperties.getConstArray();
1402cdf0e10cSrcweir
1403cdf0e10cSrcweir for (sal_Int32 nProp = 0; nProp < rProperties.getLength(); ++nProp)
1404cdf0e10cSrcweir {
1405cdf0e10cSrcweir if (!pParagraphMap->getByName(pValues[nProp].Name))
1406cdf0e10cSrcweir {
1407cdf0e10cSrcweir bIllegalException = true;
1408cdf0e10cSrcweir break;
1409cdf0e10cSrcweir }
1410cdf0e10cSrcweir try
1411cdf0e10cSrcweir {
1412cdf0e10cSrcweir SwUnoCursorHelper::SetPropertyValue(aPam, *pParaPropSet,
1413cdf0e10cSrcweir pValues[nProp].Name, pValues[nProp].Value);
1414cdf0e10cSrcweir }
1415cdf0e10cSrcweir catch (lang::IllegalArgumentException& rIllegal)
1416cdf0e10cSrcweir {
1417cdf0e10cSrcweir sMessage = rIllegal.Message;
1418cdf0e10cSrcweir bIllegalException = true;
1419cdf0e10cSrcweir break;
1420cdf0e10cSrcweir }
1421cdf0e10cSrcweir catch (uno::RuntimeException& rRuntime)
1422cdf0e10cSrcweir {
1423cdf0e10cSrcweir sMessage = rRuntime.Message;
1424cdf0e10cSrcweir bRuntimeException = true;
1425cdf0e10cSrcweir break;
1426cdf0e10cSrcweir }
1427cdf0e10cSrcweir }
1428cdf0e10cSrcweir }
1429cdf0e10cSrcweir m_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_END, NULL);
1430cdf0e10cSrcweir if (bIllegalException || bRuntimeException)
1431cdf0e10cSrcweir {
1432cdf0e10cSrcweir m_pDoc->GetIDocumentUndoRedo().Undo();
1433cdf0e10cSrcweir if (bIllegalException)
1434cdf0e10cSrcweir {
1435cdf0e10cSrcweir lang::IllegalArgumentException aEx;
1436cdf0e10cSrcweir aEx.Message = sMessage;
1437cdf0e10cSrcweir throw aEx;
1438cdf0e10cSrcweir }
1439cdf0e10cSrcweir else // if(bRuntimeException)
1440cdf0e10cSrcweir {
1441cdf0e10cSrcweir uno::RuntimeException aEx;
1442cdf0e10cSrcweir aEx.Message = sMessage;
1443cdf0e10cSrcweir throw aEx;
1444cdf0e10cSrcweir }
1445cdf0e10cSrcweir }
1446cdf0e10cSrcweir SwTxtNode *const pTxtNode( aPam.Start()->nNode.GetNode().GetTxtNode() );
1447cdf0e10cSrcweir OSL_ENSURE(pTxtNode, "no SwTxtNode?");
1448cdf0e10cSrcweir if (pTxtNode)
1449cdf0e10cSrcweir {
1450cdf0e10cSrcweir xRet.set(SwXParagraph::CreateXParagraph(*m_pDoc, *pTxtNode, &m_rThis),
1451cdf0e10cSrcweir uno::UNO_QUERY);
1452cdf0e10cSrcweir }
1453cdf0e10cSrcweir
1454cdf0e10cSrcweir return xRet;
1455cdf0e10cSrcweir }
1456cdf0e10cSrcweir
1457cdf0e10cSrcweir /*-- 08.05.2006 13:28:26---------------------------------------------------
1458cdf0e10cSrcweir Append text portions at the end of the last paragraph of the text
1459cdf0e10cSrcweir interface. Support of import filters.
1460cdf0e10cSrcweir -----------------------------------------------------------------------*/
1461cdf0e10cSrcweir uno::Reference< text::XTextRange > SAL_CALL
appendTextPortion(const::rtl::OUString & rText,const uno::Sequence<beans::PropertyValue> & rCharacterAndParagraphProperties)1462cdf0e10cSrcweir SwXText::appendTextPortion(
1463cdf0e10cSrcweir const ::rtl::OUString& rText,
1464cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue > &
1465cdf0e10cSrcweir rCharacterAndParagraphProperties)
1466cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException)
1467cdf0e10cSrcweir {
1468cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1469cdf0e10cSrcweir
1470cdf0e10cSrcweir if(!IsValid())
1471cdf0e10cSrcweir {
1472cdf0e10cSrcweir throw uno::RuntimeException();
1473cdf0e10cSrcweir }
1474cdf0e10cSrcweir uno::Reference< text::XTextRange > xRet;
1475cdf0e10cSrcweir const uno::Reference< text::XTextCursor > xTextCursor = CreateCursor();
1476cdf0e10cSrcweir xTextCursor->gotoEnd(sal_False);
1477cdf0e10cSrcweir
1478cdf0e10cSrcweir const uno::Reference< lang::XUnoTunnel > xRangeTunnel(
1479cdf0e10cSrcweir xTextCursor, uno::UNO_QUERY_THROW );
1480cdf0e10cSrcweir SwXTextCursor *const pTextCursor =
1481cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<SwXTextCursor>(xRangeTunnel);
1482cdf0e10cSrcweir
1483cdf0e10cSrcweir bool bIllegalException = false;
1484cdf0e10cSrcweir bool bRuntimeException = false;
1485cdf0e10cSrcweir ::rtl::OUString sMessage;
1486cdf0e10cSrcweir m_pImpl->m_pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL);
1487cdf0e10cSrcweir
1488cdf0e10cSrcweir // SwPaM aPam(*pStartNode->EndOfSectionNode());
1489cdf0e10cSrcweir //aPam.Move( fnMoveBackward, fnGoNode );
1490cdf0e10cSrcweir SwUnoCrsr *const pCursor = pTextCursor->GetCursor();
1491cdf0e10cSrcweir pCursor->MovePara( fnParaCurr, fnParaEnd );
1492cdf0e10cSrcweir m_pImpl->m_pDoc->DontExpandFmt( *pCursor->Start() );
1493cdf0e10cSrcweir
1494cdf0e10cSrcweir if (rText.getLength())
1495cdf0e10cSrcweir {
1496cdf0e10cSrcweir const xub_StrLen nContentPos = pCursor->GetPoint()->nContent.GetIndex();
1497cdf0e10cSrcweir SwUnoCursorHelper::DocInsertStringSplitCR(
1498cdf0e10cSrcweir *m_pImpl->m_pDoc, *pCursor, rText, false);
1499cdf0e10cSrcweir SwUnoCursorHelper::SelectPam(*pCursor, true);
1500cdf0e10cSrcweir pCursor->GetPoint()->nContent = nContentPos;
1501cdf0e10cSrcweir }
1502cdf0e10cSrcweir
1503cdf0e10cSrcweir if (rCharacterAndParagraphProperties.getLength())
1504cdf0e10cSrcweir {
1505cdf0e10cSrcweir SfxItemPropertyMap const*const pCursorMap =
1506cdf0e10cSrcweir aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)
1507cdf0e10cSrcweir ->getPropertyMap();
1508cdf0e10cSrcweir beans::PropertyValue const*const pValues =
1509cdf0e10cSrcweir rCharacterAndParagraphProperties.getConstArray();
1510cdf0e10cSrcweir SfxItemPropertySet const*const pCursorPropSet =
1511cdf0e10cSrcweir aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR);
1512cdf0e10cSrcweir const sal_Int32 nLen(rCharacterAndParagraphProperties.getLength());
1513cdf0e10cSrcweir for (sal_Int32 nProp = 0; nProp < nLen; ++nProp)
1514cdf0e10cSrcweir {
1515cdf0e10cSrcweir if (!pCursorMap->getByName( pValues[nProp].Name ))
1516cdf0e10cSrcweir {
1517cdf0e10cSrcweir bIllegalException = true;
1518cdf0e10cSrcweir break;
1519cdf0e10cSrcweir }
1520cdf0e10cSrcweir try
1521cdf0e10cSrcweir {
1522cdf0e10cSrcweir SwUnoCursorHelper::SetPropertyValue(
1523cdf0e10cSrcweir *pCursor, *pCursorPropSet,
1524cdf0e10cSrcweir pValues[nProp].Name, pValues[nProp].Value,
1525cdf0e10cSrcweir nsSetAttrMode::SETATTR_NOFORMATATTR);
1526cdf0e10cSrcweir }
1527cdf0e10cSrcweir catch( lang::IllegalArgumentException& rIllegal )
1528cdf0e10cSrcweir {
1529cdf0e10cSrcweir sMessage = rIllegal.Message;
1530cdf0e10cSrcweir bIllegalException = true;
1531cdf0e10cSrcweir break;
1532cdf0e10cSrcweir }
1533cdf0e10cSrcweir catch( uno::RuntimeException& rRuntime )
1534cdf0e10cSrcweir {
1535cdf0e10cSrcweir sMessage = rRuntime.Message;
1536cdf0e10cSrcweir bRuntimeException = true;
1537cdf0e10cSrcweir break;
1538cdf0e10cSrcweir }
1539cdf0e10cSrcweir }
1540cdf0e10cSrcweir }
1541cdf0e10cSrcweir m_pImpl->m_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL);
1542cdf0e10cSrcweir if (bIllegalException || bRuntimeException)
1543cdf0e10cSrcweir {
1544cdf0e10cSrcweir m_pImpl->m_pDoc->GetIDocumentUndoRedo().Undo();
1545cdf0e10cSrcweir if (bIllegalException)
1546cdf0e10cSrcweir {
1547cdf0e10cSrcweir lang::IllegalArgumentException aEx;
1548cdf0e10cSrcweir aEx.Message = sMessage;
1549cdf0e10cSrcweir throw aEx;
1550cdf0e10cSrcweir }
1551cdf0e10cSrcweir else //if(bRuntimeException)
1552cdf0e10cSrcweir {
1553cdf0e10cSrcweir uno::RuntimeException aEx;
1554cdf0e10cSrcweir aEx.Message = sMessage;
1555cdf0e10cSrcweir throw aEx;
1556cdf0e10cSrcweir }
1557cdf0e10cSrcweir }
1558cdf0e10cSrcweir xRet = new SwXTextRange(*pCursor, this);
1559cdf0e10cSrcweir return xRet;
1560cdf0e10cSrcweir }
1561cdf0e10cSrcweir
1562cdf0e10cSrcweir /*-- 11.05.2006 15:46:26---------------------------------------------------
1563cdf0e10cSrcweir enable appending text contents like graphic objects, shapes and so on
1564cdf0e10cSrcweir to support import filters
1565cdf0e10cSrcweir -----------------------------------------------------------------------*/
1566cdf0e10cSrcweir uno::Reference< text::XTextRange > SAL_CALL
appendTextContent(const uno::Reference<text::XTextContent> & xTextContent,const uno::Sequence<beans::PropertyValue> & rCharacterAndParagraphProperties)1567cdf0e10cSrcweir SwXText::appendTextContent(
1568cdf0e10cSrcweir const uno::Reference< text::XTextContent >& xTextContent,
1569cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >&
1570cdf0e10cSrcweir rCharacterAndParagraphProperties)
1571cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException)
1572cdf0e10cSrcweir {
1573cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1574cdf0e10cSrcweir
1575cdf0e10cSrcweir if (!IsValid())
1576cdf0e10cSrcweir {
1577cdf0e10cSrcweir throw uno::RuntimeException();
1578cdf0e10cSrcweir }
1579cdf0e10cSrcweir SwStartNode const*const pStartNode = GetStartNode();
1580cdf0e10cSrcweir if(!pStartNode)
1581cdf0e10cSrcweir {
1582cdf0e10cSrcweir throw uno::RuntimeException();
1583cdf0e10cSrcweir }
1584cdf0e10cSrcweir
1585cdf0e10cSrcweir uno::Reference< text::XTextRange > xRet;
1586cdf0e10cSrcweir m_pImpl->m_pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL);
1587cdf0e10cSrcweir // find end node, go backward - don't skip tables because the
1588cdf0e10cSrcweir // new paragraph has to be the last node
1589cdf0e10cSrcweir SwPaM aPam(*pStartNode->EndOfSectionNode());
1590cdf0e10cSrcweir aPam.Move( fnMoveBackward, fnGoNode );
1591cdf0e10cSrcweir // set cursor to the end of the last text node
1592cdf0e10cSrcweir SwCursor aCursor( *aPam.Start(), 0, false );
1593cdf0e10cSrcweir xRet = new SwXTextRange(aCursor, this);
1594cdf0e10cSrcweir aCursor.MovePara( fnParaCurr, fnParaEnd );
1595cdf0e10cSrcweir m_pImpl->m_pDoc->DontExpandFmt( *aCursor.Start() );
1596cdf0e10cSrcweir // now attach the text content here
1597cdf0e10cSrcweir insertTextContent( xRet, xTextContent, false );
1598cdf0e10cSrcweir // now apply the properties to the anchor
1599cdf0e10cSrcweir if (rCharacterAndParagraphProperties.getLength())
1600cdf0e10cSrcweir {
1601cdf0e10cSrcweir try
1602cdf0e10cSrcweir {
1603cdf0e10cSrcweir const sal_Int32 nLen(rCharacterAndParagraphProperties.getLength());
1604cdf0e10cSrcweir const uno::Reference< beans::XPropertySet > xAnchor(
1605cdf0e10cSrcweir xTextContent->getAnchor(), uno::UNO_QUERY);
1606cdf0e10cSrcweir if (xAnchor.is())
1607cdf0e10cSrcweir {
1608cdf0e10cSrcweir for (sal_Int32 nElement = 0; nElement < nLen; ++nElement)
1609cdf0e10cSrcweir {
1610cdf0e10cSrcweir xAnchor->setPropertyValue(
1611cdf0e10cSrcweir rCharacterAndParagraphProperties[nElement].Name,
1612cdf0e10cSrcweir rCharacterAndParagraphProperties[nElement].Value);
1613cdf0e10cSrcweir }
1614cdf0e10cSrcweir }
1615cdf0e10cSrcweir }
1616cdf0e10cSrcweir catch (const uno::Exception&)
1617cdf0e10cSrcweir {
1618cdf0e10cSrcweir throw uno::RuntimeException();
1619cdf0e10cSrcweir }
1620cdf0e10cSrcweir }
1621cdf0e10cSrcweir m_pImpl->m_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL);
1622cdf0e10cSrcweir return xRet;
1623cdf0e10cSrcweir }
1624cdf0e10cSrcweir
1625cdf0e10cSrcweir // move previously appended paragraphs into a text frames
1626cdf0e10cSrcweir // to support import filters
1627cdf0e10cSrcweir uno::Reference< text::XTextContent > SAL_CALL
convertToTextFrame(const uno::Reference<text::XTextRange> & xStart,const uno::Reference<text::XTextRange> & xEnd,const uno::Sequence<beans::PropertyValue> & rFrameProperties)1628cdf0e10cSrcweir SwXText::convertToTextFrame(
1629cdf0e10cSrcweir const uno::Reference< text::XTextRange >& xStart,
1630cdf0e10cSrcweir const uno::Reference< text::XTextRange >& xEnd,
1631cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >& rFrameProperties)
1632cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException)
1633cdf0e10cSrcweir {
1634cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1635cdf0e10cSrcweir
1636cdf0e10cSrcweir if(!IsValid())
1637cdf0e10cSrcweir {
1638cdf0e10cSrcweir throw uno::RuntimeException();
1639cdf0e10cSrcweir }
1640cdf0e10cSrcweir uno::Reference< text::XTextContent > xRet;
1641cdf0e10cSrcweir SwUnoInternalPaM aStartPam(*GetDoc());
1642cdf0e10cSrcweir std::auto_ptr< SwUnoInternalPaM > pEndPam(new SwUnoInternalPaM(*GetDoc()));
1643cdf0e10cSrcweir if (!::sw::XTextRangeToSwPaM(aStartPam, xStart) ||
1644cdf0e10cSrcweir !::sw::XTextRangeToSwPaM(*pEndPam, xEnd))
1645cdf0e10cSrcweir {
1646cdf0e10cSrcweir throw lang::IllegalArgumentException();
1647cdf0e10cSrcweir }
1648cdf0e10cSrcweir
1649cdf0e10cSrcweir const uno::Reference<lang::XUnoTunnel> xStartRangeTunnel(xStart,
1650cdf0e10cSrcweir uno::UNO_QUERY);
1651cdf0e10cSrcweir SwXTextRange *const pStartRange =
1652cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<SwXTextRange>(xStartRangeTunnel);
1653cdf0e10cSrcweir const uno::Reference<lang::XUnoTunnel> xEndRangeTunnel(xEnd,
1654cdf0e10cSrcweir uno::UNO_QUERY);
1655cdf0e10cSrcweir SwXTextRange *const pEndRange =
1656cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<SwXTextRange>(xEndRangeTunnel);
1657cdf0e10cSrcweir // bookmarks have to be removed before the referenced text node
1658cdf0e10cSrcweir // is deleted in DelFullPara
1659cdf0e10cSrcweir if (pStartRange)
1660cdf0e10cSrcweir {
1661cdf0e10cSrcweir pStartRange->Invalidate();
1662cdf0e10cSrcweir }
1663cdf0e10cSrcweir if (pEndRange)
1664cdf0e10cSrcweir {
1665cdf0e10cSrcweir pEndRange->Invalidate();
1666cdf0e10cSrcweir }
1667cdf0e10cSrcweir
1668cdf0e10cSrcweir m_pImpl->m_pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
1669cdf0e10cSrcweir bool bIllegalException = false;
1670cdf0e10cSrcweir bool bRuntimeException = false;
1671cdf0e10cSrcweir ::rtl::OUString sMessage;
1672cdf0e10cSrcweir SwStartNode* pStartStartNode = aStartPam.GetNode()->StartOfSectionNode();
1673cdf0e10cSrcweir while (pStartStartNode && pStartStartNode->IsSectionNode())
1674cdf0e10cSrcweir {
1675cdf0e10cSrcweir pStartStartNode = pStartStartNode->StartOfSectionNode();
1676cdf0e10cSrcweir }
1677cdf0e10cSrcweir SwStartNode* pEndStartNode = pEndPam->GetNode()->StartOfSectionNode();
1678cdf0e10cSrcweir while (pEndStartNode && pEndStartNode->IsSectionNode())
1679cdf0e10cSrcweir {
1680cdf0e10cSrcweir pEndStartNode = pEndStartNode->StartOfSectionNode();
1681cdf0e10cSrcweir }
1682cdf0e10cSrcweir bool bParaAfterInserted = false;
1683cdf0e10cSrcweir bool bParaBeforeInserted = false;
1684cdf0e10cSrcweir if (pStartStartNode != pEndStartNode || pStartStartNode != GetStartNode())
1685cdf0e10cSrcweir {
1686cdf0e10cSrcweir // todo: if the start/end is in a table then insert a paragraph
1687cdf0e10cSrcweir // before/after, move the start/end nodes, then convert and
1688cdf0e10cSrcweir // remove the addtional paragraphs in the end
1689cdf0e10cSrcweir if (pStartStartNode->GetStartNodeType() == SwTableBoxStartNode)
1690cdf0e10cSrcweir {
1691cdf0e10cSrcweir SwTableNode *const pSartTableNode(pStartStartNode->FindTableNode());
1692cdf0e10cSrcweir const SwNodeIndex aTblIdx( *pSartTableNode, -1 );
1693cdf0e10cSrcweir SwPosition aBefore(aTblIdx);
1694cdf0e10cSrcweir bParaBeforeInserted = GetDoc()->AppendTxtNode( aBefore );
1695cdf0e10cSrcweir aStartPam.DeleteMark();
1696cdf0e10cSrcweir *aStartPam.GetPoint() = aBefore;
1697cdf0e10cSrcweir pStartStartNode = aStartPam.GetNode()->StartOfSectionNode();
1698cdf0e10cSrcweir }
1699cdf0e10cSrcweir if (pEndStartNode->GetStartNodeType() == SwTableBoxStartNode)
1700cdf0e10cSrcweir {
1701cdf0e10cSrcweir SwTableNode *const pEndTableNode = pEndStartNode->FindTableNode();
1702cdf0e10cSrcweir SwEndNode *const pTableEnd = pEndTableNode->EndOfSectionNode();
1703cdf0e10cSrcweir SwPosition aTableEnd(*pTableEnd);
1704cdf0e10cSrcweir bParaAfterInserted = GetDoc()->AppendTxtNode( aTableEnd );
1705cdf0e10cSrcweir pEndPam->DeleteMark();
1706cdf0e10cSrcweir *pEndPam->GetPoint() = aTableEnd;
1707cdf0e10cSrcweir pEndStartNode = pEndPam->GetNode()->StartOfSectionNode();
1708cdf0e10cSrcweir }
1709cdf0e10cSrcweir // now we should have the positions in the same hierarchy
1710cdf0e10cSrcweir if ((pStartStartNode != pEndStartNode) ||
1711cdf0e10cSrcweir (pStartStartNode != GetStartNode()))
1712cdf0e10cSrcweir {
1713cdf0e10cSrcweir // if not - remove the additional paragraphs and throw
1714cdf0e10cSrcweir if (bParaBeforeInserted)
1715cdf0e10cSrcweir {
1716cdf0e10cSrcweir SwCursor aDelete(*aStartPam.GetPoint(), 0, false);
1717cdf0e10cSrcweir aDelete.MovePara(fnParaCurr, fnParaStart);
1718cdf0e10cSrcweir aDelete.SetMark();
1719cdf0e10cSrcweir aDelete.MovePara(fnParaCurr, fnParaEnd);
1720cdf0e10cSrcweir GetDoc()->DelFullPara(aDelete);
1721cdf0e10cSrcweir }
1722cdf0e10cSrcweir if (bParaAfterInserted)
1723cdf0e10cSrcweir {
1724cdf0e10cSrcweir SwCursor aDelete(*pEndPam->GetPoint(), 0, false);
1725cdf0e10cSrcweir aDelete.MovePara(fnParaCurr, fnParaStart);
1726cdf0e10cSrcweir aDelete.SetMark();
1727cdf0e10cSrcweir aDelete.MovePara(fnParaCurr, fnParaEnd);
1728cdf0e10cSrcweir GetDoc()->DelFullPara(aDelete);
1729cdf0e10cSrcweir }
1730cdf0e10cSrcweir throw lang::IllegalArgumentException();
1731cdf0e10cSrcweir }
1732cdf0e10cSrcweir }
1733cdf0e10cSrcweir
1734cdf0e10cSrcweir // make a selection from aStartPam to a EndPam
1735cdf0e10cSrcweir SwSelBoxes aBoxes;
1736cdf0e10cSrcweir SfxItemSet aFrameItemSet(m_pImpl->m_pDoc->GetAttrPool(),
1737cdf0e10cSrcweir RES_FRMATR_BEGIN, RES_FRMATR_END-1,
1738cdf0e10cSrcweir 0 );
1739cdf0e10cSrcweir
1740cdf0e10cSrcweir aStartPam.SetMark();
1741cdf0e10cSrcweir *aStartPam.End() = *pEndPam->End();
1742cdf0e10cSrcweir pEndPam.reset(0);
1743cdf0e10cSrcweir
1744cdf0e10cSrcweir SwXTextFrame *const pNewFrame = new SwXTextFrame(m_pImpl->m_pDoc);
1745cdf0e10cSrcweir const uno::Reference< text::XTextFrame > xNewFrame = pNewFrame;
1746cdf0e10cSrcweir pNewFrame->SetSelection( aStartPam );
1747cdf0e10cSrcweir try
1748cdf0e10cSrcweir {
1749cdf0e10cSrcweir const beans::PropertyValue* pValues = rFrameProperties.getConstArray();
1750cdf0e10cSrcweir for (sal_Int32 nProp = 0; nProp < rFrameProperties.getLength(); ++nProp)
1751cdf0e10cSrcweir {
1752cdf0e10cSrcweir pNewFrame->SwXFrame::setPropertyValue(
1753cdf0e10cSrcweir pValues[nProp].Name, pValues[nProp].Value);
1754cdf0e10cSrcweir }
1755cdf0e10cSrcweir
1756cdf0e10cSrcweir { // has to be in a block to remove the SwIndexes before
1757cdf0e10cSrcweir // DelFullPara is called
1758cdf0e10cSrcweir const uno::Reference< text::XTextRange> xInsertTextRange =
1759cdf0e10cSrcweir new SwXTextRange(aStartPam, this);
1760cdf0e10cSrcweir aStartPam.DeleteMark(); // mark position node may be deleted!
1761cdf0e10cSrcweir pNewFrame->attach( xInsertTextRange );
1762cdf0e10cSrcweir pNewFrame->setName(m_pImpl->m_pDoc->GetUniqueFrameName());
1763cdf0e10cSrcweir }
1764cdf0e10cSrcweir
1765cdf0e10cSrcweir SwTxtNode *const pTxtNode(aStartPam.GetNode()->GetTxtNode());
1766cdf0e10cSrcweir OSL_ASSERT(pTxtNode);
1767cdf0e10cSrcweir if (!pTxtNode || !pTxtNode->Len()) // don't remove if it contains text!
1768cdf0e10cSrcweir {
1769cdf0e10cSrcweir { // has to be in a block to remove the SwIndexes before
1770cdf0e10cSrcweir // DelFullPara is called
1771cdf0e10cSrcweir SwPaM aMovePam( *aStartPam.GetNode() );
1772cdf0e10cSrcweir if (aMovePam.Move( fnMoveForward, fnGoCntnt ))
1773cdf0e10cSrcweir {
1774cdf0e10cSrcweir // move the anchor to the next paragraph
1775cdf0e10cSrcweir SwFmtAnchor aNewAnchor(pNewFrame->GetFrmFmt()->GetAnchor());
1776cdf0e10cSrcweir aNewAnchor.SetAnchor( aMovePam.Start() );
1777cdf0e10cSrcweir m_pImpl->m_pDoc->SetAttr(
1778cdf0e10cSrcweir aNewAnchor, *pNewFrame->GetFrmFmt() );
1779cdf0e10cSrcweir }
1780cdf0e10cSrcweir }
1781cdf0e10cSrcweir m_pImpl->m_pDoc->DelFullPara(aStartPam);
1782cdf0e10cSrcweir }
1783cdf0e10cSrcweir }
1784cdf0e10cSrcweir catch (lang::IllegalArgumentException& rIllegal)
1785cdf0e10cSrcweir {
1786cdf0e10cSrcweir sMessage = rIllegal.Message;
1787cdf0e10cSrcweir bIllegalException = true;
1788cdf0e10cSrcweir }
1789cdf0e10cSrcweir catch (uno::RuntimeException& rRuntime)
1790cdf0e10cSrcweir {
1791cdf0e10cSrcweir sMessage = rRuntime.Message;
1792cdf0e10cSrcweir bRuntimeException = true;
1793cdf0e10cSrcweir }
1794cdf0e10cSrcweir xRet = pNewFrame;
1795cdf0e10cSrcweir if (bParaBeforeInserted || bParaAfterInserted)
1796cdf0e10cSrcweir {
1797cdf0e10cSrcweir const uno::Reference<text::XTextCursor> xFrameTextCursor =
1798cdf0e10cSrcweir pNewFrame->createTextCursor();
1799cdf0e10cSrcweir const uno::Reference<XUnoTunnel> xTunnel(xFrameTextCursor,
1800cdf0e10cSrcweir uno::UNO_QUERY);
1801cdf0e10cSrcweir SwXTextCursor *const pFrameCursor =
1802cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<SwXTextCursor>(xTunnel);
1803cdf0e10cSrcweir if (bParaBeforeInserted)
1804cdf0e10cSrcweir {
1805cdf0e10cSrcweir // todo: remove paragraph before frame
1806cdf0e10cSrcweir m_pImpl->m_pDoc->DelFullPara(*pFrameCursor->GetPaM());
1807cdf0e10cSrcweir }
1808cdf0e10cSrcweir if (bParaAfterInserted)
1809cdf0e10cSrcweir {
1810cdf0e10cSrcweir xFrameTextCursor->gotoEnd(sal_False);
1811cdf0e10cSrcweir m_pImpl->m_pDoc->DelFullPara(*pFrameCursor->GetPaM());
1812cdf0e10cSrcweir }
1813cdf0e10cSrcweir }
1814cdf0e10cSrcweir
1815cdf0e10cSrcweir m_pImpl->m_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_END, NULL);
1816cdf0e10cSrcweir if (bIllegalException || bRuntimeException)
1817cdf0e10cSrcweir {
1818cdf0e10cSrcweir m_pImpl->m_pDoc->GetIDocumentUndoRedo().Undo();
1819cdf0e10cSrcweir if (bIllegalException)
1820cdf0e10cSrcweir {
1821cdf0e10cSrcweir lang::IllegalArgumentException aEx;
1822cdf0e10cSrcweir aEx.Message = sMessage;
1823cdf0e10cSrcweir throw aEx;
1824cdf0e10cSrcweir }
1825cdf0e10cSrcweir else //if(bRuntimeException)
1826cdf0e10cSrcweir {
1827cdf0e10cSrcweir uno::RuntimeException aEx;
1828cdf0e10cSrcweir aEx.Message = sMessage;
1829cdf0e10cSrcweir throw aEx;
1830cdf0e10cSrcweir }
1831cdf0e10cSrcweir }
1832cdf0e10cSrcweir return xRet;
1833cdf0e10cSrcweir }
1834cdf0e10cSrcweir
1835cdf0e10cSrcweir /*-- 11.05.2006 15:46:26---------------------------------------------------
1836cdf0e10cSrcweir Move previously imported paragraphs into a new text table.
1837cdf0e10cSrcweir
1838cdf0e10cSrcweir -----------------------------------------------------------------------*/
1839cdf0e10cSrcweir struct VerticallyMergedCell
1840cdf0e10cSrcweir {
1841cdf0e10cSrcweir std::vector<uno::Reference< beans::XPropertySet > > aCells;
1842cdf0e10cSrcweir sal_Int32 nLeftPosition;
1843cdf0e10cSrcweir bool bOpen;
1844cdf0e10cSrcweir
VerticallyMergedCellVerticallyMergedCell1845cdf0e10cSrcweir VerticallyMergedCell(uno::Reference< beans::XPropertySet > const& rxCell,
1846cdf0e10cSrcweir const sal_Int32 nLeft)
1847cdf0e10cSrcweir : nLeftPosition( nLeft )
1848cdf0e10cSrcweir , bOpen( true )
1849cdf0e10cSrcweir {
1850cdf0e10cSrcweir aCells.push_back( rxCell );
1851cdf0e10cSrcweir }
1852cdf0e10cSrcweir };
1853cdf0e10cSrcweir #define COL_POS_FUZZY 2
lcl_SimilarPosition(const sal_Int32 nPos1,const sal_Int32 nPos2)1854cdf0e10cSrcweir static bool lcl_SimilarPosition( const sal_Int32 nPos1, const sal_Int32 nPos2 )
1855cdf0e10cSrcweir {
1856cdf0e10cSrcweir return abs( nPos1 - nPos2 ) < COL_POS_FUZZY;
1857cdf0e10cSrcweir }
1858cdf0e10cSrcweir
ConvertCell(const bool bFirstCell,const uno::Sequence<uno::Reference<text::XTextRange>> & rCell,::std::vector<SwNodeRange> & rRowNodes,::std::auto_ptr<SwPaM> & rpFirstPaM,SwPaM & rLastPaM,bool & rbExcept)1859cdf0e10cSrcweir void SwXText::Impl::ConvertCell(
1860cdf0e10cSrcweir const bool bFirstCell,
1861cdf0e10cSrcweir const uno::Sequence< uno::Reference< text::XTextRange > > & rCell,
1862cdf0e10cSrcweir ::std::vector<SwNodeRange> & rRowNodes,
1863cdf0e10cSrcweir ::std::auto_ptr< SwPaM > & rpFirstPaM,
1864cdf0e10cSrcweir SwPaM & rLastPaM,
1865cdf0e10cSrcweir bool & rbExcept)
1866cdf0e10cSrcweir {
1867cdf0e10cSrcweir if (rCell.getLength() != 2)
1868cdf0e10cSrcweir {
1869cdf0e10cSrcweir throw lang::IllegalArgumentException();
1870cdf0e10cSrcweir }
1871cdf0e10cSrcweir const uno::Reference<text::XTextRange> xStartRange = rCell[0];
1872cdf0e10cSrcweir const uno::Reference<text::XTextRange> xEndRange = rCell[1];
1873cdf0e10cSrcweir SwUnoInternalPaM aStartCellPam(*m_pDoc);
1874cdf0e10cSrcweir SwUnoInternalPaM aEndCellPam(*m_pDoc);
1875cdf0e10cSrcweir
1876cdf0e10cSrcweir // !!! TODO - PaMs in tables and sections do not work here -
1877cdf0e10cSrcweir // the same applies to PaMs in frames !!!
1878cdf0e10cSrcweir
1879cdf0e10cSrcweir if (!::sw::XTextRangeToSwPaM(aStartCellPam, xStartRange) ||
1880cdf0e10cSrcweir !::sw::XTextRangeToSwPaM(aEndCellPam, xEndRange))
1881cdf0e10cSrcweir {
1882cdf0e10cSrcweir throw lang::IllegalArgumentException();
1883cdf0e10cSrcweir }
1884cdf0e10cSrcweir
1885cdf0e10cSrcweir SwNodeRange aTmpRange(aStartCellPam.Start()->nNode,
1886cdf0e10cSrcweir aEndCellPam.End()->nNode);
1887cdf0e10cSrcweir SwNodeRange * pCorrectedRange =
1888cdf0e10cSrcweir m_pDoc->GetNodes().ExpandRangeForTableBox(aTmpRange);
1889cdf0e10cSrcweir
1890cdf0e10cSrcweir if (pCorrectedRange != NULL)
1891cdf0e10cSrcweir {
1892cdf0e10cSrcweir SwPaM aNewStartPaM(pCorrectedRange->aStart, 0);
1893cdf0e10cSrcweir aStartCellPam = aNewStartPaM;
1894cdf0e10cSrcweir
1895cdf0e10cSrcweir xub_StrLen nEndLen = 0;
1896cdf0e10cSrcweir SwTxtNode * pTxtNode = pCorrectedRange->aEnd.GetNode().GetTxtNode();
1897cdf0e10cSrcweir if (pTxtNode != NULL)
1898cdf0e10cSrcweir nEndLen = pTxtNode->Len();
1899cdf0e10cSrcweir
1900cdf0e10cSrcweir SwPaM aNewEndPaM(pCorrectedRange->aEnd, nEndLen);
1901cdf0e10cSrcweir aEndCellPam = aNewEndPaM;
1902cdf0e10cSrcweir }
1903cdf0e10cSrcweir
1904cdf0e10cSrcweir /** check the nodes between start and end
1905cdf0e10cSrcweir it is allowed to have pairs of StartNode/EndNodes
1906cdf0e10cSrcweir */
1907cdf0e10cSrcweir if (aStartCellPam.Start()->nNode < aEndCellPam.End()->nNode)
1908cdf0e10cSrcweir {
1909cdf0e10cSrcweir // increment on each StartNode and decrement on each EndNode
1910cdf0e10cSrcweir // we must reach zero at the end and must not go below zero
1911cdf0e10cSrcweir long nOpenNodeBlock = 0;
1912cdf0e10cSrcweir SwNodeIndex aCellIndex = aStartCellPam.Start()->nNode;
1913cdf0e10cSrcweir while (aCellIndex < aEndCellPam.End()->nNode.GetIndex())
1914cdf0e10cSrcweir {
1915cdf0e10cSrcweir if (aCellIndex.GetNode().IsStartNode())
1916cdf0e10cSrcweir {
1917cdf0e10cSrcweir ++nOpenNodeBlock;
1918cdf0e10cSrcweir }
1919cdf0e10cSrcweir else if (aCellIndex.GetNode().IsEndNode())
1920cdf0e10cSrcweir {
1921cdf0e10cSrcweir --nOpenNodeBlock;
1922cdf0e10cSrcweir }
1923cdf0e10cSrcweir if (nOpenNodeBlock < 0)
1924cdf0e10cSrcweir {
1925cdf0e10cSrcweir rbExcept = true;
1926cdf0e10cSrcweir break;
1927cdf0e10cSrcweir }
1928cdf0e10cSrcweir ++aCellIndex;
1929cdf0e10cSrcweir }
1930cdf0e10cSrcweir if (nOpenNodeBlock != 0)
1931cdf0e10cSrcweir {
1932cdf0e10cSrcweir rbExcept = true;
1933cdf0e10cSrcweir return;
1934cdf0e10cSrcweir }
1935cdf0e10cSrcweir }
1936cdf0e10cSrcweir
1937cdf0e10cSrcweir /** The vector<vector> NodeRanges has to contain consecutive nodes.
1938cdf0e10cSrcweir In rTableRanges the ranges don't need to be full paragraphs but
1939cdf0e10cSrcweir they have to follow each other. To process the ranges they
1940cdf0e10cSrcweir have to be aligned on paragraph borders by inserting paragraph
1941cdf0e10cSrcweir breaks. Non-consecutive ranges must initiate an exception.
1942cdf0e10cSrcweir */
1943cdf0e10cSrcweir if (bFirstCell)
1944cdf0e10cSrcweir {
1945cdf0e10cSrcweir // align the beginning - if necessary
1946cdf0e10cSrcweir if (aStartCellPam.Start()->nContent.GetIndex())
1947cdf0e10cSrcweir {
1948cdf0e10cSrcweir m_pDoc->SplitNode(*aStartCellPam.Start(), sal_False);
1949cdf0e10cSrcweir }
1950cdf0e10cSrcweir }
1951cdf0e10cSrcweir else
1952cdf0e10cSrcweir {
1953cdf0e10cSrcweir // check the predecessor
1954cdf0e10cSrcweir const sal_uLong nLastNodeIndex = rLastPaM.End()->nNode.GetIndex();
1955cdf0e10cSrcweir const sal_uLong nStartCellNodeIndex =
1956cdf0e10cSrcweir aStartCellPam.Start()->nNode.GetIndex();
1957cdf0e10cSrcweir const sal_uLong nLastNodeEndIndex = rLastPaM.End()->nNode.GetIndex();
1958cdf0e10cSrcweir if (nLastNodeIndex == nStartCellNodeIndex)
1959cdf0e10cSrcweir {
1960cdf0e10cSrcweir // same node as predecessor then equal nContent?
1961cdf0e10cSrcweir if (rLastPaM.End()->nContent != aStartCellPam.Start()->nContent)
1962cdf0e10cSrcweir {
1963cdf0e10cSrcweir rbExcept = true;
1964cdf0e10cSrcweir }
1965cdf0e10cSrcweir else
1966cdf0e10cSrcweir {
1967cdf0e10cSrcweir m_pDoc->SplitNode(*aStartCellPam.Start(), sal_False);
1968cdf0e10cSrcweir }
1969cdf0e10cSrcweir }
1970cdf0e10cSrcweir else if (nStartCellNodeIndex == (nLastNodeEndIndex + 1))
1971cdf0e10cSrcweir {
1972cdf0e10cSrcweir // next paragraph - now the content index of the new should be 0
1973cdf0e10cSrcweir // and of the old one should be equal to the text length
1974cdf0e10cSrcweir // but if it isn't we don't care - the cell is being inserted on
1975cdf0e10cSrcweir // the node border anyway
1976cdf0e10cSrcweir }
1977cdf0e10cSrcweir else
1978cdf0e10cSrcweir {
1979cdf0e10cSrcweir rbExcept = true;
1980cdf0e10cSrcweir }
1981cdf0e10cSrcweir }
1982cdf0e10cSrcweir // now check if there's a need to insert another paragraph break
1983cdf0e10cSrcweir if (aEndCellPam.End()->nContent.GetIndex() <
1984cdf0e10cSrcweir aEndCellPam.End()->nNode.GetNode().GetTxtNode()->Len())
1985cdf0e10cSrcweir {
1986cdf0e10cSrcweir m_pDoc->SplitNode(*aEndCellPam.End(), sal_False);
1987cdf0e10cSrcweir // take care that the new start/endcell is moved to the right position
1988cdf0e10cSrcweir // aStartCellPam has to point to the start of the new (previous) node
1989cdf0e10cSrcweir // aEndCellPam has to point to the end of the new (previous) node
1990cdf0e10cSrcweir aStartCellPam.DeleteMark();
1991cdf0e10cSrcweir aStartCellPam.Move(fnMoveBackward, fnGoNode);
1992cdf0e10cSrcweir aStartCellPam.GetPoint()->nContent = 0;
1993cdf0e10cSrcweir aEndCellPam.DeleteMark();
1994cdf0e10cSrcweir aEndCellPam.Move(fnMoveBackward, fnGoNode);
1995cdf0e10cSrcweir aEndCellPam.GetPoint()->nContent =
1996cdf0e10cSrcweir aEndCellPam.GetNode()->GetTxtNode()->Len();
1997cdf0e10cSrcweir }
1998cdf0e10cSrcweir
1999cdf0e10cSrcweir *rLastPaM.GetPoint() = *aEndCellPam.Start();
2000cdf0e10cSrcweir if (aStartCellPam.HasMark())
2001cdf0e10cSrcweir {
2002cdf0e10cSrcweir rLastPaM.SetMark();
2003cdf0e10cSrcweir *rLastPaM.GetMark() = *aEndCellPam.End();
2004cdf0e10cSrcweir }
2005cdf0e10cSrcweir else
2006cdf0e10cSrcweir {
2007cdf0e10cSrcweir rLastPaM.DeleteMark();
2008cdf0e10cSrcweir }
2009cdf0e10cSrcweir
2010cdf0e10cSrcweir SwNodeRange aCellRange(aStartCellPam.Start()->nNode,
2011cdf0e10cSrcweir aEndCellPam.End()->nNode);
2012cdf0e10cSrcweir rRowNodes.push_back(aCellRange);
2013cdf0e10cSrcweir if (bFirstCell)
2014cdf0e10cSrcweir {
2015cdf0e10cSrcweir rpFirstPaM.reset(new SwPaM(*aStartCellPam.Start()));
2016cdf0e10cSrcweir }
2017cdf0e10cSrcweir }
2018cdf0e10cSrcweir
2019cdf0e10cSrcweir typedef uno::Sequence< text::TableColumnSeparator > TableColumnSeparators;
2020cdf0e10cSrcweir
2021cdf0e10cSrcweir static void
lcl_ApplyRowProperties(uno::Sequence<beans::PropertyValue> const & rRowProperties,uno::Any const & rRow,TableColumnSeparators & rRowSeparators)2022cdf0e10cSrcweir lcl_ApplyRowProperties(
2023cdf0e10cSrcweir uno::Sequence<beans::PropertyValue> const& rRowProperties,
2024cdf0e10cSrcweir uno::Any const& rRow,
2025cdf0e10cSrcweir TableColumnSeparators & rRowSeparators)
2026cdf0e10cSrcweir {
2027cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xRow;
2028cdf0e10cSrcweir rRow >>= xRow;
2029cdf0e10cSrcweir const beans::PropertyValue* pProperties = rRowProperties.getConstArray();
2030cdf0e10cSrcweir for (sal_Int32 nProperty = 0; nProperty < rRowProperties.getLength();
2031cdf0e10cSrcweir ++nProperty)
2032cdf0e10cSrcweir {
2033cdf0e10cSrcweir if (pProperties[ nProperty ].Name.equalsAsciiL(
2034cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("TableColumnSeparators")))
2035cdf0e10cSrcweir {
2036cdf0e10cSrcweir // add the separators to access the cell's positions
2037cdf0e10cSrcweir // for vertical merging later
2038cdf0e10cSrcweir TableColumnSeparators aSeparators;
2039cdf0e10cSrcweir pProperties[ nProperty ].Value >>= aSeparators;
2040cdf0e10cSrcweir rRowSeparators = aSeparators;
2041cdf0e10cSrcweir }
2042cdf0e10cSrcweir xRow->setPropertyValue(
2043cdf0e10cSrcweir pProperties[ nProperty ].Name, pProperties[ nProperty ].Value);
2044cdf0e10cSrcweir }
2045cdf0e10cSrcweir }
2046cdf0e10cSrcweir
2047cdf0e10cSrcweir #ifdef DEBUG
2048cdf0e10cSrcweir //-->debug cell properties of all rows
2049cdf0e10cSrcweir static void
lcl_DebugCellProperties(const uno::Sequence<uno::Sequence<uno::Sequence<beans::PropertyValue>>> & rCellProperties)2050cdf0e10cSrcweir lcl_DebugCellProperties(
2051cdf0e10cSrcweir const uno::Sequence< uno::Sequence< uno::Sequence<
2052cdf0e10cSrcweir beans::PropertyValue > > >& rCellProperties)
2053cdf0e10cSrcweir {
2054cdf0e10cSrcweir ::rtl::OUString sNames;
2055cdf0e10cSrcweir for (sal_Int32 nDebugRow = 0; nDebugRow < rCellProperties.getLength();
2056cdf0e10cSrcweir ++nDebugRow)
2057cdf0e10cSrcweir {
2058cdf0e10cSrcweir const uno::Sequence< beans::PropertyValues > aDebugCurrentRow =
2059cdf0e10cSrcweir rCellProperties[nDebugRow];
2060cdf0e10cSrcweir sal_Int32 nDebugCells = aDebugCurrentRow.getLength();
2061cdf0e10cSrcweir (void) nDebugCells;
2062cdf0e10cSrcweir for (sal_Int32 nDebugCell = 0; nDebugCell < nDebugCells;
2063cdf0e10cSrcweir ++nDebugCell)
2064cdf0e10cSrcweir {
2065cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >&
2066cdf0e10cSrcweir rDebugCellProperties = aDebugCurrentRow[nDebugCell];
2067cdf0e10cSrcweir const sal_Int32 nDebugCellProperties =
2068cdf0e10cSrcweir rDebugCellProperties.getLength();
2069cdf0e10cSrcweir for (sal_Int32 nDebugProperty = 0;
2070cdf0e10cSrcweir nDebugProperty < nDebugCellProperties; ++nDebugProperty)
2071cdf0e10cSrcweir {
2072cdf0e10cSrcweir const ::rtl::OUString sName =
2073cdf0e10cSrcweir rDebugCellProperties[nDebugProperty].Name;
2074cdf0e10cSrcweir sNames += sName;
2075cdf0e10cSrcweir sNames += ::rtl::OUString('-');
2076cdf0e10cSrcweir }
2077cdf0e10cSrcweir sNames += ::rtl::OUString('+');
2078cdf0e10cSrcweir }
2079cdf0e10cSrcweir sNames += ::rtl::OUString('|');
2080cdf0e10cSrcweir }
2081cdf0e10cSrcweir (void)sNames;
2082cdf0e10cSrcweir }
2083cdf0e10cSrcweir //--<
2084cdf0e10cSrcweir #endif
2085cdf0e10cSrcweir
2086cdf0e10cSrcweir
2087cdf0e10cSrcweir static void
lcl_ApplyCellProperties(const sal_Int32 nCell,TableColumnSeparators const & rRowSeparators,const uno::Sequence<beans::PropertyValue> & rCellProperties,uno::Reference<uno::XInterface> xCell,::std::vector<VerticallyMergedCell> & rMergedCells)2088cdf0e10cSrcweir lcl_ApplyCellProperties(
2089cdf0e10cSrcweir const sal_Int32 nCell,
2090cdf0e10cSrcweir TableColumnSeparators const& rRowSeparators,
2091cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >& rCellProperties,
2092cdf0e10cSrcweir uno::Reference< uno::XInterface > xCell,
2093cdf0e10cSrcweir ::std::vector<VerticallyMergedCell> & rMergedCells)
2094cdf0e10cSrcweir {
2095cdf0e10cSrcweir const sal_Int32 nCellProperties = rCellProperties.getLength();
2096cdf0e10cSrcweir const uno::Reference< beans::XPropertySet > xCellPS(xCell, uno::UNO_QUERY);
2097cdf0e10cSrcweir for (sal_Int32 nProperty = 0; nProperty < nCellProperties; ++nProperty)
2098cdf0e10cSrcweir {
2099cdf0e10cSrcweir const OUString & rName = rCellProperties[nProperty].Name;
2100cdf0e10cSrcweir const uno::Any & rValue = rCellProperties[nProperty].Value;
2101cdf0e10cSrcweir if (rName.equalsAscii("VerticalMerge"))
2102cdf0e10cSrcweir {
2103cdf0e10cSrcweir // determine left border position
2104cdf0e10cSrcweir // add the cell to a queue of merged cells
2105cdf0e10cSrcweir sal_Bool bMerge = sal_False;
2106cdf0e10cSrcweir rValue >>= bMerge;
2107cdf0e10cSrcweir sal_Int32 nLeftPos = -1;
2108cdf0e10cSrcweir if (!nCell)
2109cdf0e10cSrcweir {
2110cdf0e10cSrcweir nLeftPos = 0;
2111cdf0e10cSrcweir }
2112cdf0e10cSrcweir else if (rRowSeparators.getLength() >= nCell)
2113cdf0e10cSrcweir {
2114cdf0e10cSrcweir const text::TableColumnSeparator* pSeparators =
2115cdf0e10cSrcweir rRowSeparators.getConstArray();
2116cdf0e10cSrcweir nLeftPos = pSeparators[nCell - 1].Position;
2117cdf0e10cSrcweir }
2118cdf0e10cSrcweir if (bMerge)
2119cdf0e10cSrcweir {
2120cdf0e10cSrcweir // 'close' all the cell with the same left position
2121cdf0e10cSrcweir // if separate vertical merges in the same column exist
2122cdf0e10cSrcweir if (rMergedCells.size())
2123cdf0e10cSrcweir {
2124cdf0e10cSrcweir std::vector<VerticallyMergedCell>::iterator aMergedIter =
2125cdf0e10cSrcweir rMergedCells.begin();
2126cdf0e10cSrcweir while (aMergedIter != rMergedCells.end())
2127cdf0e10cSrcweir {
2128cdf0e10cSrcweir if (lcl_SimilarPosition(aMergedIter->nLeftPosition,
2129cdf0e10cSrcweir nLeftPos))
2130cdf0e10cSrcweir {
2131cdf0e10cSrcweir aMergedIter->bOpen = false;
2132cdf0e10cSrcweir }
2133cdf0e10cSrcweir ++aMergedIter;
2134cdf0e10cSrcweir }
2135cdf0e10cSrcweir }
2136cdf0e10cSrcweir // add the new group of merged cells
2137cdf0e10cSrcweir rMergedCells.push_back(VerticallyMergedCell(xCellPS, nLeftPos));
2138cdf0e10cSrcweir }
2139cdf0e10cSrcweir else
2140cdf0e10cSrcweir {
2141cdf0e10cSrcweir // find the cell that
2142cdf0e10cSrcweir DBG_ASSERT(rMergedCells.size(),
2143cdf0e10cSrcweir "the first merged cell is missing");
2144cdf0e10cSrcweir if (rMergedCells.size())
2145cdf0e10cSrcweir {
2146cdf0e10cSrcweir std::vector<VerticallyMergedCell>::iterator aMergedIter =
2147cdf0e10cSrcweir rMergedCells.begin();
2148cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
2149cdf0e10cSrcweir bool bDbgFound = false;
2150cdf0e10cSrcweir #endif
2151cdf0e10cSrcweir while (aMergedIter != rMergedCells.end())
2152cdf0e10cSrcweir {
2153cdf0e10cSrcweir if (aMergedIter->bOpen &&
2154cdf0e10cSrcweir lcl_SimilarPosition(aMergedIter->nLeftPosition,
2155cdf0e10cSrcweir nLeftPos))
2156cdf0e10cSrcweir {
2157cdf0e10cSrcweir aMergedIter->aCells.push_back( xCellPS );
2158cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
2159cdf0e10cSrcweir bDbgFound = true;
2160cdf0e10cSrcweir #endif
2161cdf0e10cSrcweir }
2162cdf0e10cSrcweir ++aMergedIter;
2163cdf0e10cSrcweir }
2164cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
2165cdf0e10cSrcweir DBG_ASSERT( bDbgFound,
2166cdf0e10cSrcweir "couldn't find first vertically merged cell" );
2167cdf0e10cSrcweir #endif
2168cdf0e10cSrcweir }
2169cdf0e10cSrcweir }
2170cdf0e10cSrcweir }
2171cdf0e10cSrcweir else
2172cdf0e10cSrcweir {
2173cdf0e10cSrcweir try
2174cdf0e10cSrcweir {
2175cdf0e10cSrcweir xCellPS->setPropertyValue(rName, rValue);
2176cdf0e10cSrcweir }
2177c0286415SOliver-Rainer Wittmann catch (uno::Exception const& )
2178cdf0e10cSrcweir {
2179cdf0e10cSrcweir // Apply the paragraph and char properties to the cell's content
2180cdf0e10cSrcweir const uno::Reference< text::XText > xCellText(xCell,
2181cdf0e10cSrcweir uno::UNO_QUERY);
2182cdf0e10cSrcweir const uno::Reference< text::XTextCursor > xCellCurs =
2183cdf0e10cSrcweir xCellText->createTextCursor();
2184cdf0e10cSrcweir xCellCurs->gotoStart( sal_False );
2185cdf0e10cSrcweir xCellCurs->gotoEnd( sal_True );
218607f29ca7SJian Fang Zhang const uno::Reference< beans::XPropertyState >
218707f29ca7SJian Fang Zhang xCellTextPropState(xCellCurs, uno::UNO_QUERY);
218807f29ca7SJian Fang Zhang const beans::PropertyState state = xCellTextPropState->getPropertyState(rName);
218907f29ca7SJian Fang Zhang if (state == beans::PropertyState_DEFAULT_VALUE)
219007f29ca7SJian Fang Zhang {
219107f29ca7SJian Fang Zhang const uno::Reference< beans::XPropertySet >
219207f29ca7SJian Fang Zhang xCellTextProps(xCellCurs, uno::UNO_QUERY);
2193cdf0e10cSrcweir xCellTextProps->setPropertyValue(rName, rValue);
2194cdf0e10cSrcweir }
2195cdf0e10cSrcweir }
2196cdf0e10cSrcweir }
2197cdf0e10cSrcweir }
219807f29ca7SJian Fang Zhang }
2199cdf0e10cSrcweir
2200cdf0e10cSrcweir static void
lcl_MergeCells(::std::vector<VerticallyMergedCell> & rMergedCells)2201cdf0e10cSrcweir lcl_MergeCells(::std::vector<VerticallyMergedCell> & rMergedCells)
2202cdf0e10cSrcweir {
2203cdf0e10cSrcweir if (rMergedCells.size())
2204cdf0e10cSrcweir {
2205cdf0e10cSrcweir std::vector<VerticallyMergedCell>::iterator aMergedIter =
2206cdf0e10cSrcweir rMergedCells.begin();
2207cdf0e10cSrcweir while (aMergedIter != rMergedCells.end())
2208cdf0e10cSrcweir {
2209cdf0e10cSrcweir sal_Int32 nCellCount =
2210cdf0e10cSrcweir static_cast<sal_Int32>(aMergedIter->aCells.size());
2211cdf0e10cSrcweir std::vector<uno::Reference< beans::XPropertySet > >::iterator
2212cdf0e10cSrcweir aCellIter = aMergedIter->aCells.begin();
2213cdf0e10cSrcweir bool bFirstCell = true;
2214cdf0e10cSrcweir // the first of the cells gets the number of cells set as RowSpan
2215cdf0e10cSrcweir // the others get the inverted number of remaining merged cells
2216cdf0e10cSrcweir // (3,-2,-1)
2217cdf0e10cSrcweir while (aCellIter != aMergedIter->aCells.end())
2218cdf0e10cSrcweir {
2219cdf0e10cSrcweir (*aCellIter)->setPropertyValue(
2220cdf0e10cSrcweir C2U(SW_PROP_NAME_STR(UNO_NAME_ROW_SPAN)),
2221cdf0e10cSrcweir uno::makeAny(nCellCount));
2222cdf0e10cSrcweir if (bFirstCell)
2223cdf0e10cSrcweir {
2224cdf0e10cSrcweir nCellCount *= -1;
2225cdf0e10cSrcweir bFirstCell = false;
2226cdf0e10cSrcweir }
2227cdf0e10cSrcweir ++nCellCount;
2228cdf0e10cSrcweir ++aCellIter;
2229cdf0e10cSrcweir }
2230cdf0e10cSrcweir ++aMergedIter;
2231cdf0e10cSrcweir }
2232cdf0e10cSrcweir }
2233cdf0e10cSrcweir }
2234cdf0e10cSrcweir
2235cdf0e10cSrcweir uno::Reference< text::XTextTable > SAL_CALL
convertToTable(const uno::Sequence<uno::Sequence<uno::Sequence<uno::Reference<text::XTextRange>>>> & rTableRanges,const uno::Sequence<uno::Sequence<uno::Sequence<beans::PropertyValue>>> & rCellProperties,const uno::Sequence<uno::Sequence<beans::PropertyValue>> & rRowProperties,const uno::Sequence<beans::PropertyValue> & rTableProperties)2236cdf0e10cSrcweir SwXText::convertToTable(
2237cdf0e10cSrcweir const uno::Sequence< uno::Sequence< uno::Sequence<
2238cdf0e10cSrcweir uno::Reference< text::XTextRange > > > >& rTableRanges,
2239cdf0e10cSrcweir const uno::Sequence< uno::Sequence< uno::Sequence<
2240cdf0e10cSrcweir beans::PropertyValue > > >& rCellProperties,
2241cdf0e10cSrcweir const uno::Sequence< uno::Sequence< beans::PropertyValue > >&
2242cdf0e10cSrcweir rRowProperties,
2243cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >& rTableProperties)
2244cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException)
2245cdf0e10cSrcweir {
2246cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
2247cdf0e10cSrcweir
2248cdf0e10cSrcweir if(!IsValid())
2249cdf0e10cSrcweir {
2250cdf0e10cSrcweir throw uno::RuntimeException();
2251cdf0e10cSrcweir }
2252cdf0e10cSrcweir
2253cdf0e10cSrcweir //at first collect the text ranges as SwPaMs
2254cdf0e10cSrcweir const uno::Sequence< uno::Sequence< uno::Reference< text::XTextRange > > >*
2255cdf0e10cSrcweir pTableRanges = rTableRanges.getConstArray();
2256cdf0e10cSrcweir std::auto_ptr < SwPaM > pFirstPaM;
2257cdf0e10cSrcweir std::vector< std::vector<SwNodeRange> > aTableNodes;
2258cdf0e10cSrcweir bool bExcept = false;
2259cdf0e10cSrcweir SwPaM aLastPaM(m_pImpl->m_pDoc->GetNodes());
2260cdf0e10cSrcweir for (sal_Int32 nRow = 0; !bExcept && (nRow < rTableRanges.getLength());
2261cdf0e10cSrcweir ++nRow)
2262cdf0e10cSrcweir {
2263cdf0e10cSrcweir std::vector<SwNodeRange> aRowNodes;
2264cdf0e10cSrcweir const uno::Sequence< uno::Reference< text::XTextRange > >* pRow =
2265cdf0e10cSrcweir pTableRanges[nRow].getConstArray();
2266cdf0e10cSrcweir const sal_Int32 nCells(pTableRanges[nRow].getLength());
2267cdf0e10cSrcweir
2268cdf0e10cSrcweir for (sal_Int32 nCell = 0; nCell < nCells; ++nCell)
2269cdf0e10cSrcweir {
2270cdf0e10cSrcweir m_pImpl->ConvertCell((nCell == 0) && (nRow == 0), pRow[nCell],
2271cdf0e10cSrcweir aRowNodes, pFirstPaM, aLastPaM, bExcept);
2272cdf0e10cSrcweir }
2273cdf0e10cSrcweir aTableNodes.push_back(aRowNodes);
2274cdf0e10cSrcweir }
2275cdf0e10cSrcweir
2276cdf0e10cSrcweir if(bExcept)
2277cdf0e10cSrcweir {
2278cdf0e10cSrcweir m_pImpl->m_pDoc->GetIDocumentUndoRedo().Undo();
2279cdf0e10cSrcweir throw lang::IllegalArgumentException();
2280cdf0e10cSrcweir }
2281cdf0e10cSrcweir
2282cdf0e10cSrcweir std::vector< TableColumnSeparators >
2283cdf0e10cSrcweir aRowSeparators(rRowProperties.getLength());
2284cdf0e10cSrcweir std::vector<VerticallyMergedCell> aMergedCells;
2285cdf0e10cSrcweir
2286cdf0e10cSrcweir SwTable const*const pTable = m_pImpl->m_pDoc->TextToTable( aTableNodes );
2287cdf0e10cSrcweir SwXTextTable *const pTextTable = new SwXTextTable( *pTable->GetFrmFmt() );
2288cdf0e10cSrcweir const uno::Reference< text::XTextTable > xRet = pTextTable;
2289cdf0e10cSrcweir const uno::Reference< beans::XPropertySet > xPrSet = pTextTable;
2290cdf0e10cSrcweir // set properties to the table
2291cdf0e10cSrcweir // catch lang::WrappedTargetException and lang::IndexOutOfBoundsException
2292cdf0e10cSrcweir try
2293cdf0e10cSrcweir {
2294cdf0e10cSrcweir //apply table properties
2295cdf0e10cSrcweir const beans::PropertyValue* pTableProperties =
2296cdf0e10cSrcweir rTableProperties.getConstArray();
2297cdf0e10cSrcweir for (sal_Int32 nProperty = 0; nProperty < rTableProperties.getLength();
2298cdf0e10cSrcweir ++nProperty)
2299cdf0e10cSrcweir {
2300cdf0e10cSrcweir try
2301cdf0e10cSrcweir {
2302cdf0e10cSrcweir xPrSet->setPropertyValue( pTableProperties[nProperty].Name,
2303cdf0e10cSrcweir pTableProperties[nProperty].Value );
2304cdf0e10cSrcweir }
2305cdf0e10cSrcweir catch ( uno::Exception const& e )
2306cdf0e10cSrcweir {
2307cdf0e10cSrcweir #if DEBUG
2308cdf0e10cSrcweir std::clog << "Exception when setting property: ";
2309cdf0e10cSrcweir std::clog << rtl::OUStringToOString(
2310cdf0e10cSrcweir pTableProperties[nProperty].Name, RTL_TEXTENCODING_UTF8)
2311cdf0e10cSrcweir .getStr();
2312cdf0e10cSrcweir std::clog << ". Message: ";
2313cdf0e10cSrcweir std::clog << rtl::OUStringToOString( e.Message,
2314cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 ).getStr();
2315cdf0e10cSrcweir std::clog << std::endl;
2316cdf0e10cSrcweir #endif
2317cdf0e10cSrcweir }
2318cdf0e10cSrcweir }
2319cdf0e10cSrcweir
2320cdf0e10cSrcweir //apply row properties
2321cdf0e10cSrcweir const uno::Reference< table::XTableRows > xRows = xRet->getRows();
2322cdf0e10cSrcweir
2323cdf0e10cSrcweir const beans::PropertyValues* pRowProperties =
2324cdf0e10cSrcweir rRowProperties.getConstArray();
2325cdf0e10cSrcweir for (sal_Int32 nRow = 0; nRow < xRows->getCount(); ++nRow)
2326cdf0e10cSrcweir {
2327cdf0e10cSrcweir if( nRow >= rRowProperties.getLength())
2328cdf0e10cSrcweir {
2329cdf0e10cSrcweir break;
2330cdf0e10cSrcweir }
2331cdf0e10cSrcweir lcl_ApplyRowProperties(pRowProperties[nRow],
2332cdf0e10cSrcweir xRows->getByIndex(nRow), aRowSeparators[nRow]);
2333cdf0e10cSrcweir }
2334cdf0e10cSrcweir
2335cdf0e10cSrcweir #ifdef DEBUG
2336cdf0e10cSrcweir lcl_DebugCellProperties(rCellProperties);
2337cdf0e10cSrcweir #endif
2338cdf0e10cSrcweir
2339cdf0e10cSrcweir //apply cell properties
2340cdf0e10cSrcweir for (sal_Int32 nRow = 0; nRow < rCellProperties.getLength(); ++nRow)
2341cdf0e10cSrcweir {
2342cdf0e10cSrcweir const uno::Sequence< beans::PropertyValues > aCurrentRow =
2343cdf0e10cSrcweir rCellProperties[nRow];
2344cdf0e10cSrcweir sal_Int32 nCells = aCurrentRow.getLength();
2345cdf0e10cSrcweir for (sal_Int32 nCell = 0; nCell < nCells; ++nCell)
2346cdf0e10cSrcweir {
2347cdf0e10cSrcweir lcl_ApplyCellProperties(nCell,
2348cdf0e10cSrcweir aRowSeparators[nRow], aCurrentRow[nCell],
2349cdf0e10cSrcweir pTextTable->getCellByPosition(nCell, nRow),
2350cdf0e10cSrcweir aMergedCells);
2351cdf0e10cSrcweir }
2352cdf0e10cSrcweir }
2353cdf0e10cSrcweir // now that the cell properties are set the vertical merge values
2354cdf0e10cSrcweir // have to be applied
2355cdf0e10cSrcweir lcl_MergeCells(aMergedCells);
2356cdf0e10cSrcweir }
2357cdf0e10cSrcweir catch( const lang::WrappedTargetException& rWrapped )
2358cdf0e10cSrcweir {
2359cdf0e10cSrcweir (void)rWrapped;
2360cdf0e10cSrcweir }
2361cdf0e10cSrcweir catch ( const lang::IndexOutOfBoundsException& rBounds )
2362cdf0e10cSrcweir {
2363cdf0e10cSrcweir (void)rBounds;
2364cdf0e10cSrcweir }
2365cdf0e10cSrcweir
2366cdf0e10cSrcweir return xRet;
2367cdf0e10cSrcweir }
2368cdf0e10cSrcweir
2369cdf0e10cSrcweir
2370cdf0e10cSrcweir void SAL_CALL
copyText(const uno::Reference<text::XTextCopy> & xSource)2371cdf0e10cSrcweir SwXText::copyText(
2372cdf0e10cSrcweir const uno::Reference< text::XTextCopy >& xSource )
2373cdf0e10cSrcweir throw (uno::RuntimeException)
2374cdf0e10cSrcweir {
2375cdf0e10cSrcweir vos::OGuard g(Application::GetSolarMutex());
2376cdf0e10cSrcweir
2377cdf0e10cSrcweir uno::Reference< text::XText > const xText(xSource, uno::UNO_QUERY_THROW);
2378cdf0e10cSrcweir uno::Reference< text::XTextCursor > const xCursor =
2379cdf0e10cSrcweir xText->createTextCursor();
2380cdf0e10cSrcweir xCursor->gotoEnd( sal_True );
2381cdf0e10cSrcweir
2382cdf0e10cSrcweir uno::Reference< lang::XUnoTunnel > const xCursorTunnel(xCursor,
2383cdf0e10cSrcweir uno::UNO_QUERY_THROW);
2384cdf0e10cSrcweir
2385cdf0e10cSrcweir OTextCursorHelper *const pCursor =
2386cdf0e10cSrcweir ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xCursorTunnel);
2387cdf0e10cSrcweir if (!pCursor)
2388cdf0e10cSrcweir {
2389cdf0e10cSrcweir throw uno::RuntimeException();
2390cdf0e10cSrcweir }
2391cdf0e10cSrcweir
2392cdf0e10cSrcweir SwNodeIndex rNdIndex( *GetStartNode( ), 1 );
2393cdf0e10cSrcweir SwPosition rPos( rNdIndex );
2394cdf0e10cSrcweir m_pImpl->m_pDoc->CopyRange( *pCursor->GetPaM(), rPos, false );
2395cdf0e10cSrcweir }
2396cdf0e10cSrcweir
2397cdf0e10cSrcweir
2398cdf0e10cSrcweir /******************************************************************
2399cdf0e10cSrcweir * SwXBodyText
2400cdf0e10cSrcweir ******************************************************************/
SwXBodyText(SwDoc * const pDoc)2401cdf0e10cSrcweir SwXBodyText::SwXBodyText(SwDoc *const pDoc)
2402cdf0e10cSrcweir : SwXText(pDoc, CURSOR_BODY)
2403cdf0e10cSrcweir {
2404cdf0e10cSrcweir }
2405cdf0e10cSrcweir
2406cdf0e10cSrcweir /*-- 10.12.98 11:17:27---------------------------------------------------
2407cdf0e10cSrcweir
2408cdf0e10cSrcweir -----------------------------------------------------------------------*/
~SwXBodyText()2409cdf0e10cSrcweir SwXBodyText::~SwXBodyText()
2410cdf0e10cSrcweir {
2411cdf0e10cSrcweir
2412cdf0e10cSrcweir }
2413cdf0e10cSrcweir /* -----------------------------06.04.00 16:33--------------------------------
2414cdf0e10cSrcweir
2415cdf0e10cSrcweir ---------------------------------------------------------------------------*/
2416cdf0e10cSrcweir OUString SAL_CALL
getImplementationName()2417cdf0e10cSrcweir SwXBodyText::getImplementationName() throw (uno::RuntimeException)
2418cdf0e10cSrcweir {
2419cdf0e10cSrcweir return C2U("SwXBodyText");
2420cdf0e10cSrcweir }
2421cdf0e10cSrcweir /* -----------------------------06.04.00 16:33--------------------------------
2422cdf0e10cSrcweir
2423cdf0e10cSrcweir ---------------------------------------------------------------------------*/
2424cdf0e10cSrcweir static char const*const g_ServicesBodyText[] =
2425cdf0e10cSrcweir {
2426cdf0e10cSrcweir "com.sun.star.text.Text",
2427cdf0e10cSrcweir };
2428cdf0e10cSrcweir static const size_t g_nServicesBodyText(
2429cdf0e10cSrcweir sizeof(g_ServicesBodyText)/sizeof(g_ServicesBodyText[0]));
2430cdf0e10cSrcweir
supportsService(const OUString & rServiceName)2431cdf0e10cSrcweir sal_Bool SAL_CALL SwXBodyText::supportsService(const OUString& rServiceName)
2432cdf0e10cSrcweir throw (uno::RuntimeException)
2433cdf0e10cSrcweir {
2434cdf0e10cSrcweir return ::sw::SupportsServiceImpl(
2435cdf0e10cSrcweir g_nServicesBodyText, g_ServicesBodyText, rServiceName);
2436cdf0e10cSrcweir }
2437cdf0e10cSrcweir
2438cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames()2439cdf0e10cSrcweir SwXBodyText::getSupportedServiceNames() throw (uno::RuntimeException)
2440cdf0e10cSrcweir {
2441cdf0e10cSrcweir return ::sw::GetSupportedServiceNamesImpl(
2442cdf0e10cSrcweir g_nServicesBodyText, g_ServicesBodyText);
2443cdf0e10cSrcweir }
2444cdf0e10cSrcweir
2445cdf0e10cSrcweir /*-- 10.12.98 11:17:27---------------------------------------------------
2446cdf0e10cSrcweir
2447cdf0e10cSrcweir -----------------------------------------------------------------------*/
2448cdf0e10cSrcweir uno::Any SAL_CALL
queryAggregation(const uno::Type & rType)2449cdf0e10cSrcweir SwXBodyText::queryAggregation(const uno::Type& rType)
2450cdf0e10cSrcweir throw (uno::RuntimeException)
2451cdf0e10cSrcweir {
2452cdf0e10cSrcweir uno::Any aRet;
2453cdf0e10cSrcweir if (rType == container::XEnumerationAccess::static_type())
2454cdf0e10cSrcweir {
2455cdf0e10cSrcweir aRet <<= uno::Reference< container::XEnumerationAccess >(this);
2456cdf0e10cSrcweir }
2457cdf0e10cSrcweir else if (rType == container::XElementAccess::static_type())
2458cdf0e10cSrcweir {
2459cdf0e10cSrcweir aRet <<= uno::Reference< container::XElementAccess >(this);
2460cdf0e10cSrcweir }
2461cdf0e10cSrcweir else if (rType == lang::XServiceInfo::static_type())
2462cdf0e10cSrcweir {
2463cdf0e10cSrcweir aRet <<= uno::Reference< lang::XServiceInfo >(this);
2464cdf0e10cSrcweir }
2465cdf0e10cSrcweir else
2466cdf0e10cSrcweir {
2467cdf0e10cSrcweir aRet = SwXText::queryInterface( rType );
2468cdf0e10cSrcweir }
2469cdf0e10cSrcweir if(aRet.getValueType() == ::getCppuVoidType())
2470cdf0e10cSrcweir {
2471cdf0e10cSrcweir aRet = OWeakAggObject::queryAggregation( rType );
2472cdf0e10cSrcweir }
2473cdf0e10cSrcweir return aRet;
2474cdf0e10cSrcweir }
2475cdf0e10cSrcweir
2476cdf0e10cSrcweir /*-- 10.12.98 11:17:28---------------------------------------------------
2477cdf0e10cSrcweir
2478cdf0e10cSrcweir -----------------------------------------------------------------------*/
2479cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL
getTypes()2480cdf0e10cSrcweir SwXBodyText::getTypes() throw (uno::RuntimeException)
2481cdf0e10cSrcweir {
2482cdf0e10cSrcweir const uno::Sequence< uno::Type > aTypes = SwXBodyText_Base::getTypes();
2483cdf0e10cSrcweir const uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes();
2484cdf0e10cSrcweir return ::comphelper::concatSequences(aTypes, aTextTypes);
2485cdf0e10cSrcweir }
2486cdf0e10cSrcweir /* -----------------------------21.03.00 15:39--------------------------------
2487cdf0e10cSrcweir
2488cdf0e10cSrcweir ---------------------------------------------------------------------------*/
2489cdf0e10cSrcweir uno::Sequence< sal_Int8 > SAL_CALL
getImplementationId()2490cdf0e10cSrcweir SwXBodyText::getImplementationId() throw (uno::RuntimeException)
2491cdf0e10cSrcweir {
2492cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
2493cdf0e10cSrcweir static uno::Sequence< sal_Int8 > aId( 16 );
2494cdf0e10cSrcweir static sal_Bool bInit = sal_False;
2495cdf0e10cSrcweir if(!bInit)
2496cdf0e10cSrcweir {
2497cdf0e10cSrcweir rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
2498cdf0e10cSrcweir bInit = sal_True;
2499cdf0e10cSrcweir }
2500cdf0e10cSrcweir return aId;
2501cdf0e10cSrcweir }
2502cdf0e10cSrcweir /*-- 10.12.98 11:17:28---------------------------------------------------
2503cdf0e10cSrcweir
2504cdf0e10cSrcweir -----------------------------------------------------------------------*/
2505cdf0e10cSrcweir uno::Any SAL_CALL
queryInterface(const uno::Type & rType)2506cdf0e10cSrcweir SwXBodyText::queryInterface(const uno::Type& rType)
2507cdf0e10cSrcweir throw (uno::RuntimeException)
2508cdf0e10cSrcweir {
2509cdf0e10cSrcweir const uno::Any ret = SwXText::queryInterface(rType);
2510cdf0e10cSrcweir return (ret.getValueType() == ::getCppuVoidType())
2511cdf0e10cSrcweir ? SwXBodyText_Base::queryInterface(rType)
2512cdf0e10cSrcweir : ret;
2513cdf0e10cSrcweir }
2514cdf0e10cSrcweir /* -----------------------------05.01.00 11:07--------------------------------
2515cdf0e10cSrcweir
2516cdf0e10cSrcweir ---------------------------------------------------------------------------*/
CreateTextCursor(const bool bIgnoreTables)2517cdf0e10cSrcweir SwXTextCursor * SwXBodyText::CreateTextCursor(const bool bIgnoreTables)
2518cdf0e10cSrcweir {
2519cdf0e10cSrcweir if(!IsValid())
2520cdf0e10cSrcweir {
2521cdf0e10cSrcweir return 0;
2522cdf0e10cSrcweir }
2523cdf0e10cSrcweir
2524cdf0e10cSrcweir // the cursor has to skip tables contained in this text
2525cdf0e10cSrcweir SwPaM aPam(GetDoc()->GetNodes().GetEndOfContent());
2526cdf0e10cSrcweir aPam.Move( fnMoveBackward, fnGoDoc );
2527cdf0e10cSrcweir if (!bIgnoreTables)
2528cdf0e10cSrcweir {
2529cdf0e10cSrcweir SwTableNode * pTblNode = aPam.GetNode()->FindTableNode();
2530cdf0e10cSrcweir SwCntntNode * pCont = 0;
2531cdf0e10cSrcweir while (pTblNode)
2532cdf0e10cSrcweir {
2533cdf0e10cSrcweir aPam.GetPoint()->nNode = *pTblNode->EndOfSectionNode();
2534cdf0e10cSrcweir pCont = GetDoc()->GetNodes().GoNext(&aPam.GetPoint()->nNode);
2535cdf0e10cSrcweir pTblNode = pCont->FindTableNode();
2536cdf0e10cSrcweir }
2537cdf0e10cSrcweir if (pCont)
2538cdf0e10cSrcweir {
2539cdf0e10cSrcweir aPam.GetPoint()->nContent.Assign(pCont, 0);
2540cdf0e10cSrcweir }
2541cdf0e10cSrcweir }
2542cdf0e10cSrcweir return new SwXTextCursor(*GetDoc(), this, CURSOR_BODY, *aPam.GetPoint());
2543cdf0e10cSrcweir }
2544cdf0e10cSrcweir
2545cdf0e10cSrcweir /*-- 10.12.98 11:17:29---------------------------------------------------
2546cdf0e10cSrcweir
2547cdf0e10cSrcweir -----------------------------------------------------------------------*/
2548cdf0e10cSrcweir uno::Reference< text::XTextCursor > SAL_CALL
createTextCursor()2549cdf0e10cSrcweir SwXBodyText::createTextCursor() throw (uno::RuntimeException)
2550cdf0e10cSrcweir {
2551cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
2552cdf0e10cSrcweir
2553cdf0e10cSrcweir const uno::Reference< text::XTextCursor > xRef(
2554cdf0e10cSrcweir static_cast<text::XWordCursor*>(CreateTextCursor(false)) );
2555cdf0e10cSrcweir if (!xRef.is())
2556cdf0e10cSrcweir {
2557cdf0e10cSrcweir uno::RuntimeException aRuntime;
2558cdf0e10cSrcweir aRuntime.Message = C2U(cInvalidObject);
2559cdf0e10cSrcweir throw aRuntime;
2560cdf0e10cSrcweir }
2561cdf0e10cSrcweir return xRef;
2562cdf0e10cSrcweir }
2563cdf0e10cSrcweir /*-- 10.12.98 11:17:29---------------------------------------------------
2564cdf0e10cSrcweir
2565cdf0e10cSrcweir -----------------------------------------------------------------------*/
2566cdf0e10cSrcweir uno::Reference< text::XTextCursor > SAL_CALL
createTextCursorByRange(const uno::Reference<text::XTextRange> & xTextPosition)2567cdf0e10cSrcweir SwXBodyText::createTextCursorByRange(
2568cdf0e10cSrcweir const uno::Reference< text::XTextRange > & xTextPosition)
2569cdf0e10cSrcweir throw (uno::RuntimeException)
2570cdf0e10cSrcweir {
2571cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
2572cdf0e10cSrcweir
2573cdf0e10cSrcweir if(!IsValid())
2574cdf0e10cSrcweir {
2575cdf0e10cSrcweir uno::RuntimeException aRuntime;
2576cdf0e10cSrcweir aRuntime.Message = C2U(cInvalidObject);
2577cdf0e10cSrcweir throw aRuntime;
2578cdf0e10cSrcweir }
2579cdf0e10cSrcweir
2580cdf0e10cSrcweir uno::Reference< text::XTextCursor > aRef;
2581cdf0e10cSrcweir SwUnoInternalPaM aPam(*GetDoc());
2582cdf0e10cSrcweir if (::sw::XTextRangeToSwPaM(aPam, xTextPosition))
2583cdf0e10cSrcweir {
2584cdf0e10cSrcweir SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent();
2585cdf0e10cSrcweir
2586cdf0e10cSrcweir SwStartNode* p1 = aPam.GetNode()->StartOfSectionNode();
2587cdf0e10cSrcweir //document starts with a section?
2588cdf0e10cSrcweir while(p1->IsSectionNode())
2589cdf0e10cSrcweir {
2590cdf0e10cSrcweir p1 = p1->StartOfSectionNode();
2591cdf0e10cSrcweir }
2592cdf0e10cSrcweir SwStartNode *const p2 = rNode.StartOfSectionNode();
2593cdf0e10cSrcweir
2594cdf0e10cSrcweir if(p1 == p2)
2595cdf0e10cSrcweir {
2596cdf0e10cSrcweir aRef = static_cast<text::XWordCursor*>(
2597cdf0e10cSrcweir new SwXTextCursor(*GetDoc(), this, CURSOR_BODY,
2598cdf0e10cSrcweir *aPam.GetPoint(), aPam.GetMark()));
2599cdf0e10cSrcweir }
2600cdf0e10cSrcweir }
2601cdf0e10cSrcweir if(!aRef.is())
2602cdf0e10cSrcweir {
2603cdf0e10cSrcweir throw uno::RuntimeException();
2604cdf0e10cSrcweir }
2605cdf0e10cSrcweir return aRef;
2606cdf0e10cSrcweir }
2607cdf0e10cSrcweir
2608cdf0e10cSrcweir /*-- 10.12.98 11:17:30---------------------------------------------------
2609cdf0e10cSrcweir
2610cdf0e10cSrcweir -----------------------------------------------------------------------*/
2611cdf0e10cSrcweir uno::Reference< container::XEnumeration > SAL_CALL
createEnumeration()2612cdf0e10cSrcweir SwXBodyText::createEnumeration()
2613cdf0e10cSrcweir throw (uno::RuntimeException)
2614cdf0e10cSrcweir {
2615cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
2616cdf0e10cSrcweir
2617cdf0e10cSrcweir if (!IsValid())
2618cdf0e10cSrcweir {
2619cdf0e10cSrcweir uno::RuntimeException aRuntime;
2620cdf0e10cSrcweir aRuntime.Message = C2U(cInvalidObject);
2621cdf0e10cSrcweir throw aRuntime;
2622cdf0e10cSrcweir }
2623cdf0e10cSrcweir
2624cdf0e10cSrcweir SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent();
2625cdf0e10cSrcweir SwPosition aPos(rNode);
2626cdf0e10cSrcweir ::std::auto_ptr<SwUnoCrsr> pUnoCursor(
2627cdf0e10cSrcweir GetDoc()->CreateUnoCrsr(aPos, sal_False));
2628cdf0e10cSrcweir pUnoCursor->Move(fnMoveBackward, fnGoDoc);
2629cdf0e10cSrcweir const uno::Reference< container::XEnumeration > xRet
2630cdf0e10cSrcweir = new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_BODY);
2631cdf0e10cSrcweir return xRet;
2632cdf0e10cSrcweir }
2633cdf0e10cSrcweir
2634cdf0e10cSrcweir /* -----------------18.12.98 13:36-------------------
2635cdf0e10cSrcweir *
2636cdf0e10cSrcweir * --------------------------------------------------*/
2637cdf0e10cSrcweir uno::Type SAL_CALL
getElementType()2638cdf0e10cSrcweir SwXBodyText::getElementType() throw (uno::RuntimeException)
2639cdf0e10cSrcweir {
2640cdf0e10cSrcweir return text::XTextRange::static_type();
2641cdf0e10cSrcweir }
2642cdf0e10cSrcweir /* -----------------18.12.98 13:36-------------------
2643cdf0e10cSrcweir *
2644cdf0e10cSrcweir * --------------------------------------------------*/
2645cdf0e10cSrcweir sal_Bool SAL_CALL
hasElements()2646cdf0e10cSrcweir SwXBodyText::hasElements() throw (uno::RuntimeException)
2647cdf0e10cSrcweir {
2648cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
2649cdf0e10cSrcweir
2650cdf0e10cSrcweir if (!IsValid())
2651cdf0e10cSrcweir {
2652cdf0e10cSrcweir uno::RuntimeException aRuntime;
2653cdf0e10cSrcweir aRuntime.Message = C2U(cInvalidObject);
2654cdf0e10cSrcweir throw aRuntime;
2655cdf0e10cSrcweir }
2656cdf0e10cSrcweir
2657cdf0e10cSrcweir return sal_True;
2658cdf0e10cSrcweir }
2659cdf0e10cSrcweir
2660cdf0e10cSrcweir /******************************************************************
2661cdf0e10cSrcweir * SwXHeadFootText
2662cdf0e10cSrcweir ******************************************************************/
2663cdf0e10cSrcweir
2664cdf0e10cSrcweir class SwXHeadFootText::Impl
2665cdf0e10cSrcweir : public SwClient
2666cdf0e10cSrcweir {
2667cdf0e10cSrcweir
2668cdf0e10cSrcweir public:
2669cdf0e10cSrcweir
2670cdf0e10cSrcweir bool m_bIsHeader;
2671cdf0e10cSrcweir
Impl(SwXHeadFootText &,SwFrmFmt & rHeadFootFmt,const bool bIsHeader)2672cdf0e10cSrcweir Impl( SwXHeadFootText & /*rThis*/,
2673cdf0e10cSrcweir SwFrmFmt & rHeadFootFmt, const bool bIsHeader)
2674cdf0e10cSrcweir : SwClient(& rHeadFootFmt)
2675cdf0e10cSrcweir , m_bIsHeader(bIsHeader)
2676cdf0e10cSrcweir {
2677cdf0e10cSrcweir }
2678cdf0e10cSrcweir
GetHeadFootFmt() const2679cdf0e10cSrcweir SwFrmFmt * GetHeadFootFmt() const {
2680cdf0e10cSrcweir return static_cast<SwFrmFmt*>(
2681cdf0e10cSrcweir const_cast<SwModify*>(GetRegisteredIn()));
2682cdf0e10cSrcweir }
2683cdf0e10cSrcweir
GetHeadFootFmtOrThrow()2684cdf0e10cSrcweir SwFrmFmt & GetHeadFootFmtOrThrow() {
2685cdf0e10cSrcweir SwFrmFmt *const pFmt( GetHeadFootFmt() );
2686cdf0e10cSrcweir if (!pFmt) {
2687cdf0e10cSrcweir throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM(
2688cdf0e10cSrcweir "SwXHeadFootText: disposed or invalid")), 0);
2689cdf0e10cSrcweir }
2690cdf0e10cSrcweir return *pFmt;
2691cdf0e10cSrcweir }
2692cdf0e10cSrcweir protected:
2693cdf0e10cSrcweir // SwClient
2694cdf0e10cSrcweir virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew);
2695cdf0e10cSrcweir
2696cdf0e10cSrcweir };
2697cdf0e10cSrcweir
2698cdf0e10cSrcweir /*-- 11.12.98 10:14:51---------------------------------------------------
2699cdf0e10cSrcweir
2700cdf0e10cSrcweir -----------------------------------------------------------------------*/
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)2701cdf0e10cSrcweir void SwXHeadFootText::Impl::Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew)
2702cdf0e10cSrcweir {
2703cdf0e10cSrcweir ClientModify(this, pOld, pNew);
2704cdf0e10cSrcweir }
2705cdf0e10cSrcweir
IsXHeadFootText(SwClient * const pClient)2706cdf0e10cSrcweir bool SwXHeadFootText::IsXHeadFootText(SwClient *const pClient)
2707cdf0e10cSrcweir {
2708cdf0e10cSrcweir return 0 != dynamic_cast<SwXHeadFootText::Impl*>(pClient);
2709cdf0e10cSrcweir }
2710cdf0e10cSrcweir
2711cdf0e10cSrcweir uno::Reference< text::XText >
CreateXHeadFootText(SwFrmFmt & rHeadFootFmt,const bool bIsHeader)2712cdf0e10cSrcweir SwXHeadFootText::CreateXHeadFootText(
2713cdf0e10cSrcweir SwFrmFmt & rHeadFootFmt, const bool bIsHeader)
2714cdf0e10cSrcweir {
2715cdf0e10cSrcweir // re-use existing SwXHeadFootText
2716cdf0e10cSrcweir // #i105557#: do not iterate over the registered clients: race condition
2717cdf0e10cSrcweir uno::Reference< text::XText > xText(rHeadFootFmt.GetXObject(),
2718cdf0e10cSrcweir uno::UNO_QUERY);
2719cdf0e10cSrcweir if (!xText.is())
2720cdf0e10cSrcweir {
2721cdf0e10cSrcweir SwXHeadFootText *const pXHFT(
2722cdf0e10cSrcweir new SwXHeadFootText(rHeadFootFmt, bIsHeader));
2723cdf0e10cSrcweir xText.set(pXHFT);
2724cdf0e10cSrcweir rHeadFootFmt.SetXObject(xText);
2725cdf0e10cSrcweir }
2726cdf0e10cSrcweir return xText;
2727cdf0e10cSrcweir }
2728cdf0e10cSrcweir
2729cdf0e10cSrcweir /*-- 11.12.98 10:14:48---------------------------------------------------
2730cdf0e10cSrcweir
2731cdf0e10cSrcweir -----------------------------------------------------------------------*/
SwXHeadFootText(SwFrmFmt & rHeadFootFmt,const bool bIsHeader)2732cdf0e10cSrcweir SwXHeadFootText::SwXHeadFootText(SwFrmFmt & rHeadFootFmt, const bool bIsHeader)
2733cdf0e10cSrcweir : SwXText(rHeadFootFmt.GetDoc(),
2734cdf0e10cSrcweir (bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER)
2735cdf0e10cSrcweir , m_pImpl( new SwXHeadFootText::Impl(*this, rHeadFootFmt, bIsHeader) )
2736cdf0e10cSrcweir {
2737cdf0e10cSrcweir }
2738cdf0e10cSrcweir
2739cdf0e10cSrcweir /*-- 11.12.98 10:14:48---------------------------------------------------
2740cdf0e10cSrcweir
2741cdf0e10cSrcweir -----------------------------------------------------------------------*/
~SwXHeadFootText()2742cdf0e10cSrcweir SwXHeadFootText::~SwXHeadFootText()
2743cdf0e10cSrcweir {
2744cdf0e10cSrcweir }
2745cdf0e10cSrcweir
2746cdf0e10cSrcweir /* -----------------------------06.04.00 16:40--------------------------------
2747cdf0e10cSrcweir
2748cdf0e10cSrcweir ---------------------------------------------------------------------------*/
2749cdf0e10cSrcweir OUString SAL_CALL
getImplementationName()2750cdf0e10cSrcweir SwXHeadFootText::getImplementationName() throw (uno::RuntimeException)
2751cdf0e10cSrcweir {
2752cdf0e10cSrcweir return C2U("SwXHeadFootText");
2753cdf0e10cSrcweir }
2754cdf0e10cSrcweir
2755cdf0e10cSrcweir /* -----------------------------06.04.00 16:40--------------------------------
2756cdf0e10cSrcweir
2757cdf0e10cSrcweir ---------------------------------------------------------------------------*/
2758cdf0e10cSrcweir static char const*const g_ServicesHeadFootText[] =
2759cdf0e10cSrcweir {
2760cdf0e10cSrcweir "com.sun.star.text.Text",
2761cdf0e10cSrcweir };
2762cdf0e10cSrcweir static const size_t g_nServicesHeadFootText(
2763cdf0e10cSrcweir sizeof(g_ServicesHeadFootText)/sizeof(g_ServicesHeadFootText[0]));
2764cdf0e10cSrcweir
supportsService(const OUString & rServiceName)2765cdf0e10cSrcweir sal_Bool SAL_CALL SwXHeadFootText::supportsService(const OUString& rServiceName)
2766cdf0e10cSrcweir throw (uno::RuntimeException)
2767cdf0e10cSrcweir {
2768cdf0e10cSrcweir return ::sw::SupportsServiceImpl(
2769cdf0e10cSrcweir g_nServicesHeadFootText, g_ServicesHeadFootText, rServiceName);
2770cdf0e10cSrcweir }
2771cdf0e10cSrcweir
2772cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames()2773cdf0e10cSrcweir SwXHeadFootText::getSupportedServiceNames() throw (uno::RuntimeException)
2774cdf0e10cSrcweir {
2775cdf0e10cSrcweir return ::sw::GetSupportedServiceNamesImpl(
2776cdf0e10cSrcweir g_nServicesHeadFootText, g_ServicesHeadFootText);
2777cdf0e10cSrcweir }
2778cdf0e10cSrcweir
2779cdf0e10cSrcweir /*-- 11.12.98 10:14:49---------------------------------------------------
2780cdf0e10cSrcweir
2781cdf0e10cSrcweir -----------------------------------------------------------------------*/
GetStartNode() const2782cdf0e10cSrcweir const SwStartNode *SwXHeadFootText::GetStartNode() const
2783cdf0e10cSrcweir {
2784cdf0e10cSrcweir const SwStartNode *pSttNd = 0;
2785cdf0e10cSrcweir SwFrmFmt *const pHeadFootFmt = m_pImpl->GetHeadFootFmt();
2786cdf0e10cSrcweir if(pHeadFootFmt)
2787cdf0e10cSrcweir {
2788cdf0e10cSrcweir const SwFmtCntnt& rFlyCntnt = pHeadFootFmt->GetCntnt();
2789cdf0e10cSrcweir if( rFlyCntnt.GetCntntIdx() )
2790cdf0e10cSrcweir {
2791cdf0e10cSrcweir pSttNd = rFlyCntnt.GetCntntIdx()->GetNode().GetStartNode();
2792cdf0e10cSrcweir }
2793cdf0e10cSrcweir }
2794cdf0e10cSrcweir return pSttNd;
2795cdf0e10cSrcweir }
2796cdf0e10cSrcweir
2797cdf0e10cSrcweir uno::Reference< text::XTextCursor >
CreateCursor()2798cdf0e10cSrcweir SwXHeadFootText::CreateCursor() throw (uno::RuntimeException)
2799cdf0e10cSrcweir {
2800cdf0e10cSrcweir return createTextCursor();
2801cdf0e10cSrcweir }
2802cdf0e10cSrcweir /* -----------------------------21.03.00 15:39--------------------------------
2803cdf0e10cSrcweir
2804cdf0e10cSrcweir ---------------------------------------------------------------------------*/
2805cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL
getTypes()2806cdf0e10cSrcweir SwXHeadFootText::getTypes() throw (uno::RuntimeException)
2807cdf0e10cSrcweir {
2808cdf0e10cSrcweir const uno::Sequence< uno::Type > aTypes = SwXHeadFootText_Base::getTypes();
2809cdf0e10cSrcweir const uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes();
2810cdf0e10cSrcweir return ::comphelper::concatSequences(aTypes, aTextTypes);
2811cdf0e10cSrcweir }
2812cdf0e10cSrcweir
2813cdf0e10cSrcweir /* -----------------------------21.03.00 15:39--------------------------------
2814cdf0e10cSrcweir
2815cdf0e10cSrcweir ---------------------------------------------------------------------------*/
2816cdf0e10cSrcweir uno::Sequence< sal_Int8 > SAL_CALL
getImplementationId()2817cdf0e10cSrcweir SwXHeadFootText::getImplementationId() throw (uno::RuntimeException)
2818cdf0e10cSrcweir {
2819cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
2820cdf0e10cSrcweir static uno::Sequence< sal_Int8 > aId( 16 );
2821cdf0e10cSrcweir static sal_Bool bInit = sal_False;
2822cdf0e10cSrcweir if(!bInit)
2823cdf0e10cSrcweir {
2824cdf0e10cSrcweir rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
2825cdf0e10cSrcweir bInit = sal_True;
2826cdf0e10cSrcweir }
2827cdf0e10cSrcweir return aId;
2828cdf0e10cSrcweir }
2829cdf0e10cSrcweir /* -----------------------------21.03.00 15:46--------------------------------
2830cdf0e10cSrcweir
2831cdf0e10cSrcweir ---------------------------------------------------------------------------*/
2832cdf0e10cSrcweir uno::Any SAL_CALL
queryInterface(const uno::Type & rType)2833cdf0e10cSrcweir SwXHeadFootText::queryInterface(const uno::Type& rType)
2834cdf0e10cSrcweir throw (uno::RuntimeException)
2835cdf0e10cSrcweir {
2836cdf0e10cSrcweir const uno::Any ret = SwXHeadFootText_Base::queryInterface(rType);
2837cdf0e10cSrcweir return (ret.getValueType() == ::getCppuVoidType())
2838cdf0e10cSrcweir ? SwXText::queryInterface(rType)
2839cdf0e10cSrcweir : ret;
2840cdf0e10cSrcweir }
2841cdf0e10cSrcweir
2842cdf0e10cSrcweir /*-- 11.12.98 10:14:50---------------------------------------------------
2843cdf0e10cSrcweir
2844cdf0e10cSrcweir -----------------------------------------------------------------------*/
2845cdf0e10cSrcweir uno::Reference< text::XTextCursor > SAL_CALL
createTextCursor()2846cdf0e10cSrcweir SwXHeadFootText::createTextCursor() throw (uno::RuntimeException)
2847cdf0e10cSrcweir {
2848cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
2849cdf0e10cSrcweir
2850cdf0e10cSrcweir SwFrmFmt & rHeadFootFmt( m_pImpl->GetHeadFootFmtOrThrow() );
2851cdf0e10cSrcweir
2852cdf0e10cSrcweir uno::Reference< text::XTextCursor > xRet;
2853cdf0e10cSrcweir const SwFmtCntnt& rFlyCntnt = rHeadFootFmt.GetCntnt();
2854cdf0e10cSrcweir const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode();
2855cdf0e10cSrcweir SwPosition aPos(rNode);
2856cdf0e10cSrcweir SwXTextCursor *const pXCursor = new SwXTextCursor(*GetDoc(), this,
2857cdf0e10cSrcweir (m_pImpl->m_bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER, aPos);
2858cdf0e10cSrcweir SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor();
2859cdf0e10cSrcweir pUnoCrsr->Move(fnMoveForward, fnGoNode);
2860cdf0e10cSrcweir
2861cdf0e10cSrcweir // save current start node to be able to check if there is content
2862cdf0e10cSrcweir // after the table - otherwise the cursor would be in the body text!
2863cdf0e10cSrcweir SwStartNode const*const pOwnStartNode = rNode.FindSttNodeByType(
2864cdf0e10cSrcweir (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode);
2865cdf0e10cSrcweir // is there a table here?
2866cdf0e10cSrcweir SwTableNode* pTblNode = pUnoCrsr->GetNode()->FindTableNode();
2867cdf0e10cSrcweir SwCntntNode* pCont = 0;
2868cdf0e10cSrcweir while (pTblNode)
2869cdf0e10cSrcweir {
2870cdf0e10cSrcweir pUnoCrsr->GetPoint()->nNode = *pTblNode->EndOfSectionNode();
2871cdf0e10cSrcweir pCont = GetDoc()->GetNodes().GoNext(&pUnoCrsr->GetPoint()->nNode);
2872cdf0e10cSrcweir pTblNode = pCont->FindTableNode();
2873cdf0e10cSrcweir }
2874cdf0e10cSrcweir if (pCont)
2875cdf0e10cSrcweir {
2876cdf0e10cSrcweir pUnoCrsr->GetPoint()->nContent.Assign(pCont, 0);
2877cdf0e10cSrcweir }
2878cdf0e10cSrcweir SwStartNode const*const pNewStartNode =
2879cdf0e10cSrcweir pUnoCrsr->GetNode()->FindSttNodeByType(
2880cdf0e10cSrcweir (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode);
2881cdf0e10cSrcweir if (!pNewStartNode || (pNewStartNode != pOwnStartNode))
2882cdf0e10cSrcweir {
2883cdf0e10cSrcweir uno::RuntimeException aExcept;
288424c56ab9SHerbert Dürr aExcept.Message = C2U("no text available");
2885cdf0e10cSrcweir throw aExcept;
2886cdf0e10cSrcweir }
2887cdf0e10cSrcweir xRet = static_cast<text::XWordCursor*>(pXCursor);
2888cdf0e10cSrcweir return xRet;
2889cdf0e10cSrcweir }
2890cdf0e10cSrcweir
2891cdf0e10cSrcweir /*-- 11.12.98 10:14:50---------------------------------------------------
2892cdf0e10cSrcweir
2893cdf0e10cSrcweir -----------------------------------------------------------------------*/
2894cdf0e10cSrcweir uno::Reference< text::XTextCursor > SAL_CALL
createTextCursorByRange(const uno::Reference<text::XTextRange> & xTextPosition)2895cdf0e10cSrcweir SwXHeadFootText::createTextCursorByRange(
2896cdf0e10cSrcweir const uno::Reference< text::XTextRange > & xTextPosition)
2897cdf0e10cSrcweir throw (uno::RuntimeException)
2898cdf0e10cSrcweir {
2899cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
2900cdf0e10cSrcweir
2901cdf0e10cSrcweir SwFrmFmt & rHeadFootFmt( m_pImpl->GetHeadFootFmtOrThrow() );
2902cdf0e10cSrcweir
2903cdf0e10cSrcweir SwUnoInternalPaM aPam(*GetDoc());
2904cdf0e10cSrcweir if (!::sw::XTextRangeToSwPaM(aPam, xTextPosition))
2905cdf0e10cSrcweir {
2906cdf0e10cSrcweir uno::RuntimeException aRuntime;
2907cdf0e10cSrcweir aRuntime.Message = C2U(cInvalidObject);
2908cdf0e10cSrcweir throw aRuntime;
2909cdf0e10cSrcweir }
2910cdf0e10cSrcweir
2911cdf0e10cSrcweir uno::Reference< text::XTextCursor > xRet;
2912cdf0e10cSrcweir SwNode& rNode = rHeadFootFmt.GetCntnt().GetCntntIdx()->GetNode();
2913cdf0e10cSrcweir SwPosition aPos(rNode);
2914cdf0e10cSrcweir SwPaM aHFPam(aPos);
2915cdf0e10cSrcweir aHFPam.Move(fnMoveForward, fnGoNode);
2916cdf0e10cSrcweir SwStartNode *const pOwnStartNode = aHFPam.GetNode()->FindSttNodeByType(
2917cdf0e10cSrcweir (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode);
2918cdf0e10cSrcweir SwStartNode *const p1 = aPam.GetNode()->FindSttNodeByType(
2919cdf0e10cSrcweir (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode);
2920cdf0e10cSrcweir if (p1 == pOwnStartNode)
2921cdf0e10cSrcweir {
2922cdf0e10cSrcweir xRet = static_cast<text::XWordCursor*>(
2923cdf0e10cSrcweir new SwXTextCursor(*GetDoc(), this,
2924cdf0e10cSrcweir (m_pImpl->m_bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER,
2925cdf0e10cSrcweir *aPam.GetPoint(), aPam.GetMark()));
2926cdf0e10cSrcweir }
2927cdf0e10cSrcweir return xRet;
2928cdf0e10cSrcweir }
2929cdf0e10cSrcweir
2930cdf0e10cSrcweir /* -----------------19.03.99 15:44-------------------
2931cdf0e10cSrcweir *
2932cdf0e10cSrcweir * --------------------------------------------------*/
2933cdf0e10cSrcweir uno::Reference< container::XEnumeration > SAL_CALL
createEnumeration()2934cdf0e10cSrcweir SwXHeadFootText::createEnumeration()
2935cdf0e10cSrcweir throw (uno::RuntimeException)
2936cdf0e10cSrcweir {
2937cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
2938cdf0e10cSrcweir
2939cdf0e10cSrcweir SwFrmFmt & rHeadFootFmt( m_pImpl->GetHeadFootFmtOrThrow() );
2940cdf0e10cSrcweir
2941cdf0e10cSrcweir uno::Reference< container::XEnumeration > aRef;
2942cdf0e10cSrcweir const SwFmtCntnt& rFlyCntnt = rHeadFootFmt.GetCntnt();
2943cdf0e10cSrcweir const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode();
2944cdf0e10cSrcweir SwPosition aPos(rNode);
2945cdf0e10cSrcweir ::std::auto_ptr<SwUnoCrsr> pUnoCursor(
2946cdf0e10cSrcweir GetDoc()->CreateUnoCrsr(aPos, sal_False));
2947cdf0e10cSrcweir pUnoCursor->Move(fnMoveForward, fnGoNode);
2948cdf0e10cSrcweir aRef = new SwXParagraphEnumeration(this, pUnoCursor,
2949cdf0e10cSrcweir (m_pImpl->m_bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER);
2950cdf0e10cSrcweir
2951cdf0e10cSrcweir return aRef;
2952cdf0e10cSrcweir }
2953cdf0e10cSrcweir
2954cdf0e10cSrcweir /* -----------------19.03.99 15:50-------------------
2955cdf0e10cSrcweir *
2956cdf0e10cSrcweir * --------------------------------------------------*/
2957cdf0e10cSrcweir uno::Type SAL_CALL
getElementType()2958cdf0e10cSrcweir SwXHeadFootText::getElementType() throw (uno::RuntimeException)
2959cdf0e10cSrcweir {
2960cdf0e10cSrcweir return text::XTextRange::static_type();
2961cdf0e10cSrcweir }
2962cdf0e10cSrcweir /* -----------------19.03.99 15:50-------------------
2963cdf0e10cSrcweir *
2964cdf0e10cSrcweir * --------------------------------------------------*/
hasElements()2965cdf0e10cSrcweir sal_Bool SAL_CALL SwXHeadFootText::hasElements() throw (uno::RuntimeException)
2966cdf0e10cSrcweir {
2967cdf0e10cSrcweir return sal_True;
2968cdf0e10cSrcweir }
2969cdf0e10cSrcweir
2970