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
->Delete(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
->Insert( aTmp
, aMark
, 0 );
1383 pTxtAttr
= pStt
->nNode
.GetNode().GetTxtNode()->GetTxtAttr(
1384 pStt
->nContent
.GetIndex()-1, RES_TXTATR_TOXMARK
);
1386 else if( *pEnd
!= *pStt
)
1388 m_pDoc
->Insert( aPam
, aMark
, nsSetAttrMode::SETATTR_DONTEXPAND
);
1389 pTxtAttr
= pStt
->nNode
.GetNode().GetTxtNode()->GetTxtAttr(
1390 pStt
->nContent
, RES_TXTATR_TOXMARK
);
1392 //und sonst - Marke geloescht?
1394 m_pTOXMark
= &pTxtAttr
->GetTOXMark();
1396 else if(bIsDescriptor
)
1398 sAltText
= rIndexEntry
;
1401 throw uno::RuntimeException();
1403 /* -----------------18.02.99 13:40-------------------
1405 * --------------------------------------------------*/
1406 void SwXDocumentIndexMark::attachToRange(const uno::Reference
< text::XTextRange
> & xTextRange
)
1407 throw( lang::IllegalArgumentException
, uno::RuntimeException
)
1409 vos::OGuard
aGuard(Application::GetSolarMutex());
1411 throw uno::RuntimeException();
1413 uno::Reference
<XUnoTunnel
> xRangeTunnel( xTextRange
, uno::UNO_QUERY
);
1414 SwXTextRange
* pRange
= 0;
1415 OTextCursorHelper
* pCursor
= 0;
1416 if(xRangeTunnel
.is())
1418 pRange
= reinterpret_cast< SwXTextRange
* >(
1419 sal::static_int_cast
< sal_IntPtr
>( xRangeTunnel
->getSomething( SwXTextRange::getUnoTunnelId()) ));
1420 pCursor
= reinterpret_cast< OTextCursorHelper
* >(
1421 sal::static_int_cast
< sal_IntPtr
>( xRangeTunnel
->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
1424 SwDoc
* pDoc
= pRange
? (SwDoc
*)pRange
->GetDoc() : pCursor
? (SwDoc
*)pCursor
->GetDoc() : 0;
1428 const SwTOXType
* pTOXType
= 0;
1433 pTOXType
= pDoc
->GetTOXType( eType
, 0 );
1437 if(!sUserIndexName
.Len())
1438 pTOXType
= pDoc
->GetTOXType( eType
, 0 );
1441 sal_uInt16 nCount
= pDoc
->GetTOXTypeCount( eType
);
1442 for(sal_uInt16 i
= 0; i
< nCount
; i
++)
1444 const SwTOXType
* pTemp
= pDoc
->GetTOXType( eType
, i
);
1445 if(sUserIndexName
== pTemp
->GetTypeName())
1453 SwTOXType
aUserType(TOX_USER
, sUserIndexName
);
1454 pTOXType
= pDoc
->InsertTOXType(aUserType
);
1464 throw lang::IllegalArgumentException();
1465 pDoc
->GetUnoCallBack()->Add(this);
1466 ((SwTOXType
*)pTOXType
)->Add(&aTypeDepend
);
1468 SwUnoInternalPaM
aPam(*pDoc
);
1469 //das muss jetzt sal_True liefern
1470 SwXTextRange::XTextRangeToSwPaM(aPam
, xTextRange
);
1471 SwTOXMark
aMark (pTOXType
);
1473 aMark
.SetAlternativeText(sAltText
);
1477 if(sPrimaryKey
.Len())
1478 aMark
.SetPrimaryKey(sPrimaryKey
);
1479 if(sSecondaryKey
.Len())
1480 aMark
.SetSecondaryKey(sSecondaryKey
);
1481 if(sTextReading
.Len())
1482 aMark
.SetTextReading(sTextReading
);
1483 if(sPrimaryKeyReading
.Len())
1484 aMark
.SetPrimaryKeyReading(sPrimaryKeyReading
);
1485 if(sSecondaryKeyReading
.Len())
1486 aMark
.SetSecondaryKeyReading(sSecondaryKeyReading
);
1487 aMark
.SetMainEntry(bMainEntry
);
1491 if(USHRT_MAX
!= nLevel
)
1492 aMark
.SetLevel(nLevel
+1);
1498 UnoActionContext
aAction(pDoc
);
1499 sal_Bool bMark
= *aPam
.GetPoint() != *aPam
.GetMark();
1500 // Marks ohne Alternativtext ohne selektierten Text koennen nicht eingefuegt werden,
1501 // deshalb hier ein Leerzeichen - ob das die ideale Loesung ist?
1502 if(!bMark
&& !aMark
.GetAlternativeText().Len())
1503 aMark
.SetAlternativeText( String(' ') );
1504 pDoc
->Insert(aPam
, aMark
, nsSetAttrMode::SETATTR_DONTEXPAND
);
1505 if( bMark
&& *aPam
.GetPoint() > *aPam
.GetMark())
1508 SwTxtAttr
* pTxtAttr
= 0;
1510 pTxtAttr
= aPam
.GetNode()->GetTxtNode()->GetTxtAttr(
1511 aPam
.GetPoint()->nContent
, RES_TXTATR_TOXMARK
);
1513 pTxtAttr
= aPam
.GetNode()->GetTxtNode()->GetTxtAttr(
1514 aPam
.GetPoint()->nContent
.GetIndex()-1, RES_TXTATR_TOXMARK
);
1518 m_pTOXMark
= &pTxtAttr
->GetTOXMark();
1520 bIsDescriptor
= sal_False
;
1523 throw uno::RuntimeException();
1526 /*-- 14.12.98 10:25:45---------------------------------------------------
1528 -----------------------------------------------------------------------*/
1529 void SwXDocumentIndexMark::attach(const uno::Reference
< text::XTextRange
> & xTextRange
)
1530 throw( lang::IllegalArgumentException
, uno::RuntimeException
)
1532 vos::OGuard
aGuard(Application::GetSolarMutex());
1533 attachToRange( xTextRange
);
1535 /*-- 14.12.98 10:25:45---------------------------------------------------
1537 -----------------------------------------------------------------------*/
1538 uno::Reference
< text::XTextRange
> SwXDocumentIndexMark::getAnchor(void) throw( uno::RuntimeException
)
1540 vos::OGuard
aGuard(Application::GetSolarMutex());
1541 uno::Reference
< text::XTextRange
> aRet
;
1542 SwTOXType
* pType
= ((SwXDocumentIndexMark
*)this)->GetTOXType();
1543 if(pType
&& m_pTOXMark
)
1545 if( m_pTOXMark
->GetTxtTOXMark() )
1547 const SwTxtTOXMark
* pTxtMark
= m_pTOXMark
->GetTxtTOXMark();
1548 SwPaM
aPam(pTxtMark
->GetTxtNode(), *pTxtMark
->GetStart());
1550 if(pTxtMark
->GetEnd())
1552 aPam
.GetPoint()->nContent
= *pTxtMark
->GetEnd();
1555 aPam
.GetPoint()->nContent
++;
1556 uno::Reference
< frame::XModel
> xModel
= m_pDoc
->GetDocShell()->GetBaseModel();
1557 uno::Reference
< text::XTextDocument
> xTDoc(xModel
, uno::UNO_QUERY
);
1558 aRet
= new SwXTextRange(aPam
, xTDoc
->getText());
1562 throw uno::RuntimeException();
1565 /*-- 14.12.98 10:25:45---------------------------------------------------
1567 -----------------------------------------------------------------------*/
1568 void SwXDocumentIndexMark::dispose(void) throw( uno::RuntimeException
)
1570 vos::OGuard
aGuard(Application::GetSolarMutex());
1571 SwTOXType
* pType
= ((SwXDocumentIndexMark
*)this)->GetTOXType();
1572 if(pType
&& m_pTOXMark
)
1574 m_pDoc
->Delete(m_pTOXMark
);
1577 throw uno::RuntimeException();
1579 /*-- 14.12.98 10:25:45---------------------------------------------------
1581 -----------------------------------------------------------------------*/
1582 void SwXDocumentIndexMark::addEventListener(const uno::Reference
< lang::XEventListener
> & aListener
)
1583 throw( uno::RuntimeException
)
1585 if(!GetRegisteredIn())
1586 throw uno::RuntimeException();
1587 aLstnrCntnr
.AddListener(aListener
);
1589 /*-- 14.12.98 10:25:46---------------------------------------------------
1591 -----------------------------------------------------------------------*/
1592 void SwXDocumentIndexMark::removeEventListener(const uno::Reference
< lang::XEventListener
> & aListener
)
1593 throw( uno::RuntimeException
)
1595 if(!GetRegisteredIn() || !aLstnrCntnr
.RemoveListener(aListener
))
1596 throw uno::RuntimeException();
1598 /*-- 14.12.98 10:25:46---------------------------------------------------
1600 -----------------------------------------------------------------------*/
1601 uno::Reference
< beans::XPropertySetInfo
> SwXDocumentIndexMark::getPropertySetInfo(void)
1602 throw( uno::RuntimeException
)
1604 static uno::Reference
< beans::XPropertySetInfo
> xInfos
[3];
1608 case TOX_INDEX
: nPos
= 0; break;
1609 case TOX_CONTENT
: nPos
= 1; break;
1610 case TOX_USER
: nPos
= 2; break;
1614 if(!xInfos
[nPos
].is())
1616 uno::Reference
< beans::XPropertySetInfo
> xInfo
= m_pPropSet
->getPropertySetInfo();
1617 // extend PropertySetInfo!
1618 const uno::Sequence
<beans::Property
> aPropSeq
= xInfo
->getProperties();
1619 xInfos
[nPos
] = new SfxExtItemPropertySetInfo(
1620 aSwMapProvider
.GetPropertyMapEntries(PROPERTY_MAP_PARAGRAPH_EXTENSIONS
),
1623 return xInfos
[nPos
];
1625 /*-- 14.12.98 10:25:46---------------------------------------------------
1627 -----------------------------------------------------------------------*/
1628 void SwXDocumentIndexMark::setPropertyValue(const OUString
& rPropertyName
,
1629 const uno::Any
& aValue
)
1630 throw( beans::UnknownPropertyException
, beans::PropertyVetoException
,
1631 lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
1633 vos::OGuard
aGuard(Application::GetSolarMutex());
1634 SwTOXType
* pType
= ((SwXDocumentIndexMark
*)this)->GetTOXType();
1635 const SfxItemPropertySimpleEntry
* pEntry
= m_pPropSet
->getPropertyMap()->getByName(rPropertyName
);
1637 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
1638 if ( pEntry
->nFlags
& beans::PropertyAttribute::READONLY
)
1639 throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
1640 if(pType
&& m_pTOXMark
)
1642 SwDoc
* pLocalDoc
= m_pDoc
;
1644 SwTOXMark
aMark(*m_pTOXMark
);
1645 switch(pEntry
->nWID
)
1648 aMark
.SetAlternativeText(lcl_AnyToString(aValue
));
1651 aMark
.SetLevel(Min( (sal_Int8
) ( MAXLEVEL
),
1652 (sal_Int8
)(lcl_AnyToInt16(aValue
)+1)));
1654 case WID_PRIMARY_KEY
:
1655 aMark
.SetPrimaryKey(lcl_AnyToString(aValue
));
1657 case WID_SECONDARY_KEY
:
1658 aMark
.SetSecondaryKey(lcl_AnyToString(aValue
));
1660 case WID_MAIN_ENTRY
:
1661 aMark
.SetMainEntry(lcl_AnyToBool(aValue
));
1663 case WID_TEXT_READING
:
1664 aMark
.SetTextReading(lcl_AnyToString(aValue
));
1666 case WID_PRIMARY_KEY_READING
:
1667 aMark
.SetPrimaryKeyReading(lcl_AnyToString(aValue
));
1669 case WID_SECONDARY_KEY_READING
:
1670 aMark
.SetSecondaryKeyReading(lcl_AnyToString(aValue
));
1673 const SwTxtTOXMark
* pTxtMark
= m_pTOXMark
->GetTxtTOXMark();
1674 SwPaM
aPam(pTxtMark
->GetTxtNode(), *pTxtMark
->GetStart());
1676 if(pTxtMark
->GetEnd())
1678 aPam
.GetPoint()->nContent
= *pTxtMark
->GetEnd();
1681 aPam
.GetPoint()->nContent
++;
1683 //delete the old mark
1684 pLocalDoc
->Delete(m_pTOXMark
);
1687 sal_Bool bInsAtPos
= aMark
.IsAlternativeText();
1688 const SwPosition
*pStt
= aPam
.Start(),
1691 SwTxtAttr
* pTxtAttr
= 0;
1694 SwPaM
aTmp( *pStt
);
1695 pLocalDoc
->Insert( aTmp
, aMark
, 0 );
1696 pTxtAttr
= pStt
->nNode
.GetNode().GetTxtNode()->GetTxtAttr(
1697 pStt
->nContent
.GetIndex()-1, RES_TXTATR_TOXMARK
);
1699 else if( *pEnd
!= *pStt
)
1701 pLocalDoc
->Insert( aPam
, aMark
, nsSetAttrMode::SETATTR_DONTEXPAND
);
1702 pTxtAttr
= pStt
->nNode
.GetNode().GetTxtNode()->GetTxtAttr(
1703 pStt
->nContent
, RES_TXTATR_TOXMARK
);
1709 m_pTOXMark
= &pTxtAttr
->GetTOXMark();
1710 m_pDoc
->GetUnoCallBack()->Add(this);
1711 pType
->Add(&aTypeDepend
);
1714 else if(bIsDescriptor
)
1716 switch(pEntry
->nWID
)
1719 sAltText
= lcl_AnyToString(aValue
);
1723 sal_Int16 nVal
= lcl_AnyToInt16(aValue
);
1724 if(nVal
>= 0 && nVal
< MAXLEVEL
)
1727 throw lang::IllegalArgumentException();
1730 case WID_PRIMARY_KEY
:
1731 sPrimaryKey
= lcl_AnyToString(aValue
);
1733 case WID_SECONDARY_KEY
:
1734 sSecondaryKey
= lcl_AnyToString(aValue
);
1736 case WID_TEXT_READING
:
1737 sTextReading
= lcl_AnyToString(aValue
);
1739 case WID_PRIMARY_KEY_READING
:
1740 sPrimaryKeyReading
= lcl_AnyToString(aValue
);
1742 case WID_SECONDARY_KEY_READING
:
1743 sSecondaryKeyReading
= lcl_AnyToString(aValue
);
1745 case WID_USER_IDX_NAME
:
1747 OUString
sTmp(lcl_AnyToString(aValue
));
1748 lcl_ConvertTOUNameToUserName(sTmp
);
1749 sUserIndexName
= sTmp
;
1752 case WID_MAIN_ENTRY
:
1753 bMainEntry
= lcl_AnyToBool(aValue
);
1758 throw uno::RuntimeException();
1760 /*-- 14.12.98 10:25:46---------------------------------------------------
1762 -----------------------------------------------------------------------*/
1763 uno::Any
SwXDocumentIndexMark::getPropertyValue(const OUString
& rPropertyName
)
1764 throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
1766 vos::OGuard
aGuard(Application::GetSolarMutex());
1768 SwTOXType
* pType
= ((SwXDocumentIndexMark
*)this)->GetTOXType();
1769 const SfxItemPropertySimpleEntry
* pEntry
= m_pPropSet
->getPropertyMap()->getByName(rPropertyName
);
1771 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
1772 if(SwXParagraph::getDefaultTextContentValue(aRet
, rPropertyName
, pEntry
->nWID
))
1774 if(pType
&& m_pTOXMark
)
1776 switch(pEntry
->nWID
)
1779 aRet
<<= OUString(m_pTOXMark
->GetAlternativeText());
1782 aRet
<<= (sal_Int16
)(m_pTOXMark
->GetLevel() - 1);
1784 case WID_PRIMARY_KEY
:
1785 aRet
<<= OUString(m_pTOXMark
->GetPrimaryKey());
1787 case WID_SECONDARY_KEY
:
1788 aRet
<<= OUString(m_pTOXMark
->GetSecondaryKey());
1790 case WID_TEXT_READING
:
1791 aRet
<<= OUString(m_pTOXMark
->GetTextReading());
1793 case WID_PRIMARY_KEY_READING
:
1794 aRet
<<= OUString(m_pTOXMark
->GetPrimaryKeyReading());
1796 case WID_SECONDARY_KEY_READING
:
1797 aRet
<<= OUString(m_pTOXMark
->GetSecondaryKeyReading());
1799 case WID_USER_IDX_NAME
:
1801 OUString
sTmp(pType
->GetTypeName());
1802 lcl_ConvertTOUNameToProgrammaticName(sTmp
);
1806 case WID_MAIN_ENTRY
:
1808 sal_Bool bTemp
= m_pTOXMark
->IsMainEntry();
1809 aRet
.setValue(&bTemp
, ::getBooleanCppuType());
1814 else if(bIsDescriptor
)
1816 switch(pEntry
->nWID
)
1819 aRet
<<= OUString(sAltText
);
1822 aRet
<<= (sal_Int16
)nLevel
;
1824 case WID_PRIMARY_KEY
:
1825 aRet
<<= OUString(sPrimaryKey
);
1827 case WID_SECONDARY_KEY
:
1828 aRet
<<= OUString(sSecondaryKey
);
1830 case WID_TEXT_READING
:
1831 aRet
<<= OUString(sTextReading
);
1833 case WID_PRIMARY_KEY_READING
:
1834 aRet
<<= OUString(sPrimaryKeyReading
);
1836 case WID_SECONDARY_KEY_READING
:
1837 aRet
<<= OUString(sSecondaryKeyReading
);
1839 case WID_USER_IDX_NAME
:
1840 aRet
<<= OUString(sUserIndexName
);
1842 case WID_MAIN_ENTRY
:
1844 aRet
.setValue(&bMainEntry
, ::getBooleanCppuType());
1850 throw uno::RuntimeException();
1853 /*-- 14.12.98 10:25:46---------------------------------------------------
1855 -----------------------------------------------------------------------*/
1856 void SwXDocumentIndexMark::addPropertyChangeListener(const OUString
& /*PropertyName*/, const uno::Reference
< beans::XPropertyChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
1858 DBG_WARNING("not implemented");
1860 /*-- 14.12.98 10:25:46---------------------------------------------------
1862 -----------------------------------------------------------------------*/
1863 void SwXDocumentIndexMark::removePropertyChangeListener(const OUString
& /*PropertyName*/, const uno::Reference
< beans::XPropertyChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
1865 DBG_WARNING("not implemented");
1867 /*-- 14.12.98 10:25:47---------------------------------------------------
1869 -----------------------------------------------------------------------*/
1870 void SwXDocumentIndexMark::addVetoableChangeListener(const OUString
& /*PropertyName*/, const uno::Reference
< beans::XVetoableChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
1872 DBG_WARNING("not implemented");
1874 /*-- 14.12.98 10:25:47---------------------------------------------------
1876 -----------------------------------------------------------------------*/
1877 void SwXDocumentIndexMark::removeVetoableChangeListener(const OUString
& /*PropertyName*/, const uno::Reference
< beans::XVetoableChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
1879 DBG_WARNING("not implemented");
1881 /*-- 14.12.98 10:25:47---------------------------------------------------
1883 -----------------------------------------------------------------------*/
1884 SwXDocumentIndexMark
* SwXDocumentIndexMark::GetObject(SwTOXType
* pType
,
1885 const SwTOXMark
* pMark
, SwDoc
* pDoc
)
1887 SwClientIter
aIter(*pType
);
1888 SwXDocumentIndexMark
* pxMark
= (SwXDocumentIndexMark
*)
1889 aIter
.First(TYPE(SwXDocumentIndexMark
));
1892 if(pxMark
->m_pTOXMark
== pMark
)
1894 pxMark
= (SwXDocumentIndexMark
*)aIter
.Next();
1896 return new SwXDocumentIndexMark(pType
, pMark
, pDoc
);
1898 /*-- 14.12.98 10:25:47---------------------------------------------------
1900 -----------------------------------------------------------------------*/
1901 void SwXDocumentIndexMark::Modify( SfxPoolItem
*pOld
, SfxPoolItem
*pNew
)
1903 switch( pOld
? pOld
->Which() : 0 )
1905 case RES_REMOVE_UNO_OBJECT
:
1906 case RES_OBJECTDYING
:
1907 if( (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem
*)pOld
)->pObject
)
1912 // wurden wir an das neue umgehaengt und wird das alte geloscht?
1913 if( ((SwFmtChg
*)pNew
)->pChangedFmt
== GetRegisteredIn() &&
1914 ((SwFmtChg
*)pOld
)->pChangedFmt
->IsFmtInDTOR() )
1917 case RES_TOXMARK_DELETED
:
1918 if( (void*)m_pTOXMark
== ((SwPtrMsgPoolItem
*)pOld
)->pObject
)
1923 /* -----------------------------16.10.00 11:24--------------------------------
1925 ---------------------------------------------------------------------------*/
1926 void SwXDocumentIndexMark::Invalidate()
1928 if(GetRegisteredIn())
1930 ((SwModify
*)GetRegisteredIn())->Remove(this);
1931 if(aTypeDepend
.GetRegisteredIn())
1932 ((SwModify
*)aTypeDepend
.GetRegisteredIn())->Remove(&aTypeDepend
);
1933 aLstnrCntnr
.Disposing();
1938 /* -----------------------------06.04.00 15:08--------------------------------
1940 ---------------------------------------------------------------------------*/
1941 OUString
SwXDocumentIndexes::getImplementationName(void) throw( uno::RuntimeException
)
1943 return C2U("SwXDocumentIndexes");
1945 /* -----------------------------06.04.00 15:08--------------------------------
1947 ---------------------------------------------------------------------------*/
1948 BOOL
SwXDocumentIndexes::supportsService(const OUString
& rServiceName
) throw( uno::RuntimeException
)
1950 return C2U("com.sun.star.text.DocumentIndexes") == rServiceName
;
1952 /* -----------------------------06.04.00 15:08--------------------------------
1954 ---------------------------------------------------------------------------*/
1955 uno::Sequence
< OUString
> SwXDocumentIndexes::getSupportedServiceNames(void) throw( uno::RuntimeException
)
1957 uno::Sequence
< OUString
> aRet(1);
1958 OUString
* pArray
= aRet
.getArray();
1959 pArray
[0] = C2U("com.sun.star.text.DocumentIndexes");
1962 /*-- 05.05.99 13:14:59---------------------------------------------------
1964 -----------------------------------------------------------------------*/
1965 SwXDocumentIndexes::SwXDocumentIndexes(SwDoc
* _pDoc
) :
1966 SwUnoCollection(_pDoc
)
1969 /*-- 05.05.99 13:15:00---------------------------------------------------
1971 -----------------------------------------------------------------------*/
1972 SwXDocumentIndexes::~SwXDocumentIndexes()
1975 /*-- 05.05.99 13:15:01---------------------------------------------------
1977 -----------------------------------------------------------------------*/
1978 sal_Int32
SwXDocumentIndexes::getCount(void) throw( uno::RuntimeException
)
1980 vos::OGuard
aGuard(Application::GetSolarMutex());
1982 throw uno::RuntimeException();
1984 sal_uInt32 nRet
= 0;
1985 const SwSectionFmts
& rFmts
= GetDoc()->GetSections();
1986 for( sal_uInt16 n
= 0; n
< rFmts
.Count(); ++n
)
1988 const SwSection
* pSect
= rFmts
[ n
]->GetSection();
1989 if( TOX_CONTENT_SECTION
== pSect
->GetType() &&
1990 pSect
->GetFmt()->GetSectionNode() )
1995 /*-- 05.05.99 13:15:01---------------------------------------------------
1997 -----------------------------------------------------------------------*/
1998 uno::Any
SwXDocumentIndexes::getByIndex(sal_Int32 nIndex
)
1999 throw( lang::IndexOutOfBoundsException
, lang::WrappedTargetException
, uno::RuntimeException
)
2001 vos::OGuard
aGuard(Application::GetSolarMutex());
2003 throw uno::RuntimeException();
2008 const SwSectionFmts
& rFmts
= GetDoc()->GetSections();
2009 for( sal_uInt16 n
= 0; n
< rFmts
.Count(); ++n
)
2011 const SwSection
* pSect
= rFmts
[ n
]->GetSection();
2012 if( TOX_CONTENT_SECTION
== pSect
->GetType() &&
2013 pSect
->GetFmt()->GetSectionNode() &&
2016 uno::Reference
< text::XDocumentIndex
> xTmp
= new SwXDocumentIndex(
2017 (SwTOXBaseSection
*)pSect
, GetDoc() );
2018 aRet
.setValue(&xTmp
, ::getCppuType((uno::Reference
<text::XDocumentIndex
>*)0));
2023 throw lang::IndexOutOfBoundsException();
2026 /*-- 31.01.00 10:12:31---------------------------------------------------
2028 -----------------------------------------------------------------------*/
2029 uno::Any
SwXDocumentIndexes::getByName(const OUString
& rName
)
2030 throw( container::NoSuchElementException
, lang::WrappedTargetException
, uno::RuntimeException
)
2032 vos::OGuard
aGuard(Application::GetSolarMutex());
2034 throw uno::RuntimeException();
2038 String
sToFind(rName
);
2039 const SwSectionFmts
& rFmts
= GetDoc()->GetSections();
2040 for( sal_uInt16 n
= 0; n
< rFmts
.Count(); ++n
)
2042 const SwSection
* pSect
= rFmts
[ n
]->GetSection();
2043 if( TOX_CONTENT_SECTION
== pSect
->GetType() &&
2044 pSect
->GetFmt()->GetSectionNode() &&
2045 ((SwTOXBaseSection
*)pSect
)->GetTOXName() == sToFind
)
2047 uno::Reference
< text::XDocumentIndex
> xTmp
= new SwXDocumentIndex(
2048 (SwTOXBaseSection
*)pSect
, GetDoc() );
2049 aRet
.setValue(&xTmp
, ::getCppuType((uno::Reference
<text::XDocumentIndex
>*)0));
2053 throw container::NoSuchElementException();
2055 /*-- 31.01.00 10:12:31---------------------------------------------------
2057 -----------------------------------------------------------------------*/
2058 uno::Sequence
< OUString
> SwXDocumentIndexes::getElementNames(void)
2059 throw( uno::RuntimeException
)
2061 vos::OGuard
aGuard(Application::GetSolarMutex());
2063 throw uno::RuntimeException();
2065 const SwSectionFmts
& rFmts
= GetDoc()->GetSections();
2066 sal_Int32 nCount
= 0;
2068 for( n
= 0; n
< rFmts
.Count(); ++n
)
2070 const SwSection
* pSect
= rFmts
[ n
]->GetSection();
2071 if( TOX_CONTENT_SECTION
== pSect
->GetType() &&
2072 pSect
->GetFmt()->GetSectionNode() )
2076 uno::Sequence
< OUString
> aRet(nCount
);
2077 OUString
* pArray
= aRet
.getArray();
2079 for( n
= 0, nCnt
= 0; n
< rFmts
.Count(); ++n
)
2081 const SwSection
* pSect
= rFmts
[ n
]->GetSection();
2082 if( TOX_CONTENT_SECTION
== pSect
->GetType() &&
2083 pSect
->GetFmt()->GetSectionNode())
2085 pArray
[nCnt
++] = OUString(((SwTOXBaseSection
*)pSect
)->GetTOXName());
2090 /*-- 31.01.00 10:12:31---------------------------------------------------
2092 -----------------------------------------------------------------------*/
2093 sal_Bool
SwXDocumentIndexes::hasByName(const OUString
& rName
)
2094 throw( uno::RuntimeException
)
2096 vos::OGuard
aGuard(Application::GetSolarMutex());
2098 throw uno::RuntimeException();
2100 String
sToFind(rName
);
2101 const SwSectionFmts
& rFmts
= GetDoc()->GetSections();
2102 for( sal_uInt16 n
= 0; n
< rFmts
.Count(); ++n
)
2104 const SwSection
* pSect
= rFmts
[ n
]->GetSection();
2105 if( TOX_CONTENT_SECTION
== pSect
->GetType() &&
2106 pSect
->GetFmt()->GetSectionNode())
2108 if(((SwTOXBaseSection
*)pSect
)->GetTOXName() == sToFind
)
2114 /*-- 05.05.99 13:15:01---------------------------------------------------
2116 -----------------------------------------------------------------------*/
2117 uno::Type
SwXDocumentIndexes::getElementType(void) throw( uno::RuntimeException
)
2119 return ::getCppuType((uno::Reference
< text::XDocumentIndex
> *)0);
2121 /*-- 05.05.99 13:15:02---------------------------------------------------
2123 -----------------------------------------------------------------------*/
2124 sal_Bool
SwXDocumentIndexes::hasElements(void) throw( uno::RuntimeException
)
2126 vos::OGuard
aGuard(Application::GetSolarMutex());
2128 throw uno::RuntimeException();
2129 return 0 != getCount();
2132 SwXDocumentIndex
* SwXDocumentIndexes::GetObject(const SwTOXBaseSection
* pTOX
)
2134 SwSectionFmt
* pFmt
= pTOX
->GetFmt();
2135 SwClientIter
aIter(*pFmt
);
2136 SwXDocumentIndex
* pxIdx
= (SwXDocumentIndex
*)aIter
.First(TYPE(SwXDocumentIndex
));
2140 return new SwXDocumentIndex(pTOX
, pFmt
->GetDoc());
2143 /* -----------------------------06.04.00 15:08--------------------------------
2145 ---------------------------------------------------------------------------*/
2146 OUString
SwXIndexStyleAccess_Impl::getImplementationName(void) throw( uno::RuntimeException
)
2148 return C2U("SwXIndexStyleAccess_Impl");
2150 /* -----------------------------06.04.00 15:08--------------------------------
2152 ---------------------------------------------------------------------------*/
2153 BOOL
SwXIndexStyleAccess_Impl::supportsService(const OUString
& rServiceName
) throw( uno::RuntimeException
)
2155 return C2U("com.sun.star.text.DocumentIndexParagraphStyles") == rServiceName
;
2157 /* -----------------------------06.04.00 15:08--------------------------------
2159 ---------------------------------------------------------------------------*/
2160 uno::Sequence
< OUString
> SwXIndexStyleAccess_Impl::getSupportedServiceNames(void) throw( uno::RuntimeException
)
2162 uno::Sequence
< OUString
> aRet(1);
2163 OUString
* pArray
= aRet
.getArray();
2164 pArray
[0] = C2U("com.sun.star.text.DocumentIndexParagraphStyles");
2167 /*-- 13.09.99 16:52:28---------------------------------------------------
2169 -----------------------------------------------------------------------*/
2170 SwXIndexStyleAccess_Impl::SwXIndexStyleAccess_Impl(SwXDocumentIndex
& rParentIdx
) :
2171 rParent(rParentIdx
),
2172 xParent(&rParentIdx
)
2174 vos::OGuard
aGuard(Application::GetSolarMutex());
2175 rParent
.SetStyleAccess(this);
2177 /*-- 13.09.99 16:52:29---------------------------------------------------
2179 -----------------------------------------------------------------------*/
2180 SwXIndexStyleAccess_Impl::~SwXIndexStyleAccess_Impl()
2182 vos::OGuard
aGuard(Application::GetSolarMutex());
2183 rParent
.SetStyleAccess(0);
2185 /*-- 13.09.99 16:52:29---------------------------------------------------
2187 -----------------------------------------------------------------------*/
2188 void SwXIndexStyleAccess_Impl::replaceByIndex(sal_Int32 nIndex
, const uno::Any
& rElement
)
2189 throw( lang::IllegalArgumentException
, lang::IndexOutOfBoundsException
,
2190 lang::WrappedTargetException
, uno::RuntimeException
)
2192 vos::OGuard
aGuard(Application::GetSolarMutex());
2193 const sal_Bool bDescriptor
= rParent
.IsDescriptor();
2194 SwSectionFmt
* pSectFmt
= rParent
.GetFmt();
2195 if(!pSectFmt
&& !bDescriptor
)
2196 throw uno::RuntimeException();
2197 if(nIndex
< 0 || nIndex
> MAXLEVEL
)
2198 throw lang::IndexOutOfBoundsException();
2199 SwTOXBase
* pTOXBase
= bDescriptor
? &rParent
.GetProperties_Impl()->GetTOXBase() :
2200 (SwTOXBaseSection
*)pSectFmt
->GetSection();
2202 uno::Sequence
<OUString
> aSeq
;
2203 if(!(rElement
>>= aSeq
))
2204 throw lang::IllegalArgumentException();
2206 sal_Int32 nStyles
= aSeq
.getLength();
2207 const OUString
* pStyles
= aSeq
.getConstArray();
2210 for(sal_Int32 i
= 0; i
< nStyles
; i
++)
2213 sSetStyles
+= TOX_STYLE_DELIMITER
;
2214 SwStyleNameMapper::FillUIName(pStyles
[i
], aString
, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL
, sal_True
);
2215 sSetStyles
+= aString
;
2217 pTOXBase
->SetStyleNames(sSetStyles
, (sal_uInt16
) nIndex
);
2219 /*-- 13.09.99 16:52:29---------------------------------------------------
2221 -----------------------------------------------------------------------*/
2222 sal_Int32
SwXIndexStyleAccess_Impl::getCount(void) throw( uno::RuntimeException
)
2226 /*-- 13.09.99 16:52:30---------------------------------------------------
2228 -----------------------------------------------------------------------*/
2229 uno::Any
SwXIndexStyleAccess_Impl::getByIndex(sal_Int32 nIndex
)
2230 throw( lang::IndexOutOfBoundsException
, lang::WrappedTargetException
,
2231 uno::RuntimeException
)
2233 vos::OGuard
aGuard(Application::GetSolarMutex());
2234 const sal_Bool bDescriptor
= rParent
.IsDescriptor();
2235 SwSectionFmt
* pSectFmt
= rParent
.GetFmt();
2236 if(!pSectFmt
&& !bDescriptor
)
2237 throw uno::RuntimeException();
2238 if(nIndex
< 0 || nIndex
> MAXLEVEL
)
2239 throw lang::IndexOutOfBoundsException();
2240 SwTOXBase
* pTOXBase
= bDescriptor
? &rParent
.GetProperties_Impl()->GetTOXBase() :
2241 (SwTOXBaseSection
*)pSectFmt
->GetSection();
2243 const String
& rStyles
= pTOXBase
->GetStyleNames((sal_uInt16
) nIndex
);
2244 sal_uInt16 nStyles
= rStyles
.GetTokenCount(TOX_STYLE_DELIMITER
);
2245 uno::Sequence
<OUString
> aStyles(nStyles
);
2246 OUString
* pStyles
= aStyles
.getArray();
2248 for(sal_uInt16 i
= 0; i
< nStyles
; i
++)
2250 SwStyleNameMapper::FillProgName(
2251 rStyles
.GetToken(i
, TOX_STYLE_DELIMITER
),
2253 nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL
,
2255 pStyles
[i
] = OUString( aString
);
2257 uno::Any
aRet(&aStyles
, ::getCppuType((uno::Sequence
<OUString
>*)0));
2260 /*-- 13.09.99 16:52:30---------------------------------------------------
2262 -----------------------------------------------------------------------*/
2263 uno::Type
SwXIndexStyleAccess_Impl::getElementType(void)
2264 throw( uno::RuntimeException
)
2266 return ::getCppuType((uno::Sequence
<OUString
>*)0);
2268 /*-- 13.09.99 16:52:30---------------------------------------------------
2270 -----------------------------------------------------------------------*/
2271 sal_Bool
SwXIndexStyleAccess_Impl::hasElements(void) throw( uno::RuntimeException
)
2276 /* -----------------13.09.99 16:51-------------------
2278 --------------------------------------------------*/
2279 /* -----------------------------06.04.00 15:08--------------------------------
2281 ---------------------------------------------------------------------------*/
2282 OUString
SwXIndexTokenAccess_Impl::getImplementationName(void) throw( uno::RuntimeException
)
2284 return C2U("SwXIndexTokenAccess_Impl");
2286 /* -----------------------------06.04.00 15:08--------------------------------
2288 ---------------------------------------------------------------------------*/
2289 BOOL
SwXIndexTokenAccess_Impl::supportsService(const OUString
& rServiceName
) throw( uno::RuntimeException
)
2291 return C2U("com.sun.star.text.DocumentIndexLevelFormat") == rServiceName
;
2293 /* -----------------------------06.04.00 15:08--------------------------------
2295 ---------------------------------------------------------------------------*/
2296 uno::Sequence
< OUString
> SwXIndexTokenAccess_Impl::getSupportedServiceNames(void) throw( uno::RuntimeException
)
2298 uno::Sequence
< OUString
> aRet(1);
2299 OUString
* pArray
= aRet
.getArray();
2300 pArray
[0] = C2U("com.sun.star.text.DocumentIndexLevelFormat");
2303 /*-- 13.09.99 16:52:28---------------------------------------------------
2305 -----------------------------------------------------------------------*/
2306 SwXIndexTokenAccess_Impl::SwXIndexTokenAccess_Impl(SwXDocumentIndex
& rParentIdx
) :
2307 rParent(rParentIdx
),
2308 xParent(&rParentIdx
),
2309 nCount(SwForm::GetFormMaxLevel(rParent
.GetTOXType()))
2311 vos::OGuard
aGuard(Application::GetSolarMutex());
2312 rParent
.SetTokenAccess(this);
2314 /*-- 13.09.99 16:52:29---------------------------------------------------
2316 -----------------------------------------------------------------------*/
2317 SwXIndexTokenAccess_Impl::~SwXIndexTokenAccess_Impl()
2319 vos::OGuard
aGuard(Application::GetSolarMutex());
2320 rParent
.SetTokenAccess(0);
2322 /*-- 13.09.99 16:52:29---------------------------------------------------
2324 -----------------------------------------------------------------------*/
2325 void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex
, const uno::Any
& rElement
)
2326 throw( lang::IllegalArgumentException
, lang::IndexOutOfBoundsException
,
2327 lang::WrappedTargetException
, uno::RuntimeException
)
2329 vos::OGuard
aGuard(Application::GetSolarMutex());
2330 const sal_Bool bDescriptor
= rParent
.IsDescriptor();
2331 SwSectionFmt
* pSectFmt
= rParent
.GetFmt();
2332 if(!pSectFmt
&& !bDescriptor
)
2333 throw uno::RuntimeException();
2335 SwTOXBase
* pTOXBase
= bDescriptor
? &rParent
.GetProperties_Impl()->GetTOXBase() :
2336 (SwTOXBaseSection
*)pSectFmt
->GetSection();
2338 (nIndex
> pTOXBase
->GetTOXForm().GetFormMax()))
2339 throw lang::IndexOutOfBoundsException();
2341 uno::Sequence
<beans::PropertyValues
> aSeq
;
2342 if(!(rElement
>>= aSeq
))
2343 throw lang::IllegalArgumentException();
2346 sal_Int32 nTokens
= aSeq
.getLength();
2347 const beans::PropertyValues
* pTokens
= aSeq
.getConstArray();
2348 for(sal_Int32 i
= 0; i
< nTokens
; i
++)
2350 const beans::PropertyValue
* pProperties
= pTokens
[i
].getConstArray();
2351 sal_Int32 nProperties
= pTokens
[i
].getLength();
2352 //create an invalid token
2353 SwFormToken
aToken(TOKEN_END
);
2354 for(sal_Int32 j
= 0; j
< nProperties
; j
++)
2356 if( COMPARE_EQUAL
== pProperties
[j
].Name
.compareToAscii("TokenType"))
2358 const String sTokenType
=
2359 lcl_AnyToString(pProperties
[j
].Value
);
2360 if(sTokenType
.EqualsAscii("TokenEntryNumber"))
2361 aToken
.eTokenType
= TOKEN_ENTRY_NO
;
2362 else if(sTokenType
.EqualsAscii("TokenEntryText" ))
2363 aToken
.eTokenType
= TOKEN_ENTRY_TEXT
;
2364 else if(sTokenType
.EqualsAscii("TokenTabStop" ))
2365 aToken
.eTokenType
= TOKEN_TAB_STOP
;
2366 else if(sTokenType
.EqualsAscii("TokenText" ))
2367 aToken
.eTokenType
= TOKEN_TEXT
;
2368 else if(sTokenType
.EqualsAscii("TokenPageNumber"))
2369 aToken
.eTokenType
= TOKEN_PAGE_NUMS
;
2370 else if(sTokenType
.EqualsAscii("TokenChapterInfo" ))
2371 aToken
.eTokenType
= TOKEN_CHAPTER_INFO
;
2372 else if(sTokenType
.EqualsAscii("TokenHyperlinkStart" ))
2373 aToken
.eTokenType
= TOKEN_LINK_START
;
2374 else if(sTokenType
.EqualsAscii("TokenHyperlinkEnd"))
2375 aToken
.eTokenType
= TOKEN_LINK_END
;
2376 else if(sTokenType
.EqualsAscii("TokenBibliographyDataField" ))
2377 aToken
.eTokenType
= TOKEN_AUTHORITY
;
2379 else if( pProperties
[j
].Name
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("CharacterStyleName" ) ))
2381 String sCharStyleName
;
2382 SwStyleNameMapper::FillUIName(
2383 lcl_AnyToString(pProperties
[j
].Value
),
2385 nsSwGetPoolIdFromName::GET_POOLID_CHRFMT
,
2387 aToken
.sCharStyleName
= sCharStyleName
;
2388 aToken
.nPoolId
= SwStyleNameMapper::GetPoolIdFromUIName (
2389 sCharStyleName
, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT
);
2391 else if( pProperties
[j
].Name
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("TabStopRightAligned") ))
2393 sal_Bool bRight
= lcl_AnyToBool(pProperties
[j
].Value
);
2394 aToken
.eTabAlign
= bRight
?
2395 SVX_TAB_ADJUST_END
: SVX_TAB_ADJUST_LEFT
;
2397 else if( pProperties
[j
].Name
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("TabStopPosition" )))
2399 sal_Int32 nPosition
= 0;
2400 if(pProperties
[j
].Value
.getValueType() != ::getCppuType((sal_Int32
*)0))
2401 throw lang::IllegalArgumentException();
2402 pProperties
[j
].Value
>>= nPosition
;
2403 nPosition
= MM100_TO_TWIP(nPosition
);
2405 throw lang::IllegalArgumentException();
2406 aToken
.nTabStopPosition
= nPosition
;
2408 else if( pProperties
[j
].Name
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("TabStopFillCharacter" )))
2410 const String sFillChar
=
2411 lcl_AnyToString(pProperties
[j
].Value
);
2412 if(sFillChar
.Len() > 1)
2413 throw lang::IllegalArgumentException();
2414 aToken
.cTabFillChar
= sFillChar
.Len() ?
2415 sFillChar
.GetChar(0) : ' ';
2417 else if( pProperties
[j
].Name
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Text" )))
2419 const String sText
=
2420 lcl_AnyToString(pProperties
[j
].Value
);
2421 aToken
.sText
= sText
;
2423 else if( pProperties
[j
].Name
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ChapterFormat" )))
2425 sal_Int16 nFormat
= lcl_AnyToInt16(pProperties
[j
].Value
);
2428 case text::ChapterFormat::NUMBER
: nFormat
= CF_NUMBER
;
2430 case text::ChapterFormat::NAME
: nFormat
= CF_TITLE
;
2432 case text::ChapterFormat::NAME_NUMBER
: nFormat
= CF_NUM_TITLE
;
2434 case text::ChapterFormat::NO_PREFIX_SUFFIX
:nFormat
= CF_NUMBER_NOPREPST
;
2436 case text::ChapterFormat::DIGIT
: nFormat
= CF_NUM_NOPREPST_TITLE
;
2439 throw lang::IllegalArgumentException();
2441 aToken
.nChapterFormat
= nFormat
;
2444 else if( pProperties
[j
].Name
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ChapterLevel")) )
2446 const sal_Int16 nLevel
= lcl_AnyToInt16(pProperties
[j
].Value
);
2447 if( nLevel
< 1 || nLevel
> MAXLEVEL
)
2448 throw lang::IllegalArgumentException();
2449 aToken
.nOutlineLevel
= nLevel
;
2452 else if( pProperties
[j
].Name
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("BibliographyDataField")))
2454 sal_Int16 nType
= 0;
2455 pProperties
[j
].Value
>>= nType
;
2456 if(nType
< 0 || nType
> text::BibliographyDataField::ISBN
)
2458 lang::IllegalArgumentException aExcept
;
2459 aExcept
.Message
= C2U("BibliographyDataField - wrong value");
2460 aExcept
.ArgumentPosition
= static_cast< sal_Int16
>(j
);
2463 aToken
.nAuthorityField
= nType
;
2466 else if ( pProperties
[j
].Name
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("WithTab")))
2468 aToken
.bWithTab
= lcl_AnyToBool(pProperties
[j
].Value
);
2472 //exception if wrong TokenType
2473 if(TOKEN_END
<= aToken
.eTokenType
)
2474 throw lang::IllegalArgumentException();
2475 // set TokenType from TOKEN_ENTRY_TEXT to TOKEN_ENTRY if it is
2476 // not a content index
2477 if(TOKEN_ENTRY_TEXT
== aToken
.eTokenType
&&
2478 TOX_CONTENT
!= pTOXBase
->GetType())
2479 aToken
.eTokenType
= TOKEN_ENTRY
;
2481 // check for chapter format allowed values if it was TOKEN_ENTRY_NO type
2482 // only allowed value are CF_NUMBER and CF_NUM_NOPREPST_TITLE
2483 // reading from file
2484 if( TOKEN_ENTRY_NO
== aToken
.eTokenType
)
2485 switch(aToken
.nChapterFormat
)
2488 case CF_NUM_NOPREPST_TITLE
:
2491 throw lang::IllegalArgumentException();
2494 sPattern
+= aToken
.GetString();
2496 SwForm
aForm(pTOXBase
->GetTOXForm());
2497 aForm
.SetPattern((sal_uInt16
) nIndex
, sPattern
);
2498 pTOXBase
->SetTOXForm(aForm
);
2500 /*-- 13.09.99 16:52:29---------------------------------------------------
2502 -----------------------------------------------------------------------*/
2503 sal_Int32
SwXIndexTokenAccess_Impl::getCount(void) throw( uno::RuntimeException
)
2505 vos::OGuard
aGuard(Application::GetSolarMutex());
2506 const sal_Bool bDescriptor
= rParent
.IsDescriptor();
2507 SwSectionFmt
* pSectFmt
= rParent
.GetFmt();
2508 if(!pSectFmt
&& !bDescriptor
)
2509 throw uno::RuntimeException();
2510 sal_Int32 nRet
= bDescriptor
?
2512 ((SwTOXBaseSection
*)pSectFmt
->GetSection())->
2513 GetTOXForm().GetFormMax();
2516 /*-- 13.09.99 16:52:30---------------------------------------------------
2518 -----------------------------------------------------------------------*/
2519 uno::Any
SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex
)
2520 throw( lang::IndexOutOfBoundsException
, lang::WrappedTargetException
,
2521 uno::RuntimeException
)
2523 vos::OGuard
aGuard(Application::GetSolarMutex());
2524 const sal_Bool bDescriptor
= rParent
.IsDescriptor();
2525 SwSectionFmt
* pSectFmt
= rParent
.GetFmt();
2526 if(!pSectFmt
&& !bDescriptor
)
2527 throw uno::RuntimeException();
2528 SwTOXBase
* pTOXBase
= bDescriptor
? &rParent
.GetProperties_Impl()->GetTOXBase() :
2529 (SwTOXBaseSection
*)pSectFmt
->GetSection();
2531 (nIndex
> pTOXBase
->GetTOXForm().GetFormMax()))
2532 throw lang::IndexOutOfBoundsException();
2535 SwFormTokens aPattern
= pTOXBase
->GetTOXForm().
2536 GetPattern((sal_uInt16
) nIndex
);
2537 SwFormTokens::iterator aIt
= aPattern
.begin();
2539 sal_uInt16 nTokenCount
= 0;
2540 uno::Sequence
< beans::PropertyValues
> aRetSeq
;
2542 while(aIt
!= aPattern
.end()) // #i21237#
2545 aRetSeq
.realloc(nTokenCount
);
2546 beans::PropertyValues
* pTokenProps
= aRetSeq
.getArray();
2547 SwFormToken aToken
= *aIt
; // #i21237#
2549 uno::Sequence
< beans::PropertyValue
>& rCurTokenSeq
= pTokenProps
[nTokenCount
-1];
2550 SwStyleNameMapper::FillProgName(
2551 aToken
.sCharStyleName
,
2553 nsSwGetPoolIdFromName::GET_POOLID_CHRFMT
,
2555 const OUString
aProgCharStyle( aString
);
2556 switch(aToken
.eTokenType
)
2558 case TOKEN_ENTRY_NO
:
2561 // writing to file (from doc to properties)
2562 sal_Int32 nElements
= 2;
2563 sal_Int32 nCurrentElement
= 0;
2565 if( aToken
.nChapterFormat
!= CF_NUMBER
)//check for default value
2566 nElements
++;//we need the element
2567 if( aToken
.nOutlineLevel
!= MAXLEVEL
)
2570 rCurTokenSeq
.realloc( nElements
);
2572 beans::PropertyValue
* pArr
= rCurTokenSeq
.getArray();
2574 pArr
[nCurrentElement
].Name
= C2U("TokenType");
2575 pArr
[nCurrentElement
++].Value
<<= OUString::createFromAscii("TokenEntryNumber");
2576 // pArr[0].Value <<= C2U("TokenEntryNumber");
2578 pArr
[nCurrentElement
].Name
= C2U("CharacterStyleName");
2579 pArr
[nCurrentElement
++].Value
<<= aProgCharStyle
;
2580 if( aToken
.nChapterFormat
!= CF_NUMBER
)
2582 pArr
[nCurrentElement
].Name
= C2U("ChapterFormat");
2584 //! the allowed values for chapter format, when used as entry number, are CF_NUMBER and CF_NUM_NOPREPST_TITLE only, all else forced to
2586 switch(aToken
.nChapterFormat
)
2589 case CF_NUMBER
: nVal
= text::ChapterFormat::NUMBER
; break;
2590 case CF_NUM_NOPREPST_TITLE
: nVal
= text::ChapterFormat::DIGIT
; break;
2592 pArr
[nCurrentElement
++].Value
<<= (sal_Int16
)nVal
;
2595 if( aToken
.nOutlineLevel
!= MAXLEVEL
) //only a ChapterLevel != MAXLEVEL is registered
2597 pArr
[nCurrentElement
].Name
= C2U("ChapterLevel");
2598 pArr
[nCurrentElement
].Value
<<= aToken
.nOutlineLevel
;
2603 case TOKEN_ENTRY
: // no difference between Entry and Entry Text
2604 case TOKEN_ENTRY_TEXT
:
2606 rCurTokenSeq
.realloc( 2 );
2607 beans::PropertyValue
* pArr
= rCurTokenSeq
.getArray();
2609 pArr
[0].Name
= C2U("TokenType");
2610 pArr
[0].Value
<<= OUString::createFromAscii("TokenEntryText");
2612 pArr
[1].Name
= C2U("CharacterStyleName");
2613 pArr
[1].Value
<<= aProgCharStyle
;
2616 case TOKEN_TAB_STOP
:
2618 rCurTokenSeq
.realloc(5); // #i21237#
2619 beans::PropertyValue
* pArr
= rCurTokenSeq
.getArray();
2621 pArr
[0].Name
= C2U("TokenType");
2622 pArr
[0].Value
<<= OUString::createFromAscii("TokenTabStop");
2625 if(SVX_TAB_ADJUST_END
== aToken
.eTabAlign
)
2627 pArr
[1].Name
= C2U("TabStopRightAligned");
2628 BOOL bTemp
= sal_True
;
2629 pArr
[1].Value
.setValue(&bTemp
, ::getCppuBooleanType());
2633 pArr
[1].Name
= C2U("TabStopPosition");
2634 sal_Int32 nPos
= (TWIP_TO_MM100(aToken
.nTabStopPosition
));
2637 pArr
[1].Value
<<= (sal_Int32
)nPos
;
2639 pArr
[2].Name
= C2U("TabStopFillCharacter");
2640 pArr
[2].Value
<<= OUString(aToken
.cTabFillChar
);
2641 pArr
[3].Name
= C2U("CharacterStyleName");
2642 pArr
[3].Value
<<= aProgCharStyle
;
2644 pArr
[4].Name
= C2U("WithTab");
2645 pArr
[4].Value
.setValue(&aToken
.bWithTab
, ::getCppuBooleanType());
2650 rCurTokenSeq
.realloc( 3 );
2651 beans::PropertyValue
* pArr
= rCurTokenSeq
.getArray();
2653 pArr
[0].Name
= C2U("TokenType");
2654 pArr
[0].Value
<<= OUString::createFromAscii("TokenText");
2656 pArr
[1].Name
= C2U("CharacterStyleName");
2657 pArr
[1].Value
<<= aProgCharStyle
;
2659 pArr
[2].Name
= C2U("Text");
2660 pArr
[2].Value
<<= OUString(aToken
.sText
);
2663 case TOKEN_PAGE_NUMS
:
2665 rCurTokenSeq
.realloc( 2 );
2666 beans::PropertyValue
* pArr
= rCurTokenSeq
.getArray();
2668 pArr
[0].Name
= C2U("TokenType");
2669 pArr
[0].Value
<<= OUString::createFromAscii("TokenPageNumber");
2671 pArr
[1].Name
= C2U("CharacterStyleName");
2672 pArr
[1].Value
<<= aProgCharStyle
;
2675 case TOKEN_CHAPTER_INFO
:
2677 rCurTokenSeq
.realloc( 4 );
2678 beans::PropertyValue
* pArr
= rCurTokenSeq
.getArray();
2680 pArr
[0].Name
= C2U("TokenType");
2681 pArr
[0].Value
<<= OUString::createFromAscii("TokenChapterInfo");
2683 pArr
[1].Name
= C2U("CharacterStyleName");
2684 pArr
[1].Value
<<= aProgCharStyle
;
2686 pArr
[2].Name
= C2U("ChapterFormat");
2687 sal_Int16 nVal
= text::ChapterFormat::NUMBER
;
2688 switch(aToken
.nChapterFormat
)
2690 case CF_NUMBER
: nVal
= text::ChapterFormat::NUMBER
; break;
2691 case CF_TITLE
: nVal
= text::ChapterFormat::NAME
; break;
2692 case CF_NUM_TITLE
: nVal
= text::ChapterFormat::NAME_NUMBER
; break;
2693 case CF_NUMBER_NOPREPST
: nVal
= text::ChapterFormat::NO_PREFIX_SUFFIX
; break;
2694 case CF_NUM_NOPREPST_TITLE
: nVal
= text::ChapterFormat::DIGIT
; break;
2696 pArr
[2].Value
<<= (sal_Int16
)nVal
;
2698 pArr
[3].Name
= C2U("ChapterLevel");
2700 pArr
[3].Value
<<= aToken
.nOutlineLevel
;
2704 case TOKEN_LINK_START
:
2706 rCurTokenSeq
.realloc( 2 );
2707 beans::PropertyValue
* pArr
= rCurTokenSeq
.getArray();
2709 pArr
[0].Name
= C2U("TokenType");
2710 pArr
[0].Value
<<= OUString::createFromAscii("TokenHyperlinkStart");
2711 pArr
[1].Name
= C2U("CharacterStyleName");
2712 pArr
[1].Value
<<= aProgCharStyle
;
2715 case TOKEN_LINK_END
:
2717 rCurTokenSeq
.realloc( 1 );
2718 beans::PropertyValue
* pArr
= rCurTokenSeq
.getArray();
2720 pArr
[0].Name
= C2U("TokenType");
2721 pArr
[0].Value
<<= OUString::createFromAscii("TokenHyperlinkEnd");
2724 case TOKEN_AUTHORITY
:
2726 rCurTokenSeq
.realloc( 3 );
2727 beans::PropertyValue
* pArr
= rCurTokenSeq
.getArray();
2729 pArr
[0].Name
= C2U("TokenType");
2730 pArr
[0].Value
<<= OUString::createFromAscii("TokenBibliographyDataField");
2732 pArr
[1].Name
= C2U("CharacterStyleName");
2733 pArr
[1].Value
<<= aProgCharStyle
;
2735 pArr
[2].Name
= C2U("BibliographyDataField");
2736 pArr
[2].Value
<<= sal_Int16(aToken
.nAuthorityField
);
2747 uno::Any
aRet(&aRetSeq
, ::getCppuType((uno::Sequence
< beans::PropertyValues
>*)0));
2751 /*-- 13.09.99 16:52:30---------------------------------------------------
2753 -----------------------------------------------------------------------*/
2754 uno::Type
SwXIndexTokenAccess_Impl::getElementType(void)
2755 throw( uno::RuntimeException
)
2757 return ::getCppuType((uno::Sequence
< beans::PropertyValues
>*)0);
2759 /*-- 13.09.99 16:52:30---------------------------------------------------
2761 -----------------------------------------------------------------------*/
2762 sal_Bool
SwXIndexTokenAccess_Impl::hasElements(void) throw( uno::RuntimeException
)