Update ooo320-m1
[ooovba.git] / sw / source / core / unocore / unoredline.cxx
blobd3b85ff34033c361d3e1ecb4cc16e2ccfbcb48dd
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unoredline.cxx,v $
10 * $Revision: 1.34 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <vos/mutex.hxx>
36 #include <vcl/svapp.hxx>
37 #include <pagedesc.hxx>
38 #include "poolfmt.hxx"
39 #include <redline.hxx>
40 #include <section.hxx>
41 #include <unoprnms.hxx>
42 #include <unoobj.hxx>
43 #include <unocoll.hxx>
44 #include <unomap.hxx>
45 #include <unocrsr.hxx>
46 #include <unoredline.hxx>
47 #include <doc.hxx>
48 #include <docary.hxx>
49 #include <rtl/ustrbuf.hxx>
50 #include <com/sun/star/util/DateTime.hpp>
51 #include <com/sun/star/text/XTextTable.hpp>
53 using namespace ::com::sun::star;
54 using ::rtl::OUString;
55 using ::rtl::OUStringBuffer;
58 /* ---------------------------------------------------------------------------
60 ---------------------------------------------------------------------------*/
61 SwXRedlineText::SwXRedlineText(SwDoc* _pDoc, SwNodeIndex aIndex) :
62 SwXText(_pDoc, CURSOR_REDLINE),
63 aNodeIndex(aIndex)
66 /* ---------------------------------------------------------------------------
68 ---------------------------------------------------------------------------*/
69 const SwStartNode* SwXRedlineText::GetStartNode() const
71 return aNodeIndex.GetNode().GetStartNode();
73 /* ---------------------------------------------------------------------------
75 ---------------------------------------------------------------------------*/
76 uno::Any SwXRedlineText::queryInterface( const uno::Type& rType )
77 throw(uno::RuntimeException)
79 uno::Any aRet;
81 if (::getCppuType((uno::Reference<container::XEnumerationAccess> *)0) == rType)
83 uno::Reference<container::XEnumerationAccess> aAccess = this;
84 aRet <<= aAccess;
86 else
88 // delegate to SwXText and OWeakObject
89 aRet = SwXText::queryInterface(rType);
90 if(!aRet.hasValue())
92 aRet = OWeakObject::queryInterface(rType);
96 return aRet;
98 /* ---------------------------------------------------------------------------
100 ---------------------------------------------------------------------------*/
101 uno::Sequence<uno::Type> SwXRedlineText::getTypes()
102 throw(uno::RuntimeException)
104 // SwXText::getTypes()
105 uno::Sequence<uno::Type> aTypes = SwXText::getTypes();
107 // add container::XEnumerationAccess
108 sal_Int32 nLength = aTypes.getLength();
109 aTypes.realloc(nLength + 1);
110 aTypes[nLength] = ::getCppuType((uno::Reference<container::XEnumerationAccess> *)0);
112 return aTypes;
114 /* ---------------------------------------------------------------------------
116 ---------------------------------------------------------------------------*/
117 uno::Sequence<sal_Int8> SwXRedlineText::getImplementationId()
118 throw(uno::RuntimeException)
120 vos::OGuard aGuard(Application::GetSolarMutex());
121 static uno::Sequence< sal_Int8 > aId( 16 );
122 static sal_Bool bInit = sal_False;
123 if(!bInit)
125 rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
126 bInit = sal_True;
128 return aId;
130 /* ---------------------------------------------------------------------------
132 ---------------------------------------------------------------------------*/
133 uno::Reference<text::XTextCursor> SwXRedlineText::createTextCursor(void)
134 throw( uno::RuntimeException )
136 vos::OGuard aGuard(Application::GetSolarMutex());
138 SwPosition aPos(aNodeIndex);
139 SwXTextCursor* pCrsr = new SwXTextCursor(this, aPos, CURSOR_REDLINE,
140 GetDoc());
141 SwUnoCrsr* pUnoCursor = pCrsr->GetCrsr();
142 pUnoCursor->Move(fnMoveForward, fnGoNode);
144 // #101929# prevent a newly created text cursor from running inside a table
145 // because table cells have their own XText.
146 // Patterned after SwXTextFrame::createTextCursor(void).
148 // skip all tables at the beginning
149 SwTableNode* pTableNode = pUnoCursor->GetNode()->FindTableNode();
150 SwCntntNode* pContentNode = NULL;
151 bool bTable = pTableNode != NULL;
152 while( pTableNode != NULL )
154 pUnoCursor->GetPoint()->nNode = *(pTableNode->EndOfSectionNode());
155 pContentNode = GetDoc()->GetNodes().GoNext(&pUnoCursor->GetPoint()->nNode);
156 pTableNode = pContentNode->FindTableNode();
158 if( pContentNode != NULL )
159 pUnoCursor->GetPoint()->nContent.Assign( pContentNode, 0 );
160 if( bTable && pUnoCursor->GetNode()->FindSttNodeByType( SwNormalStartNode )
161 != GetStartNode() )
163 // We have gone too far and have left our own redline. This means that
164 // no content node outside of a table could be found, and therefore we
165 // except.
166 uno::RuntimeException aExcept;
167 aExcept.Message = OUString( RTL_CONSTASCII_USTRINGPARAM(
168 "No content node found that is inside this change section "
169 "but outside of a table" ) );
170 throw aExcept;
173 return (text::XWordCursor*)pCrsr;
175 /* ---------------------------------------------------------------------------
177 ---------------------------------------------------------------------------*/
178 uno::Reference<text::XTextCursor> SwXRedlineText::createTextCursorByRange(
179 const uno::Reference<text::XTextRange> & aTextRange)
180 throw( uno::RuntimeException )
182 uno::Reference<text::XTextCursor> xCursor = createTextCursor();
183 xCursor->gotoRange(aTextRange->getStart(), sal_False);
184 xCursor->gotoRange(aTextRange->getEnd(), sal_True);
185 return xCursor;
187 /* ---------------------------------------------------------------------------
189 ---------------------------------------------------------------------------*/
190 uno::Reference<container::XEnumeration> SwXRedlineText::createEnumeration(void)
191 throw( uno::RuntimeException )
193 vos::OGuard aGuard(Application::GetSolarMutex());
194 SwPaM aPam(aNodeIndex);
195 aPam.Move(fnMoveForward, fnGoNode);
196 return new SwXParagraphEnumeration(this, *aPam.Start(), CURSOR_REDLINE);
198 /* ---------------------------------------------------------------------------
200 ---------------------------------------------------------------------------*/
201 uno::Type SwXRedlineText::getElementType( ) throw(uno::RuntimeException)
203 return ::getCppuType((uno::Reference<text::XTextRange>*)0);
205 /* ---------------------------------------------------------------------------
207 ---------------------------------------------------------------------------*/
208 sal_Bool SwXRedlineText::hasElements( ) throw(uno::RuntimeException)
210 return sal_True; // we always have a content index
212 /* -----------------------------19.12.00 11:36--------------------------------
214 ---------------------------------------------------------------------------*/
215 SwXRedlinePortion::SwXRedlinePortion( const SwRedline* pRed,
216 const SwUnoCrsr* pPortionCrsr,
217 uno::Reference< text::XText > xParent, BOOL bStart) :
218 SwXTextPortion(pPortionCrsr, xParent, bStart ? PORTION_REDLINE_START : PORTION_REDLINE_END),
219 // SwXText(pPortionCrsr->GetDoc(), CURSOR_REDLINE),
220 // SwXRedlineText(pPortionCrsr->GetDoc(), *pRed->GetContentIdx()),
221 pRedline(pRed)
223 SetCollapsed(!pRedline->HasMark());
225 /*-- 19.12.00 11:37:24---------------------------------------------------
227 -----------------------------------------------------------------------*/
228 SwXRedlinePortion::~SwXRedlinePortion()
231 /* -----------------------------19.12.00 11:46--------------------------------
233 ---------------------------------------------------------------------------*/
234 static util::DateTime lcl_DateTimeToUno(const DateTime& rDT)
236 util::DateTime aRetDT;
237 aRetDT.Year = rDT.GetYear();
238 aRetDT.Month= rDT.GetMonth();
239 aRetDT.Day = rDT.GetDay();
240 aRetDT.Hours = rDT.GetHour();
241 aRetDT.Minutes = rDT.GetMin();
242 aRetDT.Seconds = rDT.GetSec();
243 aRetDT.HundredthSeconds = rDT.Get100Sec();
244 return aRetDT;
247 // ---------------------------------------------------------------------------
248 static OUString lcl_RedlineTypeToOUString(RedlineType_t eType)
250 OUString sRet;
251 switch(eType & nsRedlineType_t::REDLINE_NO_FLAG_MASK)
253 case nsRedlineType_t::REDLINE_INSERT: sRet = C2U("Insert"); break;
254 case nsRedlineType_t::REDLINE_DELETE: sRet = C2U("Delete"); break;
255 case nsRedlineType_t::REDLINE_FORMAT: sRet = C2U("Format"); break;
256 case nsRedlineType_t::REDLINE_TABLE: sRet = C2U("TextTable"); break;
257 case nsRedlineType_t::REDLINE_FMTCOLL:sRet = C2U("Style"); break;
259 return sRet;
262 // ---------------------------------------------------------------------------
263 static uno::Sequence<beans::PropertyValue> lcl_GetSuccessorProperties(const SwRedline& rRedline)
265 uno::Sequence<beans::PropertyValue> aValues(4);
267 const SwRedlineData* pNext = rRedline.GetRedlineData().Next();
268 if(pNext)
270 beans::PropertyValue* pValues = aValues.getArray();
271 pValues[0].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_REDLINE_AUTHOR));
272 // GetAuthorString(n) walks the SwRedlineData* chain;
273 // here we always need element 1
274 pValues[0].Value <<= OUString(rRedline.GetAuthorString(1));
275 pValues[1].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_REDLINE_DATE_TIME));
276 pValues[1].Value <<= lcl_DateTimeToUno(pNext->GetTimeStamp());
277 pValues[2].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_REDLINE_COMMENT));
278 pValues[2].Value <<= OUString(pNext->GetComment());
279 pValues[3].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_REDLINE_TYPE));
280 pValues[3].Value <<= lcl_RedlineTypeToOUString(pNext->GetType());
282 return aValues;
284 // ---------------------------------------------------------------------------
285 uno::Any SwXRedlinePortion::getPropertyValue( const OUString& rPropertyName )
286 throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
288 vos::OGuard aGuard(Application::GetSolarMutex());
289 Validate();
290 uno::Any aRet;
291 if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_TEXT)))
293 SwNodeIndex* pNodeIdx = pRedline->GetContentIdx();
294 if(pNodeIdx )
296 if ( 1 < ( pNodeIdx->GetNode().EndOfSectionIndex() - pNodeIdx->GetNode().GetIndex() ) )
298 SwUnoCrsr* pUnoCrsr = GetCursor();
299 uno::Reference<text::XText> xRet = new SwXRedlineText(pUnoCrsr->GetDoc(), *pNodeIdx);
300 aRet <<= xRet;
302 else {
303 DBG_ASSERT(0, "Empty section in redline portion! (end node immediately follows start node)");
307 else
309 aRet = GetPropertyValue( rPropertyName, *pRedline);
310 if(!aRet.hasValue() &&
311 ! rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_SUCCESSOR_DATA)))
312 aRet = SwXTextPortion::getPropertyValue(rPropertyName);
314 return aRet;
316 /* -----------------------------19.12.00 15:16--------------------------------
318 ---------------------------------------------------------------------------*/
319 void SwXRedlinePortion::Validate() throw( uno::RuntimeException )
321 SwUnoCrsr* pUnoCrsr = GetCursor();
322 if(!pUnoCrsr)
323 throw uno::RuntimeException();
324 //search for the redline
325 SwDoc* pDoc = pUnoCrsr->GetDoc();
326 const SwRedlineTbl& rRedTbl = pDoc->GetRedlineTbl();
327 sal_Bool bFound = FALSE;
328 for(USHORT nRed = 0; nRed < rRedTbl.Count() && !bFound; nRed++)
329 bFound = pRedline == rRedTbl[nRed];
330 if(!bFound)
331 throw uno::RuntimeException();
333 /* -----------------------------21.03.00 15:39--------------------------------
335 ---------------------------------------------------------------------------*/
336 uno::Sequence< sal_Int8 > SAL_CALL SwXRedlinePortion::getImplementationId( ) throw(uno::RuntimeException)
338 vos::OGuard aGuard(Application::GetSolarMutex());
339 static uno::Sequence< sal_Int8 > aId( 16 );
340 static sal_Bool bInit = sal_False;
341 if(!bInit)
343 rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
344 bInit = sal_True;
346 return aId;
348 /* -----------------------------11.01.01 16:39--------------------------------
350 ---------------------------------------------------------------------------*/
351 uno::Any SwXRedlinePortion::GetPropertyValue( const OUString& rPropertyName, const SwRedline& rRedline ) throw()
353 uno::Any aRet;
354 if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_AUTHOR)))
355 aRet <<= OUString(rRedline.GetAuthorString());
356 else if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_DATE_TIME)))
358 aRet <<= lcl_DateTimeToUno(rRedline.GetTimeStamp());
360 else if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_COMMENT)))
361 aRet <<= OUString(rRedline.GetComment());
362 else if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_TYPE)))
364 aRet <<= lcl_RedlineTypeToOUString(rRedline.GetType());
366 else if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_SUCCESSOR_DATA)))
368 if(rRedline.GetRedlineData().Next())
369 aRet <<= lcl_GetSuccessorProperties(rRedline);
371 else if (rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_IDENTIFIER)))
373 OUStringBuffer sBuf;
374 sBuf.append( sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(&rRedline) ) );
375 aRet <<= sBuf.makeStringAndClear();
377 else if (rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_IS_IN_HEADER_FOOTER)))
379 sal_Bool bRet =
380 rRedline.GetDoc()->IsInHeaderFooter( rRedline.GetPoint()->nNode );
381 aRet.setValue(&bRet, ::getBooleanCppuType());
383 else if (rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_MERGE_LAST_PARA)))
385 sal_Bool bRet = !rRedline.IsDelLastPara();
386 aRet.setValue( &bRet, ::getBooleanCppuType() );
388 return aRet;
390 /* -----------------------------11.01.01 11:22--------------------------------
392 ---------------------------------------------------------------------------*/
393 uno::Sequence< beans::PropertyValue > SwXRedlinePortion::CreateRedlineProperties(
394 const SwRedline& rRedline, sal_Bool bIsStart ) throw()
396 uno::Sequence< beans::PropertyValue > aRet(11);
397 const SwRedlineData* pNext = rRedline.GetRedlineData().Next();
398 beans::PropertyValue* pRet = aRet.getArray();
400 OUStringBuffer sRedlineIdBuf;
401 sRedlineIdBuf.append( sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(&rRedline) ) );
403 sal_Int32 nPropIdx = 0;
404 pRet[nPropIdx].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_REDLINE_AUTHOR));
405 pRet[nPropIdx++].Value <<= OUString(rRedline.GetAuthorString());
406 pRet[nPropIdx].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_REDLINE_DATE_TIME));
407 pRet[nPropIdx++].Value <<= lcl_DateTimeToUno(rRedline.GetTimeStamp());
408 pRet[nPropIdx].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_REDLINE_COMMENT));
409 pRet[nPropIdx++].Value <<= OUString(rRedline.GetComment());
410 pRet[nPropIdx].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_REDLINE_TYPE));
411 pRet[nPropIdx++].Value <<= lcl_RedlineTypeToOUString(rRedline.GetType());
412 pRet[nPropIdx].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_REDLINE_IDENTIFIER));
413 pRet[nPropIdx++].Value <<= sRedlineIdBuf.makeStringAndClear();
414 pRet[nPropIdx].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_IS_COLLAPSED));
415 sal_Bool bTmp = !rRedline.HasMark();
416 pRet[nPropIdx++].Value.setValue(&bTmp, ::getBooleanCppuType()) ;
418 pRet[nPropIdx].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_IS_START));
419 pRet[nPropIdx++].Value.setValue(&bIsStart, ::getBooleanCppuType()) ;
421 bTmp = !rRedline.IsDelLastPara();
422 pRet[nPropIdx].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_MERGE_LAST_PARA));
423 pRet[nPropIdx++].Value.setValue(&bTmp, ::getBooleanCppuType()) ;
425 SwNodeIndex* pNodeIdx = rRedline.GetContentIdx();
426 if(pNodeIdx )
428 if ( 1 < ( pNodeIdx->GetNode().EndOfSectionIndex() - pNodeIdx->GetNode().GetIndex() ) )
430 uno::Reference<text::XText> xRet = new SwXRedlineText(rRedline.GetDoc(), *pNodeIdx);
431 pRet[nPropIdx].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_REDLINE_TEXT));
432 pRet[nPropIdx++].Value <<= xRet;
434 else {
435 DBG_ASSERT(0, "Empty section in redline portion! (end node immediately follows start node)");
438 if(pNext)
440 pRet[nPropIdx].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_REDLINE_SUCCESSOR_DATA));
441 pRet[nPropIdx++].Value <<= lcl_GetSuccessorProperties(rRedline);
443 aRet.realloc(nPropIdx);
444 return aRet;
446 /*-- 11.01.01 17:06:07---------------------------------------------------
448 -----------------------------------------------------------------------*/
449 TYPEINIT1(SwXRedline, SwClient);
450 SwXRedline::SwXRedline(SwRedline& rRedline, SwDoc& rDoc) :
451 SwXText(&rDoc, CURSOR_REDLINE),
452 pDoc(&rDoc),
453 pRedline(&rRedline)
455 pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
457 /*-- 11.01.01 17:06:08---------------------------------------------------
459 -----------------------------------------------------------------------*/
460 SwXRedline::~SwXRedline()
463 /*-- 11.01.01 17:06:08---------------------------------------------------
465 -----------------------------------------------------------------------*/
466 uno::Reference< beans::XPropertySetInfo > SwXRedline::getPropertySetInfo( ) throw(uno::RuntimeException)
468 static uno::Reference< beans::XPropertySetInfo > xRef =
469 aSwMapProvider.GetPropertySet(PROPERTY_MAP_REDLINE)->getPropertySetInfo();
470 return xRef;
472 /*-- 11.01.01 17:06:08---------------------------------------------------
474 -----------------------------------------------------------------------*/
475 void SwXRedline::setPropertyValue( const OUString& rPropertyName, const uno::Any& aValue )
476 throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException,
477 lang::WrappedTargetException, uno::RuntimeException)
479 vos::OGuard aGuard(Application::GetSolarMutex());
480 if(!pDoc)
481 throw uno::RuntimeException();
482 if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_AUTHOR)))
484 DBG_ERROR("currently not available");
486 else if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_DATE_TIME)))
488 DBG_ERROR("currently not available");
489 // util::DateTime aDT;
490 // if(aValue >>= aDT)
491 // pRedline->SetTimeStamp(lcl_DateTimeFromUno(aDT));
493 else if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_COMMENT)))
495 OUString sTmp; aValue >>= sTmp;
496 pRedline->SetComment(sTmp);
498 else if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_TYPE)))
500 DBG_ERROR("currently not available");
501 OUString sTmp; aValue >>= sTmp;
502 if(!sTmp.getLength())
503 throw lang::IllegalArgumentException();
504 // pRedline->SetType(lcl_OUStringToRedlineType(sTmp));
506 else if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_SUCCESSOR_DATA)))
508 DBG_ERROR("currently not available");
509 /* SwRedlineData* pNext = pRedline->GetRedlineData().Next();
510 uno::Sequence<beans::PropertyValue> aValues;
511 if(!(aValue =>> aValues) || !pNext)
512 throw lang::IllegalArgumentException();
514 const beans::PropertyValue* pValues = aValues.getConstArray();
515 for(sal_Int32 nValue = 0; nValue < aValues.getLength(); nValue++)
517 if(pValues[nValue].Name.equalsAscii(UNO_NAME_REDLINE_AUTHOR.pName)
519 DBG_ERROR("currently not available");
521 else if(pValues[nValue].Name.equalsAscii(UNO_NAME_REDLINE_DATE_TIME.pName))
523 util::DateTime aDT;
524 if(pValues[nValue].Value >>= aDT)
525 pNext->SetTimeStamp(lcl_DateTimeFromUno(aDT));
527 else if(pValues[nValue].Name.equalsAscii(UNO_NAME_REDLINE_COMMENT.pName))
529 OUString sTmp; pValues[nValue].Value >>= sTmp;
530 pNext->SetComment(sTmp);
532 else if(pValues[nValue].Name.equalsAscii(UNO_NAME_REDLINE_TYPE.pName))
534 OUString sTmp; pValues[nValue].Value >>= sTmp;
535 pNext->SetType(lcl_OUStringToRedlineType(sTmp);
538 */ }
539 else
541 throw lang::IllegalArgumentException();
544 /*-- 11.01.01 17:06:08---------------------------------------------------
546 -----------------------------------------------------------------------*/
547 uno::Any SwXRedline::getPropertyValue( const OUString& rPropertyName )
548 throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
550 vos::OGuard aGuard(Application::GetSolarMutex());
551 if(!pDoc)
552 throw uno::RuntimeException();
553 uno::Any aRet;
554 BOOL bStart = rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_START));
555 if(bStart ||
556 rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_END)))
558 uno::Reference<XInterface> xRet;
559 SwNode* pNode = pRedline->GetNode();
560 if(!bStart && pRedline->HasMark())
561 pNode = pRedline->GetNode(FALSE);
562 switch(pNode->GetNodeType())
564 case ND_SECTIONNODE:
566 SwSectionNode* pSectNode = pNode->GetSectionNode();
567 DBG_ASSERT(pSectNode, "No section node!");
568 xRet = SwXTextSections::GetObject( *pSectNode->GetSection().GetFmt() );
570 break;
571 case ND_TABLENODE :
573 SwTableNode* pTblNode = pNode->GetTableNode();
574 DBG_ASSERT(pTblNode, "No table node!");
575 SwTable& rTbl = pTblNode->GetTable();
576 SwFrmFmt* pTblFmt = rTbl.GetFrmFmt();
577 xRet = SwXTextTables::GetObject( *pTblFmt );
579 break;
580 case ND_TEXTNODE :
582 SwPosition* pPoint = 0;
583 if(bStart || !pRedline->HasMark())
584 pPoint = pRedline->GetPoint();
585 else
586 pPoint = pRedline->GetMark();
587 SwPaM aTmp(*pPoint);
588 uno::Reference<text::XText> xTmpParent;
589 // uno::Reference< text::XTextRange > xRange = SwXTextRange::createTextRangeFromPaM(aTmp);
590 uno::Reference<text::XTextRange>xRange =
591 SwXTextRange::CreateTextRangeFromPosition( pDoc, *pPoint, 0 );
592 xRet = xRange.get();
594 break;
595 default:
596 DBG_ERROR("illegal node type");
598 aRet <<= xRet;
600 else if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_REDLINE_TEXT)))
602 SwNodeIndex* pNodeIdx = pRedline->GetContentIdx();
603 if( pNodeIdx )
605 if ( 1 < ( pNodeIdx->GetNode().EndOfSectionIndex() - pNodeIdx->GetNode().GetIndex() ) )
607 uno::Reference<text::XText> xRet = new SwXRedlineText(pDoc, *pNodeIdx);
608 aRet <<= xRet;
610 else {
611 DBG_ASSERT(0, "Empty section in redline portion! (end node immediately follows start node)");
615 else
616 aRet = SwXRedlinePortion::GetPropertyValue(rPropertyName, *pRedline);
617 return aRet;
619 /*-- 11.01.01 17:06:09---------------------------------------------------
621 -----------------------------------------------------------------------*/
622 void SwXRedline::addPropertyChangeListener(
623 const OUString& /*aPropertyName*/,
624 const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ )
625 throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
628 /*-- 11.01.01 17:06:09---------------------------------------------------
630 -----------------------------------------------------------------------*/
631 void SwXRedline::removePropertyChangeListener(
632 const OUString& /*aPropertyName*/, const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ )
633 throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
636 /*-- 11.01.01 17:06:09---------------------------------------------------
638 -----------------------------------------------------------------------*/
639 void SwXRedline::addVetoableChangeListener(
640 const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
641 throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
644 /*-- 11.01.01 17:06:09---------------------------------------------------
646 -----------------------------------------------------------------------*/
647 void SwXRedline::removeVetoableChangeListener(
648 const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
649 throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
652 /*-- 11.01.01 17:06:10---------------------------------------------------
654 -----------------------------------------------------------------------*/
655 void SwXRedline::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew)
657 ClientModify(this, pOld, pNew);
658 if(!GetRegisteredIn())
660 pDoc = 0;
661 pRedline = 0;
664 /*-- 19.12.00 11:37:25---------------------------------------------------
666 -----------------------------------------------------------------------*/
667 uno::Reference< container::XEnumeration > SwXRedline::createEnumeration(void) throw( uno::RuntimeException )
669 vos::OGuard aGuard(Application::GetSolarMutex());
670 uno::Reference< container::XEnumeration > xRet;
671 if(!pDoc)
672 throw uno::RuntimeException();
674 SwNodeIndex* pNodeIndex = pRedline->GetContentIdx();
675 if(pNodeIndex)
677 SwPaM aPam(*pNodeIndex);
678 aPam.Move(fnMoveForward, fnGoNode);
679 xRet = new SwXParagraphEnumeration(this, *aPam.Start(), CURSOR_REDLINE);
681 return xRet;
683 /* -----------------------------19.12.00 12:34--------------------------------
685 ---------------------------------------------------------------------------*/
686 uno::Type SwXRedline::getElementType( ) throw(uno::RuntimeException)
688 return ::getCppuType((uno::Reference<text::XTextRange>*)0);
690 /* -----------------------------19.12.00 12:34--------------------------------
692 ---------------------------------------------------------------------------*/
693 sal_Bool SwXRedline::hasElements( ) throw(uno::RuntimeException)
695 if(!pDoc)
696 throw uno::RuntimeException();
697 return 0 != pRedline->GetContentIdx();
699 /* -----------------------------19.12.00 15:11--------------------------------
701 ---------------------------------------------------------------------------*/
702 uno::Reference< text::XTextCursor > SwXRedline::createTextCursor(void) throw( uno::RuntimeException )
704 vos::OGuard aGuard(Application::GetSolarMutex());
705 if(!pDoc)
706 throw uno::RuntimeException();
708 uno::Reference< text::XTextCursor > xRet;
709 SwNodeIndex* pNodeIndex = pRedline->GetContentIdx();
710 if(pNodeIndex)
712 SwPosition aPos(*pNodeIndex);
713 SwXTextCursor* pCrsr = new SwXTextCursor(this, aPos, CURSOR_REDLINE, pDoc);
714 SwUnoCrsr* pUnoCrsr = pCrsr->GetCrsr();
715 pUnoCrsr->Move(fnMoveForward, fnGoNode);
717 //steht hier eine Tabelle?
718 SwTableNode* pTblNode = pUnoCrsr->GetNode()->FindTableNode();
719 SwCntntNode* pCont = 0;
720 while( pTblNode )
722 pUnoCrsr->GetPoint()->nNode = *pTblNode->EndOfSectionNode();
723 pCont = GetDoc()->GetNodes().GoNext(&pUnoCrsr->GetPoint()->nNode);
724 pTblNode = pCont->FindTableNode();
726 if(pCont)
727 pUnoCrsr->GetPoint()->nContent.Assign(pCont, 0);
728 xRet = (text::XWordCursor*)pCrsr;
730 else
732 throw uno::RuntimeException();
734 return xRet;
736 /* -----------------------------19.12.00 15:11--------------------------------
738 ---------------------------------------------------------------------------*/
739 uno::Reference< text::XTextCursor > SwXRedline::createTextCursorByRange(
740 const uno::Reference< text::XTextRange > & /*aTextPosition*/)
741 throw( uno::RuntimeException )
743 throw uno::RuntimeException();
745 /* ---------------------------------------------------------------------------
747 ---------------------------------------------------------------------------*/
748 uno::Any SwXRedline::queryInterface( const uno::Type& rType )
749 throw(uno::RuntimeException)
751 uno::Any aRet = SwXText::queryInterface(rType);
752 if(!aRet.hasValue())
754 aRet = SwXRedlineBaseClass::queryInterface(rType);
756 return aRet;
758 /* ---------------------------------------------------------------------------
760 ---------------------------------------------------------------------------*/
761 uno::Sequence<uno::Type> SwXRedline::getTypes()
762 throw(uno::RuntimeException)
764 uno::Sequence<uno::Type> aTypes = SwXText::getTypes();
765 uno::Sequence<uno::Type> aBaseTypes = SwXRedlineBaseClass::getTypes();
766 const uno::Type* pBaseTypes = aBaseTypes.getConstArray();
767 sal_Int32 nCurType = aTypes.getLength();
768 aTypes.realloc(aTypes.getLength() + aBaseTypes.getLength());
769 uno::Type* pTypes = aTypes.getArray();
770 for(sal_Int32 nType = 0; nType < aBaseTypes.getLength(); nType++)
771 pTypes[nCurType++] = pBaseTypes[nType];
772 return aTypes;
774 /* ---------------------------------------------------------------------------
776 ---------------------------------------------------------------------------*/
777 uno::Sequence<sal_Int8> SwXRedline::getImplementationId()
778 throw(uno::RuntimeException)
780 vos::OGuard aGuard(Application::GetSolarMutex());
781 static uno::Sequence< sal_Int8 > aId( 16 );
782 static sal_Bool bInit = sal_False;
783 if(!bInit)
785 rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
786 bInit = sal_True;
788 return aId;