Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include <com/sun/star/util/DateTime.hpp>
22 : #include <com/sun/star/text/XTextTable.hpp>
23 :
24 : #include <rtl/ustrbuf.hxx>
25 : #include <osl/mutex.hxx>
26 : #include <vcl/svapp.hxx>
27 : #include <comphelper/servicehelper.hxx>
28 :
29 : #include <pagedesc.hxx>
30 : #include "poolfmt.hxx"
31 : #include <redline.hxx>
32 : #include <section.hxx>
33 : #include <unoprnms.hxx>
34 : #include <unomid.h>
35 : #include <unotextrange.hxx>
36 : #include <unotextcursor.hxx>
37 : #include <unoparagraph.hxx>
38 : #include <unocoll.hxx>
39 : #include <unomap.hxx>
40 : #include <unocrsr.hxx>
41 : #include <unoport.hxx>
42 : #include <unoredline.hxx>
43 : #include <doc.hxx>
44 : #include <docary.hxx>
45 :
46 :
47 : using namespace ::com::sun::star;
48 :
49 0 : SwXRedlineText::SwXRedlineText(SwDoc* _pDoc, SwNodeIndex aIndex) :
50 : SwXText(_pDoc, CURSOR_REDLINE),
51 0 : aNodeIndex(aIndex)
52 : {
53 0 : }
54 :
55 0 : const SwStartNode* SwXRedlineText::GetStartNode() const
56 : {
57 0 : return aNodeIndex.GetNode().GetStartNode();
58 : }
59 :
60 0 : uno::Any SwXRedlineText::queryInterface( const uno::Type& rType )
61 : throw(uno::RuntimeException)
62 : {
63 0 : uno::Any aRet;
64 :
65 0 : if (::getCppuType((uno::Reference<container::XEnumerationAccess> *)0) == rType)
66 : {
67 0 : uno::Reference<container::XEnumerationAccess> aAccess = this;
68 0 : aRet <<= aAccess;
69 : }
70 : else
71 : {
72 : // delegate to SwXText and OWeakObject
73 0 : aRet = SwXText::queryInterface(rType);
74 0 : if(!aRet.hasValue())
75 : {
76 0 : aRet = OWeakObject::queryInterface(rType);
77 : }
78 : }
79 :
80 0 : return aRet;
81 : }
82 :
83 0 : uno::Sequence<uno::Type> SwXRedlineText::getTypes()
84 : throw(uno::RuntimeException)
85 : {
86 : // SwXText::getTypes()
87 0 : uno::Sequence<uno::Type> aTypes = SwXText::getTypes();
88 :
89 : // add container::XEnumerationAccess
90 0 : sal_Int32 nLength = aTypes.getLength();
91 0 : aTypes.realloc(nLength + 1);
92 0 : aTypes[nLength] = ::getCppuType((uno::Reference<container::XEnumerationAccess> *)0);
93 :
94 0 : return aTypes;
95 : }
96 :
97 : namespace
98 : {
99 : class theSwXRedlineTextImplementationId : public rtl::Static< UnoTunnelIdInit, theSwXRedlineTextImplementationId> {};
100 : }
101 :
102 0 : uno::Sequence<sal_Int8> SwXRedlineText::getImplementationId()
103 : throw(uno::RuntimeException)
104 : {
105 0 : return theSwXRedlineTextImplementationId::get().getSeq();
106 : }
107 :
108 0 : uno::Reference<text::XTextCursor> SwXRedlineText::createTextCursor(void)
109 : throw( uno::RuntimeException )
110 : {
111 0 : SolarMutexGuard aGuard;
112 :
113 0 : SwPosition aPos(aNodeIndex);
114 : SwXTextCursor *const pXCursor =
115 0 : new SwXTextCursor(*GetDoc(), this, CURSOR_REDLINE, aPos);
116 0 : SwUnoCrsr *const pUnoCursor = pXCursor->GetCursor();
117 0 : pUnoCursor->Move(fnMoveForward, fnGoNode);
118 :
119 : // #101929# prevent a newly created text cursor from running inside a table
120 : // because table cells have their own XText.
121 : // Patterned after SwXTextFrame::createTextCursor(void).
122 :
123 : // skip all tables at the beginning
124 0 : SwTableNode* pTableNode = pUnoCursor->GetNode()->FindTableNode();
125 0 : SwCntntNode* pContentNode = NULL;
126 0 : bool bTable = pTableNode != NULL;
127 0 : while( pTableNode != NULL )
128 : {
129 0 : pUnoCursor->GetPoint()->nNode = *(pTableNode->EndOfSectionNode());
130 0 : pContentNode = GetDoc()->GetNodes().GoNext(&pUnoCursor->GetPoint()->nNode);
131 0 : pTableNode = pContentNode->FindTableNode();
132 : }
133 0 : if( pContentNode != NULL )
134 0 : pUnoCursor->GetPoint()->nContent.Assign( pContentNode, 0 );
135 0 : if( bTable && pUnoCursor->GetNode()->FindSttNodeByType( SwNormalStartNode )
136 0 : != GetStartNode() )
137 : {
138 : // We have gone too far and have left our own redline. This means that
139 : // no content node outside of a table could be found, and therefore we
140 : // except.
141 0 : uno::RuntimeException aExcept;
142 0 : aExcept.Message = OUString(
143 : "No content node found that is inside this change section "
144 0 : "but outside of a table" );
145 0 : throw aExcept;
146 : }
147 :
148 0 : return static_cast<text::XWordCursor*>(pXCursor);
149 : }
150 :
151 0 : uno::Reference<text::XTextCursor> SwXRedlineText::createTextCursorByRange(
152 : const uno::Reference<text::XTextRange> & aTextRange)
153 : throw( uno::RuntimeException )
154 : {
155 0 : uno::Reference<text::XTextCursor> xCursor = createTextCursor();
156 0 : xCursor->gotoRange(aTextRange->getStart(), sal_False);
157 0 : xCursor->gotoRange(aTextRange->getEnd(), sal_True);
158 0 : return xCursor;
159 : }
160 :
161 0 : uno::Reference<container::XEnumeration> SwXRedlineText::createEnumeration(void)
162 : throw( uno::RuntimeException )
163 : {
164 0 : SolarMutexGuard aGuard;
165 0 : SwPaM aPam(aNodeIndex);
166 0 : aPam.Move(fnMoveForward, fnGoNode);
167 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
168 : ::std::auto_ptr<SwUnoCrsr> pUnoCursor(
169 0 : GetDoc()->CreateUnoCrsr(*aPam.Start(), false));
170 : SAL_WNODEPRECATED_DECLARATIONS_POP
171 0 : return new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_REDLINE);
172 : }
173 :
174 0 : uno::Type SwXRedlineText::getElementType( ) throw(uno::RuntimeException)
175 : {
176 0 : return ::getCppuType((uno::Reference<text::XTextRange>*)0);
177 : }
178 :
179 0 : sal_Bool SwXRedlineText::hasElements( ) throw(uno::RuntimeException)
180 : {
181 0 : return sal_True; // we always have a content index
182 : }
183 :
184 40 : SwXRedlinePortion::SwXRedlinePortion(SwRedline const& rRedline,
185 : SwUnoCrsr const*const pPortionCrsr,
186 : uno::Reference< text::XText > const& xParent, bool const bStart)
187 : : SwXTextPortion(pPortionCrsr, xParent,
188 : (bStart) ? PORTION_REDLINE_START : PORTION_REDLINE_END)
189 40 : , m_rRedline(rRedline)
190 : {
191 40 : SetCollapsed(!m_rRedline.HasMark());
192 40 : }
193 :
194 80 : SwXRedlinePortion::~SwXRedlinePortion()
195 : {
196 80 : }
197 :
198 0 : static util::DateTime lcl_DateTimeToUno(const DateTime& rDT)
199 : {
200 0 : util::DateTime aRetDT;
201 0 : aRetDT.Year = rDT.GetYear();
202 0 : aRetDT.Month= rDT.GetMonth();
203 0 : aRetDT.Day = rDT.GetDay();
204 0 : aRetDT.Hours = rDT.GetHour();
205 0 : aRetDT.Minutes = rDT.GetMin();
206 0 : aRetDT.Seconds = rDT.GetSec();
207 0 : aRetDT.NanoSeconds = rDT.GetNanoSec();
208 0 : return aRetDT;
209 : }
210 :
211 8 : static OUString lcl_RedlineTypeToOUString(RedlineType_t eType)
212 : {
213 8 : OUString sRet;
214 8 : switch(eType & nsRedlineType_t::REDLINE_NO_FLAG_MASK)
215 : {
216 0 : case nsRedlineType_t::REDLINE_INSERT: sRet = "Insert"; break;
217 4 : case nsRedlineType_t::REDLINE_DELETE: sRet = "Delete"; break;
218 4 : case nsRedlineType_t::REDLINE_FORMAT: sRet = "Format"; break;
219 0 : case nsRedlineType_t::REDLINE_TABLE: sRet = "TextTable"; break;
220 0 : case nsRedlineType_t::REDLINE_FMTCOLL:sRet = "Style"; break;
221 : }
222 8 : return sRet;
223 : }
224 :
225 0 : static uno::Sequence<beans::PropertyValue> lcl_GetSuccessorProperties(const SwRedline& rRedline)
226 : {
227 0 : uno::Sequence<beans::PropertyValue> aValues(4);
228 :
229 0 : const SwRedlineData* pNext = rRedline.GetRedlineData().Next();
230 0 : if(pNext)
231 : {
232 0 : beans::PropertyValue* pValues = aValues.getArray();
233 0 : pValues[0].Name = OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_REDLINE_AUTHOR));
234 : // GetAuthorString(n) walks the SwRedlineData* chain;
235 : // here we always need element 1
236 0 : pValues[0].Value <<= OUString(rRedline.GetAuthorString(1));
237 0 : pValues[1].Name = OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_REDLINE_DATE_TIME));
238 0 : pValues[1].Value <<= lcl_DateTimeToUno(pNext->GetTimeStamp());
239 0 : pValues[2].Name = OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_REDLINE_COMMENT));
240 0 : pValues[2].Value <<= OUString(pNext->GetComment());
241 0 : pValues[3].Name = OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_REDLINE_TYPE));
242 0 : pValues[3].Value <<= lcl_RedlineTypeToOUString(pNext->GetType());
243 : }
244 0 : return aValues;
245 : }
246 :
247 12 : uno::Any SwXRedlinePortion::getPropertyValue( const OUString& rPropertyName )
248 : throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
249 : {
250 12 : SolarMutexGuard aGuard;
251 12 : Validate();
252 12 : uno::Any aRet;
253 12 : if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_TEXT)))
254 : {
255 0 : SwNodeIndex* pNodeIdx = m_rRedline.GetContentIdx();
256 0 : if(pNodeIdx )
257 : {
258 0 : if ( 1 < ( pNodeIdx->GetNode().EndOfSectionIndex() - pNodeIdx->GetNode().GetIndex() ) )
259 : {
260 0 : SwUnoCrsr* pUnoCrsr = GetCursor();
261 0 : uno::Reference<text::XText> xRet = new SwXRedlineText(pUnoCrsr->GetDoc(), *pNodeIdx);
262 0 : aRet <<= xRet;
263 : }
264 : else {
265 : OSL_FAIL("Empty section in redline portion! (end node immediately follows start node)");
266 : }
267 : }
268 : }
269 : else
270 : {
271 12 : aRet = GetPropertyValue(rPropertyName, m_rRedline);
272 16 : if(!aRet.hasValue() &&
273 4 : ! rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_SUCCESSOR_DATA)))
274 4 : aRet = SwXTextPortion::getPropertyValue(rPropertyName);
275 : }
276 12 : return aRet;
277 : }
278 :
279 12 : void SwXRedlinePortion::Validate() throw( uno::RuntimeException )
280 : {
281 12 : SwUnoCrsr* pUnoCrsr = GetCursor();
282 12 : if(!pUnoCrsr)
283 0 : throw uno::RuntimeException();
284 : //search for the redline
285 12 : SwDoc* pDoc = pUnoCrsr->GetDoc();
286 12 : const SwRedlineTbl& rRedTbl = pDoc->GetRedlineTbl();
287 12 : bool bFound = false;
288 26 : for(sal_uInt16 nRed = 0; nRed < rRedTbl.size() && !bFound; nRed++)
289 14 : bFound = &m_rRedline == rRedTbl[nRed];
290 12 : if(!bFound)
291 0 : throw uno::RuntimeException();
292 12 : }
293 :
294 : namespace
295 : {
296 : class theSwXRedlinePortionImplementationId : public rtl::Static< UnoTunnelIdInit, theSwXRedlinePortionImplementationId > {};
297 : }
298 :
299 0 : uno::Sequence< sal_Int8 > SAL_CALL SwXRedlinePortion::getImplementationId( ) throw(uno::RuntimeException)
300 : {
301 0 : return theSwXRedlinePortionImplementationId::get().getSeq();
302 : }
303 :
304 12 : uno::Any SwXRedlinePortion::GetPropertyValue( const OUString& rPropertyName, const SwRedline& rRedline ) throw()
305 : {
306 12 : uno::Any aRet;
307 12 : if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_AUTHOR)))
308 0 : aRet <<= OUString(rRedline.GetAuthorString());
309 12 : else if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_DATE_TIME)))
310 : {
311 0 : aRet <<= lcl_DateTimeToUno(rRedline.GetTimeStamp());
312 : }
313 12 : else if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_COMMENT)))
314 0 : aRet <<= OUString(rRedline.GetComment());
315 12 : else if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_TYPE)))
316 : {
317 8 : aRet <<= lcl_RedlineTypeToOUString(rRedline.GetType());
318 : }
319 4 : else if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_SUCCESSOR_DATA)))
320 : {
321 0 : if(rRedline.GetRedlineData().Next())
322 0 : aRet <<= lcl_GetSuccessorProperties(rRedline);
323 : }
324 4 : else if (rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_IDENTIFIER)))
325 : {
326 0 : OUStringBuffer sBuf;
327 0 : sBuf.append( sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(&rRedline) ) );
328 0 : aRet <<= sBuf.makeStringAndClear();
329 : }
330 4 : else if (rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_IS_IN_HEADER_FOOTER)))
331 : {
332 : sal_Bool bRet =
333 0 : rRedline.GetDoc()->IsInHeaderFooter( rRedline.GetPoint()->nNode );
334 0 : aRet.setValue(&bRet, ::getBooleanCppuType());
335 : }
336 4 : else if (rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_MERGE_LAST_PARA)))
337 : {
338 0 : sal_Bool bRet = !rRedline.IsDelLastPara();
339 0 : aRet.setValue( &bRet, ::getBooleanCppuType() );
340 : }
341 12 : return aRet;
342 : }
343 :
344 0 : uno::Sequence< beans::PropertyValue > SwXRedlinePortion::CreateRedlineProperties(
345 : const SwRedline& rRedline, sal_Bool bIsStart ) throw()
346 : {
347 0 : uno::Sequence< beans::PropertyValue > aRet(11);
348 0 : const SwRedlineData* pNext = rRedline.GetRedlineData().Next();
349 0 : beans::PropertyValue* pRet = aRet.getArray();
350 :
351 0 : OUStringBuffer sRedlineIdBuf;
352 0 : sRedlineIdBuf.append( sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(&rRedline) ) );
353 :
354 0 : sal_Int32 nPropIdx = 0;
355 0 : pRet[nPropIdx].Name = OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_REDLINE_AUTHOR));
356 0 : pRet[nPropIdx++].Value <<= OUString(rRedline.GetAuthorString());
357 0 : pRet[nPropIdx].Name = OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_REDLINE_DATE_TIME));
358 0 : pRet[nPropIdx++].Value <<= lcl_DateTimeToUno(rRedline.GetTimeStamp());
359 0 : pRet[nPropIdx].Name = OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_REDLINE_COMMENT));
360 0 : pRet[nPropIdx++].Value <<= OUString(rRedline.GetComment());
361 0 : pRet[nPropIdx].Name = OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_REDLINE_TYPE));
362 0 : pRet[nPropIdx++].Value <<= lcl_RedlineTypeToOUString(rRedline.GetType());
363 0 : pRet[nPropIdx].Name = OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_REDLINE_IDENTIFIER));
364 0 : pRet[nPropIdx++].Value <<= sRedlineIdBuf.makeStringAndClear();
365 0 : pRet[nPropIdx].Name = OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_IS_COLLAPSED));
366 0 : sal_Bool bTmp = !rRedline.HasMark();
367 0 : pRet[nPropIdx++].Value.setValue(&bTmp, ::getBooleanCppuType()) ;
368 :
369 0 : pRet[nPropIdx].Name = OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_IS_START));
370 0 : pRet[nPropIdx++].Value.setValue(&bIsStart, ::getBooleanCppuType()) ;
371 :
372 0 : bTmp = !rRedline.IsDelLastPara();
373 0 : pRet[nPropIdx].Name = OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_MERGE_LAST_PARA));
374 0 : pRet[nPropIdx++].Value.setValue(&bTmp, ::getBooleanCppuType()) ;
375 :
376 0 : SwNodeIndex* pNodeIdx = rRedline.GetContentIdx();
377 0 : if(pNodeIdx )
378 : {
379 0 : if ( 1 < ( pNodeIdx->GetNode().EndOfSectionIndex() - pNodeIdx->GetNode().GetIndex() ) )
380 : {
381 0 : uno::Reference<text::XText> xRet = new SwXRedlineText(rRedline.GetDoc(), *pNodeIdx);
382 0 : pRet[nPropIdx].Name = OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_REDLINE_TEXT));
383 0 : pRet[nPropIdx++].Value <<= xRet;
384 : }
385 : else {
386 : OSL_FAIL("Empty section in redline portion! (end node immediately follows start node)");
387 : }
388 : }
389 0 : if(pNext)
390 : {
391 0 : pRet[nPropIdx].Name = OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_REDLINE_SUCCESSOR_DATA));
392 0 : pRet[nPropIdx++].Value <<= lcl_GetSuccessorProperties(rRedline);
393 : }
394 0 : aRet.realloc(nPropIdx);
395 0 : return aRet;
396 : }
397 :
398 0 : TYPEINIT1(SwXRedline, SwClient);
399 0 : SwXRedline::SwXRedline(SwRedline& rRedline, SwDoc& rDoc) :
400 : SwXText(&rDoc, CURSOR_REDLINE),
401 : pDoc(&rDoc),
402 0 : pRedline(&rRedline)
403 : {
404 0 : pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
405 0 : }
406 :
407 0 : SwXRedline::~SwXRedline()
408 : {
409 0 : }
410 :
411 0 : uno::Reference< beans::XPropertySetInfo > SwXRedline::getPropertySetInfo( ) throw(uno::RuntimeException)
412 : {
413 : static uno::Reference< beans::XPropertySetInfo > xRef =
414 0 : aSwMapProvider.GetPropertySet(PROPERTY_MAP_REDLINE)->getPropertySetInfo();
415 0 : return xRef;
416 : }
417 :
418 0 : void SwXRedline::setPropertyValue( const OUString& rPropertyName, const uno::Any& aValue )
419 : throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException,
420 : lang::WrappedTargetException, uno::RuntimeException)
421 : {
422 0 : SolarMutexGuard aGuard;
423 0 : if(!pDoc)
424 0 : throw uno::RuntimeException();
425 0 : if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_AUTHOR)))
426 : {
427 : OSL_FAIL("currently not available");
428 : }
429 0 : else if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_DATE_TIME)))
430 : {
431 : OSL_FAIL("currently not available");
432 : }
433 0 : else if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_COMMENT)))
434 : {
435 0 : OUString sTmp; aValue >>= sTmp;
436 0 : pRedline->SetComment(sTmp);
437 : }
438 0 : else if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_TYPE)))
439 : {
440 : OSL_FAIL("currently not available");
441 0 : OUString sTmp; aValue >>= sTmp;
442 0 : if(sTmp.isEmpty())
443 0 : throw lang::IllegalArgumentException();
444 : }
445 0 : else if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_SUCCESSOR_DATA)))
446 : {
447 : OSL_FAIL("currently not available");
448 : }
449 : else
450 : {
451 0 : throw lang::IllegalArgumentException();
452 0 : }
453 0 : }
454 :
455 0 : uno::Any SwXRedline::getPropertyValue( const OUString& rPropertyName )
456 : throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
457 : {
458 0 : SolarMutexGuard aGuard;
459 0 : if(!pDoc)
460 0 : throw uno::RuntimeException();
461 0 : uno::Any aRet;
462 0 : sal_Bool bStart = rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_START));
463 0 : if(bStart ||
464 0 : rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_END)))
465 : {
466 0 : uno::Reference<XInterface> xRet;
467 0 : SwNode* pNode = pRedline->GetNode();
468 0 : if(!bStart && pRedline->HasMark())
469 0 : pNode = pRedline->GetNode(sal_False);
470 0 : switch(pNode->GetNodeType())
471 : {
472 : case ND_SECTIONNODE:
473 : {
474 0 : SwSectionNode* pSectNode = pNode->GetSectionNode();
475 : OSL_ENSURE(pSectNode, "No section node!");
476 0 : xRet = SwXTextSections::GetObject( *pSectNode->GetSection().GetFmt() );
477 : }
478 0 : break;
479 : case ND_TABLENODE :
480 : {
481 0 : SwTableNode* pTblNode = pNode->GetTableNode();
482 : OSL_ENSURE(pTblNode, "No table node!");
483 0 : SwTable& rTbl = pTblNode->GetTable();
484 0 : SwFrmFmt* pTblFmt = rTbl.GetFrmFmt();
485 0 : xRet = SwXTextTables::GetObject( *pTblFmt );
486 : }
487 0 : break;
488 : case ND_TEXTNODE :
489 : {
490 0 : SwPosition* pPoint = 0;
491 0 : if(bStart || !pRedline->HasMark())
492 0 : pPoint = pRedline->GetPoint();
493 : else
494 0 : pPoint = pRedline->GetMark();
495 : const uno::Reference<text::XTextRange> xRange =
496 0 : SwXTextRange::CreateXTextRange(*pDoc, *pPoint, 0);
497 0 : xRet = xRange.get();
498 : }
499 0 : break;
500 : default:
501 : OSL_FAIL("illegal node type");
502 : }
503 0 : aRet <<= xRet;
504 : }
505 0 : else if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_TEXT)))
506 : {
507 0 : SwNodeIndex* pNodeIdx = pRedline->GetContentIdx();
508 0 : if( pNodeIdx )
509 : {
510 0 : if ( 1 < ( pNodeIdx->GetNode().EndOfSectionIndex() - pNodeIdx->GetNode().GetIndex() ) )
511 : {
512 0 : uno::Reference<text::XText> xRet = new SwXRedlineText(pDoc, *pNodeIdx);
513 0 : aRet <<= xRet;
514 : }
515 : else {
516 : OSL_FAIL("Empty section in redline portion! (end node immediately follows start node)");
517 : }
518 : }
519 : }
520 : else
521 0 : aRet = SwXRedlinePortion::GetPropertyValue(rPropertyName, *pRedline);
522 0 : return aRet;
523 : }
524 :
525 0 : void SwXRedline::addPropertyChangeListener(
526 : const OUString& /*aPropertyName*/,
527 : const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ )
528 : throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
529 : {
530 0 : }
531 :
532 0 : void SwXRedline::removePropertyChangeListener(
533 : const OUString& /*aPropertyName*/, const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ )
534 : throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
535 : {
536 0 : }
537 :
538 0 : void SwXRedline::addVetoableChangeListener(
539 : const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
540 : throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
541 : {
542 0 : }
543 :
544 0 : void SwXRedline::removeVetoableChangeListener(
545 : const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
546 : throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
547 : {
548 0 : }
549 :
550 0 : void SwXRedline::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
551 : {
552 0 : ClientModify(this, pOld, pNew);
553 0 : if(!GetRegisteredIn())
554 : {
555 0 : pDoc = 0;
556 0 : pRedline = 0;
557 : }
558 0 : }
559 :
560 0 : uno::Reference< container::XEnumeration > SwXRedline::createEnumeration(void) throw( uno::RuntimeException )
561 : {
562 0 : SolarMutexGuard aGuard;
563 0 : uno::Reference< container::XEnumeration > xRet;
564 0 : if(!pDoc)
565 0 : throw uno::RuntimeException();
566 :
567 0 : SwNodeIndex* pNodeIndex = pRedline->GetContentIdx();
568 0 : if(pNodeIndex)
569 : {
570 0 : SwPaM aPam(*pNodeIndex);
571 0 : aPam.Move(fnMoveForward, fnGoNode);
572 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
573 : ::std::auto_ptr<SwUnoCrsr> pUnoCursor(
574 0 : GetDoc()->CreateUnoCrsr(*aPam.Start(), false));
575 : SAL_WNODEPRECATED_DECLARATIONS_POP
576 0 : xRet = new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_REDLINE);
577 : }
578 0 : return xRet;
579 : }
580 :
581 0 : uno::Type SwXRedline::getElementType( ) throw(uno::RuntimeException)
582 : {
583 0 : return ::getCppuType((uno::Reference<text::XTextRange>*)0);
584 : }
585 :
586 0 : sal_Bool SwXRedline::hasElements( ) throw(uno::RuntimeException)
587 : {
588 0 : if(!pDoc)
589 0 : throw uno::RuntimeException();
590 0 : return 0 != pRedline->GetContentIdx();
591 : }
592 :
593 0 : uno::Reference< text::XTextCursor > SwXRedline::createTextCursor(void) throw( uno::RuntimeException )
594 : {
595 0 : SolarMutexGuard aGuard;
596 0 : if(!pDoc)
597 0 : throw uno::RuntimeException();
598 :
599 0 : uno::Reference< text::XTextCursor > xRet;
600 0 : SwNodeIndex* pNodeIndex = pRedline->GetContentIdx();
601 0 : if(pNodeIndex)
602 : {
603 0 : SwPosition aPos(*pNodeIndex);
604 : SwXTextCursor *const pXCursor =
605 0 : new SwXTextCursor(*pDoc, this, CURSOR_REDLINE, aPos);
606 0 : SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor();
607 0 : pUnoCrsr->Move(fnMoveForward, fnGoNode);
608 :
609 : //steht hier eine Tabelle?
610 0 : SwTableNode* pTblNode = pUnoCrsr->GetNode()->FindTableNode();
611 0 : SwCntntNode* pCont = 0;
612 0 : while( pTblNode )
613 : {
614 0 : pUnoCrsr->GetPoint()->nNode = *pTblNode->EndOfSectionNode();
615 0 : pCont = GetDoc()->GetNodes().GoNext(&pUnoCrsr->GetPoint()->nNode);
616 0 : pTblNode = pCont->FindTableNode();
617 : }
618 0 : if(pCont)
619 0 : pUnoCrsr->GetPoint()->nContent.Assign(pCont, 0);
620 0 : xRet = static_cast<text::XWordCursor*>(pXCursor);
621 : }
622 : else
623 : {
624 0 : throw uno::RuntimeException();
625 : }
626 0 : return xRet;
627 : }
628 :
629 0 : uno::Reference< text::XTextCursor > SwXRedline::createTextCursorByRange(
630 : const uno::Reference< text::XTextRange > & /*aTextPosition*/)
631 : throw( uno::RuntimeException )
632 : {
633 0 : throw uno::RuntimeException();
634 : }
635 :
636 0 : uno::Any SwXRedline::queryInterface( const uno::Type& rType )
637 : throw(uno::RuntimeException)
638 : {
639 0 : uno::Any aRet = SwXText::queryInterface(rType);
640 0 : if(!aRet.hasValue())
641 : {
642 0 : aRet = SwXRedlineBaseClass::queryInterface(rType);
643 : }
644 0 : return aRet;
645 : }
646 :
647 0 : uno::Sequence<uno::Type> SwXRedline::getTypes()
648 : throw(uno::RuntimeException)
649 : {
650 0 : uno::Sequence<uno::Type> aTypes = SwXText::getTypes();
651 0 : uno::Sequence<uno::Type> aBaseTypes = SwXRedlineBaseClass::getTypes();
652 0 : const uno::Type* pBaseTypes = aBaseTypes.getConstArray();
653 0 : sal_Int32 nCurType = aTypes.getLength();
654 0 : aTypes.realloc(aTypes.getLength() + aBaseTypes.getLength());
655 0 : uno::Type* pTypes = aTypes.getArray();
656 0 : for(sal_Int32 nType = 0; nType < aBaseTypes.getLength(); nType++)
657 0 : pTypes[nCurType++] = pBaseTypes[nType];
658 0 : return aTypes;
659 : }
660 :
661 : namespace
662 : {
663 : class theSwXRedlineImplementationId : public rtl::Static< UnoTunnelIdInit, theSwXRedlineImplementationId > {};
664 : }
665 :
666 0 : uno::Sequence<sal_Int8> SwXRedline::getImplementationId()
667 : throw(uno::RuntimeException)
668 : {
669 0 : return theSwXRedlineImplementationId::get().getSeq();
670 99 : }
671 :
672 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|