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