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 <unoredline.hxx>
42 : #include <doc.hxx>
43 : #include <docary.hxx>
44 :
45 :
46 : using namespace ::com::sun::star;
47 : using ::rtl::OUString;
48 : using ::rtl::OUStringBuffer;
49 :
50 0 : SwXRedlineText::SwXRedlineText(SwDoc* _pDoc, SwNodeIndex aIndex) :
51 : SwXText(_pDoc, CURSOR_REDLINE),
52 0 : aNodeIndex(aIndex)
53 : {
54 0 : }
55 :
56 0 : const SwStartNode* SwXRedlineText::GetStartNode() const
57 : {
58 0 : return aNodeIndex.GetNode().GetStartNode();
59 : }
60 :
61 0 : uno::Any SwXRedlineText::queryInterface( const uno::Type& rType )
62 : throw(uno::RuntimeException)
63 : {
64 0 : uno::Any aRet;
65 :
66 0 : if (::getCppuType((uno::Reference<container::XEnumerationAccess> *)0) == rType)
67 : {
68 0 : uno::Reference<container::XEnumerationAccess> aAccess = this;
69 0 : aRet <<= aAccess;
70 : }
71 : else
72 : {
73 : // delegate to SwXText and OWeakObject
74 0 : aRet = SwXText::queryInterface(rType);
75 0 : if(!aRet.hasValue())
76 : {
77 0 : aRet = OWeakObject::queryInterface(rType);
78 : }
79 : }
80 :
81 0 : return aRet;
82 : }
83 :
84 0 : uno::Sequence<uno::Type> SwXRedlineText::getTypes()
85 : throw(uno::RuntimeException)
86 : {
87 : // SwXText::getTypes()
88 0 : uno::Sequence<uno::Type> aTypes = SwXText::getTypes();
89 :
90 : // add container::XEnumerationAccess
91 0 : sal_Int32 nLength = aTypes.getLength();
92 0 : aTypes.realloc(nLength + 1);
93 0 : aTypes[nLength] = ::getCppuType((uno::Reference<container::XEnumerationAccess> *)0);
94 :
95 0 : return aTypes;
96 : }
97 :
98 : namespace
99 : {
100 : class theSwXRedlineTextImplementationId : public rtl::Static< UnoTunnelIdInit, theSwXRedlineTextImplementationId> {};
101 : }
102 :
103 0 : uno::Sequence<sal_Int8> SwXRedlineText::getImplementationId()
104 : throw(uno::RuntimeException)
105 : {
106 0 : return theSwXRedlineTextImplementationId::get().getSeq();
107 : }
108 :
109 0 : uno::Reference<text::XTextCursor> SwXRedlineText::createTextCursor(void)
110 : throw( uno::RuntimeException )
111 : {
112 0 : SolarMutexGuard aGuard;
113 :
114 0 : SwPosition aPos(aNodeIndex);
115 : SwXTextCursor *const pXCursor =
116 0 : new SwXTextCursor(*GetDoc(), this, CURSOR_REDLINE, aPos);
117 0 : SwUnoCrsr *const pUnoCursor = pXCursor->GetCursor();
118 0 : pUnoCursor->Move(fnMoveForward, fnGoNode);
119 :
120 : // #101929# prevent a newly created text cursor from running inside a table
121 : // because table cells have their own XText.
122 : // Patterned after SwXTextFrame::createTextCursor(void).
123 :
124 : // skip all tables at the beginning
125 0 : SwTableNode* pTableNode = pUnoCursor->GetNode()->FindTableNode();
126 0 : SwCntntNode* pContentNode = NULL;
127 0 : bool bTable = pTableNode != NULL;
128 0 : while( pTableNode != NULL )
129 : {
130 0 : pUnoCursor->GetPoint()->nNode = *(pTableNode->EndOfSectionNode());
131 0 : pContentNode = GetDoc()->GetNodes().GoNext(&pUnoCursor->GetPoint()->nNode);
132 0 : pTableNode = pContentNode->FindTableNode();
133 : }
134 0 : if( pContentNode != NULL )
135 0 : pUnoCursor->GetPoint()->nContent.Assign( pContentNode, 0 );
136 0 : if( bTable && pUnoCursor->GetNode()->FindSttNodeByType( SwNormalStartNode )
137 0 : != GetStartNode() )
138 : {
139 : // We have gone too far and have left our own redline. This means that
140 : // no content node outside of a table could be found, and therefore we
141 : // except.
142 0 : uno::RuntimeException aExcept;
143 : aExcept.Message = OUString( RTL_CONSTASCII_USTRINGPARAM(
144 : "No content node found that is inside this change section "
145 0 : "but outside of a table" ) );
146 0 : throw aExcept;
147 : }
148 :
149 0 : return static_cast<text::XWordCursor*>(pXCursor);
150 : }
151 :
152 0 : uno::Reference<text::XTextCursor> SwXRedlineText::createTextCursorByRange(
153 : const uno::Reference<text::XTextRange> & aTextRange)
154 : throw( uno::RuntimeException )
155 : {
156 0 : uno::Reference<text::XTextCursor> xCursor = createTextCursor();
157 0 : xCursor->gotoRange(aTextRange->getStart(), sal_False);
158 0 : xCursor->gotoRange(aTextRange->getEnd(), sal_True);
159 0 : return xCursor;
160 : }
161 :
162 0 : uno::Reference<container::XEnumeration> SwXRedlineText::createEnumeration(void)
163 : throw( uno::RuntimeException )
164 : {
165 0 : SolarMutexGuard aGuard;
166 0 : SwPaM aPam(aNodeIndex);
167 0 : aPam.Move(fnMoveForward, fnGoNode);
168 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
169 : ::std::auto_ptr<SwUnoCrsr> pUnoCursor(
170 0 : GetDoc()->CreateUnoCrsr(*aPam.Start(), false));
171 : SAL_WNODEPRECATED_DECLARATIONS_POP
172 0 : return new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_REDLINE);
173 : }
174 :
175 0 : uno::Type SwXRedlineText::getElementType( ) throw(uno::RuntimeException)
176 : {
177 0 : return ::getCppuType((uno::Reference<text::XTextRange>*)0);
178 : }
179 :
180 0 : sal_Bool SwXRedlineText::hasElements( ) throw(uno::RuntimeException)
181 : {
182 0 : return sal_True; // we always have a content index
183 : }
184 :
185 32 : SwXRedlinePortion::SwXRedlinePortion( const SwRedline* pRed,
186 : const SwUnoCrsr* pPortionCrsr,
187 : uno::Reference< text::XText > xParent, sal_Bool bStart) :
188 : SwXTextPortion(pPortionCrsr, xParent, bStart ? PORTION_REDLINE_START : PORTION_REDLINE_END),
189 32 : pRedline(pRed)
190 : {
191 32 : SetCollapsed(!pRedline->HasMark());
192 32 : }
193 :
194 64 : SwXRedlinePortion::~SwXRedlinePortion()
195 : {
196 64 : }
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.HundredthSeconds = rDT.Get100Sec();
208 0 : return aRetDT;
209 : }
210 :
211 4 : static OUString lcl_RedlineTypeToOUString(RedlineType_t eType)
212 : {
213 4 : OUString sRet;
214 4 : switch(eType & nsRedlineType_t::REDLINE_NO_FLAG_MASK)
215 : {
216 0 : case nsRedlineType_t::REDLINE_INSERT: sRet = C2U("Insert"); break;
217 4 : case nsRedlineType_t::REDLINE_DELETE: sRet = C2U("Delete"); break;
218 0 : case nsRedlineType_t::REDLINE_FORMAT: sRet = C2U("Format"); break;
219 0 : case nsRedlineType_t::REDLINE_TABLE: sRet = C2U("TextTable"); break;
220 0 : case nsRedlineType_t::REDLINE_FMTCOLL:sRet = C2U("Style"); break;
221 : }
222 4 : 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 = rtl::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 = rtl::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 = rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_REDLINE_COMMENT));
240 0 : pValues[2].Value <<= OUString(pNext->GetComment());
241 0 : pValues[3].Name = rtl::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 8 : uno::Any SwXRedlinePortion::getPropertyValue( const OUString& rPropertyName )
248 : throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
249 : {
250 8 : SolarMutexGuard aGuard;
251 8 : Validate();
252 8 : uno::Any aRet;
253 8 : if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_TEXT)))
254 : {
255 0 : SwNodeIndex* pNodeIdx = pRedline->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 8 : aRet = GetPropertyValue( rPropertyName, *pRedline);
272 12 : if(!aRet.hasValue() &&
273 4 : ! rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_SUCCESSOR_DATA)))
274 4 : aRet = SwXTextPortion::getPropertyValue(rPropertyName);
275 : }
276 8 : return aRet;
277 : }
278 :
279 8 : void SwXRedlinePortion::Validate() throw( uno::RuntimeException )
280 : {
281 8 : SwUnoCrsr* pUnoCrsr = GetCursor();
282 8 : if(!pUnoCrsr)
283 0 : throw uno::RuntimeException();
284 : //search for the redline
285 8 : SwDoc* pDoc = pUnoCrsr->GetDoc();
286 8 : const SwRedlineTbl& rRedTbl = pDoc->GetRedlineTbl();
287 8 : bool bFound = false;
288 16 : for(sal_uInt16 nRed = 0; nRed < rRedTbl.size() && !bFound; nRed++)
289 8 : bFound = pRedline == rRedTbl[nRed];
290 8 : if(!bFound)
291 0 : throw uno::RuntimeException();
292 8 : }
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 8 : uno::Any SwXRedlinePortion::GetPropertyValue( const OUString& rPropertyName, const SwRedline& rRedline ) throw()
305 : {
306 8 : uno::Any aRet;
307 8 : if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_AUTHOR)))
308 0 : aRet <<= OUString(rRedline.GetAuthorString());
309 8 : else if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_DATE_TIME)))
310 : {
311 0 : aRet <<= lcl_DateTimeToUno(rRedline.GetTimeStamp());
312 : }
313 8 : else if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_COMMENT)))
314 0 : aRet <<= OUString(rRedline.GetComment());
315 8 : else if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_TYPE)))
316 : {
317 4 : 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 8 : 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 = rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_REDLINE_AUTHOR));
356 0 : pRet[nPropIdx++].Value <<= OUString(rRedline.GetAuthorString());
357 0 : pRet[nPropIdx].Name = rtl::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 = rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_REDLINE_COMMENT));
360 0 : pRet[nPropIdx++].Value <<= OUString(rRedline.GetComment());
361 0 : pRet[nPropIdx].Name = rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_REDLINE_TYPE));
362 0 : pRet[nPropIdx++].Value <<= lcl_RedlineTypeToOUString(rRedline.GetType());
363 0 : pRet[nPropIdx].Name = rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_REDLINE_IDENTIFIER));
364 0 : pRet[nPropIdx++].Value <<= sRedlineIdBuf.makeStringAndClear();
365 0 : pRet[nPropIdx].Name = rtl::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 = rtl::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 = rtl::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 = rtl::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 = rtl::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 : }
671 :
672 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|