1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unoidx.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
36 #include <tools/debug.hxx>
37 #include <vos/mutex.hxx>
38 #include <vcl/svapp.hxx>
39 #include <svx/unolingu.hxx>
40 #include <com/sun/star/text/ChapterFormat.hpp>
41 #include <com/sun/star/text/ReferenceFieldPart.hpp>
42 #include <com/sun/star/text/BibliographyDataField.hpp>
43 #include <com/sun/star/frame/XModel.hpp>
44 #include <com/sun/star/text/XTextDocument.hpp>
45 #include <com/sun/star/beans/PropertyAttribute.hpp>
49 #include <swtypes.hxx>
50 #include <shellres.hxx>
54 #include <poolfmt.hxx>
56 #include <poolfmt.hrc>
58 #include <pagedesc.hxx>
62 #include <txttxmrk.hxx>
63 #include <unocrsr.hxx>
64 #include <unostyle.hxx>
67 #ifndef _DOCSH_HXX //autogen
71 #include <SwStyleNameMapper.hxx>
73 using namespace ::com::sun::star
;
74 using ::rtl::OUString
;
76 //-----------------------------------------------------------------------------
77 String
lcl_AnyToString(uno::Any rVal
) throw(lang::IllegalArgumentException
)
81 throw lang::IllegalArgumentException();
84 //-----------------------------------------------------------------------------
85 sal_Int16
lcl_AnyToInt16(uno::Any rVal
) throw(lang::IllegalArgumentException
)
89 throw lang::IllegalArgumentException();
92 //-----------------------------------------------------------------------------
93 sal_Bool
lcl_AnyToBool(uno::Any rVal
) throw(lang::IllegalArgumentException
)
95 sal_Bool bRet
= sal_False
;
97 throw lang::IllegalArgumentException();
100 /******************************************************************************
102 ******************************************************************************/
103 //-----------------------------------------------------------------------------
104 void lcl_ReAssignTOXType(SwDoc
* pDoc
, SwTOXBase
& rTOXBase
, const OUString
& rNewName
)
106 sal_uInt16 nUserCount
= pDoc
->GetTOXTypeCount( TOX_USER
);
107 const SwTOXType
* pNewType
= 0;
108 for(sal_uInt16 nUser
= 0; nUser
< nUserCount
; nUser
++)
110 const SwTOXType
* pType
= pDoc
->GetTOXType( TOX_USER
, nUser
);
111 if(pType
->GetTypeName().Equals((String
)rNewName
))
119 SwTOXType
aNewType(TOX_USER
, rNewName
);
120 pNewType
= pDoc
->InsertTOXType( aNewType
);
122 //has to be non-const-casted
123 ((SwTOXType
*)pNewType
)->Add(&rTOXBase
);
125 //-----------------------------------------------------------------------------
126 static const char cUserDefined
[] = "User-Defined";
127 static const char cUserSuffix
[] = " (user)";
129 #define USER_AND_SUFFIXLEN 19
131 void lcl_ConvertTOUNameToProgrammaticName(OUString
& rTmp
)
133 ShellResource
* pShellRes
= ViewShell::GetShellRes();
135 if(rTmp
.equals(pShellRes
->aTOXUserName
))
136 rTmp
= OUString(C2U(cUserDefined
));
137 //if the version is not English but the alternative index's name is "User-Defined"
138 //a " (user)" is appended
139 else if(rTmp
.equalsAscii(cUserDefined
))
140 rTmp
+= C2U(cUserSuffix
);
142 //-----------------------------------------------------------------------------
143 void lcl_ConvertTOUNameToUserName(OUString
& rTmp
)
145 ShellResource
* pShellRes
= ViewShell::GetShellRes();
146 if(rTmp
.equalsAscii(cUserDefined
))
148 rTmp
= pShellRes
->aTOXUserName
;
150 else if(!pShellRes
->aTOXUserName
.EqualsAscii(cUserDefined
) &&
151 USER_AND_SUFFIXLEN
== rTmp
.getLength())
153 String
sToChange(rTmp
);
154 //make sure that in non-English versions the " (user)" suffix is removed
155 if(!sToChange
.SearchAscii(cUserDefined
) && USER_LEN
== sToChange
.SearchAscii(cUserSuffix
))
156 rTmp
= C2U(cUserDefined
);
160 /******************************************************************
162 ******************************************************************/
163 /* -----------------20.06.98 11:06-------------------
165 * --------------------------------------------------*/
166 class SwDocIdxProperties_Impl
169 OUString sUserTOXTypeName
;
171 SwTOXBase
& GetTOXBase() {return *pTOXBase
;}
172 SwDocIdxProperties_Impl(const SwTOXType
* pType
);
173 ~SwDocIdxProperties_Impl(){delete pTOXBase
;}
175 const OUString
& GetTypeName()const {return sUserTOXTypeName
;}
176 void SetTypeName(const OUString
& rSet
) {sUserTOXTypeName
= rSet
;}
178 /* -----------------20.06.98 11:41-------------------
180 * --------------------------------------------------*/
181 SwDocIdxProperties_Impl::SwDocIdxProperties_Impl(const SwTOXType
* pType
)
183 SwForm
aForm(pType
->GetType());
184 pTOXBase
= new SwTOXBase(pType
, aForm
,
185 nsSwTOXElement::TOX_MARK
, pType
->GetTypeName());
186 if(pType
->GetType() == TOX_CONTENT
|| pType
->GetType() == TOX_USER
)
187 pTOXBase
->SetLevel(MAXLEVEL
);
188 sUserTOXTypeName
= pType
->GetTypeName();
190 /* -----------------------------10.03.00 18:02--------------------------------
192 ---------------------------------------------------------------------------*/
193 const uno::Sequence
< sal_Int8
> & SwXDocumentIndex::getUnoTunnelId()
195 static uno::Sequence
< sal_Int8
> aSeq
= ::CreateUnoTunnelId();
198 /* -----------------------------10.03.00 18:04--------------------------------
200 ---------------------------------------------------------------------------*/
201 sal_Int64 SAL_CALL
SwXDocumentIndex::getSomething( const uno::Sequence
< sal_Int8
>& rId
)
202 throw(uno::RuntimeException
)
204 if( rId
.getLength() == 16
205 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
206 rId
.getConstArray(), 16 ) )
208 return sal::static_int_cast
< sal_Int64
>( reinterpret_cast< sal_IntPtr
>(this) );
212 /* -----------------------------06.04.00 15:01--------------------------------
214 ---------------------------------------------------------------------------*/
215 OUString
SwXDocumentIndex::getImplementationName(void) throw( uno::RuntimeException
)
217 return C2U("SwXDocumentIndex");
219 /* -----------------------------06.04.00 15:01--------------------------------
221 ---------------------------------------------------------------------------*/
222 BOOL
SwXDocumentIndex::supportsService(const OUString
& rServiceName
) throw( uno::RuntimeException
)
224 return C2U("com.sun.star.text.BaseIndex") == rServiceName
||
225 ( TOX_INDEX
== eTOXType
&& C2U("com.sun.star.text.DocumentIndex") == rServiceName
) ||
226 ( TOX_CONTENT
== eTOXType
&& C2U("com.sun.star.text.ContentIndex") == rServiceName
) ||
227 ( TOX_USER
== eTOXType
&& C2U("com.sun.star.text.UserDefinedIndex") == rServiceName
) ||
228 ( TOX_ILLUSTRATIONS
== eTOXType
&& C2U("com.sun.star.text.IllustrationsIndex") == rServiceName
) ||
229 ( TOX_TABLES
== eTOXType
&& C2U("com.sun.star.text.TableIndex") == rServiceName
) ||
230 ( TOX_OBJECTS
== eTOXType
&& C2U("com.sun.star.text.ObjectIndex") == rServiceName
) ||
231 ( TOX_AUTHORITIES
== eTOXType
&& C2U("com.sun.star.text.Bibliography") == rServiceName
);
233 /* -----------------------------06.04.00 15:01--------------------------------
235 ---------------------------------------------------------------------------*/
236 uno::Sequence
< OUString
> SwXDocumentIndex::getSupportedServiceNames(void) throw( uno::RuntimeException
)
238 uno::Sequence
< OUString
> aRet(2);
239 OUString
* pArray
= aRet
.getArray();
240 pArray
[0] = C2U("com.sun.star.text.BaseIndex");
243 case TOX_INDEX
: pArray
[1] = C2U("com.sun.star.text.DocumentIndex");break;
244 case TOX_CONTENT
: pArray
[1] = C2U("com.sun.star.text.ContentIndex");break;
245 case TOX_TABLES
: pArray
[1] = C2U("com.sun.star.text.TableIndex");break;
246 case TOX_ILLUSTRATIONS
: pArray
[1] = C2U("com.sun.star.text.IllustrationsIndex");break;
247 case TOX_OBJECTS
: pArray
[1] = C2U("com.sun.star.text.ObjectIndex");break;
248 case TOX_AUTHORITIES
: pArray
[1] = C2U("com.sun.star.text.Bibliography");break;
251 pArray
[1] = C2U("com.sun.star.text.UserDefinedIndex");
255 /*-- 14.12.98 09:35:03---------------------------------------------------
257 -----------------------------------------------------------------------*/
258 TYPEINIT1(SwXDocumentIndex
, SwClient
)
259 SwXDocumentIndex::SwXDocumentIndex(const SwTOXBaseSection
* pB
, SwDoc
* pDc
) :
260 aLstnrCntnr( (text::XTextContent
*)this),
265 bIsDescriptor(sal_False
),
272 pBase
->GetFmt()->Add(this);
273 sal_uInt16 PropertyId
;
274 eTOXType
= pBase
->SwTOXBase::GetType();
277 case TOX_INDEX
: PropertyId
= PROPERTY_MAP_INDEX_IDX
; break;
278 case TOX_CONTENT
: PropertyId
= PROPERTY_MAP_INDEX_CNTNT
; break;
279 case TOX_TABLES
: PropertyId
= PROPERTY_MAP_INDEX_TABLES
; break;
280 case TOX_ILLUSTRATIONS
: PropertyId
= PROPERTY_MAP_INDEX_ILLUSTRATIONS
; break;
281 case TOX_OBJECTS
: PropertyId
= PROPERTY_MAP_INDEX_OBJECTS
; break;
282 case TOX_AUTHORITIES
: PropertyId
= PROPERTY_MAP_BIBLIOGRAPHY
; break;
285 PropertyId
= PROPERTY_MAP_INDEX_USER
;
287 m_pPropSet
= aSwMapProvider
.GetPropertySet(PropertyId
);
290 /* -----------------15.01.99 14:59-------------------
292 * --------------------------------------------------*/
293 SwXDocumentIndex::SwXDocumentIndex(TOXTypes eType
, SwDoc
& rDoc
) :
294 aLstnrCntnr( (text::XTextContent
*)this),
298 bIsDescriptor(sal_True
),
299 pProps(new SwDocIdxProperties_Impl(rDoc
.GetTOXType(eType
, 0))),
303 sal_uInt16 PropertyId
;
306 case TOX_INDEX
: PropertyId
= PROPERTY_MAP_INDEX_IDX
; break;
307 case TOX_CONTENT
: PropertyId
= PROPERTY_MAP_INDEX_CNTNT
; break;
308 case TOX_TABLES
: PropertyId
= PROPERTY_MAP_INDEX_TABLES
; break;
309 case TOX_ILLUSTRATIONS
: PropertyId
= PROPERTY_MAP_INDEX_ILLUSTRATIONS
; break;
310 case TOX_OBJECTS
: PropertyId
= PROPERTY_MAP_INDEX_OBJECTS
; break;
311 case TOX_AUTHORITIES
: PropertyId
= PROPERTY_MAP_BIBLIOGRAPHY
; break;
314 PropertyId
= PROPERTY_MAP_INDEX_USER
;
316 m_pPropSet
= aSwMapProvider
.GetPropertySet(PropertyId
);
319 /*-- 14.12.98 09:35:04---------------------------------------------------
321 -----------------------------------------------------------------------*/
322 SwXDocumentIndex::~SwXDocumentIndex()
326 /*-- 14.12.98 09:35:05---------------------------------------------------
328 -----------------------------------------------------------------------*/
329 OUString
SwXDocumentIndex::getServiceName(void) throw( uno::RuntimeException
)
331 USHORT nObjectType
= SW_SERVICE_TYPE_INDEX
;
334 // case TOX_INDEX: break;
335 case TOX_USER
: nObjectType
= SW_SERVICE_USER_INDEX
;break;
336 case TOX_CONTENT
: nObjectType
= SW_SERVICE_CONTENT_INDEX
;break;
337 case TOX_ILLUSTRATIONS
: nObjectType
= SW_SERVICE_INDEX_ILLUSTRATIONS
;break;
338 case TOX_OBJECTS
: nObjectType
= SW_SERVICE_INDEX_OBJECTS
;break;
339 case TOX_TABLES
: nObjectType
= SW_SERVICE_INDEX_TABLES
;break;
340 case TOX_AUTHORITIES
: nObjectType
= SW_SERVICE_INDEX_BIBLIOGRAPHY
;break;
344 return SwXServiceProvider::GetProviderName(nObjectType
);
346 /*-- 14.12.98 09:35:05---------------------------------------------------
348 -----------------------------------------------------------------------*/
349 void SwXDocumentIndex::update(void) throw( uno::RuntimeException
)
351 vos::OGuard
aGuard(Application::GetSolarMutex());
352 SwSectionFmt
*pFmt
= GetFmt();
353 SwTOXBase
* pTOXBase
= pFmt
? (SwTOXBaseSection
*)pFmt
->GetSection() : 0;
355 throw uno::RuntimeException();
356 ((SwTOXBaseSection
*)pTOXBase
)->Update();
357 // Seitennummern eintragen
358 ((SwTOXBaseSection
*)pTOXBase
)->UpdatePageNum();
360 /*-- 14.12.98 09:35:05---------------------------------------------------
362 -----------------------------------------------------------------------*/
363 uno::Reference
< beans::XPropertySetInfo
> SwXDocumentIndex::getPropertySetInfo(void) throw( uno::RuntimeException
)
365 uno::Reference
< beans::XPropertySetInfo
> aRef
= m_pPropSet
->getPropertySetInfo();
368 /*-- 14.12.98 09:35:05---------------------------------------------------
370 -----------------------------------------------------------------------*/
371 void SwXDocumentIndex::setPropertyValue(const OUString
& rPropertyName
,
372 const uno::Any
& aValue
)
373 throw( beans::UnknownPropertyException
, beans::PropertyVetoException
,
374 lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
376 vos::OGuard
aGuard(Application::GetSolarMutex());
377 const SfxItemPropertySimpleEntry
* pEntry
= m_pPropSet
->getPropertyMap()->getByName(rPropertyName
);
379 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
380 if ( pEntry
->nFlags
& beans::PropertyAttribute::READONLY
)
381 throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
383 SwTOXBase
* pTOXBase
= 0;
385 pTOXBase
= (SwTOXBaseSection
*)GetFmt()->GetSection();
386 else if(bIsDescriptor
)
387 pTOXBase
= &pProps
->GetTOXBase();
390 sal_uInt16 nCreate
= pTOXBase
->GetCreateType();
391 sal_uInt16 nTOIOptions
= 0;
392 sal_uInt16 nOLEOptions
= pTOXBase
->GetOLEOptions();
393 TOXTypes eTxBaseType
= pTOXBase
->GetTOXType()->GetType();
394 if( eTxBaseType
== TOX_INDEX
)
395 nTOIOptions
= pTOXBase
->GetOptions();
396 SwForm
aForm(pTOXBase
->GetTOXForm());
397 sal_Bool bForm
= sal_False
;
398 SfxItemSet
* pAttrSet
= 0;
405 pTOXBase
->SetTitle(sNewName
);
412 pTOXBase
->SetTOXName(sNewName
);
415 case WID_USER_IDX_NAME
:
419 lcl_ConvertTOUNameToUserName(sNewName
);
420 DBG_ASSERT(TOX_USER
== eTxBaseType
, "tox type name can only be changed for user indexes");
423 OUString sTmp
= pTOXBase
->GetTOXType()->GetTypeName();
426 lcl_ReAssignTOXType(GetFmt()->GetDoc(), *pTOXBase
, sNewName
);
430 pProps
->SetTypeName(sNewName
);
435 lang::Locale aLocale
;
436 if(aValue
>>= aLocale
)
437 pTOXBase
->SetLanguage(SvxLocaleToLanguage(aLocale
));
439 throw lang::IllegalArgumentException();
442 case WID_IDX_SORT_ALGORITHM
:
446 pTOXBase
->SetSortAlgorithm(sTmp
);
448 throw lang::IllegalArgumentException();
452 pTOXBase
->SetLevel(lcl_AnyToInt16(aValue
));
454 case WID_CREATE_FROM_MARKS
:
455 nCreate
= lcl_AnyToBool(aValue
) ? nCreate
| nsSwTOXElement::TOX_MARK
: nCreate
& ~nsSwTOXElement::TOX_MARK
;
457 case WID_CREATE_FROM_OUTLINE
:
458 nCreate
= lcl_AnyToBool(aValue
) ? nCreate
| nsSwTOXElement::TOX_OUTLINELEVEL
: nCreate
& ~nsSwTOXElement::TOX_OUTLINELEVEL
;
460 // case WID_PARAGRAPH_STYLE_NAMES :DBG_ERROR("not implemented")
462 case WID_CREATE_FROM_CHAPTER
:
463 pTOXBase
->SetFromChapter(lcl_AnyToBool(aValue
));
465 case WID_CREATE_FROM_LABELS
:
466 pTOXBase
->SetFromObjectNames(! lcl_AnyToBool(aValue
));
470 sal_Bool bSet
= lcl_AnyToBool(aValue
);
471 pTOXBase
->SetProtected(bSet
);
473 ((SwTOXBaseSection
*)pTOXBase
)->SetProtect(bSet
);
476 case WID_USE_ALPHABETICAL_SEPARATORS
:
477 nTOIOptions
= lcl_AnyToBool(aValue
) ?
478 nTOIOptions
| nsSwTOIOptions::TOI_ALPHA_DELIMITTER
: nTOIOptions
& ~nsSwTOIOptions::TOI_ALPHA_DELIMITTER
;
480 case WID_USE_KEY_AS_ENTRY
:
481 nTOIOptions
= lcl_AnyToBool(aValue
) ?
482 nTOIOptions
| nsSwTOIOptions::TOI_KEY_AS_ENTRY
: nTOIOptions
& ~nsSwTOIOptions::TOI_KEY_AS_ENTRY
;
484 case WID_USE_COMBINED_ENTRIES
:
485 nTOIOptions
= lcl_AnyToBool(aValue
) ?
486 nTOIOptions
| nsSwTOIOptions::TOI_SAME_ENTRY
: nTOIOptions
& ~nsSwTOIOptions::TOI_SAME_ENTRY
;
488 case WID_IS_CASE_SENSITIVE
:
489 nTOIOptions
= lcl_AnyToBool(aValue
) ?
490 nTOIOptions
| nsSwTOIOptions::TOI_CASE_SENSITIVE
: nTOIOptions
& ~nsSwTOIOptions::TOI_CASE_SENSITIVE
;
493 nTOIOptions
= lcl_AnyToBool(aValue
) ?
494 nTOIOptions
| nsSwTOIOptions::TOI_FF
: nTOIOptions
& ~nsSwTOIOptions::TOI_FF
;
497 nTOIOptions
= lcl_AnyToBool(aValue
) ?
498 nTOIOptions
| nsSwTOIOptions::TOI_DASH
: nTOIOptions
& ~nsSwTOIOptions::TOI_DASH
;
500 case WID_USE_UPPER_CASE
:
501 nTOIOptions
= lcl_AnyToBool(aValue
) ?
502 nTOIOptions
| nsSwTOIOptions::TOI_INITIAL_CAPS
: nTOIOptions
& ~nsSwTOIOptions::TOI_INITIAL_CAPS
;
504 case WID_IS_COMMA_SEPARATED
:
506 aForm
.SetCommaSeparated(lcl_AnyToBool(aValue
));
508 case WID_LABEL_CATEGORY
:
510 // convert file-format/API/external programmatic english name
511 // to internal UI name before usage
512 String
aName( SwStyleNameMapper::GetSpecialExtraUIName(
513 lcl_AnyToString(aValue
) ) );
514 pTOXBase
->SetSequenceName( aName
);
517 case WID_LABEL_DISPLAY_TYPE
:
519 sal_Int16 nVal
= lcl_AnyToInt16(aValue
);
520 sal_uInt16 nSet
= CAPTION_COMPLETE
;
523 case text::ReferenceFieldPart::TEXT
: nSet
= CAPTION_COMPLETE
;
525 case text::ReferenceFieldPart::CATEGORY_AND_NUMBER
: nSet
= CAPTION_NUMBER
;
527 case text::ReferenceFieldPart::ONLY_CAPTION
: nSet
= CAPTION_TEXT
;
530 throw lang::IllegalArgumentException();
532 pTOXBase
->SetCaptionDisplay((SwCaptionDisplay
)nSet
);
535 case WID_USE_LEVEL_FROM_SOURCE
:
536 pTOXBase
->SetLevelFromChapter(lcl_AnyToBool(aValue
));
538 case WID_MAIN_ENTRY_CHARACTER_STYLE_NAME
:
541 SwStyleNameMapper::FillUIName(lcl_AnyToString(aValue
), aString
, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT
, sal_True
);
542 pTOXBase
->SetMainEntryCharStyle( aString
);
545 case WID_CREATE_FROM_TABLES
:
546 nCreate
= lcl_AnyToBool(aValue
) ? nCreate
| nsSwTOXElement::TOX_TABLE
: nCreate
& ~nsSwTOXElement::TOX_TABLE
;
548 case WID_CREATE_FROM_TEXT_FRAMES
:
549 nCreate
= lcl_AnyToBool(aValue
) ? nCreate
| nsSwTOXElement::TOX_FRAME
: nCreate
& ~nsSwTOXElement::TOX_FRAME
;
551 case WID_CREATE_FROM_GRAPHIC_OBJECTS
:
552 nCreate
= lcl_AnyToBool(aValue
) ? nCreate
| nsSwTOXElement::TOX_GRAPHIC
: nCreate
& ~nsSwTOXElement::TOX_GRAPHIC
;
554 case WID_CREATE_FROM_EMBEDDED_OBJECTS
:
555 if(lcl_AnyToBool(aValue
))
556 nCreate
|= nsSwTOXElement::TOX_OLE
;
558 nCreate
&= ~nsSwTOXElement::TOX_OLE
;
560 case WID_CREATE_FROM_STAR_MATH
:
561 nOLEOptions
= lcl_AnyToBool(aValue
) ? nOLEOptions
| nsSwTOOElements::TOO_MATH
: nOLEOptions
& ~nsSwTOOElements::TOO_MATH
;
563 case WID_CREATE_FROM_STAR_CHART
:
564 nOLEOptions
= lcl_AnyToBool(aValue
) ? nOLEOptions
| nsSwTOOElements::TOO_CHART
: nOLEOptions
& ~nsSwTOOElements::TOO_CHART
;
566 case WID_CREATE_FROM_STAR_CALC
:
567 nOLEOptions
= lcl_AnyToBool(aValue
) ? nOLEOptions
| nsSwTOOElements::TOO_CALC
: nOLEOptions
& ~nsSwTOOElements::TOO_CALC
;
569 case WID_CREATE_FROM_STAR_DRAW
:
570 nOLEOptions
= lcl_AnyToBool(aValue
) ? nOLEOptions
| nsSwTOOElements::TOO_DRAW_IMPRESS
: nOLEOptions
& ~nsSwTOOElements::TOO_DRAW_IMPRESS
;
572 case WID_CREATE_FROM_OTHER_EMBEDDED_OBJECTS
:
573 nOLEOptions
= lcl_AnyToBool(aValue
) ? nOLEOptions
| nsSwTOOElements::TOO_OTHER
: nOLEOptions
& ~nsSwTOOElements::TOO_OTHER
;
578 SwStyleNameMapper::FillUIName( lcl_AnyToString(aValue
), aString
, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL
, sal_True
);
580 //Header steht an Pos 0
581 aForm
.SetTemplate( 0, aString
);
584 case WID_IS_RELATIVE_TABSTOPS
:
586 aForm
.SetRelTabPos(lcl_AnyToBool(aValue
));
592 SwStyleNameMapper::FillUIName( lcl_AnyToString(aValue
), aString
, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL
, sal_True
);
593 aForm
.SetTemplate( 1, aString
);
596 case WID_CREATE_FROM_PARAGRAPH_STYLES
:
597 nCreate
= lcl_AnyToBool(aValue
) ?
598 (nCreate
| nsSwTOXElement::TOX_TEMPLATE
) : (nCreate
& ~nsSwTOXElement::TOX_TEMPLATE
);
610 case WID_PARA_LEV10
:
613 // im sdbcx::Index beginnt Lebel 1 bei Pos 2 sonst bei Pos 1
614 sal_uInt16 nLPos
= pTOXBase
->GetType() == TOX_INDEX
? 2 : 1;
616 SwStyleNameMapper::FillUIName( lcl_AnyToString(aValue
), aString
, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL
, sal_True
);
617 aForm
.SetTemplate(nLPos
+ pEntry
->nWID
- WID_PARA_LEV1
, aString
);
621 //this is for items only
622 if(WID_PRIMARY_KEY
> pEntry
->nWID
)
624 const SwAttrSet
& rSet
= m_pDoc
->GetTOXBaseAttrSet(*pTOXBase
);
625 pAttrSet
= new SfxItemSet(rSet
);
626 m_pPropSet
->setPropertyValue(rPropertyName
, aValue
, *pAttrSet
);
628 const SwSectionFmts
& rSects
= m_pDoc
->GetSections();
629 const SwSectionFmt
* pOwnFmt
= GetFmt();
630 for(sal_uInt16 i
= 0; i
< rSects
.Count(); i
++)
632 const SwSectionFmt
* pTmpFmt
= rSects
[ i
];
633 if(pTmpFmt
== pOwnFmt
)
635 m_pDoc
->ChgSection( i
, *(SwTOXBaseSection
*)pTOXBase
, pAttrSet
);
641 pTOXBase
->SetCreate(nCreate
);
642 pTOXBase
->SetOLEOptions(nOLEOptions
);
643 if(pTOXBase
->GetTOXType()->GetType() == TOX_INDEX
)
644 pTOXBase
->SetOptions(nTOIOptions
);
646 pTOXBase
->SetTOXForm(aForm
);
650 throw uno::RuntimeException();
653 /*-- 14.12.98 09:35:05---------------------------------------------------
655 -----------------------------------------------------------------------*/
656 uno::Any
SwXDocumentIndex::getPropertyValue(const OUString
& rPropertyName
)
657 throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
659 vos::OGuard
aGuard(Application::GetSolarMutex());
661 const SfxItemPropertySimpleEntry
* pEntry
= m_pPropSet
->getPropertyMap()->getByName(rPropertyName
);
663 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
664 SwTOXBase
* pTOXBase
= 0;
666 pTOXBase
= (SwTOXBaseSection
*)GetFmt()->GetSection();
667 else if(bIsDescriptor
)
668 pTOXBase
= &pProps
->GetTOXBase();
671 sal_uInt16 nCreate
= pTOXBase
->GetCreateType();
672 sal_uInt16 nTOIOptions
= 0;
673 sal_uInt16 nOLEOptions
= pTOXBase
->GetOLEOptions();
674 if(pTOXBase
->GetTOXType()->GetType() == TOX_INDEX
)
675 nTOIOptions
= pTOXBase
->GetOptions();
676 const SwForm
& rForm
= pTOXBase
->GetTOXForm();
677 sal_Bool bBOOL
= sal_True
;
678 sal_Bool bRet
= sal_False
;
681 case WID_IDX_CONTENT_SECTION
:
682 case WID_IDX_HEADER_SECTION
:
684 if(WID_IDX_CONTENT_SECTION
== pEntry
->nWID
)
686 uno::Reference
<text::XTextSection
> xContentSect
= SwXTextSections::GetObject( *GetFmt() );
687 aRet
<<= xContentSect
;
692 GetFmt()->GetChildSections( aSectArr
, SORTSECT_NOT
, FALSE
);
693 for(USHORT i
= 0; i
< aSectArr
.Count(); i
++)
695 SwSection
* pSect
= aSectArr
[i
];
696 if(pSect
->GetType() == TOX_HEADER_SECTION
)
698 uno::Reference
<text::XTextSection
> xHeaderSect
= SwXTextSections::GetObject( *pSect
->GetFmt() );
699 aRet
<<= xHeaderSect
;
708 OUString
uRet(pTOXBase
->GetTitle());
714 aRet
<<= OUString(pTOXBase
->GetTOXName());
716 case WID_USER_IDX_NAME
:
721 sTmp
= pTOXBase
->GetTOXType()->GetTypeName();
723 sTmp
= pProps
->GetTypeName();
725 lcl_ConvertTOUNameToProgrammaticName(sTmp
);
731 aRet
<<= SvxCreateLocale(pTOXBase
->GetLanguage());
733 case WID_IDX_SORT_ALGORITHM
:
735 aRet
<<= OUString(pTOXBase
->GetSortAlgorithm());
739 aRet
<<= (sal_Int16
)pTOXBase
->GetLevel();
741 case WID_CREATE_FROM_MARKS
:
742 bRet
= 0 != (nCreate
& nsSwTOXElement::TOX_MARK
);
744 case WID_CREATE_FROM_OUTLINE
:
745 bRet
= 0 != (nCreate
& nsSwTOXElement::TOX_OUTLINELEVEL
);
747 case WID_CREATE_FROM_CHAPTER
:
748 bRet
= pTOXBase
->IsFromChapter();
750 case WID_CREATE_FROM_LABELS
:
751 bRet
= ! pTOXBase
->IsFromObjectNames();
754 bRet
= pTOXBase
->IsProtected();
756 case WID_USE_ALPHABETICAL_SEPARATORS
:
757 bRet
= 0 != (nTOIOptions
& nsSwTOIOptions::TOI_ALPHA_DELIMITTER
);
759 case WID_USE_KEY_AS_ENTRY
:
760 bRet
= 0 != (nTOIOptions
& nsSwTOIOptions::TOI_KEY_AS_ENTRY
);
762 case WID_USE_COMBINED_ENTRIES
:
763 bRet
= 0 != (nTOIOptions
& nsSwTOIOptions::TOI_SAME_ENTRY
);
765 case WID_IS_CASE_SENSITIVE
:
766 bRet
= 0 != (nTOIOptions
& nsSwTOIOptions::TOI_CASE_SENSITIVE
);
769 bRet
= 0 != (nTOIOptions
& nsSwTOIOptions::TOI_FF
);
772 bRet
= 0 != (nTOIOptions
& nsSwTOIOptions::TOI_DASH
);
774 case WID_USE_UPPER_CASE
:
775 bRet
= 0 != (nTOIOptions
& nsSwTOIOptions::TOI_INITIAL_CAPS
);
777 case WID_IS_COMMA_SEPARATED
:
778 bRet
= rForm
.IsCommaSeparated();
780 case WID_LABEL_CATEGORY
:
782 // convert internal UI name to
783 // file-format/API/external programmatic english name
785 String
aName( SwStyleNameMapper::GetSpecialExtraProgName(
786 pTOXBase
->GetSequenceName() ) );
787 aRet
<<= OUString( aName
);
791 case WID_LABEL_DISPLAY_TYPE
:
794 sal_Int16 nSet
= text::ReferenceFieldPart::TEXT
;
795 switch (pTOXBase
->GetCaptionDisplay())
797 case CAPTION_COMPLETE
: nSet
= text::ReferenceFieldPart::TEXT
;break;
798 case CAPTION_NUMBER
: nSet
= text::ReferenceFieldPart::CATEGORY_AND_NUMBER
; break;
799 case CAPTION_TEXT
: nSet
= text::ReferenceFieldPart::ONLY_CAPTION
; break;
804 case WID_USE_LEVEL_FROM_SOURCE
:
805 bRet
= pTOXBase
->IsLevelFromChapter();
807 case WID_LEVEL_FORMAT
:
809 uno::Reference
< container::XIndexReplace
> xTokenAcc
=
810 ((SwXDocumentIndex
*)this)->GetTokenAccess();
812 xTokenAcc
= new SwXIndexTokenAccess_Impl(*
813 (SwXDocumentIndex
*)this);
814 aRet
.setValue(&xTokenAcc
, ::getCppuType((const uno::Reference
<container::XIndexReplace
>*)0));
818 case WID_LEVEL_PARAGRAPH_STYLES
:
820 uno::Reference
< container::XIndexReplace
> xStyleAcc
=
821 ((SwXDocumentIndex
*)this)->GetStyleAccess();
823 xStyleAcc
= new SwXIndexStyleAccess_Impl(*
824 (SwXDocumentIndex
*)this);
825 aRet
.setValue(&xStyleAcc
, ::getCppuType((const uno::Reference
<container::XIndexReplace
>*)0));
829 case WID_MAIN_ENTRY_CHARACTER_STYLE_NAME
:
833 SwStyleNameMapper::FillProgName(
834 pTOXBase
->GetMainEntryCharStyle(),
836 nsSwGetPoolIdFromName::GET_POOLID_CHRFMT
,
838 aRet
<<= OUString( aString
);
841 case WID_CREATE_FROM_TABLES
:
842 bRet
= 0 != (nCreate
& nsSwTOXElement::TOX_TABLE
);
844 case WID_CREATE_FROM_TEXT_FRAMES
:
845 bRet
= 0 != (nCreate
& nsSwTOXElement::TOX_FRAME
);
847 case WID_CREATE_FROM_GRAPHIC_OBJECTS
:
848 bRet
= 0 != (nCreate
& nsSwTOXElement::TOX_GRAPHIC
);
850 case WID_CREATE_FROM_EMBEDDED_OBJECTS
:
851 bRet
= 0 != (nCreate
& nsSwTOXElement::TOX_OLE
);
853 case WID_CREATE_FROM_STAR_MATH
:
854 bRet
= 0 != (nOLEOptions
& nsSwTOOElements::TOO_MATH
);
856 case WID_CREATE_FROM_STAR_CHART
:
857 bRet
= 0 != (nOLEOptions
& nsSwTOOElements::TOO_CHART
);
859 case WID_CREATE_FROM_STAR_CALC
:
860 bRet
= 0 != (nOLEOptions
& nsSwTOOElements::TOO_CALC
);
862 case WID_CREATE_FROM_STAR_DRAW
:
863 bRet
= 0 != (nOLEOptions
& nsSwTOOElements::TOO_DRAW_IMPRESS
);
865 case WID_CREATE_FROM_OTHER_EMBEDDED_OBJECTS
:
866 bRet
= 0 != (nOLEOptions
& nsSwTOOElements::TOO_OTHER
);
868 case WID_CREATE_FROM_PARAGRAPH_STYLES
:
869 bRet
= 0 != (nCreate
& nsSwTOXElement::TOX_TEMPLATE
);
873 //Header steht an Pos 0
875 SwStyleNameMapper::FillProgName(rForm
.GetTemplate( 0 ), aString
,
876 nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL
, sal_True
);
877 aRet
<<= OUString( aString
);
884 SwStyleNameMapper::FillProgName(
885 rForm
.GetTemplate( 1 ),
887 nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL
,
889 aRet
<<= OUString( aString
);
902 case WID_PARA_LEV10
:
904 // im sdbcx::Index beginnt Lebel 1 bei Pos 2 sonst bei Pos 1
905 sal_uInt16 nLPos
= pTOXBase
->GetType() == TOX_INDEX
? 2 : 1;
907 SwStyleNameMapper::FillProgName(
908 rForm
.GetTemplate(nLPos
+ pEntry
->nWID
- WID_PARA_LEV1
),
910 nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL
,
912 aRet
<<= OUString( aString
);
916 case WID_IS_RELATIVE_TABSTOPS
:
917 bRet
= rForm
.IsRelTabPos();
919 case WID_INDEX_MARKS
:
922 const SwTOXType
* pType
= pTOXBase
->GetTOXType();
923 SwClientIter
aIter(*(SwTOXType
*)pType
);
924 SwTOXMark
* pMark
= (SwTOXMark
*)aIter
.First(TYPE(SwTOXMark
));
927 if(pMark
->GetTxtTOXMark())
928 aMarks
.C40_INSERT(SwTOXMark
, pMark
, aMarks
.Count());
929 pMark
= (SwTOXMark
*)aIter
.Next();
931 uno::Sequence
< uno::Reference
< text::XDocumentIndexMark
> > aXMarks(aMarks
.Count());
932 uno::Reference
<text::XDocumentIndexMark
>* pxMarks
= aXMarks
.getArray();
933 for(USHORT i
= 0; i
< aMarks
.Count(); i
++)
935 pMark
= aMarks
.GetObject(i
);
936 pxMarks
[i
] = SwXDocumentIndexMark::GetObject((SwTOXType
*)pType
, pMark
, m_pDoc
);
938 aRet
.setValue(&aXMarks
, ::getCppuType((uno::Sequence
< uno::Reference
< text::XDocumentIndexMark
> >*)0));
943 //this is for items only
945 if(WID_PRIMARY_KEY
> pEntry
->nWID
)
947 const SwAttrSet
& rSet
= m_pDoc
->GetTOXBaseAttrSet(*pTOXBase
);
948 aRet
= m_pPropSet
->getPropertyValue(rPropertyName
, rSet
);
952 aRet
.setValue(&bRet
, ::getCppuBooleanType());
956 /*-- 14.12.98 09:35:06---------------------------------------------------
958 -----------------------------------------------------------------------*/
959 void SwXDocumentIndex::addPropertyChangeListener(const OUString
& /*PropertyName*/, const uno::Reference
< beans::XPropertyChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
961 DBG_WARNING("not implemented");
963 /*-- 14.12.98 09:35:06---------------------------------------------------
965 -----------------------------------------------------------------------*/
966 void SwXDocumentIndex::removePropertyChangeListener(const OUString
& /*PropertyName*/, const uno::Reference
< beans::XPropertyChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
968 DBG_WARNING("not implemented");
970 /*-- 14.12.98 09:35:06---------------------------------------------------
972 -----------------------------------------------------------------------*/
973 void SwXDocumentIndex::addVetoableChangeListener(const OUString
& /*PropertyName*/, const uno::Reference
< beans::XVetoableChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
975 DBG_WARNING("not implemented");
977 /*-- 14.12.98 09:35:07---------------------------------------------------
979 -----------------------------------------------------------------------*/
980 void SwXDocumentIndex::removeVetoableChangeListener(const OUString
& /*PropertyName*/, const uno::Reference
< beans::XVetoableChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
982 DBG_WARNING("not implemented");
984 /*-- 14.12.98 09:35:07---------------------------------------------------
986 -----------------------------------------------------------------------*/
987 void SwXDocumentIndex::Modify( SfxPoolItem
*pOld
, SfxPoolItem
*pNew
)
989 BOOL bRemove
= FALSE
;
990 switch( pOld
? pOld
->Which() : 0 )
992 case RES_REMOVE_UNO_OBJECT
:
993 case RES_OBJECTDYING
:
994 bRemove
= (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem
*)pOld
)->pObject
;
997 // wurden wir an das neue umgehaengt und wird das alte geloscht?
998 bRemove
= ((SwFmtChg
*)pNew
)->pChangedFmt
== GetRegisteredIn() &&
999 ((SwFmtChg
*)pOld
)->pChangedFmt
->IsFmtInDTOR();
1004 ((SwModify
*)GetRegisteredIn())->Remove( this );
1005 aLstnrCntnr
.Disposing();
1008 /* -----------------18.02.99 13:39-------------------
1010 * --------------------------------------------------*/
1011 void SwXDocumentIndex::attachToRange(const uno::Reference
< text::XTextRange
> & xTextRange
)
1012 throw( lang::IllegalArgumentException
, uno::RuntimeException
)
1015 throw uno::RuntimeException();
1016 uno::Reference
<XUnoTunnel
> xRangeTunnel( xTextRange
, uno::UNO_QUERY
);
1017 SwXTextRange
* pRange
= 0;
1018 OTextCursorHelper
* pCursor
= 0;
1019 if(xRangeTunnel
.is())
1021 pRange
= reinterpret_cast< SwXTextRange
* >(
1022 sal::static_int_cast
< sal_IntPtr
>( xRangeTunnel
->getSomething( SwXTextRange::getUnoTunnelId()) ));
1023 pCursor
= reinterpret_cast< OTextCursorHelper
* >(
1024 sal::static_int_cast
< sal_IntPtr
>( xRangeTunnel
->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
1027 SwDoc
* pDoc
= pRange
? (SwDoc
*)pRange
->GetDoc() : pCursor
? (SwDoc
*)pCursor
->GetDoc() : 0;
1030 SwUnoInternalPaM
aPam(*pDoc
);
1031 //das muss jetzt sal_True liefern
1032 SwXTextRange::XTextRangeToSwPaM(aPam
, xTextRange
);
1034 const SwTOXBase
* pOld
= pDoc
->GetCurTOX( *aPam
.Start() );
1037 UnoActionContext
aAction(pDoc
);
1039 pDoc
->DeleteAndJoin(aPam
);
1041 SwTOXBase
& rTOXBase
= pProps
->GetTOXBase();
1042 const SwTOXType
* pTOXType
= rTOXBase
.GetTOXType();
1043 if(TOX_USER
== pTOXType
->GetType() && !pProps
->GetTypeName().equals(pTOXType
->GetTypeName()))
1045 lcl_ReAssignTOXType(pDoc
, rTOXBase
, pProps
->GetTypeName());
1047 //TODO: apply Section attributes (columns and background)
1048 const SwTOXBaseSection
* pTOX
= pDoc
->InsertTableOf(
1049 *aPam
.GetPoint(), rTOXBase
, 0, sal_False
);
1051 pDoc
->SetTOXBaseName( *pTOX
, pProps
->GetTOXBase().GetTOXName() );
1053 // Seitennummern eintragen
1054 pBase
= (const SwTOXBaseSection
*)pTOX
;
1055 pBase
->GetFmt()->Add(this);
1056 ((SwTOXBaseSection
*)pTOX
)->UpdatePageNum();
1059 throw lang::IllegalArgumentException();
1063 bIsDescriptor
= sal_False
;
1066 /*-- 15.01.99 14:23:51---------------------------------------------------
1068 -----------------------------------------------------------------------*/
1069 void SwXDocumentIndex::attach(const uno::Reference
< text::XTextRange
> & xTextRange
)
1070 throw( lang::IllegalArgumentException
, uno::RuntimeException
)
1072 vos::OGuard
aGuard(Application::GetSolarMutex());
1073 attachToRange( xTextRange
);
1075 /*-- 15.01.99 14:23:56---------------------------------------------------
1077 -----------------------------------------------------------------------*/
1078 uno::Reference
< text::XTextRange
> SwXDocumentIndex::getAnchor(void) throw( uno::RuntimeException
)
1080 vos::OGuard
aGuard(Application::GetSolarMutex());
1081 uno::Reference
< text::XTextRange
> xRet
;
1082 if(GetRegisteredIn())
1084 SwSectionFmt
* pSectFmt
= GetFmt();
1085 const SwNodeIndex
* pIdx
;
1086 if( 0 != ( pIdx
= pSectFmt
->GetCntnt().GetCntntIdx() ) &&
1087 pIdx
->GetNode().GetNodes().IsDocNodes() )
1090 aPaM
.Move( fnMoveForward
, fnGoCntnt
);
1092 aPaM
.GetPoint()->nNode
= *pIdx
->GetNode().EndOfSectionNode();
1093 aPaM
.Move( fnMoveBackward
, fnGoCntnt
);
1094 xRet
= SwXTextRange::CreateTextRangeFromPosition(pSectFmt
->GetDoc(),
1095 *aPaM
.GetMark(), aPaM
.GetPoint());
1099 throw uno::RuntimeException();
1102 /*-- 15.01.99 15:46:48---------------------------------------------------
1104 -----------------------------------------------------------------------*/
1105 void lcl_RemoveChildSections(SwSectionFmt
& rParentFmt
)
1108 SwDoc
* pDoc
= rParentFmt
.GetDoc();
1109 sal_uInt16 nCnt
= rParentFmt
.GetChildSections(aTmpArr
,SORTSECT_POS
);
1112 for( sal_uInt16 n
= 0; n
< nCnt
; ++n
)
1113 if( aTmpArr
[n
]->GetFmt()->IsInNodesArr() )
1115 SwSectionFmt
* pFmt
= aTmpArr
[n
]->GetFmt();
1116 lcl_RemoveChildSections(*pFmt
);
1117 pDoc
->DelSectionFmt( pFmt
);
1121 void SwXDocumentIndex::dispose(void) throw( uno::RuntimeException
)
1123 vos::OGuard
aGuard(Application::GetSolarMutex());
1124 if(GetRegisteredIn())
1126 SwSectionFmt
* pSectFmt
= GetFmt();
1127 pSectFmt
->GetDoc()->DeleteTOX( *(SwTOXBaseSection
*)pSectFmt
->GetSection(), sal_True
);
1130 throw uno::RuntimeException();
1132 /*-- 15.01.99 15:46:49---------------------------------------------------
1134 -----------------------------------------------------------------------*/
1135 void SwXDocumentIndex::addEventListener(const uno::Reference
< lang::XEventListener
> & aListener
) throw( uno::RuntimeException
)
1137 if(!GetRegisteredIn())
1138 throw uno::RuntimeException();
1139 aLstnrCntnr
.AddListener(aListener
);
1141 /*-- 15.01.99 15:46:54---------------------------------------------------
1143 -----------------------------------------------------------------------*/
1144 void SwXDocumentIndex::removeEventListener(const uno::Reference
< lang::XEventListener
> & aListener
) throw( uno::RuntimeException
)
1146 if(!GetRegisteredIn() || !aLstnrCntnr
.RemoveListener(aListener
))
1147 throw uno::RuntimeException();
1149 /* -----------------30.07.99 11:28-------------------
1151 --------------------------------------------------*/
1152 OUString
SwXDocumentIndex::getName(void) throw( uno::RuntimeException
)
1154 SwSectionFmt
* pSectionFmt
= GetFmt();
1158 uRet
= OUString(pProps
->GetTOXBase().GetTOXName());
1160 else if(pSectionFmt
)
1162 uRet
= OUString(pSectionFmt
->GetSection()->GetName());
1165 throw uno::RuntimeException();
1168 /* -----------------30.07.99 11:28-------------------
1170 --------------------------------------------------*/
1171 void SwXDocumentIndex::setName(const OUString
& rName
) throw( uno::RuntimeException
)
1173 SwSectionFmt
* pSectionFmt
= GetFmt();
1174 String
sNewName(rName
);
1175 sal_Bool bExcept
= sal_False
;
1180 pProps
->GetTOXBase().SetTOXName(sNewName
);
1182 else if(!pSectionFmt
||
1183 !pSectionFmt
->GetDoc()->SetTOXBaseName(
1184 *(SwTOXBaseSection
*)pSectionFmt
->GetSection(), sNewName
))
1188 throw uno::RuntimeException();
1191 /******************************************************************
1192 * SwXDocumentIndexMark
1193 ******************************************************************/
1194 /* -----------------------------10.03.00 18:02--------------------------------
1196 ---------------------------------------------------------------------------*/
1197 const uno::Sequence
< sal_Int8
> & SwXDocumentIndexMark::getUnoTunnelId()
1199 static uno::Sequence
< sal_Int8
> aSeq
= ::CreateUnoTunnelId();
1202 /* -----------------------------10.03.00 18:04--------------------------------
1204 ---------------------------------------------------------------------------*/
1205 sal_Int64 SAL_CALL
SwXDocumentIndexMark::getSomething( const uno::Sequence
< sal_Int8
>& rId
)
1206 throw(uno::RuntimeException
)
1208 if( rId
.getLength() == 16
1209 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
1210 rId
.getConstArray(), 16 ) )
1212 return sal::static_int_cast
< sal_Int64
>( reinterpret_cast< sal_IntPtr
>(this) );
1217 TYPEINIT1(SwXDocumentIndexMark
, SwClient
)
1218 const sal_Char cBaseMark
[] = "com.sun.star.text.BaseIndexMark";
1219 const sal_Char cContentMark
[] = "com.sun.star.text.ContentIndexMark";
1220 const sal_Char cIdxMark
[] = "com.sun.star.text.DocumentIndexMark";
1221 const sal_Char cIdxMarkAsian
[] = "com.sun.star.text.DocumentIndexMarkAsian";
1222 const sal_Char cUserMark
[] = "com.sun.star.text.UserIndexMark";
1223 const sal_Char cTextContent
[] = "com.sun.star.text.TextContent";
1224 /* -----------------------------06.04.00 15:07--------------------------------
1226 ---------------------------------------------------------------------------*/
1227 OUString
SwXDocumentIndexMark::getImplementationName(void) throw( uno::RuntimeException
)
1229 return C2U("SwXDocumentIndexMark");
1231 /* -----------------------------06.04.00 15:07--------------------------------
1233 ---------------------------------------------------------------------------*/
1234 BOOL
SwXDocumentIndexMark::supportsService(const OUString
& rServiceName
) throw( uno::RuntimeException
)
1236 return !rServiceName
.compareToAscii(cBaseMark
)||
1237 !rServiceName
.compareToAscii(cTextContent
) ||
1238 (eType
== TOX_USER
&& !rServiceName
.compareToAscii(cUserMark
)) ||
1239 (eType
== TOX_CONTENT
&& !rServiceName
.compareToAscii(cContentMark
)) ||
1240 (eType
== TOX_INDEX
&& !rServiceName
.compareToAscii(cIdxMark
)) ||
1241 (eType
== TOX_INDEX
&& !rServiceName
.compareToAscii(cIdxMarkAsian
));
1243 /* -----------------------------06.04.00 15:07--------------------------------
1245 ---------------------------------------------------------------------------*/
1246 uno::Sequence
< OUString
> SwXDocumentIndexMark::getSupportedServiceNames(void) throw( uno::RuntimeException
)
1248 INT32 nCnt
= (eType
== TOX_INDEX
) ? 4 : 3;
1249 uno::Sequence
< OUString
> aRet(nCnt
);
1250 OUString
* pArray
= aRet
.getArray();
1251 pArray
[0] = C2U(cBaseMark
);
1252 pArray
[1] = C2U(cTextContent
);
1256 pArray
[2] = C2U(cUserMark
);
1259 pArray
[2] = C2U(cContentMark
);
1262 pArray
[2] = C2U(cIdxMark
);
1263 pArray
[3] = C2U(cIdxMarkAsian
);
1271 /*-- 14.12.98 10:25:43---------------------------------------------------
1273 -----------------------------------------------------------------------*/
1274 SwXDocumentIndexMark::SwXDocumentIndexMark(TOXTypes eToxType
) :
1275 aLstnrCntnr( (text::XTextContent
*)this),
1276 aTypeDepend(this, 0),
1279 bIsDescriptor(sal_True
),
1280 bMainEntry(sal_False
),
1286 /*-- 14.12.98 10:25:44---------------------------------------------------
1288 -----------------------------------------------------------------------*/
1289 SwXDocumentIndexMark::SwXDocumentIndexMark(const SwTOXType
* pType
,
1290 const SwTOXMark
* pMark
,
1292 aLstnrCntnr( (text::XTextContent
*)this),
1293 aTypeDepend(this, (SwTOXType
*)pType
),
1296 bIsDescriptor(sal_False
),
1297 bMainEntry(sal_False
),
1298 eType(pType
->GetType()),
1301 m_pDoc
->GetUnoCallBack()->Add(this);
1304 /*-- 14.12.98 10:25:44---------------------------------------------------
1306 -----------------------------------------------------------------------*/
1307 SwXDocumentIndexMark::~SwXDocumentIndexMark()
1311 /* -----------------21.04.99 09:36-------------------
1313 * --------------------------------------------------*/
1314 void SwXDocumentIndexMark::InitMap(TOXTypes eToxType
)
1316 sal_uInt16 nMapId
= PROPERTY_MAP_USER_MARK
; //case TOX_USER:
1320 nMapId
= PROPERTY_MAP_INDEX_MARK
;
1323 nMapId
= PROPERTY_MAP_CNTIDX_MARK
;
1330 m_pPropSet
= aSwMapProvider
.GetPropertySet(nMapId
);
1332 /*-- 14.12.98 10:25:45---------------------------------------------------
1334 -----------------------------------------------------------------------*/
1335 OUString
SwXDocumentIndexMark::getMarkEntry(void) throw( uno::RuntimeException
)
1337 vos::OGuard
aGuard(Application::GetSolarMutex());
1338 SwTOXType
* pType
= ((SwXDocumentIndexMark
*)this)->GetTOXType();
1340 if(pType
&& m_pTOXMark
)
1342 sRet
= OUString(m_pTOXMark
->GetAlternativeText());
1344 else if(bIsDescriptor
)
1347 throw uno::RuntimeException();
1350 /*-- 14.12.98 10:25:45---------------------------------------------------
1352 -----------------------------------------------------------------------*/
1353 void SwXDocumentIndexMark::setMarkEntry(const OUString
& rIndexEntry
) throw( uno::RuntimeException
)
1355 vos::OGuard
aGuard(Application::GetSolarMutex());
1356 SwTOXType
* pType
= ((SwXDocumentIndexMark
*)this)->GetTOXType();
1357 if(pType
&& m_pTOXMark
)
1359 SwTOXMark
aMark(*m_pTOXMark
);
1360 aMark
.SetAlternativeText(rIndexEntry
);
1361 const SwTxtTOXMark
* pTxtMark
= m_pTOXMark
->GetTxtTOXMark();
1362 SwPaM
aPam(pTxtMark
->GetTxtNode(), *pTxtMark
->GetStart());
1364 if(pTxtMark
->GetEnd())
1366 aPam
.GetPoint()->nContent
= *pTxtMark
->GetEnd();
1369 aPam
.GetPoint()->nContent
++;
1371 //die alte Marke loeschen
1372 m_pDoc
->DeleteTOXMark(m_pTOXMark
);
1375 SwTxtAttr
* pTxtAttr
= 0;
1376 sal_Bool bInsAtPos
= aMark
.IsAlternativeText();
1377 const SwPosition
*pStt
= aPam
.Start(),
1381 SwPaM
aTmp( *pStt
);
1382 m_pDoc
->InsertPoolItem( aTmp
, aMark
, 0 );
1383 pTxtAttr
= pStt
->nNode
.GetNode().GetTxtNode()->GetTxtAttrForCharAt(
1384 pStt
->nContent
.GetIndex()-1, RES_TXTATR_TOXMARK
);
1386 else if( *pEnd
!= *pStt
)
1388 m_pDoc
->InsertPoolItem( aPam
, aMark
,
1389 nsSetAttrMode::SETATTR_DONTEXPAND
);
1390 pTxtAttr
= pStt
->nNode
.GetNode().GetTxtNode()->GetTxtAttr(
1391 pStt
->nContent
, RES_TXTATR_TOXMARK
);
1393 //und sonst - Marke geloescht?
1395 m_pTOXMark
= &pTxtAttr
->GetTOXMark();
1397 else if(bIsDescriptor
)
1399 sAltText
= rIndexEntry
;
1402 throw uno::RuntimeException();
1404 /* -----------------18.02.99 13:40-------------------
1406 * --------------------------------------------------*/
1407 void SwXDocumentIndexMark::attachToRange(const uno::Reference
< text::XTextRange
> & xTextRange
)
1408 throw( lang::IllegalArgumentException
, uno::RuntimeException
)
1410 vos::OGuard
aGuard(Application::GetSolarMutex());
1412 throw uno::RuntimeException();
1414 uno::Reference
<XUnoTunnel
> xRangeTunnel( xTextRange
, uno::UNO_QUERY
);
1415 SwXTextRange
* pRange
= 0;
1416 OTextCursorHelper
* pCursor
= 0;
1417 if(xRangeTunnel
.is())
1419 pRange
= reinterpret_cast< SwXTextRange
* >(
1420 sal::static_int_cast
< sal_IntPtr
>( xRangeTunnel
->getSomething( SwXTextRange::getUnoTunnelId()) ));
1421 pCursor
= reinterpret_cast< OTextCursorHelper
* >(
1422 sal::static_int_cast
< sal_IntPtr
>( xRangeTunnel
->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
1425 SwDoc
* pDoc
= pRange
? (SwDoc
*)pRange
->GetDoc() : pCursor
? (SwDoc
*)pCursor
->GetDoc() : 0;
1429 const SwTOXType
* pTOXType
= 0;
1434 pTOXType
= pDoc
->GetTOXType( eType
, 0 );
1438 if(!sUserIndexName
.Len())
1439 pTOXType
= pDoc
->GetTOXType( eType
, 0 );
1442 sal_uInt16 nCount
= pDoc
->GetTOXTypeCount( eType
);
1443 for(sal_uInt16 i
= 0; i
< nCount
; i
++)
1445 const SwTOXType
* pTemp
= pDoc
->GetTOXType( eType
, i
);
1446 if(sUserIndexName
== pTemp
->GetTypeName())
1454 SwTOXType
aUserType(TOX_USER
, sUserIndexName
);
1455 pTOXType
= pDoc
->InsertTOXType(aUserType
);
1465 throw lang::IllegalArgumentException();
1466 pDoc
->GetUnoCallBack()->Add(this);
1467 ((SwTOXType
*)pTOXType
)->Add(&aTypeDepend
);
1469 SwUnoInternalPaM
aPam(*pDoc
);
1470 //das muss jetzt sal_True liefern
1471 SwXTextRange::XTextRangeToSwPaM(aPam
, xTextRange
);
1472 SwTOXMark
aMark (pTOXType
);
1474 aMark
.SetAlternativeText(sAltText
);
1478 if(sPrimaryKey
.Len())
1479 aMark
.SetPrimaryKey(sPrimaryKey
);
1480 if(sSecondaryKey
.Len())
1481 aMark
.SetSecondaryKey(sSecondaryKey
);
1482 if(sTextReading
.Len())
1483 aMark
.SetTextReading(sTextReading
);
1484 if(sPrimaryKeyReading
.Len())
1485 aMark
.SetPrimaryKeyReading(sPrimaryKeyReading
);
1486 if(sSecondaryKeyReading
.Len())
1487 aMark
.SetSecondaryKeyReading(sSecondaryKeyReading
);
1488 aMark
.SetMainEntry(bMainEntry
);
1492 if(USHRT_MAX
!= nLevel
)
1493 aMark
.SetLevel(nLevel
+1);
1499 UnoActionContext
aAction(pDoc
);
1500 sal_Bool bMark
= *aPam
.GetPoint() != *aPam
.GetMark();
1501 // Marks ohne Alternativtext ohne selektierten Text koennen nicht eingefuegt werden,
1502 // deshalb hier ein Leerzeichen - ob das die ideale Loesung ist?
1503 if(!bMark
&& !aMark
.GetAlternativeText().Len())
1504 aMark
.SetAlternativeText( String(' ') );
1506 SwXTextCursor
const*const pTextCursor(
1507 dynamic_cast<SwXTextCursor
*>(pCursor
));
1508 const bool bForceExpandHints( (!bMark
&& pTextCursor
)
1509 ? pTextCursor
->IsAtEndOfMeta() : false );
1510 const SetAttrMode nInsertFlags
= (bForceExpandHints
)
1511 ? ( nsSetAttrMode::SETATTR_FORCEHINTEXPAND
1512 | nsSetAttrMode::SETATTR_DONTEXPAND
)
1513 : nsSetAttrMode::SETATTR_DONTEXPAND
;
1515 pDoc
->InsertPoolItem(aPam
, aMark
, nInsertFlags
);
1516 if( bMark
&& *aPam
.GetPoint() > *aPam
.GetMark())
1519 SwTxtAttr
* pTxtAttr
= 0;
1521 pTxtAttr
= aPam
.GetNode()->GetTxtNode()->GetTxtAttr(
1522 aPam
.GetPoint()->nContent
, RES_TXTATR_TOXMARK
);
1525 pTxtAttr
= aPam
.GetNode()->GetTxtNode()->GetTxtAttrForCharAt(
1526 aPam
.GetPoint()->nContent
.GetIndex()-1, RES_TXTATR_TOXMARK
);
1531 m_pTOXMark
= &pTxtAttr
->GetTOXMark();
1533 bIsDescriptor
= sal_False
;
1536 throw uno::RuntimeException();
1539 /*-- 14.12.98 10:25:45---------------------------------------------------
1541 -----------------------------------------------------------------------*/
1542 void SwXDocumentIndexMark::attach(const uno::Reference
< text::XTextRange
> & xTextRange
)
1543 throw( lang::IllegalArgumentException
, uno::RuntimeException
)
1545 vos::OGuard
aGuard(Application::GetSolarMutex());
1546 attachToRange( xTextRange
);
1548 /*-- 14.12.98 10:25:45---------------------------------------------------
1550 -----------------------------------------------------------------------*/
1551 uno::Reference
< text::XTextRange
> SwXDocumentIndexMark::getAnchor(void) throw( uno::RuntimeException
)
1553 vos::OGuard
aGuard(Application::GetSolarMutex());
1554 uno::Reference
< text::XTextRange
> aRet
;
1555 SwTOXType
* pType
= ((SwXDocumentIndexMark
*)this)->GetTOXType();
1556 if(pType
&& m_pTOXMark
)
1558 if( m_pTOXMark
->GetTxtTOXMark() )
1560 const SwTxtTOXMark
* pTxtMark
= m_pTOXMark
->GetTxtTOXMark();
1561 SwPaM
aPam(pTxtMark
->GetTxtNode(), *pTxtMark
->GetStart());
1563 if(pTxtMark
->GetEnd())
1565 aPam
.GetPoint()->nContent
= *pTxtMark
->GetEnd();
1568 aPam
.GetPoint()->nContent
++;
1569 uno::Reference
< frame::XModel
> xModel
= m_pDoc
->GetDocShell()->GetBaseModel();
1570 uno::Reference
< text::XTextDocument
> xTDoc(xModel
, uno::UNO_QUERY
);
1571 aRet
= new SwXTextRange(aPam
, xTDoc
->getText());
1575 throw uno::RuntimeException();
1578 /*-- 14.12.98 10:25:45---------------------------------------------------
1580 -----------------------------------------------------------------------*/
1581 void SwXDocumentIndexMark::dispose(void) throw( uno::RuntimeException
)
1583 vos::OGuard
aGuard(Application::GetSolarMutex());
1584 SwTOXType
* pType
= ((SwXDocumentIndexMark
*)this)->GetTOXType();
1585 if(pType
&& m_pTOXMark
)
1587 m_pDoc
->DeleteTOXMark(m_pTOXMark
);
1590 throw uno::RuntimeException();
1592 /*-- 14.12.98 10:25:45---------------------------------------------------
1594 -----------------------------------------------------------------------*/
1595 void SwXDocumentIndexMark::addEventListener(const uno::Reference
< lang::XEventListener
> & aListener
)
1596 throw( uno::RuntimeException
)
1598 if(!GetRegisteredIn())
1599 throw uno::RuntimeException();
1600 aLstnrCntnr
.AddListener(aListener
);
1602 /*-- 14.12.98 10:25:46---------------------------------------------------
1604 -----------------------------------------------------------------------*/
1605 void SwXDocumentIndexMark::removeEventListener(const uno::Reference
< lang::XEventListener
> & aListener
)
1606 throw( uno::RuntimeException
)
1608 if(!GetRegisteredIn() || !aLstnrCntnr
.RemoveListener(aListener
))
1609 throw uno::RuntimeException();
1611 /*-- 14.12.98 10:25:46---------------------------------------------------
1613 -----------------------------------------------------------------------*/
1614 uno::Reference
< beans::XPropertySetInfo
> SwXDocumentIndexMark::getPropertySetInfo(void)
1615 throw( uno::RuntimeException
)
1617 static uno::Reference
< beans::XPropertySetInfo
> xInfos
[3];
1621 case TOX_INDEX
: nPos
= 0; break;
1622 case TOX_CONTENT
: nPos
= 1; break;
1623 case TOX_USER
: nPos
= 2; break;
1627 if(!xInfos
[nPos
].is())
1629 uno::Reference
< beans::XPropertySetInfo
> xInfo
= m_pPropSet
->getPropertySetInfo();
1630 // extend PropertySetInfo!
1631 const uno::Sequence
<beans::Property
> aPropSeq
= xInfo
->getProperties();
1632 xInfos
[nPos
] = new SfxExtItemPropertySetInfo(
1633 aSwMapProvider
.GetPropertyMapEntries(PROPERTY_MAP_PARAGRAPH_EXTENSIONS
),
1636 return xInfos
[nPos
];
1638 /*-- 14.12.98 10:25:46---------------------------------------------------
1640 -----------------------------------------------------------------------*/
1641 void SwXDocumentIndexMark::setPropertyValue(const OUString
& rPropertyName
,
1642 const uno::Any
& aValue
)
1643 throw( beans::UnknownPropertyException
, beans::PropertyVetoException
,
1644 lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
1646 vos::OGuard
aGuard(Application::GetSolarMutex());
1647 SwTOXType
* pType
= ((SwXDocumentIndexMark
*)this)->GetTOXType();
1648 const SfxItemPropertySimpleEntry
* pEntry
= m_pPropSet
->getPropertyMap()->getByName(rPropertyName
);
1650 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
1651 if ( pEntry
->nFlags
& beans::PropertyAttribute::READONLY
)
1652 throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
1653 if(pType
&& m_pTOXMark
)
1655 SwDoc
* pLocalDoc
= m_pDoc
;
1657 SwTOXMark
aMark(*m_pTOXMark
);
1658 switch(pEntry
->nWID
)
1661 aMark
.SetAlternativeText(lcl_AnyToString(aValue
));
1664 aMark
.SetLevel(Min( (sal_Int8
) ( MAXLEVEL
),
1665 (sal_Int8
)(lcl_AnyToInt16(aValue
)+1)));
1667 case WID_PRIMARY_KEY
:
1668 aMark
.SetPrimaryKey(lcl_AnyToString(aValue
));
1670 case WID_SECONDARY_KEY
:
1671 aMark
.SetSecondaryKey(lcl_AnyToString(aValue
));
1673 case WID_MAIN_ENTRY
:
1674 aMark
.SetMainEntry(lcl_AnyToBool(aValue
));
1676 case WID_TEXT_READING
:
1677 aMark
.SetTextReading(lcl_AnyToString(aValue
));
1679 case WID_PRIMARY_KEY_READING
:
1680 aMark
.SetPrimaryKeyReading(lcl_AnyToString(aValue
));
1682 case WID_SECONDARY_KEY_READING
:
1683 aMark
.SetSecondaryKeyReading(lcl_AnyToString(aValue
));
1686 const SwTxtTOXMark
* pTxtMark
= m_pTOXMark
->GetTxtTOXMark();
1687 SwPaM
aPam(pTxtMark
->GetTxtNode(), *pTxtMark
->GetStart());
1689 if(pTxtMark
->GetEnd())
1691 aPam
.GetPoint()->nContent
= *pTxtMark
->GetEnd();
1694 aPam
.GetPoint()->nContent
++;
1696 //delete the old mark
1697 pLocalDoc
->DeleteTOXMark(m_pTOXMark
);
1700 sal_Bool bInsAtPos
= aMark
.IsAlternativeText();
1701 const SwPosition
*pStt
= aPam
.Start(),
1704 SwTxtAttr
* pTxtAttr
= 0;
1707 SwPaM
aTmp( *pStt
);
1708 pLocalDoc
->InsertPoolItem( aTmp
, aMark
, 0 );
1709 pTxtAttr
= pStt
->nNode
.GetNode().GetTxtNode()->GetTxtAttrForCharAt(
1710 pStt
->nContent
.GetIndex()-1, RES_TXTATR_TOXMARK
);
1712 else if( *pEnd
!= *pStt
)
1714 pLocalDoc
->InsertPoolItem( aPam
, aMark
,
1715 nsSetAttrMode::SETATTR_DONTEXPAND
);
1716 pTxtAttr
= pStt
->nNode
.GetNode().GetTxtNode()->GetTxtAttr(
1717 pStt
->nContent
, RES_TXTATR_TOXMARK
);
1723 m_pTOXMark
= &pTxtAttr
->GetTOXMark();
1724 m_pDoc
->GetUnoCallBack()->Add(this);
1725 pType
->Add(&aTypeDepend
);
1728 else if(bIsDescriptor
)
1730 switch(pEntry
->nWID
)
1733 sAltText
= lcl_AnyToString(aValue
);
1737 sal_Int16 nVal
= lcl_AnyToInt16(aValue
);
1738 if(nVal
>= 0 && nVal
< MAXLEVEL
)
1741 throw lang::IllegalArgumentException();
1744 case WID_PRIMARY_KEY
:
1745 sPrimaryKey
= lcl_AnyToString(aValue
);
1747 case WID_SECONDARY_KEY
:
1748 sSecondaryKey
= lcl_AnyToString(aValue
);
1750 case WID_TEXT_READING
:
1751 sTextReading
= lcl_AnyToString(aValue
);
1753 case WID_PRIMARY_KEY_READING
:
1754 sPrimaryKeyReading
= lcl_AnyToString(aValue
);
1756 case WID_SECONDARY_KEY_READING
:
1757 sSecondaryKeyReading
= lcl_AnyToString(aValue
);
1759 case WID_USER_IDX_NAME
:
1761 OUString
sTmp(lcl_AnyToString(aValue
));
1762 lcl_ConvertTOUNameToUserName(sTmp
);
1763 sUserIndexName
= sTmp
;
1766 case WID_MAIN_ENTRY
:
1767 bMainEntry
= lcl_AnyToBool(aValue
);
1772 throw uno::RuntimeException();
1774 /*-- 14.12.98 10:25:46---------------------------------------------------
1776 -----------------------------------------------------------------------*/
1777 uno::Any
SwXDocumentIndexMark::getPropertyValue(const OUString
& rPropertyName
)
1778 throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
1780 vos::OGuard
aGuard(Application::GetSolarMutex());
1782 SwTOXType
* pType
= ((SwXDocumentIndexMark
*)this)->GetTOXType();
1783 const SfxItemPropertySimpleEntry
* pEntry
= m_pPropSet
->getPropertyMap()->getByName(rPropertyName
);
1785 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
1786 if(SwXParagraph::getDefaultTextContentValue(aRet
, rPropertyName
, pEntry
->nWID
))
1788 if(pType
&& m_pTOXMark
)
1790 switch(pEntry
->nWID
)
1793 aRet
<<= OUString(m_pTOXMark
->GetAlternativeText());
1796 aRet
<<= (sal_Int16
)(m_pTOXMark
->GetLevel() - 1);
1798 case WID_PRIMARY_KEY
:
1799 aRet
<<= OUString(m_pTOXMark
->GetPrimaryKey());
1801 case WID_SECONDARY_KEY
:
1802 aRet
<<= OUString(m_pTOXMark
->GetSecondaryKey());
1804 case WID_TEXT_READING
:
1805 aRet
<<= OUString(m_pTOXMark
->GetTextReading());
1807 case WID_PRIMARY_KEY_READING
:
1808 aRet
<<= OUString(m_pTOXMark
->GetPrimaryKeyReading());
1810 case WID_SECONDARY_KEY_READING
:
1811 aRet
<<= OUString(m_pTOXMark
->GetSecondaryKeyReading());
1813 case WID_USER_IDX_NAME
:
1815 OUString
sTmp(pType
->GetTypeName());
1816 lcl_ConvertTOUNameToProgrammaticName(sTmp
);
1820 case WID_MAIN_ENTRY
:
1822 sal_Bool bTemp
= m_pTOXMark
->IsMainEntry();
1823 aRet
.setValue(&bTemp
, ::getBooleanCppuType());
1828 else if(bIsDescriptor
)
1830 switch(pEntry
->nWID
)
1833 aRet
<<= OUString(sAltText
);
1836 aRet
<<= (sal_Int16
)nLevel
;
1838 case WID_PRIMARY_KEY
:
1839 aRet
<<= OUString(sPrimaryKey
);
1841 case WID_SECONDARY_KEY
:
1842 aRet
<<= OUString(sSecondaryKey
);
1844 case WID_TEXT_READING
:
1845 aRet
<<= OUString(sTextReading
);
1847 case WID_PRIMARY_KEY_READING
:
1848 aRet
<<= OUString(sPrimaryKeyReading
);
1850 case WID_SECONDARY_KEY_READING
:
1851 aRet
<<= OUString(sSecondaryKeyReading
);
1853 case WID_USER_IDX_NAME
:
1854 aRet
<<= OUString(sUserIndexName
);
1856 case WID_MAIN_ENTRY
:
1858 aRet
.setValue(&bMainEntry
, ::getBooleanCppuType());
1864 throw uno::RuntimeException();
1867 /*-- 14.12.98 10:25:46---------------------------------------------------
1869 -----------------------------------------------------------------------*/
1870 void SwXDocumentIndexMark::addPropertyChangeListener(const OUString
& /*PropertyName*/, const uno::Reference
< beans::XPropertyChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
1872 DBG_WARNING("not implemented");
1874 /*-- 14.12.98 10:25:46---------------------------------------------------
1876 -----------------------------------------------------------------------*/
1877 void SwXDocumentIndexMark::removePropertyChangeListener(const OUString
& /*PropertyName*/, const uno::Reference
< beans::XPropertyChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
1879 DBG_WARNING("not implemented");
1881 /*-- 14.12.98 10:25:47---------------------------------------------------
1883 -----------------------------------------------------------------------*/
1884 void SwXDocumentIndexMark::addVetoableChangeListener(const OUString
& /*PropertyName*/, const uno::Reference
< beans::XVetoableChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
1886 DBG_WARNING("not implemented");
1888 /*-- 14.12.98 10:25:47---------------------------------------------------
1890 -----------------------------------------------------------------------*/
1891 void SwXDocumentIndexMark::removeVetoableChangeListener(const OUString
& /*PropertyName*/, const uno::Reference
< beans::XVetoableChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
1893 DBG_WARNING("not implemented");
1895 /*-- 14.12.98 10:25:47---------------------------------------------------
1897 -----------------------------------------------------------------------*/
1898 SwXDocumentIndexMark
* SwXDocumentIndexMark::GetObject(SwTOXType
* pType
,
1899 const SwTOXMark
* pMark
, SwDoc
* pDoc
)
1901 SwClientIter
aIter(*pType
);
1902 SwXDocumentIndexMark
* pxMark
= (SwXDocumentIndexMark
*)
1903 aIter
.First(TYPE(SwXDocumentIndexMark
));
1906 if(pxMark
->m_pTOXMark
== pMark
)
1908 pxMark
= (SwXDocumentIndexMark
*)aIter
.Next();
1910 return new SwXDocumentIndexMark(pType
, pMark
, pDoc
);
1912 /*-- 14.12.98 10:25:47---------------------------------------------------
1914 -----------------------------------------------------------------------*/
1915 void SwXDocumentIndexMark::Modify( SfxPoolItem
*pOld
, SfxPoolItem
*pNew
)
1917 switch( pOld
? pOld
->Which() : 0 )
1919 case RES_REMOVE_UNO_OBJECT
:
1920 case RES_OBJECTDYING
:
1921 if( (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem
*)pOld
)->pObject
)
1926 // wurden wir an das neue umgehaengt und wird das alte geloscht?
1927 if( ((SwFmtChg
*)pNew
)->pChangedFmt
== GetRegisteredIn() &&
1928 ((SwFmtChg
*)pOld
)->pChangedFmt
->IsFmtInDTOR() )
1931 case RES_TOXMARK_DELETED
:
1932 if( (void*)m_pTOXMark
== ((SwPtrMsgPoolItem
*)pOld
)->pObject
)
1937 /* -----------------------------16.10.00 11:24--------------------------------
1939 ---------------------------------------------------------------------------*/
1940 void SwXDocumentIndexMark::Invalidate()
1942 if(GetRegisteredIn())
1944 ((SwModify
*)GetRegisteredIn())->Remove(this);
1945 if(aTypeDepend
.GetRegisteredIn())
1946 ((SwModify
*)aTypeDepend
.GetRegisteredIn())->Remove(&aTypeDepend
);
1947 aLstnrCntnr
.Disposing();
1952 /* -----------------------------06.04.00 15:08--------------------------------
1954 ---------------------------------------------------------------------------*/
1955 OUString
SwXDocumentIndexes::getImplementationName(void) throw( uno::RuntimeException
)
1957 return C2U("SwXDocumentIndexes");
1959 /* -----------------------------06.04.00 15:08--------------------------------
1961 ---------------------------------------------------------------------------*/
1962 BOOL
SwXDocumentIndexes::supportsService(const OUString
& rServiceName
) throw( uno::RuntimeException
)
1964 return C2U("com.sun.star.text.DocumentIndexes") == rServiceName
;
1966 /* -----------------------------06.04.00 15:08--------------------------------
1968 ---------------------------------------------------------------------------*/
1969 uno::Sequence
< OUString
> SwXDocumentIndexes::getSupportedServiceNames(void) throw( uno::RuntimeException
)
1971 uno::Sequence
< OUString
> aRet(1);
1972 OUString
* pArray
= aRet
.getArray();
1973 pArray
[0] = C2U("com.sun.star.text.DocumentIndexes");
1976 /*-- 05.05.99 13:14:59---------------------------------------------------
1978 -----------------------------------------------------------------------*/
1979 SwXDocumentIndexes::SwXDocumentIndexes(SwDoc
* _pDoc
) :
1980 SwUnoCollection(_pDoc
)
1983 /*-- 05.05.99 13:15:00---------------------------------------------------
1985 -----------------------------------------------------------------------*/
1986 SwXDocumentIndexes::~SwXDocumentIndexes()
1989 /*-- 05.05.99 13:15:01---------------------------------------------------
1991 -----------------------------------------------------------------------*/
1992 sal_Int32
SwXDocumentIndexes::getCount(void) throw( uno::RuntimeException
)
1994 vos::OGuard
aGuard(Application::GetSolarMutex());
1996 throw uno::RuntimeException();
1998 sal_uInt32 nRet
= 0;
1999 const SwSectionFmts
& rFmts
= GetDoc()->GetSections();
2000 for( sal_uInt16 n
= 0; n
< rFmts
.Count(); ++n
)
2002 const SwSection
* pSect
= rFmts
[ n
]->GetSection();
2003 if( TOX_CONTENT_SECTION
== pSect
->GetType() &&
2004 pSect
->GetFmt()->GetSectionNode() )
2009 /*-- 05.05.99 13:15:01---------------------------------------------------
2011 -----------------------------------------------------------------------*/
2012 uno::Any
SwXDocumentIndexes::getByIndex(sal_Int32 nIndex
)
2013 throw( lang::IndexOutOfBoundsException
, lang::WrappedTargetException
, uno::RuntimeException
)
2015 vos::OGuard
aGuard(Application::GetSolarMutex());
2017 throw uno::RuntimeException();
2022 const SwSectionFmts
& rFmts
= GetDoc()->GetSections();
2023 for( sal_uInt16 n
= 0; n
< rFmts
.Count(); ++n
)
2025 const SwSection
* pSect
= rFmts
[ n
]->GetSection();
2026 if( TOX_CONTENT_SECTION
== pSect
->GetType() &&
2027 pSect
->GetFmt()->GetSectionNode() &&
2030 uno::Reference
< text::XDocumentIndex
> xTmp
= new SwXDocumentIndex(
2031 (SwTOXBaseSection
*)pSect
, GetDoc() );
2032 aRet
.setValue(&xTmp
, ::getCppuType((uno::Reference
<text::XDocumentIndex
>*)0));
2037 throw lang::IndexOutOfBoundsException();
2040 /*-- 31.01.00 10:12:31---------------------------------------------------
2042 -----------------------------------------------------------------------*/
2043 uno::Any
SwXDocumentIndexes::getByName(const OUString
& rName
)
2044 throw( container::NoSuchElementException
, lang::WrappedTargetException
, uno::RuntimeException
)
2046 vos::OGuard
aGuard(Application::GetSolarMutex());
2048 throw uno::RuntimeException();
2052 String
sToFind(rName
);
2053 const SwSectionFmts
& rFmts
= GetDoc()->GetSections();
2054 for( sal_uInt16 n
= 0; n
< rFmts
.Count(); ++n
)
2056 const SwSection
* pSect
= rFmts
[ n
]->GetSection();
2057 if( TOX_CONTENT_SECTION
== pSect
->GetType() &&
2058 pSect
->GetFmt()->GetSectionNode() &&
2059 ((SwTOXBaseSection
*)pSect
)->GetTOXName() == sToFind
)
2061 uno::Reference
< text::XDocumentIndex
> xTmp
= new SwXDocumentIndex(
2062 (SwTOXBaseSection
*)pSect
, GetDoc() );
2063 aRet
.setValue(&xTmp
, ::getCppuType((uno::Reference
<text::XDocumentIndex
>*)0));
2067 throw container::NoSuchElementException();
2069 /*-- 31.01.00 10:12:31---------------------------------------------------
2071 -----------------------------------------------------------------------*/
2072 uno::Sequence
< OUString
> SwXDocumentIndexes::getElementNames(void)
2073 throw( uno::RuntimeException
)
2075 vos::OGuard
aGuard(Application::GetSolarMutex());
2077 throw uno::RuntimeException();
2079 const SwSectionFmts
& rFmts
= GetDoc()->GetSections();
2080 sal_Int32 nCount
= 0;
2082 for( n
= 0; n
< rFmts
.Count(); ++n
)
2084 const SwSection
* pSect
= rFmts
[ n
]->GetSection();
2085 if( TOX_CONTENT_SECTION
== pSect
->GetType() &&
2086 pSect
->GetFmt()->GetSectionNode() )
2090 uno::Sequence
< OUString
> aRet(nCount
);
2091 OUString
* pArray
= aRet
.getArray();
2093 for( n
= 0, nCnt
= 0; n
< rFmts
.Count(); ++n
)
2095 const SwSection
* pSect
= rFmts
[ n
]->GetSection();
2096 if( TOX_CONTENT_SECTION
== pSect
->GetType() &&
2097 pSect
->GetFmt()->GetSectionNode())
2099 pArray
[nCnt
++] = OUString(((SwTOXBaseSection
*)pSect
)->GetTOXName());
2104 /*-- 31.01.00 10:12:31---------------------------------------------------
2106 -----------------------------------------------------------------------*/
2107 sal_Bool
SwXDocumentIndexes::hasByName(const OUString
& rName
)
2108 throw( uno::RuntimeException
)
2110 vos::OGuard
aGuard(Application::GetSolarMutex());
2112 throw uno::RuntimeException();
2114 String
sToFind(rName
);
2115 const SwSectionFmts
& rFmts
= GetDoc()->GetSections();
2116 for( sal_uInt16 n
= 0; n
< rFmts
.Count(); ++n
)
2118 const SwSection
* pSect
= rFmts
[ n
]->GetSection();
2119 if( TOX_CONTENT_SECTION
== pSect
->GetType() &&
2120 pSect
->GetFmt()->GetSectionNode())
2122 if(((SwTOXBaseSection
*)pSect
)->GetTOXName() == sToFind
)
2128 /*-- 05.05.99 13:15:01---------------------------------------------------
2130 -----------------------------------------------------------------------*/
2131 uno::Type
SwXDocumentIndexes::getElementType(void) throw( uno::RuntimeException
)
2133 return ::getCppuType((uno::Reference
< text::XDocumentIndex
> *)0);
2135 /*-- 05.05.99 13:15:02---------------------------------------------------
2137 -----------------------------------------------------------------------*/
2138 sal_Bool
SwXDocumentIndexes::hasElements(void) throw( uno::RuntimeException
)
2140 vos::OGuard
aGuard(Application::GetSolarMutex());
2142 throw uno::RuntimeException();
2143 return 0 != getCount();
2146 SwXDocumentIndex
* SwXDocumentIndexes::GetObject(const SwTOXBaseSection
* pTOX
)
2148 SwSectionFmt
* pFmt
= pTOX
->GetFmt();
2149 SwClientIter
aIter(*pFmt
);
2150 SwXDocumentIndex
* pxIdx
= (SwXDocumentIndex
*)aIter
.First(TYPE(SwXDocumentIndex
));
2154 return new SwXDocumentIndex(pTOX
, pFmt
->GetDoc());
2157 /* -----------------------------06.04.00 15:08--------------------------------
2159 ---------------------------------------------------------------------------*/
2160 OUString
SwXIndexStyleAccess_Impl::getImplementationName(void) throw( uno::RuntimeException
)
2162 return C2U("SwXIndexStyleAccess_Impl");
2164 /* -----------------------------06.04.00 15:08--------------------------------
2166 ---------------------------------------------------------------------------*/
2167 BOOL
SwXIndexStyleAccess_Impl::supportsService(const OUString
& rServiceName
) throw( uno::RuntimeException
)
2169 return C2U("com.sun.star.text.DocumentIndexParagraphStyles") == rServiceName
;
2171 /* -----------------------------06.04.00 15:08--------------------------------
2173 ---------------------------------------------------------------------------*/
2174 uno::Sequence
< OUString
> SwXIndexStyleAccess_Impl::getSupportedServiceNames(void) throw( uno::RuntimeException
)
2176 uno::Sequence
< OUString
> aRet(1);
2177 OUString
* pArray
= aRet
.getArray();
2178 pArray
[0] = C2U("com.sun.star.text.DocumentIndexParagraphStyles");
2181 /*-- 13.09.99 16:52:28---------------------------------------------------
2183 -----------------------------------------------------------------------*/
2184 SwXIndexStyleAccess_Impl::SwXIndexStyleAccess_Impl(SwXDocumentIndex
& rParentIdx
) :
2185 rParent(rParentIdx
),
2186 xParent(&rParentIdx
)
2188 vos::OGuard
aGuard(Application::GetSolarMutex());
2189 rParent
.SetStyleAccess(this);
2191 /*-- 13.09.99 16:52:29---------------------------------------------------
2193 -----------------------------------------------------------------------*/
2194 SwXIndexStyleAccess_Impl::~SwXIndexStyleAccess_Impl()
2196 vos::OGuard
aGuard(Application::GetSolarMutex());
2197 rParent
.SetStyleAccess(0);
2199 /*-- 13.09.99 16:52:29---------------------------------------------------
2201 -----------------------------------------------------------------------*/
2202 void SwXIndexStyleAccess_Impl::replaceByIndex(sal_Int32 nIndex
, const uno::Any
& rElement
)
2203 throw( lang::IllegalArgumentException
, lang::IndexOutOfBoundsException
,
2204 lang::WrappedTargetException
, uno::RuntimeException
)
2206 vos::OGuard
aGuard(Application::GetSolarMutex());
2207 const sal_Bool bDescriptor
= rParent
.IsDescriptor();
2208 SwSectionFmt
* pSectFmt
= rParent
.GetFmt();
2209 if(!pSectFmt
&& !bDescriptor
)
2210 throw uno::RuntimeException();
2211 if(nIndex
< 0 || nIndex
> MAXLEVEL
)
2212 throw lang::IndexOutOfBoundsException();
2213 SwTOXBase
* pTOXBase
= bDescriptor
? &rParent
.GetProperties_Impl()->GetTOXBase() :
2214 (SwTOXBaseSection
*)pSectFmt
->GetSection();
2216 uno::Sequence
<OUString
> aSeq
;
2217 if(!(rElement
>>= aSeq
))
2218 throw lang::IllegalArgumentException();
2220 sal_Int32 nStyles
= aSeq
.getLength();
2221 const OUString
* pStyles
= aSeq
.getConstArray();
2224 for(sal_Int32 i
= 0; i
< nStyles
; i
++)
2227 sSetStyles
+= TOX_STYLE_DELIMITER
;
2228 SwStyleNameMapper::FillUIName(pStyles
[i
], aString
, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL
, sal_True
);
2229 sSetStyles
+= aString
;
2231 pTOXBase
->SetStyleNames(sSetStyles
, (sal_uInt16
) nIndex
);
2233 /*-- 13.09.99 16:52:29---------------------------------------------------
2235 -----------------------------------------------------------------------*/
2236 sal_Int32
SwXIndexStyleAccess_Impl::getCount(void) throw( uno::RuntimeException
)
2240 /*-- 13.09.99 16:52:30---------------------------------------------------
2242 -----------------------------------------------------------------------*/
2243 uno::Any
SwXIndexStyleAccess_Impl::getByIndex(sal_Int32 nIndex
)
2244 throw( lang::IndexOutOfBoundsException
, lang::WrappedTargetException
,
2245 uno::RuntimeException
)
2247 vos::OGuard
aGuard(Application::GetSolarMutex());
2248 const sal_Bool bDescriptor
= rParent
.IsDescriptor();
2249 SwSectionFmt
* pSectFmt
= rParent
.GetFmt();
2250 if(!pSectFmt
&& !bDescriptor
)
2251 throw uno::RuntimeException();
2252 if(nIndex
< 0 || nIndex
> MAXLEVEL
)
2253 throw lang::IndexOutOfBoundsException();
2254 SwTOXBase
* pTOXBase
= bDescriptor
? &rParent
.GetProperties_Impl()->GetTOXBase() :
2255 (SwTOXBaseSection
*)pSectFmt
->GetSection();
2257 const String
& rStyles
= pTOXBase
->GetStyleNames((sal_uInt16
) nIndex
);
2258 sal_uInt16 nStyles
= rStyles
.GetTokenCount(TOX_STYLE_DELIMITER
);
2259 uno::Sequence
<OUString
> aStyles(nStyles
);
2260 OUString
* pStyles
= aStyles
.getArray();
2262 for(sal_uInt16 i
= 0; i
< nStyles
; i
++)
2264 SwStyleNameMapper::FillProgName(
2265 rStyles
.GetToken(i
, TOX_STYLE_DELIMITER
),
2267 nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL
,
2269 pStyles
[i
] = OUString( aString
);
2271 uno::Any
aRet(&aStyles
, ::getCppuType((uno::Sequence
<OUString
>*)0));
2274 /*-- 13.09.99 16:52:30---------------------------------------------------
2276 -----------------------------------------------------------------------*/
2277 uno::Type
SwXIndexStyleAccess_Impl::getElementType(void)
2278 throw( uno::RuntimeException
)
2280 return ::getCppuType((uno::Sequence
<OUString
>*)0);
2282 /*-- 13.09.99 16:52:30---------------------------------------------------
2284 -----------------------------------------------------------------------*/
2285 sal_Bool
SwXIndexStyleAccess_Impl::hasElements(void) throw( uno::RuntimeException
)
2290 /* -----------------13.09.99 16:51-------------------
2292 --------------------------------------------------*/
2293 /* -----------------------------06.04.00 15:08--------------------------------
2295 ---------------------------------------------------------------------------*/
2296 OUString
SwXIndexTokenAccess_Impl::getImplementationName(void) throw( uno::RuntimeException
)
2298 return C2U("SwXIndexTokenAccess_Impl");
2300 /* -----------------------------06.04.00 15:08--------------------------------
2302 ---------------------------------------------------------------------------*/
2303 BOOL
SwXIndexTokenAccess_Impl::supportsService(const OUString
& rServiceName
) throw( uno::RuntimeException
)
2305 return C2U("com.sun.star.text.DocumentIndexLevelFormat") == rServiceName
;
2307 /* -----------------------------06.04.00 15:08--------------------------------
2309 ---------------------------------------------------------------------------*/
2310 uno::Sequence
< OUString
> SwXIndexTokenAccess_Impl::getSupportedServiceNames(void) throw( uno::RuntimeException
)
2312 uno::Sequence
< OUString
> aRet(1);
2313 OUString
* pArray
= aRet
.getArray();
2314 pArray
[0] = C2U("com.sun.star.text.DocumentIndexLevelFormat");
2317 /*-- 13.09.99 16:52:28---------------------------------------------------
2319 -----------------------------------------------------------------------*/
2320 SwXIndexTokenAccess_Impl::SwXIndexTokenAccess_Impl(SwXDocumentIndex
& rParentIdx
) :
2321 rParent(rParentIdx
),
2322 xParent(&rParentIdx
),
2323 nCount(SwForm::GetFormMaxLevel(rParent
.GetTOXType()))
2325 vos::OGuard
aGuard(Application::GetSolarMutex());
2326 rParent
.SetTokenAccess(this);
2328 /*-- 13.09.99 16:52:29---------------------------------------------------
2330 -----------------------------------------------------------------------*/
2331 SwXIndexTokenAccess_Impl::~SwXIndexTokenAccess_Impl()
2333 vos::OGuard
aGuard(Application::GetSolarMutex());
2334 rParent
.SetTokenAccess(0);
2336 /*-- 13.09.99 16:52:29---------------------------------------------------
2338 -----------------------------------------------------------------------*/
2339 void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex
, const uno::Any
& rElement
)
2340 throw( lang::IllegalArgumentException
, lang::IndexOutOfBoundsException
,
2341 lang::WrappedTargetException
, uno::RuntimeException
)
2343 vos::OGuard
aGuard(Application::GetSolarMutex());
2344 const sal_Bool bDescriptor
= rParent
.IsDescriptor();
2345 SwSectionFmt
* pSectFmt
= rParent
.GetFmt();
2346 if(!pSectFmt
&& !bDescriptor
)
2347 throw uno::RuntimeException();
2349 SwTOXBase
* pTOXBase
= bDescriptor
? &rParent
.GetProperties_Impl()->GetTOXBase() :
2350 (SwTOXBaseSection
*)pSectFmt
->GetSection();
2352 (nIndex
> pTOXBase
->GetTOXForm().GetFormMax()))
2353 throw lang::IndexOutOfBoundsException();
2355 uno::Sequence
<beans::PropertyValues
> aSeq
;
2356 if(!(rElement
>>= aSeq
))
2357 throw lang::IllegalArgumentException();
2360 sal_Int32 nTokens
= aSeq
.getLength();
2361 const beans::PropertyValues
* pTokens
= aSeq
.getConstArray();
2362 for(sal_Int32 i
= 0; i
< nTokens
; i
++)
2364 const beans::PropertyValue
* pProperties
= pTokens
[i
].getConstArray();
2365 sal_Int32 nProperties
= pTokens
[i
].getLength();
2366 //create an invalid token
2367 SwFormToken
aToken(TOKEN_END
);
2368 for(sal_Int32 j
= 0; j
< nProperties
; j
++)
2370 if( COMPARE_EQUAL
== pProperties
[j
].Name
.compareToAscii("TokenType"))
2372 const String sTokenType
=
2373 lcl_AnyToString(pProperties
[j
].Value
);
2374 if(sTokenType
.EqualsAscii("TokenEntryNumber"))
2375 aToken
.eTokenType
= TOKEN_ENTRY_NO
;
2376 else if(sTokenType
.EqualsAscii("TokenEntryText" ))
2377 aToken
.eTokenType
= TOKEN_ENTRY_TEXT
;
2378 else if(sTokenType
.EqualsAscii("TokenTabStop" ))
2379 aToken
.eTokenType
= TOKEN_TAB_STOP
;
2380 else if(sTokenType
.EqualsAscii("TokenText" ))
2381 aToken
.eTokenType
= TOKEN_TEXT
;
2382 else if(sTokenType
.EqualsAscii("TokenPageNumber"))
2383 aToken
.eTokenType
= TOKEN_PAGE_NUMS
;
2384 else if(sTokenType
.EqualsAscii("TokenChapterInfo" ))
2385 aToken
.eTokenType
= TOKEN_CHAPTER_INFO
;
2386 else if(sTokenType
.EqualsAscii("TokenHyperlinkStart" ))
2387 aToken
.eTokenType
= TOKEN_LINK_START
;
2388 else if(sTokenType
.EqualsAscii("TokenHyperlinkEnd"))
2389 aToken
.eTokenType
= TOKEN_LINK_END
;
2390 else if(sTokenType
.EqualsAscii("TokenBibliographyDataField" ))
2391 aToken
.eTokenType
= TOKEN_AUTHORITY
;
2393 else if( pProperties
[j
].Name
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("CharacterStyleName" ) ))
2395 String sCharStyleName
;
2396 SwStyleNameMapper::FillUIName(
2397 lcl_AnyToString(pProperties
[j
].Value
),
2399 nsSwGetPoolIdFromName::GET_POOLID_CHRFMT
,
2401 aToken
.sCharStyleName
= sCharStyleName
;
2402 aToken
.nPoolId
= SwStyleNameMapper::GetPoolIdFromUIName (
2403 sCharStyleName
, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT
);
2405 else if( pProperties
[j
].Name
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("TabStopRightAligned") ))
2407 sal_Bool bRight
= lcl_AnyToBool(pProperties
[j
].Value
);
2408 aToken
.eTabAlign
= bRight
?
2409 SVX_TAB_ADJUST_END
: SVX_TAB_ADJUST_LEFT
;
2411 else if( pProperties
[j
].Name
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("TabStopPosition" )))
2413 sal_Int32 nPosition
= 0;
2414 if(pProperties
[j
].Value
.getValueType() != ::getCppuType((sal_Int32
*)0))
2415 throw lang::IllegalArgumentException();
2416 pProperties
[j
].Value
>>= nPosition
;
2417 nPosition
= MM100_TO_TWIP(nPosition
);
2419 throw lang::IllegalArgumentException();
2420 aToken
.nTabStopPosition
= nPosition
;
2422 else if( pProperties
[j
].Name
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("TabStopFillCharacter" )))
2424 const String sFillChar
=
2425 lcl_AnyToString(pProperties
[j
].Value
);
2426 if(sFillChar
.Len() > 1)
2427 throw lang::IllegalArgumentException();
2428 aToken
.cTabFillChar
= sFillChar
.Len() ?
2429 sFillChar
.GetChar(0) : ' ';
2431 else if( pProperties
[j
].Name
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Text" )))
2433 const String sText
=
2434 lcl_AnyToString(pProperties
[j
].Value
);
2435 aToken
.sText
= sText
;
2437 else if( pProperties
[j
].Name
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ChapterFormat" )))
2439 sal_Int16 nFormat
= lcl_AnyToInt16(pProperties
[j
].Value
);
2442 case text::ChapterFormat::NUMBER
: nFormat
= CF_NUMBER
;
2444 case text::ChapterFormat::NAME
: nFormat
= CF_TITLE
;
2446 case text::ChapterFormat::NAME_NUMBER
: nFormat
= CF_NUM_TITLE
;
2448 case text::ChapterFormat::NO_PREFIX_SUFFIX
:nFormat
= CF_NUMBER_NOPREPST
;
2450 case text::ChapterFormat::DIGIT
: nFormat
= CF_NUM_NOPREPST_TITLE
;
2453 throw lang::IllegalArgumentException();
2455 aToken
.nChapterFormat
= nFormat
;
2458 else if( pProperties
[j
].Name
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ChapterLevel")) )
2460 const sal_Int16 nLevel
= lcl_AnyToInt16(pProperties
[j
].Value
);
2461 if( nLevel
< 1 || nLevel
> MAXLEVEL
)
2462 throw lang::IllegalArgumentException();
2463 aToken
.nOutlineLevel
= nLevel
;
2466 else if( pProperties
[j
].Name
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("BibliographyDataField")))
2468 sal_Int16 nType
= 0;
2469 pProperties
[j
].Value
>>= nType
;
2470 if(nType
< 0 || nType
> text::BibliographyDataField::ISBN
)
2472 lang::IllegalArgumentException aExcept
;
2473 aExcept
.Message
= C2U("BibliographyDataField - wrong value");
2474 aExcept
.ArgumentPosition
= static_cast< sal_Int16
>(j
);
2477 aToken
.nAuthorityField
= nType
;
2480 else if ( pProperties
[j
].Name
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("WithTab")))
2482 aToken
.bWithTab
= lcl_AnyToBool(pProperties
[j
].Value
);
2486 //exception if wrong TokenType
2487 if(TOKEN_END
<= aToken
.eTokenType
)
2488 throw lang::IllegalArgumentException();
2489 // set TokenType from TOKEN_ENTRY_TEXT to TOKEN_ENTRY if it is
2490 // not a content index
2491 if(TOKEN_ENTRY_TEXT
== aToken
.eTokenType
&&
2492 TOX_CONTENT
!= pTOXBase
->GetType())
2493 aToken
.eTokenType
= TOKEN_ENTRY
;
2495 // check for chapter format allowed values if it was TOKEN_ENTRY_NO type
2496 // only allowed value are CF_NUMBER and CF_NUM_NOPREPST_TITLE
2497 // reading from file
2498 if( TOKEN_ENTRY_NO
== aToken
.eTokenType
)
2499 switch(aToken
.nChapterFormat
)
2502 case CF_NUM_NOPREPST_TITLE
:
2505 throw lang::IllegalArgumentException();
2508 sPattern
+= aToken
.GetString();
2510 SwForm
aForm(pTOXBase
->GetTOXForm());
2511 aForm
.SetPattern((sal_uInt16
) nIndex
, sPattern
);
2512 pTOXBase
->SetTOXForm(aForm
);
2514 /*-- 13.09.99 16:52:29---------------------------------------------------
2516 -----------------------------------------------------------------------*/
2517 sal_Int32
SwXIndexTokenAccess_Impl::getCount(void) throw( uno::RuntimeException
)
2519 vos::OGuard
aGuard(Application::GetSolarMutex());
2520 const sal_Bool bDescriptor
= rParent
.IsDescriptor();
2521 SwSectionFmt
* pSectFmt
= rParent
.GetFmt();
2522 if(!pSectFmt
&& !bDescriptor
)
2523 throw uno::RuntimeException();
2524 sal_Int32 nRet
= bDescriptor
?
2526 ((SwTOXBaseSection
*)pSectFmt
->GetSection())->
2527 GetTOXForm().GetFormMax();
2530 /*-- 13.09.99 16:52:30---------------------------------------------------
2532 -----------------------------------------------------------------------*/
2533 uno::Any
SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex
)
2534 throw( lang::IndexOutOfBoundsException
, lang::WrappedTargetException
,
2535 uno::RuntimeException
)
2537 vos::OGuard
aGuard(Application::GetSolarMutex());
2538 const sal_Bool bDescriptor
= rParent
.IsDescriptor();
2539 SwSectionFmt
* pSectFmt
= rParent
.GetFmt();
2540 if(!pSectFmt
&& !bDescriptor
)
2541 throw uno::RuntimeException();
2542 SwTOXBase
* pTOXBase
= bDescriptor
? &rParent
.GetProperties_Impl()->GetTOXBase() :
2543 (SwTOXBaseSection
*)pSectFmt
->GetSection();
2545 (nIndex
> pTOXBase
->GetTOXForm().GetFormMax()))
2546 throw lang::IndexOutOfBoundsException();
2549 SwFormTokens aPattern
= pTOXBase
->GetTOXForm().
2550 GetPattern((sal_uInt16
) nIndex
);
2551 SwFormTokens::iterator aIt
= aPattern
.begin();
2553 sal_uInt16 nTokenCount
= 0;
2554 uno::Sequence
< beans::PropertyValues
> aRetSeq
;
2556 while(aIt
!= aPattern
.end()) // #i21237#
2559 aRetSeq
.realloc(nTokenCount
);
2560 beans::PropertyValues
* pTokenProps
= aRetSeq
.getArray();
2561 SwFormToken aToken
= *aIt
; // #i21237#
2563 uno::Sequence
< beans::PropertyValue
>& rCurTokenSeq
= pTokenProps
[nTokenCount
-1];
2564 SwStyleNameMapper::FillProgName(
2565 aToken
.sCharStyleName
,
2567 nsSwGetPoolIdFromName::GET_POOLID_CHRFMT
,
2569 const OUString
aProgCharStyle( aString
);
2570 switch(aToken
.eTokenType
)
2572 case TOKEN_ENTRY_NO
:
2575 // writing to file (from doc to properties)
2576 sal_Int32 nElements
= 2;
2577 sal_Int32 nCurrentElement
= 0;
2579 if( aToken
.nChapterFormat
!= CF_NUMBER
)//check for default value
2580 nElements
++;//we need the element
2581 if( aToken
.nOutlineLevel
!= MAXLEVEL
)
2584 rCurTokenSeq
.realloc( nElements
);
2586 beans::PropertyValue
* pArr
= rCurTokenSeq
.getArray();
2588 pArr
[nCurrentElement
].Name
= C2U("TokenType");
2589 pArr
[nCurrentElement
++].Value
<<= OUString::createFromAscii("TokenEntryNumber");
2590 // pArr[0].Value <<= C2U("TokenEntryNumber");
2592 pArr
[nCurrentElement
].Name
= C2U("CharacterStyleName");
2593 pArr
[nCurrentElement
++].Value
<<= aProgCharStyle
;
2594 if( aToken
.nChapterFormat
!= CF_NUMBER
)
2596 pArr
[nCurrentElement
].Name
= C2U("ChapterFormat");
2598 //! the allowed values for chapter format, when used as entry number, are CF_NUMBER and CF_NUM_NOPREPST_TITLE only, all else forced to
2600 switch(aToken
.nChapterFormat
)
2603 case CF_NUMBER
: nVal
= text::ChapterFormat::NUMBER
; break;
2604 case CF_NUM_NOPREPST_TITLE
: nVal
= text::ChapterFormat::DIGIT
; break;
2606 pArr
[nCurrentElement
++].Value
<<= (sal_Int16
)nVal
;
2609 if( aToken
.nOutlineLevel
!= MAXLEVEL
) //only a ChapterLevel != MAXLEVEL is registered
2611 pArr
[nCurrentElement
].Name
= C2U("ChapterLevel");
2612 pArr
[nCurrentElement
].Value
<<= aToken
.nOutlineLevel
;
2617 case TOKEN_ENTRY
: // no difference between Entry and Entry Text
2618 case TOKEN_ENTRY_TEXT
:
2620 rCurTokenSeq
.realloc( 2 );
2621 beans::PropertyValue
* pArr
= rCurTokenSeq
.getArray();
2623 pArr
[0].Name
= C2U("TokenType");
2624 pArr
[0].Value
<<= OUString::createFromAscii("TokenEntryText");
2626 pArr
[1].Name
= C2U("CharacterStyleName");
2627 pArr
[1].Value
<<= aProgCharStyle
;
2630 case TOKEN_TAB_STOP
:
2632 rCurTokenSeq
.realloc(5); // #i21237#
2633 beans::PropertyValue
* pArr
= rCurTokenSeq
.getArray();
2635 pArr
[0].Name
= C2U("TokenType");
2636 pArr
[0].Value
<<= OUString::createFromAscii("TokenTabStop");
2639 if(SVX_TAB_ADJUST_END
== aToken
.eTabAlign
)
2641 pArr
[1].Name
= C2U("TabStopRightAligned");
2642 BOOL bTemp
= sal_True
;
2643 pArr
[1].Value
.setValue(&bTemp
, ::getCppuBooleanType());
2647 pArr
[1].Name
= C2U("TabStopPosition");
2648 sal_Int32 nPos
= (TWIP_TO_MM100(aToken
.nTabStopPosition
));
2651 pArr
[1].Value
<<= (sal_Int32
)nPos
;
2653 pArr
[2].Name
= C2U("TabStopFillCharacter");
2654 pArr
[2].Value
<<= OUString(aToken
.cTabFillChar
);
2655 pArr
[3].Name
= C2U("CharacterStyleName");
2656 pArr
[3].Value
<<= aProgCharStyle
;
2658 pArr
[4].Name
= C2U("WithTab");
2659 pArr
[4].Value
.setValue(&aToken
.bWithTab
, ::getCppuBooleanType());
2664 rCurTokenSeq
.realloc( 3 );
2665 beans::PropertyValue
* pArr
= rCurTokenSeq
.getArray();
2667 pArr
[0].Name
= C2U("TokenType");
2668 pArr
[0].Value
<<= OUString::createFromAscii("TokenText");
2670 pArr
[1].Name
= C2U("CharacterStyleName");
2671 pArr
[1].Value
<<= aProgCharStyle
;
2673 pArr
[2].Name
= C2U("Text");
2674 pArr
[2].Value
<<= OUString(aToken
.sText
);
2677 case TOKEN_PAGE_NUMS
:
2679 rCurTokenSeq
.realloc( 2 );
2680 beans::PropertyValue
* pArr
= rCurTokenSeq
.getArray();
2682 pArr
[0].Name
= C2U("TokenType");
2683 pArr
[0].Value
<<= OUString::createFromAscii("TokenPageNumber");
2685 pArr
[1].Name
= C2U("CharacterStyleName");
2686 pArr
[1].Value
<<= aProgCharStyle
;
2689 case TOKEN_CHAPTER_INFO
:
2691 rCurTokenSeq
.realloc( 4 );
2692 beans::PropertyValue
* pArr
= rCurTokenSeq
.getArray();
2694 pArr
[0].Name
= C2U("TokenType");
2695 pArr
[0].Value
<<= OUString::createFromAscii("TokenChapterInfo");
2697 pArr
[1].Name
= C2U("CharacterStyleName");
2698 pArr
[1].Value
<<= aProgCharStyle
;
2700 pArr
[2].Name
= C2U("ChapterFormat");
2701 sal_Int16 nVal
= text::ChapterFormat::NUMBER
;
2702 switch(aToken
.nChapterFormat
)
2704 case CF_NUMBER
: nVal
= text::ChapterFormat::NUMBER
; break;
2705 case CF_TITLE
: nVal
= text::ChapterFormat::NAME
; break;
2706 case CF_NUM_TITLE
: nVal
= text::ChapterFormat::NAME_NUMBER
; break;
2707 case CF_NUMBER_NOPREPST
: nVal
= text::ChapterFormat::NO_PREFIX_SUFFIX
; break;
2708 case CF_NUM_NOPREPST_TITLE
: nVal
= text::ChapterFormat::DIGIT
; break;
2710 pArr
[2].Value
<<= (sal_Int16
)nVal
;
2712 pArr
[3].Name
= C2U("ChapterLevel");
2714 pArr
[3].Value
<<= aToken
.nOutlineLevel
;
2718 case TOKEN_LINK_START
:
2720 rCurTokenSeq
.realloc( 2 );
2721 beans::PropertyValue
* pArr
= rCurTokenSeq
.getArray();
2723 pArr
[0].Name
= C2U("TokenType");
2724 pArr
[0].Value
<<= OUString::createFromAscii("TokenHyperlinkStart");
2725 pArr
[1].Name
= C2U("CharacterStyleName");
2726 pArr
[1].Value
<<= aProgCharStyle
;
2729 case TOKEN_LINK_END
:
2731 rCurTokenSeq
.realloc( 1 );
2732 beans::PropertyValue
* pArr
= rCurTokenSeq
.getArray();
2734 pArr
[0].Name
= C2U("TokenType");
2735 pArr
[0].Value
<<= OUString::createFromAscii("TokenHyperlinkEnd");
2738 case TOKEN_AUTHORITY
:
2740 rCurTokenSeq
.realloc( 3 );
2741 beans::PropertyValue
* pArr
= rCurTokenSeq
.getArray();
2743 pArr
[0].Name
= C2U("TokenType");
2744 pArr
[0].Value
<<= OUString::createFromAscii("TokenBibliographyDataField");
2746 pArr
[1].Name
= C2U("CharacterStyleName");
2747 pArr
[1].Value
<<= aProgCharStyle
;
2749 pArr
[2].Name
= C2U("BibliographyDataField");
2750 pArr
[2].Value
<<= sal_Int16(aToken
.nAuthorityField
);
2761 uno::Any
aRet(&aRetSeq
, ::getCppuType((uno::Sequence
< beans::PropertyValues
>*)0));
2765 /*-- 13.09.99 16:52:30---------------------------------------------------
2767 -----------------------------------------------------------------------*/
2768 uno::Type
SwXIndexTokenAccess_Impl::getElementType(void)
2769 throw( uno::RuntimeException
)
2771 return ::getCppuType((uno::Sequence
< beans::PropertyValues
>*)0);
2773 /*-- 13.09.99 16:52:30---------------------------------------------------
2775 -----------------------------------------------------------------------*/
2776 sal_Bool
SwXIndexTokenAccess_Impl::hasElements(void) throw( uno::RuntimeException
)