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 : :
30 : : #include <wrtsh.hxx>
31 : : #include <shellres.hxx>
32 : : #include <swwait.hxx>
33 : : #include <view.hxx>
34 : : #include <toxmgr.hxx>
35 : : #include <crsskip.hxx>
36 : : #include <doc.hxx>
37 : : #include <IDocumentUndoRedo.hxx>
38 : : #include <swundo.hxx>
39 : : #include <globals.hrc>
40 : :
41 : : /*--------------------------------------------------------------------
42 : : Description: handle indexes with TOXMgr
43 : : --------------------------------------------------------------------*/
44 : :
45 : :
46 : 0 : SwTOXMgr::SwTOXMgr(SwWrtShell* pShell):
47 : 0 : pSh(pShell)
48 : : {
49 [ # # ]: 0 : GetTOXMarks();
50 [ # # ]: 0 : SetCurTOXMark(0);
51 : 0 : }
52 : :
53 : : /*--------------------------------------------------------------------
54 : : Description: handle current TOXMarks
55 : : --------------------------------------------------------------------*/
56 : :
57 : :
58 : 0 : sal_uInt16 SwTOXMgr::GetTOXMarks()
59 : : {
60 : 0 : return pSh->GetCurTOXMarks(aCurMarks);
61 : : }
62 : :
63 : :
64 : 0 : SwTOXMark* SwTOXMgr::GetTOXMark(sal_uInt16 nId)
65 : : {
66 [ # # ]: 0 : if(!aCurMarks.empty())
67 : 0 : return aCurMarks[nId];
68 : 0 : return 0;
69 : : }
70 : :
71 : :
72 : 0 : void SwTOXMgr::DeleteTOXMark()
73 : : {
74 : 0 : SwTOXMark* pNext = 0;
75 [ # # ]: 0 : if( pCurTOXMark )
76 : : {
77 : 0 : pNext = (SwTOXMark*)&pSh->GotoTOXMark( *pCurTOXMark, TOX_NXT );
78 [ # # ]: 0 : if( pNext == pCurTOXMark )
79 : 0 : pNext = 0;
80 : :
81 : 0 : pSh->DeleteTOXMark( pCurTOXMark );
82 : 0 : pSh->SetModified();
83 : : }
84 : : // go to next one
85 : 0 : pCurTOXMark = pNext;
86 : 0 : }
87 : :
88 : 0 : void SwTOXMgr::InsertTOXMark(const SwTOXMarkDescription& rDesc)
89 : : {
90 : 0 : SwTOXMark* pMark = 0;
91 [ # # # # ]: 0 : switch(rDesc.GetTOXType())
92 : : {
93 : : case TOX_CONTENT:
94 : : {
95 : : OSL_ENSURE(rDesc.GetLevel() > 0 && rDesc.GetLevel() <= MAXLEVEL,
96 : : "invalid InsertTOCMark level");
97 [ # # ]: 0 : pMark = new SwTOXMark(pSh->GetTOXType(TOX_CONTENT, 0));
98 : 0 : pMark->SetLevel( static_cast< sal_uInt16 >(rDesc.GetLevel()) );
99 : :
100 [ # # ]: 0 : if(rDesc.GetAltStr())
101 : 0 : pMark->SetAlternativeText(*rDesc.GetAltStr());
102 : : }
103 : 0 : break;
104 : : case TOX_INDEX:
105 : : {
106 [ # # ]: 0 : pMark = new SwTOXMark(pSh->GetTOXType(TOX_INDEX, 0));
107 : :
108 [ # # ][ # # ]: 0 : if( rDesc.GetPrimKey() && rDesc.GetPrimKey()->Len() )
[ # # ]
109 : : {
110 : 0 : pMark->SetPrimaryKey( *rDesc.GetPrimKey() );
111 [ # # ]: 0 : if(rDesc.GetPhoneticReadingOfPrimKey())
112 : 0 : pMark->SetPrimaryKeyReading( *rDesc.GetPhoneticReadingOfPrimKey() );
113 : :
114 [ # # ][ # # ]: 0 : if( rDesc.GetSecKey() && rDesc.GetSecKey()->Len() )
[ # # ]
115 : : {
116 : 0 : pMark->SetSecondaryKey( *rDesc.GetSecKey() );
117 [ # # ]: 0 : if(rDesc.GetPhoneticReadingOfSecKey())
118 : 0 : pMark->SetSecondaryKeyReading( *rDesc.GetPhoneticReadingOfSecKey() );
119 : : }
120 : : }
121 [ # # ]: 0 : if(rDesc.GetAltStr())
122 : 0 : pMark->SetAlternativeText(*rDesc.GetAltStr());
123 [ # # ]: 0 : if(rDesc.GetPhoneticReadingOfAltStr())
124 : 0 : pMark->SetTextReading( *rDesc.GetPhoneticReadingOfAltStr() );
125 : 0 : pMark->SetMainEntry(rDesc.IsMainEntry());
126 : : }
127 : 0 : break;
128 : : case TOX_USER:
129 : : {
130 : : OSL_ENSURE(rDesc.GetLevel() > 0 && rDesc.GetLevel() <= MAXLEVEL,
131 : : "invalid InsertTOCMark level");
132 : 0 : sal_uInt16 nId = rDesc.GetTOUName() ?
133 [ # # ]: 0 : GetUserTypeID(*rDesc.GetTOUName()) : 0;
134 [ # # ]: 0 : pMark = new SwTOXMark(pSh->GetTOXType(TOX_USER, nId));
135 : 0 : pMark->SetLevel( static_cast< sal_uInt16 >(rDesc.GetLevel()) );
136 : :
137 [ # # ]: 0 : if(rDesc.GetAltStr())
138 : 0 : pMark->SetAlternativeText(*rDesc.GetAltStr());
139 : : }
140 : 0 : break;
141 : : default:; //prevent warning
142 : : }
143 : 0 : pSh->StartAllAction();
144 : 0 : pSh->SwEditShell::Insert(*pMark);
145 : 0 : pSh->EndAllAction();
146 : 0 : }
147 : : /*--------------------------------------------------------------------
148 : : Description: Update of TOXMarks
149 : : --------------------------------------------------------------------*/
150 : :
151 : :
152 : 0 : void SwTOXMgr::UpdateTOXMark(const SwTOXMarkDescription& rDesc)
153 : : {
154 : : OSL_ENSURE(pCurTOXMark, "no current TOXMark");
155 : :
156 : 0 : pSh->StartAllAction();
157 [ # # ]: 0 : if(pCurTOXMark->GetTOXType()->GetType() == TOX_INDEX)
158 : : {
159 [ # # ][ # # ]: 0 : if(rDesc.GetPrimKey() && rDesc.GetPrimKey()->Len() )
[ # # ]
160 : : {
161 : 0 : pCurTOXMark->SetPrimaryKey( *rDesc.GetPrimKey() );
162 [ # # ]: 0 : if(rDesc.GetPhoneticReadingOfPrimKey())
163 : 0 : pCurTOXMark->SetPrimaryKeyReading( *rDesc.GetPhoneticReadingOfPrimKey() );
164 : : else
165 : 0 : pCurTOXMark->SetPrimaryKeyReading( aEmptyStr );
166 : :
167 [ # # ][ # # ]: 0 : if( rDesc.GetSecKey() && rDesc.GetSecKey()->Len() )
[ # # ]
168 : : {
169 : 0 : pCurTOXMark->SetSecondaryKey( *rDesc.GetSecKey() );
170 [ # # ]: 0 : if(rDesc.GetPhoneticReadingOfSecKey())
171 : 0 : pCurTOXMark->SetSecondaryKeyReading( *rDesc.GetPhoneticReadingOfSecKey() );
172 : : else
173 : 0 : pCurTOXMark->SetSecondaryKeyReading( aEmptyStr );
174 : : }
175 : : else
176 : : {
177 : 0 : pCurTOXMark->SetSecondaryKey( aEmptyStr );
178 : 0 : pCurTOXMark->SetSecondaryKeyReading( aEmptyStr );
179 : : }
180 : : }
181 : : else
182 : : {
183 : 0 : pCurTOXMark->SetPrimaryKey( aEmptyStr );
184 : 0 : pCurTOXMark->SetPrimaryKeyReading( aEmptyStr );
185 : 0 : pCurTOXMark->SetSecondaryKey( aEmptyStr );
186 : 0 : pCurTOXMark->SetSecondaryKeyReading( aEmptyStr );
187 : : }
188 [ # # ]: 0 : if(rDesc.GetPhoneticReadingOfAltStr())
189 : 0 : pCurTOXMark->SetTextReading( *rDesc.GetPhoneticReadingOfAltStr() );
190 : : else
191 : 0 : pCurTOXMark->SetTextReading( aEmptyStr );
192 : 0 : pCurTOXMark->SetMainEntry(rDesc.IsMainEntry());
193 : : }
194 : : else
195 : 0 : pCurTOXMark->SetLevel( static_cast< sal_uInt16 >(rDesc.GetLevel()) );
196 : :
197 [ # # ]: 0 : if(rDesc.GetAltStr())
198 : : {
199 : : // JP 26.08.96: Bug 30344 - either the text of a Doc or an alternative test,
200 : : // not both!
201 : 0 : sal_Bool bReplace = pCurTOXMark->IsAlternativeText();
202 [ # # ]: 0 : if( bReplace )
203 : 0 : pCurTOXMark->SetAlternativeText( *rDesc.GetAltStr() );
204 : : else
205 : : {
206 [ # # ]: 0 : SwTOXMark aCpy( *pCurTOXMark );
207 : 0 : aCurMarks.clear();
208 [ # # ]: 0 : pSh->DeleteTOXMark(pCurTOXMark);
209 [ # # ]: 0 : aCpy.SetAlternativeText( *rDesc.GetAltStr() );
210 [ # # ]: 0 : pSh->SwEditShell::Insert( aCpy );
211 [ # # ]: 0 : pCurTOXMark = 0;
212 : : }
213 : : }
214 : 0 : pSh->SetModified();
215 : 0 : pSh->EndAllAction();
216 : : // Bug 36207 pCurTOXMark points nowhere here!
217 [ # # ]: 0 : if(!pCurTOXMark)
218 : : {
219 : 0 : pSh->Left(CRSR_SKIP_CHARS, sal_False, 1, sal_False );
220 : 0 : pSh->GetCurTOXMarks(aCurMarks);
221 : 0 : SetCurTOXMark(0);
222 : : }
223 : 0 : }
224 : :
225 : :
226 : : /*--------------------------------------------------------------------
227 : : Description: determine UserTypeID
228 : : --------------------------------------------------------------------*/
229 : :
230 : :
231 : 0 : sal_uInt16 SwTOXMgr::GetUserTypeID(const String& rStr)
232 : : {
233 [ # # ]: 0 : sal_uInt16 nSize = pSh->GetTOXTypeCount(TOX_USER);
234 [ # # ]: 0 : for(sal_uInt16 i=0; i < nSize; ++i)
235 : : {
236 [ # # ]: 0 : const SwTOXType* pTmp = pSh->GetTOXType(TOX_USER, i);
237 [ # # ][ # # ]: 0 : if(pTmp && pTmp->GetTypeName() == rStr)
[ # # ][ # # ]
238 : 0 : return i;
239 : : }
240 [ # # ]: 0 : SwTOXType aUserType(TOX_USER, rStr);
241 [ # # ]: 0 : pSh->InsertTOXType(aUserType);
242 [ # # ]: 0 : return nSize;
243 : : }
244 : :
245 : : /*--------------------------------------------------------------------
246 : : Description: traveling between TOXMarks
247 : : --------------------------------------------------------------------*/
248 : :
249 : :
250 : 0 : void SwTOXMgr::NextTOXMark(sal_Bool bSame)
251 : : {
252 : : OSL_ENSURE(pCurTOXMark, "no current TOXMark");
253 [ # # ]: 0 : if( pCurTOXMark )
254 : : {
255 [ # # ]: 0 : SwTOXSearch eDir = bSame ? TOX_SAME_NXT : TOX_NXT;
256 : 0 : pCurTOXMark = (SwTOXMark*)&pSh->GotoTOXMark( *pCurTOXMark, eDir );
257 : : }
258 : 0 : }
259 : :
260 : :
261 : 0 : void SwTOXMgr::PrevTOXMark(sal_Bool bSame)
262 : : {
263 : : OSL_ENSURE(pCurTOXMark, "no current TOXMark");
264 [ # # ]: 0 : if( pCurTOXMark )
265 : : {
266 [ # # ]: 0 : SwTOXSearch eDir = bSame ? TOX_SAME_PRV : TOX_PRV;
267 : 0 : pCurTOXMark = (SwTOXMark*)&pSh->GotoTOXMark(*pCurTOXMark, eDir );
268 : : }
269 : 0 : }
270 : :
271 : : /*--------------------------------------------------------------------
272 : : Description: insert keyword index
273 : : --------------------------------------------------------------------*/
274 : 0 : const SwTOXBase* SwTOXMgr::GetCurTOX()
275 : : {
276 : 0 : return pSh->GetCurTOX();
277 : : }
278 : :
279 : 0 : const SwTOXType* SwTOXMgr::GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const
280 : : {
281 : 0 : return pSh->GetTOXType(eTyp, nId);
282 : : }
283 : :
284 : 0 : void SwTOXMgr::SetCurTOXMark(sal_uInt16 nId)
285 : : {
286 [ # # ]: 0 : pCurTOXMark = (nId < aCurMarks.size()) ? aCurMarks[nId] : 0;
287 : 0 : }
288 : :
289 : 0 : sal_Bool SwTOXMgr::UpdateOrInsertTOX(const SwTOXDescription& rDesc,
290 : : SwTOXBase** ppBase,
291 : : const SfxItemSet* pSet)
292 : : {
293 [ # # ][ # # ]: 0 : SwWait aWait( *pSh->GetView().GetDocShell(), sal_True );
294 : 0 : sal_Bool bRet = sal_True;
295 [ # # ][ # # ]: 0 : const SwTOXBase* pCurTOX = ppBase && *ppBase ? *ppBase : GetCurTOX();
[ # # ]
296 : 0 : SwTOXBase* pTOX = (SwTOXBase*)pCurTOX;
297 : :
298 : 0 : SwTOXBase * pNewTOX = NULL;
299 : :
300 [ # # ]: 0 : if (pTOX)
301 [ # # ][ # # ]: 0 : pNewTOX = new SwTOXBase(*pTOX);
302 : :
303 : 0 : TOXTypes eCurTOXType = rDesc.GetTOXType();
304 [ # # ][ # # ]: 0 : if(pCurTOX && !ppBase && pSh->HasSelection())
[ # # ][ # # ]
[ # # ]
305 [ # # ]: 0 : pSh->EnterStdMode();
306 : :
307 [ # # # # : 0 : switch(eCurTOXType)
# ]
308 : : {
309 : : case TOX_INDEX :
310 : : {
311 [ # # ][ # # ]: 0 : if(!pCurTOX || (ppBase && !(*ppBase)))
[ # # ]
312 : : {
313 [ # # ]: 0 : const SwTOXType* pType = pSh->GetTOXType(eCurTOXType, 0);
314 [ # # ]: 0 : SwForm aForm(eCurTOXType);
315 [ # # ][ # # ]: 0 : pNewTOX = new SwTOXBase(pType, aForm, nsSwTOXElement::TOX_MARK, pType->GetTypeName());
[ # # ]
316 : : }
317 : 0 : pNewTOX->SetOptions(rDesc.GetIndexOptions());
318 [ # # ]: 0 : pNewTOX->SetMainEntryCharStyle(rDesc.GetMainEntryCharStyle());
319 [ # # ]: 0 : pSh->SetTOIAutoMarkURL(rDesc.GetAutoMarkURL());
320 [ # # ]: 0 : pSh->ApplyAutoMark();
321 : : }
322 : 0 : break;
323 : : case TOX_CONTENT :
324 : : {
325 [ # # ][ # # ]: 0 : if(!pCurTOX || (ppBase && !(*ppBase)))
[ # # ]
326 : : {
327 [ # # ]: 0 : const SwTOXType* pType = pSh->GetTOXType(eCurTOXType, 0);
328 [ # # ]: 0 : SwForm aForm(eCurTOXType);
329 [ # # ][ # # ]: 0 : pNewTOX = new SwTOXBase(pType, aForm, rDesc.GetContentOptions(), pType->GetTypeName());
[ # # ]
330 : : }
331 [ # # ]: 0 : pNewTOX->SetCreate(rDesc.GetContentOptions());
332 : 0 : pNewTOX->SetLevel(rDesc.GetLevel());
333 : : }
334 : 0 : break;
335 : : case TOX_USER :
336 : : {
337 [ # # ][ # # ]: 0 : if(!pCurTOX || (ppBase && !(*ppBase)))
[ # # ]
338 : : {
339 : 0 : sal_uInt16 nPos = 0;
340 [ # # ]: 0 : sal_uInt16 nSize = pSh->GetTOXTypeCount(eCurTOXType);
341 [ # # ][ # # ]: 0 : for(sal_uInt16 i=0; rDesc.GetTOUName() && i < nSize; ++i)
[ # # ]
342 [ # # ]: 0 : { const SwTOXType* pType = pSh->GetTOXType(TOX_USER, i);
343 [ # # ][ # # ]: 0 : if(pType->GetTypeName() == *rDesc.GetTOUName())
344 : 0 : { nPos = i;
345 : 0 : break;
346 : : }
347 : : }
348 [ # # ]: 0 : const SwTOXType* pType = pSh->GetTOXType(eCurTOXType, nPos);
349 : :
350 [ # # ]: 0 : SwForm aForm(eCurTOXType);
351 [ # # ][ # # ]: 0 : pNewTOX = new SwTOXBase(pType, aForm, rDesc.GetContentOptions(), pType->GetTypeName());
[ # # ]
352 : :
353 : : }
354 : : else
355 : : {
356 [ # # ]: 0 : const_cast<SwTOXBase*>( pCurTOX )->SetCreate(rDesc.GetContentOptions());
357 : : }
358 : 0 : pNewTOX->SetLevelFromChapter(rDesc.IsLevelFromChapter());
359 : : }
360 : 0 : break;
361 : : case TOX_OBJECTS:
362 : : case TOX_TABLES:
363 : : case TOX_AUTHORITIES:
364 : : case TOX_ILLUSTRATIONS:
365 : : {
366 : : //Special handling for TOX_AUTHORITY
367 [ # # ]: 0 : if(TOX_AUTHORITIES == eCurTOXType)
368 : : {
369 : : SwAuthorityFieldType* pFType = (SwAuthorityFieldType*)
370 [ # # ]: 0 : pSh->GetFldType(RES_AUTHORITY, aEmptyStr);
371 [ # # ]: 0 : if (!pFType)
372 : : {
373 [ # # ]: 0 : SwAuthorityFieldType const type(pSh->GetDoc());
374 : : pFType = static_cast<SwAuthorityFieldType*>(
375 [ # # ][ # # ]: 0 : pSh->InsertFldType(type));
376 : : }
377 [ # # ][ # # ]: 0 : pFType->SetPreSuffix(rDesc.GetAuthBrackets().GetChar(0),
378 [ # # ][ # # ]: 0 : rDesc.GetAuthBrackets().GetChar(1));
379 : 0 : pFType->SetSequence(rDesc.IsAuthSequence());
380 [ # # ]: 0 : SwTOXSortKey rArr[3];
381 : 0 : rArr[0] = rDesc.GetSortKey1();
382 : 0 : rArr[1] = rDesc.GetSortKey2();
383 : 0 : rArr[2] = rDesc.GetSortKey3();
384 [ # # ]: 0 : pFType->SetSortKeys(3, rArr);
385 : 0 : pFType->SetSortByDocument(rDesc.IsSortByDocument());
386 : 0 : pFType->SetLanguage(rDesc.GetLanguage());
387 [ # # ]: 0 : pFType->SetSortAlgorithm(rDesc.GetSortAlgorithm());
388 : :
389 [ # # ]: 0 : pFType->UpdateFlds();
390 : : }
391 : : // TODO: consider properties of the current TOXType
392 [ # # ][ # # ]: 0 : if(!pCurTOX || (ppBase && !(*ppBase)))
[ # # ]
393 : : {
394 [ # # ]: 0 : const SwTOXType* pType = pSh->GetTOXType(eCurTOXType, 0);
395 [ # # ]: 0 : SwForm aForm(eCurTOXType);
396 : : pNewTOX = new SwTOXBase(
397 : : pType, aForm,
398 [ # # ][ # # ]: 0 : TOX_AUTHORITIES == eCurTOXType ? nsSwTOXElement::TOX_MARK : 0, pType->GetTypeName());
[ # # ][ # # ]
399 : : }
400 : : else
401 : : {
402 [ # # ][ # # ]: 0 : if((!ppBase || !(*ppBase)) && pSh->HasSelection())
[ # # ][ # # ]
[ # # ]
403 [ # # ]: 0 : pSh->DelRight();
404 : 0 : pNewTOX = (SwTOXBase*)pCurTOX;
405 : : }
406 : 0 : pNewTOX->SetFromObjectNames(rDesc.IsCreateFromObjectNames());
407 : 0 : pNewTOX->SetOLEOptions(rDesc.GetOLEOptions());
408 : : }
409 : 0 : break;
410 : : }
411 : :
412 : :
413 : : OSL_ENSURE(pNewTOX, "no TOXBase created!" );
414 [ # # ]: 0 : if(!pNewTOX)
415 : 0 : return sal_False;
416 : :
417 : 0 : pNewTOX->SetFromChapter(rDesc.IsFromChapter());
418 [ # # ]: 0 : pNewTOX->SetSequenceName(rDesc.GetSequenceName());
419 : 0 : pNewTOX->SetCaptionDisplay(rDesc.GetCaptionDisplay());
420 : 0 : pNewTOX->SetProtected(rDesc.IsReadonly());
421 : :
422 [ # # ]: 0 : for(sal_uInt16 nLevel = 0; nLevel < MAXLEVEL; nLevel++)
423 [ # # ]: 0 : pNewTOX->SetStyleNames(rDesc.GetStyleNames(nLevel), nLevel);
424 : :
425 [ # # ]: 0 : if(rDesc.GetTitle())
426 [ # # ]: 0 : pNewTOX->SetTitle(*rDesc.GetTitle());
427 [ # # ]: 0 : if(rDesc.GetForm())
428 [ # # ]: 0 : pNewTOX->SetTOXForm(*rDesc.GetForm());
429 : 0 : pNewTOX->SetLanguage(rDesc.GetLanguage());
430 [ # # ]: 0 : pNewTOX->SetSortAlgorithm(rDesc.GetSortAlgorithm());
431 : :
432 [ # # ][ # # ]: 0 : if(!pCurTOX || (ppBase && !(*ppBase)) )
[ # # ]
433 : : {
434 : : // when ppBase is passed over, TOXBase is only created here
435 : : // and then inserted in a global document by the dialog
436 [ # # ]: 0 : if(ppBase)
437 : 0 : (*ppBase) = pNewTOX;
438 : : else
439 : : {
440 [ # # ]: 0 : pSh->InsertTableOf(*pNewTOX, pSet);
441 [ # # ][ # # ]: 0 : delete pNewTOX;
442 : : }
443 : : }
444 : : else
445 : : {
446 : 0 : SwDoc * pDoc = pSh->GetDoc();
447 : :
448 [ # # ][ # # ]: 0 : if (pDoc->GetIDocumentUndoRedo().DoesUndo())
[ # # ]
449 : : {
450 [ # # ]: 0 : if (pNewTOX != NULL)
451 : : {
452 [ # # ][ # # ]: 0 : pDoc->GetIDocumentUndoRedo().DelAllUndoObj();
453 : : }
454 : :
455 [ # # ][ # # ]: 0 : pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_TOXCHANGE, NULL);
456 : : }
457 : :
458 [ # # ]: 0 : if (pNewTOX != NULL) // => pTOX != NULL
459 [ # # ]: 0 : pDoc->ChgTOX(*pTOX, *pNewTOX);
460 : :
461 [ # # ]: 0 : bRet = pSh->UpdateTableOf(*pTOX, pSet);
462 : :
463 [ # # ][ # # ]: 0 : if (pDoc->GetIDocumentUndoRedo().DoesUndo())
[ # # ]
464 : : {
465 [ # # ][ # # ]: 0 : pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_TOXCHANGE, NULL);
466 : :
467 [ # # ]: 0 : if (pNewTOX == NULL)
468 : : {
469 [ # # ][ # # ]: 0 : pDoc->GetIDocumentUndoRedo().DelAllUndoObj();
470 : : }
471 : : }
472 : : }
473 : :
474 [ # # ]: 0 : return bRet;
475 : : }
476 : :
477 : 0 : void SwTOXDescription::SetSortKeys(SwTOXSortKey eKey1,
478 : : SwTOXSortKey eKey2,
479 : : SwTOXSortKey eKey3)
480 : : {
481 [ # # ]: 0 : SwTOXSortKey aArr[3];
482 : 0 : sal_uInt16 nPos = 0;
483 [ # # ]: 0 : if(AUTH_FIELD_END > eKey1.eField)
484 : 0 : aArr[nPos++] = eKey1;
485 [ # # ]: 0 : if(AUTH_FIELD_END > eKey2.eField)
486 : 0 : aArr[nPos++] = eKey2;
487 [ # # ]: 0 : if(AUTH_FIELD_END > eKey3.eField)
488 : 0 : aArr[nPos++] = eKey3;
489 : :
490 : 0 : eSortKey1 = aArr[0];
491 : 0 : eSortKey2 = aArr[1];
492 : 0 : eSortKey3 = aArr[2];
493 : 0 : }
494 : :
495 : 0 : void SwTOXDescription::ApplyTo(SwTOXBase& rTOXBase)
496 : : {
497 [ # # ]: 0 : for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
498 : 0 : rTOXBase.SetStyleNames(GetStyleNames(i), i);
499 [ # # ]: 0 : rTOXBase.SetTitle(GetTitle() ? *GetTitle() : aEmptyStr);
500 : 0 : rTOXBase.SetCreate(GetContentOptions());
501 : :
502 [ # # ]: 0 : if(GetTOXType() == TOX_INDEX)
503 : 0 : rTOXBase.SetOptions(GetIndexOptions());
504 [ # # ]: 0 : if(GetTOXType() != TOX_INDEX)
505 : 0 : rTOXBase.SetLevel(GetLevel());
506 : 0 : rTOXBase.SetFromObjectNames(IsCreateFromObjectNames());
507 : 0 : rTOXBase.SetSequenceName(GetSequenceName());
508 : 0 : rTOXBase.SetCaptionDisplay(GetCaptionDisplay());
509 : 0 : rTOXBase.SetFromChapter(IsFromChapter());
510 : 0 : rTOXBase.SetProtected(IsReadonly());
511 : 0 : rTOXBase.SetOLEOptions(GetOLEOptions());
512 : 0 : rTOXBase.SetLevelFromChapter(IsLevelFromChapter());
513 : 0 : rTOXBase.SetLanguage(eLanguage);
514 : 0 : rTOXBase.SetSortAlgorithm(sSortAlgorithm);
515 : :
516 : 0 : }
517 : :
518 : :
519 : :
520 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|