1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*efeef26fSAndrew Rist * distributed with this work for additional information
6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10*efeef26fSAndrew Rist *
11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist *
13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17*efeef26fSAndrew Rist * specific language governing permissions and limitations
18*efeef26fSAndrew Rist * under the License.
19*efeef26fSAndrew Rist *
20*efeef26fSAndrew Rist *************************************************************/
21*efeef26fSAndrew Rist
22*efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION
28cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir
31cdf0e10cSrcweir
32cdf0e10cSrcweir
33cdf0e10cSrcweir #include <rsc/rscsfx.hxx>
34cdf0e10cSrcweir #include <com/sun/star/text/XDocumentIndexesSupplier.hpp>
35cdf0e10cSrcweir #include <com/sun/star/text/XDocumentIndex.hpp>
36cdf0e10cSrcweir #include <com/sun/star/text/XTextSectionsSupplier.hpp>
37cdf0e10cSrcweir #include <com/sun/star/style/BreakType.hpp>
38cdf0e10cSrcweir #include <com/sun/star/text/XTextFieldsSupplier.hpp>
39cdf0e10cSrcweir #include <com/sun/star/text/XDependentTextField.hpp>
40cdf0e10cSrcweir #include <com/sun/star/text/XParagraphCursor.hpp>
41cdf0e10cSrcweir #include <com/sun/star/text/XDocumentIndex.hpp>
42cdf0e10cSrcweir #include <com/sun/star/text/ChapterFormat.hpp>
43cdf0e10cSrcweir #include <com/sun/star/text/XTextSection.hpp>
44cdf0e10cSrcweir #include <com/sun/star/text/ControlCharacter.hpp>
45cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValues.hpp>
46cdf0e10cSrcweir #include <com/sun/star/text/TextContentAnchorType.hpp>
47cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandEnvironment.hpp>
48cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
49cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
50cdf0e10cSrcweir #include <wrtsh.hxx>
51cdf0e10cSrcweir #ifndef _VIEW_HXX
52cdf0e10cSrcweir #include <view.hxx>
53cdf0e10cSrcweir #endif
54cdf0e10cSrcweir #include <cnttab.hxx>
55cdf0e10cSrcweir #include <poolfmt.hxx>
56cdf0e10cSrcweir #include <unoprnms.hxx>
57cdf0e10cSrcweir #include <unotools.hxx>
58cdf0e10cSrcweir #include <unotxdoc.hxx>
59cdf0e10cSrcweir #include <docsh.hxx>
60cdf0e10cSrcweir #include <swmodule.hxx>
61cdf0e10cSrcweir
62cdf0e10cSrcweir #ifndef _CMDID_H
63cdf0e10cSrcweir #include <cmdid.h>
64cdf0e10cSrcweir #endif
65cdf0e10cSrcweir #ifndef _UTLUI_HRC
66cdf0e10cSrcweir #include <utlui.hrc>
67cdf0e10cSrcweir #endif
68cdf0e10cSrcweir #ifndef _INDEX_HRC
69cdf0e10cSrcweir #include <index.hrc>
70cdf0e10cSrcweir #endif
71cdf0e10cSrcweir #ifndef _CNTTAB_HRC
72cdf0e10cSrcweir #include <cnttab.hrc>
73cdf0e10cSrcweir #endif
74cdf0e10cSrcweir #ifndef _GLOBALS_HRC
75cdf0e10cSrcweir #include <globals.hrc>
76cdf0e10cSrcweir #endif
77cdf0e10cSrcweir #include <SwStyleNameMapper.hxx>
78cdf0e10cSrcweir #include <swuicnttab.hxx>
79cdf0e10cSrcweir #include <unomid.h>
80cdf0e10cSrcweir
81cdf0e10cSrcweir
82cdf0e10cSrcweir using namespace ::com::sun::star;
83cdf0e10cSrcweir using namespace ::com::sun::star::text;
84cdf0e10cSrcweir using namespace ::com::sun::star::beans;
85cdf0e10cSrcweir using namespace ::com::sun::star::container;
86cdf0e10cSrcweir using namespace ::com::sun::star::lang;
87cdf0e10cSrcweir using namespace ::com::sun::star::ucb;
88cdf0e10cSrcweir using namespace ::com::sun::star::uno;
89cdf0e10cSrcweir using namespace com::sun::star::ui::dialogs;
90cdf0e10cSrcweir using ::rtl::OUString;
91cdf0e10cSrcweir
92cdf0e10cSrcweir
93cdf0e10cSrcweir #define INDEX_SECTION_NAME String::CreateFromAscii( \
94cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "IndexSection_" ))
95cdf0e10cSrcweir
96cdf0e10cSrcweir #ifdef SW_PROP_NAME_STR
97cdf0e10cSrcweir #undef SW_PROP_NAME_STR
98cdf0e10cSrcweir #endif
99cdf0e10cSrcweir #define SW_PROP_NAME_STR(nId) SwGetPropName((nId)).pName
100cdf0e10cSrcweir
101cdf0e10cSrcweir /* -----------------04.11.99 11:28-------------------
102cdf0e10cSrcweir
103cdf0e10cSrcweir --------------------------------------------------*/
lcl_SetProp(uno::Reference<XPropertySetInfo> & xInfo,uno::Reference<XPropertySet> & xProps,const char * pPropName,const String & rValue)104cdf0e10cSrcweir void lcl_SetProp( uno::Reference< XPropertySetInfo > & xInfo,
105cdf0e10cSrcweir uno::Reference< XPropertySet > & xProps,
106cdf0e10cSrcweir const char* pPropName, const String& rValue)
107cdf0e10cSrcweir {
108cdf0e10cSrcweir OUString uPropName(C2U(pPropName));
109cdf0e10cSrcweir if(xInfo->hasPropertyByName(uPropName))
110cdf0e10cSrcweir {
111cdf0e10cSrcweir uno::Any aValue;
112cdf0e10cSrcweir aValue <<= OUString(rValue);
113cdf0e10cSrcweir xProps->setPropertyValue(uPropName, aValue);
114cdf0e10cSrcweir }
115cdf0e10cSrcweir }
lcl_SetProp(uno::Reference<XPropertySetInfo> & xInfo,uno::Reference<XPropertySet> & xProps,sal_uInt16 nId,const String & rValue)116cdf0e10cSrcweir void lcl_SetProp( uno::Reference< XPropertySetInfo > & xInfo,
117cdf0e10cSrcweir uno::Reference< XPropertySet > & xProps,
118cdf0e10cSrcweir sal_uInt16 nId, const String& rValue)
119cdf0e10cSrcweir {
120cdf0e10cSrcweir lcl_SetProp( xInfo, xProps, SW_PROP_NAME_STR(nId), rValue);
121cdf0e10cSrcweir }
lcl_SetProp(uno::Reference<XPropertySetInfo> & xInfo,uno::Reference<XPropertySet> & xProps,sal_uInt16 nId,sal_Int16 nValue)122cdf0e10cSrcweir void lcl_SetProp( uno::Reference< XPropertySetInfo > & xInfo,
123cdf0e10cSrcweir uno::Reference< XPropertySet > & xProps,
124cdf0e10cSrcweir sal_uInt16 nId, sal_Int16 nValue )
125cdf0e10cSrcweir {
126cdf0e10cSrcweir OUString uPropName(C2U(SW_PROP_NAME_STR(nId)));
127cdf0e10cSrcweir if(xInfo->hasPropertyByName(uPropName))
128cdf0e10cSrcweir {
129cdf0e10cSrcweir uno::Any aValue;
130cdf0e10cSrcweir aValue <<= nValue;
131cdf0e10cSrcweir xProps->setPropertyValue(uPropName, aValue);
132cdf0e10cSrcweir }
133cdf0e10cSrcweir }
134cdf0e10cSrcweir
lcl_SetBOOLProp(uno::Reference<beans::XPropertySetInfo> & xInfo,uno::Reference<beans::XPropertySet> & xProps,sal_uInt16 nId,sal_Bool bValue)135cdf0e10cSrcweir void lcl_SetBOOLProp(
136cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > & xInfo,
137cdf0e10cSrcweir uno::Reference< beans::XPropertySet > & xProps,
138cdf0e10cSrcweir sal_uInt16 nId, sal_Bool bValue )
139cdf0e10cSrcweir {
140cdf0e10cSrcweir OUString uPropName(C2U(SW_PROP_NAME_STR(nId)));
141cdf0e10cSrcweir if(xInfo->hasPropertyByName(uPropName))
142cdf0e10cSrcweir {
143cdf0e10cSrcweir uno::Any aValue;
144cdf0e10cSrcweir aValue.setValue(&bValue, ::getCppuBooleanType());
145cdf0e10cSrcweir xProps->setPropertyValue(uPropName, aValue);
146cdf0e10cSrcweir }
147cdf0e10cSrcweir }
148cdf0e10cSrcweir //-----------------------------------------------------------------------------
IMPL_LINK(SwMultiTOXTabDialog,CreateExample_Hdl,void *,EMPTYARG)149cdf0e10cSrcweir IMPL_LINK( SwMultiTOXTabDialog, CreateExample_Hdl, void*, EMPTYARG )
150cdf0e10cSrcweir {
151cdf0e10cSrcweir try
152cdf0e10cSrcweir {
153cdf0e10cSrcweir uno::Reference< frame::XModel > & xModel = pExampleFrame->GetModel();
154cdf0e10cSrcweir uno::Reference< lang::XUnoTunnel > xDocTunnel(xModel, uno::UNO_QUERY);
155cdf0e10cSrcweir SwXTextDocument* pDoc = reinterpret_cast<SwXTextDocument*>(xDocTunnel->getSomething(SwXTextDocument::getUnoTunnelId()));
156cdf0e10cSrcweir
157cdf0e10cSrcweir if( pDoc )
158cdf0e10cSrcweir pDoc->GetDocShell()->_LoadStyles( *rSh.GetView().GetDocShell(), sal_True );
159cdf0e10cSrcweir
160cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xFact(
161cdf0e10cSrcweir xModel, uno::UNO_QUERY);
162cdf0e10cSrcweir
163cdf0e10cSrcweir uno::Reference< text::XTextSectionsSupplier > xSectionSupplier(
164cdf0e10cSrcweir xModel, uno::UNO_QUERY);
165cdf0e10cSrcweir uno::Reference< container::XNameAccess > xSections =
166cdf0e10cSrcweir xSectionSupplier->getTextSections();
167cdf0e10cSrcweir
168cdf0e10cSrcweir String sSectionName( INDEX_SECTION_NAME );
169cdf0e10cSrcweir for(int i = 0; i < 7; ++i )
170cdf0e10cSrcweir {
171cdf0e10cSrcweir String sTmp( sSectionName ); sTmp += String::CreateFromInt32(i);
172cdf0e10cSrcweir uno::Any aSection = xSections->getByName( sTmp );
173cdf0e10cSrcweir aSection >>= pxIndexSectionsArr[i]->xContainerSection;
174cdf0e10cSrcweir }
175cdf0e10cSrcweir uno::Reference< text::XDocumentIndexesSupplier > xIdxSupp(xModel, uno::UNO_QUERY);
176cdf0e10cSrcweir uno::Reference< container::XIndexAccess > xIdxs = xIdxSupp->getDocumentIndexes();
177cdf0e10cSrcweir int n = xIdxs->getCount();
178cdf0e10cSrcweir while(n)
179cdf0e10cSrcweir {
180cdf0e10cSrcweir n--;
181cdf0e10cSrcweir uno::Any aIdx = xIdxs->getByIndex(n);
182cdf0e10cSrcweir uno::Reference< text::XDocumentIndex > xIdx;
183cdf0e10cSrcweir aIdx >>= xIdx;
184cdf0e10cSrcweir xIdx->dispose();
185cdf0e10cSrcweir }
186cdf0e10cSrcweir CreateOrUpdateExample(eCurrentTOXType.eType);
187cdf0e10cSrcweir }
188cdf0e10cSrcweir catch(Exception&)
189cdf0e10cSrcweir {
190cdf0e10cSrcweir DBG_ERROR("::CreateExample() - exception caught");
191cdf0e10cSrcweir }
192cdf0e10cSrcweir return 0;
193cdf0e10cSrcweir }
194cdf0e10cSrcweir
195cdf0e10cSrcweir /* --------------------------------------------------
196cdf0e10cSrcweir
197cdf0e10cSrcweir --------------------------------------------------*/
CreateOrUpdateExample(TOXTypes nTOXIndex,sal_uInt16 nPage,sal_uInt16 nCurrentLevel)198cdf0e10cSrcweir void SwMultiTOXTabDialog::CreateOrUpdateExample(
199cdf0e10cSrcweir TOXTypes nTOXIndex, sal_uInt16 nPage, sal_uInt16 nCurrentLevel)
200cdf0e10cSrcweir {
201cdf0e10cSrcweir if(!pExampleFrame || !pExampleFrame->IsInitialized())
202cdf0e10cSrcweir return;
203cdf0e10cSrcweir
204cdf0e10cSrcweir const char* __FAR_DATA IndexServiceNames[] =
205cdf0e10cSrcweir {
206cdf0e10cSrcweir "com.sun.star.text.DocumentIndex",
207cdf0e10cSrcweir "com.sun.star.text.UserIndex",
208cdf0e10cSrcweir "com.sun.star.text.ContentIndex",
209cdf0e10cSrcweir "com.sun.star.text.IllustrationsIndex",
210cdf0e10cSrcweir "com.sun.star.text.ObjectIndex",
211cdf0e10cSrcweir "com.sun.star.text.TableIndex",
212cdf0e10cSrcweir "com.sun.star.text.Bibliography"
213cdf0e10cSrcweir };
214cdf0e10cSrcweir
215cdf0e10cSrcweir try
216cdf0e10cSrcweir {
217cdf0e10cSrcweir DBG_ASSERT(pxIndexSectionsArr[nTOXIndex] &&
218cdf0e10cSrcweir pxIndexSectionsArr[nTOXIndex]->xContainerSection.is(),
219cdf0e10cSrcweir "Section not created");
220cdf0e10cSrcweir uno::Reference< frame::XModel > & xModel = pExampleFrame->GetModel();
221cdf0e10cSrcweir sal_Bool bInitialCreate = sal_True;
222cdf0e10cSrcweir if(!pxIndexSectionsArr[nTOXIndex]->xDocumentIndex.is())
223cdf0e10cSrcweir {
224cdf0e10cSrcweir bInitialCreate = sal_True;
225cdf0e10cSrcweir if(!pxIndexSectionsArr[nTOXIndex]->xContainerSection.is())
226cdf0e10cSrcweir throw uno::RuntimeException();
227cdf0e10cSrcweir uno::Reference< text::XTextRange > xAnchor = pxIndexSectionsArr[nTOXIndex]->xContainerSection->getAnchor();
228cdf0e10cSrcweir xAnchor = xAnchor->getStart();
229cdf0e10cSrcweir uno::Reference< text::XTextCursor > xCrsr = xAnchor->getText()->createTextCursorByRange(xAnchor);
230cdf0e10cSrcweir
231cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xFact(xModel, uno::UNO_QUERY);
232cdf0e10cSrcweir
233cdf0e10cSrcweir String sIndexTypeName;
234cdf0e10cSrcweir sIndexTypeName.AssignAscii( IndexServiceNames[
235cdf0e10cSrcweir nTOXIndex <= TOX_AUTHORITIES ? nTOXIndex : TOX_USER] );
236cdf0e10cSrcweir pxIndexSectionsArr[nTOXIndex]->xDocumentIndex = uno::Reference< text::XDocumentIndex > (xFact->createInstance(
237cdf0e10cSrcweir sIndexTypeName), uno::UNO_QUERY);
238cdf0e10cSrcweir uno::Reference< text::XTextContent > xContent(pxIndexSectionsArr[nTOXIndex]->xDocumentIndex, uno::UNO_QUERY);
239cdf0e10cSrcweir uno::Reference< text::XTextRange > xRg(xCrsr, uno::UNO_QUERY);
240cdf0e10cSrcweir xCrsr->getText()->insertTextContent(xRg, xContent, sal_False);
241cdf0e10cSrcweir }
242cdf0e10cSrcweir OUString uIsVisible(C2U(SW_PROP_NAME_STR(UNO_NAME_IS_VISIBLE)));
243cdf0e10cSrcweir for(sal_uInt16 i = 0 ; i <= TOX_AUTHORITIES; i++)
244cdf0e10cSrcweir {
245cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xSectPr(pxIndexSectionsArr[i]->xContainerSection, uno::UNO_QUERY);
246cdf0e10cSrcweir uno::Any aVal;
247cdf0e10cSrcweir
248cdf0e10cSrcweir if(xSectPr.is())
249cdf0e10cSrcweir {
250cdf0e10cSrcweir sal_Bool bTemp = i == nTOXIndex;
251cdf0e10cSrcweir aVal.setValue(&bTemp, ::getBooleanCppuType());
252cdf0e10cSrcweir xSectPr->setPropertyValue(uIsVisible, aVal);
253cdf0e10cSrcweir }
254cdf0e10cSrcweir }
255cdf0e10cSrcweir // set properties
256cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xIdxProps(pxIndexSectionsArr[nTOXIndex]->xDocumentIndex, uno::UNO_QUERY);
257cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > xInfo = xIdxProps->getPropertySetInfo();
258cdf0e10cSrcweir SwTOXDescription& rDesc = GetTOXDescription(eCurrentTOXType);
259cdf0e10cSrcweir sal_uInt16 nIdxOptions = rDesc.GetIndexOptions();
260cdf0e10cSrcweir if(bInitialCreate || !nPage || nPage == TOX_PAGE_SELECT)
261cdf0e10cSrcweir {
262cdf0e10cSrcweir //title
263cdf0e10cSrcweir if(rDesc.GetTitle())
264cdf0e10cSrcweir lcl_SetProp(xInfo, xIdxProps, UNO_NAME_TITLE, *rDesc.GetTitle());
265cdf0e10cSrcweir
266cdf0e10cSrcweir //stylenames
267cdf0e10cSrcweir sal_uInt16 nContentOptions = rDesc.GetContentOptions();
268cdf0e10cSrcweir if(xInfo->hasPropertyByName(C2U(SW_PROP_NAME_STR(UNO_NAME_LEVEL_PARAGRAPH_STYLES))))
269cdf0e10cSrcweir {
270cdf0e10cSrcweir sal_Bool bOn = 0!=(nContentOptions&nsSwTOXElement::TOX_TEMPLATE );
271cdf0e10cSrcweir uno::Any aStyleNames(xIdxProps->getPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_LEVEL_PARAGRAPH_STYLES))));
272cdf0e10cSrcweir uno::Reference< container::XIndexReplace > xAcc;
273cdf0e10cSrcweir aStyleNames >>= xAcc;
274cdf0e10cSrcweir
275cdf0e10cSrcweir for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
276cdf0e10cSrcweir {
277cdf0e10cSrcweir String sLevel;
278cdf0e10cSrcweir if(bOn)
279cdf0e10cSrcweir sLevel = rDesc.GetStyleNames(i);
280cdf0e10cSrcweir sal_uInt16 nStyles = sLevel.GetTokenCount(TOX_STYLE_DELIMITER);
281cdf0e10cSrcweir uno::Sequence<OUString> aStyles(nStyles);
282cdf0e10cSrcweir OUString* pArr = aStyles.getArray();
283cdf0e10cSrcweir for(sal_uInt16 nStyle = 0; nStyle < nStyles; nStyle++)
284cdf0e10cSrcweir pArr[nStyle] = sLevel.GetToken(nStyle, TOX_STYLE_DELIMITER);
285cdf0e10cSrcweir uno::Any aAny(&aStyles, ::getCppuType((uno::Sequence<OUString>*)0));
286cdf0e10cSrcweir xAcc->replaceByIndex(i, aAny);
287cdf0e10cSrcweir }
288cdf0e10cSrcweir }
289cdf0e10cSrcweir lcl_SetProp(xInfo, xIdxProps, UNO_NAME_LEVEL, (sal_Int16)rDesc.GetLevel());
290cdf0e10cSrcweir lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_MARKS, 0!=(nContentOptions&nsSwTOXElement::TOX_MARK ));
291cdf0e10cSrcweir lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_OUTLINE, 0!=(nContentOptions&nsSwTOXElement::TOX_OUTLINELEVEL));
292cdf0e10cSrcweir lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_EMBEDDED_OBJECTS,0!=(nContentOptions&nsSwTOXElement::TOX_OLE ));
293cdf0e10cSrcweir lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_TABLES , 0!=(nContentOptions&nsSwTOXElement::TOX_TABLE ));
294cdf0e10cSrcweir lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_GRAPHIC_OBJECTS, 0!=(nContentOptions&nsSwTOXElement::TOX_GRAPHIC ));
295cdf0e10cSrcweir lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_TEXT_FRAMES, 0!=(nContentOptions&nsSwTOXElement::TOX_FRAME ));
296cdf0e10cSrcweir lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_LABELS, 0!=(nContentOptions&nsSwTOXElement::TOX_SEQUENCE ));
297cdf0e10cSrcweir
298cdf0e10cSrcweir lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_CHAPTER, rDesc.IsFromChapter());
299cdf0e10cSrcweir lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_IS_PROTECTED, rDesc.IsReadonly());
300cdf0e10cSrcweir
301cdf0e10cSrcweir lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_USE_COMBINED_ENTRIES, 0 != (nIdxOptions&nsSwTOIOptions::TOI_SAME_ENTRY ));
302cdf0e10cSrcweir lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_USE_P_P, 0 != (nIdxOptions&nsSwTOIOptions::TOI_FF ));
303cdf0e10cSrcweir lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_IS_CASE_SENSITIVE, 0 != (nIdxOptions&nsSwTOIOptions::TOI_CASE_SENSITIVE ));
304cdf0e10cSrcweir lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_USE_KEY_AS_ENTRY, 0 != (nIdxOptions&nsSwTOIOptions::TOI_KEY_AS_ENTRY ));
305cdf0e10cSrcweir lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_USE_ALPHABETICAL_SEPARATORS, 0 != (nIdxOptions&nsSwTOIOptions::TOI_ALPHA_DELIMITTER));
306cdf0e10cSrcweir lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_USE_DASH, 0 != (nIdxOptions&nsSwTOIOptions::TOI_DASH ));
307cdf0e10cSrcweir lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_USE_UPPER_CASE, 0 != (nIdxOptions&nsSwTOIOptions::TOI_INITIAL_CAPS ));
308cdf0e10cSrcweir
309cdf0e10cSrcweir String aTmpName( SwStyleNameMapper::GetSpecialExtraProgName( rDesc.GetSequenceName() ) );
310cdf0e10cSrcweir lcl_SetProp(xInfo, xIdxProps, UNO_NAME_LABEL_CATEGORY, aTmpName );
311cdf0e10cSrcweir lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_LABELS, !rDesc.IsCreateFromObjectNames());
312cdf0e10cSrcweir
313cdf0e10cSrcweir sal_Int16 nSet = text::ChapterFormat::NAME_NUMBER;
314cdf0e10cSrcweir switch (rDesc.GetCaptionDisplay())
315cdf0e10cSrcweir {
316cdf0e10cSrcweir case CAPTION_COMPLETE: nSet = text::ChapterFormat::NAME_NUMBER;break;
317cdf0e10cSrcweir case CAPTION_NUMBER : nSet = text::ChapterFormat::NUMBER; break;
318cdf0e10cSrcweir case CAPTION_TEXT : nSet = text::ChapterFormat::NAME; break;
319cdf0e10cSrcweir }
320cdf0e10cSrcweir lcl_SetProp(xInfo, xIdxProps, UNO_NAME_LABEL_DISPLAY_TYPE, nSet);
321cdf0e10cSrcweir
322cdf0e10cSrcweir sal_uInt16 nOLEOptions = rDesc.GetOLEOptions();
323cdf0e10cSrcweir lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_STAR_MATH, 0 != (nsSwTOOElements::TOO_MATH &nOLEOptions ));
324cdf0e10cSrcweir lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_STAR_CHART, 0 != (nsSwTOOElements::TOO_CHART &nOLEOptions ));
325cdf0e10cSrcweir lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_STAR_CALC, 0 != (nsSwTOOElements::TOO_CALC &nOLEOptions ));
326cdf0e10cSrcweir lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_STAR_DRAW, 0 != (nsSwTOOElements::TOO_DRAW_IMPRESS&nOLEOptions));
327cdf0e10cSrcweir lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_OTHER_EMBEDDED_OBJECTS, 0 != (nsSwTOOElements::TOO_OTHER|nOLEOptions ));
328cdf0e10cSrcweir
329cdf0e10cSrcweir //lcl_SetBOOLProp(xInfo, xIdxProps, , rDesc.IsLevelFromChapter());
330cdf0e10cSrcweir }
331cdf0e10cSrcweir const SwForm* pForm = GetForm(eCurrentTOXType);
332cdf0e10cSrcweir if(bInitialCreate || !nPage || nPage == TOX_PAGE_ENTRY)
333cdf0e10cSrcweir {
334cdf0e10cSrcweir lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_IS_COMMA_SEPARATED, pForm->IsCommaSeparated());
335cdf0e10cSrcweir lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_USE_ALPHABETICAL_SEPARATORS, 0 != (nIdxOptions&nsSwTOIOptions::TOI_ALPHA_DELIMITTER));
336cdf0e10cSrcweir sal_uInt16 nStartLevel = USHRT_MAX;
337cdf0e10cSrcweir sal_uInt16 nEndLevel = USHRT_MAX;
338cdf0e10cSrcweir if(nCurrentLevel < pForm->GetFormMax())
339cdf0e10cSrcweir nStartLevel = nEndLevel = nCurrentLevel;
340cdf0e10cSrcweir else
341cdf0e10cSrcweir {
342cdf0e10cSrcweir nStartLevel = 0;
343cdf0e10cSrcweir nEndLevel = pForm->GetFormMax() - 1;
344cdf0e10cSrcweir }
345cdf0e10cSrcweir
346cdf0e10cSrcweir if(xInfo->hasPropertyByName(C2U(SW_PROP_NAME_STR(UNO_NAME_LEVEL_FORMAT))))
347cdf0e10cSrcweir {
348cdf0e10cSrcweir for(sal_uInt16 nCurrLevel = nStartLevel; nCurrLevel <= nEndLevel; nCurrLevel++)
349cdf0e10cSrcweir {
350cdf0e10cSrcweir String sTokenType;
351cdf0e10cSrcweir uno::Sequence< beans::PropertyValues> aSequPropVals(10);
352cdf0e10cSrcweir long nTokenIndex = 0;
353cdf0e10cSrcweir long nParamCount = 2;
354cdf0e10cSrcweir
355cdf0e10cSrcweir // #i24377#
356cdf0e10cSrcweir SwFormTokens aPattern = pForm->GetPattern(nCurrLevel);
357cdf0e10cSrcweir SwFormTokens::iterator aIt = aPattern.begin();
358cdf0e10cSrcweir
359cdf0e10cSrcweir while(aIt != aPattern.end())
360cdf0e10cSrcweir {
361cdf0e10cSrcweir if( aSequPropVals.getLength() <= nTokenIndex)
362cdf0e10cSrcweir aSequPropVals.realloc(nTokenIndex + 10);
363cdf0e10cSrcweir
364cdf0e10cSrcweir SwFormToken aToken = *aIt; // #i24377#
365cdf0e10cSrcweir switch(aToken.eTokenType)
366cdf0e10cSrcweir {
367cdf0e10cSrcweir case TOKEN_ENTRY_NO :
368cdf0e10cSrcweir sTokenType.AssignAscii(RTL_CONSTASCII_STRINGPARAM(
369cdf0e10cSrcweir "TokenEntryNumber"));
370cdf0e10cSrcweir // fuer Inhaltsverzeichnis Numerierung
371cdf0e10cSrcweir break;
372cdf0e10cSrcweir case TOKEN_ENTRY_TEXT :
373cdf0e10cSrcweir case TOKEN_ENTRY :
374cdf0e10cSrcweir sTokenType.AssignAscii(RTL_CONSTASCII_STRINGPARAM(
375cdf0e10cSrcweir "TokenEntryText"));
376cdf0e10cSrcweir break;
377cdf0e10cSrcweir case TOKEN_TAB_STOP :
378cdf0e10cSrcweir nParamCount += 3;
379cdf0e10cSrcweir sTokenType.AssignAscii(RTL_CONSTASCII_STRINGPARAM(
380cdf0e10cSrcweir "TokenTabStop"));
381cdf0e10cSrcweir break;
382cdf0e10cSrcweir case TOKEN_TEXT :
383cdf0e10cSrcweir sTokenType.AssignAscii(RTL_CONSTASCII_STRINGPARAM(
384cdf0e10cSrcweir "TokenText"));
385cdf0e10cSrcweir nParamCount += 1;
386cdf0e10cSrcweir break;
387cdf0e10cSrcweir case TOKEN_PAGE_NUMS :
388cdf0e10cSrcweir sTokenType.AssignAscii(RTL_CONSTASCII_STRINGPARAM(
389cdf0e10cSrcweir "TokenPageNumber"));
390cdf0e10cSrcweir break;
391cdf0e10cSrcweir case TOKEN_CHAPTER_INFO :
392cdf0e10cSrcweir sTokenType.AssignAscii(RTL_CONSTASCII_STRINGPARAM(
393cdf0e10cSrcweir "TokenChapterInfo"));
394cdf0e10cSrcweir break;
395cdf0e10cSrcweir case TOKEN_LINK_START :
396cdf0e10cSrcweir sTokenType.AssignAscii(RTL_CONSTASCII_STRINGPARAM(
397cdf0e10cSrcweir "TokenHyperlinkStart"));
398cdf0e10cSrcweir break;
399cdf0e10cSrcweir case TOKEN_LINK_END :
400cdf0e10cSrcweir sTokenType.AssignAscii(RTL_CONSTASCII_STRINGPARAM(
401cdf0e10cSrcweir "TokenHyperlinkEnd"));
402cdf0e10cSrcweir break;
403cdf0e10cSrcweir case TOKEN_AUTHORITY :
404cdf0e10cSrcweir {
405cdf0e10cSrcweir sTokenType.AssignAscii(RTL_CONSTASCII_STRINGPARAM(
406cdf0e10cSrcweir "TokenBibliographyDataField"));
407cdf0e10cSrcweir }
408cdf0e10cSrcweir break;
409cdf0e10cSrcweir default:; //prevent warning
410cdf0e10cSrcweir }
411cdf0e10cSrcweir beans::PropertyValues aPropVals(nParamCount);
412cdf0e10cSrcweir beans::PropertyValue* pPropValArr = aPropVals.getArray();
413cdf0e10cSrcweir pPropValArr[0].Name = C2U("TokenType");
414cdf0e10cSrcweir pPropValArr[0].Value <<= OUString(sTokenType);
415cdf0e10cSrcweir pPropValArr[1].Name = C2U("CharacterStyleName");
416cdf0e10cSrcweir pPropValArr[1].Value <<= OUString(aToken.sCharStyleName);
417cdf0e10cSrcweir if(TOKEN_TAB_STOP == aToken.eTokenType)
418cdf0e10cSrcweir {
419cdf0e10cSrcweir pPropValArr[2].Name = C2U("TabStopRightAligned");
420cdf0e10cSrcweir sal_Bool bTemp = SVX_TAB_ADJUST_END == aToken.eTabAlign;
421cdf0e10cSrcweir pPropValArr[2].Value.setValue(&bTemp, ::getBooleanCppuType());
422cdf0e10cSrcweir pPropValArr[3].Name = C2U("TabStopFillCharacter");
423cdf0e10cSrcweir pPropValArr[3].Value <<= OUString(aToken.cTabFillChar);
424cdf0e10cSrcweir pPropValArr[4].Name = C2U("TabStopPosition");
425cdf0e10cSrcweir SwTwips nTempPos = aToken.nTabStopPosition >= 0 ?
426cdf0e10cSrcweir aToken.nTabStopPosition : 0;
427cdf0e10cSrcweir nTempPos = TWIP_TO_MM100(nTempPos);
428cdf0e10cSrcweir pPropValArr[4].Value <<= (sal_Int32)nTempPos;
429cdf0e10cSrcweir }
430cdf0e10cSrcweir else if(TOKEN_TEXT == aToken.eTokenType)
431cdf0e10cSrcweir {
432cdf0e10cSrcweir pPropValArr[2].Name = C2U("Text");
433cdf0e10cSrcweir pPropValArr[2].Value <<= OUString(aToken.sText);
434cdf0e10cSrcweir }
435cdf0e10cSrcweir beans::PropertyValues* pValues = aSequPropVals.getArray();
436cdf0e10cSrcweir pValues[nTokenIndex] = aPropVals;
437cdf0e10cSrcweir nTokenIndex++;
438cdf0e10cSrcweir
439cdf0e10cSrcweir aIt++; // #i24377#
440cdf0e10cSrcweir }
441cdf0e10cSrcweir aSequPropVals.realloc(nTokenIndex);
442cdf0e10cSrcweir
443cdf0e10cSrcweir uno::Any aFormatAccess = xIdxProps->getPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_LEVEL_FORMAT)));
444cdf0e10cSrcweir DBG_ASSERT(aFormatAccess.getValueType() == ::getCppuType((uno::Reference<container::XIndexReplace>*)0),
445cdf0e10cSrcweir "wrong property type");
446cdf0e10cSrcweir
447cdf0e10cSrcweir
448cdf0e10cSrcweir uno::Reference< container::XIndexReplace > xFormatAccess;
449cdf0e10cSrcweir aFormatAccess >>= xFormatAccess;
450cdf0e10cSrcweir uno::Any aLevelProp(&aSequPropVals, ::getCppuType((uno::Sequence<beans::PropertyValues>*)0));
451cdf0e10cSrcweir xFormatAccess->replaceByIndex(nCurrLevel, aLevelProp);
452cdf0e10cSrcweir }
453cdf0e10cSrcweir }
454cdf0e10cSrcweir }
455cdf0e10cSrcweir if(bInitialCreate || !nPage || nPage == TOX_PAGE_STYLES)
456cdf0e10cSrcweir {
457cdf0e10cSrcweir lcl_SetProp(xInfo, xIdxProps, "ParaStyleHeading", pForm->GetTemplate(0));
458cdf0e10cSrcweir sal_uInt16 nOffset = 0;
459cdf0e10cSrcweir sal_uInt16 nEndLevel = 2;
460cdf0e10cSrcweir switch(eCurrentTOXType.eType)
461cdf0e10cSrcweir {
462cdf0e10cSrcweir case TOX_INDEX:
463cdf0e10cSrcweir {
464cdf0e10cSrcweir nOffset = 1;
465cdf0e10cSrcweir nEndLevel = 4;
466cdf0e10cSrcweir lcl_SetProp(xInfo, xIdxProps, "ParaStyleSeparator", pForm->GetTemplate(1));
467cdf0e10cSrcweir }
468cdf0e10cSrcweir break;
469cdf0e10cSrcweir case TOX_CONTENT :
470cdf0e10cSrcweir nEndLevel = 11;
471cdf0e10cSrcweir break;
472cdf0e10cSrcweir default:; //prevent warning
473cdf0e10cSrcweir }
474cdf0e10cSrcweir for(sal_uInt16 i = 1; i < nEndLevel; i++)
475cdf0e10cSrcweir {
476cdf0e10cSrcweir String sPropName(C2S("ParaStyleLevel"));
477cdf0e10cSrcweir sPropName += String::CreateFromInt32( i );
478cdf0e10cSrcweir lcl_SetProp(xInfo,
479cdf0e10cSrcweir xIdxProps,
480cdf0e10cSrcweir ByteString(sPropName, RTL_TEXTENCODING_ASCII_US).GetBuffer(),
481cdf0e10cSrcweir pForm->GetTemplate(i + nOffset));
482cdf0e10cSrcweir }
483cdf0e10cSrcweir }
484cdf0e10cSrcweir /*
485cdf0e10cSrcweir const String& GetAutoMarkURL() const { return sAutoMarkURL;}
486cdf0e10cSrcweir const String& GetMainEntryCharStyle() const {return sMainEntryCharStyle;}
487cdf0e10cSrcweir
488cdf0e10cSrcweir String GetAuthBrackets() const {return sAuthBrackets;}
489cdf0e10cSrcweir sal_Bool IsAuthSequence() const {return bIsAuthSequence;}
490cdf0e10cSrcweir sal_Bool IsSortByDocument()const {return bSortByDocument ;}
491cdf0e10cSrcweir
492cdf0e10cSrcweir SwTOXSortKey GetSortKey1() const {return eSortKey1;}
493cdf0e10cSrcweir SwTOXSortKey GetSortKey2() const {return eSortKey2;}
494cdf0e10cSrcweir SwTOXSortKey GetSortKey3() const {return eSortKey3;}
495cdf0e10cSrcweir */
496cdf0e10cSrcweir //
497cdf0e10cSrcweir pxIndexSectionsArr[nTOXIndex]->xDocumentIndex->update();
498cdf0e10cSrcweir
499cdf0e10cSrcweir //#if OSL_DEBUG_LEVEL > 1
500cdf0e10cSrcweir // uno::Reference< frame::XStorable > xStor(xModel, uno::UNO_QUERY);
501cdf0e10cSrcweir // String sURL("file:///e|/temp/sw/idxexample.sdw");
502cdf0e10cSrcweir // uno::Sequence< beans::PropertyValue > aArgs(0);
503cdf0e10cSrcweir // xStor->storeToURL(S2U(sURL), aArgs);
504cdf0e10cSrcweir //#endif
505cdf0e10cSrcweir
506cdf0e10cSrcweir }
507cdf0e10cSrcweir catch(Exception&)
508cdf0e10cSrcweir {
509cdf0e10cSrcweir DBG_ERROR("::CreateExample() - exception caught");
510cdf0e10cSrcweir }
511cdf0e10cSrcweir }
512cdf0e10cSrcweir
513