1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sw.hxx" 26 27 #include <unoparagraph.hxx> 28 #include <cmdid.h> 29 #include <unomid.h> 30 #include <unoparaframeenum.hxx> 31 #include <unotext.hxx> 32 #include <unotextrange.hxx> 33 #include <unoport.hxx> 34 #include <unomap.hxx> 35 #include <unocrsr.hxx> 36 #include <unoprnms.hxx> 37 #include <unocrsrhelper.hxx> 38 #include <doc.hxx> 39 #include <ndtxt.hxx> 40 #include <vos/mutex.hxx> 41 #include <vcl/svapp.hxx> 42 #include <docsh.hxx> 43 44 #define _SVSTDARR_USHORTS 45 #define _SVSTDARR_USHORTSSORT 46 #include <svl/svstdarr.hxx> 47 48 #include <com/sun/star/beans/SetPropertyTolerantFailed.hpp> 49 #include <com/sun/star/beans/GetPropertyTolerantResult.hpp> 50 #include <com/sun/star/beans/TolerantPropertySetResultType.hpp> 51 #include <com/sun/star/beans/PropertyAttribute.hpp> 52 #include <com/sun/star/text/WrapTextMode.hpp> 53 #include <com/sun/star/text/TextContentAnchorType.hpp> 54 55 //UUUU 56 #include <swunohelper.hxx> 57 #include <svx/unobrushitemhelper.hxx> 58 #include <editeng/unoipset.hxx> 59 #include <svx/xflbstit.hxx> 60 #include <svx/xflbmtit.hxx> 61 #include <com/sun/star/drawing/BitmapMode.hpp> 62 63 using namespace ::com::sun::star; 64 using ::rtl::OUString; 65 66 /* -----------------------------01.12.00 18:09-------------------------------- 67 68 ---------------------------------------------------------------------------*/ 69 class SwParaSelection 70 { 71 SwCursor & m_rCursor; 72 public: 73 SwParaSelection(SwCursor & rCursor); 74 ~SwParaSelection(); 75 }; 76 77 SwParaSelection::SwParaSelection(SwCursor & rCursor) 78 : m_rCursor(rCursor) 79 { 80 if (m_rCursor.HasMark()) 81 { 82 m_rCursor.DeleteMark(); 83 } 84 // is it at the start? 85 if (m_rCursor.GetPoint()->nContent != 0) 86 { 87 m_rCursor.MovePara(fnParaCurr, fnParaStart); 88 } 89 // or at the end already? 90 if (m_rCursor.GetPoint()->nContent != m_rCursor.GetCntntNode()->Len()) 91 { 92 m_rCursor.SetMark(); 93 m_rCursor.MovePara(fnParaCurr, fnParaEnd); 94 } 95 } 96 97 SwParaSelection::~SwParaSelection() 98 { 99 if (m_rCursor.GetPoint()->nContent != 0) 100 { 101 m_rCursor.DeleteMark(); 102 m_rCursor.MovePara(fnParaCurr, fnParaStart); 103 } 104 } 105 106 107 /****************************************************************** 108 * forward declarations 109 ******************************************************************/ 110 111 beans::PropertyState lcl_SwXParagraph_getPropertyState( 112 const SwTxtNode& rTxtNode, 113 const SwAttrSet** ppSet, 114 const SfxItemPropertySimpleEntry& rEntry, 115 sal_Bool &rAttrSetFetched ) 116 throw (beans::UnknownPropertyException); 117 118 /****************************************************************** 119 * SwXParagraph 120 ******************************************************************/ 121 122 class SwXParagraph::Impl 123 : public SwClient 124 { 125 126 public: 127 SwXParagraph & m_rThis; 128 SwEventListenerContainer m_ListenerContainer; 129 SfxItemPropertySet const& m_rPropSet; 130 bool m_bIsDescriptor; 131 sal_Int32 m_nSelectionStartPos; 132 sal_Int32 m_nSelectionEndPos; 133 ::rtl::OUString m_sText; 134 uno::Reference<text::XText> m_xParentText; 135 136 Impl( SwXParagraph & rThis, 137 SwTxtNode *const pTxtNode = 0, 138 uno::Reference< text::XText > const & xParent = 0, 139 const sal_Int32 nSelStart = -1, const sal_Int32 nSelEnd = -1) 140 : SwClient(pTxtNode) 141 , m_rThis(rThis) 142 , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) 143 , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH)) 144 // #i111177# unxsols4 (Sun C++ 5.9 SunOS_sparc) may generate wrong code 145 , m_bIsDescriptor((0 == pTxtNode) ? true : false) 146 , m_nSelectionStartPos(nSelStart) 147 , m_nSelectionEndPos(nSelEnd) 148 , m_xParentText(xParent) 149 { 150 } 151 152 const SwTxtNode * GetTxtNode() const { 153 return static_cast<const SwTxtNode*>(GetRegisteredIn()); 154 } 155 SwTxtNode * GetTxtNode() { 156 return static_cast<SwTxtNode*>(GetRegisteredInNonConst()); 157 } 158 159 SwTxtNode & GetTxtNodeOrThrow() { 160 SwTxtNode *const pTxtNode( GetTxtNode() ); 161 if (!pTxtNode) { 162 throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( 163 "SwXParagraph: disposed or invalid")), 0); 164 } 165 return *pTxtNode; 166 } 167 168 bool IsDescriptor() const { return m_bIsDescriptor; } 169 170 void SetPropertyValues_Impl( 171 const uno::Sequence< ::rtl::OUString >& rPropertyNames, 172 const uno::Sequence< uno::Any >& rValues) 173 throw (beans::UnknownPropertyException, beans::PropertyVetoException, 174 lang::IllegalArgumentException, lang::WrappedTargetException, 175 uno::RuntimeException); 176 177 uno::Sequence< uno::Any > 178 GetPropertyValues_Impl( 179 const uno::Sequence< ::rtl::OUString >& rPropertyNames) 180 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 181 uno::RuntimeException); 182 183 //UUUU 184 void GetSinglePropertyValue_Impl( 185 const SfxItemPropertySimpleEntry& rEntry, 186 const SfxItemSet& rSet, 187 uno::Any& rAny ) const 188 throw(uno::RuntimeException); 189 190 uno::Sequence< beans::GetDirectPropertyTolerantResult > 191 GetPropertyValuesTolerant_Impl( 192 const uno::Sequence< ::rtl::OUString >& rPropertyNames, 193 bool bDirectValuesOnly) 194 throw (uno::RuntimeException); 195 protected: 196 // SwClient 197 virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew); 198 199 }; 200 201 /*-- 11.12.98 08:12:58--------------------------------------------------- 202 203 -----------------------------------------------------------------------*/ 204 void SwXParagraph::Impl::Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew ) 205 { 206 ClientModify(this, pOld, pNew); 207 if (!GetRegisteredIn()) 208 { 209 m_ListenerContainer.Disposing(); 210 } 211 } 212 213 /*-- 11.12.98 08:12:47--------------------------------------------------- 214 215 -----------------------------------------------------------------------*/ 216 SwXParagraph::SwXParagraph() 217 : m_pImpl( new SwXParagraph::Impl(*this) ) 218 { 219 } 220 221 /*-- 11.12.98 08:12:47--------------------------------------------------- 222 223 -----------------------------------------------------------------------*/ 224 SwXParagraph::SwXParagraph( 225 uno::Reference< text::XText > const & xParent, 226 SwTxtNode & rTxtNode, 227 const sal_Int32 nSelStart, const sal_Int32 nSelEnd) 228 : m_pImpl( 229 new SwXParagraph::Impl(*this, &rTxtNode, xParent, nSelStart, nSelEnd)) 230 { 231 } 232 233 /*-- 11.12.98 08:12:48--------------------------------------------------- 234 235 -----------------------------------------------------------------------*/ 236 SwXParagraph::~SwXParagraph() 237 { 238 } 239 240 const SwTxtNode * SwXParagraph::GetTxtNode() const 241 { 242 return m_pImpl->GetTxtNode(); 243 } 244 245 bool SwXParagraph::IsDescriptor() const 246 { 247 return m_pImpl->IsDescriptor(); 248 } 249 250 uno::Reference<text::XTextContent> 251 SwXParagraph::CreateXParagraph(SwDoc & rDoc, SwTxtNode& rTxtNode, 252 uno::Reference< text::XText> const& i_xParent, 253 const sal_Int32 nSelStart, const sal_Int32 nSelEnd) 254 { 255 // re-use existing SwXParagraph 256 // #i105557#: do not iterate over the registered clients: race condition 257 uno::Reference<text::XTextContent> xParagraph; 258 if ((-1 == nSelStart) && (-1 == nSelEnd)) // only use cache if no selection! 259 { 260 xParagraph.set(rTxtNode.GetXParagraph()); 261 } 262 if (xParagraph.is()) 263 { 264 return xParagraph; 265 } 266 267 // create new SwXParagraph 268 uno::Reference<text::XText> xParentText(i_xParent); 269 if (!xParentText.is()) 270 { 271 SwPosition Pos( rTxtNode ); 272 xParentText.set(::sw::CreateParentXText( rDoc, Pos )); 273 } 274 SwXParagraph *const pXPara( 275 new SwXParagraph(xParentText, rTxtNode, nSelStart, nSelEnd) ); 276 // this is why the constructor is private: need to acquire pXPara here 277 xParagraph.set(pXPara); 278 // in order to initialize the weak pointer cache in the core object 279 if ((-1 == nSelStart) && (-1 == nSelEnd)) 280 { 281 rTxtNode.SetXParagraph(xParagraph); 282 } 283 return xParagraph; 284 } 285 286 bool SwXParagraph::SelectPaM(SwPaM & rPaM) 287 { 288 SwTxtNode const*const pTxtNode( GetTxtNode() ); 289 290 if (!pTxtNode) 291 { 292 return false; 293 } 294 295 *rPaM.GetPoint() = SwPosition( *pTxtNode ); 296 // set selection to the whole paragraph 297 rPaM.SetMark(); 298 rPaM.GetMark()->nContent = pTxtNode->GetTxt().Len(); 299 return true; 300 } 301 302 /* -----------------------------13.03.00 12:15-------------------------------- 303 304 ---------------------------------------------------------------------------*/ 305 const uno::Sequence< sal_Int8 > & SwXParagraph::getUnoTunnelId() 306 { 307 static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); 308 return aSeq; 309 } 310 /* -----------------------------10.03.00 18:04-------------------------------- 311 312 ---------------------------------------------------------------------------*/ 313 sal_Int64 SAL_CALL 314 SwXParagraph::getSomething(const uno::Sequence< sal_Int8 >& rId) 315 throw (uno::RuntimeException) 316 { 317 return ::sw::UnoTunnelImpl<SwXParagraph>(rId, this); 318 } 319 320 /* -----------------------------06.04.00 16:37-------------------------------- 321 322 ---------------------------------------------------------------------------*/ 323 OUString SAL_CALL 324 SwXParagraph::getImplementationName() throw (uno::RuntimeException) 325 { 326 return C2U("SwXParagraph"); 327 } 328 /* -----------------------------06.04.00 16:37-------------------------------- 329 330 ---------------------------------------------------------------------------*/ 331 static char const*const g_ServicesParagraph[] = 332 { 333 "com.sun.star.text.TextContent", 334 "com.sun.star.text.Paragraph", 335 "com.sun.star.style.CharacterProperties", 336 "com.sun.star.style.CharacterPropertiesAsian", 337 "com.sun.star.style.CharacterPropertiesComplex", 338 "com.sun.star.style.ParagraphProperties", 339 "com.sun.star.style.ParagraphPropertiesAsian", 340 "com.sun.star.style.ParagraphPropertiesComplex", 341 }; 342 static const size_t g_nServicesParagraph( 343 sizeof(g_ServicesParagraph)/sizeof(g_ServicesParagraph[0])); 344 345 sal_Bool SAL_CALL 346 SwXParagraph::supportsService(const OUString& rServiceName) 347 throw (uno::RuntimeException) 348 { 349 return ::sw::SupportsServiceImpl( 350 g_nServicesParagraph, g_ServicesParagraph, rServiceName); 351 } 352 /* -----------------------------06.04.00 16:37-------------------------------- 353 354 ---------------------------------------------------------------------------*/ 355 uno::Sequence< OUString > SAL_CALL 356 SwXParagraph::getSupportedServiceNames() throw (uno::RuntimeException) 357 { 358 return ::sw::GetSupportedServiceNamesImpl( 359 g_nServicesParagraph, g_ServicesParagraph); 360 } 361 362 /* -----------------------------11.07.00 14:48-------------------------------- 363 364 ---------------------------------------------------------------------------*/ 365 void 366 SwXParagraph::attachToText(SwXText & rParent, SwTxtNode & rTxtNode) 367 { 368 DBG_ASSERT(m_pImpl->m_bIsDescriptor, "Paragraph is not a descriptor"); 369 if (m_pImpl->m_bIsDescriptor) 370 { 371 m_pImpl->m_bIsDescriptor = false; 372 rTxtNode.Add(m_pImpl.get()); 373 rTxtNode.SetXParagraph(uno::Reference<text::XTextContent>(this)); 374 m_pImpl->m_xParentText = &rParent; 375 if (m_pImpl->m_sText.getLength()) 376 { 377 try { setString(m_pImpl->m_sText); } 378 catch(...){} 379 m_pImpl->m_sText = OUString(); 380 } 381 } 382 } 383 384 /*-- 11.12.98 08:12:49--------------------------------------------------- 385 386 -----------------------------------------------------------------------*/ 387 uno::Reference< beans::XPropertySetInfo > SAL_CALL 388 SwXParagraph::getPropertySetInfo() 389 throw (uno::RuntimeException) 390 { 391 vos::OGuard g(Application::GetSolarMutex()); 392 393 static uno::Reference< beans::XPropertySetInfo > xRef = 394 m_pImpl->m_rPropSet.getPropertySetInfo(); 395 return xRef; 396 } 397 /*-- 11.12.98 08:12:49--------------------------------------------------- 398 399 -----------------------------------------------------------------------*/ 400 void SAL_CALL 401 SwXParagraph::setPropertyValue(const OUString& rPropertyName, 402 const uno::Any& rValue) 403 throw (beans::UnknownPropertyException, beans::PropertyVetoException, 404 lang::IllegalArgumentException, lang::WrappedTargetException, 405 uno::RuntimeException ) 406 { 407 vos::OGuard aGuard(Application::GetSolarMutex()); 408 uno::Sequence<OUString> aPropertyNames(1); 409 aPropertyNames.getArray()[0] = rPropertyName; 410 uno::Sequence<uno::Any> aValues(1); 411 aValues.getArray()[0] = rValue; 412 m_pImpl->SetPropertyValues_Impl( aPropertyNames, aValues ); 413 } 414 415 /*-- 11.12.98 08:12:49--------------------------------------------------- 416 417 -----------------------------------------------------------------------*/ 418 uno::Any 419 SwXParagraph::getPropertyValue(const OUString& rPropertyName) 420 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 421 uno::RuntimeException ) 422 { 423 vos::OGuard aGuard(Application::GetSolarMutex()); 424 uno::Sequence<OUString> aPropertyNames(1); 425 aPropertyNames.getArray()[0] = rPropertyName; 426 const uno::Sequence< uno::Any > aRet = 427 m_pImpl->GetPropertyValues_Impl(aPropertyNames); 428 return aRet.getConstArray()[0]; 429 } 430 /* -----------------------------02.04.01 11:43-------------------------------- 431 432 ---------------------------------------------------------------------------*/ 433 void SwXParagraph::Impl::SetPropertyValues_Impl( 434 const uno::Sequence< OUString >& rPropertyNames, 435 const uno::Sequence< uno::Any >& rValues ) 436 throw (beans::UnknownPropertyException, beans::PropertyVetoException, 437 lang::IllegalArgumentException, lang::WrappedTargetException, 438 uno::RuntimeException) 439 { 440 SwTxtNode & rTxtNode(GetTxtNodeOrThrow()); 441 442 SwPosition aPos( rTxtNode ); 443 SwCursor aCursor( aPos, 0, false ); 444 const OUString* pPropertyNames = rPropertyNames.getConstArray(); 445 const uno::Any* pValues = rValues.getConstArray(); 446 SfxItemPropertyMap const*const pMap = m_rPropSet.getPropertyMap(); 447 SwParaSelection aParaSel( aCursor ); 448 for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) 449 { 450 SfxItemPropertySimpleEntry const*const pEntry = 451 pMap->getByName( pPropertyNames[nProp] ); 452 if (!pEntry) 453 { 454 throw beans::UnknownPropertyException( 455 OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) 456 + pPropertyNames[nProp], 457 static_cast< cppu::OWeakObject * >(&m_rThis)); 458 } 459 if (pEntry->nFlags & beans::PropertyAttribute::READONLY) 460 { 461 throw beans::PropertyVetoException( 462 OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: ")) 463 + pPropertyNames[nProp], 464 static_cast< cppu::OWeakObject * >(&m_rThis)); 465 } 466 SwUnoCursorHelper::SetPropertyValue(aCursor, m_rPropSet, 467 pPropertyNames[nProp], pValues[nProp]); 468 } 469 } 470 471 void SAL_CALL SwXParagraph::setPropertyValues( 472 const uno::Sequence< OUString >& rPropertyNames, 473 const uno::Sequence< uno::Any >& rValues ) 474 throw (beans::PropertyVetoException, lang::IllegalArgumentException, 475 lang::WrappedTargetException, uno::RuntimeException) 476 { 477 vos::OGuard aGuard(Application::GetSolarMutex()); 478 479 // workaround for bad designed API 480 try 481 { 482 m_pImpl->SetPropertyValues_Impl( rPropertyNames, rValues ); 483 } 484 catch (beans::UnknownPropertyException &rException) 485 { 486 // wrap the original (here not allowed) exception in 487 // a lang::WrappedTargetException that gets thrown instead. 488 lang::WrappedTargetException aWExc; 489 aWExc.TargetException <<= rException; 490 throw aWExc; 491 } 492 } 493 494 /* -----------------------------02.04.01 11:43-------------------------------- 495 496 ---------------------------------------------------------------------------*/ 497 498 //UUUU Support for DrawingLayer FillStyles for GetPropertyValue() usages 499 void SwXParagraph::Impl::GetSinglePropertyValue_Impl( 500 const SfxItemPropertySimpleEntry& rEntry, 501 const SfxItemSet& rSet, 502 uno::Any& rAny ) const 503 throw(uno::RuntimeException) 504 { 505 bool bDone(false); 506 507 switch(rEntry.nWID) 508 { 509 case RES_BACKGROUND: 510 { 511 const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND)); 512 const sal_uInt8 nMemberId(rEntry.nMemberId & (~SFX_METRIC_ITEM)); 513 514 if(!aOriginalBrushItem.QueryValue(rAny, nMemberId)) 515 { 516 OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)"); 517 } 518 519 bDone = true; 520 break; 521 } 522 case OWN_ATTR_FILLBMP_MODE: 523 { 524 const XFillBmpStretchItem* pStretchItem = dynamic_cast< const XFillBmpStretchItem* >(&rSet.Get(XATTR_FILLBMP_STRETCH)); 525 const XFillBmpTileItem* pTileItem = dynamic_cast< const XFillBmpTileItem* >(&rSet.Get(XATTR_FILLBMP_TILE)); 526 527 if( pTileItem && pTileItem->GetValue() ) 528 { 529 rAny <<= drawing::BitmapMode_REPEAT; 530 } 531 else if( pStretchItem && pStretchItem->GetValue() ) 532 { 533 rAny <<= drawing::BitmapMode_STRETCH; 534 } 535 else 536 { 537 rAny <<= drawing::BitmapMode_NO_REPEAT; 538 } 539 540 bDone = true; 541 break; 542 } 543 default: break; 544 } 545 546 if(!bDone) 547 { 548 // fallback to standard get value implementation used before this helper was created 549 m_rPropSet.getPropertyValue(rEntry, rSet, rAny); 550 551 if(rEntry.pType && *(rEntry.pType) == ::getCppuType((const sal_Int16*)0) && *(rEntry.pType) != rAny.getValueType()) 552 { 553 // since the sfx uInt16 item now exports a sal_Int32, we may have to fix this here 554 sal_Int32 nValue(0); 555 556 rAny >>= nValue; 557 rAny <<= static_cast< sal_Int16 >(nValue); 558 } 559 560 //UUUU check for needed metric translation 561 if(rEntry.nMemberId & SFX_METRIC_ITEM) 562 { 563 bool bDoIt(true); 564 565 if(XATTR_FILLBMP_SIZEX == rEntry.nWID || XATTR_FILLBMP_SIZEY == rEntry.nWID) 566 { 567 // exception: If these ItemTypes are used, do not convert when these are negative 568 // since this means they are intended as percent values 569 sal_Int32 nValue = 0; 570 571 if(rAny >>= nValue) 572 { 573 bDoIt = nValue > 0; 574 } 575 } 576 577 if(bDoIt) 578 { 579 const SfxMapUnit eMapUnit(rSet.GetPool()->GetMetric(rEntry.nWID)); 580 581 if(eMapUnit != SFX_MAPUNIT_100TH_MM) 582 { 583 SvxUnoConvertToMM(eMapUnit, rAny); 584 } 585 } 586 } 587 } 588 } 589 590 uno::Sequence< uno::Any > SwXParagraph::Impl::GetPropertyValues_Impl( 591 const uno::Sequence< OUString > & rPropertyNames ) 592 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 593 uno::RuntimeException) 594 { 595 SwTxtNode & rTxtNode(GetTxtNodeOrThrow()); 596 597 uno::Sequence< uno::Any > aValues(rPropertyNames.getLength()); 598 SwPosition aPos( rTxtNode ); 599 SwPaM aPam( aPos ); 600 uno::Any* pValues = aValues.getArray(); 601 const OUString* pPropertyNames = rPropertyNames.getConstArray(); 602 SfxItemPropertyMap const*const pMap = m_rPropSet.getPropertyMap(); 603 const SwAttrSet& rAttrSet( rTxtNode.GetSwAttrSet() ); 604 for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) 605 { 606 SfxItemPropertySimpleEntry const*const pEntry = 607 pMap->getByName( pPropertyNames[nProp] ); 608 if (!pEntry) 609 { 610 throw beans::UnknownPropertyException( 611 OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) 612 + pPropertyNames[nProp], 613 static_cast< cppu::OWeakObject * >(&m_rThis)); 614 } 615 if (! ::sw::GetDefaultTextContentValue( 616 pValues[nProp], pPropertyNames[nProp], pEntry->nWID)) 617 { 618 beans::PropertyState eTemp; 619 const bool bDone = SwUnoCursorHelper::getCrsrPropertyValue( 620 *pEntry, aPam, &(pValues[nProp]), eTemp, &rTxtNode ); 621 if (!bDone) 622 { 623 //UUUU 624 GetSinglePropertyValue_Impl(*pEntry, rAttrSet, pValues[nProp]); 625 } 626 } 627 } 628 return aValues; 629 } 630 631 /* -----------------------------04.11.03 11:43-------------------------------- 632 633 ---------------------------------------------------------------------------*/ 634 uno::Sequence< uno::Any > SAL_CALL 635 SwXParagraph::getPropertyValues(const uno::Sequence< OUString >& rPropertyNames) 636 throw (uno::RuntimeException) 637 { 638 vos::OGuard aGuard(Application::GetSolarMutex()); 639 uno::Sequence< uno::Any > aValues; 640 641 // workaround for bad designed API 642 try 643 { 644 aValues = m_pImpl->GetPropertyValues_Impl( rPropertyNames ); 645 } 646 catch (beans::UnknownPropertyException &) 647 { 648 throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( 649 "Unknown property exception caught")), 650 static_cast<cppu::OWeakObject *>(this)); 651 } 652 catch (lang::WrappedTargetException &) 653 { 654 throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( 655 "WrappedTargetException caught")), 656 static_cast<cppu::OWeakObject *>(this)); 657 } 658 659 return aValues; 660 } 661 662 /* -----------------------------02.04.01 11:43-------------------------------- 663 664 ---------------------------------------------------------------------------*/ 665 void SAL_CALL SwXParagraph::addPropertiesChangeListener( 666 const uno::Sequence< OUString >& /*aPropertyNames*/, 667 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) 668 throw (uno::RuntimeException) 669 { 670 OSL_ENSURE(false, 671 "SwXParagraph::addPropertiesChangeListener(): not implemented"); 672 } 673 /* -----------------------------02.04.01 11:43-------------------------------- 674 675 ---------------------------------------------------------------------------*/ 676 void SAL_CALL SwXParagraph::removePropertiesChangeListener( 677 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) 678 throw (uno::RuntimeException) 679 { 680 OSL_ENSURE(false, 681 "SwXParagraph::removePropertiesChangeListener(): not implemented"); 682 } 683 /* -----------------------------02.04.01 11:43-------------------------------- 684 685 ---------------------------------------------------------------------------*/ 686 void SAL_CALL SwXParagraph::firePropertiesChangeEvent( 687 const uno::Sequence< OUString >& /*aPropertyNames*/, 688 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) 689 throw(uno::RuntimeException) 690 { 691 OSL_ENSURE(false, 692 "SwXParagraph::firePropertiesChangeEvent(): not implemented"); 693 } 694 /* -----------------------------25.09.03 11:09-------------------------------- 695 696 ---------------------------------------------------------------------------*/ 697 698 /* disabled for #i46921# */ 699 700 uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL 701 SwXParagraph::setPropertyValuesTolerant( 702 const uno::Sequence< OUString >& rPropertyNames, 703 const uno::Sequence< uno::Any >& rValues ) 704 throw (lang::IllegalArgumentException, uno::RuntimeException) 705 { 706 vos::OGuard aGuard( Application::GetSolarMutex() ); 707 708 if (rPropertyNames.getLength() != rValues.getLength()) 709 { 710 throw lang::IllegalArgumentException(); 711 } 712 713 SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); 714 715 //SwNode& rTxtNode = pUnoCrsr->GetPoint()->nNode.GetNode(); 716 //const SwAttrSet& rAttrSet = ((SwTxtNode&)rTxtNode).GetSwAttrSet(); 717 //sal_uInt16 nAttrCount = rAttrSet.Count(); 718 719 const sal_Int32 nProps = rPropertyNames.getLength(); 720 const OUString *pProp = rPropertyNames.getConstArray(); 721 722 //sal_Int32 nVals = rValues.getLength(); 723 const uno::Any *pValue = rValues.getConstArray(); 724 725 sal_Int32 nFailed = 0; 726 uno::Sequence< beans::SetPropertyTolerantFailed > aFailed( nProps ); 727 beans::SetPropertyTolerantFailed *pFailed = aFailed.getArray(); 728 729 // get entry to start with 730 SfxItemPropertyMap const*const pPropMap = 731 m_pImpl->m_rPropSet.getPropertyMap(); 732 733 OUString sTmp; 734 SwPosition aPos( rTxtNode ); 735 SwCursor aCursor( aPos, 0, false ); 736 SwParaSelection aParaSel( aCursor ); 737 for (sal_Int32 i = 0; i < nProps; ++i) 738 { 739 try 740 { 741 pFailed[ nFailed ].Name = pProp[i]; 742 743 SfxItemPropertySimpleEntry const*const pEntry = 744 pPropMap->getByName( pProp[i] ); 745 if (!pEntry) 746 { 747 pFailed[ nFailed++ ].Result = 748 beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; 749 } 750 else 751 { 752 // set property value 753 // (compare to SwXParagraph::setPropertyValues) 754 if (pEntry->nFlags & beans::PropertyAttribute::READONLY) 755 { 756 pFailed[ nFailed++ ].Result = 757 beans::TolerantPropertySetResultType::PROPERTY_VETO; 758 } 759 else 760 { 761 SwUnoCursorHelper::SetPropertyValue( 762 aCursor, m_pImpl->m_rPropSet, pProp[i], pValue[i]); 763 } 764 } 765 } 766 catch (beans::UnknownPropertyException &) 767 { 768 // should not occur because property was searched for before 769 DBG_ERROR( "unexpected exception caught" ); 770 pFailed[ nFailed++ ].Result = 771 beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; 772 } 773 catch (lang::IllegalArgumentException &) 774 { 775 pFailed[ nFailed++ ].Result = 776 beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT; 777 } 778 catch (beans::PropertyVetoException &) 779 { 780 pFailed[ nFailed++ ].Result = 781 beans::TolerantPropertySetResultType::PROPERTY_VETO; 782 } 783 catch (lang::WrappedTargetException &) 784 { 785 pFailed[ nFailed++ ].Result = 786 beans::TolerantPropertySetResultType::WRAPPED_TARGET; 787 } 788 } 789 790 aFailed.realloc( nFailed ); 791 return aFailed; 792 } 793 794 795 uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL 796 SwXParagraph::getPropertyValuesTolerant( 797 const uno::Sequence< OUString >& rPropertyNames ) 798 throw (uno::RuntimeException) 799 { 800 vos::OGuard aGuard( Application::GetSolarMutex() ); 801 802 uno::Sequence< beans::GetDirectPropertyTolerantResult > aTmpRes( 803 m_pImpl->GetPropertyValuesTolerant_Impl( rPropertyNames, false ) ); 804 const beans::GetDirectPropertyTolerantResult *pTmpRes = 805 aTmpRes.getConstArray(); 806 807 // copy temporary result to final result type 808 const sal_Int32 nLen = aTmpRes.getLength(); 809 uno::Sequence< beans::GetPropertyTolerantResult > aRes( nLen ); 810 beans::GetPropertyTolerantResult *pRes = aRes.getArray(); 811 for (sal_Int32 i = 0; i < nLen; i++) 812 { 813 *pRes++ = *pTmpRes++; 814 } 815 return aRes; 816 } 817 818 819 uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL 820 SwXParagraph::getDirectPropertyValuesTolerant( 821 const uno::Sequence< OUString >& rPropertyNames ) 822 throw (uno::RuntimeException) 823 { 824 vos::OGuard aGuard( Application::GetSolarMutex() ); 825 826 return m_pImpl->GetPropertyValuesTolerant_Impl( rPropertyNames, true ); 827 } 828 829 830 uno::Sequence< beans::GetDirectPropertyTolerantResult > 831 SwXParagraph::Impl::GetPropertyValuesTolerant_Impl( 832 const uno::Sequence< OUString >& rPropertyNames, 833 bool bDirectValuesOnly ) 834 throw (uno::RuntimeException) 835 { 836 vos::OGuard aGuard( Application::GetSolarMutex() ); 837 838 SwTxtNode & rTxtNode(GetTxtNodeOrThrow()); 839 840 // #i46786# Use SwAttrSet pointer for determining the state. 841 // Use the value SwAttrSet (from the paragraph OR the style) 842 // for determining the actual value(s). 843 const SwAttrSet* pAttrSet = rTxtNode.GetpSwAttrSet(); 844 const SwAttrSet& rValueAttrSet = rTxtNode.GetSwAttrSet(); 845 846 sal_Int32 nProps = rPropertyNames.getLength(); 847 const OUString *pProp = rPropertyNames.getConstArray(); 848 849 uno::Sequence< beans::GetDirectPropertyTolerantResult > aResult( nProps ); 850 beans::GetDirectPropertyTolerantResult *pResult = aResult.getArray(); 851 sal_Int32 nIdx = 0; 852 853 // get entry to start with 854 SfxItemPropertyMap const*const pPropMap = m_rPropSet.getPropertyMap(); 855 856 for (sal_Int32 i = 0; i < nProps; ++i) 857 { 858 DBG_ASSERT( nIdx < nProps, "index out ouf bounds" ); 859 beans::GetDirectPropertyTolerantResult &rResult = pResult[nIdx]; 860 861 try 862 { 863 rResult.Name = pProp[i]; 864 865 SfxItemPropertySimpleEntry const*const pEntry = 866 pPropMap->getByName( pProp[i] ); 867 if (!pEntry) // property available? 868 { 869 rResult.Result = 870 beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; 871 } 872 else 873 { 874 // get property state 875 // (compare to SwXParagraph::getPropertyState) 876 sal_Bool bAttrSetFetched = sal_True; 877 beans::PropertyState eState = lcl_SwXParagraph_getPropertyState( 878 rTxtNode, &pAttrSet, *pEntry, bAttrSetFetched ); 879 rResult.State = eState; 880 881 // if (bDirectValuesOnly && PropertyState_DIRECT_VALUE != eState) 882 // rResult.Result = beans::TolerantPropertySetResultType::NO_DIRECT_VALUE; 883 // else 884 rResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_FAILURE; 885 if (!bDirectValuesOnly || 886 (beans::PropertyState_DIRECT_VALUE == eState)) 887 { 888 // get property value 889 // (compare to SwXParagraph::getPropertyValue(s)) 890 uno::Any aValue; 891 if (! ::sw::GetDefaultTextContentValue( 892 aValue, pProp[i], pEntry->nWID ) ) 893 { 894 SwPosition aPos( rTxtNode ); 895 SwPaM aPam( aPos ); 896 // handle properties that are not part of the attribute 897 // and thus only pretend to be paragraph attributes 898 beans::PropertyState eTemp; 899 const bool bDone = 900 SwUnoCursorHelper::getCrsrPropertyValue( 901 *pEntry, aPam, &aValue, eTemp, &rTxtNode ); 902 903 // if not found try the real paragraph attributes... 904 if (!bDone) 905 { 906 //UUUU 907 GetSinglePropertyValue_Impl(*pEntry, rValueAttrSet, aValue); 908 } 909 } 910 911 rResult.Value = aValue; 912 rResult.Result = beans::TolerantPropertySetResultType::SUCCESS; 913 914 nIdx++; 915 } 916 // this assertion should never occur! 917 DBG_ASSERT( nIdx < 1 || pResult[nIdx - 1].Result != beans::TolerantPropertySetResultType::UNKNOWN_FAILURE, 918 "unknown failure while retrieving property" ); 919 920 } 921 } 922 catch (beans::UnknownPropertyException &) 923 { 924 // should not occur because property was searched for before 925 DBG_ERROR( "unexpected exception caught" ); 926 rResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; 927 } 928 catch (lang::IllegalArgumentException &) 929 { 930 rResult.Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT; 931 } 932 catch (beans::PropertyVetoException &) 933 { 934 rResult.Result = beans::TolerantPropertySetResultType::PROPERTY_VETO; 935 } 936 catch (lang::WrappedTargetException &) 937 { 938 rResult.Result = beans::TolerantPropertySetResultType::WRAPPED_TARGET; 939 } 940 } 941 942 // resize to actually used size 943 aResult.realloc( nIdx ); 944 945 return aResult; 946 } 947 948 /* -----------------------------12.09.00 11:09-------------------------------- 949 950 ---------------------------------------------------------------------------*/ 951 bool ::sw::GetDefaultTextContentValue( 952 uno::Any& rAny, const OUString& rPropertyName, sal_uInt16 nWID) 953 { 954 if(!nWID) 955 { 956 if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ANCHOR_TYPE))) 957 nWID = FN_UNO_ANCHOR_TYPE; 958 else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ANCHOR_TYPES))) 959 nWID = FN_UNO_ANCHOR_TYPES; 960 else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_TEXT_WRAP))) 961 nWID = FN_UNO_TEXT_WRAP; 962 else 963 return sal_False; 964 } 965 966 switch(nWID) 967 { 968 case FN_UNO_TEXT_WRAP: rAny <<= text::WrapTextMode_NONE; break; 969 case FN_UNO_ANCHOR_TYPE: rAny <<= text::TextContentAnchorType_AT_PARAGRAPH; break; 970 case FN_UNO_ANCHOR_TYPES: 971 { uno::Sequence<text::TextContentAnchorType> aTypes(1); 972 text::TextContentAnchorType* pArray = aTypes.getArray(); 973 pArray[0] = text::TextContentAnchorType_AT_PARAGRAPH; 974 rAny.setValue(&aTypes, ::getCppuType((uno::Sequence<text::TextContentAnchorType>*)0)); 975 } 976 break; 977 default: 978 return sal_False; 979 } 980 return sal_True; 981 } 982 /*-- 11.12.98 08:12:50--------------------------------------------------- 983 984 -----------------------------------------------------------------------*/ 985 void SAL_CALL 986 SwXParagraph::addPropertyChangeListener( 987 const ::rtl::OUString& /*rPropertyName*/, 988 const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) 989 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 990 uno::RuntimeException) 991 { 992 OSL_ENSURE(false, 993 "SwXParagraph::addPropertyChangeListener(): not implemented"); 994 } 995 996 /*-- 11.12.98 08:12:50--------------------------------------------------- 997 998 -----------------------------------------------------------------------*/ 999 void SAL_CALL 1000 SwXParagraph::removePropertyChangeListener( 1001 const ::rtl::OUString& /*rPropertyName*/, 1002 const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) 1003 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 1004 uno::RuntimeException) 1005 { 1006 OSL_ENSURE(false, 1007 "SwXParagraph::removePropertyChangeListener(): not implemented"); 1008 } 1009 1010 /*-- 11.12.98 08:12:50--------------------------------------------------- 1011 1012 -----------------------------------------------------------------------*/ 1013 void SAL_CALL 1014 SwXParagraph::addVetoableChangeListener( 1015 const ::rtl::OUString& /*rPropertyName*/, 1016 const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) 1017 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 1018 uno::RuntimeException) 1019 { 1020 OSL_ENSURE(false, 1021 "SwXParagraph::addVetoableChangeListener(): not implemented"); 1022 } 1023 1024 /*-- 11.12.98 08:12:51--------------------------------------------------- 1025 1026 -----------------------------------------------------------------------*/ 1027 void SAL_CALL 1028 SwXParagraph::removeVetoableChangeListener( 1029 const ::rtl::OUString& /*rPropertyName*/, 1030 const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) 1031 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 1032 uno::RuntimeException) 1033 { 1034 OSL_ENSURE(false, 1035 "SwXParagraph::removeVetoableChangeListener(): not implemented"); 1036 } 1037 1038 //----------------------------------------------------------------------------- 1039 beans::PropertyState lcl_SwXParagraph_getPropertyState( 1040 // SwUnoCrsr& rUnoCrsr, 1041 const SwTxtNode& rTxtNode, 1042 const SwAttrSet** ppSet, 1043 const SfxItemPropertySimpleEntry& rEntry, 1044 sal_Bool &rAttrSetFetched) 1045 throw (beans::UnknownPropertyException) 1046 { 1047 beans::PropertyState eRet(beans::PropertyState_DEFAULT_VALUE); 1048 1049 if(!(*ppSet) && !rAttrSetFetched) 1050 { 1051 (*ppSet) = rTxtNode.GetpSwAttrSet(); 1052 rAttrSetFetched = sal_True; 1053 } 1054 1055 SwPosition aPos(rTxtNode); 1056 SwPaM aPam(aPos); 1057 bool bDone(false); 1058 1059 switch(rEntry.nWID) 1060 { 1061 case FN_UNO_NUM_RULES: 1062 { 1063 // if numbering is set, return it; else do nothing 1064 SwUnoCursorHelper::getNumberingProperty(aPam,eRet,NULL); 1065 bDone = true; 1066 break; 1067 } 1068 case FN_UNO_ANCHOR_TYPES: 1069 { 1070 bDone = true; 1071 break; 1072 } 1073 case RES_ANCHOR: 1074 { 1075 bDone = (MID_SURROUND_SURROUNDTYPE == rEntry.nMemberId); 1076 break; 1077 } 1078 case RES_SURROUND: 1079 { 1080 bDone = (MID_ANCHOR_ANCHORTYPE == rEntry.nMemberId); 1081 break; 1082 } 1083 case FN_UNO_PARA_STYLE: 1084 case FN_UNO_PARA_CONDITIONAL_STYLE_NAME: 1085 { 1086 SwFmtColl* pFmt = SwUnoCursorHelper::GetCurTxtFmtColl(aPam,rEntry.nWID == FN_UNO_PARA_CONDITIONAL_STYLE_NAME); 1087 eRet = pFmt ? beans::PropertyState_DIRECT_VALUE : beans::PropertyState_AMBIGUOUS_VALUE; 1088 bDone = true; 1089 break; 1090 } 1091 case FN_UNO_PAGE_STYLE: 1092 { 1093 String sVal; 1094 SwUnoCursorHelper::GetCurPageStyle(aPam,sVal); 1095 eRet = sVal.Len() ? beans::PropertyState_DIRECT_VALUE : beans::PropertyState_AMBIGUOUS_VALUE; 1096 bDone = true; 1097 break; 1098 } 1099 1100 //UUUU DrawingLayer PropertyStyle support 1101 case OWN_ATTR_FILLBMP_MODE: 1102 { 1103 if(*ppSet) 1104 { 1105 if(SFX_ITEM_SET == (*ppSet)->GetItemState(XATTR_FILLBMP_STRETCH, false) 1106 || SFX_ITEM_SET == (*ppSet)->GetItemState(XATTR_FILLBMP_TILE, false)) 1107 { 1108 eRet = beans::PropertyState_DIRECT_VALUE; 1109 } 1110 else 1111 { 1112 eRet = beans::PropertyState_AMBIGUOUS_VALUE; 1113 } 1114 1115 bDone = true; 1116 } 1117 break; 1118 } 1119 case RES_BACKGROUND: 1120 { 1121 if(*ppSet) 1122 { 1123 if(SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(**ppSet)) 1124 { 1125 eRet = beans::PropertyState_DIRECT_VALUE; 1126 bDone = true; 1127 } 1128 } 1129 break; 1130 } 1131 } 1132 1133 if(!bDone) 1134 { 1135 if((*ppSet) && SFX_ITEM_SET == (*ppSet)->GetItemState(rEntry.nWID,sal_False)) 1136 { 1137 eRet = beans::PropertyState_DIRECT_VALUE; 1138 } 1139 } 1140 1141 return eRet; 1142 } 1143 1144 /*-- 05.03.99 11:37:30--------------------------------------------------- 1145 1146 -----------------------------------------------------------------------*/ 1147 beans::PropertyState SAL_CALL 1148 SwXParagraph::getPropertyState(const OUString& rPropertyName) 1149 throw (beans::UnknownPropertyException, uno::RuntimeException) 1150 { 1151 vos::OGuard aGuard(Application::GetSolarMutex()); 1152 1153 SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); 1154 1155 const SwAttrSet* pSet = 0; 1156 SfxItemPropertySimpleEntry const*const pEntry = 1157 m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); 1158 if (!pEntry) 1159 { 1160 throw beans::UnknownPropertyException( 1161 OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) 1162 + rPropertyName, 1163 static_cast<cppu::OWeakObject *>(this)); 1164 } 1165 sal_Bool bDummy = sal_False; 1166 const beans::PropertyState eRet = 1167 lcl_SwXParagraph_getPropertyState(rTxtNode, &pSet, *pEntry, bDummy); 1168 return eRet; 1169 } 1170 /*-- 05.03.99 11:37:32--------------------------------------------------- 1171 1172 -----------------------------------------------------------------------*/ 1173 1174 uno::Sequence< beans::PropertyState > SAL_CALL 1175 SwXParagraph::getPropertyStates( 1176 const uno::Sequence< OUString >& PropertyNames) 1177 throw (beans::UnknownPropertyException, uno::RuntimeException) 1178 { 1179 vos::OGuard aGuard(Application::GetSolarMutex()); 1180 1181 SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); 1182 1183 const OUString* pNames = PropertyNames.getConstArray(); 1184 uno::Sequence< beans::PropertyState > aRet(PropertyNames.getLength()); 1185 beans::PropertyState* pStates = aRet.getArray(); 1186 SfxItemPropertyMap const*const pMap = m_pImpl->m_rPropSet.getPropertyMap(); 1187 const SwAttrSet* pSet = 0; 1188 sal_Bool bAttrSetFetched = sal_False; 1189 1190 for (sal_Int32 i = 0, nEnd = PropertyNames.getLength(); i < nEnd; 1191 ++i, ++pStates, ++pNames) 1192 { 1193 SfxItemPropertySimpleEntry const*const pEntry = 1194 pMap->getByName( *pNames ); 1195 if (!pEntry) 1196 { 1197 throw beans::UnknownPropertyException( 1198 OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) 1199 + *pNames, 1200 static_cast<cppu::OWeakObject *>(this)); 1201 } 1202 1203 if (bAttrSetFetched && !pSet && isATR(pEntry->nWID)) 1204 { 1205 *pStates = beans::PropertyState_DEFAULT_VALUE; 1206 } 1207 else 1208 { 1209 *pStates = lcl_SwXParagraph_getPropertyState( 1210 rTxtNode, &pSet, *pEntry, bAttrSetFetched ); 1211 } 1212 } 1213 1214 return aRet; 1215 } 1216 1217 /*-- 05.03.99 11:37:33--------------------------------------------------- 1218 1219 -----------------------------------------------------------------------*/ 1220 void SAL_CALL 1221 SwXParagraph::setPropertyToDefault(const OUString& rPropertyName) 1222 throw (beans::UnknownPropertyException, uno::RuntimeException) 1223 { 1224 vos::OGuard aGuard(Application::GetSolarMutex()); 1225 1226 SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); 1227 1228 SwPosition aPos( rTxtNode ); 1229 SwCursor aCursor( aPos, 0, false ); 1230 if (rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_ANCHOR_TYPE)) || 1231 rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_ANCHOR_TYPES)) || 1232 rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_TEXT_WRAP))) 1233 { 1234 return; 1235 } 1236 1237 // select paragraph 1238 SwParaSelection aParaSel( aCursor ); 1239 SfxItemPropertySimpleEntry const*const pEntry = 1240 m_pImpl->m_rPropSet.getPropertyMap()->getByName( rPropertyName ); 1241 if (!pEntry) 1242 { 1243 throw beans::UnknownPropertyException( 1244 OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) 1245 + rPropertyName, 1246 static_cast<cppu::OWeakObject *>(this)); 1247 } 1248 1249 if (pEntry->nFlags & beans::PropertyAttribute::READONLY) 1250 { 1251 throw uno::RuntimeException( 1252 OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: ")) 1253 + rPropertyName, 1254 static_cast<cppu::OWeakObject *>(this)); 1255 } 1256 1257 const bool bBelowFrmAtrEnd(pEntry->nWID < RES_FRMATR_END); 1258 const bool bDrawingLayerRange(XATTR_FILL_FIRST <= pEntry->nWID && XATTR_FILL_LAST >= pEntry->nWID); 1259 1260 if(bBelowFrmAtrEnd || bDrawingLayerRange) 1261 { 1262 SvUShortsSort aWhichIds; 1263 1264 //UUUU For FillBitmapMode two IDs have to be reset (!) 1265 if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID) 1266 { 1267 aWhichIds.Insert(XATTR_FILLBMP_STRETCH); 1268 aWhichIds.Insert(XATTR_FILLBMP_TILE); 1269 } 1270 else 1271 { 1272 aWhichIds.Insert(pEntry->nWID); 1273 } 1274 1275 if (pEntry->nWID < RES_PARATR_BEGIN) 1276 { 1277 aCursor.GetDoc()->ResetAttrs(aCursor, sal_True, &aWhichIds); 1278 } 1279 else 1280 { 1281 // for paragraph attributes the selection must be extended 1282 // to paragraph boundaries 1283 SwPosition aStart( *aCursor.Start() ); 1284 SwPosition aEnd ( *aCursor.End() ); 1285 ::std::auto_ptr<SwUnoCrsr> pTemp( aCursor.GetDoc()->CreateUnoCrsr(aStart, sal_False) ); 1286 1287 if(!SwUnoCursorHelper::IsStartOfPara(*pTemp)) 1288 { 1289 pTemp->MovePara(fnParaCurr, fnParaStart); 1290 } 1291 1292 pTemp->SetMark(); 1293 *pTemp->GetPoint() = aEnd; 1294 //pTemp->Exchange(); 1295 1296 SwUnoCursorHelper::SelectPam(*pTemp, true); 1297 1298 if (!SwUnoCursorHelper::IsEndOfPara(*pTemp)) 1299 { 1300 pTemp->MovePara(fnParaCurr, fnParaEnd); 1301 } 1302 1303 pTemp->GetDoc()->ResetAttrs(*pTemp, sal_True, &aWhichIds); 1304 } 1305 } 1306 else 1307 { 1308 SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, aCursor); 1309 } 1310 } 1311 1312 /*-- 05.03.99 11:37:33--------------------------------------------------- 1313 1314 -----------------------------------------------------------------------*/ 1315 uno::Any SAL_CALL 1316 SwXParagraph::getPropertyDefault(const OUString& rPropertyName) 1317 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 1318 uno::RuntimeException) 1319 { 1320 vos::OGuard g(Application::GetSolarMutex()); 1321 1322 SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); 1323 1324 uno::Any aRet; 1325 if (::sw::GetDefaultTextContentValue(aRet, rPropertyName)) 1326 { 1327 return aRet; 1328 } 1329 1330 SfxItemPropertySimpleEntry const*const pEntry = 1331 m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); 1332 if (!pEntry) 1333 { 1334 throw beans::UnknownPropertyException( 1335 OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) 1336 + rPropertyName, 1337 static_cast<cppu::OWeakObject *>(this)); 1338 } 1339 1340 const bool bBelowFrmAtrEnd(pEntry->nWID < RES_FRMATR_END); 1341 const bool bDrawingLayerRange(XATTR_FILL_FIRST <= pEntry->nWID && XATTR_FILL_LAST >= pEntry->nWID); 1342 1343 if(bBelowFrmAtrEnd || bDrawingLayerRange) 1344 { 1345 const SfxPoolItem& rDefItem = rTxtNode.GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID); 1346 1347 rDefItem.QueryValue(aRet, pEntry->nMemberId); 1348 } 1349 1350 return aRet; 1351 } 1352 1353 /*-- 11.12.98 08:12:51--------------------------------------------------- 1354 1355 -----------------------------------------------------------------------*/ 1356 void SAL_CALL 1357 SwXParagraph::attach(const uno::Reference< text::XTextRange > & /*xTextRange*/) 1358 throw (lang::IllegalArgumentException, uno::RuntimeException) 1359 { 1360 vos::OGuard aGuard(Application::GetSolarMutex()); 1361 // SwXParagraph will only created in order to be inserted by 1362 // 'insertTextContentBefore' or 'insertTextContentAfter' therefore 1363 // they cannot be attached 1364 throw uno::RuntimeException(); 1365 } 1366 1367 /*-- 11.12.98 08:12:51--------------------------------------------------- 1368 1369 -----------------------------------------------------------------------*/ 1370 uno::Reference< text::XTextRange > SAL_CALL 1371 SwXParagraph::getAnchor() throw (uno::RuntimeException) 1372 { 1373 vos::OGuard aGuard(Application::GetSolarMutex()); 1374 1375 SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); 1376 1377 SwPosition aPos( rTxtNode ); 1378 SwCursor aCursor( aPos, 0, false ); 1379 // select paragraph 1380 SwParaSelection aParaSel( aCursor ); 1381 const uno::Reference< text::XTextRange > xRet = 1382 new SwXTextRange(aCursor, m_pImpl->m_xParentText); 1383 return xRet; 1384 } 1385 1386 /*-- 11.12.98 08:12:52--------------------------------------------------- 1387 1388 -----------------------------------------------------------------------*/ 1389 void SAL_CALL SwXParagraph::dispose() throw (uno::RuntimeException) 1390 { 1391 vos::OGuard aGuard(Application::GetSolarMutex()); 1392 1393 SwTxtNode *const pTxtNode( m_pImpl->GetTxtNode() ); 1394 if (pTxtNode) 1395 { 1396 SwCursor aCursor( SwPosition( *pTxtNode ), 0, false ); 1397 // select paragraph 1398 { 1399 SwParaSelection aParaSel( aCursor ); 1400 pTxtNode->GetDoc()->DelFullPara(aCursor); 1401 } 1402 m_pImpl->m_ListenerContainer.Disposing(); 1403 } 1404 } 1405 1406 /*-- 11.12.98 08:12:52--------------------------------------------------- 1407 1408 -----------------------------------------------------------------------*/ 1409 void SAL_CALL SwXParagraph::addEventListener( 1410 const uno::Reference< lang::XEventListener > & xListener) 1411 throw (uno::RuntimeException) 1412 { 1413 vos::OGuard g(Application::GetSolarMutex()); 1414 1415 if (!m_pImpl->GetTxtNode()) 1416 { 1417 throw uno::RuntimeException(); 1418 } 1419 m_pImpl->m_ListenerContainer.AddListener(xListener); 1420 } 1421 /*-- 11.12.98 08:12:53--------------------------------------------------- 1422 1423 -----------------------------------------------------------------------*/ 1424 void SAL_CALL SwXParagraph::removeEventListener( 1425 const uno::Reference< lang::XEventListener > & xListener) 1426 throw (uno::RuntimeException) 1427 { 1428 vos::OGuard g(Application::GetSolarMutex()); 1429 1430 if (!m_pImpl->GetTxtNode() || 1431 !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) 1432 { 1433 throw uno::RuntimeException(); 1434 } 1435 } 1436 1437 /*-- 11.12.98 08:12:53--------------------------------------------------- 1438 1439 -----------------------------------------------------------------------*/ 1440 uno::Reference< container::XEnumeration > SAL_CALL 1441 SwXParagraph::createEnumeration() throw (uno::RuntimeException) 1442 { 1443 vos::OGuard aGuard(Application::GetSolarMutex()); 1444 1445 SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); 1446 1447 SwPosition aPos( rTxtNode ); 1448 SwPaM aPam ( aPos ); 1449 const uno::Reference< container::XEnumeration > xRef = 1450 new SwXTextPortionEnumeration(aPam, m_pImpl->m_xParentText, 1451 m_pImpl->m_nSelectionStartPos, m_pImpl->m_nSelectionEndPos); 1452 return xRef; 1453 } 1454 1455 /*-- 11.12.98 08:12:54--------------------------------------------------- 1456 1457 -----------------------------------------------------------------------*/ 1458 uno::Type SAL_CALL SwXParagraph::getElementType() throw (uno::RuntimeException) 1459 { 1460 return text::XTextRange::static_type(); 1461 } 1462 /*-- 11.12.98 08:12:54--------------------------------------------------- 1463 1464 -----------------------------------------------------------------------*/ 1465 sal_Bool SAL_CALL SwXParagraph::hasElements() throw (uno::RuntimeException) 1466 { 1467 vos::OGuard aGuard(Application::GetSolarMutex()); 1468 return (GetTxtNode()) ? sal_True : sal_False; 1469 } 1470 1471 /*-- 11.12.98 08:12:55--------------------------------------------------- 1472 1473 -----------------------------------------------------------------------*/ 1474 uno::Reference< text::XText > SAL_CALL 1475 SwXParagraph::getText() throw (uno::RuntimeException) 1476 { 1477 vos::OGuard g(Application::GetSolarMutex()); 1478 1479 return m_pImpl->m_xParentText; 1480 } 1481 1482 /*-- 11.12.98 08:12:55--------------------------------------------------- 1483 1484 -----------------------------------------------------------------------*/ 1485 uno::Reference< text::XTextRange > SAL_CALL 1486 SwXParagraph::getStart() throw (uno::RuntimeException) 1487 { 1488 vos::OGuard aGuard(Application::GetSolarMutex()); 1489 1490 SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); 1491 1492 SwPosition aPos( rTxtNode ); 1493 SwCursor aCursor( aPos, 0, false ); 1494 SwParaSelection aParaSel( aCursor ); 1495 SwPaM aPam( *aCursor.Start() ); 1496 uno::Reference< text::XText > xParent = getText(); 1497 const uno::Reference< text::XTextRange > xRet = 1498 new SwXTextRange(aPam, xParent); 1499 return xRet; 1500 } 1501 /*-- 11.12.98 08:12:56--------------------------------------------------- 1502 1503 -----------------------------------------------------------------------*/ 1504 uno::Reference< text::XTextRange > SAL_CALL 1505 SwXParagraph::getEnd() throw (uno::RuntimeException) 1506 { 1507 vos::OGuard aGuard(Application::GetSolarMutex()); 1508 1509 SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); 1510 1511 SwPosition aPos( rTxtNode ); 1512 SwCursor aCursor( aPos, 0, false ); 1513 SwParaSelection aParaSel( aCursor ); 1514 SwPaM aPam( *aCursor.End() ); 1515 uno::Reference< text::XText > xParent = getText(); 1516 const uno::Reference< text::XTextRange > xRet = 1517 new SwXTextRange(aPam, xParent); 1518 return xRet; 1519 } 1520 1521 /*-- 11.12.98 08:12:56--------------------------------------------------- 1522 1523 -----------------------------------------------------------------------*/ 1524 OUString SAL_CALL SwXParagraph::getString() throw (uno::RuntimeException) 1525 { 1526 vos::OGuard aGuard(Application::GetSolarMutex()); 1527 OUString aRet; 1528 SwTxtNode const*const pTxtNode( GetTxtNode() ); 1529 if (pTxtNode) 1530 { 1531 SwPosition aPos( *pTxtNode ); 1532 SwCursor aCursor( aPos, 0, false ); 1533 SwParaSelection aParaSel( aCursor ); 1534 SwUnoCursorHelper::GetTextFromPam(aCursor, aRet); 1535 } 1536 else if (m_pImpl->IsDescriptor()) 1537 { 1538 aRet = m_pImpl->m_sText; 1539 } 1540 else 1541 { 1542 throw uno::RuntimeException(); 1543 } 1544 return aRet; 1545 } 1546 /*-- 11.12.98 08:12:57--------------------------------------------------- 1547 1548 -----------------------------------------------------------------------*/ 1549 void SAL_CALL SwXParagraph::setString(const OUString& aString) 1550 throw (uno::RuntimeException) 1551 { 1552 vos::OGuard aGuard(Application::GetSolarMutex()); 1553 1554 SwTxtNode const*const pTxtNode( GetTxtNode() ); 1555 if (pTxtNode) 1556 { 1557 SwPosition aPos( *pTxtNode ); 1558 SwCursor aCursor( aPos, 0, false ); 1559 if (!SwUnoCursorHelper::IsStartOfPara(aCursor)) { 1560 aCursor.MovePara(fnParaCurr, fnParaStart); 1561 } 1562 SwUnoCursorHelper::SelectPam(aCursor, true); 1563 if (pTxtNode->GetTxt().Len()) { 1564 aCursor.MovePara(fnParaCurr, fnParaEnd); 1565 } 1566 SwUnoCursorHelper::SetString(aCursor, aString); 1567 SwUnoCursorHelper::SelectPam(aCursor, false); 1568 } 1569 else if (m_pImpl->IsDescriptor()) 1570 { 1571 m_pImpl->m_sText = aString; 1572 } 1573 else 1574 { 1575 throw uno::RuntimeException(); 1576 } 1577 } 1578 1579 /* -----------------23.03.99 12:49------------------- 1580 * 1581 * --------------------------------------------------*/ 1582 uno::Reference< container::XEnumeration > SAL_CALL 1583 SwXParagraph::createContentEnumeration(const OUString& rServiceName) 1584 throw (uno::RuntimeException) 1585 { 1586 vos::OGuard g(Application::GetSolarMutex()); 1587 1588 if (!rServiceName.equalsAscii("com.sun.star.text.TextContent")) 1589 { 1590 throw uno::RuntimeException(); 1591 } 1592 1593 SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); 1594 1595 SwPosition aPos( rTxtNode ); 1596 SwPaM aPam( aPos ); 1597 uno::Reference< container::XEnumeration > xRet = 1598 new SwXParaFrameEnumeration(aPam, PARAFRAME_PORTION_PARAGRAPH); 1599 return xRet; 1600 } 1601 /* -----------------23.03.99 12:49------------------- 1602 * 1603 * --------------------------------------------------*/ 1604 uno::Sequence< OUString > SAL_CALL 1605 SwXParagraph::getAvailableServiceNames() throw (uno::RuntimeException) 1606 { 1607 uno::Sequence< OUString > aRet(1); 1608 OUString* pArray = aRet.getArray(); 1609 pArray[0] = C2U("com.sun.star.text.TextContent"); 1610 return aRet; 1611 } 1612 1613 1614 // MetadatableMixin 1615 ::sfx2::Metadatable* SwXParagraph::GetCoreObject() 1616 { 1617 SwTxtNode *const pTxtNode( m_pImpl->GetTxtNode() ); 1618 return pTxtNode; 1619 } 1620 1621 uno::Reference<frame::XModel> SwXParagraph::GetModel() 1622 { 1623 SwTxtNode *const pTxtNode( m_pImpl->GetTxtNode() ); 1624 if (pTxtNode) 1625 { 1626 SwDocShell const*const pShell( pTxtNode->GetDoc()->GetDocShell() ); 1627 return (pShell) ? pShell->GetModel() : 0; 1628 } 1629 return 0; 1630 } 1631 1632