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