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 <ctype.h> // tolower
31 : : #include <stdio.h> // sscanf()
32 : :
33 : : #include <sal/types.h>
34 : : #include <tools/solar.h>
35 : :
36 : : #include <comphelper/storagehelper.hxx>
37 : : #include <comphelper/string.hxx>
38 : : #include <sot/storinfo.hxx>
39 : : #include <com/sun/star/embed/XStorage.hpp>
40 : : #include <com/sun/star/embed/ElementModes.hpp>
41 : : #include <com/sun/star/embed/XTransactedObject.hpp>
42 : : #include <com/sun/star/io/XStream.hpp>
43 : :
44 : : #include <com/sun/star/ucb/XCommandEnvironment.hpp>
45 : : #include <svl/urihelper.hxx>
46 : : #include <svl/zforlist.hxx>
47 : : #include <svl/zformat.hxx>
48 : : #include <sfx2/linkmgr.hxx>
49 : :
50 : : #include <ucbhelper/content.hxx>
51 : : #include <ucbhelper/contentbroker.hxx>
52 : : #include <ucbhelper/commandenvironment.hxx>
53 : :
54 : : #include <com/sun/star/i18n/ScriptType.hpp>
55 : : #include <hintids.hxx>
56 : : #include <editeng/fontitem.hxx>
57 : : #include <editeng/fhgtitem.hxx>
58 : : #include <editeng/langitem.hxx>
59 : : #include <fmtfld.hxx>
60 : : #include <fmtanchr.hxx>
61 : : #include <pam.hxx> // fuer SwPam
62 : : #include <doc.hxx>
63 : : #include <charatr.hxx> // class SwFmtFld
64 : : #include <flddat.hxx> // class SwDateTimeField
65 : : #include <docufld.hxx> // class SwPageNumberField
66 : : #include <reffld.hxx> // class SwGetRefField
67 : : #include <IMark.hxx>
68 : : #include <expfld.hxx> // class SwSetExpField
69 : : #include <dbfld.hxx> // class SwDBField
70 : : #include <usrfld.hxx>
71 : : #include <tox.hxx>
72 : : #include <section.hxx> // class SwSection
73 : : #include <ndtxt.hxx>
74 : : #include <fmtinfmt.hxx>
75 : : #include <chpfld.hxx>
76 : : #include <ftnidx.hxx>
77 : : #include <txtftn.hxx>
78 : : #include <viewsh.hxx>
79 : : #include <shellres.hxx>
80 : : #include <fmtruby.hxx>
81 : : #include <charfmt.hxx>
82 : : #include <txtatr.hxx>
83 : : #include <breakit.hxx>
84 : : #include <fmtclds.hxx>
85 : : #include <pagedesc.hxx>
86 : : #include <SwStyleNameMapper.hxx>
87 : :
88 : : #include "ww8scan.hxx" // WW8FieldDesc
89 : : #include "ww8par.hxx"
90 : : #include "ww8par2.hxx"
91 : : #include "writerhelper.hxx"
92 : : #include "fields.hxx"
93 : : #include <unotools/fltrcfg.hxx>
94 : : #include <xmloff/odffields.hxx>
95 : :
96 : : #include <algorithm> // #i24377#
97 : :
98 : : #define MAX_FIELDLEN 64000
99 : :
100 : : #define WW8_TOX_LEVEL_DELIM ':'
101 : :
102 : : using namespace ::com::sun::star;
103 : : using namespace sw::util;
104 : : using namespace sw::mark;
105 : : using namespace std; // #i24377#
106 : : using namespace nsSwDocInfoSubType;
107 : :
108 : :
109 : : class _ReadFieldParams
110 : : {
111 : : private:
112 : : String aData;
113 : : xub_StrLen nLen, nFnd, nNext, nSavPtr;
114 : : public:
115 : : _ReadFieldParams( const String& rData );
116 : : ~_ReadFieldParams();
117 : :
118 : : xub_StrLen GoToTokenParam();
119 : : long SkipToNextToken();
120 : 0 : xub_StrLen GetTokenSttPtr() const { return nFnd; }
121 : :
122 : : xub_StrLen FindNextStringPiece( xub_StrLen _nStart = STRING_NOTFOUND );
123 : : bool GetTokenSttFromTo(xub_StrLen* _pFrom, xub_StrLen* _pTo,
124 : : xub_StrLen _nMax);
125 : :
126 : : String GetResult() const;
127 : : };
128 : :
129 : :
130 : 9 : _ReadFieldParams::_ReadFieldParams( const String& _rData )
131 : 9 : : aData( _rData ), nLen( _rData.Len() ), nNext( 0 )
132 : : {
133 : : /*
134 : : erstmal nach einer oeffnenden Klammer oder einer Leerstelle oder einem
135 : : Anfuehrungszeichen oder einem Backslash suchen, damit der Feldbefehl
136 : : (also INCLUDEPICTURE bzw EINFUeGENGRAFIK bzw ...) ueberlesen wird
137 : : */
138 [ + - ][ + + ]: 15 : while( (nLen > nNext) && (aData.GetChar( nNext ) == ' ') )
[ + + ]
139 : 6 : ++nNext;
140 : :
141 : : sal_Unicode c;
142 [ + + ][ + + ]: 186 : while( nLen > nNext
[ + - ][ + - ]
[ + - ][ + - ]
[ + + ]
143 : 183 : && (c = aData.GetChar( nNext )) != ' '
144 : : && c != '"'
145 : : && c != '\\'
146 : : && c != 132
147 : : && c != 0x201c )
148 : 177 : ++nNext;
149 : :
150 : 9 : nFnd = nNext;
151 : 9 : nSavPtr = nNext;
152 : 9 : }
153 : :
154 : :
155 : 9 : _ReadFieldParams::~_ReadFieldParams()
156 : : {
157 : :
158 : 9 : }
159 : :
160 : :
161 : 6 : String _ReadFieldParams::GetResult() const
162 : : {
163 : : return (STRING_NOTFOUND == nFnd)
164 : : ? aEmptyStr
165 [ - + ]: 6 : : aData.Copy( nFnd, (nSavPtr - nFnd) );
166 : : }
167 : :
168 : :
169 : 0 : xub_StrLen _ReadFieldParams::GoToTokenParam()
170 : : {
171 : 0 : xub_StrLen nOld = nNext;
172 [ # # ]: 0 : if( -2 == SkipToNextToken() )
173 : 0 : return GetTokenSttPtr();
174 : 0 : nNext = nOld;
175 : 0 : return STRING_NOTFOUND;
176 : : }
177 : :
178 : : // ret: -2: NOT a '\' parameter but normal Text
179 : 15 : long _ReadFieldParams::SkipToNextToken()
180 : : {
181 : 15 : long nRet = -1; // Ende
182 [ + - ]: 27 : if (
[ + + + + ]
[ + + ]
183 : : (STRING_NOTFOUND != nNext) && (nLen > nNext) &&
184 : 12 : STRING_NOTFOUND != (nFnd = FindNextStringPiece(nNext))
185 : : )
186 : : {
187 : 6 : nSavPtr = nNext;
188 : :
189 [ - + ][ # # ]: 6 : if ('\\' == aData.GetChar(nFnd) && '\\' != aData.GetChar(nFnd + 1))
[ - + ]
190 : : {
191 : 0 : nRet = aData.GetChar(++nFnd);
192 : 0 : nNext = ++nFnd; // und dahinter setzen
193 : : }
194 : : else
195 : : {
196 : 6 : nRet = -2;
197 [ + - - + : 12 : if (
# # ][ + - ]
198 : : (STRING_NOTFOUND != nSavPtr ) &&
199 : : (
200 : 6 : ('"' == aData.GetChar(nSavPtr - 1)) ||
201 : 0 : (0x201d == aData.GetChar(nSavPtr - 1))
202 : : )
203 : : )
204 : : {
205 : 6 : --nSavPtr;
206 : : }
207 : : }
208 : : }
209 : 15 : return nRet;
210 : : }
211 : :
212 : : // FindNextPara sucht naechsten Backslash-Parameter oder naechste Zeichenkette
213 : : // bis zum Blank oder naechsten "\" oder zum schliessenden Anfuehrungszeichen
214 : : // oder zum String-Ende von pStr.
215 : : //
216 : : // Ausgabe ppNext (falls ppNext != 0) Suchbeginn fuer naechsten Parameter bzw. 0
217 : : //
218 : : // Returnwert: 0 falls String-Ende erreicht,
219 : : // ansonsten Anfang des Paramters bzw. der Zeichenkette
220 : : //
221 : 12 : xub_StrLen _ReadFieldParams::FindNextStringPiece(const xub_StrLen nStart)
222 : : {
223 [ - + ]: 12 : xub_StrLen n = ( STRING_NOTFOUND == nStart ) ? nFnd : nStart; // Anfang
224 : : xub_StrLen n2; // Ende
225 : :
226 : 12 : nNext = STRING_NOTFOUND; // Default fuer nicht gefunden
227 : :
228 [ + + ][ + + ]: 24 : while( (nLen > n) && (aData.GetChar( n ) == ' ') )
[ + + ]
229 : 12 : ++n;
230 : :
231 [ - + ]: 12 : if ( aData.GetChar( n ) == 0x13 )
232 : : {
233 : : // Skip the nested field code since it's not supported
234 [ # # ][ # # ]: 0 : while ( ( nLen > n ) && ( aData.GetChar( n ) != 0x14 ) )
[ # # ]
235 : 0 : n++;
236 : : }
237 : :
238 [ + + ]: 12 : if( nLen == n )
239 : 6 : return STRING_NOTFOUND; // String End reached!
240 : :
241 [ - + # # : 6 : if( (aData.GetChar( n ) == '"') // Anfuehrungszeichen vor Para?
# # # # ]
[ + - ]
242 : 0 : || (aData.GetChar( n ) == 0x201c)
243 : 0 : || (aData.GetChar( n ) == 132)
244 : 0 : || (aData.GetChar( n ) == 0x14) )
245 : : {
246 : 6 : n++; // Anfuehrungszeichen ueberlesen
247 : 6 : n2 = n; // ab hier nach Ende suchen
248 [ + - + + : 897 : while( (nLen > n2)
+ - + - +
- ][ + + ]
249 : 183 : && (aData.GetChar( n2 ) != '"')
250 : 177 : && (aData.GetChar( n2 ) != 0x201d)
251 : 177 : && (aData.GetChar( n2 ) != 147)
252 : 177 : && (aData.GetChar( n2 ) != 0x15) )
253 : 177 : n2++; // Ende d. Paras suchen
254 : : }
255 : : else // keine Anfuehrungszeichen
256 : : {
257 : 0 : n2 = n; // ab hier nach Ende suchen
258 [ # # ][ # # ]: 0 : while( (nLen > n2) && (aData.GetChar( n2 ) != ' ') ) // Ende d. Paras suchen
[ # # ]
259 : : {
260 [ # # ]: 0 : if( aData.GetChar( n2 ) == '\\' )
261 : : {
262 [ # # ]: 0 : if( aData.GetChar( n2+1 ) == '\\' )
263 : 0 : n2 += 2; // Doppel-Backslash -> OK
264 : : else
265 : : {
266 [ # # ]: 0 : if( n2 > n )
267 : 0 : n2--;
268 : 0 : break; // einfach-Backslash -> Ende
269 : : }
270 : : }
271 : : else
272 : 0 : n2++; // kein Backslash -> OK
273 : : }
274 : : }
275 [ + - ]: 6 : if( nLen > n2 )
276 : : {
277 [ + - ]: 6 : if(aData.GetChar( n2 ) != ' ') n2++;
278 : 6 : nNext = n2;
279 : : }
280 : 12 : return n;
281 : : }
282 : :
283 : :
284 : :
285 : : // read parameters "1-3" or 1-3 with both values between 1 and nMax
286 : 0 : bool _ReadFieldParams::GetTokenSttFromTo(sal_uInt16* pFrom, sal_uInt16* pTo, sal_uInt16 nMax)
287 : : {
288 : 0 : sal_uInt16 nStart = 0;
289 : 0 : sal_uInt16 nEnd = 0;
290 : 0 : xub_StrLen n = GoToTokenParam();
291 [ # # ]: 0 : if( STRING_NOTFOUND != n )
292 : : {
293 : :
294 [ # # ]: 0 : String sParams( GetResult() );
295 : :
296 : 0 : xub_StrLen nIndex = 0;
297 [ # # ]: 0 : String sStart( sParams.GetToken(0, '-', nIndex) );
298 [ # # ]: 0 : if( STRING_NOTFOUND != nIndex )
299 : : {
300 [ # # ]: 0 : nStart = static_cast<sal_uInt16>(sStart.ToInt32());
301 [ # # ][ # # ]: 0 : nEnd = static_cast<sal_uInt16>(sParams.Copy(nIndex).ToInt32());
[ # # ]
302 [ # # ][ # # ]: 0 : }
303 : : }
304 [ # # ]: 0 : if( pFrom ) *pFrom = nStart;
305 [ # # ]: 0 : if( pTo ) *pTo = nEnd;
306 : :
307 [ # # ][ # # ]: 0 : return nStart && nEnd && (nMax >= nStart) && (nMax >= nEnd);
[ # # ][ # # ]
308 : : }
309 : :
310 : : //----------------------------------------
311 : : // Bookmarks
312 : : //----------------------------------------
313 : :
314 : 12 : long SwWW8ImplReader::Read_Book(WW8PLCFManResult*)
315 : : {
316 : : // muesste auch ueber pRes.nCo2OrIdx gehen
317 : 12 : WW8PLCFx_Book* pB = pPlcxMan->GetBook();
318 [ - + ]: 12 : if( !pB )
319 : : {
320 : : OSL_ENSURE( pB, "WW8PLCFx_Book - Pointer nicht da" );
321 : 0 : return 0;
322 : : }
323 : :
324 [ + - ]: 12 : eBookStatus eB = pB->GetStatus();
325 [ - + ]: 12 : if (eB & BOOK_IGNORE)
326 : 0 : return 0; // Bookmark zu ignorieren
327 : :
328 [ + + ]: 12 : if (pB->GetIsEnd())
329 : : {
330 : 6 : pReffedStck->SetAttr(*pPaM->GetPoint(), RES_FLTR_BOOKMARK, true,
331 [ + - + - ]: 12 : pB->GetHandle(), (eB & BOOK_FIELD)!=0);
332 : 6 : return 0;
333 : : }
334 : :
335 : : //"_Toc*" and "_Hlt*" are unnecessary
336 [ + - ]: 6 : const String* pName = pB->GetName();
337 : : #if !defined(WW_NATIVE_TOC)
338 [ + - ][ + - ]: 12 : if( !pName || pName->EqualsIgnoreCaseAscii( "_Toc", 0, 4 )
[ + - ][ - + ]
[ - + ]
339 [ + - ]: 6 : || pName->EqualsIgnoreCaseAscii( "_Hlt", 0, 4 ) )
340 : 0 : return 0;
341 : : #endif
342 : :
343 : : //ToUpper darf auf keinen Fall gemacht werden, weil der Bookmark- name ein Hyperlink-Ziel sein kann!
344 : :
345 [ + - ]: 6 : String aVal;
346 [ - + ]: 6 : if( SwFltGetFlag( nFieldFlags, SwFltControlStack::BOOK_TO_VAR_REF ) )
347 : : {
348 : : // Fuer UEbersetzung Bookmark -> Variable setzen
349 [ # # ]: 0 : long nLen = pB->GetLen();
350 [ # # ]: 0 : if( nLen > MAX_FIELDLEN )
351 : 0 : nLen = MAX_FIELDLEN;
352 : :
353 : 0 : long nOldPos = pStrm->Tell();
354 : : nLen = pSBase->WW8ReadString( *pStrm, aVal, pB->GetStartPos(), nLen,
355 [ # # ]: 0 : eStructCharSet );
356 [ # # ]: 0 : pStrm->Seek( nOldPos );
357 : :
358 : : // now here the implementation of the old "QuoteString" and
359 : : // I hope with a better performance as before. It's also only
360 : : // needed if the filterflags say we will convert bookmarks
361 : : // to SetExpFields! And this the exception!
362 : :
363 : 0 : rtl::OUString sHex("\\x");
364 : : bool bSetAsHex;
365 : : bool bAllowCr = SwFltGetFlag(nFieldFlags,
366 : 0 : SwFltControlStack::ALLOW_FLD_CR) ? true : false;
367 : :
368 : : sal_Unicode cChar;
369 : :
370 [ # # # # ]: 0 : for( xub_StrLen nI = 0;
[ # # ]
371 : 0 : nI < aVal.Len() && aVal.Len() < (MAX_FIELDLEN - 4); ++nI )
372 : : {
373 [ # # # ]: 0 : switch( cChar = aVal.GetChar( nI ) )
374 : : {
375 : : case 0x0b:
376 : : case 0x0c:
377 : : case 0x0d:
378 [ # # ]: 0 : if( bAllowCr )
379 [ # # ]: 0 : aVal.SetChar( nI, '\n' ), bSetAsHex = false;
380 : : else
381 : 0 : bSetAsHex = true;
382 : 0 : break;
383 : :
384 : : case 0xFE:
385 : : case 0xFF:
386 : 0 : bSetAsHex = true;
387 : 0 : break;
388 : :
389 : : default:
390 : 0 : bSetAsHex = 0x20 > cChar;
391 : 0 : break;
392 : : }
393 : :
394 [ # # ]: 0 : if( bSetAsHex )
395 : : {
396 : : //all Hex-Numbers with \x before
397 [ # # ]: 0 : String sTmp( sHex );
398 [ # # ]: 0 : if( cChar < 0x10 )
399 [ # # ]: 0 : sTmp += '0';
400 [ # # ][ # # ]: 0 : sTmp += String::CreateFromInt32( cChar, 16 );
[ # # ]
401 [ # # ]: 0 : aVal.Replace( nI, 1 , sTmp );
402 [ # # ]: 0 : nI += sTmp.Len() - 1;
403 : : }
404 : : }
405 : :
406 [ # # ]: 0 : if( aVal.Len() > (MAX_FIELDLEN - 4))
407 [ # # ]: 0 : aVal.Erase( MAX_FIELDLEN - 4 );
408 : : }
409 : :
410 : : //e.g. inserting bookmark around field result, so we need to put
411 : : //it around the entire writer field, as we don't have the seperation
412 : : //of field and field result of word, see #i16941#
413 [ + - ]: 6 : SwPosition aStart(*pPaM->GetPoint());
414 [ - + ]: 6 : if (!maFieldStack.empty())
415 : : {
416 [ # # ]: 0 : const WW8FieldEntry &rTest = maFieldStack.back();
417 [ # # ][ # # ]: 0 : aStart = rTest.maStartPos;
[ # # ]
418 : : }
419 : :
420 : : pReffedStck->NewAttr(aStart, SwFltBookmark(BookmarkToWriter(*pName), aVal,
421 [ + - ][ + - ]: 6 : pB->GetHandle(), 0));
[ + - ][ + - ]
[ + - ][ + - ]
422 [ + - ][ + - ]: 12 : return 0;
423 : : }
424 : :
425 : : //----------------------------------------------------------------------
426 : : // allgemeine Hilfsroutinen zum Auseinanderdroeseln der Parameter
427 : : //----------------------------------------------------------------------
428 : :
429 : : // ConvertFFileName uebersetzt FeldParameter-Namen u. ae. in den
430 : : // System-Zeichensatz.
431 : : // Gleichzeitig werden doppelte Backslashes in einzelne uebersetzt.
432 : 6 : void SwWW8ImplReader::ConvertFFileName( String& rName, const String& rOrg )
433 : : {
434 : 6 : rName = rOrg;
435 [ + - ][ + - ]: 6 : rName.SearchAndReplaceAllAscii( "\\\\", rtl::OUString( '\\' ));
[ + - ]
436 [ + - ][ + - ]: 6 : rName.SearchAndReplaceAllAscii( "%20", rtl::OUString( ' ' ));
[ + - ]
437 : :
438 : : // ggfs. anhaengende Anfuehrungszeichen entfernen
439 [ - + ][ - + ]: 6 : if( rName.Len() && '"' == rName.GetChar( rName.Len()-1 ))
[ + - ]
440 : 0 : rName.Erase( rName.Len()-1, 1);
441 : :
442 : : // Need the more sophisticated url converter. cmc
443 [ + - ]: 6 : if (rName.Len())
444 : : rName = URIHelper::SmartRel2Abs(
445 [ + - ][ + - ]: 6 : INetURLObject(sBaseURL), rName, Link(), false);
[ + - ][ + - ]
[ + - ][ + - ]
446 : 6 : }
447 : :
448 : : // ConvertUFNneme uebersetzt FeldParameter-Namen u. ae. in den
449 : : // System-Zeichensatz und Upcased sie ( z.B. fuer Ref-Felder )
450 : : namespace
451 : : {
452 : 0 : void ConvertUFName( String& rName )
453 : : {
454 [ # # ][ # # ]: 0 : rName = GetAppCharClass().uppercase( rName );
[ # # ]
455 : 0 : }
456 : : }
457 : :
458 : 0 : static void lcl_ConvertSequenceName(String& rSequenceName)
459 : : {
460 : 0 : ConvertUFName(rSequenceName);
461 [ # # ][ # # ]: 0 : if ('0' <= rSequenceName.GetChar(0) && '9' >= rSequenceName.GetChar(0))
[ # # ]
462 : 0 : rSequenceName.Insert('_', 0);
463 : 0 : }
464 : :
465 : : // FindParaStart() finds 1st Parameter that follows '\' and cToken
466 : : // and returns start of this parameter or STRING_NOT_FOUND.
467 : 9 : xub_StrLen FindParaStart( const String& rStr, sal_Unicode cToken, sal_Unicode cToken2 )
468 : : {
469 : 9 : bool bStr = false; // innerhalb String ignorieren
470 : :
471 [ + + ]: 54 : for( xub_StrLen nBuf=0; nBuf+1 < rStr.Len(); nBuf++ )
472 : : {
473 [ - + ]: 45 : if( rStr.GetChar( nBuf ) == '"' )
474 : 0 : bStr = !bStr;
475 : :
476 [ + - - + : 90 : if( !bStr
# # # # ]
[ - + ]
477 : 45 : && rStr.GetChar( nBuf ) == '\\'
478 : 0 : && ( rStr.GetChar( nBuf + 1 ) == cToken
479 : 0 : || rStr.GetChar( nBuf + 1 ) == cToken2 ) )
480 : : {
481 : 0 : nBuf += 2;
482 : : // skip spaces between cToken and it's parameters
483 [ # # # # ]: 0 : while( nBuf < rStr.Len()
[ # # ]
484 : 0 : && rStr.GetChar( nBuf ) == ' ' )
485 : 0 : nBuf++;
486 : : // return start of parameters
487 [ # # ]: 0 : return nBuf < rStr.Len() ? nBuf : STRING_NOTFOUND;
488 : : }
489 : : }
490 : 9 : return STRING_NOTFOUND;
491 : : }
492 : :
493 : : // FindPara() findet den ersten Parameter mit '\' und cToken. Es wird
494 : : // ein neuer String allokiert ( der vom Aufrufer deallokiert werden muss )
495 : : // und alles, was zum Parameter gehoert, wird in ihm zurueckgeliefert.
496 : 9 : String FindPara( const String& rStr, sal_Unicode cToken, sal_Unicode cToken2 )
497 : : {
498 : : xub_StrLen n2; // Ende
499 : 9 : xub_StrLen n = FindParaStart( rStr, cToken, cToken2 ); // Anfang
500 [ + - ]: 9 : if( STRING_NOTFOUND == n )
501 : 9 : return aEmptyStr;
502 : :
503 [ # # # # ]: 0 : if( rStr.GetChar( n ) == '"'
[ # # ]
504 : 0 : || rStr.GetChar( n ) == 132 )
505 : : { // Anfuehrungszeichen vor Para
506 : 0 : n++; // Anfuehrungszeichen ueberlesen
507 : 0 : n2 = n; // ab hier nach Ende suchen
508 [ # # # # : 0 : while( n2 < rStr.Len()
# # ][ # # ]
509 : 0 : && rStr.GetChar( n2 ) != 147
510 : 0 : && rStr.GetChar( n2 ) != '"' )
511 : 0 : n2++; // Ende d. Paras suchen
512 : : }
513 : : else
514 : : { // keine Anfuehrungszeichen
515 : 0 : n2 = n; // ab hier nach Ende suchen
516 [ # # # # ]: 0 : while( n2 < rStr.Len()
[ # # ]
517 : 0 : && rStr.GetChar( n2 ) != ' ' )
518 : 0 : n2++; // Ende d. Paras suchen
519 : : }
520 : 9 : return rStr.Copy( n, n2-n );
521 : : }
522 : :
523 : :
524 : 9 : static SvxExtNumType GetNumTypeFromName(const String& rStr,
525 : : bool bAllowPageDesc = false)
526 : : {
527 [ + - ]: 9 : SvxExtNumType eTyp = bAllowPageDesc ? SVX_NUM_PAGEDESC : SVX_NUM_ARABIC;
528 [ - + ]: 9 : if( rStr.EqualsIgnoreCaseAscii( "Arabi", 0, 5 ) ) // Arabisch, Arabic
529 : 0 : eTyp = SVX_NUM_ARABIC;
530 [ - + ]: 9 : else if( rStr.EqualsAscii( "misch", 2, 5 ) ) // r"omisch
531 : 0 : eTyp = SVX_NUM_ROMAN_LOWER;
532 [ - + ]: 9 : else if( rStr.EqualsAscii( "MISCH", 2, 5 ) ) // R"OMISCH
533 : 0 : eTyp = SVX_NUM_ROMAN_UPPER;
534 [ - + ]: 9 : else if( rStr.EqualsIgnoreCaseAscii( "alphabeti", 0, 9 ) )// alphabetisch, alphabetic
535 : 0 : eTyp = ( rStr.GetChar( 0 ) == 'A' )
536 : : ? SVX_NUM_CHARS_UPPER_LETTER_N
537 [ # # ]: 0 : : SVX_NUM_CHARS_LOWER_LETTER_N;
538 [ - + ]: 9 : else if( rStr.EqualsIgnoreCaseAscii( "roman", 0, 5 ) ) // us
539 : 0 : eTyp = ( rStr.GetChar( 0 ) == 'R' )
540 : : ? SVX_NUM_ROMAN_UPPER
541 [ # # ]: 0 : : SVX_NUM_ROMAN_LOWER;
542 : 9 : return eTyp;
543 : : }
544 : :
545 : 9 : static SvxExtNumType GetNumberPara(String& rStr, bool bAllowPageDesc = false)
546 : : {
547 [ + - ]: 9 : String s( FindPara( rStr, '*', '*' ) ); // Ziffernart
548 [ + - ]: 9 : SvxExtNumType aType = GetNumTypeFromName( s, bAllowPageDesc );
549 [ + - ]: 9 : return aType;
550 : : }
551 : :
552 : :
553 : :
554 : :
555 : 0 : bool SwWW8ImplReader::ForceFieldLanguage(SwField &rFld, sal_uInt16 nLang)
556 : : {
557 : 0 : bool bRet(false);
558 : :
559 : : const SvxLanguageItem *pLang =
560 : 0 : (const SvxLanguageItem*)GetFmtAttr(RES_CHRATR_LANGUAGE);
561 : : OSL_ENSURE(pLang, "impossible");
562 [ # # ]: 0 : sal_uInt16 nDefault = pLang ? pLang->GetValue() : LANGUAGE_ENGLISH_US;
563 : :
564 [ # # ]: 0 : if (nLang != nDefault)
565 : : {
566 : 0 : rFld.SetAutomaticLanguage(false);
567 : 0 : rFld.SetLanguage(nLang);
568 : 0 : bRet = true;
569 : : }
570 : :
571 : 0 : return bRet;
572 : : }
573 : :
574 : 0 : String GetWordDefaultDateStringAsUS(SvNumberFormatter* pFormatter, sal_uInt16 nLang)
575 : : {
576 : : //Get the system date in the correct final language layout, convert to
577 : : //a known language and modify the 2 digit year part to be 4 digit, and
578 : : //convert back to the correct language layout.
579 [ # # ]: 0 : sal_uLong nIndex = pFormatter->GetFormatIndex(NF_DATE_SYSTEM_SHORT, nLang);
580 : :
581 : : SvNumberformat aFormat = const_cast<SvNumberformat &>
582 [ # # ][ # # ]: 0 : (*(pFormatter->GetEntry(nIndex)));
583 [ # # ]: 0 : aFormat.ConvertLanguage(*pFormatter, nLang, LANGUAGE_ENGLISH_US);
584 : :
585 [ # # ]: 0 : String sParams(aFormat.GetFormatstring());
586 : : // #i36594#
587 : : // Fix provided by mloiseleur@openoffice.org.
588 : : // A default date can have already 4 year digits, in some case
589 [ # # ][ # # ]: 0 : const xub_StrLen pos = sParams.Search(rtl::OUString("YYYY"));
[ # # ]
590 [ # # ]: 0 : if ( pos == STRING_NOTFOUND )
591 : : {
592 [ # # ][ # # ]: 0 : sParams.SearchAndReplace(rtl::OUString("YY"), rtl::OUString("YYYY"));
[ # # ][ # # ]
[ # # ]
593 : : }
594 [ # # ]: 0 : return sParams;
595 : : }
596 : :
597 : 0 : short SwWW8ImplReader::GetTimeDatePara(String& rStr, sal_uInt32& rFormat,
598 : : sal_uInt16 &rLang, int nWhichDefault, bool bHijri)
599 : : {
600 : 0 : bool bRTL = false;
601 [ # # ][ # # ]: 0 : if (pPlcxMan && !bVer67)
602 : : {
603 [ # # ]: 0 : const sal_uInt8 *pResult = pPlcxMan->HasCharSprm(0x85A);
604 [ # # ][ # # ]: 0 : if (pResult && *pResult)
605 : 0 : bRTL = true;
606 : : }
607 [ # # ]: 0 : RES_CHRATR eLang = bRTL ? RES_CHRATR_CTL_LANGUAGE : RES_CHRATR_LANGUAGE;
608 [ # # ]: 0 : const SvxLanguageItem *pLang = (SvxLanguageItem*)GetFmtAttr( static_cast< sal_uInt16 >(eLang));
609 : : OSL_ENSURE(pLang, "impossible");
610 [ # # ]: 0 : rLang = pLang ? pLang->GetValue() : LANGUAGE_ENGLISH_US;
611 : :
612 [ # # ]: 0 : SvNumberFormatter* pFormatter = rDoc.GetNumberFormatter();
613 [ # # ]: 0 : String sParams( FindPara( rStr, '@', '@' ) );// Date/Time
614 [ # # ]: 0 : if (!sParams.Len())
615 : : {
616 : 0 : bool bHasTime = false;
617 [ # # # ]: 0 : switch (nWhichDefault)
618 : : {
619 : : case ww::ePRINTDATE:
620 : : case ww::eSAVEDATE:
621 [ # # ][ # # ]: 0 : sParams = GetWordDefaultDateStringAsUS(pFormatter, rLang);
[ # # ]
622 [ # # ]: 0 : sParams.APPEND_CONST_ASC(" HH:MM:SS AM/PM");
623 : 0 : bHasTime = true;
624 : 0 : break;
625 : : case ww::eCREATEDATE:
626 [ # # ]: 0 : sParams.ASSIGN_CONST_ASC("DD/MM/YYYY HH:MM:SS");
627 : 0 : bHasTime = true;
628 : 0 : break;
629 : : default:
630 : : case ww::eDATE:
631 [ # # ][ # # ]: 0 : sParams = GetWordDefaultDateStringAsUS(pFormatter, rLang);
[ # # ]
632 : 0 : break;
633 : : }
634 : :
635 [ # # ]: 0 : if (bHijri)
636 [ # # ][ # # ]: 0 : sParams.Insert(rtl::OUString("[~hijri]"), 0);
[ # # ]
637 : :
638 : 0 : sal_uInt16 nCheckPos = 0;
639 : 0 : sal_Int16 nType = NUMBERFORMAT_DEFINED;
640 : 0 : rFormat = 0;
641 : :
642 : : pFormatter->PutandConvertEntry(sParams, nCheckPos, nType, rFormat,
643 [ # # ]: 0 : LANGUAGE_ENGLISH_US, rLang);
644 : :
645 [ # # ]: 0 : return bHasTime ? NUMBERFORMAT_DATETIME : NUMBERFORMAT_DATE;
646 : : }
647 : :
648 : : sal_uLong nFmtIdx =
649 : : sw::ms::MSDateTimeFormatToSwFormat(sParams, pFormatter, rLang, bHijri,
650 [ # # ]: 0 : GetFib().lid);
651 : 0 : short nNumFmtType = NUMBERFORMAT_UNDEFINED;
652 [ # # ]: 0 : if (nFmtIdx)
653 [ # # ]: 0 : nNumFmtType = pFormatter->GetType(nFmtIdx);
654 : 0 : rFormat = nFmtIdx;
655 : :
656 [ # # ]: 0 : return nNumFmtType;
657 : : }
658 : :
659 : : //-----------------------------------------
660 : : // Felder
661 : : //-----------------------------------------
662 : : // Am Ende des Einlesens entsprechende Felder updaten ( z.Zt. die Referenzen )
663 : 102 : void SwWW8ImplReader::UpdateFields()
664 : : {
665 : 102 : rDoc.SetUpdateExpFldStat(true); // JP: neu fuer alles wichtige
666 : 102 : rDoc.SetInitDBFields(true); // Datenbank-Felder auch
667 : 102 : }
668 : :
669 : 42 : sal_uInt16 SwWW8ImplReader::End_Field()
670 : : {
671 : 42 : sal_uInt16 nRet = 0;
672 : 42 : WW8PLCFx_FLD* pF = pPlcxMan->GetFld();
673 : : OSL_ENSURE(pF, "WW8PLCFx_FLD - Pointer nicht da");
674 [ + + ][ + + ]: 42 : if (!pF || !pF->EndPosIsFieldEnd())
[ + - ]
675 : 21 : return nRet;
676 : :
677 : 21 : const SvtFilterOptions &rOpt = SvtFilterOptions::Get();
678 : 21 : sal_Bool bUseEnhFields = rOpt.IsUseEnhancedFields();
679 : :
680 : : OSL_ENSURE(!maFieldStack.empty(), "Empty field stack\n");
681 [ + - ]: 21 : if (!maFieldStack.empty())
682 : : {
683 : : /*
684 : : only hyperlinks currently need to be handled like this, for the other
685 : : cases we have inserted a field not an attribute with an unknown end
686 : : point
687 : : */
688 : 21 : nRet = maFieldStack.back().mnFieldId;
689 [ - + - + ]: 21 : switch (nRet)
690 : : {
691 : : case 70:
692 [ # # ][ # # ]: 0 : if (bUseEnhFields && pPaM!=NULL && pPaM->GetPoint()!=NULL) {
[ # # ][ # # ]
693 [ # # ]: 0 : SwPosition aEndPos = *pPaM->GetPoint();
694 [ # # ][ # # ]: 0 : SwPaM aFldPam( maFieldStack.back().GetPtNode(), maFieldStack.back().GetPtCntnt(), aEndPos.nNode, aEndPos.nContent.GetIndex());
[ # # ][ # # ]
[ # # ]
695 [ # # ]: 0 : IDocumentMarkAccess* pMarksAccess = rDoc.getIDocumentMarkAccess( );
696 : : IFieldmark *pFieldmark = dynamic_cast<IFieldmark*>( pMarksAccess->makeFieldBookmark(
697 [ # # ][ # # ]: 0 : aFldPam, maFieldStack.back().GetBookmarkName(), ODF_FORMTEXT ) );
698 : : OSL_ENSURE(pFieldmark!=NULL, "hmmm; why was the bookmark not created?");
699 [ # # ]: 0 : if (pFieldmark!=NULL) {
700 [ # # ]: 0 : const IFieldmark::parameter_map_t& pParametersToAdd = maFieldStack.back().getParameters();
701 [ # # ][ # # ]: 0 : pFieldmark->GetParameters()->insert(pParametersToAdd.begin(), pParametersToAdd.end());
702 [ # # ][ # # ]: 0 : }
703 : : }
704 : : break;
705 : : #if defined(WW_NATIVE_TOC)
706 : : case 8: // TOX_INDEX
707 : : case 13: // TOX_CONTENT
708 : : case 88: // HYPERLINK
709 : : case 37: // REF
710 : : if (pPaM!=NULL && pPaM->GetPoint()!=NULL) {
711 : :
712 : : SwPosition aEndPos = *pPaM->GetPoint();
713 : : SwPaM aFldPam( maFieldStack.back().GetPtNode(), maFieldStack.back().GetPtCntnt(), aEndPos.nNode, aEndPos.nContent.GetIndex());
714 : : SwFieldBookmark *pFieldmark=(SwFieldBookmark*)rDoc.makeFieldBookmark(aFldPam, maFieldStack.back().GetBookmarkName(), maFieldStack.back().GetBookmarkType());
715 : : OSL_ENSURE(pFieldmark!=NULL, "hmmm; why was the bookmark not created?");
716 : : if (pFieldmark!=NULL) {
717 : : const IFieldmark::parameter_map_t& pParametersToAdd = maFieldStack.back().getParameters();
718 : : pFieldmark->GetParameters()->insert(pParameters.begin(), pParameters.end());
719 : : }
720 : : }
721 : : break;
722 : : #else
723 : : case 88:
724 [ + - ]: 9 : pCtrlStck->SetAttr(*pPaM->GetPoint(),RES_TXTATR_INETFMT);
725 : : break;
726 : : #endif
727 : : case 36:
728 : : case 68:
729 : : //Move outside the section associated with this type of field
730 [ # # ][ # # ]: 0 : *pPaM->GetPoint() = maFieldStack.back().maStartPos;
[ # # ][ # # ]
731 : : break;
732 : : default:
733 [ + - ]: 12 : rtl::OUString aCode = maFieldStack.back().GetBookmarkCode();
734 [ - + ]: 12 : if ( !aCode.isEmpty() )
735 : : {
736 : : // Unhandled field with stored code
737 [ # # ]: 0 : SwPosition aEndPos = *pPaM->GetPoint();
738 : : SwPaM aFldPam(
739 [ # # ][ # # ]: 0 : maFieldStack.back().GetPtNode(), maFieldStack.back().GetPtCntnt(),
740 [ # # ][ # # ]: 0 : aEndPos.nNode, aEndPos.nContent.GetIndex());
[ # # ]
741 : :
742 [ # # ]: 0 : IDocumentMarkAccess* pMarksAccess = rDoc.getIDocumentMarkAccess( );
743 : :
744 : : IFieldmark* pFieldmark = pMarksAccess->makeFieldBookmark(
745 : : aFldPam,
746 [ # # ]: 0 : maFieldStack.back().GetBookmarkName(),
747 [ # # ]: 0 : ODF_UNHANDLED );
748 [ # # ]: 0 : if ( pFieldmark )
749 : : {
750 [ # # ]: 0 : const IFieldmark::parameter_map_t& pParametersToAdd = maFieldStack.back().getParameters();
751 [ # # ][ # # ]: 0 : pFieldmark->GetParameters()->insert(pParametersToAdd.begin(), pParametersToAdd.end());
752 [ # # ]: 0 : rtl::OUString sFieldId = rtl::OUString::valueOf( sal_Int32( maFieldStack.back().mnFieldId ) );
753 : 0 : pFieldmark->GetParameters()->insert(
754 : : std::pair< rtl::OUString, uno::Any > (
755 : : ODF_ID_PARAM,
756 [ # # ][ # # ]: 0 : uno::makeAny( sFieldId ) ) );
[ # # ][ # # ]
757 : 0 : pFieldmark->GetParameters()->insert(
758 : : std::pair< rtl::OUString, uno::Any > (
759 : : ODF_CODE_PARAM,
760 [ # # ][ # # ]: 0 : uno::makeAny( aCode ) ) );
[ # # ][ # # ]
761 : :
762 [ # # ][ # # ]: 0 : if ( maFieldStack.back().mnObjLocFc > 0 )
763 : : {
764 : : // Store the OLE object as an internal link
765 [ # # ]: 0 : String sOleId = rtl::OUString('_');
766 [ # # ][ # # ]: 0 : sOleId += String::CreateFromInt32( maFieldStack.back().mnObjLocFc );
[ # # ][ # # ]
767 : :
768 [ # # ][ # # ]: 0 : SvStorageRef xSrc0 = pStg->OpenSotStorage(rtl::OUString(SL::aObjectPool));
[ # # ]
769 [ # # ]: 0 : SvStorageRef xSrc1 = xSrc0->OpenSotStorage( sOleId, STREAM_READ );
770 : :
771 : : // Store it now!
772 [ # # ]: 0 : uno::Reference< embed::XStorage > xDocStg = GetDoc().GetDocStorage();
773 [ # # ]: 0 : if (xDocStg.is())
774 : : {
775 [ # # ]: 0 : uno::Reference< embed::XStorage > xOleStg = xDocStg->openStorageElement(
776 [ # # ]: 0 : "OLELinks", embed::ElementModes::WRITE );
777 [ # # ]: 0 : SotStorageRef xObjDst = SotStorage::OpenOLEStorage( xOleStg, sOleId );
778 : :
779 [ # # ]: 0 : if ( xObjDst.Is() )
780 : : {
781 [ # # ]: 0 : xSrc1->CopyTo( xObjDst );
782 : :
783 [ # # ]: 0 : if ( !xObjDst->GetError() )
784 [ # # ]: 0 : xObjDst->Commit();
785 : : }
786 : :
787 [ # # ]: 0 : uno::Reference< embed::XTransactedObject > xTransact( xOleStg, uno::UNO_QUERY );
788 [ # # ]: 0 : if ( xTransact.is() )
789 [ # # ][ # # ]: 0 : xTransact->commit();
[ # # ]
790 : : }
791 : :
792 : : // Store the OLE Id as a parameter
793 : 0 : pFieldmark->GetParameters()->insert(
794 : : std::pair< rtl::OUString, uno::Any >(
795 [ # # ][ # # ]: 0 : ODF_OLE_PARAM, uno::makeAny( rtl::OUString( sOleId ) ) ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
796 : 0 : }
797 : :
798 [ # # ][ # # ]: 0 : }
799 : : }
800 : :
801 : 12 : break;
802 : : }
803 : 21 : maFieldStack.pop_back();
804 : : }
805 : 42 : return nRet;
806 : : }
807 : :
808 : 0 : bool AcceptableNestedField(sal_uInt16 nFieldCode)
809 : : {
810 [ # # ]: 0 : switch (nFieldCode)
811 : : {
812 : : #if defined(WW_NATIVE_TOC)
813 : : case 8: // allow recursive field in TOC...
814 : : case 13: // allow recursive field in TOC...
815 : : #endif
816 : : case 36:
817 : : case 68:
818 : : case 79:
819 : : case 88:
820 : : // Accept AutoTextList field as nested field.
821 : : // Thus, the field result is imported as plain text.
822 : : case 89:
823 : 0 : return true;
824 : : default:
825 : 0 : return false;
826 : : }
827 : : }
828 : :
829 : 21 : WW8FieldEntry::WW8FieldEntry(SwPosition &rPos, sal_uInt16 nFieldId) throw()
830 [ + - ][ + - ]: 21 : : maStartPos(rPos), mnFieldId(nFieldId), mnObjLocFc(0)
831 : : {
832 : 21 : }
833 : :
834 : 21 : WW8FieldEntry::WW8FieldEntry(const WW8FieldEntry &rOther) throw()
835 [ + - ][ + - ]: 21 : : maStartPos(rOther.maStartPos), mnFieldId(rOther.mnFieldId), mnObjLocFc(rOther.mnObjLocFc)
836 : : {
837 : 21 : }
838 : :
839 : 0 : void WW8FieldEntry::Swap(WW8FieldEntry &rOther) throw()
840 : : {
841 : 0 : std::swap(maStartPos, rOther.maStartPos);
842 : 0 : std::swap(mnFieldId, rOther.mnFieldId);
843 : 0 : }
844 : :
845 : 0 : WW8FieldEntry &WW8FieldEntry::operator=(const WW8FieldEntry &rOther) throw()
846 : : {
847 : 0 : WW8FieldEntry aTemp(rOther);
848 : 0 : Swap(aTemp);
849 [ # # ]: 0 : return *this;
850 : : }
851 : :
852 : 0 : ::rtl::OUString WW8FieldEntry::GetBookmarkName()
853 : : {
854 : 0 : return msBookmarkName;
855 : : }
856 : :
857 : 12 : ::rtl::OUString WW8FieldEntry::GetBookmarkCode()
858 : : {
859 : 12 : return msMarkCode;
860 : : }
861 : :
862 : 0 : void WW8FieldEntry::SetBookmarkName(::rtl::OUString bookmarkName)
863 : : {
864 : 0 : msBookmarkName=bookmarkName;
865 : 0 : }
866 : :
867 : 0 : void WW8FieldEntry::SetBookmarkType(::rtl::OUString bookmarkType)
868 : : {
869 : 0 : msMarkType=bookmarkType;
870 : 0 : }
871 : :
872 : 0 : void WW8FieldEntry::SetBookmarkCode(::rtl::OUString bookmarkCode)
873 : : {
874 : 0 : msMarkCode = bookmarkCode;
875 : 0 : }
876 : :
877 : :
878 : 0 : ::sw::mark::IFieldmark::parameter_map_t& WW8FieldEntry::getParameters() {
879 : 0 : return maParams;
880 : : }
881 : :
882 : :
883 : : // Read_Field liest ein Feld ein oder, wenn es nicht gelesen werden kann,
884 : : // wird 0 zurueckgegeben, so dass das Feld vom Aufrufer textuell gelesen wird.
885 : : // Returnwert: Gesamtlaenge des Feldes ( zum UEberlesen )
886 : 42 : long SwWW8ImplReader::Read_Field(WW8PLCFManResult* pRes)
887 : : {
888 : : typedef eF_ResT (SwWW8ImplReader:: *FNReadField)( WW8FieldDesc*, String& );
889 : : enum Limits {eMax = 96};
890 : : static FNReadField aWW8FieldTab[eMax+1] =
891 : : {
892 : : 0,
893 : : &SwWW8ImplReader::Read_F_Input,
894 : : 0,
895 : : &SwWW8ImplReader::Read_F_Ref, // 3
896 : : 0,
897 : : 0,
898 : : &SwWW8ImplReader::Read_F_Set, // 6
899 : : 0,
900 : : &SwWW8ImplReader::Read_F_Tox, // 8
901 : : 0,
902 : : 0,
903 : : 0,
904 : : &SwWW8ImplReader::Read_F_Seq, // 12
905 : : &SwWW8ImplReader::Read_F_Tox, // 13
906 : : &SwWW8ImplReader::Read_F_DocInfo, // 14
907 : : &SwWW8ImplReader::Read_F_DocInfo, // 15
908 : : &SwWW8ImplReader::Read_F_DocInfo, // 16
909 : : &SwWW8ImplReader::Read_F_Author, // 17
910 : : &SwWW8ImplReader::Read_F_DocInfo, // 18
911 : : &SwWW8ImplReader::Read_F_DocInfo, // 19
912 : : &SwWW8ImplReader::Read_F_DocInfo, // 20
913 : : &SwWW8ImplReader::Read_F_DocInfo, // 21
914 : : &SwWW8ImplReader::Read_F_DocInfo, // 22
915 : : &SwWW8ImplReader::Read_F_DocInfo, // 23
916 : : &SwWW8ImplReader::Read_F_DocInfo, // 24
917 : : &SwWW8ImplReader::Read_F_DocInfo, // 25
918 : : &SwWW8ImplReader::Read_F_Anz, // 26
919 : : &SwWW8ImplReader::Read_F_Anz, // 27
920 : : &SwWW8ImplReader::Read_F_Anz, // 28
921 : : &SwWW8ImplReader::Read_F_FileName, // 29
922 : : &SwWW8ImplReader::Read_F_TemplName, // 30
923 : : &SwWW8ImplReader::Read_F_DateTime, // 31
924 : : &SwWW8ImplReader::Read_F_DateTime, // 32
925 : : &SwWW8ImplReader::Read_F_CurPage, // 33
926 : : 0,
927 : : 0,
928 : : &SwWW8ImplReader::Read_F_IncludeText, // 36
929 : : &SwWW8ImplReader::Read_F_PgRef, // 37
930 : : &SwWW8ImplReader::Read_F_InputVar, // 38
931 : : &SwWW8ImplReader::Read_F_Input, // 39
932 : : 0,
933 : : &SwWW8ImplReader::Read_F_DBNext, // 41
934 : : 0,
935 : : 0,
936 : : &SwWW8ImplReader::Read_F_DBNum, // 44
937 : : 0,
938 : : 0,
939 : : 0,
940 : : 0,
941 : : &SwWW8ImplReader::Read_F_Equation, // 49
942 : : 0,
943 : : &SwWW8ImplReader::Read_F_Macro, // 51
944 : : &SwWW8ImplReader::Read_F_ANumber, // 52
945 : : &SwWW8ImplReader::Read_F_ANumber, // 53
946 : : &SwWW8ImplReader::Read_F_ANumber, // 54
947 : : 0,
948 : :
949 : :
950 : : 0, // 56
951 : :
952 : :
953 : : &SwWW8ImplReader::Read_F_Symbol, // 57
954 : : &SwWW8ImplReader::Read_F_Embedd, // 58
955 : : &SwWW8ImplReader::Read_F_DBField, // 59
956 : : 0,
957 : : 0,
958 : : 0,
959 : : 0,
960 : : &SwWW8ImplReader::Read_F_DocInfo, // 64 - DOCVARIABLE
961 : : 0,
962 : : 0,
963 : : &SwWW8ImplReader::Read_F_IncludePicture, // 67
964 : : &SwWW8ImplReader::Read_F_IncludeText, // 68
965 : : 0,
966 : : &SwWW8ImplReader::Read_F_FormTextBox, // 70
967 : : &SwWW8ImplReader::Read_F_FormCheckBox, // 71
968 : : &SwWW8ImplReader::Read_F_NoteReference, // 72
969 : : 0, /*&SwWW8ImplReader::Read_F_Tox*/
970 : : 0,
971 : : 0,
972 : : 0,
973 : : 0,
974 : : 0,
975 : : 0,
976 : : 0,
977 : : 0,
978 : : 0,
979 : : &SwWW8ImplReader::Read_F_FormListBox, // 83
980 : : 0, // 84
981 : : &SwWW8ImplReader::Read_F_DocInfo, // 85
982 : : 0, // 86
983 : : &SwWW8ImplReader::Read_F_OCX, // 87
984 : : &SwWW8ImplReader::Read_F_Hyperlink, // 88
985 : : 0, // 89
986 : : 0, // 90
987 : : &SwWW8ImplReader::Read_F_HTMLControl, // 91
988 : : 0, // 92
989 : : 0, // 93
990 : : 0, // 94
991 : : &SwWW8ImplReader::Read_F_Shape, // 95
992 : : 0 // eMax - Dummy leer Methode
993 : : };
994 : : OSL_ENSURE( ( sizeof( aWW8FieldTab ) / sizeof( *aWW8FieldTab ) == eMax+1 ),
995 : : "FeldFunc-Tabelle stimmt nicht" );
996 : :
997 [ + - ]: 42 : WW8PLCFx_FLD* pF = pPlcxMan->GetFld();
998 : : OSL_ENSURE(pF, "WW8PLCFx_FLD - Pointer nicht da");
999 : :
1000 [ + - ][ + - ]: 42 : if (!pF || !pF->StartPosIsFieldStart())
[ + + ][ + + ]
1001 : 21 : return 0;
1002 : :
1003 : 21 : bool bNested = false;
1004 [ - + ]: 21 : if (!maFieldStack.empty())
1005 : : {
1006 : 0 : mycFieldIter aEnd = maFieldStack.end();
1007 [ # # ][ # # ]: 0 : for(mycFieldIter aIter = maFieldStack.begin(); aIter != aEnd; ++aIter)
[ # # ]
1008 : : {
1009 : 0 : bNested = !AcceptableNestedField(aIter->mnFieldId);
1010 [ # # ]: 0 : if (bNested)
1011 : 0 : break;
1012 : : }
1013 : : }
1014 : :
1015 : : WW8FieldDesc aF;
1016 [ + - ]: 21 : bool bOk = pF->GetPara(pRes->nCp2OrIdx, aF);
1017 : :
1018 : : OSL_ENSURE(bOk, "WW8: Bad Field!\n");
1019 [ + + ]: 21 : if (aF.nId == 33) aF.bCodeNest=false; // do not recurse into nested page fields
1020 : 21 : bool bCodeNest = aF.bCodeNest;
1021 [ - + ]: 21 : if ( aF.nId == 6 ) bCodeNest = false; // We can handle them and loose the inner data
1022 : :
1023 [ + - ][ + - ]: 21 : maFieldStack.push_back(WW8FieldEntry(*pPaM->GetPoint(), aF.nId));
1024 : :
1025 [ - + ]: 21 : if (bNested)
1026 : 0 : return 0;
1027 : :
1028 : 21 : sal_uInt16 n = (aF.nId <= eMax) ? aF.nId : static_cast<sal_uInt16>(eMax);
1029 : 21 : sal_uInt16 nI = n / 32; // # des sal_uInt32
1030 : 21 : sal_uLong nMask = 1 << ( n % 32 ); // Maske fuer Bits
1031 : :
1032 [ - + ]: 21 : if ((sizeof(nFieldTagAlways)/sizeof(nFieldTagAlways[0])) <= nI)
1033 : : { // if indexes larger than 95 are needed, then a new configuration
1034 : : // item has to be added, and nFieldTagAlways/nFieldTagBad expanded!
1035 : 0 : return aF.nLen;
1036 : : }
1037 : :
1038 [ - + ]: 21 : if( nFieldTagAlways[nI] & nMask ) // Flag: Tag it
1039 [ # # ]: 0 : return Read_F_Tag( &aF ); // Resultat nicht als Text
1040 : :
1041 [ + - ][ - + ]: 21 : if( !bOk || !aF.nId ) // Feld kaputt
1042 : 0 : return aF.nLen; // -> ignorieren
1043 : :
1044 [ - + ]: 21 : if( aF.nId > eMax - 1) // WW: Nested Field
1045 : : {
1046 [ # # ]: 0 : if( nFieldTagBad[nI] & nMask ) // Flag: Tag it when bad
1047 [ # # ]: 0 : return Read_F_Tag( &aF ); // Resultat nicht als Text
1048 : : else
1049 : 0 : return aF.nLen;
1050 : : }
1051 : :
1052 : : //Only one type of field (hyperlink) in drawing textboxes exists
1053 [ + + ][ + - ]: 21 : if (aF.nId != 88 && pPlcxMan && pPlcxMan->GetDoingDrawTextBox())
[ - + ][ - + ]
1054 : 0 : return aF.nLen;
1055 : :
1056 : : // keine Routine vorhanden
1057 [ + - ][ + - ]: 21 : if (bNested || !aWW8FieldTab[aF.nId] || bCodeNest)
[ - + ]
1058 : : {
1059 [ # # ]: 0 : if( nFieldTagBad[nI] & nMask ) // Flag: Tag it when bad
1060 [ # # ]: 0 : return Read_F_Tag( &aF ); // Resultat nicht als Text
1061 : : // Lese nur Resultat
1062 [ # # ][ # # ]: 0 : if (aF.bResNest && !AcceptableNestedField(aF.nId))
[ # # ]
1063 : 0 : return aF.nLen; // Result nested -> nicht brauchbar
1064 : :
1065 : 0 : long nOldPos = pStrm->Tell();
1066 [ # # ]: 0 : String aStr;
1067 : 0 : aF.nLCode = pSBase->WW8ReadString( *pStrm, aStr, pPlcxMan->GetCpOfs()+
1068 [ # # ]: 0 : aF.nSCode, aF.nLCode, eTextCharSet );
1069 [ # # ]: 0 : pStrm->Seek( nOldPos );
1070 : :
1071 : : // field codes which contain '/' or '.' are not displayed in WinWord
1072 [ # # ]: 0 : xub_StrLen nSpacePos = aStr.Search( ' ', 1 );
1073 [ # # ]: 0 : if ( STRING_NOTFOUND == nSpacePos )
1074 : 0 : nSpacePos = aStr.Len( );
1075 : 0 : xub_StrLen nSearchPos = STRING_NOTFOUND;
1076 [ # # ][ # # ]: 0 : if ( !( aStr.EqualsAscii( "=", 1, 1 ) ) && (
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1077 : : ( ( nSearchPos = aStr.Search('.') ) != STRING_NOTFOUND && nSearchPos < nSpacePos ) ||
1078 : : ( ( nSearchPos = aStr.Search('/') ) != STRING_NOTFOUND && nSearchPos < nSpacePos ) ) )
1079 : 0 : return aF.nLen;
1080 : : else
1081 : : {
1082 : : // Link fields aren't supported, but they are bound to an OLE object
1083 : : // that needs to be roundtripped
1084 [ # # ]: 0 : if ( aF.nId == 56 )
1085 : 0 : bEmbeddObj = true;
1086 : : // Field not supported: store the field code for later use
1087 [ # # ][ # # ]: 0 : maFieldStack.back().SetBookmarkCode( aStr );
1088 : 0 : return aF.nLen - aF.nLRes - 1; // so viele ueberlesen, das Resultfeld
1089 : : // wird wie Haupttext eingelesen
1090 [ # # ]: 0 : }
1091 : : }
1092 : : else
1093 : : { // Lies Feld
1094 : 21 : long nOldPos = pStrm->Tell();
1095 [ + - ]: 21 : String aStr;
1096 [ - + ][ # # ]: 21 : if ( aF.nId == 6 && aF.bCodeNest )
1097 : : {
1098 : : // TODO Extract the whole code string using the nested codes
1099 : 0 : aF.nLCode = pSBase->WW8ReadString( *pStrm, aStr, pPlcxMan->GetCpOfs() +
1100 [ # # ]: 0 : aF.nSCode, aF.nSRes - aF.nSCode - 1, eTextCharSet );
1101 : : }
1102 : : else
1103 : : {
1104 : 21 : aF.nLCode = pSBase->WW8ReadString( *pStrm, aStr, pPlcxMan->GetCpOfs()+
1105 [ + - ]: 21 : aF.nSCode, aF.nLCode, eTextCharSet );
1106 : : }
1107 : :
1108 : : // #i51312# - graphics inside field code not supported by Writer.
1109 : : // Thus, delete character 0x01, which stands for such a graphic.
1110 [ - + ]: 21 : if (aF.nId==51) //#i56768# only do it for the MACROBUTTON field, since DropListFields need the 0x01.
1111 : : {
1112 [ # # ][ # # ]: 0 : aStr = comphelper::string::remove(aStr, 0x01);
1113 : : }
1114 : :
1115 [ + - ][ + - ]: 21 : eF_ResT eRes = (this->*aWW8FieldTab[aF.nId])( &aF, aStr );
1116 [ + - ]: 21 : pStrm->Seek( nOldPos );
1117 : :
1118 [ + - + - : 21 : switch ( eRes )
- - ]
1119 : : {
1120 : : case FLD_OK:
1121 : 9 : return aF.nLen; // alles OK
1122 : : case FLD_TAGTXT:
1123 [ # # ]: 0 : if ((nFieldTagBad[nI] & nMask)) // Flag: Tag bad
1124 [ # # ]: 0 : return Read_F_Tag(&aF); // Taggen
1125 : : //fall through...
1126 : : case FLD_TEXT:
1127 : : // so viele ueberlesen, das Resultfeld wird wie Haupttext
1128 : : // eingelesen
1129 : : // attributes can start at char 0x14 so skip one
1130 : : // char more back == "-2"
1131 [ + - ]: 12 : if (aF.nLRes)
1132 : 12 : return aF.nLen - aF.nLRes - 2;
1133 : : else
1134 : 0 : return aF.nLen;
1135 : : case FLD_TAGIGN:
1136 [ # # ]: 0 : if( ( nFieldTagBad[nI] & nMask ) ) // Flag: Tag bad
1137 [ # # ]: 0 : return Read_F_Tag( &aF ); // Taggen
1138 : 0 : return aF.nLen; // oder ignorieren
1139 : : case FLD_READ_FSPA:
1140 : 0 : return aF.nLen - aF.nLRes - 2; // auf Char 1 positionieren
1141 : : default:
1142 : 0 : return aF.nLen; // ignorieren
1143 [ + - ]: 42 : }
1144 : : }
1145 : : }
1146 : :
1147 : : //-----------------------------------------
1148 : : // Felder Taggen
1149 : : //-----------------------------------------
1150 : :
1151 : : // MakeTagString() gibt als Returnwert die Position des ersten
1152 : : // CR / Zeilenende / Seitenumbruch in pText und wandelt auch nur bis dort
1153 : : // Wenn keins dieser Sonderzeichen enthalten ist, wird 0 zurueckgeliefert.
1154 : 0 : void SwWW8ImplReader::MakeTagString( String& rStr, const String& rOrg )
1155 : : {
1156 : 0 : rtl::OUString sHex("\\x");
1157 : 0 : bool bAllowCr = SwFltGetFlag( nFieldFlags, SwFltControlStack::TAGS_IN_TEXT )
1158 [ # # ][ # # ]: 0 : || SwFltGetFlag( nFieldFlags, SwFltControlStack::ALLOW_FLD_CR );
1159 : : sal_Unicode cChar;
1160 [ # # ]: 0 : rStr = rOrg;
1161 : :
1162 [ # # # # ]: 0 : for( xub_StrLen nI = 0;
[ # # ]
1163 : 0 : nI < rStr.Len() && rStr.Len() < (MAX_FIELDLEN - 4); ++nI )
1164 : : {
1165 : 0 : bool bSetAsHex = false;
1166 [ # # # # : 0 : switch( cChar = rStr.GetChar( nI ) )
# # # # ]
1167 : : {
1168 : : case 132: // Typographische Anfuehrungszeichen
1169 : : case 148: // gegen normale tauschen
1170 : : case 147:
1171 [ # # ]: 0 : rStr.SetChar( nI, '"' );
1172 : 0 : break;
1173 : : case 19:
1174 [ # # ]: 0 : rStr.SetChar( nI, '{' );
1175 : 0 : break; // 19..21 zu {|}
1176 : : case 20:
1177 [ # # ]: 0 : rStr.SetChar( nI, '|' );
1178 : 0 : break;
1179 : : case 21:
1180 [ # # ]: 0 : rStr.SetChar( nI, '}' );
1181 : 0 : break;
1182 : : case '\\': // \{|} per \ Taggen
1183 : : case '{':
1184 : : case '|':
1185 : : case '}':
1186 [ # # ]: 0 : rStr.Insert( nI, '\\' );
1187 : 0 : ++nI;
1188 : 0 : break;
1189 : : case 0x0b:
1190 : : case 0x0c:
1191 : : case 0x0d:
1192 [ # # ]: 0 : if( bAllowCr )
1193 [ # # ]: 0 : rStr.SetChar( nI, '\n' );
1194 : : else
1195 : 0 : bSetAsHex = true;
1196 : 0 : break;
1197 : : case 0xFE:
1198 : : case 0xFF:
1199 : 0 : bSetAsHex = true;
1200 : 0 : break;
1201 : : default:
1202 : 0 : bSetAsHex = 0x20 > cChar;
1203 : 0 : break;
1204 : : }
1205 : :
1206 [ # # ]: 0 : if( bSetAsHex )
1207 : : {
1208 : : //all Hex-Numbers with \x before
1209 [ # # ]: 0 : String sTmp( sHex );
1210 [ # # ]: 0 : if( cChar < 0x10 )
1211 [ # # ]: 0 : sTmp += '0';
1212 [ # # ][ # # ]: 0 : sTmp += String::CreateFromInt32( cChar, 16 );
[ # # ]
1213 [ # # ]: 0 : rStr.Replace( nI, 1 , sTmp );
1214 [ # # ]: 0 : nI += sTmp.Len() - 1;
1215 : : }
1216 : : }
1217 : :
1218 [ # # ]: 0 : if( rStr.Len() > (MAX_FIELDLEN - 4))
1219 [ # # ]: 0 : rStr.Erase( MAX_FIELDLEN - 4 );
1220 : 0 : }
1221 : :
1222 : 0 : void SwWW8ImplReader::InsertTagField( const sal_uInt16 nId, const String& rTagText )
1223 : : {
1224 [ # # ]: 0 : String aName(rtl::OUString("WwFieldTag"));
1225 [ # # ]: 0 : if( SwFltGetFlag( nFieldFlags, SwFltControlStack::TAGS_DO_ID ) ) // Nummer?
1226 [ # # ][ # # ]: 0 : aName += String::CreateFromInt32( nId ); // ausgeben ?
[ # # ]
1227 : :
1228 [ # # ]: 0 : if( SwFltGetFlag(nFieldFlags, SwFltControlStack::TAGS_IN_TEXT))
1229 : : {
1230 [ # # ]: 0 : aName += rTagText; // als Txt taggen
1231 : : rDoc.InsertString(*pPaM, aName,
1232 [ # # ]: 0 : IDocumentContentOperations::INS_NOHINTEXPAND);
1233 : : }
1234 : : else
1235 : : { // normal tagggen
1236 : :
1237 : : SwFieldType* pFT = rDoc.InsertFldType(
1238 [ # # ][ # # ]: 0 : SwSetExpFieldType( &rDoc, aName, nsSwGetSetExpType::GSE_STRING ) );
[ # # ]
1239 [ # # ]: 0 : SwSetExpField aFld( (SwSetExpFieldType*)pFT, rTagText ); // SUB_INVISIBLE
1240 [ # # ]: 0 : sal_uInt16 nSubType = ( SwFltGetFlag( nFieldFlags, SwFltControlStack::TAGS_VISIBLE ) ) ? 0 : nsSwExtendedSubType::SUB_INVISIBLE;
1241 [ # # ]: 0 : aFld.SetSubType(nSubType | nsSwGetSetExpType::GSE_STRING);
1242 : :
1243 [ # # ][ # # ]: 0 : rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
[ # # ][ # # ]
1244 [ # # ]: 0 : }
1245 : 0 : }
1246 : :
1247 : 0 : long SwWW8ImplReader::Read_F_Tag( WW8FieldDesc* pF )
1248 : : {
1249 : 0 : long nOldPos = pStrm->Tell();
1250 : :
1251 : 0 : WW8_CP nStart = pF->nSCode - 1; // mit 0x19 am Anfang
1252 : 0 : long nL = pF->nLen; // Gesamtlaenge mit Resultat u. Nest
1253 [ # # ]: 0 : if( nL > MAX_FIELDLEN )
1254 : 0 : nL = MAX_FIELDLEN; // MaxLaenge, durch Quoten
1255 : : // max. 4* so gross
1256 [ # # ]: 0 : String sFTxt;
1257 : : nL = pSBase->WW8ReadString( *pStrm, sFTxt,
1258 [ # # ]: 0 : pPlcxMan->GetCpOfs() + nStart, nL, eStructCharSet);
1259 : :
1260 : :
1261 [ # # ]: 0 : String aTagText;
1262 [ # # ]: 0 : MakeTagString( aTagText, sFTxt );
1263 [ # # ]: 0 : InsertTagField( pF->nId, aTagText );
1264 : :
1265 [ # # ]: 0 : pStrm->Seek( nOldPos );
1266 [ # # ][ # # ]: 0 : return pF->nLen;
1267 : : }
1268 : :
1269 : :
1270 : : //-----------------------------------------
1271 : : // normale Felder
1272 : : //-----------------------------------------
1273 : :
1274 : 0 : eF_ResT SwWW8ImplReader::Read_F_Input( WW8FieldDesc* pF, String& rStr )
1275 : : {
1276 [ # # ]: 0 : String aDef;
1277 [ # # ]: 0 : String aQ;
1278 : : long nRet;
1279 [ # # ]: 0 : _ReadFieldParams aReadParam( rStr );
1280 [ # # ][ # # ]: 0 : while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
1281 : : {
1282 [ # # # ]: 0 : switch( nRet )
1283 : : {
1284 : : case -2:
1285 [ # # ]: 0 : if( !aQ.Len() )
1286 [ # # ][ # # ]: 0 : aQ = aReadParam.GetResult();
[ # # ]
1287 : 0 : break;
1288 : : case 'd':
1289 : : case 'D':
1290 : : {
1291 [ # # ]: 0 : xub_StrLen n = aReadParam.GoToTokenParam();
1292 [ # # ]: 0 : if( STRING_NOTFOUND != n )
1293 [ # # ][ # # ]: 0 : aDef = aReadParam.GetResult();
[ # # ]
1294 : : }
1295 : 0 : break;
1296 : : }
1297 : : }
1298 [ # # ]: 0 : if( !aDef.Len() )
1299 [ # # ][ # # ]: 0 : aDef = GetFieldResult( pF );
[ # # ]
1300 : :
1301 [ # # ]: 0 : if ( pF->nId != 0x01 ) // 0x01 fields have no result
1302 : : {
1303 [ # # ]: 0 : SwInputField aFld( (SwInputFieldType*)rDoc.GetSysFldType( RES_INPUTFLD ),
1304 [ # # ]: 0 : aDef, aQ, INP_TXT, 0 ); // sichtbar ( geht z.Zt. nicht anders )
1305 [ # # ][ # # ]: 0 : rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
[ # # ][ # # ]
1306 : : }
1307 : :
1308 [ # # ][ # # ]: 0 : return FLD_OK;
[ # # ]
1309 : : }
1310 : :
1311 : : // GetFieldResult alloziert einen String und liest das Feld-Resultat ein
1312 : 0 : String SwWW8ImplReader::GetFieldResult( WW8FieldDesc* pF )
1313 : : {
1314 : 0 : long nOldPos = pStrm->Tell();
1315 : :
1316 : 0 : WW8_CP nStart = pF->nSRes; // Start Resultat
1317 : 0 : long nL = pF->nLRes; // Laenge Resultat
1318 [ # # ]: 0 : if( !nL )
1319 [ # # ]: 0 : return aEmptyStr; // kein Resultat
1320 : :
1321 [ # # ]: 0 : if( nL > MAX_FIELDLEN )
1322 : 0 : nL = MAX_FIELDLEN; // MaxLaenge, durch Quoten
1323 : : // max. 4* so gross
1324 : :
1325 [ # # ]: 0 : String sRes;
1326 : 0 : nL = pSBase->WW8ReadString( *pStrm, sRes, pPlcxMan->GetCpOfs() + nStart,
1327 [ # # ]: 0 : nL, eStructCharSet );
1328 : :
1329 [ # # ]: 0 : pStrm->Seek( nOldPos );
1330 : :
1331 : : //replace CR 0x0D with LF 0x0A
1332 [ # # ]: 0 : sRes.SearchAndReplaceAll(0x0D, 0x0A);
1333 : : //replace VT 0x0B with LF 0x0A
1334 [ # # ]: 0 : sRes.SearchAndReplaceAll(0x0B, 0x0A);
1335 [ # # ][ # # ]: 0 : return sRes;
1336 : : }
1337 : :
1338 : : /*
1339 : : Bookmarks can be set with fields SET and ASK, and they can be referenced with
1340 : : REF. When set, they behave like variables in writer, otherwise they behave
1341 : : like normal bookmarks. We can check whether we should use a show variable
1342 : : instead of a normal bookmark ref by converting to "show variable" at the end
1343 : : of the document those refs which look for the content of a bookmark but whose
1344 : : bookmarks were set with SET or ASK. (See SwWW8FltRefStack)
1345 : :
1346 : : The other piece of the puzzle is that refs that point to the "location" of the
1347 : : bookmark will in word actually point to the last location where the bookmark
1348 : : was set with SET or ASK, not the actual bookmark. This is only noticable when
1349 : : a document sets the bookmark more than once. This is because word places the
1350 : : true bookmark at the location of the last set, but the refs will display the
1351 : : position of the first set before the ref.
1352 : :
1353 : : So what we will do is
1354 : :
1355 : : 1) keep a list of all bookmarks that were set, any bookmark names mentioned
1356 : : here that are refed by content will be converted to show variables.
1357 : :
1358 : : 2) create pseudo bookmarks for every position that a bookmark is set with SET
1359 : : or ASK but has no existing bookmark. We can then keep a map from the original
1360 : : bookmark name to the new one. As we parse the document new pseudo names will
1361 : : replace the older ones, so the map always contains the bookmark of the
1362 : : location that msword itself would use.
1363 : :
1364 : : 3) word's bookmarks are case insensitive, writers are not. So we need to
1365 : : map case different versions together, regardless of whether they are
1366 : : variables or not.
1367 : :
1368 : : 4) when a reference is (first) SET or ASK, the bookmark associated with it
1369 : : is placed around the 0x14 0x15 result part of the field. We will fiddle
1370 : : the placement to be the writer equivalent of directly before and after
1371 : : the field, which gives the same effect and meaning, to do so we must
1372 : : get any bookmarks in the field range, and begin them immediately before
1373 : : the set/ask field, and end them directly afterwards. MapBookmarkVariables
1374 : : returns an identifier of the bookmark attribute to close after inserting
1375 : : the appropriate set/ask field.
1376 : : */
1377 : 0 : long SwWW8ImplReader::MapBookmarkVariables(const WW8FieldDesc* pF,
1378 : : String &rOrigName, const String &rData)
1379 : : {
1380 : : OSL_ENSURE(pPlcxMan,"No pPlcxMan");
1381 : : long nNo;
1382 : : /*
1383 : : If there was no bookmark associated with this set field, then we create a
1384 : : pseudo one and insert it in the document.
1385 : : */
1386 : : sal_uInt16 nIndex;
1387 [ # # ]: 0 : pPlcxMan->GetBook()->MapName(rOrigName);
1388 : : String sName = pPlcxMan->GetBook()->GetBookmark(
1389 [ # # ]: 0 : pF->nSCode, pF->nSCode + pF->nLen, nIndex);
1390 [ # # ]: 0 : if (sName.Len())
1391 : : {
1392 [ # # ]: 0 : pPlcxMan->GetBook()->SetStatus(nIndex, BOOK_IGNORE);
1393 : 0 : nNo = nIndex;
1394 : : }
1395 : : else
1396 : : {
1397 [ # # ]: 0 : sName = rtl::OUString("WWSetBkmk");
1398 : 0 : nNo = pReffingStck->aFieldVarNames.size()+1;
1399 [ # # ][ # # ]: 0 : sName += String::CreateFromInt32(nNo);
[ # # ]
1400 : 0 : nNo += pPlcxMan->GetBook()->GetIMax();
1401 : : }
1402 : 0 : pReffedStck->NewAttr(*pPaM->GetPoint(),
1403 [ # # ]: 0 : SwFltBookmark(BookmarkToWriter(sName), rData, nNo, 0));
[ # # # # ]
[ # # ][ # # ]
1404 [ # # ][ # # ]: 0 : pReffingStck->aFieldVarNames[rOrigName] = sName;
1405 [ # # ]: 0 : return nNo;
1406 : : }
1407 : :
1408 : : /*
1409 : : Word can set a bookmark with set or with ask, such a bookmark is equivalent to
1410 : : our variables, but until the end of a document we cannot be sure if a bookmark
1411 : : is a variable or not, at the end we will have a list of reference names which
1412 : : were set or asked, all bookmarks using the content of those bookmarks are
1413 : : converted to show variables, those that reference the position of the field
1414 : : can be left as references, because a bookmark is also inserted at the position
1415 : : of a set or ask field, either by word, or in some special cases by the import
1416 : : filter itself.
1417 : : */
1418 : 0 : SwFltStackEntry *SwWW8FltRefStack::RefToVar(const SwField* pFld,
1419 : : SwFltStackEntry &rEntry)
1420 : : {
1421 : 0 : SwFltStackEntry *pRet=0;
1422 [ # # ][ # # ]: 0 : if (pFld && RES_GETREFFLD == pFld->Which())
[ # # ]
1423 : : {
1424 : : //Get the name of the ref field, and see if actually a variable
1425 [ # # ][ # # ]: 0 : const String &rName = pFld->GetPar1();
1426 : : ::std::map<String,String,SwWW8FltRefStack::ltstr>::const_iterator
1427 [ # # ][ # # ]: 0 : aResult = aFieldVarNames.find(rName);
1428 : :
1429 [ # # ][ # # ]: 0 : if (aResult != aFieldVarNames.end())
[ # # ]
1430 : : {
1431 : : SwGetExpField aFld( (SwGetExpFieldType*)
1432 [ # # ][ # # ]: 0 : pDoc->GetSysFldType(RES_GETEXPFLD), rName, nsSwGetSetExpType::GSE_STRING, 0);
1433 [ # # ][ # # ]: 0 : delete rEntry.pAttr;
1434 [ # # ]: 0 : SwFmtFld aTmp(aFld);
1435 [ # # ]: 0 : rEntry.pAttr = aTmp.Clone();
1436 [ # # ][ # # ]: 0 : pRet = &rEntry;
1437 [ # # ]: 0 : }
1438 : : }
1439 : 0 : return pRet;
1440 : : }
1441 : :
1442 : 0 : String SwWW8ImplReader::GetMappedBookmark(const String &rOrigName)
1443 : : {
1444 [ # # ]: 0 : String sName(BookmarkToWriter(rOrigName));
1445 : : OSL_ENSURE(pPlcxMan,"no pPlcxMan");
1446 [ # # ]: 0 : pPlcxMan->GetBook()->MapName(sName);
1447 : :
1448 : : //See if there has been a variable set with this name, if so get
1449 : : //the pseudo bookmark name that was set with it.
1450 : : ::std::map<String,String,SwWW8FltRefStack::ltstr>::const_iterator aResult =
1451 [ # # ][ # # ]: 0 : pReffingStck->aFieldVarNames.find(sName);
1452 : :
1453 [ # # ][ # # ]: 0 : const String &rBkmName = (aResult == pReffingStck->aFieldVarNames.end())
1454 [ # # ][ # # ]: 0 : ? sName : (*aResult).second;
1455 : :
1456 [ # # ][ # # ]: 0 : return rBkmName;
1457 : : }
1458 : :
1459 : : // "ASK"
1460 : 0 : eF_ResT SwWW8ImplReader::Read_F_InputVar( WW8FieldDesc* pF, String& rStr )
1461 : : {
1462 [ # # ]: 0 : String sOrigName;
1463 [ # # ]: 0 : String aQ;
1464 [ # # ]: 0 : String aDef;
1465 : : long nRet;
1466 [ # # ]: 0 : _ReadFieldParams aReadParam( rStr );
1467 [ # # ][ # # ]: 0 : while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
1468 : : {
1469 [ # # # ]: 0 : switch( nRet )
1470 : : {
1471 : : case -2:
1472 [ # # ]: 0 : if (!sOrigName.Len())
1473 [ # # ][ # # ]: 0 : sOrigName = aReadParam.GetResult();
[ # # ]
1474 [ # # ]: 0 : else if( !aQ.Len() )
1475 [ # # ][ # # ]: 0 : aQ = aReadParam.GetResult();
[ # # ]
1476 : 0 : break;
1477 : : case 'd':
1478 : : case 'D':
1479 [ # # ][ # # ]: 0 : if (STRING_NOTFOUND != aReadParam.GoToTokenParam())
1480 [ # # ][ # # ]: 0 : aDef = aReadParam.GetResult();
[ # # ]
1481 : 0 : break;
1482 : : }
1483 : : }
1484 : :
1485 [ # # ]: 0 : if( !sOrigName.Len() )
1486 : 0 : return FLD_TAGIGN; // macht ohne Textmarke keinen Sinn
1487 : :
1488 [ # # ]: 0 : String aResult(GetFieldResult(pF));
1489 : :
1490 : : //#i24377#, munge Default Text into title as we have only one slot
1491 : : //available for aResult and aDef otherwise
1492 [ # # ]: 0 : if (aDef.Len())
1493 : : {
1494 [ # # ]: 0 : if (aQ.Len())
1495 [ # # ]: 0 : aQ.APPEND_CONST_ASC(" - ");
1496 [ # # ]: 0 : aQ.Append(aDef);
1497 : : }
1498 : :
1499 [ # # ]: 0 : long nNo = MapBookmarkVariables(pF, sOrigName, aResult);
1500 : :
1501 : : SwSetExpFieldType* pFT = (SwSetExpFieldType*)rDoc.InsertFldType(
1502 [ # # ][ # # ]: 0 : SwSetExpFieldType(&rDoc, sOrigName, nsSwGetSetExpType::GSE_STRING));
[ # # ]
1503 [ # # ]: 0 : SwSetExpField aFld(pFT, aResult);
1504 [ # # ]: 0 : aFld.SetSubType(nsSwExtendedSubType::SUB_INVISIBLE | nsSwGetSetExpType::GSE_STRING);
1505 : 0 : aFld.SetInputFlag(true);
1506 [ # # ]: 0 : aFld.SetPromptText( aQ );
1507 : :
1508 [ # # ][ # # ]: 0 : rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
[ # # ]
1509 : :
1510 [ # # ]: 0 : pReffedStck->SetAttr(*pPaM->GetPoint(), RES_FLTR_BOOKMARK, true, nNo);
1511 [ # # ][ # # ]: 0 : return FLD_OK;
[ # # ][ # # ]
[ # # ][ # # ]
1512 : : }
1513 : :
1514 : : // "AUTONR"
1515 : 0 : eF_ResT SwWW8ImplReader::Read_F_ANumber( WW8FieldDesc*, String& rStr )
1516 : : {
1517 [ # # ]: 0 : if( !pNumFldType ){ // 1. Mal
1518 [ # # ][ # # ]: 0 : SwSetExpFieldType aT( &rDoc, rtl::OUString("AutoNr"), nsSwGetSetExpType::GSE_SEQ );
[ # # ]
1519 [ # # ][ # # ]: 0 : pNumFldType = rDoc.InsertFldType( aT );
1520 : : }
1521 : : SwSetExpField aFld( (SwSetExpFieldType*)pNumFldType, aEmptyStr,
1522 [ # # ][ # # ]: 0 : GetNumberPara( rStr ) );
1523 [ # # ]: 0 : aFld.SetValue( ++nFldNum );
1524 [ # # ][ # # ]: 0 : rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
[ # # ]
1525 [ # # ]: 0 : return FLD_OK;
1526 : : }
1527 : :
1528 : : // "SEQ"
1529 : 0 : eF_ResT SwWW8ImplReader::Read_F_Seq( WW8FieldDesc*, String& rStr )
1530 : : {
1531 [ # # ]: 0 : String aSequenceName;
1532 [ # # ]: 0 : String aBook;
1533 : 0 : bool bCountOn = true;
1534 [ # # ]: 0 : String sStart;
1535 : 0 : SvxExtNumType eNumFormat = SVX_NUM_ARABIC;
1536 : : long nRet;
1537 [ # # ]: 0 : _ReadFieldParams aReadParam( rStr );
1538 [ # # ][ # # ]: 0 : while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
1539 : : {
1540 [ # # # # : 0 : switch( nRet )
# # # # ]
1541 : : {
1542 : : case -2:
1543 [ # # ]: 0 : if( !aSequenceName.Len() )
1544 [ # # ][ # # ]: 0 : aSequenceName = aReadParam.GetResult();
[ # # ]
1545 [ # # ]: 0 : else if( !aBook.Len() )
1546 [ # # ][ # # ]: 0 : aBook = aReadParam.GetResult();
[ # # ]
1547 : 0 : break;
1548 : :
1549 : : case 'h':
1550 : 0 : break;
1551 : :
1552 : : case '*':
1553 [ # # ]: 0 : nRet = aReadParam.SkipToNextToken();
1554 [ # # ]: 0 : if( -2 == nRet )
1555 [ # # ][ # # ]: 0 : eNumFormat = GetNumTypeFromName( aReadParam.GetResult() );
[ # # ]
1556 : 0 : break;
1557 : :
1558 : : case 'r':
1559 : 0 : bCountOn = false;
1560 [ # # ]: 0 : nRet = aReadParam.SkipToNextToken();
1561 [ # # ]: 0 : if( -2 == nRet )
1562 [ # # ][ # # ]: 0 : sStart = aReadParam.GetResult();
[ # # ]
1563 : 0 : break;
1564 : :
1565 : : case 'c':
1566 : 0 : bCountOn = false;
1567 : 0 : break;
1568 : :
1569 : : case 'n':
1570 : 0 : bCountOn = true; // Nummer um eins erhoehen (default)
1571 : 0 : break;
1572 : :
1573 : : case 's': // Outline Level
1574 : : //#i19682, what am I to do with this value
1575 : 0 : break;
1576 : : }
1577 : : }
1578 [ # # ][ # # ]: 0 : if (!aSequenceName.Len() && !aBook.Len())
[ # # ]
1579 : 0 : return FLD_TAGIGN;
1580 : :
1581 : : SwSetExpFieldType* pFT = (SwSetExpFieldType*)rDoc.InsertFldType(
1582 [ # # ][ # # ]: 0 : SwSetExpFieldType( &rDoc, aSequenceName, nsSwGetSetExpType::GSE_SEQ ) );
[ # # ]
1583 [ # # ]: 0 : SwSetExpField aFld( pFT, aEmptyStr, eNumFormat );
1584 : :
1585 [ # # ]: 0 : if (sStart.Len())
1586 [ # # ][ # # ]: 0 : aFld.SetFormula( ( aSequenceName += '=' ) += sStart );
[ # # ]
1587 [ # # ]: 0 : else if (!bCountOn)
1588 [ # # ]: 0 : aFld.SetFormula(aSequenceName);
1589 : :
1590 [ # # ][ # # ]: 0 : rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
[ # # ]
1591 [ # # ][ # # ]: 0 : return FLD_OK;
[ # # ][ # # ]
[ # # ]
1592 : : }
1593 : :
1594 : 0 : eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, String& rStr )
1595 : : {
1596 : 0 : sal_uInt16 nSub=0;
1597 : : // RegInfoFormat, DefaultFormat fuer DocInfoFelder
1598 : 0 : sal_uInt16 nReg = DI_SUB_AUTHOR;
1599 : 0 : bool bDateTime = false;
1600 : :
1601 [ # # ]: 0 : if( 85 == pF->nId )
1602 : : {
1603 [ # # ]: 0 : String aDocProperty;
1604 [ # # ]: 0 : _ReadFieldParams aReadParam( rStr );
1605 : : long nRet;
1606 [ # # ][ # # ]: 0 : while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
1607 : : {
1608 [ # # # ]: 0 : switch( nRet )
1609 : : {
1610 : : case -2:
1611 [ # # ]: 0 : if( !aDocProperty.Len() )
1612 [ # # ][ # # ]: 0 : aDocProperty = aReadParam.GetResult();
[ # # ]
1613 : 0 : break;
1614 : : case '*':
1615 : : //Skip over MERGEFORMAT
1616 [ # # ]: 0 : aReadParam.SkipToNextToken();
1617 : 0 : break;
1618 : : }
1619 : : }
1620 : :
1621 [ # # ][ # # ]: 0 : aDocProperty = comphelper::string::remove(aDocProperty, '"');
1622 : :
1623 : : /*
1624 : : There are up to 26 fields that may be meant by 'DocumentProperty'.
1625 : : Which of them is to be inserted here ?
1626 : : This Problem can only be solved by implementing a name matching
1627 : : method that compares the given Parameter String with the four
1628 : : possible name sets (english, german, french, spanish)
1629 : : */
1630 : :
1631 : : static const sal_Char* aName10 = "\x0F"; // SW field code
1632 : : static const sal_Char* aName11 // German
1633 : : = "TITEL";
1634 : : static const sal_Char* aName12 // French
1635 : : = "TITRE";
1636 : : static const sal_Char* aName13 // English
1637 : : = "TITLE";
1638 : : static const sal_Char* aName14 // Spanish
1639 : : = "TITRO";
1640 : : static const sal_Char* aName20 = "\x15"; // SW filed code
1641 : : static const sal_Char* aName21 // German
1642 : : = "ERSTELLDATUM";
1643 : : static const sal_Char* aName22 // French
1644 : : = "CR\xC9\xC9";
1645 : : static const sal_Char* aName23 // English
1646 : : = "CREATED";
1647 : : static const sal_Char* aName24 // Spanish
1648 : : = "CREADO";
1649 : : static const sal_Char* aName30 = "\x16"; // SW filed code
1650 : : static const sal_Char* aName31 // German
1651 : : = "ZULETZTGESPEICHERTZEIT";
1652 : : static const sal_Char* aName32 // French
1653 : : = "DERNIERENREGISTREMENT";
1654 : : static const sal_Char* aName33 // English
1655 : : = "SAVED";
1656 : : static const sal_Char* aName34 // Spanish
1657 : : = "MODIFICADO";
1658 : : static const sal_Char* aName40 = "\x17"; // SW filed code
1659 : : static const sal_Char* aName41 // German
1660 : : = "ZULETZTGEDRUCKT";
1661 : : static const sal_Char* aName42 // French
1662 : : = "DERNI\xC8" "REIMPRESSION";
1663 : : static const sal_Char* aName43 // English
1664 : : = "LASTPRINTED";
1665 : : static const sal_Char* aName44 // Spanish
1666 : : = "HUPS PUPS";
1667 : : static const sal_Char* aName50 = "\x18"; // SW filed code
1668 : : static const sal_Char* aName51 // German
1669 : : = "\xDC" "BERARBEITUNGSNUMMER";
1670 : : static const sal_Char* aName52 // French
1671 : : = "NUM\xC9" "RODEREVISION";
1672 : : static const sal_Char* aName53 // English
1673 : : = "REVISIONNUMBER";
1674 : : static const sal_Char* aName54 // Spanish
1675 : : = "SNUBBEL BUBBEL";
1676 : : static const sal_uInt16 nFldCnt = 5;
1677 : :
1678 : : // additional fields are to be coded soon! :-)
1679 : :
1680 : : static const sal_uInt16 nLangCnt = 4;
1681 : : static const sal_Char *aNameSet_26[nFldCnt][nLangCnt+1] =
1682 : : {
1683 : : {aName10, aName11, aName12, aName13, aName14},
1684 : : {aName20, aName21, aName22, aName23, aName24},
1685 : : {aName30, aName31, aName32, aName33, aName34},
1686 : : {aName40, aName41, aName42, aName43, aName44},
1687 : : {aName50, aName51, aName52, aName53, aName54}
1688 [ # # ][ # # ]: 0 : };
1689 : :
1690 : 0 : bool bFldFound= false;
1691 : : sal_uInt16 nFIdx;
1692 [ # # ][ # # ]: 0 : for(sal_uInt16 nLIdx=1; !bFldFound && (nLangCnt > nLIdx); ++nLIdx)
[ # # ]
1693 : : {
1694 [ # # ][ # # ]: 0 : for(nFIdx = 0; !bFldFound && (nFldCnt > nFIdx); ++nFIdx)
[ # # ]
1695 : : {
1696 [ # # ]: 0 : if( aDocProperty.Equals( String( aNameSet_26[nFIdx][nLIdx],
1697 [ # # ][ # # ]: 0 : RTL_TEXTENCODING_MS_1252 ) ) )
[ # # ]
1698 : : {
1699 : 0 : bFldFound = true;
1700 : 0 : pF->nId = aNameSet_26[nFIdx][0][0];
1701 : : }
1702 : : }
1703 : : }
1704 : :
1705 [ # # ]: 0 : if( !bFldFound )
1706 : : {
1707 : : SwDocInfoField aFld( (SwDocInfoFieldType*)
1708 [ # # ][ # # ]: 0 : rDoc.GetSysFldType( RES_DOCINFOFLD ), DI_CUSTOM|nReg, aDocProperty, GetFieldResult( pF ) );
[ # # ][ # # ]
1709 [ # # ][ # # ]: 0 : rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
[ # # ]
1710 : :
1711 [ # # ]: 0 : return FLD_OK;
1712 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
1713 : : }
1714 : :
1715 [ # # # # : 0 : switch( pF->nId )
# # # # #
# # # # ]
1716 : : {
1717 : : case 14:
1718 : : /* kann alle INFO-Vars!! */
1719 : 0 : nSub = DI_KEYS;
1720 : 0 : break;
1721 : : case 15:
1722 : 0 : nSub = DI_TITEL;
1723 : 0 : break;
1724 : : case 16:
1725 : 0 : nSub = DI_THEMA;
1726 : 0 : break;
1727 : : case 18:
1728 : 0 : nSub = DI_KEYS;
1729 : 0 : break;
1730 : : case 19:
1731 : 0 : nSub = DI_COMMENT;
1732 : 0 : break;
1733 : : case 20:
1734 : 0 : nSub = DI_CHANGE;
1735 : 0 : nReg = DI_SUB_AUTHOR;
1736 : 0 : break;
1737 : : case 21:
1738 : 0 : nSub = DI_CREATE;
1739 : 0 : nReg = DI_SUB_DATE;
1740 : 0 : bDateTime = true;
1741 : 0 : break;
1742 : : case 23:
1743 : 0 : nSub = DI_PRINT;
1744 : 0 : nReg = DI_SUB_DATE;
1745 : 0 : bDateTime = true;
1746 : 0 : break;
1747 : : case 24:
1748 : 0 : nSub = DI_DOCNO;
1749 : 0 : break;
1750 : : case 22:
1751 : 0 : nSub = DI_CHANGE;
1752 : 0 : nReg = DI_SUB_DATE;
1753 : 0 : bDateTime = true;
1754 : 0 : break;
1755 : : case 25:
1756 : 0 : nSub = DI_CHANGE;
1757 : 0 : nReg = DI_SUB_TIME;
1758 : 0 : bDateTime = true;
1759 : 0 : break;
1760 : : case 64: // DOCVARIABLE
1761 : 0 : nSub = DI_CUSTOM;
1762 : 0 : break;
1763 : : }
1764 : :
1765 : 0 : sal_uInt32 nFormat = 0;
1766 : :
1767 : 0 : sal_uInt16 nLang(0);
1768 [ # # ]: 0 : if (bDateTime)
1769 : : {
1770 [ # # ]: 0 : short nDT = GetTimeDatePara(rStr, nFormat, nLang, pF->nId);
1771 [ # # # # ]: 0 : switch (nDT)
1772 : : {
1773 : : case NUMBERFORMAT_DATE:
1774 : 0 : nReg = DI_SUB_DATE;
1775 : 0 : break;
1776 : : case NUMBERFORMAT_TIME:
1777 : 0 : nReg = DI_SUB_TIME;
1778 : 0 : break;
1779 : : case NUMBERFORMAT_DATETIME:
1780 : 0 : nReg = DI_SUB_DATE;
1781 : 0 : break;
1782 : : default:
1783 : 0 : nReg = DI_SUB_DATE;
1784 : 0 : break;
1785 : : }
1786 : : }
1787 : :
1788 [ # # ]: 0 : String aData;
1789 : : // Extract DOCVARIABLE varname
1790 [ # # ]: 0 : if ( 64 == pF->nId )
1791 : : {
1792 [ # # ]: 0 : _ReadFieldParams aReadParam( rStr );
1793 : : long nRet;
1794 [ # # ][ # # ]: 0 : while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
1795 : : {
1796 [ # # # ]: 0 : switch( nRet )
1797 : : {
1798 : : case -2:
1799 [ # # ]: 0 : if( !aData.Len() )
1800 [ # # ][ # # ]: 0 : aData = aReadParam.GetResult();
[ # # ]
1801 : 0 : break;
1802 : : case '*':
1803 : : //Skip over MERGEFORMAT
1804 [ # # ]: 0 : aReadParam.SkipToNextToken();
1805 : 0 : break;
1806 : : }
1807 : : }
1808 : :
1809 [ # # ][ # # ]: 0 : aData = comphelper::string::remove(aData, '"');
[ # # ]
1810 : : }
1811 : :
1812 : : SwDocInfoField aFld( (SwDocInfoFieldType*)
1813 [ # # ][ # # ]: 0 : rDoc.GetSysFldType( RES_DOCINFOFLD ), nSub|nReg, aData, nFormat );
1814 [ # # ]: 0 : if (bDateTime)
1815 [ # # ]: 0 : ForceFieldLanguage(aFld, nLang);
1816 [ # # ][ # # ]: 0 : rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
[ # # ]
1817 : :
1818 [ # # ][ # # ]: 0 : return FLD_OK;
1819 : : }
1820 : :
1821 : 0 : eF_ResT SwWW8ImplReader::Read_F_Author( WW8FieldDesc*, String& )
1822 : : {
1823 : : // SH: Das SwAuthorField bezeichnet nicht den urspruenglichen
1824 : : // Autor, sondern den aktuellen Benutzer, also besser ueber DocInfo
1825 : : SwDocInfoField aFld( (SwDocInfoFieldType*)
1826 [ # # ]: 0 : rDoc.GetSysFldType( RES_DOCINFOFLD ),
1827 [ # # ][ # # ]: 0 : DI_CREATE|DI_SUB_AUTHOR, String() );
[ # # ]
1828 [ # # ][ # # ]: 0 : rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
[ # # ]
1829 [ # # ]: 0 : return FLD_OK;
1830 : : }
1831 : :
1832 : 0 : eF_ResT SwWW8ImplReader::Read_F_TemplName( WW8FieldDesc*, String& )
1833 : : {
1834 : : SwTemplNameField aFld( (SwTemplNameFieldType*)
1835 [ # # ][ # # ]: 0 : rDoc.GetSysFldType( RES_TEMPLNAMEFLD ), FF_NAME );
1836 [ # # ][ # # ]: 0 : rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
[ # # ]
1837 [ # # ]: 0 : return FLD_OK;
1838 : : }
1839 : :
1840 : : // Sowohl das Datum- wie auch das Uhrzeit-Feld kann fuer Datum, fuer Uhrzeit
1841 : : // oder fuer beides benutzt werden.
1842 : 0 : eF_ResT SwWW8ImplReader::Read_F_DateTime( WW8FieldDesc*pF, String& rStr )
1843 : : {
1844 : 0 : bool bHijri = false;
1845 [ # # ]: 0 : _ReadFieldParams aReadParam(rStr);
1846 : : long nTok;
1847 [ # # ][ # # ]: 0 : while (-1 != (nTok = aReadParam.SkipToNextToken()))
1848 : : {
1849 [ # # # ]: 0 : switch (nTok)
1850 : : {
1851 : : default:
1852 : : case 'l':
1853 : : case -2:
1854 : 0 : break;
1855 : : case 'h':
1856 : 0 : bHijri = true;
1857 : 0 : break;
1858 : : case 's':
1859 : : //Saka Calendar, should we do something with this ?
1860 : 0 : break;
1861 : : }
1862 : : }
1863 : :
1864 : 0 : sal_uInt32 nFormat = 0;
1865 : :
1866 : 0 : sal_uInt16 nLang(0);
1867 [ # # ]: 0 : short nDT = GetTimeDatePara(rStr, nFormat, nLang, ww::eDATE, bHijri);
1868 : :
1869 [ # # ]: 0 : if( NUMBERFORMAT_UNDEFINED == nDT ) // no D/T-Formatstring
1870 : : {
1871 [ # # ]: 0 : if (32 == pF->nId)
1872 : : {
1873 : 0 : nDT = NUMBERFORMAT_TIME;
1874 : : nFormat = rDoc.GetNumberFormatter()->GetFormatIndex(
1875 [ # # ][ # # ]: 0 : NF_TIME_START, LANGUAGE_SYSTEM );
1876 : : }
1877 : : else
1878 : : {
1879 : 0 : nDT = NUMBERFORMAT_DATE;
1880 : : nFormat = rDoc.GetNumberFormatter()->GetFormatIndex(
1881 [ # # ][ # # ]: 0 : NF_DATE_START, LANGUAGE_SYSTEM );
1882 : : }
1883 : : }
1884 : :
1885 [ # # ]: 0 : if (nDT & NUMBERFORMAT_DATE)
1886 : : {
1887 : : SwDateTimeField aFld((SwDateTimeFieldType*)
1888 [ # # ][ # # ]: 0 : rDoc.GetSysFldType(RES_DATETIMEFLD ), DATEFLD, nFormat);
1889 [ # # ]: 0 : ForceFieldLanguage(aFld, nLang);
1890 [ # # ][ # # ]: 0 : rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
[ # # ][ # # ]
1891 : : }
1892 [ # # ]: 0 : else if (nDT == NUMBERFORMAT_TIME)
1893 : : {
1894 : : SwDateTimeField aFld((SwDateTimeFieldType*)
1895 [ # # ][ # # ]: 0 : rDoc.GetSysFldType(RES_DATETIMEFLD), TIMEFLD, nFormat);
1896 [ # # ]: 0 : ForceFieldLanguage(aFld, nLang);
1897 [ # # ][ # # ]: 0 : rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
[ # # ][ # # ]
1898 : : }
1899 : :
1900 [ # # ]: 0 : return FLD_OK;
1901 : : }
1902 : :
1903 : 0 : eF_ResT SwWW8ImplReader::Read_F_FileName(WW8FieldDesc*, String &rStr)
1904 : : {
1905 : 0 : SwFileNameFormat eType = FF_NAME;
1906 : : long nRet;
1907 [ # # ]: 0 : _ReadFieldParams aReadParam(rStr);
1908 [ # # ][ # # ]: 0 : while (-1 != (nRet = aReadParam.SkipToNextToken()))
1909 : : {
1910 [ # # # ]: 0 : switch (nRet)
1911 : : {
1912 : : case 'p':
1913 : 0 : eType = FF_PATHNAME;
1914 : 0 : break;
1915 : : case '*':
1916 : : //Skip over MERGEFORMAT
1917 [ # # ]: 0 : aReadParam.SkipToNextToken();
1918 : 0 : break;
1919 : : default:
1920 : : OSL_ENSURE(!this, "unknown option in FileName field");
1921 : 0 : break;
1922 : : }
1923 : : }
1924 : :
1925 : : SwFileNameField aFld(
1926 [ # # ][ # # ]: 0 : (SwFileNameFieldType*)rDoc.GetSysFldType(RES_FILENAMEFLD), eType);
1927 [ # # ][ # # ]: 0 : rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
[ # # ]
1928 [ # # ][ # # ]: 0 : return FLD_OK;
1929 : : }
1930 : :
1931 : 0 : eF_ResT SwWW8ImplReader::Read_F_Anz( WW8FieldDesc* pF, String& rStr )
1932 : : { // SeitenZahl - Feld
1933 : 0 : sal_uInt16 nSub = DS_PAGE;
1934 [ # # # ]: 0 : switch ( pF->nId ){
1935 : 0 : case 27: nSub = DS_WORD; break; // Wordzahl
1936 : 0 : case 28: nSub = DS_CHAR; break; // Zeichenzahl
1937 : : }
1938 : : SwDocStatField aFld( (SwDocStatFieldType*)
1939 [ # # ]: 0 : rDoc.GetSysFldType( RES_DOCSTATFLD ), nSub,
1940 [ # # ][ # # ]: 0 : GetNumberPara( rStr ) );
1941 [ # # ][ # # ]: 0 : rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
[ # # ]
1942 [ # # ]: 0 : return FLD_OK;
1943 : : }
1944 : :
1945 : 9 : eF_ResT SwWW8ImplReader::Read_F_CurPage( WW8FieldDesc*, String& rStr )
1946 : : {
1947 : : // Seitennummer
1948 : : SwPageNumberField aFld( (SwPageNumberFieldType*)
1949 [ + - ]: 9 : rDoc.GetSysFldType( RES_PAGENUMBERFLD ), PG_RANDOM,
1950 [ + - ][ + - ]: 18 : GetNumberPara(rStr, true));
1951 : :
1952 [ + - ][ + - ]: 9 : rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
[ + - ]
1953 [ + - ]: 9 : return FLD_OK;
1954 : : }
1955 : :
1956 : 0 : eF_ResT SwWW8ImplReader::Read_F_Symbol( WW8FieldDesc*, String& rStr )
1957 : : {
1958 : : //e.g. #i20118#
1959 [ # # ]: 0 : String aQ;
1960 [ # # ]: 0 : String aName;
1961 : 0 : sal_Int32 nSize = 0;
1962 : : long nRet;
1963 [ # # ]: 0 : _ReadFieldParams aReadParam( rStr );
1964 [ # # ][ # # ]: 0 : while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
1965 : : {
1966 [ # # # # ]: 0 : switch( nRet )
1967 : : {
1968 : : case -2:
1969 [ # # ]: 0 : if( !aQ.Len() )
1970 [ # # ][ # # ]: 0 : aQ = aReadParam.GetResult();
[ # # ]
1971 : 0 : break;
1972 : : case 'f':
1973 : : case 'F':
1974 : : {
1975 [ # # ]: 0 : xub_StrLen n = aReadParam.GoToTokenParam();
1976 [ # # ]: 0 : if( STRING_NOTFOUND != n )
1977 [ # # ][ # # ]: 0 : aName = aReadParam.GetResult();
[ # # ]
1978 : : }
1979 : 0 : break;
1980 : : case 's':
1981 : : case 'S':
1982 : : {
1983 [ # # ]: 0 : String aSiz;
1984 [ # # ]: 0 : xub_StrLen n = aReadParam.GoToTokenParam();
1985 [ # # ]: 0 : if (STRING_NOTFOUND != n)
1986 [ # # ][ # # ]: 0 : aSiz = aReadParam.GetResult();
[ # # ]
1987 [ # # ]: 0 : if (aSiz.Len())
1988 [ # # ][ # # ]: 0 : nSize = aSiz.ToInt32() * 20; // pT -> twip
1989 : : }
1990 : 0 : break;
1991 : : }
1992 : : }
1993 [ # # ]: 0 : if( !aQ.Len() )
1994 : 0 : return FLD_TAGIGN; // -> kein 0-Zeichen in Text
1995 : :
1996 [ # # ][ # # ]: 0 : if (sal_Unicode cChar = static_cast<sal_Unicode>(aQ.ToInt32()))
1997 : : {
1998 [ # # ]: 0 : if (aName.Len()) // Font Name set ?
1999 : : {
2000 : : SvxFontItem aFont(FAMILY_DONTKNOW, aName, aEmptyStr,
2001 [ # # ]: 0 : PITCH_DONTKNOW, RTL_TEXTENCODING_SYMBOL, RES_CHRATR_FONT);
2002 [ # # ][ # # ]: 0 : NewAttr(aFont); // new Font
2003 : : }
2004 : :
2005 [ # # ]: 0 : if (nSize > 0) //#i20118#
2006 : : {
2007 [ # # ]: 0 : SvxFontHeightItem aSz(nSize, 100, RES_CHRATR_FONTSIZE);
2008 [ # # ][ # # ]: 0 : NewAttr(aSz);
2009 : : }
2010 : :
2011 [ # # ][ # # ]: 0 : rDoc.InsertString(*pPaM, rtl::OUString(cChar));
[ # # ]
2012 : :
2013 [ # # ]: 0 : if (nSize > 0)
2014 [ # # ]: 0 : pCtrlStck->SetAttr(*pPaM->GetPoint(), RES_CHRATR_FONTSIZE);
2015 [ # # ]: 0 : if (aName.Len())
2016 [ # # ]: 0 : pCtrlStck->SetAttr(*pPaM->GetPoint(), RES_CHRATR_FONT);
2017 : : }
2018 : : else
2019 : : {
2020 [ # # ][ # # ]: 0 : rDoc.InsertString(*pPaM, rtl::OUString("###"));
[ # # ]
2021 : : }
2022 : :
2023 [ # # ][ # # ]: 0 : return FLD_OK;
[ # # ]
2024 : : }
2025 : :
2026 : : // "EINBETTEN"
2027 : 0 : eF_ResT SwWW8ImplReader::Read_F_Embedd( WW8FieldDesc*, String& rStr )
2028 : : {
2029 [ # # ]: 0 : String sHost;
2030 : :
2031 : : long nRet;
2032 [ # # ]: 0 : _ReadFieldParams aReadParam( rStr );
2033 [ # # ][ # # ]: 0 : while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
2034 : : {
2035 [ # # # ]: 0 : switch( nRet )
2036 : : {
2037 : : case -2:
2038 [ # # ][ # # ]: 0 : sHost = aReadParam.GetResult();
[ # # ]
2039 : 0 : break;
2040 : :
2041 : : case 's':
2042 : : // use ObjectSize
2043 : 0 : break;
2044 : : }
2045 : : }
2046 : :
2047 [ # # ][ # # ]: 0 : if( bObj && nPicLocFc )
2048 : 0 : nObjLocFc = nPicLocFc;
2049 : 0 : bEmbeddObj = true;
2050 [ # # ][ # # ]: 0 : return FLD_TEXT;
2051 : : }
2052 : :
2053 : :
2054 : : // "SET"
2055 : 0 : eF_ResT SwWW8ImplReader::Read_F_Set( WW8FieldDesc* pF, String& rStr )
2056 : : {
2057 [ # # ]: 0 : String sOrigName;
2058 [ # # ]: 0 : String sVal;
2059 : : long nRet;
2060 [ # # ]: 0 : _ReadFieldParams aReadParam( rStr );
2061 [ # # ][ # # ]: 0 : while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
2062 : : {
2063 [ # # ]: 0 : switch( nRet )
2064 : : {
2065 : : case -2:
2066 [ # # ]: 0 : if( !sOrigName.Len() )
2067 [ # # ][ # # ]: 0 : sOrigName = aReadParam.GetResult();
[ # # ]
2068 [ # # ]: 0 : else if( !sVal.Len() )
2069 [ # # ][ # # ]: 0 : sVal = aReadParam.GetResult();
[ # # ]
2070 : 0 : break;
2071 : : }
2072 : : }
2073 : :
2074 [ # # ]: 0 : long nNo = MapBookmarkVariables(pF,sOrigName,sVal);
2075 : :
2076 : : SwFieldType* pFT = rDoc.InsertFldType( SwSetExpFieldType( &rDoc, sOrigName,
2077 [ # # ][ # # ]: 0 : nsSwGetSetExpType::GSE_STRING ) );
[ # # ]
2078 [ # # ]: 0 : SwSetExpField aFld( (SwSetExpFieldType*)pFT, sVal, ULONG_MAX );
2079 [ # # ]: 0 : aFld.SetSubType(nsSwExtendedSubType::SUB_INVISIBLE | nsSwGetSetExpType::GSE_STRING);
2080 : :
2081 [ # # ][ # # ]: 0 : rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
[ # # ]
2082 : :
2083 [ # # ]: 0 : pReffedStck->SetAttr(*pPaM->GetPoint(), RES_FLTR_BOOKMARK, true, nNo);
2084 : :
2085 [ # # ][ # # ]: 0 : return FLD_OK;
[ # # ][ # # ]
2086 : : }
2087 : :
2088 : : // "REF"
2089 : 0 : eF_ResT SwWW8ImplReader::Read_F_Ref( WW8FieldDesc*, String& rStr )
2090 : : { // Reference - Field
2091 [ # # ]: 0 : String sOrigBkmName;
2092 : 0 : REFERENCEMARK eFormat = REF_CONTENT;
2093 : :
2094 : : long nRet;
2095 [ # # ]: 0 : _ReadFieldParams aReadParam( rStr );
2096 [ # # ][ # # ]: 0 : while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
2097 : : {
2098 [ # # # # : 0 : switch( nRet )
# # # ]
2099 : : {
2100 : : case -2:
2101 [ # # ]: 0 : if( !sOrigBkmName.Len() ) // get name of bookmark
2102 [ # # ][ # # ]: 0 : sOrigBkmName = aReadParam.GetResult();
[ # # ]
2103 : 0 : break;
2104 : :
2105 : : /* References to numbers in Word could be either to a numbered
2106 : : paragraph or to a chapter number. However Word does not seem to
2107 : : have the capability we do, of refering to the chapter number some
2108 : : other bookmark is in. As a result, cross-references to chapter
2109 : : numbers in a word document will be cross-references to a numbered
2110 : : paragraph, being the chapter heading paragraph. As it happens, our
2111 : : cross-references to numbered paragraphs will do the right thing
2112 : : when the target is a numbered chapter heading, so there is no need
2113 : : for us to use the REF_CHAPTER bookmark format on import.
2114 : : */
2115 : : case 'n':
2116 : 0 : eFormat = REF_NUMBER_NO_CONTEXT;
2117 : 0 : break;
2118 : : case 'r':
2119 : 0 : eFormat = REF_NUMBER;
2120 : 0 : break;
2121 : : case 'w':
2122 : 0 : eFormat = REF_NUMBER_FULL_CONTEXT;
2123 : 0 : break;
2124 : :
2125 : : case 'p':
2126 : 0 : eFormat = REF_UPDOWN;
2127 : 0 : break;
2128 : : case 'h':
2129 : 0 : break;
2130 : : default:
2131 : : // unimplemented switch: just do 'nix nought nothing' :-)
2132 : 0 : break;
2133 : : }
2134 : : }
2135 : :
2136 [ # # ]: 0 : String sBkmName(GetMappedBookmark(sOrigBkmName));
2137 : :
2138 : : SwGetRefField aFld(
2139 [ # # ]: 0 : (SwGetRefFieldType*)rDoc.GetSysFldType( RES_GETREFFLD ),
2140 [ # # ]: 0 : sBkmName,REF_BOOKMARK,0,eFormat);
2141 : :
2142 [ # # ]: 0 : if (eFormat == REF_CONTENT)
2143 : : {
2144 : : /*
2145 : : If we are just inserting the contents of the bookmark, then it
2146 : : is possible that the bookmark is actually a variable, so we
2147 : : must store it until the end of the document to see if it was,
2148 : : in which case we'll turn it into a show variable
2149 : : */
2150 [ # # ][ # # ]: 0 : pReffingStck->NewAttr( *pPaM->GetPoint(), SwFmtFld(aFld) );
[ # # ]
2151 [ # # ]: 0 : pReffingStck->SetAttr( *pPaM->GetPoint(), RES_TXTATR_FIELD);
2152 : : }
2153 : : else
2154 : : {
2155 [ # # ][ # # ]: 0 : rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
[ # # ]
2156 : : }
2157 [ # # ][ # # ]: 0 : return FLD_OK;
[ # # ][ # # ]
2158 : : }
2159 : :
2160 : : // Note Reference - Field
2161 : 0 : eF_ResT SwWW8ImplReader::Read_F_NoteReference( WW8FieldDesc*, String& rStr )
2162 : : {
2163 [ # # ]: 0 : String aBkmName;
2164 : 0 : bool bAboveBelow = false;
2165 : :
2166 : : long nRet;
2167 [ # # ]: 0 : _ReadFieldParams aReadParam( rStr );
2168 [ # # ][ # # ]: 0 : while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
2169 : : {
2170 [ # # # # : 0 : switch( nRet )
# ]
2171 : : {
2172 : : case -2:
2173 [ # # ]: 0 : if( !aBkmName.Len() ) // get name of foot/endnote
2174 [ # # ][ # # ]: 0 : aBkmName = aReadParam.GetResult();
[ # # ]
2175 : 0 : break;
2176 : : case 'r':
2177 : : // activate flag 'Chapter Number'
2178 : 0 : break;
2179 : : case 'p':
2180 : 0 : bAboveBelow = true;
2181 : 0 : break;
2182 : : case 'h':
2183 : 0 : break;
2184 : : default:
2185 : : // unimplemented switch: just do 'nix nought nothing' :-)
2186 : 0 : break;
2187 : : }
2188 : : }
2189 : :
2190 : : // set Sequence No of corresponding Foot-/Endnote to Zero
2191 : : // (will be corrected in
2192 : : SwGetRefField aFld( (SwGetRefFieldType*)
2193 [ # # ]: 0 : rDoc.GetSysFldType( RES_GETREFFLD ), aBkmName, REF_FOOTNOTE, 0,
2194 [ # # ]: 0 : REF_ONLYNUMBER );
2195 [ # # ][ # # ]: 0 : pReffingStck->NewAttr(*pPaM->GetPoint(), SwFmtFld(aFld));
[ # # ]
2196 [ # # ]: 0 : pReffingStck->SetAttr(*pPaM->GetPoint(), RES_TXTATR_FIELD);
2197 [ # # ]: 0 : if (bAboveBelow)
2198 : : {
2199 : : SwGetRefField aFld2( (SwGetRefFieldType*)
2200 [ # # ]: 0 : rDoc.GetSysFldType( RES_GETREFFLD ),aBkmName, REF_FOOTNOTE, 0,
2201 [ # # ]: 0 : REF_UPDOWN );
2202 [ # # ][ # # ]: 0 : pReffingStck->NewAttr(*pPaM->GetPoint(), SwFmtFld(aFld2));
[ # # ]
2203 [ # # ][ # # ]: 0 : pReffingStck->SetAttr(*pPaM->GetPoint(), RES_TXTATR_FIELD);
2204 : : }
2205 [ # # ][ # # ]: 0 : return FLD_OK;
[ # # ]
2206 : : }
2207 : :
2208 : : // "SEITENREF"
2209 : 0 : eF_ResT SwWW8ImplReader::Read_F_PgRef( WW8FieldDesc*, String& rStr )
2210 : : {
2211 [ # # ]: 0 : String sOrigName;
2212 : : long nRet;
2213 [ # # ]: 0 : _ReadFieldParams aReadParam( rStr );
2214 [ # # ][ # # ]: 0 : while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
2215 : : {
2216 [ # # ]: 0 : switch( nRet )
2217 : : {
2218 : : case -2:
2219 [ # # ]: 0 : if( !sOrigName.Len() )
2220 [ # # ][ # # ]: 0 : sOrigName = aReadParam.GetResult();
[ # # ]
2221 : 0 : break;
2222 : : }
2223 : : }
2224 : :
2225 [ # # ]: 0 : String sName(GetMappedBookmark(sOrigName));
2226 : :
2227 : : #if defined(WW_NATIVE_TOC)
2228 : : if (1) {
2229 : : ::rtl::OUString aBookmarkName("_REF");
2230 : : maFieldStack.back().SetBookmarkName(aBookmarkName);
2231 : : maFieldStack.back().SetBookmarkType(ODF_PAGEREF);
2232 : : maFieldStack.back().AddParam(rtl::OUString(), sName);
2233 : : return FLD_TEXT;
2234 : : }
2235 : : #endif
2236 : :
2237 : :
2238 : : SwGetRefField aFld(
2239 [ # # ]: 0 : (SwGetRefFieldType*)rDoc.GetSysFldType( RES_GETREFFLD ), sName,
2240 [ # # ]: 0 : REF_BOOKMARK, 0, REF_PAGE );
2241 : :
2242 [ # # ][ # # ]: 0 : rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
[ # # ]
2243 [ # # ][ # # ]: 0 : return FLD_OK;
[ # # ][ # # ]
2244 : : }
2245 : :
2246 : : // "MACROSCHALTFL"ACHE"
2247 : 0 : eF_ResT SwWW8ImplReader::Read_F_Macro( WW8FieldDesc*, String& rStr)
2248 : : {
2249 [ # # ]: 0 : String aName;
2250 [ # # ]: 0 : String aVText;
2251 : : long nRet;
2252 : 0 : bool bNewVText = true;
2253 : 0 : bool bBracket = false;
2254 [ # # ]: 0 : _ReadFieldParams aReadParam( rStr );
2255 : :
2256 : 0 : xub_StrLen nOffset = 0;
2257 : :
2258 [ # # ][ # # ]: 0 : while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
2259 : : {
2260 [ # # ]: 0 : switch( nRet )
2261 : : {
2262 : : case -2:
2263 [ # # ]: 0 : if( !aName.Len() )
2264 [ # # ][ # # ]: 0 : aName = aReadParam.GetResult();
[ # # ]
2265 [ # # ][ # # ]: 0 : else if( !aVText.Len() || bBracket )
[ # # ]
2266 : : {
2267 : 0 : nOffset = aReadParam.GetTokenSttPtr() + 1;
2268 : :
2269 [ # # ]: 0 : if( bBracket )
2270 [ # # ]: 0 : aVText += ' ';
2271 [ # # ][ # # ]: 0 : aVText += aReadParam.GetResult();
[ # # ]
2272 [ # # ]: 0 : if (bNewVText)
2273 : : {
2274 [ # # ][ # # ]: 0 : bBracket = aVText.EqualsIgnoreCaseAscii(rtl::OUString('['), 1, 0)
[ # # ]
2275 : 0 : ? true : false;
2276 : 0 : bNewVText = false;
2277 : : }
2278 [ # # ]: 0 : else if( aVText.GetChar( aVText.Len()-1 ) == ']' )
2279 : 0 : bBracket = false;
2280 : : }
2281 : 0 : break;
2282 : : }
2283 : : }
2284 [ # # ]: 0 : if( !aName.Len() )
2285 : 0 : return FLD_TAGIGN; // makes no sense without Makro-Name
2286 : :
2287 [ # # ]: 0 : aName.InsertAscii( "StarOffice.Standard.Modul1.", 0 );
2288 : :
2289 : : SwMacroField aFld( (SwMacroFieldType*)
2290 [ # # ][ # # ]: 0 : rDoc.GetSysFldType( RES_MACROFLD ), aName, aVText );
2291 [ # # ][ # # ]: 0 : rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
[ # # ]
2292 : :
2293 : :
2294 [ # # ]: 0 : WW8_CP nOldCp = pPlcxMan->Where();
2295 : 0 : WW8_CP nCp = nOldCp + nOffset;
2296 : :
2297 [ # # ]: 0 : SwPaM aPaM(*pPaM);
2298 [ # # ]: 0 : aPaM.SetMark();
2299 [ # # ]: 0 : aPaM.Move(fnMoveBackward);
2300 : 0 : aPaM.Exchange();
2301 : :
2302 [ # # ][ # # ]: 0 : mpPostProcessAttrsInfo = new WW8PostProcessAttrsInfo(nCp, nCp, aPaM);
2303 : :
2304 [ # # ][ # # ]: 0 : return FLD_OK;
[ # # ][ # # ]
[ # # ]
2305 : : }
2306 : :
2307 : 0 : WW8PostProcessAttrsInfo::WW8PostProcessAttrsInfo(WW8_CP nCpStart, WW8_CP nCpEnd,
2308 : : SwPaM & rPaM)
2309 : : : mbCopy(false),
2310 : : mnCpStart(nCpStart),
2311 : : mnCpEnd(nCpEnd),
2312 : 0 : mPaM(*rPaM.GetPoint(), *rPaM.GetMark()),
2313 [ # # ]: 0 : mItemSet(rPaM.GetDoc()->GetAttrPool(), RES_CHRATR_BEGIN, RES_PARATR_END - 1)
2314 : : {
2315 : 0 : }
2316 : :
2317 : 0 : bool CanUseRemoteLink(const String &rGrfName)
2318 : : {
2319 : 0 : bool bUseRemote = false;
2320 : : try
2321 : : {
2322 : : ::ucbhelper::Content aCnt(rGrfName,
2323 : : uno::Reference<
2324 [ # # ][ # # ]: 0 : ucb::XCommandEnvironment >() );
2325 : 0 : rtl::OUString aTitle;
2326 : :
2327 [ # # ]: 0 : aCnt.getPropertyValue("Title") >>= aTitle;
2328 [ # # ]: 0 : bUseRemote = !aTitle.isEmpty();
2329 : : }
2330 : 0 : catch ( ... )
2331 : : {
2332 : : // this file did not exist, so we will not set this as graphiclink
2333 : 0 : bUseRemote = false;
2334 : : }
2335 : 0 : return bUseRemote;
2336 : : }
2337 : :
2338 : : // "EINF"UGENGRAFIK"
2339 : 0 : eF_ResT SwWW8ImplReader::Read_F_IncludePicture( WW8FieldDesc*, String& rStr )
2340 : : {
2341 [ # # ]: 0 : String aGrfName;
2342 : 0 : bool bEmbedded = true;
2343 : :
2344 : : long nRet;
2345 [ # # ]: 0 : _ReadFieldParams aReadParam( rStr );
2346 [ # # ][ # # ]: 0 : while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
2347 : : {
2348 [ # # # # ]: 0 : switch( nRet )
2349 : : {
2350 : : case -2:
2351 [ # # ]: 0 : if (!aGrfName.Len())
2352 [ # # ][ # # ]: 0 : ConvertFFileName(aGrfName, aReadParam.GetResult());
[ # # ]
2353 : 0 : break;
2354 : :
2355 : : case 'd':
2356 : 0 : bEmbedded = false; // Embedded-Flag deaktivieren
2357 : 0 : break;
2358 : :
2359 : : case 'c':// den Converter-Namen ueberlesen
2360 : 0 : aReadParam.FindNextStringPiece();
2361 : 0 : break;
2362 : : }
2363 : : }
2364 : :
2365 [ # # ]: 0 : if (!bEmbedded)
2366 [ # # ]: 0 : bEmbedded = !CanUseRemoteLink(aGrfName);
2367 : :
2368 [ # # ]: 0 : if (!bEmbedded)
2369 : : {
2370 : : /*
2371 : : Besonderheit:
2372 : :
2373 : : Wir setzen jetzt den Link ins Doc und merken uns den SwFlyFrmFmt.
2374 : : Da wir ja unten auf jjeden Fall mit Return-Wert FLD_READ_FSPA enden,
2375 : : wird der Skip-Wert so bemessen, dass das folgende Char-1 eingelesen
2376 : : wird.
2377 : : Wenn wir dann in SwWW8ImplReader::ImportGraf() reinlaufen, wird
2378 : : erkannt, dass wir soeben einen Grafik-Link inserted haben und
2379 : : das passende SwAttrSet wird ins Frame-Format eingesetzt.
2380 : : */
2381 : 0 : SfxItemSet aFlySet( rDoc.GetAttrPool(), RES_FRMATR_BEGIN,
2382 [ # # ]: 0 : RES_FRMATR_END-1 );
2383 [ # # ][ # # ]: 0 : aFlySet.Put( SwFmtAnchor( FLY_AS_CHAR ) );
[ # # ]
2384 [ # # ][ # # ]: 0 : aFlySet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME ));
[ # # ]
2385 : : pFlyFmtOfJustInsertedGraphic = rDoc.Insert( *pPaM,
2386 : : aGrfName,
2387 : : aEmptyStr,
2388 : : 0, // Graphic*
2389 : : &aFlySet,
2390 [ # # ]: 0 : 0, 0); // SwFrmFmt*
2391 : : maGrfNameGenerator.SetUniqueGraphName(pFlyFmtOfJustInsertedGraphic,
2392 [ # # ][ # # ]: 0 : INetURLObject(aGrfName).GetBase());
[ # # ][ # # ]
[ # # ][ # # ]
2393 : : }
2394 [ # # ][ # # ]: 0 : return FLD_READ_FSPA;
2395 : : }
2396 : :
2397 : :
2398 : 0 : String wwSectionNamer::UniqueName()
2399 : : {
2400 [ # # ]: 0 : String aName(msFileLinkSeed);
2401 [ # # ][ # # ]: 0 : aName += String::CreateFromInt32(++mnFileSectionNo);
[ # # ]
2402 [ # # ][ # # ]: 0 : return mrDoc.GetUniqueSectionName(&aName);
2403 : : }
2404 : :
2405 : : // "EINFUEGENTEXT"
2406 : 0 : eF_ResT SwWW8ImplReader::Read_F_IncludeText( WW8FieldDesc* /*pF*/, String& rStr )
2407 : : {
2408 [ # # ]: 0 : String aPara;
2409 [ # # ]: 0 : String aBook;
2410 : : long nRet;
2411 [ # # ]: 0 : _ReadFieldParams aReadParam( rStr );
2412 [ # # ][ # # ]: 0 : while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
2413 : : {
2414 [ # # # ]: 0 : switch( nRet )
2415 : : {
2416 : : case -2:
2417 [ # # ]: 0 : if( !aPara.Len() )
2418 [ # # ][ # # ]: 0 : aPara = aReadParam.GetResult();
[ # # ]
2419 [ # # ]: 0 : else if( !aBook.Len() )
2420 [ # # ][ # # ]: 0 : aBook = aReadParam.GetResult();
[ # # ]
2421 : 0 : break;
2422 : : case '*':
2423 : : //Skip over MERGEFORMAT
2424 [ # # ]: 0 : aReadParam.SkipToNextToken();
2425 : 0 : break;
2426 : : }
2427 : : }
2428 [ # # ]: 0 : ConvertFFileName(aPara, aPara);
2429 : :
2430 [ # # ][ # # ]: 0 : if (aBook.Len() && aBook.GetChar( 0 ) != '\\')
[ # # ]
2431 : : {
2432 : : // Bereich aus Quelle ( kein Switch ) ?
2433 [ # # ]: 0 : ConvertUFName(aBook);
2434 [ # # ]: 0 : aPara += sfx2::cTokenSeperator;
2435 [ # # ]: 0 : aPara += sfx2::cTokenSeperator;
2436 [ # # ]: 0 : aPara += aBook;
2437 : : }
2438 : :
2439 : : /*
2440 : : ##509##
2441 : : What we will do is insert a section to be linked to a file, but just in
2442 : : case the file is not available we will fill in the section with the stored
2443 : : content of this winword field as a fallback.
2444 : : */
2445 [ # # ]: 0 : SwPosition aTmpPos(*pPaM->GetPoint());
2446 : :
2447 : : SwSectionData aSection(FILE_LINK_SECTION,
2448 [ # # ][ # # ]: 0 : maSectionNameGenerator.UniqueName());
[ # # ]
2449 [ # # ]: 0 : aSection.SetLinkFileName( aPara );
2450 : 0 : aSection.SetProtectFlag(true);
2451 : :
2452 : : SwSection *const pSection =
2453 [ # # ]: 0 : rDoc.InsertSwSection(*pPaM, aSection, 0, 0, false);
2454 : : OSL_ENSURE(pSection, "no section inserted");
2455 [ # # ]: 0 : if (!pSection)
2456 : 0 : return FLD_TEXT;
2457 [ # # ]: 0 : const SwSectionNode* pSectionNode = pSection->GetFmt()->GetSectionNode();
2458 : : OSL_ENSURE(pSectionNode, "no section node!");
2459 [ # # ]: 0 : if (!pSectionNode)
2460 : 0 : return FLD_TEXT;
2461 : :
2462 [ # # ]: 0 : pPaM->GetPoint()->nNode = pSectionNode->GetIndex()+1;
2463 [ # # ][ # # ]: 0 : pPaM->GetPoint()->nContent.Assign(pPaM->GetCntntNode(), 0 );
2464 : :
2465 : : //we have inserted a section before this point, so adjust pos
2466 : : //for future page/section segment insertion
2467 [ # # ]: 0 : maSectionManager.PrependedInlineNode(aTmpPos, *pPaM->GetNode());
2468 : :
2469 [ # # ][ # # ]: 0 : return FLD_TEXT;
[ # # ][ # # ]
[ # # ]
2470 : : }
2471 : :
2472 : : // "SERIENDRUCKFELD"
2473 : 0 : eF_ResT SwWW8ImplReader::Read_F_DBField( WW8FieldDesc* pF, String& rStr )
2474 : : {
2475 [ # # ]: 0 : String aName;
2476 : : long nRet;
2477 [ # # ]: 0 : _ReadFieldParams aReadParam( rStr );
2478 [ # # ][ # # ]: 0 : while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
2479 : : {
2480 [ # # ]: 0 : switch( nRet )
2481 : : {
2482 : : case -2:
2483 [ # # ]: 0 : if( !aName.Len() )
2484 [ # # ][ # # ]: 0 : aName = aReadParam.GetResult();
[ # # ]
2485 : 0 : break;
2486 : : }
2487 : : }
2488 [ # # ]: 0 : SwDBFieldType aD( &rDoc, aName, SwDBData() ); // Datenbank: Nichts
2489 : :
2490 [ # # ]: 0 : SwFieldType* pFT = rDoc.InsertFldType( aD );
2491 [ # # ]: 0 : SwDBField aFld( (SwDBFieldType*)pFT );
2492 [ # # ]: 0 : aFld.SetFieldCode( rStr );
2493 : :
2494 [ # # ]: 0 : String aResult;
2495 : 0 : pSBase->WW8ReadString( *pStrm, aResult, pPlcxMan->GetCpOfs()+
2496 [ # # ]: 0 : pF->nSRes, pF->nLRes, eTextCharSet );
2497 : :
2498 [ # # ]: 0 : aFld.InitContent(aResult);
2499 : :
2500 [ # # ][ # # ]: 0 : rDoc.InsertPoolItem(*pPaM, SwFmtFld( aFld ), 0);
[ # # ]
2501 : :
2502 [ # # ][ # # ]: 0 : return FLD_OK;
[ # # ][ # # ]
[ # # ]
2503 : : }
2504 : :
2505 : : // "N"ACHSTER"
2506 : 0 : eF_ResT SwWW8ImplReader::Read_F_DBNext( WW8FieldDesc*, String& )
2507 : : {
2508 [ # # ]: 0 : SwDBNextSetFieldType aN;
2509 [ # # ]: 0 : SwFieldType* pFT = rDoc.InsertFldType( aN );
2510 : : SwDBNextSetField aFld( (SwDBNextSetFieldType*)pFT, aEmptyStr, aEmptyStr,
2511 [ # # ]: 0 : SwDBData() ); // Datenbank: Nichts
2512 [ # # ][ # # ]: 0 : rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
[ # # ]
2513 [ # # ][ # # ]: 0 : return FLD_OK;
2514 : : }
2515 : :
2516 : : // "DATENSATZ"
2517 : 0 : eF_ResT SwWW8ImplReader::Read_F_DBNum( WW8FieldDesc*, String& )
2518 : : {
2519 [ # # ]: 0 : SwDBSetNumberFieldType aN;
2520 [ # # ]: 0 : SwFieldType* pFT = rDoc.InsertFldType( aN );
2521 : : SwDBSetNumberField aFld( (SwDBSetNumberFieldType*)pFT,
2522 [ # # ]: 0 : SwDBData() ); // Datenbank: Nichts
2523 [ # # ][ # # ]: 0 : rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
[ # # ]
2524 [ # # ][ # # ]: 0 : return FLD_OK;
2525 : : }
2526 : :
2527 : : /*
2528 : : EQ , only the usage for
2529 : : a. Combined Characters supported, must be exactly in the form that word
2530 : : only accepts as combined charactersm, i.e.
2531 : : eq \o(\s\up Y(XXX),\s\do Y(XXX))
2532 : : b. Ruby Text supported, must be in the form that word recognizes as being
2533 : : ruby text
2534 : : ...
2535 : : */
2536 : 0 : eF_ResT SwWW8ImplReader::Read_F_Equation( WW8FieldDesc*, String& rStr )
2537 : : {
2538 [ # # ]: 0 : _ReadFieldParams aReadParam( rStr );
2539 [ # # ]: 0 : long cChar = aReadParam.SkipToNextToken();
2540 [ # # ]: 0 : if ('o' == cChar)
2541 [ # # ]: 0 : Read_SubF_Combined(aReadParam);
2542 [ # # ]: 0 : else if ('*' == cChar)
2543 [ # # ]: 0 : Read_SubF_Ruby(aReadParam);
2544 [ # # ]: 0 : return FLD_OK;
2545 : : }
2546 : :
2547 : 0 : void SwWW8ImplReader::Read_SubF_Combined( _ReadFieldParams& rReadParam)
2548 : : {
2549 [ # # ]: 0 : String sCombinedCharacters;
2550 [ # # ][ # # ]: 0 : if ((-2 == rReadParam.SkipToNextToken()) &&
[ # # ][ # # ]
2551 [ # # ][ # # ]: 0 : rReadParam.GetResult().EqualsIgnoreCaseAscii(rtl::OUString('('), 1, 0))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # ]
2552 : : {
2553 [ # # ]: 0 : for (int i=0;i<2;i++)
2554 : : {
2555 [ # # ][ # # ]: 0 : if ('s' == rReadParam.SkipToNextToken())
2556 : : {
2557 [ # # ]: 0 : long cChar = rReadParam.SkipToNextToken();
2558 [ # # ][ # # ]: 0 : if (-2 != rReadParam.SkipToNextToken())
2559 : : break;
2560 [ # # ]: 0 : String sF = rReadParam.GetResult();
2561 [ # # ][ # # ]: 0 : if ((('u' == cChar) && sF.EqualsIgnoreCaseAscii(rtl::OUString('p'), 1, 0))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # ]
2562 [ # # ][ # # ]: 0 : || (('d' == cChar) && sF.EqualsIgnoreCaseAscii(rtl::OUString('o'), 1, 0)))
[ # # ][ # # ]
[ # # ]
[ # # # # ]
2563 : : {
2564 [ # # ][ # # ]: 0 : if (-2 == rReadParam.SkipToNextToken())
2565 : : {
2566 [ # # ]: 0 : String sPart = rReadParam.GetResult();
2567 [ # # ]: 0 : xub_StrLen nBegin = sPart.Search('(');
2568 : :
2569 : : //Word disallows brackets in this field, which
2570 : : //aids figuring out the case of an end of )) vs )
2571 [ # # ]: 0 : xub_StrLen nEnd = sPart.Search(')');
2572 : :
2573 [ # # ][ # # ]: 0 : if ((nBegin != STRING_NOTFOUND) &&
2574 : : (nEnd != STRING_NOTFOUND))
2575 : : {
2576 : : sCombinedCharacters +=
2577 [ # # ][ # # ]: 0 : sPart.Copy(nBegin+1,nEnd-nBegin-1);
[ # # ]
2578 [ # # ]: 0 : }
2579 : : }
2580 [ # # ]: 0 : }
2581 : : }
2582 : : }
2583 : : }
2584 [ # # ]: 0 : if (sCombinedCharacters.Len())
2585 : : {
2586 : : SwCombinedCharField aFld((SwCombinedCharFieldType*)
2587 [ # # ][ # # ]: 0 : rDoc.GetSysFldType(RES_COMBINED_CHARS),sCombinedCharacters);
2588 [ # # ][ # # ]: 0 : rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
[ # # ][ # # ]
2589 [ # # ]: 0 : }
2590 : 0 : }
2591 : :
2592 : 0 : void SwWW8ImplReader::Read_SubF_Ruby( _ReadFieldParams& rReadParam)
2593 : : {
2594 : 0 : sal_uInt16 nJustificationCode=0;
2595 [ # # ]: 0 : String sFontName;
2596 : 0 : sal_uInt32 nFontSize=0;
2597 [ # # ]: 0 : String sRuby;
2598 [ # # ]: 0 : String sText;
2599 : : long nRet;
2600 [ # # ][ # # ]: 0 : while( -1 != ( nRet = rReadParam.SkipToNextToken() ))
2601 : : {
2602 [ # # # # ]: 0 : switch( nRet )
2603 : : {
2604 : : case -2:
2605 : : {
2606 [ # # ]: 0 : String sTemp = rReadParam.GetResult();
2607 [ # # ][ # # ]: 0 : if( sTemp.EqualsIgnoreCaseAscii( "jc", 0, 2 ) )
2608 : : {
2609 [ # # ]: 0 : sTemp.Erase(0,2);
2610 [ # # ]: 0 : nJustificationCode = static_cast<sal_uInt16>(sTemp.ToInt32());
2611 : : }
2612 [ # # ][ # # ]: 0 : else if( sTemp.EqualsIgnoreCaseAscii( "hps", 0, 3 ) )
2613 : : {
2614 [ # # ]: 0 : sTemp.Erase(0,3);
2615 [ # # ]: 0 : nFontSize= static_cast<sal_uInt32>(sTemp.ToInt32());
2616 : : }
2617 [ # # ][ # # ]: 0 : else if( sTemp.EqualsIgnoreCaseAscii( "Font:", 0, 5 ) )
2618 : : {
2619 [ # # ]: 0 : sTemp.Erase(0,5);
2620 [ # # ]: 0 : sFontName = sTemp;
2621 [ # # ]: 0 : }
2622 : : }
2623 : 0 : break;
2624 : : case '*':
2625 : 0 : break;
2626 : : case 'o':
2627 [ # # ][ # # ]: 0 : while( -1 != ( nRet = rReadParam.SkipToNextToken() ))
2628 : : {
2629 [ # # ]: 0 : if ('u' == nRet)
2630 : : {
2631 [ # # ][ # # ]: 0 : if (-2 == rReadParam.SkipToNextToken() &&
[ # # ][ # # ]
2632 [ # # ][ # # ]: 0 : (rReadParam.GetResult().EqualsIgnoreCaseAscii(rtl::OUString('p'), 1, 0)))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # ]
2633 : : {
2634 [ # # ][ # # ]: 0 : if (-2 == rReadParam.SkipToNextToken())
2635 : : {
2636 [ # # ]: 0 : String sPart = rReadParam.GetResult();
2637 [ # # ]: 0 : xub_StrLen nBegin = sPart.Search('(');
2638 : :
2639 : : //Word disallows brackets in this field,
2640 [ # # ]: 0 : xub_StrLen nEnd = sPart.Search(')');
2641 : :
2642 [ # # ][ # # ]: 0 : if ((nBegin != STRING_NOTFOUND) &&
2643 : : (nEnd != STRING_NOTFOUND))
2644 : : {
2645 [ # # ][ # # ]: 0 : sRuby = sPart.Copy(nBegin+1,nEnd-nBegin-1);
[ # # ]
2646 : : }
2647 [ # # ][ # # ]: 0 : if (STRING_NOTFOUND ==
2648 : 0 : (nBegin = sPart.Search(',',nEnd)))
2649 : : {
2650 [ # # ]: 0 : nBegin = sPart.Search(';',nEnd);
2651 : : }
2652 [ # # ]: 0 : nEnd = sPart.SearchBackward(')');
2653 [ # # ][ # # ]: 0 : if ((nBegin != STRING_NOTFOUND) &&
2654 : : (nEnd != STRING_NOTFOUND))
2655 : : {
2656 [ # # ][ # # ]: 0 : sText = sPart.Copy(nBegin+1,nEnd-nBegin-1);
[ # # ]
2657 [ # # ]: 0 : }
2658 : : }
2659 : : }
2660 : : }
2661 : :
2662 : : }
2663 : 0 : break;
2664 : : }
2665 : : }
2666 : :
2667 : : //Translate and apply
2668 [ # # ][ # # ]: 0 : if (sRuby.Len() && sText.Len() && sFontName.Len() && nFontSize)
[ # # ][ # # ]
[ # # ]
2669 : : {
2670 [ # # # # : 0 : switch (nJustificationCode)
# ]
2671 : : {
2672 : : case 0:
2673 : 0 : nJustificationCode=1;
2674 : 0 : break;
2675 : : case 1:
2676 : 0 : nJustificationCode=3;
2677 : 0 : break;
2678 : : case 2:
2679 : 0 : nJustificationCode=4;
2680 : 0 : break;
2681 : : default:
2682 : : case 3:
2683 : 0 : nJustificationCode=0;
2684 : 0 : break;
2685 : : case 4:
2686 : 0 : nJustificationCode=2;
2687 : 0 : break;
2688 : : }
2689 : :
2690 [ # # ]: 0 : SwFmtRuby aRuby(sRuby);
2691 : 0 : const SwCharFmt *pCharFmt=0;
2692 : : //Make a guess at which of asian of western we should be setting
2693 : : sal_uInt16 nScript;
2694 [ # # ][ # # ]: 0 : if (pBreakIt->GetBreakIter().is())
2695 [ # # ][ # # ]: 0 : nScript = pBreakIt->GetBreakIter()->getScriptType(sRuby, 0);
[ # # ][ # # ]
2696 : : else
2697 : 0 : nScript = i18n::ScriptType::ASIAN;
2698 : :
2699 : : //Check to see if we already have a ruby charstyle that this fits
2700 : : std::vector<const SwCharFmt*>::const_iterator aEnd =
2701 [ # # ]: 0 : aRubyCharFmts.end();
2702 [ # # ][ # # ]: 0 : for(std::vector<const SwCharFmt*>::const_iterator aIter
[ # # ]
2703 [ # # ]: 0 : = aRubyCharFmts.begin(); aIter != aEnd; ++aIter)
2704 : : {
2705 : : const SvxFontHeightItem &rFH =
2706 [ # # ]: 0 : ItemGet<SvxFontHeightItem>(*(*aIter),
2707 [ # # ][ # # ]: 0 : GetWhichOfScript(RES_CHRATR_FONTSIZE,nScript));
2708 [ # # ]: 0 : if (rFH.GetHeight() == nFontSize*10)
2709 : : {
2710 [ # # ]: 0 : const SvxFontItem &rF = ItemGet<SvxFontItem>(*(*aIter),
2711 [ # # ][ # # ]: 0 : GetWhichOfScript(RES_CHRATR_FONT,nScript));
2712 [ # # ][ # # ]: 0 : if (rF.GetFamilyName().Equals(sFontName))
2713 : : {
2714 [ # # ]: 0 : pCharFmt=*aIter;
2715 : 0 : break;
2716 : : }
2717 : : }
2718 : : }
2719 : :
2720 : : //Create a new char style if necessary
2721 [ # # ]: 0 : if (!pCharFmt)
2722 : : {
2723 : 0 : SwCharFmt *pFmt=0;
2724 [ # # ]: 0 : String aNm;
2725 : : //Take this as the base name
2726 [ # # ]: 0 : SwStyleNameMapper::FillUIName(RES_POOLCHR_RUBYTEXT,aNm);
2727 [ # # ][ # # ]: 0 : aNm+=String::CreateFromInt32(aRubyCharFmts.size()+1);
[ # # ]
2728 [ # # ]: 0 : pFmt = rDoc.MakeCharFmt(aNm,(SwCharFmt*)rDoc.GetDfltCharFmt());
2729 [ # # ]: 0 : SvxFontHeightItem aHeightItem(nFontSize*10, 100, RES_CHRATR_FONTSIZE);
2730 : : SvxFontItem aFontItem(FAMILY_DONTKNOW,sFontName,
2731 [ # # ]: 0 : aEmptyStr,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW, RES_CHRATR_FONT);
2732 [ # # ]: 0 : aHeightItem.SetWhich(GetWhichOfScript(RES_CHRATR_FONTSIZE,nScript));
2733 [ # # ]: 0 : aFontItem.SetWhich(GetWhichOfScript(RES_CHRATR_FONT,nScript));
2734 [ # # ]: 0 : pFmt->SetFmtAttr(aHeightItem);
2735 [ # # ]: 0 : pFmt->SetFmtAttr(aFontItem);
2736 [ # # ]: 0 : aRubyCharFmts.push_back(pFmt);
2737 [ # # ][ # # ]: 0 : pCharFmt = pFmt;
[ # # ]
2738 : : }
2739 : :
2740 : : //Set the charstyle and justification
2741 [ # # ]: 0 : aRuby.SetCharFmtName(pCharFmt->GetName());
2742 : 0 : aRuby.SetCharFmtId(pCharFmt->GetPoolFmtId());
2743 : 0 : aRuby.SetAdjustment(nJustificationCode);
2744 : :
2745 [ # # ]: 0 : NewAttr(aRuby);
2746 [ # # ]: 0 : rDoc.InsertString( *pPaM, sText );
2747 [ # # ][ # # ]: 0 : pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_TXTATR_CJK_RUBY );
2748 [ # # ][ # # ]: 0 : }
[ # # ]
2749 : 0 : }
2750 : :
2751 : : //-----------------------------------------
2752 : : // Verzeichnis-Felder
2753 : : //-----------------------------------------
2754 : :
2755 : 0 : void lcl_toxMatchACSwitch( SwWW8ImplReader& /*rReader*/,
2756 : : SwDoc& rDoc,
2757 : : SwTOXBase& rBase,
2758 : : _ReadFieldParams& rParam,
2759 : : SwCaptionDisplay eCaptionType)
2760 : : {
2761 : 0 : xub_StrLen n = rParam.GoToTokenParam();
2762 [ # # ]: 0 : if( STRING_NOTFOUND != n )
2763 : : {
2764 [ # # ]: 0 : SwTOXType* pType = (SwTOXType*)rDoc.GetTOXType( TOX_ILLUSTRATIONS, 0);
2765 [ # # ]: 0 : rBase.RegisterToTOXType( *pType );
2766 : 0 : rBase.SetCaptionDisplay( eCaptionType );
2767 : : // Read Sequence Name and store in TOXBase
2768 [ # # ]: 0 : String sSeqName( rParam.GetResult() );
2769 [ # # ]: 0 : lcl_ConvertSequenceName( sSeqName );
2770 [ # # ][ # # ]: 0 : rBase.SetSequenceName( sSeqName );
2771 : : }
2772 : 0 : }
2773 : :
2774 : : //For all outline styles that are not in the outline numbering add them here as
2775 : : //custom extra styles
2776 : 0 : bool SwWW8ImplReader::AddExtraOutlinesAsExtraStyles(SwTOXBase& rBase)
2777 : : {
2778 : 0 : bool bExtras = false;
2779 : : //This is the case if the winword outline numbering is set while the
2780 : : //writer one is not
2781 [ # # ]: 0 : for (sal_uInt16 nI = 0; nI < vColl.size(); ++nI)
2782 : : {
2783 : 0 : SwWW8StyInf& rSI = vColl[nI];
2784 [ # # ]: 0 : if (rSI.IsOutline())
2785 : : {
2786 : 0 : const SwTxtFmtColl *pFmt = (const SwTxtFmtColl*)(rSI.pFmt);
2787 : 0 : sal_uInt16 nStyleLevel = rSI.nOutlineLevel;
2788 : 0 : sal_uInt16 nMaxLevel = rBase.GetLevel();
2789 [ # # ][ # # ]: 0 : if (
[ # # ]
2790 : 0 : nStyleLevel != (pFmt->GetAttrOutlineLevel()-1) && //<-end,zhaojianwei
2791 : : nStyleLevel < nMaxLevel
2792 : : )
2793 : : {
2794 [ # # ]: 0 : String sStyles(rBase.GetStyleNames(rSI.nOutlineLevel));
2795 [ # # ]: 0 : if( sStyles.Len())
2796 [ # # ]: 0 : sStyles += TOX_STYLE_DELIMITER;
2797 [ # # ]: 0 : sStyles += pFmt->GetName();
2798 [ # # ]: 0 : rBase.SetStyleNames(sStyles, rSI.nOutlineLevel);
2799 [ # # ]: 0 : bExtras = true;
2800 : : }
2801 : : }
2802 : : }
2803 : 0 : return bExtras;
2804 : : }
2805 : :
2806 : 0 : static void EnsureMaxLevelForTemplates(SwTOXBase& rBase)
2807 : : {
2808 : : //If the TOC contains Template entries at levels > the evaluation level
2809 : : //that was initially taken from the max normal outline level of the word TOC
2810 : : //then we cannot use that for the evaluation level because writer cuts off
2811 : : //all styles above that level, while word just cuts off the "standard"
2812 : : //outline styles, we have no option but to expand to the highest level
2813 : : //Word included.
2814 [ # # ][ # # ]: 0 : if ((rBase.GetLevel() != MAXLEVEL) && (nsSwTOXElement::TOX_TEMPLATE & rBase.GetCreateType()))
[ # # ]
2815 : : {
2816 [ # # ]: 0 : for (sal_uInt16 nI = MAXLEVEL; nI > 0; --nI)
2817 : : {
2818 [ # # ]: 0 : String sStyles(rBase.GetStyleNames(nI-1));
2819 [ # # ]: 0 : if (rBase.GetStyleNames(nI-1).Len())
2820 : : {
2821 : 0 : rBase.SetLevel(nI);
2822 : : break;
2823 : : }
2824 [ # # ][ # # ]: 0 : }
2825 : : }
2826 : 0 : }
2827 : :
2828 : 0 : void lcl_toxMatchTSwitch(SwWW8ImplReader& rReader, SwTOXBase& rBase,
2829 : : _ReadFieldParams& rParam)
2830 : : {
2831 : 0 : xub_StrLen n = rParam.GoToTokenParam();
2832 [ # # ]: 0 : if( STRING_NOTFOUND != n )
2833 : : {
2834 [ # # ]: 0 : String sParams( rParam.GetResult() );
2835 [ # # ]: 0 : if( sParams.Len() )
2836 : : {
2837 : 0 : xub_StrLen nIndex = 0;
2838 : :
2839 : : // Delimiters between styles and style levels appears to allow both ; and ,
2840 : :
2841 [ # # ]: 0 : String sTemplate( sParams.GetToken(0, ';', nIndex) );
2842 [ # # ]: 0 : if( STRING_NOTFOUND == nIndex )
2843 : : {
2844 : 0 : nIndex=0;
2845 [ # # ][ # # ]: 0 : sTemplate = sParams.GetToken(0, ',', nIndex);
[ # # ]
2846 : : }
2847 [ # # ]: 0 : if( STRING_NOTFOUND == nIndex )
2848 : : {
2849 [ # # ]: 0 : const SwFmt* pStyle = rReader.GetStyleWithOrgWWName(sTemplate);
2850 [ # # ]: 0 : if( pStyle )
2851 [ # # ]: 0 : sTemplate = pStyle->GetName();
2852 : : // Store Style for Level 0 into TOXBase
2853 [ # # ]: 0 : rBase.SetStyleNames( sTemplate, 0 );
2854 : : }
2855 [ # # ]: 0 : else while( STRING_NOTFOUND != nIndex )
2856 : : {
2857 : 0 : xub_StrLen nOldIndex=nIndex;
2858 : : sal_uInt16 nLevel = static_cast<sal_uInt16>(
2859 [ # # ][ # # ]: 0 : sParams.GetToken(0, ';', nIndex).ToInt32());
[ # # ]
2860 [ # # ]: 0 : if( STRING_NOTFOUND == nIndex )
2861 : : {
2862 : 0 : nIndex = nOldIndex;
2863 : : nLevel = static_cast<sal_uInt16>(
2864 [ # # ][ # # ]: 0 : sParams.GetToken(0, ',', nIndex).ToInt32());
[ # # ]
2865 : : }
2866 : :
2867 [ # # ][ # # ]: 0 : if( (0 < nLevel) && (MAXLEVEL >= nLevel) )
2868 : : {
2869 : 0 : nLevel--;
2870 : : // Store Style and Level into TOXBase
2871 : : const SwFmt* pStyle
2872 [ # # ]: 0 : = rReader.GetStyleWithOrgWWName( sTemplate );
2873 : :
2874 [ # # ]: 0 : if( pStyle )
2875 [ # # ]: 0 : sTemplate = pStyle->GetName();
2876 : :
2877 [ # # ]: 0 : String sStyles( rBase.GetStyleNames( nLevel ) );
2878 [ # # ]: 0 : if( sStyles.Len() )
2879 [ # # ]: 0 : sStyles += TOX_STYLE_DELIMITER;
2880 [ # # ]: 0 : sStyles += sTemplate;
2881 [ # # ][ # # ]: 0 : rBase.SetStyleNames( sStyles, nLevel );
2882 : : }
2883 : : // read next style name...
2884 : 0 : nOldIndex = nIndex;
2885 [ # # ][ # # ]: 0 : sTemplate = sParams.GetToken(0, ';', nIndex);
[ # # ]
2886 [ # # ]: 0 : if( STRING_NOTFOUND == nIndex )
2887 : : {
2888 : 0 : nIndex=nOldIndex;
2889 [ # # ][ # # ]: 0 : sTemplate = sParams.GetToken(0, ',', nIndex);
[ # # ]
2890 : : }
2891 [ # # ]: 0 : }
2892 [ # # ]: 0 : }
2893 : : }
2894 : 0 : }
2895 : :
2896 : 0 : sal_uInt16 wwSectionManager::CurrentSectionColCount() const
2897 : : {
2898 : 0 : sal_uInt16 nIndexCols = 1;
2899 [ # # ]: 0 : if (!maSegments.empty())
2900 : 0 : nIndexCols = maSegments.back().maSep.ccolM1 + 1;
2901 : 0 : return nIndexCols;
2902 : : }
2903 : :
2904 : : //Will there be a new pagebreak at this position (don't know what type
2905 : : //until later)
2906 : 0 : bool wwSectionManager::WillHavePageDescHere(SwNodeIndex aIdx) const
2907 : : {
2908 : 0 : bool bRet = false;
2909 [ # # ]: 0 : if (!maSegments.empty())
2910 : : {
2911 [ # # # # ]: 0 : if (!maSegments.back().IsContinous() &&
[ # # ]
2912 : 0 : maSegments.back().maStart == aIdx)
2913 : : {
2914 : 0 : bRet = true;
2915 : : }
2916 : : }
2917 : 0 : return bRet;
2918 : : }
2919 : :
2920 : 0 : sal_uInt16 lcl_GetMaxValidWordTOCLevel(const SwForm &rForm)
2921 : : {
2922 : : // GetFormMax() returns level + 1, hence the -1
2923 : 0 : sal_uInt16 nRet = rForm.GetFormMax()-1;
2924 : :
2925 : : // If the max of this type of TOC is greater than the max of a word
2926 : : // possible toc, then clip to the word max
2927 [ # # ]: 0 : if (nRet > WW8ListManager::nMaxLevel)
2928 : 0 : nRet = WW8ListManager::nMaxLevel;
2929 : :
2930 : 0 : return nRet;
2931 : : }
2932 : :
2933 : 0 : eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, String& rStr )
2934 : : {
2935 : : #if defined(WW_NATIVE_TOC)
2936 : : if (1) {
2937 : : ::rtl::OUString aBookmarkName("_TOC");
2938 : : maFieldStack.back().SetBookmarkName(aBookmarkName);
2939 : : maFieldStack.back().SetBookmarkType(ODF_TOC);
2940 : : return FLD_TEXT;
2941 : : }
2942 : : #endif
2943 : :
2944 [ # # ]: 0 : if (pF->nLRes < 3)
2945 : 0 : return FLD_TEXT; // ignore (#i25440#)
2946 : :
2947 : : TOXTypes eTox; // Baue ToxBase zusammen
2948 [ # # # ]: 0 : switch( pF->nId )
2949 : : {
2950 : : case 8:
2951 : 0 : eTox = TOX_INDEX;
2952 : 0 : break;
2953 : : case 13:
2954 : 0 : eTox = TOX_CONTENT;
2955 : 0 : break;
2956 : : default:
2957 : 0 : eTox = TOX_USER;
2958 : 0 : break;
2959 : : }
2960 : :
2961 [ # # ]: 0 : sal_uInt16 nCreateOf = (eTox == TOX_CONTENT) ? nsSwTOXElement::TOX_OUTLINELEVEL : nsSwTOXElement::TOX_MARK;
2962 : :
2963 : 0 : sal_uInt16 nIndexCols = 1;
2964 : :
2965 [ # # ]: 0 : const SwTOXType* pType = rDoc.GetTOXType( eTox, 0 );
2966 [ # # ]: 0 : SwForm aOrigForm(eTox);
2967 [ # # ][ # # ]: 0 : SwTOXBase* pBase = new SwTOXBase( pType, aOrigForm, nCreateOf, aEmptyStr );
2968 [ # # ]: 0 : pBase->SetProtected(maSectionManager.CurrentSectionIsProtected());
2969 [ # # # # ]: 0 : switch( eTox ){
2970 : : case TOX_INDEX:
2971 : : {
2972 : 0 : sal_uInt16 eOptions = nsSwTOIOptions::TOI_SAME_ENTRY | nsSwTOIOptions::TOI_CASE_SENSITIVE;
2973 : :
2974 : : // TOX_OUTLINELEVEL setzen wir genau dann, wenn
2975 : : // die Parameter \o in 1 bis 9 liegen
2976 : : // oder der Parameter \f existiert
2977 : : // oder GARKEINE Switches Parameter angegeben sind.
2978 : : long nRet;
2979 [ # # ]: 0 : _ReadFieldParams aReadParam( rStr );
2980 [ # # ][ # # ]: 0 : while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
2981 : : {
2982 [ # # # # ]: 0 : switch( nRet )
2983 : : {
2984 : : case 'c':
2985 : : {
2986 [ # # ]: 0 : xub_StrLen n = aReadParam.GoToTokenParam();
2987 [ # # ]: 0 : if( STRING_NOTFOUND != n )
2988 : : {
2989 [ # # ]: 0 : String sParams( aReadParam.GetResult() );
2990 : : // if NO String just ignore the \c
2991 [ # # ]: 0 : if( sParams.Len() )
2992 : : {
2993 : : nIndexCols =
2994 [ # # ]: 0 : static_cast<sal_uInt16>(sParams.ToInt32());
2995 [ # # ]: 0 : }
2996 : : }
2997 : : }
2998 : 0 : break;
2999 : : case 'e':
3000 : : {
3001 [ # # ]: 0 : xub_StrLen n = aReadParam.GoToTokenParam();
3002 [ # # ]: 0 : if( STRING_NOTFOUND != n ) // if NO String just ignore the \e
3003 : : {
3004 [ # # ]: 0 : String sDelimiter( aReadParam.GetResult() );
3005 [ # # ][ # # ]: 0 : SwForm aForm( pBase->GetTOXForm() );
3006 : :
3007 : : // Attention: if TOX_CONTENT brave
3008 : : // GetFormMax() returns MAXLEVEL + 1 !!
3009 : 0 : sal_uInt16 nEnd = aForm.GetFormMax()-1;
3010 : :
3011 [ # # ]: 0 : for(sal_uInt16 nLevel = 1;
3012 : : nLevel <= nEnd;
3013 : : ++nLevel)
3014 : : {
3015 : : // Levels count from 1
3016 : : // Level 0 is reserved for CAPTION
3017 : :
3018 : : // Delimiter statt Tabstop vor der Seitenzahl einsetzen,
3019 : : // falls es eine Seitenzahl gibt:
3020 : 0 : FormTokenType ePrevType = TOKEN_END;
3021 : : FormTokenType eType;
3022 : : // -> #i21237#
3023 : : SwFormTokens aPattern =
3024 [ # # ][ # # ]: 0 : aForm.GetPattern(nLevel);
3025 : 0 : SwFormTokens::iterator aIt = aPattern.begin();
3026 [ # # ]: 0 : do
3027 : : {
3028 [ # # ][ # # ]: 0 : eType = ++aIt == aPattern.end() ? TOKEN_END : aIt->eTokenType;
[ # # ][ # # ]
3029 : :
3030 [ # # ]: 0 : if (eType == TOKEN_PAGE_NUMS)
3031 : : {
3032 [ # # ]: 0 : if (TOKEN_TAB_STOP == ePrevType)
3033 : : {
3034 [ # # ]: 0 : --aIt;
3035 : :
3036 [ # # ]: 0 : if(0x09 == sDelimiter.GetChar(0))
3037 [ # # ]: 0 : aIt->eTabAlign = SVX_TAB_ADJUST_END;
3038 : : else
3039 : : {
3040 [ # # ]: 0 : SwFormToken aToken(TOKEN_TEXT);
3041 [ # # ]: 0 : aToken.sText = sDelimiter;
3042 [ # # ][ # # ]: 0 : *aIt = aToken;
[ # # ]
3043 : : }
3044 [ # # ]: 0 : aForm.SetPattern(nLevel, aPattern);
3045 : : }
3046 : :
3047 : 0 : eType = TOKEN_END;
3048 : : }
3049 : :
3050 : 0 : ePrevType = eType;
3051 : : }
3052 : : while (TOKEN_END != eType);
3053 : : // <- #i21237#
3054 : 0 : }
3055 [ # # ][ # # ]: 0 : pBase->SetTOXForm( aForm );
[ # # ]
3056 : : }
3057 : : }
3058 : 0 : break;
3059 : : case 'h':
3060 : : {
3061 : 0 : eOptions |= nsSwTOIOptions::TOI_ALPHA_DELIMITTER;
3062 : : }
3063 : 0 : break;
3064 : : }
3065 : : }
3066 [ # # ]: 0 : pBase->SetOptions( eOptions );
3067 : : }
3068 : 0 : break;
3069 : :
3070 : : case TOX_CONTENT:
3071 : : {
3072 : 0 : bool bIsHyperlink = false;
3073 : : // TOX_OUTLINELEVEL setzen wir genau dann, wenn
3074 : : // die Parameter \o in 1 bis 9 liegen
3075 : : // oder der Parameter \f existiert
3076 : : // oder GARKEINE Switches Parameter angegeben sind.
3077 : 0 : sal_uInt16 eCreateFrom = 0;
3078 : 0 : sal_uInt16 nMaxLevel = 0;
3079 : : long nRet;
3080 [ # # ]: 0 : _ReadFieldParams aReadParam( rStr );
3081 [ # # ][ # # ]: 0 : while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
3082 : : {
3083 [ # # # # : 0 : switch( nRet )
# # # #
# ]
3084 : : {
3085 : : case 'h':
3086 : 0 : bIsHyperlink = true;
3087 : 0 : break;
3088 : : case 'a':
3089 : : case 'c':
3090 : : lcl_toxMatchACSwitch(*this, rDoc, *pBase, aReadParam,
3091 : : ('c' == nRet)
3092 : : ? CAPTION_COMPLETE
3093 [ # # ][ # # ]: 0 : : CAPTION_TEXT );
3094 : 0 : break;
3095 : : case 'o':
3096 : : {
3097 : : sal_uInt16 nVal;
3098 [ # # ][ # # ]: 0 : if( !aReadParam.GetTokenSttFromTo(0, &nVal, WW8ListManager::nMaxLevel) )
3099 : 0 : nVal = lcl_GetMaxValidWordTOCLevel(aOrigForm);
3100 [ # # ]: 0 : if( nMaxLevel < nVal )
3101 : 0 : nMaxLevel = nVal;
3102 : 0 : eCreateFrom |= nsSwTOXElement::TOX_OUTLINELEVEL;
3103 : : }
3104 : 0 : break;
3105 : : case 'f':
3106 : 0 : eCreateFrom |= nsSwTOXElement::TOX_MARK;
3107 : 0 : break;
3108 : : case 'l':
3109 : : {
3110 : : sal_uInt16 nVal;
3111 [ # # ][ # # ]: 0 : if( aReadParam.GetTokenSttFromTo(0, &nVal, WW8ListManager::nMaxLevel) )
3112 : : {
3113 [ # # ]: 0 : if( nMaxLevel < nVal )
3114 : 0 : nMaxLevel = nVal;
3115 : 0 : eCreateFrom |= nsSwTOXElement::TOX_MARK;
3116 : : }
3117 : : }
3118 : 0 : break;
3119 : : case 't': // paragraphs using special styles shall
3120 : : // provide the TOX's content
3121 [ # # ]: 0 : lcl_toxMatchTSwitch(*this, *pBase, aReadParam);
3122 : 0 : eCreateFrom |= nsSwTOXElement::TOX_TEMPLATE;
3123 : 0 : break;
3124 : : case 'p':
3125 : : {
3126 [ # # ]: 0 : xub_StrLen n = aReadParam.GoToTokenParam();
3127 [ # # ]: 0 : if( STRING_NOTFOUND != n ) // if NO String just ignore the \p
3128 : : {
3129 [ # # ]: 0 : String sDelimiter( aReadParam.GetResult() );
3130 [ # # ][ # # ]: 0 : SwForm aForm( pBase->GetTOXForm() );
3131 : :
3132 : : // Attention: if TOX_CONTENT brave
3133 : : // GetFormMax() returns MAXLEVEL + 1 !!
3134 : 0 : sal_uInt16 nEnd = aForm.GetFormMax()-1;
3135 : :
3136 [ # # ]: 0 : for(sal_uInt16 nLevel = 1;
3137 : : nLevel <= nEnd;
3138 : : ++nLevel)
3139 : : {
3140 : : // Levels count from 1
3141 : : // Level 0 is reserved for CAPTION
3142 : :
3143 : : // Delimiter statt Tabstop vor der Seitenzahl einsetzen,
3144 : : // falls es eine Seitenzahl gibt:
3145 : 0 : FormTokenType ePrevType = TOKEN_END;
3146 : : FormTokenType eType;
3147 : :
3148 : : // -> #i21237#
3149 [ # # ][ # # ]: 0 : SwFormTokens aPattern = aForm.GetPattern(nLevel);
3150 : 0 : SwFormTokens::iterator aIt = aPattern.begin();
3151 [ # # ]: 0 : do
3152 : : {
3153 [ # # ][ # # ]: 0 : eType = ++aIt == aPattern.end() ? TOKEN_END : aIt->eTokenType;
[ # # ][ # # ]
3154 : :
3155 [ # # ]: 0 : if (eType == TOKEN_PAGE_NUMS)
3156 : : {
3157 [ # # ]: 0 : if (TOKEN_TAB_STOP == ePrevType)
3158 : : {
3159 [ # # ]: 0 : --aIt;
3160 : :
3161 [ # # ]: 0 : SwFormToken aToken(TOKEN_TEXT);
3162 [ # # ]: 0 : aToken.sText = sDelimiter;
3163 : :
3164 [ # # ][ # # ]: 0 : *aIt = aToken;
3165 : : aForm.SetPattern(nLevel,
3166 [ # # ][ # # ]: 0 : aPattern);
3167 : : }
3168 : 0 : eType = TOKEN_END;
3169 : : }
3170 : 0 : ePrevType = eType;
3171 : : }
3172 : : while( TOKEN_END != eType );
3173 : : // <- #i21237#
3174 : 0 : }
3175 [ # # ][ # # ]: 0 : pBase->SetTOXForm( aForm );
[ # # ]
3176 : : }
3177 : : }
3178 : 0 : break;
3179 : : case 'n': // don't print page numbers
3180 : : {
3181 : : // read START and END param
3182 : : sal_uInt16 nStart, nEnd;
3183 [ # # ]: 0 : if( !aReadParam.GetTokenSttFromTo( &nStart, &nEnd,
3184 [ # # ]: 0 : WW8ListManager::nMaxLevel ) )
3185 : : {
3186 : 0 : nStart = 1;
3187 : 0 : nEnd = aOrigForm.GetFormMax()-1;
3188 : : }
3189 : : // remove page numbers from this levels
3190 [ # # ][ # # ]: 0 : SwForm aForm( pBase->GetTOXForm() );
3191 [ # # ]: 0 : if (aForm.GetFormMax() <= nEnd)
3192 : 0 : nEnd = aForm.GetFormMax()-1;
3193 [ # # ]: 0 : for (
3194 : 0 : sal_uInt16 nLevel = nStart; nLevel <= nEnd;
3195 : : ++nLevel
3196 : : )
3197 : : {
3198 : : // Levels count from 1
3199 : : // Level 0 is reserved for CAPTION
3200 : :
3201 : : // Seitenzahl und ggfs. davorstehenden Tabstop
3202 : : // entfernen:
3203 : : FormTokenType eType;
3204 : : // -> #i21237#
3205 [ # # ][ # # ]: 0 : SwFormTokens aPattern = aForm.GetPattern(nLevel);
3206 : 0 : SwFormTokens::iterator aIt = aPattern.begin();
3207 [ # # ]: 0 : do
3208 : : {
3209 [ # # ][ # # ]: 0 : eType = ++aIt == aPattern.end() ? TOKEN_END : aIt->eTokenType;
[ # # ][ # # ]
3210 : :
3211 [ # # ]: 0 : if (eType == TOKEN_PAGE_NUMS)
3212 : : {
3213 [ # # ]: 0 : aIt = aPattern.erase(aIt);
3214 [ # # ]: 0 : --aIt;
3215 [ # # ]: 0 : if (
3216 : : TOKEN_TAB_STOP ==
3217 [ # # ]: 0 : aIt->eTokenType
3218 : : )
3219 : : {
3220 [ # # ]: 0 : aPattern.erase(aIt);
3221 [ # # ]: 0 : aForm.SetPattern(nLevel, aPattern);
3222 : : }
3223 : 0 : eType = TOKEN_END;
3224 : : }
3225 : : }
3226 : : while (TOKEN_END != eType);
3227 : : // <- #i21237#
3228 : 0 : }
3229 [ # # ][ # # ]: 0 : pBase->SetTOXForm( aForm );
3230 : : }
3231 : 0 : break;
3232 : :
3233 : : /*
3234 : : // the following switches are not (yet) supported
3235 : : // by good old StarWriter:
3236 : : case 'b':
3237 : : case 's':
3238 : : case 'd':
3239 : : break;
3240 : : */
3241 : : }
3242 : : }
3243 : :
3244 [ # # ]: 0 : if (bIsHyperlink)
3245 : : {
3246 [ # # ][ # # ]: 0 : SwForm aForm(pBase->GetTOXForm());
3247 : 0 : sal_uInt16 nEnd = aForm.GetFormMax()-1;
3248 [ # # ]: 0 : SwFormToken aLinkStart(TOKEN_LINK_START);
3249 [ # # ]: 0 : SwFormToken aLinkEnd(TOKEN_LINK_END);
3250 : :
3251 : : // -> #i21237#
3252 [ # # ]: 0 : for(sal_uInt16 nLevel = 1; nLevel <= nEnd; ++nLevel)
3253 : : {
3254 [ # # ][ # # ]: 0 : SwFormTokens aPattern = aForm.GetPattern(nLevel);
3255 : :
3256 [ # # ]: 0 : aPattern.insert(aPattern.begin(), aLinkStart);
3257 [ # # ]: 0 : aPattern.push_back(aLinkEnd);
3258 : :
3259 [ # # ]: 0 : aForm.SetPattern(nLevel, aPattern);
3260 : :
3261 : 0 : }
3262 : : // <- #i21237#
3263 [ # # ][ # # ]: 0 : pBase->SetTOXForm(aForm);
[ # # ][ # # ]
3264 : : }
3265 : :
3266 [ # # ]: 0 : if (!nMaxLevel)
3267 : 0 : nMaxLevel = WW8ListManager::nMaxLevel;
3268 : 0 : pBase->SetLevel(nMaxLevel);
3269 : :
3270 [ # # ]: 0 : const TOXTypes eType = pBase->GetTOXType()->GetType();
3271 [ # # # ]: 0 : switch( eType )
3272 : : {
3273 : : case TOX_CONTENT:
3274 : : {
3275 : : //If we would be created from outlines, either explictly or by default
3276 : : //then see if we need extra styles added to the outlines
3277 [ # # ]: 0 : sal_uInt16 eEffectivelyFrom = eCreateFrom ? eCreateFrom : nsSwTOXElement::TOX_OUTLINELEVEL;
3278 [ # # ]: 0 : if (eEffectivelyFrom & nsSwTOXElement::TOX_OUTLINELEVEL)
3279 : : {
3280 [ # # ][ # # ]: 0 : if (AddExtraOutlinesAsExtraStyles(*pBase))
3281 : 0 : eCreateFrom |= (nsSwTOXElement::TOX_TEMPLATE | nsSwTOXElement::TOX_OUTLINELEVEL);
3282 : :
3283 : : // #i19683# Insert a text token " " between the number and entry token.
3284 : : // In an ideal world we could handle the tab stop between the number and
3285 : : // the entry correctly, but I currently have no clue how to obtain
3286 : : // the tab stop position. It is _not_ set at the paragraph style.
3287 : 0 : SwForm* pForm = 0;
3288 [ # # ]: 0 : for (sal_uInt16 nI = 0; nI < vColl.size(); ++nI)
3289 : : {
3290 : 0 : const SwWW8StyInf& rSI = vColl[nI];
3291 [ # # ]: 0 : if (rSI.IsOutlineNumbered())
3292 : : {
3293 : 0 : sal_uInt16 nStyleLevel = rSI.nOutlineLevel;
3294 [ # # ]: 0 : const SwNumFmt& rFmt = rSI.GetOutlineNumrule()->Get( nStyleLevel );
3295 [ # # ]: 0 : if ( SVX_NUM_NUMBER_NONE != rFmt.GetNumberingType() )
3296 : : {
3297 : 0 : ++nStyleLevel;
3298 : :
3299 [ # # ]: 0 : if ( !pForm )
3300 [ # # ][ # # ]: 0 : pForm = new SwForm( pBase->GetTOXForm() );
[ # # ]
3301 : :
3302 [ # # ][ # # ]: 0 : SwFormTokens aPattern = pForm->GetPattern(nStyleLevel);
3303 : : SwFormTokens::iterator aIt =
3304 : : find_if(aPattern.begin(), aPattern.end(),
3305 [ # # ]: 0 : SwFormTokenEqualToFormTokenType(TOKEN_ENTRY_NO));
3306 : :
3307 [ # # ][ # # ]: 0 : if ( aIt != aPattern.end() )
3308 : : {
3309 [ # # ]: 0 : SwFormToken aNumberEntrySeparator( TOKEN_TEXT );
3310 [ # # ]: 0 : aNumberEntrySeparator.sText = rtl::OUString(" ");
3311 [ # # ][ # # ]: 0 : aPattern.insert( ++aIt, aNumberEntrySeparator );
3312 [ # # ][ # # ]: 0 : pForm->SetPattern( nStyleLevel, aPattern );
3313 : 0 : }
3314 : : }
3315 : : }
3316 : : }
3317 [ # # ]: 0 : if ( pForm )
3318 [ # # ]: 0 : pBase->SetTOXForm( *pForm );
3319 : : }
3320 : :
3321 [ # # ]: 0 : if (eCreateFrom)
3322 [ # # ]: 0 : pBase->SetCreate(eCreateFrom);
3323 [ # # ]: 0 : EnsureMaxLevelForTemplates(*pBase);
3324 : : }
3325 : 0 : break;
3326 : : case TOX_ILLUSTRATIONS:
3327 : : {
3328 [ # # ]: 0 : if( !eCreateFrom )
3329 : 0 : eCreateFrom = nsSwTOXElement::TOX_SEQUENCE;
3330 [ # # ]: 0 : pBase->SetCreate( eCreateFrom );
3331 : :
3332 : : /*
3333 : : We don't know until here if we are an illustration
3334 : : or not, and so have being used a TOX_CONTENT so far
3335 : : which has 10 levels, while TOX has only two, this
3336 : : level is set only in the constructor of SwForm, so
3337 : : create a new one and copy over anything that could
3338 : : be set in the old one, and remove entries from the
3339 : : pattern which do not apply to illustration indices
3340 : : */
3341 [ # # ][ # # ]: 0 : SwForm aOldForm( pBase->GetTOXForm() );
3342 [ # # ]: 0 : SwForm aForm( eType );
3343 : 0 : sal_uInt16 nEnd = aForm.GetFormMax()-1;
3344 : :
3345 : : // #i21237#
3346 [ # # ]: 0 : for(sal_uInt16 nLevel = 1; nLevel <= nEnd; ++nLevel)
3347 : : {
3348 [ # # ][ # # ]: 0 : SwFormTokens aPattern = aOldForm.GetPattern(nLevel);
3349 : :
3350 : : SwFormTokens::iterator new_end=remove_if(aPattern.begin(), aPattern.end(),
3351 [ # # ]: 0 : SwFormTokenEqualToFormTokenType(TOKEN_ENTRY_NO));
3352 : :
3353 : : // table index imported with wrong page number format
3354 [ # # ]: 0 : aPattern.erase (new_end, aPattern.end() );
3355 : :
3356 [ # # ]: 0 : aForm.SetPattern(nLevel, aPattern);
3357 : :
3358 : : aForm.SetTemplate( nLevel,
3359 [ # # ]: 0 : aOldForm.GetTemplate(nLevel));
3360 : 0 : }
3361 : :
3362 [ # # ][ # # ]: 0 : pBase->SetTOXForm( aForm );
[ # # ]
3363 : : }
3364 : 0 : break;
3365 : : default:
3366 : : OSL_ENSURE(!this, "Unhandled toc options!");
3367 : 0 : break;
3368 [ # # ]: 0 : }
3369 : : }
3370 : 0 : break;
3371 : : case TOX_USER:
3372 : 0 : break;
3373 : : default:
3374 : : OSL_ENSURE(!this, "Unhandled toc options!");
3375 : 0 : break;
3376 : : } // ToxBase fertig
3377 : :
3378 : : // Update fuer TOX anstossen
3379 : 0 : rDoc.SetUpdateTOX(true);
3380 : :
3381 : : // #i21237# - propagate tab stops from paragraph styles
3382 : : // used in TOX to patterns of the TOX
3383 : :
3384 [ # # ]: 0 : pBase->AdjustTabStops(rDoc, sal_True);
3385 : :
3386 : : // #i10028# - inserting a toc implicltly acts like a parabreak in word and writer
3387 [ # # ]: 0 : if (pPaM->GetPoint()->nContent.GetIndex())
3388 [ # # ]: 0 : AppendTxtNode(*pPaM->GetPoint());
3389 : :
3390 : 0 : const SwPosition* pPos = pPaM->GetPoint();
3391 : :
3392 [ # # ]: 0 : SwFltTOX aFltTOX( pBase, nIndexCols );
3393 : :
3394 : : // test if there is already a break item on this node
3395 [ # # ]: 0 : if(SwCntntNode* pNd = pPos->nNode.GetNode().GetCntntNode())
3396 : : {
3397 [ # # ]: 0 : const SfxItemSet* pSet = pNd->GetpSwAttrSet();
3398 [ # # ]: 0 : if( pSet )
3399 : : {
3400 [ # # ][ # # ]: 0 : if (SFX_ITEM_SET == pSet->GetItemState(RES_BREAK, false))
3401 : 0 : aFltTOX.SetHadBreakItem(true);
3402 [ # # ][ # # ]: 0 : if (SFX_ITEM_SET == pSet->GetItemState(RES_PAGEDESC, false))
3403 : 0 : aFltTOX.SetHadPageDescItem(true);
3404 : : }
3405 : : }
3406 : :
3407 : : //Will there be a new pagebreak at this position (don't know what type
3408 : : //until later)
3409 [ # # ][ # # ]: 0 : if (maSectionManager.WillHavePageDescHere(pPos->nNode))
[ # # ][ # # ]
3410 : 0 : aFltTOX.SetHadPageDescItem(true);
3411 : :
3412 : : // Setze Anfang in Stack
3413 [ # # ]: 0 : pReffedStck->NewAttr( *pPos, aFltTOX );
3414 : :
3415 [ # # ]: 0 : rDoc.InsertTableOf(*pPaM->GetPoint(), *aFltTOX.GetBase());
3416 : :
3417 : : //inserting a toc inserts a section before this point, so adjust pos
3418 : : //for future page/section segment insertion
3419 [ # # ]: 0 : SwPaM aRegion(*pPaM);
3420 [ # # ]: 0 : aRegion.Move(fnMoveBackward);
3421 : : OSL_ENSURE(rDoc.GetCurTOX(*aRegion.GetPoint()), "Misunderstood how toc works");
3422 [ # # ][ # # ]: 0 : if (SwTOXBase* pBase2 = (SwTOXBase*)rDoc.GetCurTOX(*aRegion.GetPoint()))
3423 : : {
3424 [ # # ]: 0 : if(nIndexCols>1)
3425 : : {
3426 : : // Set the column number for index
3427 [ # # ]: 0 : SfxItemSet aSet( rDoc.GetAttrPool(), RES_COL, RES_COL );
3428 [ # # ]: 0 : SwFmtCol aCol;
3429 [ # # ]: 0 : aCol.Init( nIndexCols, 708, USHRT_MAX );
3430 [ # # ]: 0 : aSet.Put( aCol );
3431 [ # # ][ # # ]: 0 : pBase2->SetAttrSet( aSet );
[ # # ]
3432 : : }
3433 : :
3434 : 0 : maSectionManager.PrependedInlineNode(*pPaM->GetPoint(),
3435 [ # # ]: 0 : *aRegion.GetNode());
3436 : : }
3437 : :
3438 : : // Setze Ende in Stack
3439 [ # # ]: 0 : pReffedStck->SetAttr( *pPos, RES_FLTR_TOX );
3440 : :
3441 [ # # ][ # # ]: 0 : if (!maApos.back()) //a para end in apo doesn't count
3442 : 0 : bWasParaEnd = true;
3443 [ # # ][ # # ]: 0 : return FLD_OK;
[ # # ]
3444 : : }
3445 : :
3446 : 3 : eF_ResT SwWW8ImplReader::Read_F_Shape(WW8FieldDesc* /*pF*/, String& /*rStr*/)
3447 : : {
3448 : : /*
3449 : : #i3958# 0x8 followed by 0x1 where the shape is the 0x8 and its anchoring
3450 : : to be ignored followed by a 0x1 with an empty drawing. Detect in inserting
3451 : : the drawing that we are in the Shape field and respond accordingly
3452 : : */
3453 : 3 : return FLD_TEXT;
3454 : : }
3455 : :
3456 : 9 : eF_ResT SwWW8ImplReader::Read_F_Hyperlink( WW8FieldDesc* /*pF*/, String& rStr )
3457 : : {
3458 : : #if defined(WW_NATIVE_TOC)
3459 : : if (1) {
3460 : : ::rtl::OUString aBookmarkName("_HYPERLINK");
3461 : : maFieldStack.back().SetBookmarkName(aBookmarkName);
3462 : : maFieldStack.back().SetBookmarkType(ODF_HYPERLINK);
3463 : : return FLD_TEXT;
3464 : : }
3465 : : #endif
3466 : :
3467 [ + - ][ + - ]: 9 : String sURL, sTarget, sMark;
[ + - ]
3468 : 9 : bool bDataImport = false;
3469 : : //HYPERLINK "filename" [switches]
3470 : 9 : bool bOptions=false;
3471 : :
3472 [ + - ][ + - ]: 9 : rStr = comphelper::string::stripEnd(rStr, 1);
[ + - ]
3473 : :
3474 [ + - ]: 9 : if (!bDataImport)
3475 : : {
3476 : : long nRet;
3477 [ + - ]: 9 : _ReadFieldParams aReadParam( rStr );
3478 [ + - ][ + + ]: 15 : while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
3479 : : {
3480 [ + - - - : 6 : switch( nRet )
- - ]
3481 : : {
3482 : : case -2:
3483 [ + - ]: 6 : if (!sURL.Len() & !bOptions)
3484 [ + - ][ + - ]: 6 : ConvertFFileName(sURL, aReadParam.GetResult());
[ + - ]
3485 : 6 : break;
3486 : :
3487 : : case 'n':
3488 [ # # ]: 0 : sTarget.ASSIGN_CONST_ASC( "_blank" );
3489 : 0 : bOptions = true;
3490 : 0 : break;
3491 : :
3492 : : case 'l':
3493 [ # # ]: 0 : nRet = aReadParam.SkipToNextToken();
3494 : 0 : bOptions = true;
3495 [ # # ]: 0 : if( -2 == nRet )
3496 : : {
3497 [ # # ][ # # ]: 0 : sMark = aReadParam.GetResult();
[ # # ]
3498 [ # # ][ # # ]: 0 : if( sMark.Len() && '"' == sMark.GetChar( sMark.Len()-1 ))
[ # # ]
3499 [ # # ]: 0 : sMark.Erase( sMark.Len() - 1 );
3500 : :
3501 : : }
3502 : 0 : break;
3503 : : case 't':
3504 [ # # ]: 0 : nRet = aReadParam.SkipToNextToken();
3505 : 0 : bOptions = true;
3506 [ # # ]: 0 : if (-2 == nRet)
3507 [ # # ][ # # ]: 0 : sTarget = aReadParam.GetResult();
[ # # ]
3508 : 0 : break;
3509 : : case 'h':
3510 : : case 'm':
3511 : : OSL_ENSURE( !this, "Auswertung fehlt noch - Daten unbekannt" );
3512 : : case 's': //worthless fake anchor option
3513 : 0 : bOptions = true;
3514 : 0 : break;
3515 : : }
3516 [ + - ]: 9 : }
3517 : : }
3518 : :
3519 : : // das Resultat uebernehmen
3520 : : OSL_ENSURE((sURL.Len() || sMark.Len()), "WW8: Empty URL");
3521 : :
3522 [ - + ]: 9 : if( sMark.Len() )
3523 [ # # ][ # # ]: 0 : ( sURL += INET_MARK_TOKEN ) += sMark;
3524 : :
3525 [ + - ]: 9 : SwFmtINetFmt aURL( sURL, sTarget );
3526 : :
3527 : : //As an attribute this needs to be closed, and that'll happen from
3528 : : //EndExtSprm in conjunction with the maFieldStack If there are are flyfrms
3529 : : //between the start and begin, their hyperlinks will be set at that time
3530 : : //as well.
3531 [ + - ]: 9 : pCtrlStck->NewAttr( *pPaM->GetPoint(), aURL );
3532 [ + - ][ + - ]: 9 : return FLD_TEXT;
[ + - ][ + - ]
3533 : : }
3534 : :
3535 : 0 : void lcl_ImportTox(SwDoc &rDoc, SwPaM &rPaM, const String &rStr, bool bIdx)
3536 : : {
3537 [ # # ]: 0 : TOXTypes eTox = ( !bIdx ) ? TOX_CONTENT : TOX_INDEX; // Default
3538 : :
3539 : 0 : sal_uInt16 nLevel = 1;
3540 : :
3541 : : xub_StrLen n;
3542 [ # # ]: 0 : String sFldTxt;
3543 : : long nRet;
3544 [ # # ]: 0 : _ReadFieldParams aReadParam(rStr);
3545 [ # # ][ # # ]: 0 : while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
3546 [ # # # # ]: 0 : switch( nRet )
3547 : : {
3548 : : case -2:
3549 [ # # ]: 0 : if( !sFldTxt.Len() )
3550 : : {
3551 : : // PrimaryKey ohne ":", 2nd dahinter
3552 [ # # ][ # # ]: 0 : sFldTxt = aReadParam.GetResult();
[ # # ]
3553 : : }
3554 : 0 : break;
3555 : :
3556 : : case 'f':
3557 [ # # ]: 0 : n = aReadParam.GoToTokenParam();
3558 [ # # ]: 0 : if( STRING_NOTFOUND != n )
3559 : : {
3560 [ # # ]: 0 : String sParams( aReadParam.GetResult() );
3561 [ # # ][ # # ]: 0 : if( 'C' != sParams.GetChar(0) && 'c' != sParams.GetChar(0) )
[ # # ]
3562 [ # # ]: 0 : eTox = TOX_USER;
3563 : : }
3564 : 0 : break;
3565 : :
3566 : : case 'l':
3567 [ # # ]: 0 : n = aReadParam.GoToTokenParam();
3568 [ # # ]: 0 : if( STRING_NOTFOUND != n )
3569 : : {
3570 [ # # ]: 0 : String sParams( aReadParam.GetResult() );
3571 [ # # # # : 0 : if( sParams.Len() // if NO String just ignore the \l
# # ][ # # ]
3572 : 0 : && sParams.GetChar( 0 ) > '0'
3573 : 0 : && sParams.GetChar( 0 ) <= '9' )
3574 : : {
3575 [ # # ]: 0 : nLevel = (sal_uInt16)sParams.ToInt32();
3576 [ # # ]: 0 : }
3577 : : }
3578 : 0 : break;
3579 : : }
3580 : :
3581 : : OSL_ENSURE( rDoc.GetTOXTypeCount( eTox ), "Doc.GetTOXTypeCount() == 0 :-(" );
3582 : :
3583 [ # # ]: 0 : const SwTOXType* pT = rDoc.GetTOXType( eTox, 0 );
3584 [ # # ]: 0 : SwTOXMark aM( pT );
3585 : :
3586 [ # # ]: 0 : if( eTox != TOX_INDEX )
3587 : 0 : aM.SetLevel( nLevel );
3588 : : else
3589 : : {
3590 [ # # ]: 0 : xub_StrLen nFnd = sFldTxt.Search( WW8_TOX_LEVEL_DELIM );
3591 [ # # ]: 0 : if( STRING_NOTFOUND != nFnd ) // it exist levels
3592 : : {
3593 [ # # ][ # # ]: 0 : aM.SetPrimaryKey( sFldTxt.Copy( 0, nFnd ) );
[ # # ]
3594 : : xub_StrLen nScndFnd =
3595 [ # # ]: 0 : sFldTxt.Search( WW8_TOX_LEVEL_DELIM, nFnd+1 );
3596 [ # # ]: 0 : if( STRING_NOTFOUND != nScndFnd )
3597 : : {
3598 [ # # ][ # # ]: 0 : aM.SetSecondaryKey( sFldTxt.Copy( nFnd+1, nScndFnd - nFnd - 1 ));
[ # # ]
3599 : 0 : nFnd = nScndFnd;
3600 : : }
3601 [ # # ]: 0 : sFldTxt.Erase( 0, nFnd+1 );
3602 : : }
3603 : : }
3604 : :
3605 [ # # ]: 0 : if (sFldTxt.Len())
3606 : : {
3607 [ # # ]: 0 : aM.SetAlternativeText( sFldTxt );
3608 [ # # ]: 0 : rDoc.InsertPoolItem( rPaM, aM, 0 );
3609 [ # # ][ # # ]: 0 : }
[ # # ]
3610 : 0 : }
3611 : :
3612 : 0 : void sw::ms::ImportXE(SwDoc &rDoc, SwPaM &rPaM, const String &rStr)
3613 : : {
3614 : 0 : lcl_ImportTox(rDoc, rPaM, rStr, true);
3615 : 0 : }
3616 : :
3617 : 0 : void SwWW8ImplReader::ImportTox( int nFldId, String aStr )
3618 : : {
3619 : 0 : bool bIdx = (nFldId != 9);
3620 : 0 : lcl_ImportTox(rDoc, *pPaM, aStr, bIdx);
3621 : 0 : }
3622 : :
3623 : 18 : void SwWW8ImplReader::Read_FldVanish( sal_uInt16, const sal_uInt8*, short nLen )
3624 : : {
3625 : : //Meaningless in a style
3626 [ + - ][ + - ]: 18 : if (pAktColl || !pPlcxMan)
3627 : : return;
3628 : :
3629 : 18 : const int nChunk = 64; //number of characters to read at one time
3630 : :
3631 : : // Vorsicht: Bei Feldnamen mit Umlauten geht das MEMICMP nicht!
3632 : : const static sal_Char *aFldNames[] = { "\x06""INHALT", "\x02""XE", // dt.
3633 : : "\x02""TC" }; // us
3634 : : const static sal_uInt8 aFldId[] = { 9, 4, 9 };
3635 : :
3636 [ + + ]: 18 : if( nLen < 0 )
3637 : : {
3638 : 9 : bIgnoreText = false;
3639 : : return;
3640 : : }
3641 : :
3642 : : // our methode was called from
3643 : : // ''Skip attributes of field contents'' loop within ReadTextAttr()
3644 [ + + ]: 9 : if( bIgnoreText )
3645 : : return;
3646 : :
3647 : 3 : bIgnoreText = true;
3648 : 3 : long nOldPos = pStrm->Tell();
3649 : :
3650 [ + - ]: 3 : WW8_CP nStartCp = pPlcxMan->Where() + pPlcxMan->GetCpOfs();
3651 : :
3652 [ + - ]: 3 : String sFieldName;
3653 : : sal_uInt16 nFieldLen = pSBase->WW8ReadString( *pStrm, sFieldName, nStartCp,
3654 [ + - ]: 3 : nChunk, eStructCharSet );
3655 : 3 : nStartCp+=nFieldLen;
3656 : :
3657 : 3 : xub_StrLen nC = 0;
3658 : : //If the first chunk did not start with a field start then
3659 : : //reset the stream position and give up
3660 [ + - ][ + - ]: 3 : if( !nFieldLen || (0x13 != sFieldName.GetChar( nC ))) // Field Start Mark
[ + - ]
3661 : : {
3662 : : // If Field End Mark found
3663 [ + - ][ - + ]: 3 : if( nFieldLen && (0x15 == sFieldName.GetChar( nC )))
[ - + ]
3664 : 0 : bIgnoreText = false;
3665 [ + - ]: 3 : pStrm->Seek( nOldPos );
3666 : : return; // kein Feld zu finden
3667 : : }
3668 : :
3669 : : xub_StrLen nFnd;
3670 : : //If this chunk does not contain a field end, keep reading chunks
3671 : : //until we find one, or we run out of text,
3672 [ # # ][ # # ]: 0 : while (STRING_NOTFOUND == (nFnd = sFieldName.Search(0x15)))
3673 : : {
3674 [ # # ]: 0 : String sTemp;
3675 : : nFieldLen = pSBase->WW8ReadString( *pStrm, sTemp,
3676 [ # # ]: 0 : nStartCp, nChunk, eStructCharSet );
3677 [ # # ]: 0 : sFieldName+=sTemp;
3678 : 0 : nStartCp+=nFieldLen;
3679 [ # # ]: 0 : if (!nFieldLen)
3680 : : break;
3681 [ # # ][ # # ]: 0 : }
3682 : :
3683 [ # # ]: 0 : pStrm->Seek( nOldPos );
3684 : :
3685 : : //if we have no 0x15 give up, otherwise erase everything from the 0x15
3686 : : //onwards
3687 [ # # ]: 0 : if (STRING_NOTFOUND == nFnd)
3688 : : return;
3689 : : else
3690 [ # # ]: 0 : sFieldName.Erase(nFnd);
3691 : :
3692 : 0 : nC++;
3693 [ # # ]: 0 : while( ' ' == sFieldName.GetChar( nC ))
3694 : 0 : nC++;
3695 : :
3696 [ # # ]: 0 : for( int i = 0; i < 3; i++ )
3697 : : {
3698 : 0 : const sal_Char* pName = aFldNames[i];
3699 : 0 : sal_uInt16 nNameLen = *pName++;
3700 [ # # ][ # # ]: 0 : if( sFieldName.EqualsIgnoreCaseAscii( pName, nC, nNameLen ) )
3701 : : {
3702 [ # # ][ # # ]: 0 : ImportTox( aFldId[i], sFieldName.Copy( nC + nNameLen ) );
[ # # ]
3703 : 0 : break; // keine Mehrfachnennungen moeglich
3704 : : }
3705 : : }
3706 : 0 : bIgnoreText = true;
3707 [ # # ][ + - ]: 18 : pStrm->Seek( nOldPos );
[ - + ]
3708 [ + - ][ + - ]: 54 : }
3709 : :
3710 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|