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 <com/sun/star/beans/PropertyAttribute.hpp> 28 #include <com/sun/star/container/XIndexReplace.hpp> 29 #include <com/sun/star/frame/XModel.hpp> 30 #include <com/sun/star/text/ChapterFormat.hpp> 31 #include <com/sun/star/text/ReferenceFieldPart.hpp> 32 #include <com/sun/star/text/BibliographyDataField.hpp> 33 #include <com/sun/star/text/XTextDocument.hpp> 34 35 #include <tools/debug.hxx> 36 #include <vos/mutex.hxx> 37 #include <vcl/svapp.hxx> 38 #include <editeng/unolingu.hxx> 39 #include <com/sun/star/text/ChapterFormat.hpp> 40 #include <com/sun/star/text/ReferenceFieldPart.hpp> 41 #include <com/sun/star/text/BibliographyDataField.hpp> 42 #include <com/sun/star/frame/XModel.hpp> 43 #include <com/sun/star/text/XTextDocument.hpp> 44 #include <com/sun/star/beans/PropertyAttribute.hpp> 45 #include <hints.hxx> 46 #include <cmdid.h> 47 #include <swtypes.hxx> 48 #include <shellres.hxx> 49 #include <viewsh.hxx> 50 #include <doc.hxx> 51 #include <docary.hxx> 52 #include <poolfmt.hxx> 53 #include <poolfmt.hrc> 54 #include <pagedesc.hxx> 55 #include <fmtcntnt.hxx> 56 #include <unomap.hxx> 57 #include <unotextrange.hxx> 58 #include <unotextcursor.hxx> 59 #include <unosection.hxx> 60 #include <doctxm.hxx> 61 #include <txttxmrk.hxx> 62 #include <unocrsr.hxx> 63 #include <unostyle.hxx> 64 #include <ndtxt.hxx> 65 #include <unoidx.hxx> 66 #include <docsh.hxx> 67 #include <chpfld.hxx> 68 #include <SwStyleNameMapper.hxx> 69 #include <unoevtlstnr.hxx> 70 71 72 using namespace ::com::sun::star; 73 using ::rtl::OUString; 74 75 //----------------------------------------------------------------------------- 76 static OUString 77 lcl_AnyToString(uno::Any const& rVal) throw (lang::IllegalArgumentException) 78 { 79 OUString sRet; 80 if(!(rVal >>= sRet)) 81 { 82 throw lang::IllegalArgumentException(); 83 } 84 return sRet; 85 } 86 //----------------------------------------------------------------------------- 87 static sal_Int16 88 lcl_AnyToInt16(uno::Any const& rVal) throw (lang::IllegalArgumentException) 89 { 90 sal_Int16 nRet = 0; 91 if(!(rVal >>= nRet)) 92 { 93 throw lang::IllegalArgumentException(); 94 } 95 return nRet; 96 } 97 //----------------------------------------------------------------------------- 98 static sal_Bool 99 lcl_AnyToBool(uno::Any const& rVal) throw (lang::IllegalArgumentException) 100 { 101 sal_Bool bRet = sal_False; 102 if(!(rVal >>= bRet)) 103 { 104 throw lang::IllegalArgumentException(); 105 } 106 return bRet; 107 } 108 109 static void 110 lcl_AnyToBitMask(uno::Any const& rValue, 111 sal_uInt16 & rBitMask, const sal_uInt16 nBit) 112 throw (lang::IllegalArgumentException) 113 { 114 rBitMask = lcl_AnyToBool(rValue) 115 ? (rBitMask | nBit) 116 : (rBitMask & ~nBit); 117 } 118 static void 119 lcl_BitMaskToAny(uno::Any & o_rValue, 120 const sal_uInt16 nBitMask, const sal_uInt16 nBit) 121 { 122 const sal_Bool bRet = 0 != (nBitMask & nBit); 123 o_rValue <<= bRet; 124 } 125 126 //----------------------------------------------------------------------------- 127 static void 128 lcl_ReAssignTOXType(SwDoc* pDoc, SwTOXBase& rTOXBase, const OUString& rNewName) 129 { 130 const sal_uInt16 nUserCount = pDoc->GetTOXTypeCount( TOX_USER ); 131 const SwTOXType* pNewType = 0; 132 for(sal_uInt16 nUser = 0; nUser < nUserCount; nUser++) 133 { 134 const SwTOXType* pType = pDoc->GetTOXType( TOX_USER, nUser ); 135 if(pType->GetTypeName().Equals((String)rNewName)) 136 { 137 pNewType = pType; 138 break; 139 } 140 } 141 if(!pNewType) 142 { 143 SwTOXType aNewType(TOX_USER, rNewName); 144 pNewType = pDoc->InsertTOXType( aNewType ); 145 } 146 147 rTOXBase.RegisterToTOXType( *((SwTOXType*)pNewType) ); 148 } 149 //----------------------------------------------------------------------------- 150 static const char cUserDefined[] = "User-Defined"; 151 static const char cUserSuffix[] = " (user)"; 152 #define USER_LEN 12 153 #define USER_AND_SUFFIXLEN 19 154 155 void lcl_ConvertTOUNameToProgrammaticName(OUString& rTmp) 156 { 157 ShellResource* pShellRes = ViewShell::GetShellRes(); 158 159 if(rTmp.equals(pShellRes->aTOXUserName)) 160 { 161 rTmp = OUString(C2U(cUserDefined)); 162 } 163 // if the version is not English but the alternative index's name is 164 // "User-Defined" a " (user)" is appended 165 else if(rTmp.equalsAscii(cUserDefined)) 166 { 167 rTmp += C2U(cUserSuffix); 168 } 169 } 170 //----------------------------------------------------------------------------- 171 static void 172 lcl_ConvertTOUNameToUserName(OUString& rTmp) 173 { 174 ShellResource* pShellRes = ViewShell::GetShellRes(); 175 if(rTmp.equalsAscii(cUserDefined)) 176 { 177 rTmp = pShellRes->aTOXUserName; 178 } 179 else if(!pShellRes->aTOXUserName.EqualsAscii(cUserDefined) && 180 USER_AND_SUFFIXLEN == rTmp.getLength()) 181 { 182 //make sure that in non-English versions the " (user)" suffix is removed 183 if (rTmp.matchAsciiL(cUserDefined, sizeof(cUserDefined)) && 184 rTmp.matchAsciiL(cUserSuffix, sizeof(cUserSuffix), USER_LEN)) 185 { 186 rTmp = C2U(cUserDefined); 187 } 188 } 189 } 190 191 /* -----------------13.09.99 16:39------------------- 192 193 --------------------------------------------------*/ 194 typedef ::cppu::WeakImplHelper2 195 < lang::XServiceInfo 196 , container::XIndexReplace 197 > SwXDocumentIndexStyleAccess_Base; 198 199 class SwXDocumentIndex::StyleAccess_Impl 200 : public SwXDocumentIndexStyleAccess_Base 201 { 202 203 private: 204 /// can be destroyed threadsafely, so no UnoImplPtr here 205 ::rtl::Reference<SwXDocumentIndex> m_xParent; 206 207 virtual ~StyleAccess_Impl(); 208 209 public: 210 StyleAccess_Impl(SwXDocumentIndex& rParentIdx); 211 212 // XServiceInfo 213 virtual ::rtl::OUString SAL_CALL getImplementationName() 214 throw (uno::RuntimeException); 215 virtual sal_Bool SAL_CALL 216 supportsService(const ::rtl::OUString& rServiceName) 217 throw (uno::RuntimeException); 218 virtual uno::Sequence< ::rtl::OUString > SAL_CALL 219 getSupportedServiceNames() throw (uno::RuntimeException); 220 221 // XElementAccess 222 virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException); 223 virtual sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException); 224 225 // XIndexAccess 226 virtual sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException); 227 virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) 228 throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, 229 uno::RuntimeException); 230 231 // XIndexReplace 232 virtual void SAL_CALL 233 replaceByIndex(sal_Int32 Index, const uno::Any& rElement) 234 throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, 235 lang::WrappedTargetException, uno::RuntimeException); 236 237 }; 238 239 /* -----------------13.09.99 16:39------------------- 240 241 --------------------------------------------------*/ 242 typedef ::cppu::WeakImplHelper2 243 < lang::XServiceInfo 244 , container::XIndexReplace 245 > SwXDocumentIndexTokenAccess_Base; 246 247 class SwXDocumentIndex::TokenAccess_Impl 248 : public SwXDocumentIndexTokenAccess_Base 249 { 250 251 private: 252 /// can be destroyed threadsafely, so no UnoImplPtr here 253 ::rtl::Reference<SwXDocumentIndex> m_xParent; 254 255 virtual ~TokenAccess_Impl(); 256 257 public: 258 259 TokenAccess_Impl(SwXDocumentIndex& rParentIdx); 260 261 // XServiceInfo 262 virtual ::rtl::OUString SAL_CALL getImplementationName() 263 throw (uno::RuntimeException); 264 virtual sal_Bool SAL_CALL 265 supportsService(const ::rtl::OUString& rServiceName) 266 throw (uno::RuntimeException); 267 virtual uno::Sequence< ::rtl::OUString > SAL_CALL 268 getSupportedServiceNames() throw (uno::RuntimeException); 269 270 // XElementAccess 271 virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException); 272 virtual sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException); 273 274 // XIndexAccess 275 virtual sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException); 276 virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) 277 throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, 278 uno::RuntimeException); 279 280 // XIndexReplace 281 virtual void SAL_CALL 282 replaceByIndex(sal_Int32 Index, const uno::Any& rElement) 283 throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, 284 lang::WrappedTargetException, uno::RuntimeException); 285 286 }; 287 288 289 /****************************************************************** 290 * SwXDocumentIndex 291 ******************************************************************/ 292 293 /* -----------------20.06.98 11:06------------------- 294 * 295 * --------------------------------------------------*/ 296 class SwDocIndexDescriptorProperties_Impl 297 { 298 private: 299 ::std::auto_ptr<SwTOXBase> m_pTOXBase; 300 OUString m_sUserTOXTypeName; 301 302 public: 303 SwDocIndexDescriptorProperties_Impl(SwTOXType const*const pType); 304 305 SwTOXBase & GetTOXBase() { return *m_pTOXBase; } 306 const OUString& GetTypeName() const { return m_sUserTOXTypeName; } 307 void SetTypeName(const OUString& rSet) { m_sUserTOXTypeName = rSet; } 308 }; 309 /* -----------------20.06.98 11:41------------------- 310 * 311 * --------------------------------------------------*/ 312 SwDocIndexDescriptorProperties_Impl::SwDocIndexDescriptorProperties_Impl( 313 SwTOXType const*const pType) 314 { 315 SwForm aForm(pType->GetType()); 316 m_pTOXBase.reset(new SwTOXBase(pType, aForm, 317 nsSwTOXElement::TOX_MARK, pType->GetTypeName())); 318 if(pType->GetType() == TOX_CONTENT || pType->GetType() == TOX_USER) 319 { 320 m_pTOXBase->SetLevel(MAXLEVEL); 321 } 322 m_sUserTOXTypeName = pType->GetTypeName(); 323 } 324 325 static sal_uInt16 326 lcl_TypeToPropertyMap_Index(const TOXTypes eType) 327 { 328 switch (eType) 329 { 330 case TOX_INDEX: return PROPERTY_MAP_INDEX_IDX; 331 case TOX_CONTENT: return PROPERTY_MAP_INDEX_CNTNT; 332 case TOX_TABLES: return PROPERTY_MAP_INDEX_TABLES; 333 case TOX_ILLUSTRATIONS: return PROPERTY_MAP_INDEX_ILLUSTRATIONS; 334 case TOX_OBJECTS: return PROPERTY_MAP_INDEX_OBJECTS; 335 case TOX_AUTHORITIES: return PROPERTY_MAP_BIBLIOGRAPHY; 336 //case TOX_USER: 337 default: 338 return PROPERTY_MAP_INDEX_USER; 339 } 340 } 341 342 class SwXDocumentIndex::Impl 343 : public SwClient 344 { 345 346 public: 347 348 SfxItemPropertySet const& m_rPropSet; 349 const TOXTypes m_eTOXType; 350 SwEventListenerContainer m_ListenerContainer; 351 bool m_bIsDescriptor; 352 SwDoc * m_pDoc; 353 ::std::auto_ptr<SwDocIndexDescriptorProperties_Impl> m_pProps; 354 uno::WeakReference<container::XIndexReplace> m_wStyleAccess; 355 uno::WeakReference<container::XIndexReplace> m_wTokenAccess; 356 357 Impl( SwXDocumentIndex & rThis, 358 SwDoc & rDoc, 359 const TOXTypes eType, 360 SwTOXBaseSection const*const pBaseSection) 361 : SwClient((pBaseSection) ? pBaseSection->GetFmt() : 0) 362 , m_rPropSet( 363 *aSwMapProvider.GetPropertySet(lcl_TypeToPropertyMap_Index(eType))) 364 , m_eTOXType(eType) 365 , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) 366 // #i111177# unxsols4 (Sun C++ 5.9 SunOS_sparc) may generate wrong code 367 , m_bIsDescriptor((0 == pBaseSection) ? true : false) 368 , m_pDoc(&rDoc) 369 , m_pProps((m_bIsDescriptor) 370 ? new SwDocIndexDescriptorProperties_Impl(rDoc.GetTOXType(eType, 0)) 371 : 0) 372 { 373 } 374 375 SwSectionFmt * GetSectionFmt() const { 376 return static_cast<SwSectionFmt *>( 377 const_cast<SwModify *>(GetRegisteredIn())); 378 } 379 380 SwTOXBase & GetTOXSectionOrThrow() const 381 { 382 SwSectionFmt *const pSectionFmt(GetSectionFmt()); 383 SwTOXBase *const pTOXSection( (m_bIsDescriptor) 384 ? &m_pProps->GetTOXBase() 385 : ((pSectionFmt) 386 ? static_cast<SwTOXBaseSection*>(pSectionFmt->GetSection()) 387 : 0)); 388 if (!pTOXSection) 389 { 390 throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( 391 "SwXDocumentIndex: disposed or invalid")), 0); 392 } 393 return *pTOXSection; 394 } 395 396 sal_Int32 GetFormMax() const 397 { 398 SwTOXBase & rSection( GetTOXSectionOrThrow() ); 399 return (m_bIsDescriptor) 400 ? SwForm::GetFormMaxLevel(m_eTOXType) 401 : rSection.GetTOXForm().GetFormMax(); 402 } 403 protected: 404 // SwClient 405 virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew); 406 407 }; 408 409 /*-- 14.12.98 09:35:07--------------------------------------------------- 410 411 -----------------------------------------------------------------------*/ 412 void SwXDocumentIndex::Impl::Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) 413 { 414 ClientModify(this, pOld, pNew); 415 416 if (!GetRegisteredIn()) 417 { 418 m_ListenerContainer.Disposing(); 419 } 420 } 421 422 /*-- 14.12.98 09:35:03--------------------------------------------------- 423 424 -----------------------------------------------------------------------*/ 425 SwXDocumentIndex::SwXDocumentIndex( 426 SwTOXBaseSection const& rBaseSection, SwDoc & rDoc) 427 : m_pImpl( new SwXDocumentIndex::Impl( *this, 428 rDoc, rBaseSection.SwTOXBase::GetType(), & rBaseSection) ) 429 { 430 } 431 /* -----------------15.01.99 14:59------------------- 432 * 433 * --------------------------------------------------*/ 434 SwXDocumentIndex::SwXDocumentIndex(const TOXTypes eType, SwDoc& rDoc) 435 : m_pImpl( new SwXDocumentIndex::Impl( *this, rDoc, eType, 0) ) 436 { 437 } 438 439 /*-- 14.12.98 09:35:04--------------------------------------------------- 440 441 -----------------------------------------------------------------------*/ 442 SwXDocumentIndex::~SwXDocumentIndex() 443 { 444 } 445 446 uno::Reference<text::XDocumentIndex> 447 SwXDocumentIndex::CreateXDocumentIndex( 448 SwDoc & rDoc, SwTOXBaseSection const& rSection) 449 { 450 // re-use existing SwXDocumentIndex 451 // #i105557#: do not iterate over the registered clients: race condition 452 SwSectionFmt *const pFmt = rSection.GetFmt(); 453 uno::Reference<text::XDocumentIndex> xIndex(pFmt->GetXObject(), 454 uno::UNO_QUERY); 455 if (!xIndex.is()) 456 { 457 SwXDocumentIndex *const pIndex(new SwXDocumentIndex(rSection, rDoc)); 458 xIndex.set(pIndex); 459 pFmt->SetXObject(uno::Reference<uno::XInterface>(xIndex)); 460 } 461 return xIndex; 462 } 463 464 /* -----------------------------10.03.00 18:02-------------------------------- 465 466 ---------------------------------------------------------------------------*/ 467 const uno::Sequence< sal_Int8 > & SwXDocumentIndex::getUnoTunnelId() 468 { 469 static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); 470 return aSeq; 471 } 472 /* -----------------------------10.03.00 18:04-------------------------------- 473 474 ---------------------------------------------------------------------------*/ 475 sal_Int64 SAL_CALL 476 SwXDocumentIndex::getSomething(const uno::Sequence< sal_Int8 >& rId) 477 throw (uno::RuntimeException) 478 { 479 return ::sw::UnoTunnelImpl<SwXDocumentIndex>(rId, this); 480 } 481 482 /* -----------------------------06.04.00 15:01-------------------------------- 483 484 ---------------------------------------------------------------------------*/ 485 OUString SAL_CALL 486 SwXDocumentIndex::getImplementationName() throw (uno::RuntimeException) 487 { 488 return C2U("SwXDocumentIndex"); 489 } 490 /* -----------------------------06.04.00 15:01-------------------------------- 491 492 ---------------------------------------------------------------------------*/ 493 sal_Bool SAL_CALL 494 SwXDocumentIndex::supportsService(const OUString& rServiceName) 495 throw (uno::RuntimeException) 496 { 497 vos::OGuard g(Application::GetSolarMutex()); 498 499 return C2U("com.sun.star.text.BaseIndex") == rServiceName 500 || ((TOX_INDEX == m_pImpl->m_eTOXType) && 501 rServiceName.equalsAscii("com.sun.star.text.DocumentIndex")) 502 || ((TOX_CONTENT == m_pImpl->m_eTOXType) && 503 rServiceName.equalsAscii("com.sun.star.text.ContentIndex")) 504 || ((TOX_USER == m_pImpl->m_eTOXType) && 505 rServiceName.equalsAscii("com.sun.star.text.UserDefinedIndex")) 506 || ((TOX_ILLUSTRATIONS == m_pImpl->m_eTOXType) && 507 rServiceName.equalsAscii("com.sun.star.text.IllustrationsIndex")) 508 || ((TOX_TABLES == m_pImpl->m_eTOXType) && 509 rServiceName.equalsAscii("com.sun.star.text.TableIndex")) 510 || ((TOX_OBJECTS == m_pImpl->m_eTOXType) && 511 rServiceName.equalsAscii("com.sun.star.text.ObjectIndex")) 512 || ((TOX_AUTHORITIES == m_pImpl->m_eTOXType) && 513 rServiceName.equalsAscii("com.sun.star.text.Bibliography")); 514 } 515 /* -----------------------------06.04.00 15:01-------------------------------- 516 517 ---------------------------------------------------------------------------*/ 518 uno::Sequence< OUString > SAL_CALL 519 SwXDocumentIndex::getSupportedServiceNames() throw (uno::RuntimeException) 520 { 521 vos::OGuard g(Application::GetSolarMutex()); 522 523 uno::Sequence< OUString > aRet(2); 524 OUString* pArray = aRet.getArray(); 525 pArray[0] = C2U("com.sun.star.text.BaseIndex"); 526 switch (m_pImpl->m_eTOXType) 527 { 528 case TOX_INDEX: 529 pArray[1] = C2U("com.sun.star.text.DocumentIndex"); 530 break; 531 case TOX_CONTENT: 532 pArray[1] = C2U("com.sun.star.text.ContentIndex"); 533 break; 534 case TOX_TABLES: 535 pArray[1] = C2U("com.sun.star.text.TableIndex"); 536 break; 537 case TOX_ILLUSTRATIONS: 538 pArray[1] = C2U("com.sun.star.text.IllustrationsIndex"); 539 break; 540 case TOX_OBJECTS: 541 pArray[1] = C2U("com.sun.star.text.ObjectIndex"); 542 break; 543 case TOX_AUTHORITIES: 544 pArray[1] = C2U("com.sun.star.text.Bibliography"); 545 break; 546 //case TOX_USER: 547 default: 548 pArray[1] = C2U("com.sun.star.text.UserDefinedIndex"); 549 } 550 return aRet; 551 } 552 553 /*-- 14.12.98 09:35:05--------------------------------------------------- 554 555 -----------------------------------------------------------------------*/ 556 OUString SAL_CALL SwXDocumentIndex::getServiceName() 557 throw (uno::RuntimeException) 558 { 559 vos::OGuard g(Application::GetSolarMutex()); 560 561 sal_uInt16 nObjectType = SW_SERVICE_TYPE_INDEX; 562 switch (m_pImpl->m_eTOXType) 563 { 564 // case TOX_INDEX: break; 565 case TOX_USER: nObjectType = SW_SERVICE_USER_INDEX; 566 break; 567 case TOX_CONTENT: nObjectType = SW_SERVICE_CONTENT_INDEX; 568 break; 569 case TOX_ILLUSTRATIONS: nObjectType = SW_SERVICE_INDEX_ILLUSTRATIONS; 570 break; 571 case TOX_OBJECTS: nObjectType = SW_SERVICE_INDEX_OBJECTS; 572 break; 573 case TOX_TABLES: nObjectType = SW_SERVICE_INDEX_TABLES; 574 break; 575 case TOX_AUTHORITIES: nObjectType = SW_SERVICE_INDEX_BIBLIOGRAPHY; 576 break; 577 default: 578 break; 579 } 580 return SwXServiceProvider::GetProviderName(nObjectType); 581 } 582 583 /*-- 14.12.98 09:35:05--------------------------------------------------- 584 585 -----------------------------------------------------------------------*/ 586 void SAL_CALL SwXDocumentIndex::update() throw (uno::RuntimeException) 587 { 588 vos::OGuard aGuard(Application::GetSolarMutex()); 589 590 SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt(); 591 SwTOXBaseSection *const pTOXBase = (pFmt) ? 592 static_cast<SwTOXBaseSection*>(pFmt->GetSection()) : 0; 593 if(!pTOXBase) 594 { 595 throw uno::RuntimeException(); 596 } 597 pTOXBase->Update(); 598 // page numbers 599 pTOXBase->UpdatePageNum(); 600 } 601 602 /*-- 14.12.98 09:35:05--------------------------------------------------- 603 604 -----------------------------------------------------------------------*/ 605 uno::Reference< beans::XPropertySetInfo > SAL_CALL 606 SwXDocumentIndex::getPropertySetInfo() throw (uno::RuntimeException) 607 { 608 vos::OGuard g(Application::GetSolarMutex()); 609 610 const uno::Reference< beans::XPropertySetInfo > xRef = 611 m_pImpl->m_rPropSet.getPropertySetInfo(); 612 return xRef; 613 } 614 615 /*-- 14.12.98 09:35:05--------------------------------------------------- 616 617 -----------------------------------------------------------------------*/ 618 void SAL_CALL 619 SwXDocumentIndex::setPropertyValue( 620 const OUString& rPropertyName, const uno::Any& rValue) 621 throw (beans::UnknownPropertyException, beans::PropertyVetoException, 622 lang::IllegalArgumentException, lang::WrappedTargetException, 623 uno::RuntimeException) 624 { 625 vos::OGuard aGuard(Application::GetSolarMutex()); 626 627 SfxItemPropertySimpleEntry const*const pEntry = 628 m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); 629 if (!pEntry) 630 { 631 throw beans::UnknownPropertyException( 632 OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) 633 + rPropertyName, 634 static_cast<cppu::OWeakObject *>(this)); 635 } 636 if (pEntry->nFlags & beans::PropertyAttribute::READONLY) 637 { 638 throw beans::PropertyVetoException( 639 OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: " )) 640 + rPropertyName, 641 static_cast<cppu::OWeakObject *>(this)); 642 } 643 644 SwSectionFmt *const pSectionFmt(m_pImpl->GetSectionFmt()); 645 SwTOXBase & rTOXBase( m_pImpl->GetTOXSectionOrThrow() ); 646 647 sal_uInt16 nCreate = rTOXBase.GetCreateType(); 648 sal_uInt16 nTOIOptions = 0; 649 sal_uInt16 nOLEOptions = rTOXBase.GetOLEOptions(); 650 const TOXTypes eTxBaseType = rTOXBase.GetTOXType()->GetType(); 651 if (eTxBaseType == TOX_INDEX) 652 { 653 nTOIOptions = rTOXBase.GetOptions(); 654 } 655 SwForm aForm(rTOXBase.GetTOXForm()); 656 sal_Bool bForm = sal_False; 657 switch (pEntry->nWID) 658 { 659 case WID_IDX_TITLE: 660 { 661 OUString sNewName; 662 if (!(rValue >>= sNewName)) 663 { 664 throw lang::IllegalArgumentException(); 665 } 666 rTOXBase.SetTitle(sNewName); 667 } 668 break; 669 case WID_IDX_NAME: 670 { 671 OUString sNewName; 672 if (!(rValue >>= sNewName)) 673 { 674 throw lang::IllegalArgumentException(); 675 } 676 rTOXBase.SetTOXName(sNewName); 677 } 678 break; 679 case WID_USER_IDX_NAME: 680 { 681 OUString sNewName; 682 if (!(rValue >>= sNewName)) 683 { 684 throw lang::IllegalArgumentException(); 685 } 686 lcl_ConvertTOUNameToUserName(sNewName); 687 DBG_ASSERT(TOX_USER == eTxBaseType, 688 "tox type name can only be changed for user indexes"); 689 if (pSectionFmt) 690 { 691 OUString sTmp = rTOXBase.GetTOXType()->GetTypeName(); 692 if (sTmp != sNewName) 693 { 694 lcl_ReAssignTOXType(pSectionFmt->GetDoc(), 695 rTOXBase, sNewName); 696 } 697 } 698 else 699 { 700 m_pImpl->m_pProps->SetTypeName(sNewName); 701 } 702 } 703 break; 704 case WID_IDX_LOCALE: 705 { 706 lang::Locale aLocale; 707 if (!(rValue>>= aLocale)) 708 { 709 throw lang::IllegalArgumentException(); 710 } 711 rTOXBase.SetLanguage(SvxLocaleToLanguage(aLocale)); 712 } 713 break; 714 case WID_IDX_SORT_ALGORITHM: 715 { 716 OUString sTmp; 717 if (!(rValue >>= sTmp)) 718 { 719 throw lang::IllegalArgumentException(); 720 } 721 rTOXBase.SetSortAlgorithm(sTmp); 722 } 723 break; 724 case WID_LEVEL: 725 { 726 rTOXBase.SetLevel(lcl_AnyToInt16(rValue)); 727 } 728 break; 729 case WID_CREATE_FROM_MARKS: 730 lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_MARK); 731 break; 732 case WID_CREATE_FROM_OUTLINE: 733 lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_OUTLINELEVEL); 734 break; 735 // case WID_PARAGRAPH_STYLE_NAMES :DBG_ERROR("not implemented") 736 // break; 737 case WID_CREATE_FROM_CHAPTER: 738 rTOXBase.SetFromChapter(lcl_AnyToBool(rValue)); 739 break; 740 case WID_CREATE_FROM_LABELS: 741 rTOXBase.SetFromObjectNames(! lcl_AnyToBool(rValue)); 742 break; 743 case WID_PROTECTED: 744 { 745 sal_Bool bSet = lcl_AnyToBool(rValue); 746 rTOXBase.SetProtected(bSet); 747 if (pSectionFmt) 748 { 749 static_cast<SwTOXBaseSection &>(rTOXBase).SetProtect(bSet); 750 } 751 } 752 break; 753 case WID_USE_ALPHABETICAL_SEPARATORS: 754 lcl_AnyToBitMask(rValue, nTOIOptions, 755 nsSwTOIOptions::TOI_ALPHA_DELIMITTER); 756 break; 757 case WID_USE_KEY_AS_ENTRY: 758 lcl_AnyToBitMask(rValue, nTOIOptions, 759 nsSwTOIOptions::TOI_KEY_AS_ENTRY); 760 break; 761 case WID_USE_COMBINED_ENTRIES: 762 lcl_AnyToBitMask(rValue, nTOIOptions, 763 nsSwTOIOptions::TOI_SAME_ENTRY); 764 break; 765 case WID_IS_CASE_SENSITIVE: 766 lcl_AnyToBitMask(rValue, nTOIOptions, 767 nsSwTOIOptions::TOI_CASE_SENSITIVE); 768 break; 769 case WID_USE_P_P: 770 lcl_AnyToBitMask(rValue, nTOIOptions, nsSwTOIOptions::TOI_FF); 771 break; 772 case WID_USE_DASH: 773 lcl_AnyToBitMask(rValue, nTOIOptions, nsSwTOIOptions::TOI_DASH); 774 break; 775 case WID_USE_UPPER_CASE: 776 lcl_AnyToBitMask(rValue, nTOIOptions, 777 nsSwTOIOptions::TOI_INITIAL_CAPS); 778 break; 779 case WID_IS_COMMA_SEPARATED: 780 bForm = sal_True; 781 aForm.SetCommaSeparated(lcl_AnyToBool(rValue)); 782 break; 783 case WID_LABEL_CATEGORY: 784 { 785 // convert file-format/API/external programmatic english name 786 // to internal UI name before usage 787 String aName( SwStyleNameMapper::GetSpecialExtraUIName( 788 lcl_AnyToString(rValue) ) ); 789 rTOXBase.SetSequenceName( aName ); 790 } 791 break; 792 case WID_LABEL_DISPLAY_TYPE: 793 { 794 const sal_Int16 nVal = lcl_AnyToInt16(rValue); 795 sal_uInt16 nSet = CAPTION_COMPLETE; 796 switch (nVal) 797 { 798 case text::ReferenceFieldPart::TEXT: 799 nSet = CAPTION_COMPLETE; 800 break; 801 case text::ReferenceFieldPart::CATEGORY_AND_NUMBER: 802 nSet = CAPTION_NUMBER; 803 break; 804 case text::ReferenceFieldPart::ONLY_CAPTION: 805 nSet = CAPTION_TEXT; 806 break; 807 default: 808 throw lang::IllegalArgumentException(); 809 } 810 rTOXBase.SetCaptionDisplay(static_cast<SwCaptionDisplay>(nSet)); 811 } 812 break; 813 case WID_USE_LEVEL_FROM_SOURCE: 814 rTOXBase.SetLevelFromChapter(lcl_AnyToBool(rValue)); 815 break; 816 case WID_MAIN_ENTRY_CHARACTER_STYLE_NAME: 817 { 818 String aString; 819 SwStyleNameMapper::FillUIName(lcl_AnyToString(rValue), 820 aString, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True); 821 rTOXBase.SetMainEntryCharStyle( aString ); 822 } 823 break; 824 case WID_CREATE_FROM_TABLES: 825 lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_TABLE); 826 break; 827 case WID_CREATE_FROM_TEXT_FRAMES: 828 lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_FRAME); 829 break; 830 case WID_CREATE_FROM_GRAPHIC_OBJECTS: 831 lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_GRAPHIC); 832 break; 833 case WID_CREATE_FROM_EMBEDDED_OBJECTS: 834 lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_OLE); 835 break; 836 case WID_CREATE_FROM_STAR_MATH: 837 lcl_AnyToBitMask(rValue, nOLEOptions, nsSwTOOElements::TOO_MATH); 838 break; 839 case WID_CREATE_FROM_STAR_CHART: 840 lcl_AnyToBitMask(rValue, nOLEOptions, nsSwTOOElements::TOO_CHART); 841 break; 842 case WID_CREATE_FROM_STAR_CALC: 843 lcl_AnyToBitMask(rValue, nOLEOptions, nsSwTOOElements::TOO_CALC); 844 break; 845 case WID_CREATE_FROM_STAR_DRAW: 846 lcl_AnyToBitMask(rValue, nOLEOptions, 847 nsSwTOOElements::TOO_DRAW_IMPRESS); 848 break; 849 case WID_CREATE_FROM_OTHER_EMBEDDED_OBJECTS: 850 lcl_AnyToBitMask(rValue, nOLEOptions, nsSwTOOElements::TOO_OTHER); 851 break; 852 case WID_PARA_HEAD: 853 { 854 String aString; 855 SwStyleNameMapper::FillUIName( lcl_AnyToString(rValue), 856 aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); 857 bForm = sal_True; 858 // Header is on Pos 0 859 aForm.SetTemplate( 0, aString ); 860 } 861 break; 862 case WID_IS_RELATIVE_TABSTOPS: 863 bForm = sal_True; 864 aForm.SetRelTabPos(lcl_AnyToBool(rValue)); 865 break; 866 case WID_PARA_SEP: 867 { 868 String aString; 869 bForm = sal_True; 870 SwStyleNameMapper::FillUIName( lcl_AnyToString(rValue), 871 aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); 872 aForm.SetTemplate( 1, aString ); 873 } 874 break; 875 case WID_CREATE_FROM_PARAGRAPH_STYLES: 876 lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_TEMPLATE); 877 break; 878 879 case WID_PARA_LEV1: 880 case WID_PARA_LEV2: 881 case WID_PARA_LEV3: 882 case WID_PARA_LEV4: 883 case WID_PARA_LEV5: 884 case WID_PARA_LEV6: 885 case WID_PARA_LEV7: 886 case WID_PARA_LEV8: 887 case WID_PARA_LEV9: 888 case WID_PARA_LEV10: 889 { 890 bForm = sal_True; 891 // in sdbcx::Index Label 1 begins at Pos 2 otherwise at Pos 1 892 const sal_uInt16 nLPos = rTOXBase.GetType() == TOX_INDEX ? 2 : 1; 893 String aString; 894 SwStyleNameMapper::FillUIName( lcl_AnyToString(rValue), 895 aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); 896 aForm.SetTemplate(nLPos + pEntry->nWID - WID_PARA_LEV1, aString ); 897 } 898 break; 899 default: 900 //this is for items only 901 if (WID_PRIMARY_KEY > pEntry->nWID) 902 { 903 const SwAttrSet& rSet = 904 m_pImpl->m_pDoc->GetTOXBaseAttrSet(rTOXBase); 905 SfxItemSet aAttrSet(rSet); 906 m_pImpl->m_rPropSet.setPropertyValue( 907 rPropertyName, rValue, aAttrSet); 908 909 const SwSectionFmts& rSects = m_pImpl->m_pDoc->GetSections(); 910 for (sal_uInt16 i = 0; i < rSects.Count(); i++) 911 { 912 const SwSectionFmt* pTmpFmt = rSects[ i ]; 913 if (pTmpFmt == pSectionFmt) 914 { 915 SwSectionData tmpData( 916 static_cast<SwTOXBaseSection&>(rTOXBase)); 917 m_pImpl->m_pDoc->UpdateSection(i, tmpData, & aAttrSet); 918 break; 919 } 920 } 921 } 922 } 923 rTOXBase.SetCreate(nCreate); 924 rTOXBase.SetOLEOptions(nOLEOptions); 925 if (rTOXBase.GetTOXType()->GetType() == TOX_INDEX) 926 { 927 rTOXBase.SetOptions(nTOIOptions); 928 } 929 if (bForm) 930 { 931 rTOXBase.SetTOXForm(aForm); 932 } 933 } 934 935 /*-- 14.12.98 09:35:05--------------------------------------------------- 936 937 -----------------------------------------------------------------------*/ 938 uno::Any SAL_CALL 939 SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName) 940 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 941 uno::RuntimeException) 942 { 943 vos::OGuard aGuard(Application::GetSolarMutex()); 944 945 uno::Any aRet; 946 SfxItemPropertySimpleEntry const*const pEntry = 947 m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); 948 if (!pEntry) 949 { 950 throw beans::UnknownPropertyException( 951 OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) 952 + rPropertyName, 953 static_cast< cppu::OWeakObject * >(this)); 954 } 955 956 SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() ); 957 SwTOXBase* pTOXBase = 0; 958 if (pSectionFmt) 959 { 960 pTOXBase = static_cast<SwTOXBaseSection*>(pSectionFmt->GetSection()); 961 } 962 else if (m_pImpl->m_bIsDescriptor) 963 { 964 pTOXBase = &m_pImpl->m_pProps->GetTOXBase(); 965 } 966 if(pTOXBase) 967 { 968 const sal_uInt16 nCreate = pTOXBase->GetCreateType(); 969 const sal_uInt16 nOLEOptions = pTOXBase->GetOLEOptions(); 970 const sal_uInt16 nTOIOptions = 971 (pTOXBase->GetTOXType()->GetType() == TOX_INDEX) 972 ? pTOXBase->GetOptions() 973 : 0U; 974 const SwForm& rForm = pTOXBase->GetTOXForm(); 975 switch(pEntry->nWID) 976 { 977 case WID_IDX_CONTENT_SECTION: 978 case WID_IDX_HEADER_SECTION : 979 if(WID_IDX_CONTENT_SECTION == pEntry->nWID) 980 { 981 const uno::Reference <text::XTextSection> xContentSect = 982 SwXTextSection::CreateXTextSection( pSectionFmt ); 983 aRet <<= xContentSect; 984 } 985 else 986 { 987 SwSections aSectArr; 988 pSectionFmt->GetChildSections(aSectArr, 989 SORTSECT_NOT, sal_False); 990 for(sal_uInt16 i = 0; i < aSectArr.Count(); i++) 991 { 992 SwSection* pSect = aSectArr[i]; 993 if(pSect->GetType() == TOX_HEADER_SECTION) 994 { 995 const uno::Reference <text::XTextSection> xHeader = 996 SwXTextSection::CreateXTextSection( 997 pSect->GetFmt() ); 998 aRet <<= xHeader; 999 break; 1000 } 1001 } 1002 } 1003 break; 1004 case WID_IDX_TITLE : 1005 { 1006 OUString uRet(pTOXBase->GetTitle()); 1007 aRet <<= uRet; 1008 break; 1009 } 1010 case WID_IDX_NAME: 1011 aRet <<= OUString(pTOXBase->GetTOXName()); 1012 break; 1013 case WID_USER_IDX_NAME: 1014 { 1015 OUString sTmp; 1016 if (!m_pImpl->m_bIsDescriptor) 1017 { 1018 sTmp = pTOXBase->GetTOXType()->GetTypeName(); 1019 } 1020 else 1021 { 1022 sTmp = m_pImpl->m_pProps->GetTypeName(); 1023 } 1024 //I18N 1025 lcl_ConvertTOUNameToProgrammaticName(sTmp); 1026 aRet <<= sTmp; 1027 } 1028 break; 1029 case WID_IDX_LOCALE: 1030 aRet <<= SvxCreateLocale(pTOXBase->GetLanguage()); 1031 break; 1032 case WID_IDX_SORT_ALGORITHM: 1033 aRet <<= OUString(pTOXBase->GetSortAlgorithm()); 1034 break; 1035 case WID_LEVEL : 1036 aRet <<= static_cast<sal_Int16>(pTOXBase->GetLevel()); 1037 break; 1038 case WID_CREATE_FROM_MARKS: 1039 lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_MARK); 1040 break; 1041 case WID_CREATE_FROM_OUTLINE: 1042 lcl_BitMaskToAny(aRet, nCreate, 1043 nsSwTOXElement::TOX_OUTLINELEVEL); 1044 break; 1045 case WID_CREATE_FROM_CHAPTER: 1046 { 1047 const sal_Bool bRet = pTOXBase->IsFromChapter(); 1048 aRet <<= bRet; 1049 } 1050 break; 1051 case WID_CREATE_FROM_LABELS: 1052 { 1053 const sal_Bool bRet = ! pTOXBase->IsFromObjectNames(); 1054 aRet <<= bRet; 1055 } 1056 break; 1057 case WID_PROTECTED: 1058 { 1059 const sal_Bool bRet = pTOXBase->IsProtected(); 1060 aRet <<= bRet; 1061 } 1062 break; 1063 case WID_USE_ALPHABETICAL_SEPARATORS: 1064 lcl_BitMaskToAny(aRet, nTOIOptions, 1065 nsSwTOIOptions::TOI_ALPHA_DELIMITTER); 1066 break; 1067 case WID_USE_KEY_AS_ENTRY: 1068 lcl_BitMaskToAny(aRet, nTOIOptions, 1069 nsSwTOIOptions::TOI_KEY_AS_ENTRY); 1070 break; 1071 case WID_USE_COMBINED_ENTRIES: 1072 lcl_BitMaskToAny(aRet, nTOIOptions, 1073 nsSwTOIOptions::TOI_SAME_ENTRY); 1074 break; 1075 case WID_IS_CASE_SENSITIVE: 1076 lcl_BitMaskToAny(aRet, nTOIOptions, 1077 nsSwTOIOptions::TOI_CASE_SENSITIVE); 1078 break; 1079 case WID_USE_P_P: 1080 lcl_BitMaskToAny(aRet, nTOIOptions, nsSwTOIOptions::TOI_FF); 1081 break; 1082 case WID_USE_DASH: 1083 lcl_BitMaskToAny(aRet, nTOIOptions, nsSwTOIOptions::TOI_DASH); 1084 break; 1085 case WID_USE_UPPER_CASE: 1086 lcl_BitMaskToAny(aRet, nTOIOptions, 1087 nsSwTOIOptions::TOI_INITIAL_CAPS); 1088 break; 1089 case WID_IS_COMMA_SEPARATED: 1090 { 1091 const sal_Bool bRet = rForm.IsCommaSeparated(); 1092 aRet <<= bRet; 1093 } 1094 break; 1095 case WID_LABEL_CATEGORY: 1096 { 1097 // convert internal UI name to 1098 // file-format/API/external programmatic english name 1099 // before usage 1100 String aName( SwStyleNameMapper::GetSpecialExtraProgName( 1101 pTOXBase->GetSequenceName() ) ); 1102 aRet <<= OUString( aName ); 1103 } 1104 break; 1105 case WID_LABEL_DISPLAY_TYPE: 1106 { 1107 sal_Int16 nSet = text::ReferenceFieldPart::TEXT; 1108 switch (pTOXBase->GetCaptionDisplay()) 1109 { 1110 case CAPTION_COMPLETE: 1111 nSet = text::ReferenceFieldPart::TEXT; 1112 break; 1113 case CAPTION_NUMBER: 1114 nSet = text::ReferenceFieldPart::CATEGORY_AND_NUMBER; 1115 break; 1116 case CAPTION_TEXT: 1117 nSet = text::ReferenceFieldPart::ONLY_CAPTION; 1118 break; 1119 } 1120 aRet <<= nSet; 1121 } 1122 break; 1123 case WID_USE_LEVEL_FROM_SOURCE: 1124 { 1125 const sal_Bool bRet = pTOXBase->IsLevelFromChapter(); 1126 aRet <<= bRet; 1127 } 1128 break; 1129 case WID_LEVEL_FORMAT: 1130 { 1131 uno::Reference< container::XIndexReplace > xTokenAccess( 1132 m_pImpl->m_wTokenAccess); 1133 if (!xTokenAccess.is()) 1134 { 1135 xTokenAccess = new TokenAccess_Impl(*this); 1136 m_pImpl->m_wTokenAccess = xTokenAccess; 1137 } 1138 aRet <<= xTokenAccess; 1139 } 1140 break; 1141 case WID_LEVEL_PARAGRAPH_STYLES: 1142 { 1143 uno::Reference< container::XIndexReplace > xStyleAccess( 1144 m_pImpl->m_wStyleAccess); 1145 if (!xStyleAccess.is()) 1146 { 1147 xStyleAccess = new StyleAccess_Impl(*this); 1148 m_pImpl->m_wStyleAccess = xStyleAccess; 1149 } 1150 aRet <<= xStyleAccess; 1151 } 1152 break; 1153 case WID_MAIN_ENTRY_CHARACTER_STYLE_NAME: 1154 { 1155 String aString; 1156 SwStyleNameMapper::FillProgName( 1157 pTOXBase->GetMainEntryCharStyle(), 1158 aString, 1159 nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, 1160 sal_True); 1161 aRet <<= OUString( aString ); 1162 } 1163 break; 1164 case WID_CREATE_FROM_TABLES: 1165 lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_TABLE); 1166 break; 1167 case WID_CREATE_FROM_TEXT_FRAMES: 1168 lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_FRAME); 1169 break; 1170 case WID_CREATE_FROM_GRAPHIC_OBJECTS: 1171 lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_GRAPHIC); 1172 break; 1173 case WID_CREATE_FROM_EMBEDDED_OBJECTS: 1174 lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_OLE); 1175 break; 1176 case WID_CREATE_FROM_STAR_MATH: 1177 lcl_BitMaskToAny(aRet, nOLEOptions, nsSwTOOElements::TOO_MATH); 1178 break; 1179 case WID_CREATE_FROM_STAR_CHART: 1180 lcl_BitMaskToAny(aRet, nOLEOptions, nsSwTOOElements::TOO_CHART); 1181 break; 1182 case WID_CREATE_FROM_STAR_CALC: 1183 lcl_BitMaskToAny(aRet, nOLEOptions, nsSwTOOElements::TOO_CALC); 1184 break; 1185 case WID_CREATE_FROM_STAR_DRAW: 1186 lcl_BitMaskToAny(aRet, nOLEOptions, 1187 nsSwTOOElements::TOO_DRAW_IMPRESS); 1188 break; 1189 case WID_CREATE_FROM_OTHER_EMBEDDED_OBJECTS: 1190 lcl_BitMaskToAny(aRet, nOLEOptions, nsSwTOOElements::TOO_OTHER); 1191 break; 1192 case WID_CREATE_FROM_PARAGRAPH_STYLES: 1193 lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_TEMPLATE); 1194 break; 1195 case WID_PARA_HEAD: 1196 { 1197 //Header steht an Pos 0 1198 String aString; 1199 SwStyleNameMapper::FillProgName(rForm.GetTemplate( 0 ), aString, 1200 nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True ); 1201 aRet <<= OUString( aString ); 1202 } 1203 break; 1204 case WID_PARA_SEP: 1205 { 1206 String aString; 1207 SwStyleNameMapper::FillProgName( 1208 rForm.GetTemplate( 1 ), 1209 aString, 1210 nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, 1211 sal_True); 1212 aRet <<= OUString( aString ); 1213 } 1214 break; 1215 case WID_PARA_LEV1: 1216 case WID_PARA_LEV2: 1217 case WID_PARA_LEV3: 1218 case WID_PARA_LEV4: 1219 case WID_PARA_LEV5: 1220 case WID_PARA_LEV6: 1221 case WID_PARA_LEV7: 1222 case WID_PARA_LEV8: 1223 case WID_PARA_LEV9: 1224 case WID_PARA_LEV10: 1225 { 1226 // in sdbcx::Index Label 1 begins at Pos 2 otherwise at Pos 1 1227 sal_uInt16 nLPos = pTOXBase->GetType() == TOX_INDEX ? 2 : 1; 1228 String aString; 1229 SwStyleNameMapper::FillProgName( 1230 rForm.GetTemplate(nLPos + pEntry->nWID - WID_PARA_LEV1), 1231 aString, 1232 nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, 1233 sal_True); 1234 aRet <<= OUString( aString ); 1235 } 1236 break; 1237 case WID_IS_RELATIVE_TABSTOPS: 1238 { 1239 const sal_Bool bRet = rForm.IsRelTabPos(); 1240 aRet <<= bRet; 1241 } 1242 break; 1243 case WID_INDEX_MARKS: 1244 { 1245 SwTOXMarks aMarks; 1246 const SwTOXType* pType = pTOXBase->GetTOXType(); 1247 SwTOXMark::InsertTOXMarks( aMarks, *pType ); 1248 uno::Sequence< uno::Reference<text::XDocumentIndexMark> > aXMarks(aMarks.Count()); 1249 uno::Reference<text::XDocumentIndexMark>* pxMarks = aXMarks.getArray(); 1250 for(sal_uInt16 i = 0; i < aMarks.Count(); i++) 1251 { 1252 SwTOXMark* pMark = aMarks.GetObject(i); 1253 pxMarks[i] = SwXDocumentIndexMark::CreateXDocumentIndexMark( 1254 *m_pImpl->m_pDoc, 1255 *const_cast<SwTOXType*>(pType), *pMark); 1256 } 1257 aRet <<= aXMarks; 1258 } 1259 break; 1260 default: 1261 //this is for items only 1262 if(WID_PRIMARY_KEY > pEntry->nWID) 1263 { 1264 const SwAttrSet& rSet = 1265 m_pImpl->m_pDoc->GetTOXBaseAttrSet(*pTOXBase); 1266 aRet = m_pImpl->m_rPropSet.getPropertyValue( 1267 rPropertyName, rSet); 1268 } 1269 } 1270 } 1271 return aRet; 1272 } 1273 1274 /*-- 14.12.98 09:35:06--------------------------------------------------- 1275 1276 -----------------------------------------------------------------------*/ 1277 void SAL_CALL 1278 SwXDocumentIndex::addPropertyChangeListener( 1279 const ::rtl::OUString& /*rPropertyName*/, 1280 const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) 1281 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 1282 uno::RuntimeException) 1283 { 1284 OSL_ENSURE(false, 1285 "SwXDocumentIndex::addPropertyChangeListener(): not implemented"); 1286 } 1287 1288 void SAL_CALL 1289 SwXDocumentIndex::removePropertyChangeListener( 1290 const ::rtl::OUString& /*rPropertyName*/, 1291 const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) 1292 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 1293 uno::RuntimeException) 1294 { 1295 OSL_ENSURE(false, 1296 "SwXDocumentIndex::removePropertyChangeListener(): not implemented"); 1297 } 1298 1299 void SAL_CALL 1300 SwXDocumentIndex::addVetoableChangeListener( 1301 const ::rtl::OUString& /*rPropertyName*/, 1302 const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) 1303 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 1304 uno::RuntimeException) 1305 { 1306 OSL_ENSURE(false, 1307 "SwXDocumentIndex::addVetoableChangeListener(): not implemented"); 1308 } 1309 1310 void SAL_CALL 1311 SwXDocumentIndex::removeVetoableChangeListener( 1312 const ::rtl::OUString& /*rPropertyName*/, 1313 const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) 1314 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 1315 uno::RuntimeException) 1316 { 1317 OSL_ENSURE(false, 1318 "SwXDocumentIndex::removeVetoableChangeListener(): not implemented"); 1319 } 1320 1321 /* -----------------18.02.99 13:39------------------- 1322 * 1323 * --------------------------------------------------*/ 1324 void SAL_CALL 1325 SwXDocumentIndex::attach(const uno::Reference< text::XTextRange > & xTextRange) 1326 throw (lang::IllegalArgumentException, uno::RuntimeException) 1327 { 1328 vos::OGuard aGuard(Application::GetSolarMutex()); 1329 1330 if (!m_pImpl->m_bIsDescriptor) 1331 { 1332 throw uno::RuntimeException(); 1333 } 1334 const uno::Reference<XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); 1335 SwXTextRange *const pRange = 1336 ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel); 1337 OTextCursorHelper *const pCursor = 1338 ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel); 1339 1340 SwDoc *const pDoc = 1341 (pRange) ? pRange->GetDoc() : ((pCursor) ? pCursor->GetDoc() : 0); 1342 if (!pDoc) 1343 { 1344 throw lang::IllegalArgumentException(); 1345 } 1346 1347 SwUnoInternalPaM aPam(*pDoc); 1348 //das muss jetzt sal_True liefern 1349 ::sw::XTextRangeToSwPaM(aPam, xTextRange); 1350 1351 const SwTOXBase* pOld = pDoc->GetCurTOX( *aPam.Start() ); 1352 if (pOld) 1353 { 1354 throw lang::IllegalArgumentException(); 1355 } 1356 1357 UnoActionContext aAction(pDoc); 1358 if (aPam.HasMark()) 1359 { 1360 pDoc->DeleteAndJoin(aPam); 1361 } 1362 1363 SwTOXBase & rTOXBase = m_pImpl->m_pProps->GetTOXBase(); 1364 SwTOXType const*const pTOXType = rTOXBase.GetTOXType(); 1365 if ((TOX_USER == pTOXType->GetType()) && 1366 !m_pImpl->m_pProps->GetTypeName().equals(pTOXType->GetTypeName())) 1367 { 1368 lcl_ReAssignTOXType(pDoc, rTOXBase, m_pImpl->m_pProps->GetTypeName()); 1369 } 1370 //TODO: apply Section attributes (columns and background) 1371 SwTOXBaseSection const*const pTOX = 1372 pDoc->InsertTableOf( *aPam.GetPoint(), rTOXBase, 0, sal_False ); 1373 1374 pDoc->SetTOXBaseName(*pTOX, m_pImpl->m_pProps->GetTOXBase().GetTOXName()); 1375 1376 // update page numbers 1377 pTOX->GetFmt()->Add(m_pImpl.get()); 1378 pTOX->GetFmt()->SetXObject(static_cast< ::cppu::OWeakObject*>(this)); 1379 const_cast<SwTOXBaseSection*>(pTOX)->UpdatePageNum(); 1380 1381 m_pImpl->m_pProps.reset(); 1382 m_pImpl->m_pDoc = pDoc; 1383 m_pImpl->m_bIsDescriptor = sal_False; 1384 } 1385 1386 /*-- 15.01.99 14:23:56--------------------------------------------------- 1387 1388 -----------------------------------------------------------------------*/ 1389 uno::Reference< text::XTextRange > SAL_CALL 1390 SwXDocumentIndex::getAnchor() throw (uno::RuntimeException) 1391 { 1392 vos::OGuard aGuard(Application::GetSolarMutex()); 1393 1394 SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() ); 1395 if (!pSectionFmt) 1396 { 1397 throw uno::RuntimeException(); 1398 } 1399 1400 uno::Reference< text::XTextRange > xRet; 1401 SwNodeIndex const*const pIdx( pSectionFmt->GetCntnt().GetCntntIdx() ); 1402 if (pIdx && pIdx->GetNode().GetNodes().IsDocNodes()) 1403 { 1404 SwPaM aPaM(*pIdx); 1405 aPaM.Move( fnMoveForward, fnGoCntnt ); 1406 aPaM.SetMark(); 1407 aPaM.GetPoint()->nNode = *pIdx->GetNode().EndOfSectionNode(); 1408 aPaM.Move( fnMoveBackward, fnGoCntnt ); 1409 xRet = SwXTextRange::CreateXTextRange(*pSectionFmt->GetDoc(), 1410 *aPaM.GetMark(), aPaM.GetPoint()); 1411 } 1412 return xRet; 1413 } 1414 1415 /*-- 15.01.99 15:46:48--------------------------------------------------- 1416 1417 -----------------------------------------------------------------------*/ 1418 void lcl_RemoveChildSections(SwSectionFmt& rParentFmt) 1419 { 1420 SwSections aTmpArr; 1421 SwDoc *const pDoc = rParentFmt.GetDoc(); 1422 const sal_uInt16 nCnt = rParentFmt.GetChildSections(aTmpArr, SORTSECT_POS); 1423 if( nCnt ) 1424 { 1425 for( sal_uInt16 n = 0; n < nCnt; ++n ) 1426 { 1427 if( aTmpArr[n]->GetFmt()->IsInNodesArr() ) 1428 { 1429 SwSectionFmt* pFmt = aTmpArr[n]->GetFmt(); 1430 lcl_RemoveChildSections(*pFmt); 1431 pDoc->DelSectionFmt( pFmt ); 1432 } 1433 } 1434 } 1435 } 1436 1437 void SAL_CALL SwXDocumentIndex::dispose() throw (uno::RuntimeException) 1438 { 1439 vos::OGuard aGuard(Application::GetSolarMutex()); 1440 1441 SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() ); 1442 if (pSectionFmt) 1443 { 1444 pSectionFmt->GetDoc()->DeleteTOX( 1445 *static_cast<SwTOXBaseSection*>(pSectionFmt->GetSection()), 1446 sal_True); 1447 } 1448 } 1449 1450 /*-- 15.01.99 15:46:49--------------------------------------------------- 1451 1452 -----------------------------------------------------------------------*/ 1453 void SAL_CALL 1454 SwXDocumentIndex::addEventListener( 1455 const uno::Reference< lang::XEventListener > & xListener) 1456 throw (uno::RuntimeException) 1457 { 1458 vos::OGuard g(Application::GetSolarMutex()); 1459 1460 if (!m_pImpl->GetRegisteredIn()) 1461 { 1462 throw uno::RuntimeException(); 1463 } 1464 m_pImpl->m_ListenerContainer.AddListener(xListener); 1465 } 1466 /*-- 15.01.99 15:46:54--------------------------------------------------- 1467 1468 -----------------------------------------------------------------------*/ 1469 void SAL_CALL 1470 SwXDocumentIndex::removeEventListener( 1471 const uno::Reference< lang::XEventListener > & xListener) 1472 throw (uno::RuntimeException) 1473 { 1474 vos::OGuard g(Application::GetSolarMutex()); 1475 1476 if (!m_pImpl->GetRegisteredIn() || 1477 !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) 1478 { 1479 throw uno::RuntimeException(); 1480 } 1481 } 1482 1483 /* -----------------30.07.99 11:28------------------- 1484 1485 --------------------------------------------------*/ 1486 OUString SAL_CALL SwXDocumentIndex::getName() throw (uno::RuntimeException) 1487 { 1488 vos::OGuard g(Application::GetSolarMutex()); 1489 1490 OUString uRet; 1491 SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() ); 1492 if (m_pImpl->m_bIsDescriptor) 1493 { 1494 uRet = OUString(m_pImpl->m_pProps->GetTOXBase().GetTOXName()); 1495 } 1496 else if(pSectionFmt) 1497 { 1498 uRet = OUString(pSectionFmt->GetSection()->GetSectionName()); 1499 } 1500 else 1501 { 1502 throw uno::RuntimeException(); 1503 } 1504 return uRet; 1505 } 1506 /* -----------------30.07.99 11:28------------------- 1507 1508 --------------------------------------------------*/ 1509 void SAL_CALL 1510 SwXDocumentIndex::setName(const OUString& rName) throw (uno::RuntimeException) 1511 { 1512 vos::OGuard g(Application::GetSolarMutex()); 1513 1514 if (!rName.getLength()) 1515 { 1516 throw uno::RuntimeException(); 1517 } 1518 1519 SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() ); 1520 if (m_pImpl->m_bIsDescriptor) 1521 { 1522 m_pImpl->m_pProps->GetTOXBase().SetTOXName(rName); 1523 } 1524 else if (pSectionFmt) 1525 { 1526 const bool bSuccess = pSectionFmt->GetDoc()->SetTOXBaseName( 1527 *static_cast<SwTOXBaseSection*>(pSectionFmt->GetSection()), rName); 1528 if (!bSuccess) 1529 { 1530 throw uno::RuntimeException(); 1531 } 1532 } 1533 else 1534 { 1535 throw uno::RuntimeException(); 1536 } 1537 } 1538 1539 // MetadatableMixin 1540 ::sfx2::Metadatable* SwXDocumentIndex::GetCoreObject() 1541 { 1542 SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() ); 1543 return pSectionFmt; 1544 } 1545 1546 uno::Reference<frame::XModel> SwXDocumentIndex::GetModel() 1547 { 1548 SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() ); 1549 if (pSectionFmt) 1550 { 1551 SwDocShell const*const pShell( pSectionFmt->GetDoc()->GetDocShell() ); 1552 return (pShell) ? pShell->GetModel() : 0; 1553 } 1554 return 0; 1555 } 1556 1557 1558 /****************************************************************** 1559 * SwXDocumentIndexMark 1560 ******************************************************************/ 1561 /* -----------------21.04.99 09:36------------------- 1562 * 1563 * --------------------------------------------------*/ 1564 static sal_uInt16 1565 lcl_TypeToPropertyMap_Mark(const TOXTypes eType) 1566 { 1567 switch (eType) 1568 { 1569 case TOX_INDEX: return PROPERTY_MAP_INDEX_MARK; 1570 case TOX_CONTENT: return PROPERTY_MAP_CNTIDX_MARK; 1571 //case TOX_USER: 1572 default: 1573 return PROPERTY_MAP_USER_MARK; 1574 } 1575 } 1576 1577 class SwXDocumentIndexMark::Impl 1578 : public SwClient 1579 { 1580 private: 1581 bool m_bInReplaceMark; 1582 1583 public: 1584 1585 SfxItemPropertySet const& m_rPropSet; 1586 const TOXTypes m_eTOXType; 1587 SwEventListenerContainer m_ListenerContainer; 1588 bool m_bIsDescriptor; 1589 SwDepend m_TypeDepend; 1590 const SwTOXMark * m_pTOXMark; 1591 SwDoc * m_pDoc; 1592 1593 sal_Bool m_bMainEntry; 1594 sal_uInt16 m_nLevel; 1595 OUString m_sAltText; 1596 OUString m_sPrimaryKey; 1597 OUString m_sSecondaryKey; 1598 OUString m_sTextReading; 1599 OUString m_sPrimaryKeyReading; 1600 OUString m_sSecondaryKeyReading; 1601 OUString m_sUserIndexName; 1602 1603 Impl( SwXDocumentIndexMark & rThis, 1604 SwDoc *const pDoc, 1605 const enum TOXTypes eType, 1606 SwTOXType *const pType, SwTOXMark const*const pMark) 1607 : SwClient(const_cast<SwTOXMark*>(pMark)) 1608 , m_bInReplaceMark(false) 1609 , m_rPropSet( 1610 *aSwMapProvider.GetPropertySet(lcl_TypeToPropertyMap_Mark(eType))) 1611 , m_eTOXType(eType) 1612 , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) 1613 // #i112513#: unxsols4 (Sun C++ 5.9 SunOS_sparc) generates wrong code for this 1614 // , m_bIsDescriptor(0 == pMark) 1615 , m_bIsDescriptor((0 == pMark) ? true : false) 1616 , m_TypeDepend(this, pType) 1617 , m_pTOXMark(pMark) 1618 , m_pDoc(pDoc) 1619 , m_bMainEntry(sal_False) 1620 , m_nLevel(0) 1621 { 1622 } 1623 1624 SwTOXType * GetTOXType() const { 1625 return static_cast<SwTOXType*>( 1626 const_cast<SwModify *>(m_TypeDepend.GetRegisteredIn())); 1627 } 1628 1629 void DeleteTOXMark() 1630 { 1631 m_pDoc->DeleteTOXMark(m_pTOXMark); // calls Invalidate() via Modify! 1632 m_pTOXMark = 0; 1633 } 1634 1635 void InsertTOXMark(SwTOXType & rTOXType, SwTOXMark & rMark, SwPaM & rPam, 1636 SwXTextCursor const*const pTextCursor); 1637 1638 void ReplaceTOXMark(SwTOXType & rTOXType, SwTOXMark & rMark, SwPaM & rPam) 1639 { 1640 m_bInReplaceMark = true; 1641 DeleteTOXMark(); 1642 m_bInReplaceMark = false; 1643 try { 1644 InsertTOXMark(rTOXType, rMark, rPam, 0); 1645 } catch (...) { 1646 OSL_ENSURE(false, "ReplaceTOXMark() failed!"); 1647 m_ListenerContainer.Disposing(); 1648 throw; 1649 } 1650 } 1651 1652 void Invalidate(); 1653 protected: 1654 // SwClient 1655 virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew); 1656 }; 1657 1658 /* -----------------------------16.10.00 11:24-------------------------------- 1659 1660 ---------------------------------------------------------------------------*/ 1661 void SwXDocumentIndexMark::Impl::Invalidate() 1662 { 1663 if (GetRegisteredIn()) 1664 { 1665 const_cast<SwModify*>(GetRegisteredIn())->Remove(this); 1666 if (m_TypeDepend.GetRegisteredIn()) 1667 { 1668 const_cast<SwModify*>(m_TypeDepend.GetRegisteredIn())->Remove( 1669 &m_TypeDepend); 1670 } 1671 } 1672 if (!m_bInReplaceMark) // #i109983# only dispose on delete, not on replace! 1673 { 1674 m_ListenerContainer.Disposing(); 1675 } 1676 m_pDoc = 0; 1677 m_pTOXMark = 0; 1678 } 1679 1680 /*-- 14.12.98 10:25:47--------------------------------------------------- 1681 1682 -----------------------------------------------------------------------*/ 1683 void SwXDocumentIndexMark::Impl::Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) 1684 { 1685 ClientModify(this, pOld, pNew); 1686 1687 if (!GetRegisteredIn()) // removed => dispose 1688 { 1689 Invalidate(); 1690 } 1691 } 1692 1693 /*-- 14.12.98 10:25:43--------------------------------------------------- 1694 1695 -----------------------------------------------------------------------*/ 1696 SwXDocumentIndexMark::SwXDocumentIndexMark(const TOXTypes eToxType) 1697 : m_pImpl( new SwXDocumentIndexMark::Impl(*this, 0, eToxType, 0, 0) ) 1698 { 1699 } 1700 /*-- 14.12.98 10:25:44--------------------------------------------------- 1701 1702 -----------------------------------------------------------------------*/ 1703 SwXDocumentIndexMark::SwXDocumentIndexMark(SwDoc & rDoc, 1704 SwTOXType & rType, SwTOXMark & rMark) 1705 : m_pImpl( new SwXDocumentIndexMark::Impl(*this, &rDoc, rType.GetType(), 1706 &rType, &rMark) ) 1707 { 1708 } 1709 /*-- 14.12.98 10:25:44--------------------------------------------------- 1710 1711 -----------------------------------------------------------------------*/ 1712 SwXDocumentIndexMark::~SwXDocumentIndexMark() 1713 { 1714 } 1715 1716 uno::Reference<text::XDocumentIndexMark> 1717 SwXDocumentIndexMark::CreateXDocumentIndexMark( 1718 SwDoc & rDoc, SwTOXType & rType, SwTOXMark & rMark) 1719 { 1720 // re-use existing SwXDocumentIndexMark 1721 // NB: xmloff depends on this caching to generate ID from the address! 1722 // #i105557#: do not iterate over the registered clients: race condition 1723 uno::Reference< text::XDocumentIndexMark > xTOXMark(rMark.GetXTOXMark()); 1724 if (!xTOXMark.is()) 1725 { 1726 SwXDocumentIndexMark *const pNew = 1727 new SwXDocumentIndexMark(rDoc, rType, rMark); 1728 xTOXMark.set(pNew); 1729 rMark.SetXTOXMark(xTOXMark); 1730 } 1731 return xTOXMark; 1732 } 1733 1734 /* -----------------------------10.03.00 18:02-------------------------------- 1735 1736 ---------------------------------------------------------------------------*/ 1737 const uno::Sequence< sal_Int8 > & SwXDocumentIndexMark::getUnoTunnelId() 1738 { 1739 static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); 1740 return aSeq; 1741 } 1742 /* -----------------------------10.03.00 18:04-------------------------------- 1743 1744 ---------------------------------------------------------------------------*/ 1745 sal_Int64 SAL_CALL 1746 SwXDocumentIndexMark::getSomething(const uno::Sequence< sal_Int8 >& rId) 1747 throw (uno::RuntimeException) 1748 { 1749 return ::sw::UnoTunnelImpl<SwXDocumentIndexMark>(rId, this); 1750 } 1751 1752 static const sal_Char cBaseMark[] = "com.sun.star.text.BaseIndexMark"; 1753 static const sal_Char cContentMark[] = "com.sun.star.text.ContentIndexMark"; 1754 static const sal_Char cIdxMark[] = "com.sun.star.text.DocumentIndexMark"; 1755 static const sal_Char cIdxMarkAsian[] = "com.sun.star.text.DocumentIndexMarkAsian"; 1756 static const sal_Char cUserMark[] = "com.sun.star.text.UserIndexMark"; 1757 static const sal_Char cTextContent[] = "com.sun.star.text.TextContent"; 1758 1759 /* -----------------------------06.04.00 15:07-------------------------------- 1760 1761 ---------------------------------------------------------------------------*/ 1762 OUString SAL_CALL 1763 SwXDocumentIndexMark::getImplementationName() throw (uno::RuntimeException) 1764 { 1765 return C2U("SwXDocumentIndexMark"); 1766 } 1767 /* -----------------------------06.04.00 15:07-------------------------------- 1768 1769 ---------------------------------------------------------------------------*/ 1770 sal_Bool SAL_CALL 1771 SwXDocumentIndexMark::supportsService(const OUString& rServiceName) 1772 throw (uno::RuntimeException) 1773 { 1774 vos::OGuard g(Application::GetSolarMutex()); 1775 1776 return rServiceName.equalsAscii(cBaseMark) 1777 || rServiceName.equalsAscii(cTextContent) 1778 || ((m_pImpl->m_eTOXType == TOX_USER) 1779 && rServiceName.equalsAscii(cUserMark)) 1780 || ((m_pImpl->m_eTOXType == TOX_CONTENT) 1781 && rServiceName.equalsAscii(cContentMark)) 1782 || ((m_pImpl->m_eTOXType == TOX_INDEX) 1783 && rServiceName.equalsAscii(cIdxMark)) 1784 || ((m_pImpl->m_eTOXType == TOX_INDEX) 1785 && rServiceName.equalsAscii(cIdxMarkAsian)); 1786 } 1787 /* -----------------------------06.04.00 15:07-------------------------------- 1788 1789 ---------------------------------------------------------------------------*/ 1790 uno::Sequence< OUString > SAL_CALL 1791 SwXDocumentIndexMark::getSupportedServiceNames() throw (uno::RuntimeException) 1792 { 1793 vos::OGuard g(Application::GetSolarMutex()); 1794 1795 const sal_Int32 nCnt = (m_pImpl->m_eTOXType == TOX_INDEX) ? 4 : 3; 1796 uno::Sequence< OUString > aRet(nCnt); 1797 OUString* pArray = aRet.getArray(); 1798 pArray[0] = C2U(cBaseMark); 1799 pArray[1] = C2U(cTextContent); 1800 switch (m_pImpl->m_eTOXType) 1801 { 1802 case TOX_USER: 1803 pArray[2] = C2U(cUserMark); 1804 break; 1805 case TOX_CONTENT: 1806 pArray[2] = C2U(cContentMark); 1807 break; 1808 case TOX_INDEX: 1809 pArray[2] = C2U(cIdxMark); 1810 pArray[3] = C2U(cIdxMarkAsian); 1811 break; 1812 1813 default: 1814 ; 1815 } 1816 return aRet; 1817 } 1818 1819 /*-- 14.12.98 10:25:45--------------------------------------------------- 1820 1821 -----------------------------------------------------------------------*/ 1822 OUString SAL_CALL 1823 SwXDocumentIndexMark::getMarkEntry() throw (uno::RuntimeException) 1824 { 1825 vos::OGuard aGuard(Application::GetSolarMutex()); 1826 1827 OUString sRet; 1828 SwTOXType *const pType = m_pImpl->GetTOXType(); 1829 if (pType && m_pImpl->m_pTOXMark) 1830 { 1831 sRet = OUString(m_pImpl->m_pTOXMark->GetAlternativeText()); 1832 } 1833 else if (m_pImpl->m_bIsDescriptor) 1834 { 1835 sRet = m_pImpl->m_sAltText; 1836 } 1837 else 1838 { 1839 throw uno::RuntimeException(); 1840 } 1841 return sRet; 1842 } 1843 /*-- 14.12.98 10:25:45--------------------------------------------------- 1844 1845 -----------------------------------------------------------------------*/ 1846 void SAL_CALL 1847 SwXDocumentIndexMark::setMarkEntry(const OUString& rIndexEntry) 1848 throw (uno::RuntimeException) 1849 { 1850 vos::OGuard aGuard(Application::GetSolarMutex()); 1851 1852 SwTOXType *const pType = m_pImpl->GetTOXType(); 1853 if (pType && m_pImpl->m_pTOXMark) 1854 { 1855 SwTOXMark aMark(*m_pImpl->m_pTOXMark); 1856 aMark.SetAlternativeText(rIndexEntry); 1857 SwTxtTOXMark const*const pTxtMark = 1858 m_pImpl->m_pTOXMark->GetTxtTOXMark(); 1859 SwPaM aPam(pTxtMark->GetTxtNode(), *pTxtMark->GetStart()); 1860 aPam.SetMark(); 1861 if(pTxtMark->GetEnd()) 1862 { 1863 aPam.GetPoint()->nContent = *pTxtMark->GetEnd(); 1864 } 1865 else 1866 aPam.GetPoint()->nContent++; 1867 1868 m_pImpl->ReplaceTOXMark(*pType, aMark, aPam); 1869 } 1870 else if (m_pImpl->m_bIsDescriptor) 1871 { 1872 m_pImpl->m_sAltText = rIndexEntry; 1873 } 1874 else 1875 { 1876 throw uno::RuntimeException(); 1877 } 1878 } 1879 1880 /* -----------------18.02.99 13:40------------------- 1881 * 1882 * --------------------------------------------------*/ 1883 void SAL_CALL 1884 SwXDocumentIndexMark::attach( 1885 const uno::Reference< text::XTextRange > & xTextRange) 1886 throw (lang::IllegalArgumentException, uno::RuntimeException) 1887 { 1888 vos::OGuard aGuard(Application::GetSolarMutex()); 1889 1890 if (!m_pImpl->m_bIsDescriptor) 1891 { 1892 throw uno::RuntimeException(); 1893 } 1894 1895 const uno::Reference<XUnoTunnel> xRangeTunnel(xTextRange, uno::UNO_QUERY); 1896 SwXTextRange *const pRange = 1897 ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel); 1898 OTextCursorHelper *const pCursor = 1899 ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel); 1900 SwDoc *const pDoc = 1901 (pRange) ? pRange->GetDoc() : ((pCursor) ? pCursor->GetDoc() : 0); 1902 if (!pDoc) 1903 { 1904 throw lang::IllegalArgumentException(); 1905 } 1906 1907 const SwTOXType* pTOXType = 0; 1908 switch (m_pImpl->m_eTOXType) 1909 { 1910 case TOX_INDEX: 1911 case TOX_CONTENT: 1912 pTOXType = pDoc->GetTOXType( m_pImpl->m_eTOXType, 0 ); 1913 break; 1914 case TOX_USER: 1915 { 1916 if (!m_pImpl->m_sUserIndexName.getLength()) 1917 { 1918 pTOXType = pDoc->GetTOXType( m_pImpl->m_eTOXType, 0 ); 1919 } 1920 else 1921 { 1922 const sal_uInt16 nCount = 1923 pDoc->GetTOXTypeCount(m_pImpl->m_eTOXType); 1924 for (sal_uInt16 i = 0; i < nCount; i++) 1925 { 1926 SwTOXType const*const pTemp = 1927 pDoc->GetTOXType( m_pImpl->m_eTOXType, i ); 1928 if (m_pImpl->m_sUserIndexName == 1929 OUString(pTemp->GetTypeName())) 1930 { 1931 pTOXType = pTemp; 1932 break; 1933 } 1934 } 1935 if (!pTOXType) 1936 { 1937 SwTOXType aUserType(TOX_USER, m_pImpl->m_sUserIndexName); 1938 pTOXType = pDoc->InsertTOXType(aUserType); 1939 } 1940 } 1941 } 1942 break; 1943 1944 default: 1945 break; 1946 } 1947 if (!pTOXType) 1948 { 1949 throw lang::IllegalArgumentException(); 1950 } 1951 1952 SwUnoInternalPaM aPam(*pDoc); 1953 //das muss jetzt sal_True liefern 1954 ::sw::XTextRangeToSwPaM(aPam, xTextRange); 1955 SwTOXMark aMark (pTOXType); 1956 if (m_pImpl->m_sAltText.getLength()) 1957 { 1958 aMark.SetAlternativeText(m_pImpl->m_sAltText); 1959 } 1960 switch (m_pImpl->m_eTOXType) 1961 { 1962 case TOX_INDEX: 1963 if (m_pImpl->m_sPrimaryKey.getLength()) 1964 { 1965 aMark.SetPrimaryKey(m_pImpl->m_sPrimaryKey); 1966 } 1967 if (m_pImpl->m_sSecondaryKey.getLength()) 1968 { 1969 aMark.SetSecondaryKey(m_pImpl->m_sSecondaryKey); 1970 } 1971 if (m_pImpl->m_sTextReading.getLength()) 1972 { 1973 aMark.SetTextReading(m_pImpl->m_sTextReading); 1974 } 1975 if (m_pImpl->m_sPrimaryKeyReading.getLength()) 1976 { 1977 aMark.SetPrimaryKeyReading(m_pImpl->m_sPrimaryKeyReading); 1978 } 1979 if (m_pImpl->m_sSecondaryKeyReading.getLength()) 1980 { 1981 aMark.SetSecondaryKeyReading(m_pImpl->m_sSecondaryKeyReading); 1982 } 1983 aMark.SetMainEntry(m_pImpl->m_bMainEntry); 1984 break; 1985 case TOX_USER: 1986 case TOX_CONTENT: 1987 if (USHRT_MAX != m_pImpl->m_nLevel) 1988 { 1989 aMark.SetLevel(m_pImpl->m_nLevel+1); 1990 } 1991 break; 1992 1993 default: 1994 break; 1995 } 1996 1997 m_pImpl->InsertTOXMark(*const_cast<SwTOXType *>(pTOXType), aMark, aPam, 1998 dynamic_cast<SwXTextCursor const*>(pCursor)); 1999 2000 m_pImpl->m_bIsDescriptor = sal_False; 2001 } 2002 2003 template<typename T> struct NotContainedIn 2004 { 2005 ::std::vector<T> const& m_rVector; 2006 explicit NotContainedIn(::std::vector<T> const& rVector) 2007 : m_rVector(rVector) { } 2008 bool operator() (T const& rT) { 2009 return ::std::find(m_rVector.begin(), m_rVector.end(), rT) 2010 == m_rVector.end(); 2011 } 2012 }; 2013 2014 void SwXDocumentIndexMark::Impl::InsertTOXMark( 2015 SwTOXType & rTOXType, SwTOXMark & rMark, SwPaM & rPam, 2016 SwXTextCursor const*const pTextCursor) 2017 { 2018 SwDoc *const pDoc( rPam.GetDoc() ); 2019 UnoActionContext aAction(pDoc); 2020 bool bMark = *rPam.GetPoint() != *rPam.GetMark(); 2021 // n.b.: toxmarks must have either alternative text or an extent 2022 if (bMark && rMark.GetAlternativeText().Len()) 2023 { 2024 rPam.Normalize(sal_True); 2025 rPam.DeleteMark(); 2026 bMark = false; 2027 } 2028 // Marks ohne Alternativtext ohne selektierten Text koennen nicht eingefuegt werden, 2029 // deshalb hier ein Leerzeichen - ob das die ideale Loesung ist? 2030 if (!bMark && !rMark.GetAlternativeText().Len()) 2031 { 2032 rMark.SetAlternativeText( String(' ') ); 2033 } 2034 2035 const bool bForceExpandHints( (!bMark && pTextCursor) 2036 ? pTextCursor->IsAtEndOfMeta() : false ); 2037 const SetAttrMode nInsertFlags = (bForceExpandHints) 2038 ? ( nsSetAttrMode::SETATTR_FORCEHINTEXPAND 2039 | nsSetAttrMode::SETATTR_DONTEXPAND) 2040 : nsSetAttrMode::SETATTR_DONTEXPAND; 2041 2042 ::std::vector<SwTxtAttr *> oldMarks; 2043 if (bMark) 2044 { 2045 oldMarks = rPam.GetNode()->GetTxtNode()->GetTxtAttrsAt( 2046 rPam.GetPoint()->nContent.GetIndex(), RES_TXTATR_TOXMARK); 2047 } 2048 2049 pDoc->InsertPoolItem(rPam, rMark, nInsertFlags); 2050 if (bMark && *rPam.GetPoint() > *rPam.GetMark()) 2051 { 2052 rPam.Exchange(); 2053 } 2054 2055 // rMark was copied into the document pool; now retrieve real format... 2056 SwTxtAttr * pTxtAttr(0); 2057 if (bMark) 2058 { 2059 // #i107672# 2060 // ensure that we do not retrieve a different mark at the same position 2061 ::std::vector<SwTxtAttr *> const newMarks( 2062 rPam.GetNode()->GetTxtNode()->GetTxtAttrsAt( 2063 rPam.GetPoint()->nContent.GetIndex(), RES_TXTATR_TOXMARK)); 2064 ::std::vector<SwTxtAttr *>::const_iterator const iter( 2065 ::std::find_if(newMarks.begin(), newMarks.end(), 2066 NotContainedIn<SwTxtAttr *>(oldMarks))); 2067 OSL_ASSERT(newMarks.end() != iter); 2068 if (newMarks.end() != iter) 2069 { 2070 pTxtAttr = *iter; 2071 } 2072 } 2073 else 2074 { 2075 pTxtAttr = rPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( 2076 rPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_TOXMARK ); 2077 } 2078 2079 if (!pTxtAttr) 2080 { 2081 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 2082 "SwXDocumentIndexMark::InsertTOXMark(): cannot insert attribute")), 2083 0); 2084 } 2085 2086 m_pDoc = pDoc; 2087 m_pTOXMark = & pTxtAttr->GetTOXMark(); 2088 const_cast<SwTOXMark*>(m_pTOXMark)->Add(this); 2089 const_cast<SwTOXType &>(rTOXType).Add(& m_TypeDepend); 2090 } 2091 2092 /*-- 14.12.98 10:25:45--------------------------------------------------- 2093 2094 -----------------------------------------------------------------------*/ 2095 uno::Reference< text::XTextRange > SAL_CALL 2096 SwXDocumentIndexMark::getAnchor() throw (uno::RuntimeException) 2097 { 2098 vos::OGuard aGuard(Application::GetSolarMutex()); 2099 2100 SwTOXType *const pType = m_pImpl->GetTOXType(); 2101 if (!pType || !m_pImpl->m_pTOXMark) 2102 { 2103 throw uno::RuntimeException(); 2104 } 2105 if (!m_pImpl->m_pTOXMark->GetTxtTOXMark()) 2106 { 2107 throw uno::RuntimeException(); 2108 } 2109 const SwTxtTOXMark* pTxtMark = m_pImpl->m_pTOXMark->GetTxtTOXMark(); 2110 SwPaM aPam(pTxtMark->GetTxtNode(), *pTxtMark->GetStart()); 2111 aPam.SetMark(); 2112 if(pTxtMark->GetEnd()) 2113 { 2114 aPam.GetPoint()->nContent = *pTxtMark->GetEnd(); 2115 } 2116 else 2117 { 2118 aPam.GetPoint()->nContent++; 2119 } 2120 const uno::Reference< frame::XModel > xModel = 2121 m_pImpl->m_pDoc->GetDocShell()->GetBaseModel(); 2122 const uno::Reference< text::XTextDocument > xTDoc(xModel, uno::UNO_QUERY); 2123 const uno::Reference< text::XTextRange > xRet = 2124 new SwXTextRange(aPam, xTDoc->getText()); 2125 2126 return xRet; 2127 } 2128 2129 /*-- 14.12.98 10:25:45--------------------------------------------------- 2130 2131 -----------------------------------------------------------------------*/ 2132 void SAL_CALL 2133 SwXDocumentIndexMark::dispose() throw (uno::RuntimeException) 2134 { 2135 vos::OGuard aGuard(Application::GetSolarMutex()); 2136 2137 SwTOXType *const pType = m_pImpl->GetTOXType(); 2138 if (pType && m_pImpl->m_pTOXMark) 2139 { 2140 m_pImpl->DeleteTOXMark(); // call Invalidate() via modify! 2141 } 2142 } 2143 /*-- 14.12.98 10:25:45--------------------------------------------------- 2144 2145 -----------------------------------------------------------------------*/ 2146 void SAL_CALL 2147 SwXDocumentIndexMark::addEventListener( 2148 const uno::Reference< lang::XEventListener > & xListener) 2149 throw (uno::RuntimeException) 2150 { 2151 vos::OGuard g(Application::GetSolarMutex()); 2152 2153 if (!m_pImpl->GetRegisteredIn()) 2154 { 2155 throw uno::RuntimeException(); 2156 } 2157 m_pImpl->m_ListenerContainer.AddListener(xListener); 2158 } 2159 /*-- 14.12.98 10:25:46--------------------------------------------------- 2160 2161 -----------------------------------------------------------------------*/ 2162 void SAL_CALL 2163 SwXDocumentIndexMark::removeEventListener( 2164 const uno::Reference< lang::XEventListener > & xListener) 2165 throw (uno::RuntimeException) 2166 { 2167 vos::OGuard g(Application::GetSolarMutex()); 2168 2169 if (!m_pImpl->GetRegisteredIn() || 2170 !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) 2171 { 2172 throw uno::RuntimeException(); 2173 } 2174 } 2175 2176 /*-- 14.12.98 10:25:46--------------------------------------------------- 2177 2178 -----------------------------------------------------------------------*/ 2179 uno::Reference< beans::XPropertySetInfo > SAL_CALL 2180 SwXDocumentIndexMark::getPropertySetInfo() throw (uno::RuntimeException) 2181 { 2182 vos::OGuard g(Application::GetSolarMutex()); 2183 2184 static uno::Reference< beans::XPropertySetInfo > xInfos[3]; 2185 int nPos = 0; 2186 switch (m_pImpl->m_eTOXType) 2187 { 2188 case TOX_INDEX: nPos = 0; break; 2189 case TOX_CONTENT: nPos = 1; break; 2190 case TOX_USER: nPos = 2; break; 2191 default: 2192 ; 2193 } 2194 if(!xInfos[nPos].is()) 2195 { 2196 const uno::Reference< beans::XPropertySetInfo > xInfo = 2197 m_pImpl->m_rPropSet.getPropertySetInfo(); 2198 // extend PropertySetInfo! 2199 const uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties(); 2200 xInfos[nPos] = new SfxExtItemPropertySetInfo( 2201 aSwMapProvider.GetPropertyMapEntries( 2202 PROPERTY_MAP_PARAGRAPH_EXTENSIONS), 2203 aPropSeq ); 2204 } 2205 return xInfos[nPos]; 2206 } 2207 2208 /*-- 14.12.98 10:25:46--------------------------------------------------- 2209 2210 -----------------------------------------------------------------------*/ 2211 void SAL_CALL 2212 SwXDocumentIndexMark::setPropertyValue( 2213 const OUString& rPropertyName, const uno::Any& rValue) 2214 throw (beans::UnknownPropertyException, beans::PropertyVetoException, 2215 lang::IllegalArgumentException, lang::WrappedTargetException, 2216 uno::RuntimeException) 2217 { 2218 vos::OGuard aGuard(Application::GetSolarMutex()); 2219 2220 SfxItemPropertySimpleEntry const*const pEntry = 2221 m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); 2222 if (!pEntry) 2223 { 2224 throw beans::UnknownPropertyException( 2225 OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) 2226 + rPropertyName, 2227 static_cast<cppu::OWeakObject *>(this)); 2228 } 2229 if (pEntry->nFlags & beans::PropertyAttribute::READONLY) 2230 { 2231 throw beans::PropertyVetoException( 2232 OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: ")) 2233 + rPropertyName, 2234 static_cast<cppu::OWeakObject *>(this)); 2235 } 2236 2237 SwTOXType *const pType = m_pImpl->GetTOXType(); 2238 if (pType && m_pImpl->m_pTOXMark) 2239 { 2240 SwTOXMark aMark(*m_pImpl->m_pTOXMark); 2241 switch(pEntry->nWID) 2242 { 2243 case WID_ALT_TEXT: 2244 aMark.SetAlternativeText(lcl_AnyToString(rValue)); 2245 break; 2246 case WID_LEVEL: 2247 aMark.SetLevel(Min( static_cast<sal_Int8>( MAXLEVEL ), 2248 static_cast<sal_Int8>(lcl_AnyToInt16(rValue)+1))); 2249 break; 2250 case WID_PRIMARY_KEY : 2251 aMark.SetPrimaryKey(lcl_AnyToString(rValue)); 2252 break; 2253 case WID_SECONDARY_KEY: 2254 aMark.SetSecondaryKey(lcl_AnyToString(rValue)); 2255 break; 2256 case WID_MAIN_ENTRY: 2257 aMark.SetMainEntry(lcl_AnyToBool(rValue)); 2258 break; 2259 case WID_TEXT_READING: 2260 aMark.SetTextReading(lcl_AnyToString(rValue)); 2261 break; 2262 case WID_PRIMARY_KEY_READING: 2263 aMark.SetPrimaryKeyReading(lcl_AnyToString(rValue)); 2264 break; 2265 case WID_SECONDARY_KEY_READING: 2266 aMark.SetSecondaryKeyReading(lcl_AnyToString(rValue)); 2267 break; 2268 } 2269 SwTxtTOXMark const*const pTxtMark = 2270 m_pImpl->m_pTOXMark->GetTxtTOXMark(); 2271 SwPaM aPam(pTxtMark->GetTxtNode(), *pTxtMark->GetStart()); 2272 aPam.SetMark(); 2273 if(pTxtMark->GetEnd()) 2274 { 2275 aPam.GetPoint()->nContent = *pTxtMark->GetEnd(); 2276 } 2277 else 2278 { 2279 aPam.GetPoint()->nContent++; 2280 } 2281 2282 m_pImpl->ReplaceTOXMark(*pType, aMark, aPam); 2283 } 2284 else if (m_pImpl->m_bIsDescriptor) 2285 { 2286 switch(pEntry->nWID) 2287 { 2288 case WID_ALT_TEXT: 2289 m_pImpl->m_sAltText = lcl_AnyToString(rValue); 2290 break; 2291 case WID_LEVEL: 2292 { 2293 const sal_Int16 nVal = lcl_AnyToInt16(rValue); 2294 if(nVal >= 0 && nVal < MAXLEVEL) 2295 { 2296 m_pImpl->m_nLevel = nVal; 2297 } 2298 else 2299 { 2300 throw lang::IllegalArgumentException(); 2301 } 2302 } 2303 break; 2304 case WID_PRIMARY_KEY: 2305 m_pImpl->m_sPrimaryKey = lcl_AnyToString(rValue); 2306 break; 2307 case WID_SECONDARY_KEY: 2308 m_pImpl->m_sSecondaryKey = lcl_AnyToString(rValue); 2309 break; 2310 case WID_TEXT_READING: 2311 m_pImpl->m_sTextReading = lcl_AnyToString(rValue); 2312 break; 2313 case WID_PRIMARY_KEY_READING: 2314 m_pImpl->m_sPrimaryKeyReading = lcl_AnyToString(rValue); 2315 break; 2316 case WID_SECONDARY_KEY_READING: 2317 m_pImpl->m_sSecondaryKeyReading = lcl_AnyToString(rValue); 2318 break; 2319 case WID_USER_IDX_NAME: 2320 { 2321 OUString sTmp(lcl_AnyToString(rValue)); 2322 lcl_ConvertTOUNameToUserName(sTmp); 2323 m_pImpl->m_sUserIndexName = sTmp; 2324 } 2325 break; 2326 case WID_MAIN_ENTRY: 2327 m_pImpl->m_bMainEntry = lcl_AnyToBool(rValue); 2328 break; 2329 } 2330 } 2331 else 2332 { 2333 throw uno::RuntimeException(); 2334 } 2335 } 2336 2337 /*-- 14.12.98 10:25:46--------------------------------------------------- 2338 2339 -----------------------------------------------------------------------*/ 2340 uno::Any SAL_CALL 2341 SwXDocumentIndexMark::getPropertyValue(const OUString& rPropertyName) 2342 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 2343 uno::RuntimeException) 2344 { 2345 vos::OGuard aGuard(Application::GetSolarMutex()); 2346 2347 uno::Any aRet; 2348 SfxItemPropertySimpleEntry const*const pEntry = 2349 m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); 2350 if (!pEntry) 2351 { 2352 throw beans::UnknownPropertyException( 2353 OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) 2354 + rPropertyName, 2355 static_cast<cppu::OWeakObject *>(this)); 2356 } 2357 if (::sw::GetDefaultTextContentValue(aRet, rPropertyName, pEntry->nWID)) 2358 { 2359 return aRet; 2360 } 2361 2362 SwTOXType *const pType = m_pImpl->GetTOXType(); 2363 if (pType && m_pImpl->m_pTOXMark) 2364 { 2365 switch(pEntry->nWID) 2366 { 2367 case WID_ALT_TEXT: 2368 aRet <<= OUString(m_pImpl->m_pTOXMark->GetAlternativeText()); 2369 break; 2370 case WID_LEVEL: 2371 aRet <<= static_cast<sal_Int16>( 2372 m_pImpl->m_pTOXMark->GetLevel() - 1); 2373 break; 2374 case WID_PRIMARY_KEY : 2375 aRet <<= OUString(m_pImpl->m_pTOXMark->GetPrimaryKey()); 2376 break; 2377 case WID_SECONDARY_KEY: 2378 aRet <<= OUString(m_pImpl->m_pTOXMark->GetSecondaryKey()); 2379 break; 2380 case WID_TEXT_READING: 2381 aRet <<= OUString(m_pImpl->m_pTOXMark->GetTextReading()); 2382 break; 2383 case WID_PRIMARY_KEY_READING: 2384 aRet <<= OUString(m_pImpl->m_pTOXMark->GetPrimaryKeyReading()); 2385 break; 2386 case WID_SECONDARY_KEY_READING: 2387 aRet <<= OUString( 2388 m_pImpl->m_pTOXMark->GetSecondaryKeyReading()); 2389 break; 2390 case WID_USER_IDX_NAME : 2391 { 2392 OUString sTmp(pType->GetTypeName()); 2393 lcl_ConvertTOUNameToProgrammaticName(sTmp); 2394 aRet <<= sTmp; 2395 } 2396 break; 2397 case WID_MAIN_ENTRY: 2398 { 2399 const sal_Bool bTemp = m_pImpl->m_pTOXMark->IsMainEntry(); 2400 aRet <<= bTemp; 2401 } 2402 break; 2403 } 2404 } 2405 else if (m_pImpl->m_bIsDescriptor) 2406 { 2407 switch(pEntry->nWID) 2408 { 2409 case WID_ALT_TEXT: 2410 aRet <<= m_pImpl->m_sAltText; 2411 break; 2412 case WID_LEVEL: 2413 aRet <<= static_cast<sal_Int16>(m_pImpl->m_nLevel); 2414 break; 2415 case WID_PRIMARY_KEY: 2416 aRet <<= m_pImpl->m_sPrimaryKey; 2417 break; 2418 case WID_SECONDARY_KEY: 2419 aRet <<= m_pImpl->m_sSecondaryKey; 2420 break; 2421 case WID_TEXT_READING: 2422 aRet <<= m_pImpl->m_sTextReading; 2423 break; 2424 case WID_PRIMARY_KEY_READING: 2425 aRet <<= m_pImpl->m_sPrimaryKeyReading; 2426 break; 2427 case WID_SECONDARY_KEY_READING: 2428 aRet <<= m_pImpl->m_sSecondaryKeyReading; 2429 break; 2430 case WID_USER_IDX_NAME : 2431 aRet <<= m_pImpl->m_sUserIndexName; 2432 break; 2433 case WID_MAIN_ENTRY: 2434 { 2435 aRet <<= static_cast<sal_Bool>(m_pImpl->m_bMainEntry); 2436 } 2437 break; 2438 } 2439 } 2440 else 2441 { 2442 throw uno::RuntimeException(); 2443 } 2444 return aRet; 2445 } 2446 2447 /*-- 14.12.98 10:25:46--------------------------------------------------- 2448 2449 -----------------------------------------------------------------------*/ 2450 void SAL_CALL 2451 SwXDocumentIndexMark::addPropertyChangeListener( 2452 const ::rtl::OUString& /*rPropertyName*/, 2453 const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) 2454 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 2455 uno::RuntimeException) 2456 { 2457 OSL_ENSURE(false, 2458 "SwXDocumentIndexMark::addPropertyChangeListener(): not implemented"); 2459 } 2460 2461 void SAL_CALL 2462 SwXDocumentIndexMark::removePropertyChangeListener( 2463 const ::rtl::OUString& /*rPropertyName*/, 2464 const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) 2465 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 2466 uno::RuntimeException) 2467 { 2468 OSL_ENSURE(false, 2469 "SwXDocumentIndexMark::removePropertyChangeListener(): not implemented"); 2470 } 2471 2472 void SAL_CALL 2473 SwXDocumentIndexMark::addVetoableChangeListener( 2474 const ::rtl::OUString& /*rPropertyName*/, 2475 const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) 2476 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 2477 uno::RuntimeException) 2478 { 2479 OSL_ENSURE(false, 2480 "SwXDocumentIndexMark::addVetoableChangeListener(): not implemented"); 2481 } 2482 2483 void SAL_CALL 2484 SwXDocumentIndexMark::removeVetoableChangeListener( 2485 const ::rtl::OUString& /*rPropertyName*/, 2486 const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) 2487 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 2488 uno::RuntimeException) 2489 { 2490 OSL_ENSURE(false, 2491 "SwXDocumentIndexMark::removeVetoableChangeListener(): not implemented"); 2492 } 2493 2494 2495 /****************************************************************** 2496 * SwXDocumentIndexes 2497 ******************************************************************/ 2498 /*-- 05.05.99 13:14:59--------------------------------------------------- 2499 2500 -----------------------------------------------------------------------*/ 2501 SwXDocumentIndexes::SwXDocumentIndexes(SwDoc *const _pDoc) 2502 : SwUnoCollection(_pDoc) 2503 { 2504 } 2505 /*-- 05.05.99 13:15:00--------------------------------------------------- 2506 2507 -----------------------------------------------------------------------*/ 2508 SwXDocumentIndexes::~SwXDocumentIndexes() 2509 { 2510 } 2511 2512 /* -----------------------------06.04.00 15:08-------------------------------- 2513 2514 ---------------------------------------------------------------------------*/ 2515 OUString SAL_CALL 2516 SwXDocumentIndexes::getImplementationName() throw (uno::RuntimeException) 2517 { 2518 return C2U("SwXDocumentIndexes"); 2519 } 2520 2521 static char const*const g_ServicesDocumentIndexes[] = 2522 { 2523 "com.sun.star.text.DocumentIndexes", 2524 }; 2525 static const size_t g_nServicesDocumentIndexes( 2526 sizeof(g_ServicesDocumentIndexes)/sizeof(g_ServicesDocumentIndexes[0])); 2527 2528 sal_Bool SAL_CALL 2529 SwXDocumentIndexes::supportsService(const OUString& rServiceName) 2530 throw (uno::RuntimeException) 2531 { 2532 return ::sw::SupportsServiceImpl( 2533 g_nServicesDocumentIndexes, g_ServicesDocumentIndexes, rServiceName); 2534 } 2535 2536 uno::Sequence< OUString > SAL_CALL 2537 SwXDocumentIndexes::getSupportedServiceNames() throw (uno::RuntimeException) 2538 { 2539 return ::sw::GetSupportedServiceNamesImpl( 2540 g_nServicesDocumentIndexes, g_ServicesDocumentIndexes); 2541 } 2542 2543 /*-- 05.05.99 13:15:01--------------------------------------------------- 2544 2545 -----------------------------------------------------------------------*/ 2546 sal_Int32 SAL_CALL 2547 SwXDocumentIndexes::getCount() throw (uno::RuntimeException) 2548 { 2549 vos::OGuard aGuard(Application::GetSolarMutex()); 2550 2551 if(!IsValid()) 2552 throw uno::RuntimeException(); 2553 2554 sal_uInt32 nRet = 0; 2555 const SwSectionFmts& rFmts = GetDoc()->GetSections(); 2556 for( sal_uInt16 n = 0; n < rFmts.Count(); ++n ) 2557 { 2558 const SwSection* pSect = rFmts[ n ]->GetSection(); 2559 if( TOX_CONTENT_SECTION == pSect->GetType() && 2560 pSect->GetFmt()->GetSectionNode() ) 2561 { 2562 ++nRet; 2563 } 2564 } 2565 return nRet; 2566 } 2567 2568 /*-- 05.05.99 13:15:01--------------------------------------------------- 2569 2570 -----------------------------------------------------------------------*/ 2571 uno::Any SAL_CALL 2572 SwXDocumentIndexes::getByIndex(sal_Int32 nIndex) 2573 throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, 2574 uno::RuntimeException) 2575 { 2576 vos::OGuard aGuard(Application::GetSolarMutex()); 2577 2578 if(!IsValid()) 2579 throw uno::RuntimeException(); 2580 2581 sal_Int32 nIdx = 0; 2582 2583 const SwSectionFmts& rFmts = GetDoc()->GetSections(); 2584 for( sal_uInt16 n = 0; n < rFmts.Count(); ++n ) 2585 { 2586 const SwSection* pSect = rFmts[ n ]->GetSection(); 2587 if( TOX_CONTENT_SECTION == pSect->GetType() && 2588 pSect->GetFmt()->GetSectionNode() && 2589 nIdx++ == nIndex ) 2590 { 2591 const uno::Reference< text::XDocumentIndex > xTmp = 2592 SwXDocumentIndex::CreateXDocumentIndex( 2593 *GetDoc(), static_cast<SwTOXBaseSection const&>(*pSect)); 2594 uno::Any aRet; 2595 aRet <<= xTmp; 2596 return aRet; 2597 } 2598 } 2599 2600 throw lang::IndexOutOfBoundsException(); 2601 } 2602 2603 /*-- 31.01.00 10:12:31--------------------------------------------------- 2604 2605 -----------------------------------------------------------------------*/ 2606 uno::Any SAL_CALL 2607 SwXDocumentIndexes::getByName(const OUString& rName) 2608 throw (container::NoSuchElementException, lang::WrappedTargetException, 2609 uno::RuntimeException) 2610 { 2611 vos::OGuard aGuard(Application::GetSolarMutex()); 2612 2613 if(!IsValid()) 2614 throw uno::RuntimeException(); 2615 2616 String sToFind(rName); 2617 const SwSectionFmts& rFmts = GetDoc()->GetSections(); 2618 for( sal_uInt16 n = 0; n < rFmts.Count(); ++n ) 2619 { 2620 const SwSection* pSect = rFmts[ n ]->GetSection(); 2621 if( TOX_CONTENT_SECTION == pSect->GetType() && 2622 pSect->GetFmt()->GetSectionNode() && 2623 (static_cast<SwTOXBaseSection const*>(pSect)->GetTOXName() 2624 == sToFind)) 2625 { 2626 const uno::Reference< text::XDocumentIndex > xTmp = 2627 SwXDocumentIndex::CreateXDocumentIndex( 2628 *GetDoc(), static_cast<SwTOXBaseSection const&>(*pSect)); 2629 uno::Any aRet; 2630 aRet <<= xTmp; 2631 return aRet; 2632 } 2633 } 2634 throw container::NoSuchElementException(); 2635 } 2636 2637 /*-- 31.01.00 10:12:31--------------------------------------------------- 2638 2639 -----------------------------------------------------------------------*/ 2640 uno::Sequence< OUString > SAL_CALL 2641 SwXDocumentIndexes::getElementNames() throw (uno::RuntimeException) 2642 { 2643 vos::OGuard aGuard(Application::GetSolarMutex()); 2644 2645 if(!IsValid()) 2646 throw uno::RuntimeException(); 2647 2648 const SwSectionFmts& rFmts = GetDoc()->GetSections(); 2649 sal_Int32 nCount = 0; 2650 sal_uInt16 n; 2651 for( n = 0; n < rFmts.Count(); ++n ) 2652 { 2653 SwSection const*const pSect = rFmts[ n ]->GetSection(); 2654 if( TOX_CONTENT_SECTION == pSect->GetType() && 2655 pSect->GetFmt()->GetSectionNode() ) 2656 { 2657 ++nCount; 2658 } 2659 } 2660 2661 uno::Sequence< OUString > aRet(nCount); 2662 OUString* pArray = aRet.getArray(); 2663 sal_uInt16 nCnt; 2664 for( n = 0, nCnt = 0; n < rFmts.Count(); ++n ) 2665 { 2666 SwSection const*const pSect = rFmts[ n ]->GetSection(); 2667 if( TOX_CONTENT_SECTION == pSect->GetType() && 2668 pSect->GetFmt()->GetSectionNode()) 2669 { 2670 pArray[nCnt++] = OUString( 2671 static_cast<SwTOXBaseSection const*>(pSect)->GetTOXName()); 2672 } 2673 } 2674 return aRet; 2675 } 2676 2677 /*-- 31.01.00 10:12:31--------------------------------------------------- 2678 2679 -----------------------------------------------------------------------*/ 2680 sal_Bool SAL_CALL 2681 SwXDocumentIndexes::hasByName(const OUString& rName) 2682 throw (uno::RuntimeException) 2683 { 2684 vos::OGuard aGuard(Application::GetSolarMutex()); 2685 2686 if(!IsValid()) 2687 throw uno::RuntimeException(); 2688 2689 String sToFind(rName); 2690 const SwSectionFmts& rFmts = GetDoc()->GetSections(); 2691 for( sal_uInt16 n = 0; n < rFmts.Count(); ++n ) 2692 { 2693 SwSection const*const pSect = rFmts[ n ]->GetSection(); 2694 if( TOX_CONTENT_SECTION == pSect->GetType() && 2695 pSect->GetFmt()->GetSectionNode()) 2696 { 2697 if (static_cast<SwTOXBaseSection const*>(pSect)->GetTOXName() 2698 == sToFind) 2699 { 2700 return sal_True; 2701 } 2702 } 2703 } 2704 return sal_False; 2705 } 2706 2707 /*-- 05.05.99 13:15:01--------------------------------------------------- 2708 2709 -----------------------------------------------------------------------*/ 2710 uno::Type SAL_CALL 2711 SwXDocumentIndexes::getElementType() throw (uno::RuntimeException) 2712 { 2713 return text::XDocumentIndex::static_type(); 2714 } 2715 /*-- 05.05.99 13:15:02--------------------------------------------------- 2716 2717 -----------------------------------------------------------------------*/ 2718 sal_Bool SAL_CALL 2719 SwXDocumentIndexes::hasElements() throw (uno::RuntimeException) 2720 { 2721 return 0 != getCount(); 2722 } 2723 2724 /****************************************************************** 2725 * SwXDocumentIndex::StyleAccess_Impl 2726 ******************************************************************/ 2727 2728 /*-- 13.09.99 16:52:28--------------------------------------------------- 2729 2730 -----------------------------------------------------------------------*/ 2731 SwXDocumentIndex::StyleAccess_Impl::StyleAccess_Impl( 2732 SwXDocumentIndex& rParentIdx) 2733 : m_xParent(&rParentIdx) 2734 { 2735 } 2736 /*-- 13.09.99 16:52:29--------------------------------------------------- 2737 2738 -----------------------------------------------------------------------*/ 2739 SwXDocumentIndex::StyleAccess_Impl::~StyleAccess_Impl() 2740 { 2741 } 2742 2743 /* -----------------------------06.04.00 15:08-------------------------------- 2744 2745 ---------------------------------------------------------------------------*/ 2746 OUString SAL_CALL 2747 SwXDocumentIndex::StyleAccess_Impl::getImplementationName() 2748 throw (uno::RuntimeException) 2749 { 2750 return C2U("SwXDocumentIndex::StyleAccess_Impl"); 2751 } 2752 2753 static char const*const g_ServicesIndexStyleAccess[] = 2754 { 2755 "com.sun.star.text.DocumentIndexParagraphStyles", 2756 }; 2757 static const size_t g_nServicesIndexStyleAccess( 2758 sizeof(g_ServicesIndexStyleAccess)/sizeof(g_ServicesIndexStyleAccess[0])); 2759 2760 sal_Bool SAL_CALL 2761 SwXDocumentIndex::StyleAccess_Impl::supportsService( 2762 const OUString& rServiceName) 2763 throw (uno::RuntimeException) 2764 { 2765 return ::sw::SupportsServiceImpl( 2766 g_nServicesIndexStyleAccess, g_ServicesIndexStyleAccess, rServiceName); 2767 } 2768 2769 uno::Sequence< OUString > SAL_CALL 2770 SwXDocumentIndex::StyleAccess_Impl::getSupportedServiceNames() 2771 throw (uno::RuntimeException) 2772 { 2773 return ::sw::GetSupportedServiceNamesImpl( 2774 g_nServicesIndexStyleAccess, g_ServicesIndexStyleAccess); 2775 } 2776 2777 /*-- 13.09.99 16:52:29--------------------------------------------------- 2778 2779 -----------------------------------------------------------------------*/ 2780 void SAL_CALL 2781 SwXDocumentIndex::StyleAccess_Impl::replaceByIndex( 2782 sal_Int32 nIndex, const uno::Any& rElement) 2783 throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, 2784 lang::WrappedTargetException, uno::RuntimeException) 2785 { 2786 vos::OGuard aGuard(Application::GetSolarMutex()); 2787 2788 if(nIndex < 0 || nIndex > MAXLEVEL) 2789 { 2790 throw lang::IndexOutOfBoundsException(); 2791 } 2792 2793 SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() ); 2794 2795 uno::Sequence<OUString> aSeq; 2796 if(!(rElement >>= aSeq)) 2797 { 2798 throw lang::IllegalArgumentException(); 2799 } 2800 2801 const sal_Int32 nStyles = aSeq.getLength(); 2802 const OUString* pStyles = aSeq.getConstArray(); 2803 String sSetStyles; 2804 String aString; 2805 for(sal_Int32 i = 0; i < nStyles; i++) 2806 { 2807 if(i) 2808 { 2809 sSetStyles += TOX_STYLE_DELIMITER; 2810 } 2811 SwStyleNameMapper::FillUIName(pStyles[i], aString, 2812 nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); 2813 sSetStyles += aString; 2814 } 2815 rTOXBase.SetStyleNames(sSetStyles, static_cast<sal_uInt16>(nIndex)); 2816 } 2817 /*-- 13.09.99 16:52:29--------------------------------------------------- 2818 2819 -----------------------------------------------------------------------*/ 2820 sal_Int32 SAL_CALL 2821 SwXDocumentIndex::StyleAccess_Impl::getCount() throw (uno::RuntimeException) 2822 { 2823 return MAXLEVEL; 2824 } 2825 /*-- 13.09.99 16:52:30--------------------------------------------------- 2826 2827 -----------------------------------------------------------------------*/ 2828 uno::Any SAL_CALL 2829 SwXDocumentIndex::StyleAccess_Impl::getByIndex(sal_Int32 nIndex) 2830 throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, 2831 uno::RuntimeException) 2832 { 2833 vos::OGuard aGuard(Application::GetSolarMutex()); 2834 2835 if(nIndex < 0 || nIndex > MAXLEVEL) 2836 { 2837 throw lang::IndexOutOfBoundsException(); 2838 } 2839 2840 SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() ); 2841 2842 const String& rStyles = 2843 rTOXBase.GetStyleNames(static_cast<sal_uInt16>(nIndex)); 2844 const sal_uInt16 nStyles = rStyles.GetTokenCount(TOX_STYLE_DELIMITER); 2845 uno::Sequence<OUString> aStyles(nStyles); 2846 OUString* pStyles = aStyles.getArray(); 2847 String aString; 2848 for(sal_uInt16 i = 0; i < nStyles; i++) 2849 { 2850 SwStyleNameMapper::FillProgName( 2851 rStyles.GetToken(i, TOX_STYLE_DELIMITER), 2852 aString, 2853 nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, 2854 sal_True); 2855 pStyles[i] = OUString( aString ); 2856 } 2857 uno::Any aRet(&aStyles, ::getCppuType((uno::Sequence<OUString>*)0)); 2858 return aRet; 2859 } 2860 /*-- 13.09.99 16:52:30--------------------------------------------------- 2861 2862 -----------------------------------------------------------------------*/ 2863 uno::Type SAL_CALL 2864 SwXDocumentIndex::StyleAccess_Impl::getElementType() 2865 throw (uno::RuntimeException) 2866 { 2867 return ::getCppuType((uno::Sequence<OUString>*)0); 2868 } 2869 /*-- 13.09.99 16:52:30--------------------------------------------------- 2870 2871 -----------------------------------------------------------------------*/ 2872 sal_Bool SAL_CALL 2873 SwXDocumentIndex::StyleAccess_Impl::hasElements() throw (uno::RuntimeException) 2874 { 2875 return sal_True; 2876 } 2877 2878 /****************************************************************** 2879 * SwXDocumentIndex::TokenAccess_Impl 2880 ******************************************************************/ 2881 /*-- 13.09.99 16:52:28--------------------------------------------------- 2882 2883 -----------------------------------------------------------------------*/ 2884 SwXDocumentIndex::TokenAccess_Impl::TokenAccess_Impl( 2885 SwXDocumentIndex& rParentIdx) 2886 : m_xParent(&rParentIdx) 2887 { 2888 } 2889 /*-- 13.09.99 16:52:29--------------------------------------------------- 2890 2891 -----------------------------------------------------------------------*/ 2892 SwXDocumentIndex::TokenAccess_Impl::~TokenAccess_Impl() 2893 { 2894 } 2895 2896 /* -----------------------------06.04.00 15:08-------------------------------- 2897 2898 ---------------------------------------------------------------------------*/ 2899 OUString SAL_CALL 2900 SwXDocumentIndex::TokenAccess_Impl::getImplementationName() 2901 throw (uno::RuntimeException) 2902 { 2903 return C2U("SwXDocumentIndex::TokenAccess_Impl"); 2904 } 2905 2906 static char const*const g_ServicesIndexTokenAccess[] = 2907 { 2908 "com.sun.star.text.DocumentIndexLevelFormat", 2909 }; 2910 static const size_t g_nServicesIndexTokenAccess( 2911 sizeof(g_ServicesIndexTokenAccess)/sizeof(g_ServicesIndexTokenAccess[0])); 2912 2913 sal_Bool SAL_CALL 2914 SwXDocumentIndex::TokenAccess_Impl::supportsService( 2915 const OUString& rServiceName) 2916 throw (uno::RuntimeException) 2917 { 2918 return ::sw::SupportsServiceImpl( 2919 g_nServicesIndexTokenAccess, g_ServicesIndexTokenAccess, rServiceName); 2920 } 2921 2922 uno::Sequence< OUString > SAL_CALL 2923 SwXDocumentIndex::TokenAccess_Impl::getSupportedServiceNames() 2924 throw (uno::RuntimeException) 2925 { 2926 return ::sw::GetSupportedServiceNamesImpl( 2927 g_nServicesIndexTokenAccess, g_ServicesIndexTokenAccess); 2928 } 2929 2930 struct TokenType { 2931 const char *pName; 2932 const enum FormTokenType eTokenType; 2933 }; 2934 2935 static const struct TokenType g_TokenTypes[] = 2936 { 2937 { "TokenEntryNumber", TOKEN_ENTRY_NO }, 2938 { "TokenEntryText", TOKEN_ENTRY_TEXT }, 2939 { "TokenTabStop", TOKEN_TAB_STOP }, 2940 { "TokenText", TOKEN_TEXT }, 2941 { "TokenPageNumber", TOKEN_PAGE_NUMS }, 2942 { "TokenChapterInfo", TOKEN_CHAPTER_INFO }, 2943 { "TokenHyperlinkStart", TOKEN_LINK_START }, 2944 { "TokenHyperlinkEnd", TOKEN_LINK_END }, 2945 { "TokenBibliographyDataField", TOKEN_AUTHORITY }, 2946 { 0, static_cast<enum FormTokenType>(0) } 2947 }; 2948 2949 /*-- 13.09.99 16:52:29--------------------------------------------------- 2950 2951 -----------------------------------------------------------------------*/ 2952 void SAL_CALL 2953 SwXDocumentIndex::TokenAccess_Impl::replaceByIndex( 2954 sal_Int32 nIndex, const uno::Any& rElement) 2955 throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, 2956 lang::WrappedTargetException, uno::RuntimeException) 2957 { 2958 vos::OGuard aGuard(Application::GetSolarMutex()); 2959 2960 SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() ); 2961 2962 if ((nIndex < 0) || (nIndex > rTOXBase.GetTOXForm().GetFormMax())) 2963 { 2964 throw lang::IndexOutOfBoundsException(); 2965 } 2966 2967 uno::Sequence<beans::PropertyValues> aSeq; 2968 if(!(rElement >>= aSeq)) 2969 { 2970 throw lang::IllegalArgumentException(); 2971 } 2972 2973 String sPattern; 2974 const sal_Int32 nTokens = aSeq.getLength(); 2975 const beans::PropertyValues* pTokens = aSeq.getConstArray(); 2976 for(sal_Int32 i = 0; i < nTokens; i++) 2977 { 2978 const beans::PropertyValue* pProperties = pTokens[i].getConstArray(); 2979 const sal_Int32 nProperties = pTokens[i].getLength(); 2980 //create an invalid token 2981 SwFormToken aToken(TOKEN_END); 2982 for(sal_Int32 j = 0; j < nProperties; j++) 2983 { 2984 if (pProperties[j].Name.equalsAscii("TokenType")) 2985 { 2986 const OUString sTokenType = 2987 lcl_AnyToString(pProperties[j].Value); 2988 for (TokenType const* pTokenType = g_TokenTypes; 2989 pTokenType->pName; ++pTokenType) 2990 { 2991 if (sTokenType.equalsAscii(pTokenType->pName)) 2992 { 2993 aToken.eTokenType = pTokenType->eTokenType; 2994 break; 2995 } 2996 } 2997 } 2998 else if (pProperties[j].Name.equalsAsciiL( 2999 RTL_CONSTASCII_STRINGPARAM("CharacterStyleName"))) 3000 { 3001 String sCharStyleName; 3002 SwStyleNameMapper::FillUIName( 3003 lcl_AnyToString(pProperties[j].Value), 3004 sCharStyleName, 3005 nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, 3006 sal_True); 3007 aToken.sCharStyleName = sCharStyleName; 3008 aToken.nPoolId = SwStyleNameMapper::GetPoolIdFromUIName ( 3009 sCharStyleName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); 3010 } 3011 else if (pProperties[j].Name.equalsAsciiL( 3012 RTL_CONSTASCII_STRINGPARAM("TabStopRightAligned"))) 3013 { 3014 const sal_Bool bRight = lcl_AnyToBool(pProperties[j].Value); 3015 aToken.eTabAlign = bRight ? 3016 SVX_TAB_ADJUST_END : SVX_TAB_ADJUST_LEFT; 3017 } 3018 else if (pProperties[j].Name.equalsAsciiL( 3019 RTL_CONSTASCII_STRINGPARAM("TabStopPosition"))) 3020 { 3021 sal_Int32 nPosition = 0; 3022 if (!(pProperties[j].Value >>= nPosition)) 3023 { 3024 throw lang::IllegalArgumentException(); 3025 } 3026 nPosition = MM100_TO_TWIP(nPosition); 3027 if(nPosition < 0) 3028 { 3029 throw lang::IllegalArgumentException(); 3030 } 3031 aToken.nTabStopPosition = nPosition; 3032 } 3033 else if (pProperties[j].Name.equalsAsciiL( 3034 RTL_CONSTASCII_STRINGPARAM("TabStopFillCharacter"))) 3035 { 3036 const OUString sFillChar = 3037 lcl_AnyToString(pProperties[j].Value); 3038 if (sFillChar.getLength() > 1) 3039 { 3040 throw lang::IllegalArgumentException(); 3041 } 3042 aToken.cTabFillChar = 3043 (sFillChar.getLength()) ? sFillChar[0] : ' '; 3044 } 3045 else if (pProperties[j].Name.equalsAsciiL( 3046 RTL_CONSTASCII_STRINGPARAM("Text"))) 3047 { 3048 const OUString sText = lcl_AnyToString(pProperties[j].Value); 3049 aToken.sText = sText; 3050 } 3051 else if (pProperties[j].Name.equalsAsciiL( 3052 RTL_CONSTASCII_STRINGPARAM("ChapterFormat"))) 3053 { 3054 sal_Int16 nFormat = lcl_AnyToInt16(pProperties[j].Value); 3055 switch(nFormat) 3056 { 3057 case text::ChapterFormat::NUMBER: 3058 nFormat = CF_NUMBER; 3059 break; 3060 case text::ChapterFormat::NAME: 3061 nFormat = CF_TITLE; 3062 break; 3063 case text::ChapterFormat::NAME_NUMBER: 3064 nFormat = CF_NUM_TITLE; 3065 break; 3066 case text::ChapterFormat::NO_PREFIX_SUFFIX: 3067 nFormat = CF_NUMBER_NOPREPST; 3068 break; 3069 case text::ChapterFormat::DIGIT: 3070 nFormat = CF_NUM_NOPREPST_TITLE; 3071 break; 3072 default: 3073 throw lang::IllegalArgumentException(); 3074 } 3075 aToken.nChapterFormat = nFormat; 3076 } 3077 //--->i53420 3078 else if (pProperties[j].Name.equalsAsciiL( 3079 RTL_CONSTASCII_STRINGPARAM("ChapterLevel"))) 3080 { 3081 const sal_Int16 nLevel = lcl_AnyToInt16(pProperties[j].Value); 3082 if( nLevel < 1 || nLevel > MAXLEVEL ) 3083 { 3084 throw lang::IllegalArgumentException(); 3085 } 3086 aToken.nOutlineLevel = nLevel; 3087 } 3088 //<--- 3089 else if (pProperties[j].Name.equalsAsciiL( 3090 RTL_CONSTASCII_STRINGPARAM("BibliographyDataField"))) 3091 { 3092 sal_Int16 nType = 0; 3093 pProperties[j].Value >>= nType; 3094 if(nType < 0 || nType > text::BibliographyDataField::ISBN) 3095 { 3096 lang::IllegalArgumentException aExcept; 3097 aExcept.Message = C2U("BibliographyDataField - wrong value"); 3098 aExcept.ArgumentPosition = static_cast< sal_Int16 >(j); 3099 throw aExcept; 3100 } 3101 aToken.nAuthorityField = nType; 3102 } 3103 // #i21237# 3104 else if (pProperties[j].Name.equalsAsciiL( 3105 RTL_CONSTASCII_STRINGPARAM("WithTab"))) 3106 { 3107 aToken.bWithTab = lcl_AnyToBool(pProperties[j].Value); 3108 } 3109 3110 } 3111 //exception if wrong TokenType 3112 if(TOKEN_END <= aToken.eTokenType ) 3113 { 3114 throw lang::IllegalArgumentException(); 3115 } 3116 // set TokenType from TOKEN_ENTRY_TEXT to TOKEN_ENTRY if it is 3117 // not a content index 3118 if(TOKEN_ENTRY_TEXT == aToken.eTokenType && 3119 (TOX_CONTENT != rTOXBase.GetType())) 3120 { 3121 aToken.eTokenType = TOKEN_ENTRY; 3122 } 3123 //---> i53420 3124 // check for chapter format allowed values if it was TOKEN_ENTRY_NO type 3125 // only allowed value are CF_NUMBER and CF_NUM_NOPREPST_TITLE 3126 // reading from file 3127 if( TOKEN_ENTRY_NO == aToken.eTokenType ) 3128 { 3129 switch(aToken.nChapterFormat) 3130 { 3131 case CF_NUMBER: 3132 case CF_NUM_NOPREPST_TITLE: 3133 break; 3134 default: 3135 throw lang::IllegalArgumentException(); 3136 } 3137 } 3138 //<--- 3139 sPattern += aToken.GetString(); 3140 } 3141 SwForm aForm(rTOXBase.GetTOXForm()); 3142 aForm.SetPattern(static_cast<sal_uInt16>(nIndex), sPattern); 3143 rTOXBase.SetTOXForm(aForm); 3144 } 3145 3146 /*-- 13.09.99 16:52:29--------------------------------------------------- 3147 3148 -----------------------------------------------------------------------*/ 3149 sal_Int32 SAL_CALL 3150 SwXDocumentIndex::TokenAccess_Impl::getCount() throw (uno::RuntimeException) 3151 { 3152 vos::OGuard aGuard(Application::GetSolarMutex()); 3153 3154 const sal_Int32 nRet = m_xParent->m_pImpl->GetFormMax(); 3155 return nRet; 3156 } 3157 3158 /*-- 13.09.99 16:52:30--------------------------------------------------- 3159 3160 -----------------------------------------------------------------------*/ 3161 uno::Any SAL_CALL 3162 SwXDocumentIndex::TokenAccess_Impl::getByIndex(sal_Int32 nIndex) 3163 throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, 3164 uno::RuntimeException) 3165 { 3166 vos::OGuard aGuard(Application::GetSolarMutex()); 3167 3168 SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() ); 3169 3170 if ((nIndex < 0) || (nIndex > rTOXBase.GetTOXForm().GetFormMax())) 3171 { 3172 throw lang::IndexOutOfBoundsException(); 3173 } 3174 3175 // #i21237# 3176 SwFormTokens aPattern = rTOXBase.GetTOXForm(). 3177 GetPattern(static_cast<sal_uInt16>(nIndex)); 3178 SwFormTokens::iterator aIt = aPattern.begin(); 3179 3180 sal_uInt16 nTokenCount = 0; 3181 uno::Sequence< beans::PropertyValues > aRetSeq; 3182 String aString; 3183 while(aIt != aPattern.end()) // #i21237# 3184 { 3185 nTokenCount++; 3186 aRetSeq.realloc(nTokenCount); 3187 beans::PropertyValues* pTokenProps = aRetSeq.getArray(); 3188 SwFormToken aToken = *aIt; // #i21237# 3189 3190 uno::Sequence< beans::PropertyValue >& rCurTokenSeq = 3191 pTokenProps[nTokenCount-1]; 3192 SwStyleNameMapper::FillProgName( 3193 aToken.sCharStyleName, 3194 aString, 3195 nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, 3196 sal_True ); 3197 const OUString aProgCharStyle( aString ); 3198 switch(aToken.eTokenType) 3199 { 3200 case TOKEN_ENTRY_NO: 3201 { 3202 //--->i53420 3203 // writing to file (from doc to properties) 3204 sal_Int32 nElements = 2; 3205 sal_Int32 nCurrentElement = 0; 3206 3207 // check for default value 3208 if (aToken.nChapterFormat != CF_NUMBER) 3209 { 3210 nElements++;//we need the element 3211 } 3212 if( aToken.nOutlineLevel != MAXLEVEL ) 3213 { 3214 nElements++; 3215 } 3216 3217 rCurTokenSeq.realloc( nElements ); 3218 3219 beans::PropertyValue* pArr = rCurTokenSeq.getArray(); 3220 3221 pArr[nCurrentElement].Name = C2U("TokenType"); 3222 pArr[nCurrentElement++].Value <<= 3223 OUString::createFromAscii("TokenEntryNumber"); 3224 3225 pArr[nCurrentElement].Name = C2U("CharacterStyleName"); 3226 pArr[nCurrentElement++].Value <<= aProgCharStyle; 3227 if( aToken.nChapterFormat != CF_NUMBER ) 3228 { 3229 pArr[nCurrentElement].Name = C2U("ChapterFormat"); 3230 sal_Int16 nVal; 3231 // the allowed values for chapter format, when used as entry number, 3232 // are CF_NUMBER and CF_NUM_NOPREPST_TITLE only, all else forced to 3233 //CF_NUMBER 3234 switch(aToken.nChapterFormat) 3235 { 3236 default: 3237 case CF_NUMBER: 3238 nVal = text::ChapterFormat::NUMBER; 3239 break; 3240 case CF_NUM_NOPREPST_TITLE: 3241 nVal = text::ChapterFormat::DIGIT; 3242 break; 3243 } 3244 pArr[nCurrentElement++].Value <<= nVal; 3245 } 3246 3247 // only a ChapterLevel != MAXLEVEL is registered 3248 if (aToken.nOutlineLevel != MAXLEVEL) 3249 { 3250 pArr[nCurrentElement].Name = C2U("ChapterLevel"); 3251 pArr[nCurrentElement].Value <<= aToken.nOutlineLevel; 3252 } 3253 //<--- 3254 } 3255 break; 3256 case TOKEN_ENTRY: // no difference between Entry and Entry Text 3257 case TOKEN_ENTRY_TEXT: 3258 { 3259 rCurTokenSeq.realloc( 2 ); 3260 beans::PropertyValue* pArr = rCurTokenSeq.getArray(); 3261 3262 pArr[0].Name = C2U("TokenType"); 3263 pArr[0].Value <<= OUString::createFromAscii("TokenEntryText"); 3264 3265 pArr[1].Name = C2U("CharacterStyleName"); 3266 pArr[1].Value <<= aProgCharStyle; 3267 } 3268 break; 3269 case TOKEN_TAB_STOP: 3270 { 3271 rCurTokenSeq.realloc(5); // #i21237# 3272 beans::PropertyValue* pArr = rCurTokenSeq.getArray(); 3273 3274 pArr[0].Name = C2U("TokenType"); 3275 pArr[0].Value <<= OUString::createFromAscii("TokenTabStop"); 3276 3277 if(SVX_TAB_ADJUST_END == aToken.eTabAlign) 3278 { 3279 pArr[1].Name = C2U("TabStopRightAligned"); 3280 sal_Bool bTemp = sal_True; 3281 pArr[1].Value.setValue(&bTemp, ::getCppuBooleanType()); 3282 } 3283 else 3284 { 3285 pArr[1].Name = C2U("TabStopPosition"); 3286 sal_Int32 nPos = (TWIP_TO_MM100(aToken.nTabStopPosition)); 3287 if(nPos < 0) 3288 nPos = 0; 3289 pArr[1].Value <<= (sal_Int32)nPos; 3290 } 3291 pArr[2].Name = C2U("TabStopFillCharacter"); 3292 pArr[2].Value <<= OUString(aToken.cTabFillChar); 3293 pArr[3].Name = C2U("CharacterStyleName"); 3294 pArr[3].Value <<= aProgCharStyle; 3295 // #i21237# 3296 pArr[4].Name = C2U("WithTab"); 3297 pArr[4].Value <<= static_cast<sal_Bool>(aToken.bWithTab); 3298 } 3299 break; 3300 case TOKEN_TEXT: 3301 { 3302 rCurTokenSeq.realloc( 3 ); 3303 beans::PropertyValue* pArr = rCurTokenSeq.getArray(); 3304 3305 pArr[0].Name = C2U("TokenType"); 3306 pArr[0].Value <<= OUString::createFromAscii("TokenText"); 3307 3308 pArr[1].Name = C2U("CharacterStyleName"); 3309 pArr[1].Value <<= aProgCharStyle; 3310 3311 pArr[2].Name = C2U("Text"); 3312 pArr[2].Value <<= OUString(aToken.sText); 3313 } 3314 break; 3315 case TOKEN_PAGE_NUMS: 3316 { 3317 rCurTokenSeq.realloc( 2 ); 3318 beans::PropertyValue* pArr = rCurTokenSeq.getArray(); 3319 3320 pArr[0].Name = C2U("TokenType"); 3321 pArr[0].Value <<= OUString::createFromAscii("TokenPageNumber"); 3322 3323 pArr[1].Name = C2U("CharacterStyleName"); 3324 pArr[1].Value <<= aProgCharStyle; 3325 } 3326 break; 3327 case TOKEN_CHAPTER_INFO: 3328 { 3329 rCurTokenSeq.realloc( 4 ); 3330 beans::PropertyValue* pArr = rCurTokenSeq.getArray(); 3331 3332 pArr[0].Name = C2U("TokenType"); 3333 pArr[0].Value <<= OUString::createFromAscii("TokenChapterInfo"); 3334 3335 pArr[1].Name = C2U("CharacterStyleName"); 3336 pArr[1].Value <<= aProgCharStyle; 3337 3338 pArr[2].Name = C2U("ChapterFormat"); 3339 sal_Int16 nVal = text::ChapterFormat::NUMBER; 3340 switch(aToken.nChapterFormat) 3341 { 3342 case CF_NUMBER: 3343 nVal = text::ChapterFormat::NUMBER; 3344 break; 3345 case CF_TITLE: 3346 nVal = text::ChapterFormat::NAME; 3347 break; 3348 case CF_NUM_TITLE: 3349 nVal = text::ChapterFormat::NAME_NUMBER; 3350 break; 3351 case CF_NUMBER_NOPREPST: 3352 nVal = text::ChapterFormat::NO_PREFIX_SUFFIX; 3353 break; 3354 case CF_NUM_NOPREPST_TITLE: 3355 nVal = text::ChapterFormat::DIGIT; 3356 break; 3357 } 3358 pArr[2].Value <<= nVal; 3359 //--->i53420 3360 pArr[3].Name = C2U("ChapterLevel"); 3361 // 3362 pArr[3].Value <<= aToken.nOutlineLevel; 3363 //<--- 3364 } 3365 break; 3366 case TOKEN_LINK_START: 3367 { 3368 rCurTokenSeq.realloc( 2 ); 3369 beans::PropertyValue* pArr = rCurTokenSeq.getArray(); 3370 3371 pArr[0].Name = C2U("TokenType"); 3372 pArr[0].Value <<= 3373 OUString::createFromAscii("TokenHyperlinkStart"); 3374 pArr[1].Name = C2U("CharacterStyleName"); 3375 pArr[1].Value <<= aProgCharStyle; 3376 } 3377 break; 3378 case TOKEN_LINK_END: 3379 { 3380 rCurTokenSeq.realloc( 1 ); 3381 beans::PropertyValue* pArr = rCurTokenSeq.getArray(); 3382 3383 pArr[0].Name = C2U("TokenType"); 3384 pArr[0].Value <<= 3385 OUString::createFromAscii("TokenHyperlinkEnd"); 3386 } 3387 break; 3388 case TOKEN_AUTHORITY: 3389 { 3390 rCurTokenSeq.realloc( 3 ); 3391 beans::PropertyValue* pArr = rCurTokenSeq.getArray(); 3392 3393 pArr[0].Name = C2U("TokenType"); 3394 pArr[0].Value <<= 3395 OUString::createFromAscii("TokenBibliographyDataField"); 3396 3397 pArr[1].Name = C2U("CharacterStyleName"); 3398 pArr[1].Value <<= aProgCharStyle; 3399 3400 pArr[2].Name = C2U("BibliographyDataField"); 3401 pArr[2].Value <<= sal_Int16(aToken.nAuthorityField); 3402 } 3403 break; 3404 3405 default: 3406 ; 3407 } 3408 3409 aIt++; // #i21237# 3410 } 3411 3412 uno::Any aRet; 3413 aRet <<= aRetSeq; 3414 return aRet; 3415 } 3416 3417 /*-- 13.09.99 16:52:30--------------------------------------------------- 3418 3419 -----------------------------------------------------------------------*/ 3420 uno::Type SAL_CALL 3421 SwXDocumentIndex::TokenAccess_Impl::getElementType() 3422 throw (uno::RuntimeException) 3423 { 3424 return ::getCppuType((uno::Sequence< beans::PropertyValues >*)0); 3425 } 3426 /*-- 13.09.99 16:52:30--------------------------------------------------- 3427 3428 -----------------------------------------------------------------------*/ 3429 sal_Bool SAL_CALL 3430 SwXDocumentIndex::TokenAccess_Impl::hasElements() 3431 throw (uno::RuntimeException) 3432 { 3433 return sal_True; 3434 } 3435 3436