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 <com/sun/star/embed/ElementModes.hpp>
31 : :
32 : : #include <i18npool/mslangid.hxx>
33 : :
34 : : #include <unotools/ucbstreamhelper.hxx>
35 : : #include <rtl/random.h>
36 : :
37 : : #include <sfx2/docinf.hxx>
38 : : #include <sfx2/request.hxx>
39 : : #include <sfx2/frame.hxx>
40 : : #include <tools/urlobj.hxx>
41 : : #include <unotools/tempfile.hxx>
42 : :
43 : : #include <comphelper/docpasswordrequest.hxx>
44 : : #include <comphelper/string.hxx>
45 : :
46 : : #include <editeng/tstpitem.hxx>
47 : : #include <editeng/ulspitem.hxx>
48 : : #include <editeng/langitem.hxx>
49 : : #include <editeng/opaqitem.hxx>
50 : : #include <editeng/charhiddenitem.hxx>
51 : : #include <editeng/fontitem.hxx>
52 : : #include <svx/unoapi.hxx>
53 : : #include <svx/svdoole2.hxx>
54 : : #include <svx/svdoashp.hxx>
55 : : #include <svx/svxerr.hxx>
56 : : #include <filter/msfilter/mscodec.hxx>
57 : : #include <svx/svdmodel.hxx>
58 : : #include <svx/xflclit.hxx>
59 : :
60 : : #include <unotools/fltrcfg.hxx>
61 : : #include <fmtfld.hxx>
62 : : #include <fmturl.hxx>
63 : : #include <fmtinfmt.hxx>
64 : : #include <reffld.hxx>
65 : : #include <fmthdft.hxx>
66 : : #include <fmtcntnt.hxx>
67 : : #include <fmtcnct.hxx>
68 : : #include <fmtpdsc.hxx>
69 : : #include <ftninfo.hxx>
70 : : #include <fmtftn.hxx>
71 : : #include <txtftn.hxx>
72 : : #include <ndtxt.hxx> // class SwTxtNode
73 : : #include <pagedesc.hxx> // class SwPageDesc
74 : : #include <paratr.hxx>
75 : : #include <fmtclbl.hxx>
76 : : #include <section.hxx>
77 : : #include <docsh.hxx>
78 : : #include <docufld.hxx>
79 : : #include <swfltopt.hxx>
80 : : #include <viewsh.hxx>
81 : : #include <shellres.hxx>
82 : : #include <mdiexp.hxx> // Progress
83 : : #include <statstr.hrc> // ResId fuer Statusleiste
84 : : #include <swerror.h> // ERR_WW8_...
85 : : #include <swtable.hxx> // class SwTableLines, ...
86 : : // #i18732#
87 : : #include <fmtfollowtextflow.hxx>
88 : : #include <fchrfmt.hxx>
89 : : #include <charfmt.hxx>
90 : :
91 : :
92 : : #include <comphelper/extract.hxx>
93 : : #include <fltini.hxx>
94 : :
95 : : #include "writerwordglue.hxx"
96 : :
97 : :
98 : : #include "ww8par2.hxx" // class WW8RStyle, class WW8AnchorPara
99 : :
100 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
101 : : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
102 : : #include <svl/itemiter.hxx> //SfxItemIter
103 : :
104 : : #include <comphelper/processfactory.hxx>
105 : : #include <basic/basmgr.hxx>
106 : :
107 : : #include "ww8toolbar.hxx"
108 : : #include <osl/file.hxx>
109 : : #include <com/sun/star/document/XDocumentInfoSupplier.hpp>
110 : :
111 : : #include <breakit.hxx>
112 : :
113 : : #if OSL_DEBUG_LEVEL > 1
114 : : #include <iostream>
115 : : #include <dbgoutsw.hxx>
116 : : #endif
117 : : #include <unotools/localfilehelper.hxx>
118 : :
119 : : #include "WW8Sttbf.hxx"
120 : : #include "WW8FibData.hxx"
121 : :
122 : : using namespace ::com::sun::star;
123 : : using namespace sw::util;
124 : : using namespace sw::types;
125 : : using namespace nsHdFtFlags;
126 : :
127 : : #include <com/sun/star/i18n/ScriptType.hpp>
128 : : #include <unotools/pathoptions.hxx>
129 : : #include <com/sun/star/ucb/SimpleFileAccess.hpp>
130 : :
131 : : #include <com/sun/star/script/vba/XVBACompatibility.hpp>
132 : : #include <comphelper/mediadescriptor.hxx>
133 : : #include <oox/ole/vbaproject.hxx>
134 : : #include <oox/ole/olestorage.hxx>
135 : : #include <comphelper/componentcontext.hxx>
136 : :
137 : :
138 : : using ::comphelper::MediaDescriptor;
139 : : using ::comphelper::getProcessServiceFactory;
140 : :
141 : 102 : class BasicProjImportHelper
142 : : {
143 : : SwDocShell& mrDocShell;
144 : : uno::Reference< uno::XComponentContext > mxCtx;
145 : : public:
146 : 102 : BasicProjImportHelper( SwDocShell& rShell ) : mrDocShell( rShell )
147 : : {
148 [ + - ][ + - ]: 102 : comphelper::ComponentContext aCtx( ::comphelper::getProcessServiceFactory() );
149 [ + - ][ + - ]: 102 : mxCtx = aCtx.getUNOContext();
[ + - ]
150 : 102 : }
151 : : bool import( const uno::Reference< io::XInputStream >& rxIn );
152 : : rtl::OUString getProjectName();
153 : : };
154 : :
155 : 102 : bool BasicProjImportHelper::import( const uno::Reference< io::XInputStream >& rxIn )
156 : : {
157 : 102 : bool bRet = false;
158 : : try
159 : : {
160 [ + - ]: 102 : oox::ole::OleStorage root( mxCtx, rxIn, false );
161 [ + - ][ + - ]: 102 : oox::StorageRef vbaStg = root.openSubStorage( CREATE_OUSTRING( "Macros" ), false );
162 [ + + ]: 102 : if ( vbaStg.get() )
163 : : {
164 [ + - ][ + - ]: 3 : oox::ole::VbaProject aVbaPrj( mxCtx, mrDocShell.GetModel(), rtl::OUString("Writer") );
165 [ # # ][ - + ]: 3 : bRet = aVbaPrj.importVbaProject( *vbaStg );
166 [ + - ][ + - ]: 102 : }
[ - + ]
167 : : }
168 : 3 : catch( const uno::Exception& )
169 : : {
170 : 3 : bRet = false;
171 : : }
172 : 102 : return bRet;
173 : : }
174 : :
175 : 102 : rtl::OUString BasicProjImportHelper::getProjectName()
176 : : {
177 : 102 : rtl::OUString sProjName( "Standard" );
178 [ + - ][ + - ]: 102 : uno::Reference< beans::XPropertySet > xProps( mrDocShell.GetModel(), uno::UNO_QUERY );
179 [ + - ]: 102 : if ( xProps.is() )
180 : : {
181 : : try
182 : : {
183 [ + - ][ + - ]: 102 : uno::Reference< script::vba::XVBACompatibility > xVBA( xProps->getPropertyValue( "BasicLibraries" ), uno::UNO_QUERY_THROW );
[ + + ]
184 [ + - ][ - + ]: 102 : sProjName = xVBA->getProjectName();
[ + - ]
185 : :
186 : : }
187 [ + - ]: 87 : catch( const uno::Exception& )
188 : : {
189 : : }
190 : : }
191 : 102 : return sProjName;
192 : : }
193 : :
194 : :
195 : : class Sttb : TBBase
196 : : {
197 : 9396 : struct SBBItem
198 : : {
199 : : sal_uInt16 cchData;
200 : : rtl::OUString data;
201 : 1458 : SBBItem() : cchData(0){}
202 : : };
203 : : sal_uInt16 fExtend;
204 : : sal_uInt16 cData;
205 : : sal_uInt16 cbExtra;
206 : :
207 : : std::vector< SBBItem > dataItems;
208 : :
209 : : Sttb(const Sttb&);
210 : : Sttb& operator = ( const Sttb&);
211 : : public:
212 : : Sttb();
213 : : ~Sttb();
214 : : bool Read(SvStream &rS);
215 : : void Print( FILE* fp );
216 : : rtl::OUString getStringAtIndex( sal_uInt32 );
217 : : };
218 : :
219 : 87 : Sttb::Sttb() : fExtend( 0 )
220 : : ,cData( 0 )
221 [ + - ]: 87 : ,cbExtra( 0 )
222 : : {
223 : 87 : }
224 : :
225 : 87 : Sttb::~Sttb()
226 : : {
227 [ - + ]: 87 : }
228 : :
229 : 87 : bool Sttb::Read( SvStream& rS )
230 : : {
231 : : OSL_TRACE("Sttb::Read() stream pos 0x%x", rS.Tell() );
232 : 87 : nOffSet = rS.Tell();
233 : 87 : rS >> fExtend >> cData >> cbExtra;
234 [ + + ]: 87 : if ( cData )
235 : : {
236 [ + + ]: 1539 : for ( sal_Int32 index = 0; index < cData; ++index )
237 : : {
238 : 1458 : SBBItem aItem;
239 [ + - ]: 1458 : rS >> aItem.cchData;
240 [ + - ]: 1458 : aItem.data = read_uInt16s_ToOUString(rS, aItem.cchData);
241 [ + - ]: 1458 : dataItems.push_back( aItem );
242 : 1458 : }
243 : : }
244 : 87 : return true;
245 : : }
246 : :
247 : 0 : void Sttb::Print( FILE* fp )
248 : : {
249 : 0 : fprintf( fp, "[ 0x%" SAL_PRIxUINT32 " ] Sttb - dump\n", nOffSet);
250 : 0 : fprintf( fp, " fExtend 0x%x [expected 0xFFFF ]\n", fExtend );
251 : 0 : fprintf( fp, " cData no. or string data items %d (0x%x)\n", cData, cData );
252 : :
253 [ # # ]: 0 : if ( cData )
254 : : {
255 [ # # ]: 0 : for ( sal_Int32 index = 0; index < cData; ++index )
256 [ # # ]: 0 : fprintf(fp," string dataItem[ %d(0x%x) ] has name %s\n", static_cast< int >( index ), static_cast< unsigned int >( index ), rtl::OUStringToOString( dataItems[ index ].data, RTL_TEXTENCODING_UTF8 ).getStr() );
257 : : }
258 : :
259 : 0 : }
260 : :
261 : : rtl::OUString
262 : 87 : Sttb::getStringAtIndex( sal_uInt32 index )
263 : : {
264 : 87 : rtl::OUString aRet;
265 [ + + ]: 87 : if ( index < dataItems.size() )
266 : 81 : aRet = dataItems[ index ].data;
267 : 87 : return aRet;
268 : : }
269 : :
270 : 42 : SwMSDffManager::SwMSDffManager( SwWW8ImplReader& rRdr )
271 : 42 : : SvxMSDffManager(*rRdr.pTableStream, rRdr.GetBaseURL(), rRdr.pWwFib->fcDggInfo,
272 : : rRdr.pDataStream, 0, 0, COL_WHITE, 12, rRdr.pStrm),
273 [ + - ]: 42 : rReader(rRdr), pFallbackStream(0)
274 : : {
275 : 42 : SetSvxMSDffSettings( GetSvxMSDffSettings() );
276 [ + - ]: 42 : nSvxMSDffOLEConvFlags = SwMSDffManager::GetFilterFlags();
277 : 42 : }
278 : :
279 : 42 : sal_uInt32 SwMSDffManager::GetFilterFlags()
280 : : {
281 : 42 : sal_uInt32 nFlags(0);
282 : 42 : const SvtFilterOptions& rOpt = SvtFilterOptions::Get();
283 [ + - ]: 42 : if (rOpt.IsMathType2Math())
284 : 42 : nFlags |= OLE_MATHTYPE_2_STARMATH;
285 [ + - ]: 42 : if (rOpt.IsExcel2Calc())
286 : 42 : nFlags |= OLE_EXCEL_2_STARCALC;
287 [ + - ]: 42 : if (rOpt.IsPowerPoint2Impress())
288 : 42 : nFlags |= OLE_POWERPOINT_2_STARIMPRESS;
289 [ + - ]: 42 : if (rOpt.IsWinWord2Writer())
290 : 42 : nFlags |= OLE_WINWORD_2_STARWRITER;
291 : 42 : return nFlags;
292 : : }
293 : :
294 : : /*
295 : : * I would like to override the default OLE importing to add a test
296 : : * and conversion of OCX controls from their native OLE type into our
297 : : * native nonOLE Form Control Objects.
298 : : *
299 : : * cmc
300 : : */
301 : : // #i32596# - consider new parameter <_nCalledByGroup>
302 : 3 : SdrObject* SwMSDffManager::ImportOLE( long nOLEId,
303 : : const Graphic& rGrf,
304 : : const Rectangle& rBoundRect,
305 : : const Rectangle& rVisArea,
306 : : const int _nCalledByGroup,
307 : : sal_Int64 nAspect ) const
308 : : {
309 : : // #i32596# - no import of OLE object, if it's inside a group.
310 : : // NOTE: This can be undone, if grouping of Writer fly frames is possible or
311 : : // if drawing OLE objects are allowed in Writer.
312 [ - + ]: 3 : if ( _nCalledByGroup > 0 )
313 : : {
314 : 0 : return 0L;
315 : : }
316 : :
317 : 3 : SdrObject* pRet = 0;
318 [ + - ]: 3 : String sStorageName;
319 : 3 : SotStorageRef xSrcStg;
320 : 3 : uno::Reference < embed::XStorage > xDstStg;
321 [ + - ][ + - ]: 3 : if( GetOLEStorageName( nOLEId, sStorageName, xSrcStg, xDstStg ))
322 : : {
323 : : SvStorageRef xSrc = xSrcStg->OpenSotStorage( sStorageName,
324 [ + - ]: 3 : STREAM_READWRITE| STREAM_SHARE_DENYALL );
325 : : OSL_ENSURE(rReader.pFormImpl, "No Form Implementation!");
326 : 3 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape;
327 [ + - ][ + - ]: 6 : if ( (!(rReader.bIsHeader || rReader.bIsFooter)) &&
[ + - ][ + - ]
328 [ + - ]: 3 : rReader.pFormImpl->ReadOCXStream(xSrc,&xShape,true))
329 : : {
330 : 3 : pRet = GetSdrObjectFromXShape(xShape);
331 : : }
332 : : else
333 : : {
334 : 0 : ErrCode nError = ERRCODE_NONE;
335 : : pRet = CreateSdrOLEFromStorage( sStorageName, xSrcStg, xDstStg,
336 [ # # ]: 0 : rGrf, rBoundRect, rVisArea, pStData, nError, nSvxMSDffOLEConvFlags, nAspect );
337 [ + - ]: 3 : }
338 : : }
339 [ + - ][ + - ]: 3 : return pRet;
340 : : }
341 : :
342 : 18 : void SwMSDffManager::DisableFallbackStream()
343 : : {
344 : : OSL_ENSURE(!pFallbackStream,
345 : : "if you're recursive, you're broken");
346 : 18 : pFallbackStream = pStData2;
347 : 18 : aOldEscherBlipCache = aEscherBlipCache;
348 : 18 : aEscherBlipCache.clear();
349 : 18 : pStData2 = 0;
350 : 18 : }
351 : :
352 : 18 : void SwMSDffManager::EnableFallbackStream()
353 : : {
354 : 18 : pStData2 = pFallbackStream;
355 : 18 : aEscherBlipCache = aOldEscherBlipCache;
356 : 18 : aOldEscherBlipCache.clear();
357 : 18 : pFallbackStream = 0;
358 : 18 : }
359 : :
360 : 4482 : sal_uInt16 SwWW8ImplReader::GetToggleAttrFlags() const
361 : : {
362 [ + - ]: 4482 : return pCtrlStck ? pCtrlStck->GetToggleAttrFlags() : 0;
363 : : }
364 : :
365 : 4482 : sal_uInt16 SwWW8ImplReader::GetToggleBiDiAttrFlags() const
366 : : {
367 [ + - ]: 4482 : return pCtrlStck ? pCtrlStck->GetToggleBiDiAttrFlags() : 0;
368 : : }
369 : :
370 : 4482 : void SwWW8ImplReader::SetToggleAttrFlags(sal_uInt16 nFlags)
371 : : {
372 [ + - ]: 4482 : if (pCtrlStck)
373 : 4482 : pCtrlStck->SetToggleAttrFlags(nFlags);
374 : 4482 : }
375 : :
376 : 4482 : void SwWW8ImplReader::SetToggleBiDiAttrFlags(sal_uInt16 nFlags)
377 : : {
378 [ + - ]: 4482 : if (pCtrlStck)
379 : 4482 : pCtrlStck->SetToggleBiDiAttrFlags(nFlags);
380 : 4482 : }
381 : :
382 : :
383 : 537 : SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
384 : : DffObjData& rObjData,
385 : : void* pData,
386 : : Rectangle& rTextRect,
387 : : SdrObject* pObj
388 : : )
389 : : {
390 [ + - ]: 537 : if( !rTextRect.IsEmpty() )
391 : : {
392 : 537 : SvxMSDffImportData& rImportData = *(SvxMSDffImportData*)pData;
393 [ + - ]: 537 : SvxMSDffImportRec* pImpRec = new SvxMSDffImportRec;
394 : :
395 : : // fill Import Record with data
396 : 537 : pImpRec->nShapeId = rObjData.nShapeId;
397 : 537 : pImpRec->eShapeType = rObjData.eShapeType;
398 : :
399 : : rObjData.bClientAnchor = maShapeRecords.SeekToContent( rSt,
400 : : DFF_msofbtClientAnchor,
401 : 537 : SEEK_FROM_CURRENT_AND_RESTART );
402 [ + + ]: 537 : if( rObjData.bClientAnchor )
403 : : ProcessClientAnchor( rSt,
404 : 168 : maShapeRecords.Current()->nRecLen,
405 : 168 : pImpRec->pClientAnchorBuffer, pImpRec->nClientAnchorLen );
406 : :
407 : : rObjData.bClientData = maShapeRecords.SeekToContent( rSt,
408 : : DFF_msofbtClientData,
409 : 537 : SEEK_FROM_CURRENT_AND_RESTART );
410 [ + + ]: 537 : if( rObjData.bClientData )
411 : : ProcessClientData( rSt,
412 : 519 : maShapeRecords.Current()->nRecLen,
413 : 519 : pImpRec->pClientDataBuffer, pImpRec->nClientDataLen );
414 : :
415 : :
416 : : // process user (== Winword) defined parameters in 0xF122 record
417 : : // #i84783# - set special value to determine, if property is provided or not.
418 : 537 : pImpRec->nLayoutInTableCell = 0xFFFFFFFF;
419 : :
420 [ + + ]: 678 : if( maShapeRecords.SeekToContent( rSt,
[ + + + - ]
421 : : DFF_msofbtUDefProp,
422 : 537 : SEEK_FROM_CURRENT_AND_RESTART )
423 : 141 : && maShapeRecords.Current()->nRecLen )
424 : : {
425 [ + - ]: 141 : sal_uInt32 nBytesLeft = maShapeRecords.Current()->nRecLen;
426 : : sal_uInt32 nUDData;
427 : : sal_uInt16 nPID;
428 [ + + ]: 1494 : while( 5 < nBytesLeft )
429 : : {
430 [ + - ]: 1353 : rSt >> nPID;
431 [ - + ]: 1353 : if ( rSt.GetError() != 0 )
432 : 0 : break;
433 [ + - ]: 1353 : rSt >> nUDData;
434 [ + + + + : 1353 : switch( nPID )
+ + + + ]
435 : : {
436 : 48 : case 0x038F: pImpRec->nXAlign = nUDData; break;
437 : : case 0x0390:
438 : 15 : delete pImpRec->pXRelTo;
439 [ + - ]: 15 : pImpRec->pXRelTo = new sal_uInt32;
440 : 15 : *(pImpRec->pXRelTo) = nUDData;
441 : 15 : break;
442 : 48 : case 0x0391: pImpRec->nYAlign = nUDData; break;
443 : : case 0x0392:
444 : 15 : delete pImpRec->pYRelTo;
445 [ + - ]: 15 : pImpRec->pYRelTo = new sal_uInt32;
446 : 15 : *(pImpRec->pYRelTo) = nUDData;
447 : 15 : break;
448 : 87 : case 0x03BF: pImpRec->nLayoutInTableCell = nUDData; break;
449 : : case 0x0393:
450 : : // This seems to correspond to o:hrpct from .docx (even including
451 : : // the difference that it's in 0.1% even though the .docx spec
452 : : // says it's in 1%).
453 : 9 : pImpRec->relativeHorizontalWidth = nUDData;
454 : 9 : break;
455 : : case 0x0394:
456 : : // And this is really just a guess, but a mere presence of this
457 : : // flag makes a horizontal rule be as wide as the page (unless
458 : : // overriden by something), so it probably matches o:hr from .docx.
459 : 12 : pImpRec->isHorizontalRule = true;
460 : 12 : break;
461 : : }
462 [ - + ]: 1353 : if ( rSt.GetError() != 0 )
463 : 0 : break;
464 : 1353 : pImpRec->bHasUDefProp = sal_True;
465 : 1353 : nBytesLeft -= 6;
466 : : }
467 : : }
468 : :
469 : : // Textrahmen, auch Title oder Outline
470 : 537 : sal_uInt32 nTextId = GetPropertyValue( DFF_Prop_lTxid, 0 );
471 [ + + ]: 537 : if( nTextId )
472 : : {
473 [ + - ]: 147 : SfxItemSet aSet( pSdrModel->GetItemPool() );
474 : :
475 : : //Originally anything that as a mso_sptTextBox was created as a
476 : : //textbox, this was changed for #88277# to be created as a simple
477 : : //rect to keep impress happy. For the rest of us we'd like to turn
478 : : //it back into a textbox again.
479 : 147 : sal_Bool bIsSimpleDrawingTextBox = (pImpRec->eShapeType == mso_sptTextBox);
480 [ + + ]: 147 : if (!bIsSimpleDrawingTextBox)
481 : : {
482 : : //Either
483 : : //a) its a simple text object or
484 : : //b) its a rectangle with text and square wrapping.
485 : : bIsSimpleDrawingTextBox =
486 : : (
487 : : (pImpRec->eShapeType == mso_sptTextSimple) ||
488 : : (
489 : : (pImpRec->eShapeType == mso_sptRectangle)
490 [ + - ]: 144 : && ShapeHasText(pImpRec->nShapeId, rObjData.rSpHd.GetRecBegFilePos() )
491 : : )
492 [ + - ][ + - ]: 288 : );
[ + - ]
493 : : }
494 : :
495 : : // Distance of Textbox to it's surrounding Autoshape
496 [ + - ]: 147 : sal_Int32 nTextLeft = GetPropertyValue( DFF_Prop_dxTextLeft, 91440L);
497 [ + - ]: 147 : sal_Int32 nTextRight = GetPropertyValue( DFF_Prop_dxTextRight, 91440L );
498 [ + - ]: 147 : sal_Int32 nTextTop = GetPropertyValue( DFF_Prop_dyTextTop, 45720L );
499 [ + - ]: 147 : sal_Int32 nTextBottom = GetPropertyValue( DFF_Prop_dyTextBottom, 45720L );
500 : :
501 [ + - ]: 147 : ScaleEmu( nTextLeft );
502 [ + - ]: 147 : ScaleEmu( nTextRight );
503 [ + - ]: 147 : ScaleEmu( nTextTop );
504 [ + - ]: 147 : ScaleEmu( nTextBottom );
505 : :
506 : 147 : sal_Int32 nTextRotationAngle=0;
507 : 147 : bool bVerticalText = false;
508 [ - + ]: 147 : if ( IsProperty( DFF_Prop_txflTextFlow ) )
509 : : {
510 : : MSO_TextFlow eTextFlow = (MSO_TextFlow)(GetPropertyValue(
511 [ # # ]: 0 : DFF_Prop_txflTextFlow) & 0xFFFF);
512 [ # # # # : 0 : switch( eTextFlow )
# ]
513 : : {
514 : : case mso_txflBtoT:
515 : 0 : nTextRotationAngle = 9000;
516 : 0 : break;
517 : : case mso_txflVertN:
518 : : case mso_txflTtoBN:
519 : 0 : nTextRotationAngle = 27000;
520 : 0 : break;
521 : : case mso_txflTtoBA:
522 : 0 : bVerticalText = true;
523 : 0 : break;
524 : : case mso_txflHorzA:
525 : 0 : bVerticalText = true;
526 : 0 : nTextRotationAngle = 9000;
527 : : case mso_txflHorzN:
528 : : default :
529 : 0 : break;
530 : : }
531 : : }
532 : :
533 [ - + ]: 147 : if (nTextRotationAngle)
534 : : {
535 [ # # ]: 0 : while (nTextRotationAngle > 360000)
536 : 0 : nTextRotationAngle-=9000;
537 [ # # # ]: 0 : switch (nTextRotationAngle)
538 : : {
539 : : case 9000:
540 : : {
541 [ # # ]: 0 : long nWidth = rTextRect.GetWidth();
542 [ # # ]: 0 : rTextRect.Right() = rTextRect.Left() + rTextRect.GetHeight();
543 : 0 : rTextRect.Bottom() = rTextRect.Top() + nWidth;
544 : :
545 : 0 : sal_Int32 nOldTextLeft = nTextLeft;
546 : 0 : sal_Int32 nOldTextRight = nTextRight;
547 : 0 : sal_Int32 nOldTextTop = nTextTop;
548 : 0 : sal_Int32 nOldTextBottom = nTextBottom;
549 : :
550 : 0 : nTextLeft = nOldTextBottom;
551 : 0 : nTextRight = nOldTextTop;
552 : 0 : nTextTop = nOldTextLeft;
553 : 0 : nTextBottom = nOldTextRight;
554 : : }
555 : 0 : break;
556 : : case 27000:
557 : : {
558 [ # # ]: 0 : long nWidth = rTextRect.GetWidth();
559 [ # # ]: 0 : rTextRect.Right() = rTextRect.Left() + rTextRect.GetHeight();
560 : 0 : rTextRect.Bottom() = rTextRect.Top() + nWidth;
561 : :
562 : 0 : sal_Int32 nOldTextLeft = nTextLeft;
563 : 0 : sal_Int32 nOldTextRight = nTextRight;
564 : 0 : sal_Int32 nOldTextTop = nTextTop;
565 : 0 : sal_Int32 nOldTextBottom = nTextBottom;
566 : :
567 : 0 : nTextLeft = nOldTextTop;
568 : 0 : nTextRight = nOldTextBottom;
569 : 0 : nTextTop = nOldTextRight;
570 : 0 : nTextBottom = nOldTextLeft;
571 : : }
572 : 0 : break;
573 : : default:
574 : 0 : break;
575 : : }
576 : : }
577 : :
578 [ + - ]: 147 : if (bIsSimpleDrawingTextBox)
579 : : {
580 [ + - ]: 147 : SdrObject::Free( pObj );
581 [ + - ][ + - ]: 147 : pObj = new SdrRectObj(OBJ_TEXT, rTextRect);
582 : : }
583 : :
584 : : // Die vertikalen Absatzeinrueckungen sind im BoundRect mit drin,
585 : : // hier rausrechnen
586 : 147 : Rectangle aNewRect(rTextRect);
587 : 147 : aNewRect.Bottom() -= nTextTop + nTextBottom;
588 : 147 : aNewRect.Right() -= nTextLeft + nTextRight;
589 : :
590 : : // Nur falls es eine einfache Textbox ist, darf der Writer
591 : : // das Objekt durch einen Rahmen ersetzen, ansonsten
592 [ + - ]: 147 : if( bIsSimpleDrawingTextBox )
593 : : {
594 : : ::boost::shared_ptr<SvxMSDffShapeInfo> const pTmpRec(
595 [ + - ][ + - ]: 147 : new SvxMSDffShapeInfo(0, pImpRec->nShapeId));
596 : :
597 : : SvxMSDffShapeInfos_ById::const_iterator const it =
598 [ + - ][ + - ]: 147 : GetShapeInfos()->find(pTmpRec);
599 [ + - ][ + - ]: 147 : if (it != GetShapeInfos()->end())
600 : : {
601 : 147 : SvxMSDffShapeInfo& rInfo = **it;
602 : 147 : pImpRec->bReplaceByFly = rInfo.bReplaceByFly;
603 : 147 : pImpRec->bLastBoxInChain = rInfo.bLastBoxInChain;
604 [ + - ]: 147 : }
605 : : }
606 : :
607 [ + - ]: 147 : if( bIsSimpleDrawingTextBox )
608 [ + - ]: 147 : ApplyAttributes( rSt, aSet, rObjData );
609 : :
610 [ + - ][ - + ]: 147 : if (GetPropertyValue(DFF_Prop_FitTextToShape) & 2)
611 : : {
612 [ # # ][ # # ]: 0 : aSet.Put( SdrTextAutoGrowHeightItem( sal_True ) );
[ # # ]
613 : : aSet.Put( SdrTextMinFrameHeightItem(
614 [ # # ][ # # ]: 0 : aNewRect.Bottom() - aNewRect.Top() ) );
[ # # ]
615 : : aSet.Put( SdrTextMinFrameWidthItem(
616 [ # # ][ # # ]: 0 : aNewRect.Right() - aNewRect.Left() ) );
[ # # ]
617 : : }
618 : : else
619 : : {
620 [ + - ][ + - ]: 147 : aSet.Put( SdrTextAutoGrowHeightItem( sal_False ) );
[ + - ]
621 [ + - ][ + - ]: 147 : aSet.Put( SdrTextAutoGrowWidthItem( sal_False ) );
[ + - ]
622 : : }
623 : :
624 [ - - + ]: 147 : switch ( (MSO_WrapMode)
625 [ + - ]: 147 : GetPropertyValue( DFF_Prop_WrapText, mso_wrapSquare ) )
626 : : {
627 : : case mso_wrapNone :
628 [ # # ][ # # ]: 0 : aSet.Put( SdrTextAutoGrowWidthItem( sal_True ) );
[ # # ]
629 : 0 : pImpRec->bAutoWidth = true;
630 : 0 : break;
631 : : case mso_wrapByPoints :
632 [ # # ][ # # ]: 0 : aSet.Put( SdrTextContourFrameItem( sal_True ) );
[ # # ]
633 : 0 : break;
634 : : default:
635 : : ;
636 : : }
637 : :
638 : : // Abstaende an den Raendern der Textbox setzen
639 [ + - ][ + - ]: 147 : aSet.Put( SdrTextLeftDistItem( nTextLeft ) );
[ + - ]
640 [ + - ][ + - ]: 147 : aSet.Put( SdrTextRightDistItem( nTextRight ) );
[ + - ]
641 [ + - ][ + - ]: 147 : aSet.Put( SdrTextUpperDistItem( nTextTop ) );
[ + - ]
642 [ + - ][ + - ]: 147 : aSet.Put( SdrTextLowerDistItem( nTextBottom ) );
[ + - ]
643 : 147 : pImpRec->nDxTextLeft = nTextLeft;
644 : 147 : pImpRec->nDyTextTop = nTextTop;
645 : 147 : pImpRec->nDxTextRight = nTextRight;
646 : 147 : pImpRec->nDyTextBottom = nTextBottom;
647 : :
648 : : // taking the correct default (which is mso_anchorTop)
649 : : MSO_Anchor eTextAnchor =
650 [ + - ]: 147 : (MSO_Anchor)GetPropertyValue( DFF_Prop_anchorText, mso_anchorTop );
651 : :
652 : : SdrTextVertAdjust eTVA = bVerticalText
653 : : ? SDRTEXTVERTADJUST_BLOCK
654 [ - + ]: 147 : : SDRTEXTVERTADJUST_CENTER;
655 : : SdrTextHorzAdjust eTHA = bVerticalText
656 : : ? SDRTEXTHORZADJUST_CENTER
657 [ - + ]: 147 : : SDRTEXTHORZADJUST_BLOCK;
658 : :
659 [ + - - - : 147 : switch( eTextAnchor )
- - - ]
660 : : {
661 : : case mso_anchorTop:
662 : : {
663 [ - + ]: 147 : if ( bVerticalText )
664 : 0 : eTHA = SDRTEXTHORZADJUST_RIGHT;
665 : : else
666 : 147 : eTVA = SDRTEXTVERTADJUST_TOP;
667 : : }
668 : 147 : break;
669 : : case mso_anchorTopCentered:
670 : : {
671 [ # # ]: 0 : if ( bVerticalText )
672 : 0 : eTHA = SDRTEXTHORZADJUST_RIGHT;
673 : : else
674 : 0 : eTVA = SDRTEXTVERTADJUST_TOP;
675 : : }
676 : 0 : break;
677 : : case mso_anchorMiddle:
678 : 0 : break;
679 : : case mso_anchorMiddleCentered:
680 : 0 : break;
681 : : case mso_anchorBottom:
682 : : {
683 [ # # ]: 0 : if ( bVerticalText )
684 : 0 : eTHA = SDRTEXTHORZADJUST_LEFT;
685 : : else
686 : 0 : eTVA = SDRTEXTVERTADJUST_BOTTOM;
687 : : }
688 : 0 : break;
689 : : case mso_anchorBottomCentered:
690 : : {
691 [ # # ]: 0 : if ( bVerticalText )
692 : 0 : eTHA = SDRTEXTHORZADJUST_LEFT;
693 : : else
694 : 0 : eTVA = SDRTEXTVERTADJUST_BOTTOM;
695 : : }
696 : 0 : break;
697 : : default:
698 : : ;
699 : : }
700 : :
701 [ + - ][ + - ]: 147 : aSet.Put( SdrTextVertAdjustItem( eTVA ) );
[ + - ]
702 [ + - ][ + - ]: 147 : aSet.Put( SdrTextHorzAdjustItem( eTHA ) );
[ + - ]
703 : :
704 [ + - ]: 147 : if (pObj != NULL)
705 : : {
706 [ + - ]: 147 : pObj->SetMergedItemSet(aSet);
707 [ + - ]: 147 : pObj->SetModel(pSdrModel);
708 : :
709 [ - + ][ # # ]: 147 : if (bVerticalText && dynamic_cast< SdrTextObj* >( pObj ) )
[ # # ][ - + ]
710 [ # # ][ # # ]: 0 : dynamic_cast< SdrTextObj* >( pObj )->SetVerticalWriting(sal_True);
711 : :
712 [ + - ]: 147 : if ( bIsSimpleDrawingTextBox )
713 : : {
714 [ - + ]: 147 : if ( nTextRotationAngle )
715 : : {
716 [ # # ][ # # ]: 0 : long nMinWH = rTextRect.GetWidth() < rTextRect.GetHeight() ?
717 [ # # ][ # # ]: 0 : rTextRect.GetWidth() : rTextRect.GetHeight();
[ # # ]
718 : 0 : nMinWH /= 2;
719 : 0 : Point aPivot(rTextRect.TopLeft());
720 : 0 : aPivot.X() += nMinWH;
721 : 0 : aPivot.Y() += nMinWH;
722 : 0 : double a = nTextRotationAngle * nPi180;
723 [ # # ]: 0 : pObj->NbcRotate(aPivot, nTextRotationAngle, sin(a), cos(a));
724 : : }
725 : : }
726 : :
727 [ + - ][ + - ]: 147 : if ( ( ( rObjData.nSpFlags & SP_FFLIPV ) || mnFix16Angle || nTextRotationAngle ) && dynamic_cast< SdrObjCustomShape* >( pObj ) )
[ - + ][ # # ]
[ # # ][ - + ]
728 : : {
729 [ # # ]: 0 : SdrObjCustomShape* pCustomShape = dynamic_cast< SdrObjCustomShape* >( pObj );
730 : :
731 : 0 : double fExtraTextRotation = 0.0;
732 [ # # ][ # # ]: 0 : if ( mnFix16Angle && !( GetPropertyValue( DFF_Prop_FitTextToShape ) & 4 ) )
[ # # ][ # # ]
733 : : { // text is already rotated, we have to take back the object rotation if DFF_Prop_RotateText is false
734 : 0 : fExtraTextRotation = -mnFix16Angle;
735 : : }
736 [ # # ]: 0 : if ( rObjData.nSpFlags & SP_FFLIPV ) // sj: in ppt the text is flipped, whereas in word the text
737 : : { // remains unchanged, so we have to take back the flipping here
738 : 0 : fExtraTextRotation += 18000.0; // because our core will flip text if the shape is flipped.
739 : : }
740 : 0 : fExtraTextRotation += nTextRotationAngle;
741 [ # # ]: 0 : if ( !::basegfx::fTools::equalZero( fExtraTextRotation ) )
742 : : {
743 : 0 : fExtraTextRotation /= 100.0;
744 [ # # ][ # # ]: 0 : SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pCustomShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
745 : 0 : const rtl::OUString sTextRotateAngle( "TextRotateAngle" );
746 : 0 : com::sun::star::beans::PropertyValue aPropVal;
747 : 0 : aPropVal.Name = sTextRotateAngle;
748 [ # # ]: 0 : aPropVal.Value <<= fExtraTextRotation;
749 [ # # ]: 0 : aGeometryItem.SetPropertyValue( aPropVal );
750 [ # # ][ # # ]: 0 : pCustomShape->SetMergedItem( aGeometryItem );
751 : : }
752 : : }
753 [ - + ]: 147 : else if ( mnFix16Angle )
754 : : {
755 : : // rotate text with shape ?
756 : 0 : double a = mnFix16Angle * nPi180;
757 : 0 : pObj->NbcRotate( rObjData.aBoundRect.Center(), mnFix16Angle,
758 [ # # ][ # # ]: 0 : sin( a ), cos( a ) );
759 : : }
760 [ + - ]: 147 : }
761 : : }
762 [ - + ]: 390 : else if( !pObj )
763 : : {
764 : : // simple rectangular objects are ignored by ImportObj() :-(
765 : : // this is OK for Draw but not for Calc and Writer
766 : : // cause here these objects have a default border
767 [ # # ][ # # ]: 0 : pObj = new SdrRectObj(rTextRect);
768 [ # # ]: 0 : pObj->SetModel( pSdrModel );
769 [ # # ]: 0 : SfxItemSet aSet( pSdrModel->GetItemPool() );
770 [ # # ]: 0 : ApplyAttributes( rSt, aSet, rObjData );
771 : :
772 : 0 : const SfxPoolItem* pPoolItem=NULL;
773 : : SfxItemState eState = aSet.GetItemState( XATTR_FILLCOLOR,
774 [ # # ]: 0 : sal_False, &pPoolItem );
775 [ # # ]: 0 : if( SFX_ITEM_DEFAULT == eState )
776 : : aSet.Put( XFillColorItem( String(),
777 [ # # ][ # # ]: 0 : Color( mnDefaultColor ) ) );
[ # # ][ # # ]
[ # # ]
778 [ # # ][ # # ]: 0 : pObj->SetMergedItemSet(aSet);
779 : : }
780 : :
781 : : //Means that fBehindDocument is set
782 [ - + ]: 537 : if (GetPropertyValue(DFF_Prop_fPrint) & 0x20)
783 : 0 : pImpRec->bDrawHell = sal_True;
784 : : else
785 : 537 : pImpRec->bDrawHell = sal_False;
786 [ - + ]: 537 : if (GetPropertyValue(DFF_Prop_fPrint) & 0x02)
787 : 0 : pImpRec->bHidden = sal_True;
788 : 537 : pImpRec->nNextShapeId = GetPropertyValue( DFF_Prop_hspNext, 0 );
789 : :
790 [ + + ]: 537 : if ( nTextId )
791 : : {
792 : 147 : pImpRec->aTextId.nTxBxS = (sal_uInt16)( nTextId >> 16 );
793 : 147 : pImpRec->aTextId.nSequence = (sal_uInt16)nTextId;
794 : : }
795 : :
796 : : pImpRec->nDxWrapDistLeft = GetPropertyValue(
797 : 537 : DFF_Prop_dxWrapDistLeft, 114935L ) / 635L;
798 : : pImpRec->nDyWrapDistTop = GetPropertyValue(
799 : 537 : DFF_Prop_dyWrapDistTop, 0 ) / 635L;
800 : : pImpRec->nDxWrapDistRight = GetPropertyValue(
801 : 537 : DFF_Prop_dxWrapDistRight, 114935L ) / 635L;
802 : : pImpRec->nDyWrapDistBottom = GetPropertyValue(
803 : 537 : DFF_Prop_dyWrapDistBottom, 0 ) / 635L;
804 : : // 16.16 fraction times total image width or height, as appropriate.
805 : :
806 [ - + ]: 537 : if (SeekToContent(DFF_Prop_pWrapPolygonVertices, rSt))
807 : : {
808 [ # # ][ # # ]: 0 : delete pImpRec->pWrapPolygon;
809 : : sal_uInt16 nNumElemVert, nNumElemMemVert, nElemSizeVert;
810 [ # # ][ # # ]: 0 : rSt >> nNumElemVert >> nNumElemMemVert >> nElemSizeVert;
[ # # ]
811 [ # # ][ # # ]: 0 : if (nNumElemVert && ((nElemSizeVert == 8) || (nElemSizeVert == 4)))
[ # # ]
812 : : {
813 [ # # ][ # # ]: 0 : pImpRec->pWrapPolygon = new Polygon(nNumElemVert);
814 [ # # ]: 0 : for (sal_uInt16 i = 0; i < nNumElemVert; ++i)
815 : : {
816 : : sal_Int32 nX, nY;
817 [ # # ]: 0 : if (nElemSizeVert == 8)
818 [ # # ][ # # ]: 0 : rSt >> nX >> nY;
819 : : else
820 : : {
821 : : sal_Int16 nSmallX, nSmallY;
822 [ # # ][ # # ]: 0 : rSt >> nSmallX >> nSmallY;
823 : 0 : nX = nSmallX;
824 : 0 : nY = nSmallY;
825 : : }
826 [ # # ]: 0 : (*(pImpRec->pWrapPolygon))[i].X() = nX;
827 [ # # ]: 0 : (*(pImpRec->pWrapPolygon))[i].Y() = nY;
828 : : }
829 : : }
830 : : }
831 : :
832 : : pImpRec->nCropFromTop = GetPropertyValue(
833 : 537 : DFF_Prop_cropFromTop, 0 );
834 : : pImpRec->nCropFromBottom = GetPropertyValue(
835 : 537 : DFF_Prop_cropFromBottom, 0 );
836 : : pImpRec->nCropFromLeft = GetPropertyValue(
837 : 537 : DFF_Prop_cropFromLeft, 0 );
838 : : pImpRec->nCropFromRight = GetPropertyValue(
839 : 537 : DFF_Prop_cropFromRight, 0 );
840 : :
841 : 537 : sal_uInt32 nLineFlags = GetPropertyValue( DFF_Prop_fNoLineDrawDash );
842 : :
843 [ - + ][ - + ]: 537 : if ( !IsHardAttribute( DFF_Prop_fLine ) &&
[ + + ]
844 : : pImpRec->eShapeType == mso_sptPictureFrame )
845 : : {
846 : 0 : nLineFlags &= ~0x08;
847 : : }
848 : :
849 : : pImpRec->eLineStyle = (nLineFlags & 8)
850 : : ? (MSO_LineStyle)GetPropertyValue(
851 : : DFF_Prop_lineStyle,
852 : 324 : mso_lineSimple )
853 [ + + ]: 537 : : (MSO_LineStyle)USHRT_MAX;
854 : : pImpRec->eLineDashing = (MSO_LineDashing)GetPropertyValue(
855 : 537 : DFF_Prop_lineDashing, mso_lineSolid );
856 : :
857 : 537 : pImpRec->nFlags = rObjData.nSpFlags;
858 : :
859 [ + - ]: 537 : if( pImpRec->nShapeId )
860 : : {
861 : : // Import-Record-Liste ergaenzen
862 : 537 : pImpRec->pObj = pObj;
863 : 537 : rImportData.aRecords.insert( pImpRec );
864 : :
865 : : // Eintrag in Z-Order-Liste um Zeiger auf dieses Objekt ergaenzen
866 : : /*Only store objects which are not deep inside the tree*/
867 [ + + ][ + - ]: 537 : if( ( rObjData.nCalledByGroup == 0 )
[ + + ]
868 : : ||
869 : : ( (rObjData.nSpFlags & SP_FGROUP)
870 : : && (rObjData.nCalledByGroup < 2) )
871 : : )
872 : : StoreShapeOrder( pImpRec->nShapeId,
873 : : ( ( (sal_uLong)pImpRec->aTextId.nTxBxS ) << 16 )
874 : 177 : + pImpRec->aTextId.nSequence, pObj );
875 : : }
876 : : else
877 [ # # ]: 0 : delete pImpRec;
878 : : }
879 : :
880 : 537 : return pObj;
881 : : }
882 : :
883 : : /***************************************************************************
884 : : # Spezial FastSave - Attribute
885 : : #**************************************************************************/
886 : :
887 : 0 : void SwWW8ImplReader::Read_StyleCode( sal_uInt16, const sal_uInt8* pData, short nLen )
888 : : {
889 [ # # ]: 0 : if (nLen < 0)
890 : : {
891 : 0 : bCpxStyle = false;
892 : 0 : return;
893 : : }
894 : 0 : sal_uInt16 nColl = 0;
895 [ # # ]: 0 : if (pWwFib->GetFIBVersion() <= ww::eWW2)
896 : 0 : nColl = *pData;
897 : : else
898 : 0 : nColl = SVBT16ToShort(pData);
899 [ # # ]: 0 : if (nColl < vColl.size())
900 : : {
901 : 0 : SetTxtFmtCollAndListLevel( *pPaM, vColl[nColl] );
902 : 0 : bCpxStyle = true;
903 : : }
904 : : }
905 : :
906 : : // Read_Majority ist fuer Majority ( 103 ) und Majority50 ( 108 )
907 : 0 : void SwWW8ImplReader::Read_Majority( sal_uInt16, const sal_uInt8* , short )
908 : : {
909 : 0 : }
910 : :
911 : : //-----------------------------------------
912 : : // Stack
913 : : //-----------------------------------------
914 : 12054 : void SwWW8FltControlStack::NewAttr(const SwPosition& rPos,
915 : : const SfxPoolItem& rAttr)
916 : : {
917 : : OSL_ENSURE(RES_TXTATR_FIELD != rAttr.Which(), "probably don't want to put"
918 : : "fields into the control stack");
919 : : OSL_ENSURE(RES_FLTR_REDLINE != rAttr.Which(), "probably don't want to put"
920 : : "redlines into the control stack");
921 : 12054 : SwFltControlStack::NewAttr(rPos, rAttr);
922 : 12054 : }
923 : :
924 : 24210 : SwFltStackEntry* SwWW8FltControlStack::SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId,
925 : : sal_Bool bTstEnde, long nHand, sal_Bool )
926 : : {
927 : 24210 : SwFltStackEntry *pRet = NULL;
928 : : //Doing a textbox, and using the control stack only as a temporary
929 : : //collection point for properties which will are not to be set into
930 : : //the real document
931 [ + + ][ + + ]: 24210 : if (rReader.pPlcxMan && rReader.pPlcxMan->GetDoingDrawTextBox())
[ + + ]
932 : : {
933 : 1404 : size_t nCnt = size();
934 [ + + ]: 4464 : for (size_t i=0; i < nCnt; ++i)
935 : : {
936 : 3060 : SwFltStackEntry& rEntry = (*this)[i];
937 [ + + ]: 3060 : if (nAttrId == rEntry.pAttr->Which())
938 : : {
939 : 288 : DeleteAndDestroy(i--);
940 : 288 : --nCnt;
941 : : }
942 : : }
943 : : }
944 : : else //Normal case, set the attribute into the document
945 : 22806 : pRet = SwFltControlStack::SetAttr(rPos, nAttrId, bTstEnde, nHand);
946 : 24210 : return pRet;
947 : : }
948 : :
949 : 0 : long GetListFirstLineIndent(const SwNumFmt &rFmt)
950 : : {
951 : : OSL_ENSURE( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION,
952 : : "<GetListFirstLineIndent> - misusage: position-and-space-mode does not equal LABEL_WIDTH_AND_POSITION" );
953 : :
954 : 0 : SvxAdjust eAdj = rFmt.GetNumAdjust();
955 : : long nReverseListIndented;
956 [ # # ]: 0 : if (eAdj == SVX_ADJUST_RIGHT)
957 : 0 : nReverseListIndented = -rFmt.GetCharTextDistance();
958 [ # # ]: 0 : else if (eAdj == SVX_ADJUST_CENTER)
959 : 0 : nReverseListIndented = rFmt.GetFirstLineOffset()/2;
960 : : else
961 : 0 : nReverseListIndented = rFmt.GetFirstLineOffset();
962 : 0 : return nReverseListIndented;
963 : : }
964 : :
965 : 0 : long lcl_GetTrueMargin(const SvxLRSpaceItem &rLR, const SwNumFmt &rFmt,
966 : : long &rFirstLinePos)
967 : : {
968 : : OSL_ENSURE( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION,
969 : : "<lcl_GetTrueMargin> - misusage: position-and-space-mode does not equal LABEL_WIDTH_AND_POSITION" );
970 : :
971 : 0 : const long nBodyIndent = rLR.GetTxtLeft();
972 : 0 : const long nFirstLineDiff = rLR.GetTxtFirstLineOfst();
973 : 0 : rFirstLinePos = nBodyIndent + nFirstLineDiff;
974 : :
975 : 0 : const long nPseudoListBodyIndent = rFmt.GetAbsLSpace();
976 : 0 : const long nReverseListIndented = GetListFirstLineIndent(rFmt);
977 : 0 : long nExtraListIndent = nPseudoListBodyIndent + nReverseListIndented;
978 : :
979 : 0 : return nExtraListIndent > 0 ? nExtraListIndent : 0;
980 : : }
981 : :
982 : : // #i103711#
983 : : // #i105414#
984 : 153 : void SyncIndentWithList( SvxLRSpaceItem &rLR,
985 : : const SwNumFmt &rFmt,
986 : : const bool bFirstLineOfstSet,
987 : : const bool bLeftIndentSet )
988 : : {
989 [ - + ]: 153 : if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
990 : : {
991 : : long nWantedFirstLinePos;
992 [ # # ]: 0 : long nExtraListIndent = lcl_GetTrueMargin(rLR, rFmt, nWantedFirstLinePos);
993 [ # # ]: 0 : rLR.SetTxtLeft(nWantedFirstLinePos - nExtraListIndent);
994 [ # # ]: 0 : rLR.SetTxtFirstLineOfst(0);
995 : : }
996 [ + - ]: 153 : else if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
997 : : {
998 [ + + ]: 297 : if ( !bFirstLineOfstSet && bLeftIndentSet &&
[ + - - + ]
[ - + ]
999 : 144 : rFmt.GetFirstLineIndent() != 0 )
1000 : : {
1001 : 0 : rLR.SetTxtFirstLineOfst( rFmt.GetFirstLineIndent() );
1002 : : }
1003 [ + + ]: 153 : else if ( bFirstLineOfstSet && !bLeftIndentSet &&
[ - + # # ]
[ - + ]
1004 : 0 : rFmt.GetIndentAt() != 0 )
1005 : : {
1006 : 0 : rLR.SetTxtLeft( rFmt.GetIndentAt() );
1007 : : }
1008 : : }
1009 : 153 : }
1010 : :
1011 : 1305 : const SwNumFmt* SwWW8FltControlStack::GetNumFmtFromStack(const SwPosition &rPos,
1012 : : const SwTxtNode &rTxtNode)
1013 : : {
1014 : 1305 : const SwNumFmt *pRet = 0;
1015 : 1305 : const SfxPoolItem *pItem = GetStackAttr(rPos, RES_FLTR_NUMRULE);
1016 [ # # ][ - + ]: 1305 : if (pItem && rTxtNode.GetNumRule())
[ - + ]
1017 : : {
1018 [ # # ]: 0 : String sName(((SfxStringItem*)pItem)->GetValue());
1019 [ # # ][ # # ]: 0 : if (rTxtNode.IsCountedInList())
1020 : : {
1021 [ # # ]: 0 : const SwNumRule *pRule = pDoc->FindNumRulePtr(sName);
1022 [ # # ]: 0 : sal_uInt8 nLvl = static_cast< sal_uInt8 >(rTxtNode.GetActualListLevel());
1023 [ # # ]: 0 : pRet = &(pRule->Get(nLvl));
1024 [ # # ]: 0 : }
1025 : : }
1026 : 1305 : return pRet;
1027 : : }
1028 : :
1029 : 8832 : void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
1030 : : SwFltStackEntry& rEntry)
1031 : : {
1032 [ + - + + ]: 8832 : switch (rEntry.pAttr->Which())
1033 : : {
1034 : : case RES_LR_SPACE:
1035 : : {
1036 : : /*
1037 : : Loop over the affect nodes and
1038 : : a) convert the word style absolute indent to indent relative
1039 : : to any numbering indent active on the nodes
1040 : : b) adjust the writer style tabstops relative to the old
1041 : : paragraph indent to be relative to the new paragraph indent
1042 : : */
1043 : : using namespace sw::util;
1044 [ + - ]: 1758 : SwPaM aRegion(rTmpPos);
1045 [ + - ][ + + ]: 1758 : if (rEntry.MakeRegion(pDoc, aRegion, false))
1046 : : {
1047 [ + - ]: 1305 : SvxLRSpaceItem aNewLR( *(SvxLRSpaceItem*)rEntry.pAttr );
1048 [ + - ]: 1305 : sal_uLong nStart = aRegion.Start()->nNode.GetIndex();
1049 [ + - ]: 1305 : sal_uLong nEnd = aRegion.End()->nNode.GetIndex();
1050 [ + + ]: 2610 : for(; nStart <= nEnd; ++nStart)
1051 : : {
1052 [ + - ][ + - ]: 1305 : SwNode* pNode = pDoc->GetNodes()[ nStart ];
1053 [ + - ][ - + ]: 1305 : if (!pNode || !pNode->IsTxtNode())
[ - + ]
1054 : 0 : continue;
1055 : :
1056 [ + - ]: 1305 : SwCntntNode* pNd = (SwCntntNode*)pNode;
1057 : : SvxLRSpaceItem aOldLR = (const SvxLRSpaceItem&)
1058 [ + - ][ + - ]: 1305 : pNd->GetAttr(RES_LR_SPACE);
1059 : :
1060 [ + - ]: 1305 : SwTxtNode *pTxtNode = (SwTxtNode*)pNode;
1061 : :
1062 : 1305 : const SwNumFmt *pNum = 0;
1063 : 1305 : pNum = GetNumFmtFromStack(*aRegion.GetPoint(),
1064 [ + - ]: 1305 : *pTxtNode);
1065 [ + - ]: 1305 : if (!pNum)
1066 : : {
1067 [ + - ]: 1305 : pNum = GetNumFmtFromTxtNode(*pTxtNode);
1068 : : }
1069 : :
1070 [ + + ]: 1305 : if ( pNum )
1071 : : {
1072 : : // #i103711#
1073 : : const bool bFirstLineIndentSet =
1074 : 153 : ( rReader.maTxtNodesHavingFirstLineOfstSet.end() !=
1075 [ + - ][ + - ]: 153 : rReader.maTxtNodesHavingFirstLineOfstSet.find( pNode ) );
1076 : : // #i105414#
1077 : : const bool bLeftIndentSet =
1078 : 153 : ( rReader.maTxtNodesHavingLeftIndentSet.end() !=
1079 [ + - ][ + - ]: 153 : rReader.maTxtNodesHavingLeftIndentSet.find( pNode ) );
1080 : : SyncIndentWithList( aNewLR, *pNum,
1081 : : bFirstLineIndentSet,
1082 [ + - ]: 153 : bLeftIndentSet );
1083 : : }
1084 : :
1085 [ + - ][ + + ]: 1305 : if (aNewLR == aOldLR)
1086 : 108 : continue;
1087 : :
1088 [ + - ][ + + ]: 2502 : pNd->SetAttr(aNewLR);
1089 : :
1090 [ + - ][ + - ]: 2610 : }
1091 [ + - ]: 1758 : }
1092 : : }
1093 : 1758 : break;
1094 : : case RES_TXTATR_FIELD:
1095 : : OSL_ENSURE(!this, "What is a field doing in the control stack,"
1096 : : "probably should have been in the endstack");
1097 : 0 : break;
1098 : : case RES_TXTATR_INETFMT:
1099 : : {
1100 [ + - ]: 9 : SwPaM aRegion(rTmpPos);
1101 [ + - ][ + - ]: 9 : if (rEntry.MakeRegion(pDoc, aRegion, false))
1102 : : {
1103 : : SwFrmFmt *pFrm;
1104 : : //If we have just one single inline graphic then
1105 : : //don't insert a field for the single frame, set
1106 : : //the frames hyperlink field attribute directly.
1107 [ + - ][ - + ]: 9 : if (0 != (pFrm = rReader.ContainsSingleInlineGraphic(aRegion)))
1108 : : {
1109 : : const SwFmtINetFmt *pAttr = (const SwFmtINetFmt *)
1110 : 0 : rEntry.pAttr;
1111 [ # # ]: 0 : SwFmtURL aURL;
1112 [ # # ]: 0 : aURL.SetURL(pAttr->GetValue(), false);
1113 [ # # ]: 0 : aURL.SetTargetFrameName(pAttr->GetTargetFrame());
1114 [ # # ][ # # ]: 0 : pFrm->SetFmtAttr(aURL);
1115 : : }
1116 : : else
1117 : : {
1118 [ + - ]: 9 : pDoc->InsertPoolItem(aRegion, *rEntry.pAttr, 0);
1119 : : }
1120 [ + - ]: 9 : }
1121 : : }
1122 : 9 : break;
1123 : : default:
1124 : 7065 : SwFltControlStack::SetAttrInDoc(rTmpPos, rEntry);
1125 : 7065 : break;
1126 : : }
1127 : 8832 : }
1128 : :
1129 : 17133 : const SfxPoolItem* SwWW8FltControlStack::GetFmtAttr(const SwPosition& rPos,
1130 : : sal_uInt16 nWhich)
1131 : : {
1132 : 17133 : const SfxPoolItem *pItem = GetStackAttr(rPos, nWhich);
1133 [ + + ]: 17133 : if (!pItem)
1134 : : {
1135 : 16587 : SwCntntNode const*const pNd = rPos.nNode.GetNode().GetCntntNode();
1136 [ - + ]: 16587 : if (!pNd)
1137 : 0 : pItem = &pDoc->GetAttrPool().GetDefaultItem(nWhich);
1138 : : else
1139 : : {
1140 : : /*
1141 : : If we're hunting for the indent on a paragraph and need to use the
1142 : : parent style indent, then return the indent in msword format, and
1143 : : not writer format, because that's the style that the filter works
1144 : : in (naturally)
1145 : : */
1146 [ + + ]: 16587 : if (nWhich == RES_LR_SPACE)
1147 : : {
1148 : 1128 : SfxItemState eState = SFX_ITEM_DEFAULT;
1149 [ + + ]: 1128 : if (const SfxItemSet *pSet = pNd->GetpSwAttrSet())
1150 : 687 : eState = pSet->GetItemState(RES_LR_SPACE, false);
1151 [ + - ][ + - ]: 1128 : if (eState != SFX_ITEM_SET && rReader.nAktColl < rReader.vColl.size())
[ + - ]
1152 : 1128 : pItem = &(rReader.vColl[rReader.nAktColl].maWordLR);
1153 : : }
1154 : :
1155 : : /*
1156 : : If we're hunting for a character property, try and exact position
1157 : : within the text node for lookup
1158 : : */
1159 [ + - ]: 16587 : if (pNd->IsTxtNode())
1160 : : {
1161 : 16587 : xub_StrLen nPos = rPos.nContent.GetIndex();
1162 [ + - ]: 16587 : SfxItemSet aSet(pDoc->GetAttrPool(), nWhich, nWhich);
1163 [ + - ][ + + ]: 16587 : if (static_cast<const SwTxtNode*>(pNd)->GetAttr(aSet, nPos, nPos))
1164 [ + - ][ + - ]: 16587 : pItem = aSet.GetItem(nWhich);
1165 : : }
1166 : :
1167 [ + + ]: 16587 : if (!pItem)
1168 : 6372 : pItem = &pNd->GetAttr(nWhich);
1169 : : }
1170 : : }
1171 : 17133 : return pItem;
1172 : : }
1173 : :
1174 : 18615 : const SfxPoolItem* SwWW8FltControlStack::GetStackAttr(const SwPosition& rPos,
1175 : : sal_uInt16 nWhich)
1176 : : {
1177 [ + - ]: 18615 : SwFltPosition aFltPos(rPos);
1178 : :
1179 [ + - ]: 18615 : size_t nSize = size();
1180 [ + + ]: 115128 : while (nSize)
1181 : : {
1182 [ + - ]: 97059 : const SwFltStackEntry& rEntry = (*this)[ --nSize ];
1183 [ + + ]: 97059 : if (rEntry.pAttr->Which() == nWhich)
1184 : : {
1185 [ + + + - : 4776 : if ( (rEntry.bOpen) ||
- + ][ # # ]
[ # # ][ + + ]
1186 : : (
1187 : 1410 : (rEntry.m_aMkPos.m_nNode <= aFltPos.m_nNode) &&
1188 : 1410 : (rEntry.m_aPtPos.m_nNode >= aFltPos.m_nNode) &&
1189 : : (rEntry.m_aMkPos.m_nCntnt <= aFltPos.m_nCntnt) &&
1190 : : (rEntry.m_aPtPos.m_nCntnt > aFltPos.m_nCntnt)
1191 : : )
1192 : : )
1193 : : /*
1194 : : * e.g. half-open range [0-3) so asking for properties at 3
1195 : : * means props that end at 3 are not included
1196 : : */
1197 : : {
1198 : 546 : return rEntry.pAttr;
1199 : : }
1200 : : }
1201 : : }
1202 [ + - ]: 18615 : return 0;
1203 : : }
1204 : :
1205 : 0 : bool SwWW8FltRefStack::IsFtnEdnBkmField(const SwFmtFld& rFmtFld, sal_uInt16& rBkmNo)
1206 : : {
1207 : 0 : const SwField* pFld = rFmtFld.GetFld();
1208 : : sal_uInt16 nSubType;
1209 [ # # ][ # # ]: 0 : if(pFld && (RES_GETREFFLD == pFld->Which())
[ # # # # ]
[ # # ][ # # ]
1210 : 0 : && ((REF_FOOTNOTE == (nSubType = pFld->GetSubType())) || (REF_ENDNOTE == nSubType))
1211 : 0 : && !((SwGetRefField*)pFld)->GetSetRefName().isEmpty())
1212 : : {
1213 [ # # ]: 0 : const IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
1214 : : IDocumentMarkAccess::const_iterator_t ppBkmk = pMarkAccess->findMark(
1215 [ # # ]: 0 : ((SwGetRefField*)pFld)->GetSetRefName());
1216 [ # # ][ # # ]: 0 : if(ppBkmk != pMarkAccess->getMarksEnd())
[ # # ]
1217 : : {
1218 : : // find Sequence No of corresponding Foot-/Endnote
1219 [ # # ][ # # ]: 0 : rBkmNo = ppBkmk - pMarkAccess->getMarksBegin();
1220 : 0 : return true;
1221 : : }
1222 : : }
1223 : 0 : return false;
1224 : : }
1225 : :
1226 : 0 : void SwWW8FltRefStack::SetAttrInDoc(const SwPosition& rTmpPos,
1227 : : SwFltStackEntry& rEntry)
1228 : : {
1229 [ # # # ]: 0 : switch (rEntry.pAttr->Which())
1230 : : {
1231 : : /*
1232 : : Look up these in our lists of bookmarks that were changed to
1233 : : variables, and replace the ref field with a var field, otherwise
1234 : : do normal (?) strange stuff
1235 : : */
1236 : : case RES_TXTATR_FIELD:
1237 : : {
1238 [ # # ]: 0 : SwNodeIndex aIdx(rEntry.m_aMkPos.m_nNode, 1);
1239 [ # # ]: 0 : SwPaM aPaM(aIdx, rEntry.m_aMkPos.m_nCntnt);
1240 : :
1241 : 0 : SwFmtFld& rFmtFld = *(SwFmtFld*)rEntry.pAttr;
1242 : 0 : SwField* pFld = rFmtFld.GetFld();
1243 : :
1244 : : // <NOT> got lost from revision 1.128 to 1.129
1245 [ # # ][ # # ]: 0 : if (!RefToVar(pFld, rEntry))
1246 : : {
1247 : : sal_uInt16 nBkmNo;
1248 [ # # ][ # # ]: 0 : if( IsFtnEdnBkmField(rFmtFld, nBkmNo) )
1249 : : {
1250 [ # # ][ # # ]: 0 : ::sw::mark::IMark const * const pMark = (pDoc->getIDocumentMarkAccess()->getMarksBegin() + nBkmNo)->get();
[ # # ]
1251 : :
1252 [ # # ]: 0 : const SwPosition& rBkMrkPos = pMark->GetMarkPos();
1253 : :
1254 : 0 : SwTxtNode* pTxt = rBkMrkPos.nNode.GetNode().GetTxtNode();
1255 [ # # ][ # # ]: 0 : if( pTxt && rBkMrkPos.nContent.GetIndex() )
[ # # ]
1256 : : {
1257 : : SwTxtAttr* const pFtn = pTxt->GetTxtAttrForCharAt(
1258 [ # # ]: 0 : rBkMrkPos.nContent.GetIndex()-1, RES_TXTATR_FTN );
1259 [ # # ]: 0 : if( pFtn )
1260 : : {
1261 : 0 : sal_uInt16 nRefNo = ((SwTxtFtn*)pFtn)->GetSeqRefNo();
1262 : :
1263 : 0 : ((SwGetRefField*)pFld)->SetSeqNo( nRefNo );
1264 : :
1265 [ # # ]: 0 : if( pFtn->GetFtn().IsEndNote() )
1266 [ # # ]: 0 : ((SwGetRefField*)pFld)->SetSubType(REF_ENDNOTE);
1267 : : }
1268 : : }
1269 : : }
1270 : : }
1271 : :
1272 [ # # ]: 0 : pDoc->InsertPoolItem(aPaM, *rEntry.pAttr, 0);
1273 [ # # ][ # # ]: 0 : MoveAttrs(*aPaM.GetPoint());
[ # # ]
1274 : : }
1275 : 0 : break;
1276 : : case RES_FLTR_TOX:
1277 : 0 : SwFltEndStack::SetAttrInDoc(rTmpPos, rEntry);
1278 : 0 : break;
1279 : : default:
1280 : : case RES_FLTR_BOOKMARK:
1281 : : OSL_ENSURE(!this, "EndStck used with non field, not what we want");
1282 : 0 : SwFltEndStack::SetAttrInDoc(rTmpPos, rEntry);
1283 : 0 : break;
1284 : : }
1285 : 0 : }
1286 : :
1287 : : /*
1288 : : For styles we will do our tabstop arithmetic in word style and adjust them to
1289 : : writer style after all the styles have been finished and the dust settles as
1290 : : to what affects what.
1291 : :
1292 : : For explicit attributes we turn the adjusted writer tabstops back into 0 based
1293 : : word indexes and we'll turn them back into writer indexes when setting them
1294 : : into the document. If explicit left indent exist which affects them, then this
1295 : : is handled when the explict left indent is set into the document
1296 : : */
1297 : 432 : void SwWW8ImplReader::Read_Tab(sal_uInt16 , const sal_uInt8* pData, short nLen)
1298 : : {
1299 [ + + ]: 432 : if (nLen < 0)
1300 : : {
1301 [ + - ]: 171 : pCtrlStck->SetAttr(*pPaM->GetPoint(), RES_PARATR_TABSTOP);
1302 : 432 : return;
1303 : : }
1304 : :
1305 [ + - ]: 261 : sal_uInt8 nDel = (nLen > 0) ? pData[0] : 0;
1306 : 261 : const sal_uInt8* pDel = pData + 1; // Del - Array
1307 : :
1308 [ + - ]: 261 : sal_uInt8 nIns = (nLen > nDel*2+1) ? pData[nDel*2+1] : 0;
1309 : 261 : const sal_uInt8* pIns = pData + 2*nDel + 2; // Ins - Array
1310 : :
1311 : 261 : short nRequiredLength = 2 + 2*nDel + 2*nIns + 1*nIns;
1312 [ - + ]: 261 : if (nRequiredLength > nLen)
1313 : : {
1314 : : //would require more data than available to describe!, discard invalid
1315 : : //record
1316 : 0 : nIns = 0;
1317 : 0 : nDel = 0;
1318 : : }
1319 : :
1320 : 261 : WW8_TBD* pTyp = (WW8_TBD*)(pData + 2*nDel + 2*nIns + 2);// Typ - Array
1321 : :
1322 [ + - ]: 261 : SvxTabStopItem aAttr(0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP);
1323 : :
1324 : 261 : const SwTxtFmtColl* pSty = 0;
1325 : : sal_uInt16 nTabBase;
1326 [ + + ][ + - ]: 261 : if (pAktColl && nAktColl < vColl.size()) // StyleDef
[ + + ]
1327 : : {
1328 : 90 : nTabBase = vColl[nAktColl].nBase;
1329 [ + + ]: 90 : if (nTabBase < vColl.size()) // Based On
1330 : 84 : pSty = (const SwTxtFmtColl*)vColl[nTabBase].pFmt;
1331 : : }
1332 : : else
1333 : : { // Text
1334 : 171 : nTabBase = nAktColl;
1335 [ + - ]: 171 : if (nAktColl < vColl.size())
1336 : 171 : pSty = (const SwTxtFmtColl*)vColl[nAktColl].pFmt;
1337 : : //TODO figure else here
1338 : : }
1339 : :
1340 : 261 : bool bFound = false;
1341 [ + - ]: 261 : ::boost::unordered_set<size_t> aLoopWatch;
1342 [ + + ][ + + ]: 546 : while (pSty && !bFound)
[ + + ]
1343 : : {
1344 : : const SfxPoolItem* pTabs;
1345 : 285 : bFound = pSty->GetAttrSet().GetItemState(RES_PARATR_TABSTOP, false,
1346 [ + - ]: 285 : &pTabs) == SFX_ITEM_SET;
1347 [ + + ]: 285 : if( bFound )
1348 [ + - ]: 21 : aAttr = *((const SvxTabStopItem*)pTabs);
1349 : : else
1350 : : {
1351 : 264 : sal_uInt16 nOldTabBase = nTabBase;
1352 : : // If based on another
1353 [ + - ]: 264 : if (nTabBase < vColl.size())
1354 : 264 : nTabBase = vColl[nTabBase].nBase;
1355 : :
1356 [ + - ][ + - ]: 264 : if (
[ + + ][ + + ]
1357 : 264 : nTabBase < vColl.size() &&
1358 : : nOldTabBase != nTabBase &&
1359 : : nTabBase != ww::stiNil
1360 : : )
1361 : : {
1362 : : // #i61789: Stop searching when next style is the same as the
1363 : : // current one (prevent loop)
1364 [ + - ]: 30 : aLoopWatch.insert(reinterpret_cast<size_t>(pSty));
1365 [ + - ]: 30 : if (nTabBase < vColl.size())
1366 : 30 : pSty = (const SwTxtFmtColl*)vColl[nTabBase].pFmt;
1367 : : //TODO figure out the else branch
1368 : :
1369 [ - + ]: 30 : if (aLoopWatch.find(reinterpret_cast<size_t>(pSty)) !=
1370 [ + - ][ + - ]: 30 : aLoopWatch.end())
1371 : 0 : pSty = 0;
1372 : : }
1373 : : else
1374 : 285 : pSty = 0; // gib die Suche auf
1375 : : }
1376 : : }
1377 : :
1378 [ + - ]: 261 : SvxTabStop aTabStop;
1379 [ + + ]: 450 : for (short i=0; i < nDel; ++i)
1380 : : {
1381 [ + - ]: 189 : sal_uInt16 nPos = aAttr.GetPos(SVBT16ToShort(pDel + i*2));
1382 [ + + ]: 189 : if( nPos != SVX_TAB_NOTFOUND )
1383 [ + - ]: 33 : aAttr.Remove( nPos, 1 );
1384 : : }
1385 : :
1386 [ + + ]: 573 : for (short i=0; i < nIns; ++i)
1387 : : {
1388 : 312 : short nPos = SVBT16ToShort(pIns + i*2);
1389 : 312 : aTabStop.GetTabPos() = nPos;
1390 [ + + + - : 312 : switch( SVBT8ToByte( pTyp[i].aBits1 ) & 0x7 ) // pTyp[i].jc
- + ]
1391 : : {
1392 : : case 0:
1393 : 9 : aTabStop.GetAdjustment() = SVX_TAB_ADJUST_LEFT;
1394 : 9 : break;
1395 : : case 1:
1396 : 66 : aTabStop.GetAdjustment() = SVX_TAB_ADJUST_CENTER;
1397 : 66 : break;
1398 : : case 2:
1399 : 81 : aTabStop.GetAdjustment() = SVX_TAB_ADJUST_RIGHT;
1400 : 81 : break;
1401 : : case 3:
1402 : 0 : aTabStop.GetAdjustment() = SVX_TAB_ADJUST_DECIMAL;
1403 : 0 : break;
1404 : : case 4:
1405 : 0 : continue; // ignoriere Bar
1406 : : }
1407 : :
1408 [ + + - - : 312 : switch( SVBT8ToByte( pTyp[i].aBits1 ) >> 3 & 0x7 )
- ]
1409 : : {
1410 : : case 0:
1411 : 303 : aTabStop.GetFill() = ' ';
1412 : 303 : break;
1413 : : case 1:
1414 : 9 : aTabStop.GetFill() = '.';
1415 : 9 : break;
1416 : : case 2:
1417 : 0 : aTabStop.GetFill() = '-';
1418 : 0 : break;
1419 : : case 3:
1420 : : case 4:
1421 : 0 : aTabStop.GetFill() = '_';
1422 : 0 : break;
1423 : : }
1424 : :
1425 [ + - ]: 312 : sal_uInt16 nPos2 = aAttr.GetPos( nPos );
1426 [ - + ]: 312 : if (nPos2 != SVX_TAB_NOTFOUND)
1427 [ # # ]: 0 : aAttr.Remove(nPos2, 1); // sonst weigert sich das Insert()
1428 [ + - ]: 312 : aAttr.Insert(aTabStop);
1429 : : }
1430 : :
1431 [ + + ][ + - ]: 261 : if (nIns || nDel)
1432 [ + - ]: 261 : NewAttr(aAttr);
1433 : : else
1434 : : {
1435 : : //Here we have a tab definition which inserts no extra tabs, or deletes
1436 : : //no existing tabs. An older version of writer is probably the creater
1437 : : //of the document :-( . So if we are importing a style we can just
1438 : : //ignore it. But if we are importing into text we cannot as during
1439 : : //text SwWW8ImplReader::Read_Tab is called at the begin and end of
1440 : : //the range the attrib affects, and ignoring it would upset the
1441 : : //balance
1442 [ # # ]: 0 : if (!pAktColl) //not importing into a style
1443 : : {
1444 : : using namespace sw::util;
1445 : : SvxTabStopItem aOrig = pSty ?
1446 : 0 : ItemGet<SvxTabStopItem>(*pSty, RES_PARATR_TABSTOP) :
1447 [ # # ][ # # ]: 0 : DefaultItemGet<SvxTabStopItem>(rDoc, RES_PARATR_TABSTOP);
[ # # ][ # # ]
1448 [ # # ][ # # ]: 0 : NewAttr(aOrig);
1449 : : }
1450 [ + - ][ + - ]: 432 : }
1451 : : }
1452 : :
1453 : : //-----------------------------------------
1454 : : // DOP
1455 : : //-----------------------------------------
1456 : :
1457 : 102 : void SwWW8ImplReader::ImportDop()
1458 : : {
1459 : : // correct the LastPrinted date in DocumentInfo
1460 : : uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
1461 [ + - ][ + - ]: 102 : mpDocShell->GetModel(), uno::UNO_QUERY_THROW);
1462 : : uno::Reference<document::XDocumentProperties> xDocuProps(
1463 [ + - ][ + - ]: 102 : xDPS->getDocumentProperties());
1464 : : OSL_ENSURE(xDocuProps.is(), "DocumentProperties is null");
1465 [ + - ]: 102 : if (xDocuProps.is())
1466 : : {
1467 : : DateTime aLastPrinted(
1468 [ + - ]: 102 : msfilter::util::DTTM2DateTime(pWDop->dttmLastPrint));
1469 : 102 : ::util::DateTime uDT(aLastPrinted.Get100Sec(),
1470 : 102 : aLastPrinted.GetSec(), aLastPrinted.GetMin(),
1471 : 102 : aLastPrinted.GetHour(), aLastPrinted.GetDay(),
1472 : 204 : aLastPrinted.GetMonth(), aLastPrinted.GetYear());
1473 [ + - ][ + - ]: 102 : xDocuProps->setPrintDate(uDT);
1474 : : }
1475 : :
1476 : : //
1477 : : // COMPATIBILITY FLAGS START
1478 : : //
1479 : :
1480 : : // i#78951, remember the unknown compatability options
1481 : : // so as to export them out
1482 [ + - ]: 102 : rDoc.Setn32DummyCompatabilityOptions1( pWDop->GetCompatabilityOptions());
1483 [ + - ]: 102 : rDoc.Setn32DummyCompatabilityOptions2( pWDop->GetCompatabilityOptions2());
1484 : :
1485 : : // Abstand zwischen zwei Absaetzen ist die SUMME von unterem
1486 : : // Abst. des ersten und oberem Abst. des zweiten
1487 [ + - ]: 102 : rDoc.set(IDocumentSettingAccess::PARA_SPACE_MAX, pWDop->fDontUseHTMLAutoSpacing);
1488 [ + - ]: 102 : rDoc.set(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES, true );
1489 : : // move tabs on alignment
1490 [ + - ]: 102 : rDoc.set(IDocumentSettingAccess::TAB_COMPAT, true);
1491 : : // #i24363# tab stops relative to indent
1492 [ + - ]: 102 : rDoc.set(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT, false);
1493 : : // #i18732# - adjust default of option 'FollowTextFlow'
1494 [ + - ][ + - ]: 102 : rDoc.SetDefault( SwFmtFollowTextFlow( sal_False ) );
[ + - ]
1495 : :
1496 : : // Import Default-Tabs
1497 : 102 : long nDefTabSiz = pWDop->dxaTab;
1498 [ + + ]: 102 : if( nDefTabSiz < 56 )
1499 : 3 : nDefTabSiz = 709;
1500 : :
1501 : : // wir wollen genau einen DefaultTab
1502 [ + - ]: 102 : SvxTabStopItem aNewTab( 1, sal_uInt16(nDefTabSiz), SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP );
1503 [ + - ]: 102 : ((SvxTabStop&)aNewTab[0]).GetAdjustment() = SVX_TAB_ADJUST_DEFAULT;
1504 : :
1505 [ + - ]: 102 : rDoc.GetAttrPool().SetPoolDefaultItem( aNewTab );
1506 : :
1507 [ + - ]: 102 : rDoc.set(IDocumentSettingAccess::USE_VIRTUAL_DEVICE, !pWDop->fUsePrinterMetrics);
1508 [ + - ]: 102 : rDoc.set(IDocumentSettingAccess::USE_HIRES_VIRTUAL_DEVICE, true);
1509 [ + - ]: 102 : rDoc.set(IDocumentSettingAccess::ADD_FLY_OFFSETS, true );
1510 [ + - ]: 102 : rDoc.set(IDocumentSettingAccess::ADD_EXT_LEADING, !pWDop->fNoLeading);
1511 [ + - ]: 102 : rDoc.set(IDocumentSettingAccess::OLD_NUMBERING, false);
1512 [ + - ]: 102 : rDoc.set(IDocumentSettingAccess::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING, false); // #i47448#
1513 [ + - ]: 102 : rDoc.set(IDocumentSettingAccess::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK, !pWDop->fExpShRtn); // #i49277#, #i56856#
1514 [ + - ]: 102 : rDoc.set(IDocumentSettingAccess::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT, false); // #i53199#
1515 [ + - ]: 102 : rDoc.set(IDocumentSettingAccess::OLD_LINE_SPACING, false);
1516 : :
1517 : : // #i25901# - set new compatibility option
1518 : : // 'Add paragraph and table spacing at bottom of table cells'
1519 [ + - ]: 102 : rDoc.set(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS, true);
1520 : :
1521 : : // #i11860# - set new compatibility option
1522 : : // 'Use former object positioning' to <sal_False>
1523 [ + - ]: 102 : rDoc.set(IDocumentSettingAccess::USE_FORMER_OBJECT_POS, false);
1524 : :
1525 : : // #i27767# - set new compatibility option
1526 : : // 'Conder Wrapping mode when positioning object' to <sal_True>
1527 [ + - ]: 102 : rDoc.set(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION, true);
1528 : :
1529 [ + - ]: 102 : rDoc.set(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING, false); // #i13832#, #i24135#
1530 : :
1531 [ + - ]: 102 : rDoc.set(IDocumentSettingAccess::TABLE_ROW_KEEP, true); //SetTableRowKeep( true );
1532 : :
1533 [ + - ]: 102 : rDoc.set(IDocumentSettingAccess::IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION, true); // #i3952#
1534 : :
1535 [ + - ]: 102 : rDoc.set(IDocumentSettingAccess::INVERT_BORDER_SPACING, true);
1536 [ + - ]: 102 : rDoc.set(IDocumentSettingAccess::COLLAPSE_EMPTY_CELL_PARA, true);
1537 [ + - ]: 102 : rDoc.set(IDocumentSettingAccess::TAB_OVERFLOW, true);
1538 [ + - ]: 102 : rDoc.set(IDocumentSettingAccess::UNBREAKABLE_NUMBERINGS, true);
1539 : :
1540 : : //
1541 : : // COMPATIBILITY FLAGS END
1542 : : //
1543 : :
1544 : : //import magic doptypography information, if its there
1545 [ + - ]: 102 : if (pWwFib->nFib > 105)
1546 [ + - ]: 102 : ImportDopTypography(pWDop->doptypography);
1547 : :
1548 : : // disable form design mode to be able to use imported controls directly
1549 : : // #i31239# always disable form design mode, not only in protected docs
1550 : : {
1551 : : using namespace com::sun::star;
1552 : :
1553 : : uno::Reference<lang::XComponent> xModelComp(mpDocShell->GetModel(),
1554 [ + - ][ + - ]: 102 : uno::UNO_QUERY);
1555 : : uno::Reference<beans::XPropertySet> xDocProps(xModelComp,
1556 [ + - ]: 102 : uno::UNO_QUERY);
1557 [ + - ]: 102 : if (xDocProps.is())
1558 : : {
1559 : : uno::Reference<beans::XPropertySetInfo> xInfo =
1560 [ + - ][ + - ]: 102 : xDocProps->getPropertySetInfo();
1561 : 102 : sal_Bool bValue = false;
1562 [ + - ]: 102 : if (xInfo.is())
1563 : : {
1564 [ + - ][ + - ]: 102 : if (xInfo->hasPropertyByName("ApplyFormDesignMode"))
[ + - ]
1565 : : {
1566 [ + - ][ + - ]: 102 : xDocProps->setPropertyValue("ApplyFormDesignMode", cppu::bool2any(bValue));
[ + - ]
1567 : : }
1568 : 102 : }
1569 : 102 : }
1570 : : }
1571 : :
1572 [ + - ]: 102 : mpDocShell->SetModifyPasswordHash(pWDop->lKeyProtDoc);
1573 : :
1574 [ + - ]: 102 : const SvtFilterOptions& rOpt = SvtFilterOptions::Get();
1575 [ + - ][ + - ]: 102 : if (rOpt.IsUseEnhancedFields())
1576 [ + - ][ + - ]: 102 : rDoc.set(IDocumentSettingAccess::PROTECT_FORM, pWDop->fProtEnabled );
1577 : 102 : }
1578 : :
1579 : 102 : void SwWW8ImplReader::ImportDopTypography(const WW8DopTypography &rTypo)
1580 : : {
1581 : : using namespace com::sun::star;
1582 [ - + ]: 102 : switch (rTypo.iLevelOfKinsoku)
1583 : : {
1584 : : case 2: //custom
1585 : : {
1586 : : i18n::ForbiddenCharacters aForbidden(rTypo.rgxchFPunct,
1587 : 0 : rTypo.rgxchLPunct);
1588 [ # # ]: 0 : rDoc.setForbiddenCharacters(rTypo.GetConvertedLang(),
1589 [ # # ]: 0 : aForbidden);
1590 : : //Obviously cannot set the standard level 1 for japanese, so
1591 : : //bail out now while we can.
1592 [ # # ][ # # ]: 0 : if (rTypo.GetConvertedLang() == LANGUAGE_JAPANESE)
1593 [ # # ]: 102 : return;
1594 : : }
1595 : 0 : break;
1596 : : default:
1597 : 102 : break;
1598 : : }
1599 : :
1600 : : /*
1601 : : This MS hack means that level 2 of japanese is not in operation, so we put
1602 : : in what we know are the MS defaults, there is a complementary reverse
1603 : : hack in the writer. Its our default as well, but we can set it anyway
1604 : : as a flag for later.
1605 : : */
1606 [ + + ]: 102 : if (!rTypo.reserved2)
1607 : : {
1608 : : i18n::ForbiddenCharacters aForbidden(rTypo.GetJapanNotBeginLevel1(),
1609 [ + - ][ + - ]: 87 : rTypo.GetJapanNotEndLevel1());
1610 [ + - ]: 87 : rDoc.setForbiddenCharacters(LANGUAGE_JAPANESE,aForbidden);
1611 : : }
1612 : :
1613 : 102 : rDoc.set(IDocumentSettingAccess::KERN_ASIAN_PUNCTUATION, rTypo.fKerningPunct);
1614 : 102 : rDoc.setCharacterCompressionType(static_cast<SwCharCompressType>(rTypo.iJustification));
1615 : : }
1616 : :
1617 : : //-----------------------------------------
1618 : : // Fuss- und Endnoten
1619 : :
1620 : : //-----------------------------------------
1621 : :
1622 : 186 : WW8ReaderSave::WW8ReaderSave(SwWW8ImplReader* pRdr ,WW8_CP nStartCp) :
1623 : 186 : maTmpPos(*pRdr->pPaM->GetPoint()),
1624 : : mpOldStck(pRdr->pCtrlStck),
1625 : : mpOldAnchorStck(pRdr->pAnchorStck),
1626 : : mpOldRedlines(pRdr->mpRedlineStack),
1627 : : mpOldPlcxMan(pRdr->pPlcxMan),
1628 : : mpWFlyPara(pRdr->pWFlyPara),
1629 : : mpSFlyPara(pRdr->pSFlyPara),
1630 : : mpPreviousNumPaM(pRdr->pPreviousNumPaM),
1631 : : mpPrevNumRule(pRdr->pPrevNumRule),
1632 : : mpTableDesc(pRdr->pTableDesc),
1633 : : mnInTable(pRdr->nInTable),
1634 : : mnAktColl(pRdr->nAktColl),
1635 : : mcSymbol(pRdr->cSymbol),
1636 : : mbIgnoreText(pRdr->bIgnoreText),
1637 : : mbSymbol(pRdr->bSymbol),
1638 : : mbHdFtFtnEdn(pRdr->bHdFtFtnEdn),
1639 : : mbTxbxFlySection(pRdr->bTxbxFlySection),
1640 : : mbAnl(pRdr->bAnl),
1641 : : mbInHyperlink(pRdr->bInHyperlink),
1642 : : mbPgSecBreak(pRdr->bPgSecBreak),
1643 : : mbWasParaEnd(pRdr->bWasParaEnd),
1644 : : mbHasBorder(pRdr->bHasBorder),
1645 [ + - ][ + - ]: 186 : mbFirstPara(pRdr->bFirstPara)
1646 : : {
1647 : 186 : pRdr->bSymbol = false;
1648 : 186 : pRdr->bHdFtFtnEdn = true;
1649 : : pRdr->bTxbxFlySection = pRdr->bAnl = pRdr->bPgSecBreak = pRdr->bWasParaEnd
1650 : 186 : = pRdr->bHasBorder = false;
1651 : 186 : pRdr->bFirstPara = true;
1652 : 186 : pRdr->nInTable = 0;
1653 : 186 : pRdr->pWFlyPara = 0;
1654 : 186 : pRdr->pSFlyPara = 0;
1655 : 186 : pRdr->pPreviousNumPaM = 0;
1656 : 186 : pRdr->pPrevNumRule = 0;
1657 : 186 : pRdr->pTableDesc = 0;
1658 : 186 : pRdr->nAktColl = 0;
1659 : :
1660 : :
1661 : : pRdr->pCtrlStck = new SwWW8FltControlStack(&pRdr->rDoc, pRdr->nFieldFlags,
1662 [ + - ][ + - ]: 186 : *pRdr);
1663 : :
1664 [ + - ][ + - ]: 186 : pRdr->mpRedlineStack = new sw::util::RedlineStack(pRdr->rDoc);
1665 : :
1666 [ + - ][ + - ]: 186 : pRdr->pAnchorStck = new SwWW8FltAnchorStack(&pRdr->rDoc, pRdr->nFieldFlags);
1667 : :
1668 : : // rette die Attributverwaltung: dies ist noetig, da der neu anzulegende
1669 : : // PLCFx Manager natuerlich auf die gleichen FKPs zugreift, wie der alte
1670 : : // und deren Start-End-Positionen veraendert...
1671 [ + + ]: 186 : if (pRdr->pPlcxMan)
1672 [ + - ]: 150 : pRdr->pPlcxMan->SaveAllPLCFx(maPLCFxSave);
1673 : :
1674 [ - + ]: 186 : if (nStartCp != -1)
1675 : : {
1676 : : pRdr->pPlcxMan = new WW8PLCFMan(pRdr->pSBase,
1677 [ # # ][ # # ]: 0 : mpOldPlcxMan->GetManType(), nStartCp);
1678 : : }
1679 : :
1680 [ + - ]: 186 : maOldApos.push_back(false);
1681 [ + - ]: 186 : maOldApos.swap(pRdr->maApos);
1682 [ + - ]: 186 : maOldFieldStack.swap(pRdr->maFieldStack);
1683 : 186 : }
1684 : :
1685 : 186 : void WW8ReaderSave::Restore( SwWW8ImplReader* pRdr )
1686 : : {
1687 : 186 : pRdr->pWFlyPara = mpWFlyPara;
1688 : 186 : pRdr->pSFlyPara = mpSFlyPara;
1689 : 186 : pRdr->pPreviousNumPaM = mpPreviousNumPaM;
1690 : 186 : pRdr->pPrevNumRule = mpPrevNumRule;
1691 : 186 : pRdr->pTableDesc = mpTableDesc;
1692 : 186 : pRdr->cSymbol = mcSymbol;
1693 : 186 : pRdr->bSymbol = mbSymbol;
1694 : 186 : pRdr->bIgnoreText = mbIgnoreText;
1695 : 186 : pRdr->bHdFtFtnEdn = mbHdFtFtnEdn;
1696 : 186 : pRdr->bTxbxFlySection = mbTxbxFlySection;
1697 : 186 : pRdr->nInTable = mnInTable;
1698 : 186 : pRdr->bAnl = mbAnl;
1699 : 186 : pRdr->bInHyperlink = mbInHyperlink;
1700 : 186 : pRdr->bWasParaEnd = mbWasParaEnd;
1701 : 186 : pRdr->bPgSecBreak = mbPgSecBreak;
1702 : 186 : pRdr->nAktColl = mnAktColl;
1703 : 186 : pRdr->bHasBorder = mbHasBorder;
1704 : 186 : pRdr->bFirstPara = mbFirstPara;
1705 : :
1706 : : // schliesse alle Attribute, da sonst Attribute
1707 : : // entstehen koennen, die aus dem Fly rausragen
1708 : 186 : pRdr->DeleteCtrlStk();
1709 : 186 : pRdr->pCtrlStck = mpOldStck;
1710 : :
1711 : 186 : pRdr->mpRedlineStack->closeall(*pRdr->pPaM->GetPoint());
1712 [ + - ]: 186 : delete pRdr->mpRedlineStack;
1713 : 186 : pRdr->mpRedlineStack = mpOldRedlines;
1714 : :
1715 : 186 : pRdr->DeleteAnchorStk();
1716 : 186 : pRdr->pAnchorStck = mpOldAnchorStck;
1717 : :
1718 : 186 : *pRdr->pPaM->GetPoint() = maTmpPos;
1719 : :
1720 [ + + ]: 186 : if (mpOldPlcxMan != pRdr->pPlcxMan)
1721 : : {
1722 [ + + ]: 150 : delete pRdr->pPlcxMan;
1723 : 150 : pRdr->pPlcxMan = mpOldPlcxMan;
1724 : : }
1725 [ + + ]: 186 : if (pRdr->pPlcxMan)
1726 : 150 : pRdr->pPlcxMan->RestoreAllPLCFx(maPLCFxSave);
1727 : 186 : pRdr->maApos.swap(maOldApos);
1728 : 186 : pRdr->maFieldStack.swap(maOldFieldStack);
1729 : 186 : }
1730 : :
1731 : 39 : void SwWW8ImplReader::Read_HdFtFtnText( const SwNodeIndex* pSttIdx,
1732 : : long nStartCp, long nLen, ManTypes nType )
1733 : : {
1734 : : // rettet Flags u.ae. u. setzt sie zurueck
1735 [ + - ]: 39 : WW8ReaderSave aSave( this );
1736 : :
1737 [ + - ]: 39 : pPaM->GetPoint()->nNode = pSttIdx->GetIndex() + 1; //
1738 [ + - ][ + - ]: 39 : pPaM->GetPoint()->nContent.Assign( pPaM->GetCntntNode(), 0 );
1739 : :
1740 : : // dann Text fuer Header, Footer o. Footnote einlesen
1741 : :
1742 [ + - ]: 39 : ReadText( nStartCp, nLen, nType ); // Sepx dabei ignorieren
1743 [ + - ][ + - ]: 39 : aSave.Restore( this );
1744 : 39 : }
1745 : :
1746 : : //Use authornames, if not available fall back to initials.
1747 : 0 : long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes)
1748 : : {
1749 : 0 : WW8PLCFx_SubDoc* pSD = pPlcxMan->GetAtn();
1750 [ # # ]: 0 : if( !pSD )
1751 : 0 : return 0;
1752 : :
1753 [ # # ]: 0 : String sAuthor;
1754 [ # # ]: 0 : if( bVer67 )
1755 : : {
1756 : 0 : const WW67_ATRD* pDescri = (const WW67_ATRD*)pSD->GetData();
1757 [ # # ]: 0 : const String* pA = GetAnnotationAuthor(SVBT16ToShort(pDescri->ibst));
1758 [ # # ]: 0 : if (pA)
1759 [ # # ]: 0 : sAuthor = *pA;
1760 : : else
1761 : 0 : sAuthor = String(pDescri->xstUsrInitl + 1, pDescri->xstUsrInitl[0],
1762 [ # # ][ # # ]: 0 : RTL_TEXTENCODING_MS_1252);
[ # # ]
1763 : : }
1764 : : else
1765 : : {
1766 : 0 : const WW8_ATRD* pDescri = (const WW8_ATRD*)pSD->GetData();
1767 : :
1768 [ # # ][ # # ]: 0 : if (const String* pA = GetAnnotationAuthor(SVBT16ToShort(pDescri->ibst)))
1769 [ # # ]: 0 : sAuthor = *pA;
1770 : : else
1771 : : {
1772 : 0 : sal_uInt16 nLen = SVBT16ToShort(pDescri->xstUsrInitl[0]);
1773 [ # # ]: 0 : for(sal_uInt16 nIdx = 1; nIdx <= nLen; ++nIdx)
1774 [ # # ]: 0 : sAuthor += SVBT16ToShort(pDescri->xstUsrInitl[nIdx]);
1775 : : }
1776 : : }
1777 : :
1778 : 0 : sal_uInt32 nDateTime = 0;
1779 : :
1780 [ # # ]: 0 : if (sal_uInt8 * pExtended = pPlcxMan->GetExtendedAtrds()) // Word < 2002 has no date data for comments
1781 : : {
1782 [ # # ]: 0 : sal_uLong nIndex = pSD->GetIdx() & 0xFFFF; //Index is (stupidly) multiplexed for WW8PLCFx_SubDocs
1783 [ # # ]: 0 : if (pWwFib->lcbAtrdExtra/18 > nIndex)
1784 : 0 : nDateTime = SVBT32ToUInt32(*(SVBT32*)(pExtended+(nIndex*18)));
1785 : : }
1786 : :
1787 [ # # ]: 0 : DateTime aDate = msfilter::util::DTTM2DateTime(nDateTime);
1788 : :
1789 [ # # ]: 0 : String sTxt;
1790 : : OutlinerParaObject *pOutliner = ImportAsOutliner( sTxt, pRes->nCp2OrIdx,
1791 [ # # ]: 0 : pRes->nCp2OrIdx + pRes->nMemLen, MAN_AND );
1792 : :
1793 : 0 : this->pFmtOfJustInsertedApo = 0;
1794 : : SwPostItField aPostIt(
1795 [ # # ]: 0 : (SwPostItFieldType*)rDoc.GetSysFldType(RES_POSTITFLD), sAuthor,
1796 [ # # ]: 0 : sTxt, aEmptyStr, aEmptyStr, aDate );
1797 [ # # ]: 0 : aPostIt.SetTextObject(pOutliner);
1798 : :
1799 [ # # ][ # # ]: 0 : pCtrlStck->NewAttr(*pPaM->GetPoint(), SvxCharHiddenItem(false, RES_CHRATR_HIDDEN));
[ # # ]
1800 [ # # ][ # # ]: 0 : rDoc.InsertPoolItem(*pPaM, SwFmtFld(aPostIt), 0);
[ # # ]
1801 [ # # ]: 0 : pCtrlStck->SetAttr(*pPaM->GetPoint(), RES_CHRATR_HIDDEN);
1802 : :
1803 [ # # ][ # # ]: 0 : return 0;
[ # # ]
1804 : : }
1805 : :
1806 : 0 : void SwWW8ImplReader::Read_HdFtTextAsHackedFrame(long nStart, long nLen,
1807 : : SwFrmFmt &rHdFtFmt, sal_uInt16 nPageWidth)
1808 : : {
1809 [ # # ]: 0 : const SwNodeIndex* pSttIdx = rHdFtFmt.GetCntnt().GetCntntIdx();
1810 : : OSL_ENSURE(pSttIdx, "impossible");
1811 [ # # ]: 0 : if (!pSttIdx)
1812 : 0 : return;
1813 : :
1814 [ # # ]: 0 : SwPosition aTmpPos(*pPaM->GetPoint());
1815 : :
1816 [ # # ]: 0 : pPaM->GetPoint()->nNode = pSttIdx->GetIndex() + 1;
1817 [ # # ][ # # ]: 0 : pPaM->GetPoint()->nContent.Assign(pPaM->GetCntntNode(), 0);
1818 : :
1819 [ # # ]: 0 : SwFlyFrmFmt *pFrame = rDoc.MakeFlySection(FLY_AT_PARA, pPaM->GetPoint());
1820 : :
1821 [ # # ][ # # ]: 0 : pFrame->SetFmtAttr(SwFmtFrmSize(ATT_MIN_SIZE, nPageWidth, MINLAY));
[ # # ]
1822 [ # # ][ # # ]: 0 : pFrame->SetFmtAttr(SwFmtSurround(SURROUND_THROUGHT));
[ # # ]
1823 [ # # ][ # # ]: 0 : pFrame->SetFmtAttr(SwFmtHoriOrient(0, text::HoriOrientation::RIGHT)); //iFOO
[ # # ]
1824 : : // #i43427# - send frame for header/footer into background.
1825 [ # # ][ # # ]: 0 : pFrame->SetFmtAttr( SvxOpaqueItem( RES_OPAQUE, false ) );
[ # # ]
1826 [ # # ]: 0 : SdrObject* pFrmObj = CreateContactObject( pFrame );
1827 : : OSL_ENSURE( pFrmObj,
1828 : : "<SwWW8ImplReader::Read_HdFtTextAsHackedFrame(..)> - missing SdrObject instance" );
1829 [ # # ]: 0 : if ( pFrmObj )
1830 : : {
1831 [ # # ]: 0 : pFrmObj->SetOrdNum( 0L );
1832 : : }
1833 [ # # ]: 0 : MoveInsideFly(pFrame);
1834 : :
1835 [ # # ]: 0 : const SwNodeIndex* pHackIdx = pFrame->GetCntnt().GetCntntIdx();
1836 : :
1837 [ # # ]: 0 : Read_HdFtFtnText(pHackIdx, nStart, nLen - 1, MAN_HDFT);
1838 : :
1839 [ # # ][ # # ]: 0 : MoveOutsideFly(pFrame, aTmpPos);
1840 : : }
1841 : :
1842 : 36 : void SwWW8ImplReader::Read_HdFtText(long nStart, long nLen, SwFrmFmt* pHdFtFmt)
1843 : : {
1844 [ + - ]: 36 : const SwNodeIndex* pSttIdx = pHdFtFmt->GetCntnt().GetCntntIdx();
1845 [ + - ]: 36 : if (!pSttIdx)
1846 : 36 : return;
1847 : :
1848 [ + - ]: 36 : SwPosition aTmpPos( *pPaM->GetPoint() ); // merke alte Cursorposition
1849 : :
1850 [ + - ]: 36 : Read_HdFtFtnText(pSttIdx, nStart, nLen - 1, MAN_HDFT);
1851 : :
1852 [ + - ][ + - ]: 36 : *pPaM->GetPoint() = aTmpPos;
1853 : : }
1854 : :
1855 : :
1856 : 36 : bool SwWW8ImplReader::isValid_HdFt_CP(WW8_CP nHeaderCP) const
1857 : : {
1858 : : //each CP of Plcfhdd MUST be less than FibRgLw97.ccpHdd
1859 : 36 : return (nHeaderCP < pWwFib->ccpHdr) ? true : false;
1860 : : }
1861 : :
1862 : 0 : bool SwWW8ImplReader::HasOwnHeaderFooter(sal_uInt8 nWhichItems, sal_uInt8 grpfIhdt,
1863 : : int nSect)
1864 : : {
1865 [ # # ]: 0 : if (pHdFt)
1866 : : {
1867 : : WW8_CP start;
1868 : : long nLen;
1869 : 0 : sal_uInt8 nNumber = 5;
1870 : :
1871 [ # # ]: 0 : for( sal_uInt8 nI = 0x20; nI; nI >>= 1, nNumber-- )
1872 : : {
1873 [ # # ]: 0 : if (nI & nWhichItems)
1874 : : {
1875 : 0 : bool bOk = true;
1876 [ # # ]: 0 : if( bVer67 )
1877 [ # # ][ # # ]: 0 : bOk = ( pHdFt->GetTextPos(grpfIhdt, nI, start, nLen ) && nLen >= 2 );
[ # # ]
1878 : : else
1879 : : {
1880 [ # # ]: 0 : pHdFt->GetTextPosExact( static_cast< short >(nNumber + (nSect+1)*6), start, nLen);
1881 [ # # ][ # # ]: 0 : bOk = ( 2 <= nLen ) && isValid_HdFt_CP(start);
1882 : : }
1883 : :
1884 [ # # ]: 0 : if (bOk)
1885 : 0 : return true;
1886 : : }
1887 : : }
1888 : : }
1889 : 0 : return false;
1890 : : }
1891 : :
1892 : 36 : void SwWW8ImplReader::Read_HdFt(bool bIsTitle, int nSect,
1893 : : const SwPageDesc *pPrev, const wwSection &rSection)
1894 : : {
1895 : 36 : sal_uInt8 nWhichItems = 0;
1896 : 36 : SwPageDesc *pPD = 0;
1897 [ + + ]: 36 : if (!bIsTitle)
1898 : : {
1899 : : nWhichItems =
1900 : 18 : rSection.maSep.grpfIhdt & ~(WW8_HEADER_FIRST | WW8_FOOTER_FIRST);
1901 : 18 : pPD = rSection.mpPage;
1902 : : }
1903 : : else
1904 : : {
1905 : : // Always read title page header/footer data - it could be used by following sections
1906 : 18 : nWhichItems = ( WW8_HEADER_FIRST | WW8_FOOTER_FIRST );
1907 : :
1908 : 18 : pPD = rSection.mpTitlePage;
1909 : : }
1910 : :
1911 : 36 : sal_uInt8 grpfIhdt = rSection.maSep.grpfIhdt;
1912 : :
1913 : :
1914 [ + - ]: 36 : if( pHdFt )
1915 : : {
1916 : : WW8_CP start;
1917 : : long nLen;
1918 : 36 : sal_uInt8 nNumber = 5;
1919 : :
1920 [ + + ]: 252 : for( sal_uInt8 nI = 0x20; nI; nI >>= 1, nNumber-- )
1921 : : {
1922 [ + + ]: 216 : if (nI & nWhichItems)
1923 : : {
1924 : 60 : bool bOk = true;
1925 [ - + ]: 60 : if( bVer67 )
1926 [ # # ][ # # ]: 0 : bOk = ( pHdFt->GetTextPos(grpfIhdt, nI, start, nLen ) && nLen >= 2 );
[ # # ]
1927 : : else
1928 : : {
1929 [ + - ]: 60 : pHdFt->GetTextPosExact( static_cast< short >(nNumber + (nSect+1)*6), start, nLen);
1930 [ + + ][ + - ]: 60 : bOk = ( 2 <= nLen ) && isValid_HdFt_CP(start);
1931 : : }
1932 : :
1933 : : bool bUseLeft
1934 : 60 : = (nI & ( WW8_HEADER_EVEN | WW8_FOOTER_EVEN )) ? true: false;
1935 : : bool bFooter
1936 : 60 : = (nI & ( WW8_FOOTER_EVEN | WW8_FOOTER_ODD | WW8_FOOTER_FIRST )) ? true: false;
1937 : :
1938 [ - + ]: 60 : SwFrmFmt& rFmt = bUseLeft ? pPD->GetLeft() : pPD->GetMaster();
1939 : :
1940 : : SwFrmFmt* pHdFtFmt;
1941 [ + + ]: 60 : if (bFooter)
1942 : : {
1943 : 36 : bIsFooter = true;
1944 : : //#i17196# Cannot have left without right
1945 [ + - ][ + - ]: 36 : if (!pPD->GetMaster().GetFooter().GetFooterFmt())
1946 [ + - ][ + - ]: 36 : pPD->GetMaster().SetFmtAttr(SwFmtFooter(true));
[ + - ]
1947 [ - + ]: 36 : if (bUseLeft)
1948 [ # # ][ # # ]: 0 : pPD->GetLeft().SetFmtAttr(SwFmtFooter(true));
[ # # ]
1949 [ + - ]: 36 : pHdFtFmt = const_cast<SwFrmFmt*>(rFmt.GetFooter().GetFooterFmt());
1950 : : }
1951 : : else
1952 : : {
1953 : 24 : bIsHeader = true;
1954 : : //#i17196# Cannot have left without right
1955 [ + - ][ + - ]: 24 : if (!pPD->GetMaster().GetHeader().GetHeaderFmt())
1956 [ + - ][ + - ]: 24 : pPD->GetMaster().SetFmtAttr(SwFmtHeader(true));
[ + - ]
1957 [ - + ]: 24 : if (bUseLeft)
1958 [ # # ][ # # ]: 0 : pPD->GetLeft().SetFmtAttr(SwFmtHeader(true));
[ # # ]
1959 [ + - ]: 24 : pHdFtFmt = const_cast<SwFrmFmt*>(rFmt.GetHeader().GetHeaderFmt());
1960 : : }
1961 : :
1962 [ + + ]: 60 : if (bOk)
1963 : : {
1964 : 36 : bool bHackRequired = false;
1965 [ + + ][ - + ]: 36 : if (bIsHeader && rSection.IsFixedHeightHeader())
[ - + ]
1966 : 0 : bHackRequired = true;
1967 [ + + ][ - + ]: 36 : else if (bIsFooter && rSection.IsFixedHeightFooter())
[ - + ]
1968 : 0 : bHackRequired = true;
1969 : :
1970 [ - + ]: 36 : if (bHackRequired)
1971 : : {
1972 : : Read_HdFtTextAsHackedFrame(start, nLen, *pHdFtFmt,
1973 [ # # ][ # # ]: 0 : static_cast< sal_uInt16 >(rSection.GetTextAreaWidth()) );
1974 : : }
1975 : : else
1976 [ + - ]: 36 : Read_HdFtText(start, nLen, pHdFtFmt);
1977 : : }
1978 [ + - ][ - + ]: 24 : else if (!bOk && pPrev)
1979 [ # # ]: 0 : CopyPageDescHdFt(pPrev, pPD, nI);
1980 : :
1981 : 60 : bIsHeader = bIsFooter = false;
1982 : : }
1983 : : }
1984 : : }
1985 : 36 : }
1986 : :
1987 : 108 : bool wwSectionManager::SectionIsProtected(const wwSection &rSection) const
1988 : : {
1989 [ - + ][ # # ]: 108 : return (mrReader.pWwFib->fReadOnlyRecommended && !rSection.IsNotProtected());
1990 : : }
1991 : :
1992 : 108 : void wwSectionManager::SetHdFt(wwSection &rSection, int nSect,
1993 : : const wwSection *pPrevious)
1994 : : {
1995 : : // Header / Footer nicht da
1996 [ + + ]: 108 : if (!rSection.maSep.grpfIhdt)
1997 : 108 : return;
1998 : :
1999 : : OSL_ENSURE(rSection.mpPage, "makes no sense to call with a main page");
2000 [ + - ]: 18 : if (rSection.mpPage)
2001 : : {
2002 : : mrReader.Read_HdFt(false, nSect, pPrevious ? pPrevious->mpPage : 0,
2003 [ - + ]: 18 : rSection);
2004 : : }
2005 : :
2006 [ + - ]: 18 : if (rSection.mpTitlePage)
2007 : : {
2008 : : // 2 Pagedescs noetig: 1.Seite und folgende
2009 : : // 1. Seite einlesen
2010 : : mrReader.Read_HdFt(true, nSect, pPrevious ? pPrevious->mpTitlePage : 0,
2011 [ - + ]: 18 : rSection);
2012 : : }
2013 : :
2014 : : // Kopf / Fuss - Index Updaten
2015 : : // Damit der Index auch spaeter noch stimmt
2016 [ + - ]: 18 : if (mrReader.pHdFt)
2017 : 18 : mrReader.pHdFt->UpdateIndex(rSection.maSep.grpfIhdt);
2018 : :
2019 : : }
2020 : :
2021 : : class AttribHere : public std::unary_function<const xub_StrLen*, bool>
2022 : : {
2023 : : private:
2024 : : xub_StrLen nPosition;
2025 : : public:
2026 : : AttribHere(xub_StrLen nPos) : nPosition(nPos) {}
2027 : : bool operator()(const xub_StrLen *pPosition) const
2028 : : {
2029 : : return (*pPosition >= nPosition);
2030 : : }
2031 : : };
2032 : :
2033 : 5487 : void SwWW8ImplReader::AppendTxtNode(SwPosition& rPos)
2034 : : {
2035 : 5487 : SwTxtNode* pTxt = pPaM->GetNode()->GetTxtNode();
2036 : :
2037 : 5487 : const SwNumRule* pRule = NULL;
2038 : :
2039 [ + - ]: 5487 : if (pTxt != NULL)
2040 : 5487 : pRule = sw::util::GetNumRuleFromTxtNode(*pTxt);
2041 : :
2042 [ + + ][ + + ]: 5487 : if (
[ + - ][ - + ]
2043 : 849 : pRule && !pWDop->fDontUseHTMLAutoSpacing &&
2044 : : (bParaAutoBefore || bParaAutoAfter)
2045 : : )
2046 : : {
2047 : : // If after spacing is set to auto, set the after space to 0
2048 [ # # ]: 0 : if (bParaAutoAfter)
2049 : 0 : SetLowerSpacing(*pPaM, 0);
2050 : :
2051 : : // If the previous textnode had numbering and
2052 : : // and before spacing is set to auto, set before space to 0
2053 [ # # ][ # # ]: 0 : if(pPrevNumRule && bParaAutoBefore)
2054 : 0 : SetUpperSpacing(*pPaM, 0);
2055 : :
2056 : : // If the previous numbering rule was different we need
2057 : : // to insert a space after the previous paragraph
2058 [ # # ][ # # ]: 0 : if((pRule != pPrevNumRule) && pPreviousNumPaM)
2059 : 0 : SetLowerSpacing(*pPreviousNumPaM, GetParagraphAutoSpace(pWDop->fDontUseHTMLAutoSpacing));
2060 : :
2061 : : // cache current paragraph
2062 [ # # ]: 0 : if(pPreviousNumPaM)
2063 [ # # ]: 0 : delete pPreviousNumPaM, pPreviousNumPaM = 0;
2064 : :
2065 [ # # ]: 0 : pPreviousNumPaM = new SwPaM(*pPaM);
2066 : 0 : pPrevNumRule = pRule;
2067 : : }
2068 [ + + ][ - + ]: 5487 : else if(!pRule && pPreviousNumPaM)
2069 : : {
2070 : : // If the previous paragraph has numbering but the current one does not
2071 : : // we need to add a space after the previous paragraph
2072 : 0 : SetLowerSpacing(*pPreviousNumPaM, GetParagraphAutoSpace(pWDop->fDontUseHTMLAutoSpacing));
2073 [ # # ]: 0 : delete pPreviousNumPaM, pPreviousNumPaM = 0;
2074 : 0 : pPrevNumRule = 0;
2075 : : }
2076 : : else
2077 : : {
2078 : : // clear paragraph cache
2079 [ - + ]: 5487 : if(pPreviousNumPaM)
2080 [ # # ]: 0 : delete pPreviousNumPaM, pPreviousNumPaM = 0;
2081 : 5487 : pPrevNumRule = pRule;
2082 : : }
2083 : :
2084 : : // If this is the first paragraph in the document and
2085 : : // Auto-spacing before paragraph is set,
2086 : : // set the upper spacing value to 0
2087 [ - + ][ # # ]: 5487 : if(bParaAutoBefore && bFirstPara && !pWDop->fDontUseHTMLAutoSpacing)
[ # # ]
2088 : 0 : SetUpperSpacing(*pPaM, 0);
2089 : :
2090 : 5487 : bFirstPara = false;
2091 : :
2092 : 5487 : rDoc.AppendTxtNode(rPos);
2093 : :
2094 : : //We can flush all anchored graphics at the end of a paragraph.
2095 : 5487 : pAnchorStck->Flush();
2096 : 5487 : }
2097 : :
2098 : 0 : bool SwWW8ImplReader::SetSpacing(SwPaM &rMyPam, int nSpace, bool bIsUpper )
2099 : : {
2100 : 0 : bool bRet = false;
2101 : 0 : const SwPosition* pSpacingPos = rMyPam.GetPoint();
2102 : :
2103 : 0 : const SvxULSpaceItem* pULSpaceItem = (const SvxULSpaceItem*)pCtrlStck->GetFmtAttr(*pSpacingPos, RES_UL_SPACE);
2104 : :
2105 [ # # ]: 0 : if(pULSpaceItem != 0)
2106 : : {
2107 [ # # ]: 0 : SvxULSpaceItem aUL(*pULSpaceItem);
2108 : :
2109 [ # # ]: 0 : if(bIsUpper)
2110 : 0 : aUL.SetUpper( static_cast< sal_uInt16 >(nSpace) );
2111 : : else
2112 : 0 : aUL.SetLower( static_cast< sal_uInt16 >(nSpace) );
2113 : :
2114 : 0 : xub_StrLen nEnd = pSpacingPos->nContent.GetIndex();
2115 [ # # ][ # # ]: 0 : rMyPam.GetPoint()->nContent.Assign(rMyPam.GetCntntNode(), 0);
2116 [ # # ]: 0 : pCtrlStck->NewAttr(*pSpacingPos, aUL);
2117 [ # # ][ # # ]: 0 : rMyPam.GetPoint()->nContent.Assign(rMyPam.GetCntntNode(), nEnd);
2118 [ # # ]: 0 : pCtrlStck->SetAttr(*pSpacingPos, RES_UL_SPACE);
2119 [ # # ]: 0 : bRet = true;
2120 : : }
2121 : 0 : return bRet;
2122 : : }
2123 : :
2124 : 0 : bool SwWW8ImplReader::SetLowerSpacing(SwPaM &rMyPam, int nSpace)
2125 : : {
2126 : 0 : return SetSpacing(rMyPam, nSpace, false);
2127 : : }
2128 : :
2129 : 0 : bool SwWW8ImplReader::SetUpperSpacing(SwPaM &rMyPam, int nSpace)
2130 : : {
2131 : 0 : return SetSpacing(rMyPam, nSpace, true);
2132 : : }
2133 : :
2134 : 5307 : sal_uInt16 SwWW8ImplReader::TabRowSprm(int nLevel) const
2135 : : {
2136 [ - + ]: 5307 : if (bVer67)
2137 : 0 : return 25;
2138 [ + + ]: 5307 : return nLevel ? 0x244C : 0x2417;
2139 : : }
2140 : :
2141 : 144 : void SwWW8ImplReader::EndSpecial()
2142 : : {
2143 : : // Frame / Table / Anl
2144 [ - + ]: 144 : if (bAnl)
2145 : 0 : StopAllAnl(); // -> bAnl = false
2146 : :
2147 [ - + ]: 144 : while(maApos.size() > 1)
2148 : : {
2149 : 0 : StopTable();
2150 : 0 : maApos.pop_back();
2151 : 0 : --nInTable;
2152 [ # # ]: 0 : if (maApos[nInTable] == true)
2153 : 0 : StopApo();
2154 : : }
2155 : :
2156 [ - + ]: 144 : if (maApos[0] == true)
2157 : 0 : StopApo();
2158 : :
2159 : : OSL_ENSURE(!nInTable, "unclosed table!");
2160 : 144 : }
2161 : :
2162 : 6153 : bool SwWW8ImplReader::ProcessSpecial(bool &rbReSync, WW8_CP nStartCp)
2163 : : {
2164 : : // Frame / Table / Anl
2165 [ - + ]: 6153 : if (bInHyperlink)
2166 : 0 : return false;
2167 : :
2168 : 6153 : rbReSync = false;
2169 : :
2170 : : OSL_ENSURE(nInTable >= 0,"nInTable < 0!");
2171 : :
2172 : : // TabRowEnd
2173 [ - + ][ + - ]: 6153 : bool bTableRowEnd = (pPlcxMan->HasParaSprm(bVer67 ? 25 : 0x2417) != 0 );
2174 : :
2175 : : // es muss leider fuer jeden Absatz zuerst nachgesehen werden,
2176 : : // ob sich unter den sprms
2177 : : // das sprm 29 (bzw. 0x261B) befindet, das ein APO einleitet.
2178 : : // Alle weiteren sprms beziehen sich dann naemlich auf das APO und nicht
2179 : : // auf den normalen Text drumrum.
2180 : : // Dasselbe gilt fuer eine Tabelle ( sprm 24 (bzw. 0x2416) )
2181 : : // und Anls ( sprm 13 ).
2182 : : // WW: Tabelle in APO geht ( Beide Anfaende treten gleichzeitig auf )
2183 : : // WW: APO in Tabelle geht nicht
2184 : : // d.h. Wenn eine Tabelle Inhalt eines Apo ist, dann muss der
2185 : : // Apo-Anfang zuerst bearbeitet werden, damit die Tabelle im Apo steht
2186 : : // und nicht umgekehrt. Am Ende muss dagegen zuerst das Tabellenende
2187 : : // bearbeitet werden, da die Apo erst nach der Tabelle abgeschlossen
2188 : : // werden darf ( sonst wird das Apo-Ende nie gefunden ).
2189 : : // Dasselbe gilt fuer Fly / Anl, Tab / Anl, Fly / Tab / Anl.
2190 : : //
2191 : : // Wenn die Tabelle in einem Apo steht, fehlen im TabRowEnd-Bereich
2192 : : // die Apo-Angaben. Damit hier die Apo nicht beendet wird, wird
2193 : : // ProcessApo dann nicht aufgerufen.
2194 : :
2195 : : // KHZ: When there is a table inside the Apo the Apo-flags are also
2196 : : // missing for the 2nd, 3rd... paragraphs of each cell.
2197 : :
2198 : :
2199 : : // 1st look for in-table flag, for 2000+ there is a subtable flag to
2200 : : // be considered, the sprm 6649 gives the level of the table
2201 : 6153 : sal_uInt8 nCellLevel = 0;
2202 : :
2203 [ - + ]: 6153 : if (bVer67)
2204 [ # # ]: 0 : nCellLevel = 0 != pPlcxMan->HasParaSprm(24);
2205 : : else
2206 : : {
2207 [ + - ]: 6153 : nCellLevel = 0 != pPlcxMan->HasParaSprm(0x2416);
2208 [ + + ]: 6153 : if (!nCellLevel)
2209 [ + - ]: 5526 : nCellLevel = 0 != pPlcxMan->HasParaSprm(0x244B);
2210 : : }
2211 : :
2212 : 6153 : WW8_TablePos *pTabPos=0;
2213 : : WW8_TablePos aTabPos;
2214 [ + + ][ + - ]: 6153 : if (nCellLevel && !bVer67)
2215 : : {
2216 : : WW8PLCFxSave1 aSave;
2217 [ + - ]: 627 : pPlcxMan->GetPap()->Save( aSave );
2218 : 627 : rbReSync = true;
2219 : 627 : WW8PLCFx_Cp_FKP* pPap = pPlcxMan->GetPapPLCF();
2220 : 627 : WW8_CP nMyStartCp=nStartCp;
2221 : :
2222 [ + - ][ + - ]: 627 : if (const sal_uInt8 *pLevel = pPlcxMan->HasParaSprm(0x6649))
2223 : 627 : nCellLevel = *pLevel;
2224 : :
2225 [ + - ]: 627 : bool bHasRowEnd = SearchRowEnd(pPap, nMyStartCp, nCellLevel-1);
2226 : :
2227 : : //Bad Table, remain unchanged in level, e.g. #i19667#
2228 [ - + ]: 627 : if (!bHasRowEnd)
2229 : 0 : nCellLevel = static_cast< sal_uInt8 >(nInTable);
2230 : :
2231 [ + - ][ + - ]: 627 : if (bHasRowEnd && ParseTabPos(&aTabPos,pPap))
[ - + ][ - + ]
2232 : 0 : pTabPos = &aTabPos;
2233 : :
2234 [ + - ]: 627 : pPlcxMan->GetPap()->Restore( aSave );
2235 : : }
2236 : :
2237 : : // then look if we are in an Apo
2238 : :
2239 [ + - ]: 6153 : ApoTestResults aApo = TestApo(nCellLevel, bTableRowEnd, pTabPos);
2240 : :
2241 : : //look to see if we are in a Table, but Table in foot/end note not allowed
2242 [ + + ][ + - ]: 6153 : bool bStartTab = (nInTable < nCellLevel) && !bFtnEdn;
2243 : :
2244 [ + + ][ + + ]: 6153 : bool bStopTab = bWasTabRowEnd && (nInTable > nCellLevel) && !bFtnEdn;
[ + - ]
2245 : :
2246 : 6153 : bWasTabRowEnd = false; // must be deactivated right here to prevent next
2247 : : // WW8TabDesc::TableCellEnd() from making nonsense
2248 : :
2249 [ + + ][ + + ]: 6153 : if (nInTable && !bTableRowEnd && !bStopTab && (nInTable == nCellLevel && aApo.HasStartStop()))
[ + + ][ + + ]
[ - + ][ - + ]
2250 : 0 : bStopTab = bStartTab = true; // Required to stop and start table
2251 : :
2252 : : // Dann auf Anl (Nummerierung) testen
2253 : : // und dann alle Ereignisse in der richtigen Reihenfolge bearbeiten
2254 : :
2255 [ - + ][ # # ]: 6153 : if( bAnl && !bTableRowEnd )
2256 : : {
2257 [ # # ]: 0 : const sal_uInt8* pSprm13 = pPlcxMan->HasParaSprm( 13 );
2258 [ # # ]: 0 : if( pSprm13 )
2259 : : { // Noch Anl ?
2260 [ # # ]: 0 : sal_uInt8 nT = static_cast< sal_uInt8 >(GetNumType( *pSprm13 ));
2261 [ # # ]: 0 : if( ( nT != WW8_Pause && nT != nWwNumType ) // Anl-Wechsel
[ # # # # ]
[ # # ][ # # ]
[ # # ]
2262 : 0 : || aApo.HasStartStop() // erzwungenes Anl-Ende
2263 : : || bStopTab || bStartTab )
2264 : : {
2265 [ # # ]: 0 : StopAnlToRestart(nT); // Anl-Restart ( = Wechsel ) ueber sprms
2266 : : }
2267 : : else
2268 : : {
2269 [ # # ]: 0 : NextAnlLine( pSprm13 ); // naechste Anl-Zeile
2270 : : }
2271 : : }
2272 : : else
2273 : : { // Anl normal zuende
2274 [ # # ]: 0 : StopAllAnl(); // Wirkliches Ende
2275 : : }
2276 : : }
2277 [ + + ]: 6153 : if (bStopTab)
2278 : : {
2279 [ + - ]: 90 : StopTable();
2280 [ + - ]: 90 : maApos.pop_back();
2281 : 90 : --nInTable;
2282 : : }
2283 [ + + ]: 6153 : if (aApo.mbStopApo)
2284 : : {
2285 [ + - ]: 9 : StopApo();
2286 [ + - ]: 9 : maApos[nInTable] = false;
2287 : : }
2288 : :
2289 [ + + ]: 6153 : if (aApo.mbStartApo)
2290 : : {
2291 [ + - ][ + - ]: 9 : maApos[nInTable] = StartApo(aApo, pTabPos);
2292 : : // nach StartApo ist ein ReSync noetig ( eigentlich nur, falls die Apo
2293 : : // ueber eine FKP-Grenze geht
2294 : 9 : rbReSync = true;
2295 : : }
2296 [ + + ]: 6153 : if (bStartTab)
2297 : : {
2298 : : WW8PLCFxSave1 aSave;
2299 [ + - ]: 81 : pPlcxMan->GetPap()->Save( aSave );
2300 : :
2301 [ - + ]: 81 : if (bAnl) // Nummerierung ueber Zellengrenzen
2302 [ # # ]: 0 : StopAllAnl(); // fuehrt zu Absturz -> keine Anls
2303 : : // in Tabellen
2304 [ + + ]: 171 : while (nInTable < nCellLevel)
2305 : : {
2306 [ + - ][ + - ]: 90 : if (StartTable(nStartCp))
2307 : 90 : ++nInTable;
2308 : : else
2309 : 0 : break;
2310 : :
2311 [ + - ]: 90 : maApos.push_back(false);
2312 : : }
2313 : : // nach StartTable ist ein ReSync noetig ( eigentlich nur, falls die
2314 : : // Tabelle ueber eine FKP-Grenze geht
2315 : 81 : rbReSync = true;
2316 [ + - ]: 81 : pPlcxMan->GetPap()->Restore( aSave );
2317 : : }
2318 : 6153 : return bTableRowEnd;
2319 : : }
2320 : :
2321 : 147 : CharSet SwWW8ImplReader::GetCurrentCharSet()
2322 : : {
2323 : : /*
2324 : : #i2015
2325 : : If the hard charset is set use it, if not see if there is an open
2326 : : character run that has set the charset, if not then fallback to the
2327 : : current underlying paragraph style.
2328 : : */
2329 : 147 : CharSet eSrcCharSet = eHardCharSet;
2330 [ + - ]: 147 : if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW)
2331 : : {
2332 [ + + ]: 147 : if (!maFontSrcCharSets.empty())
2333 : 144 : eSrcCharSet = maFontSrcCharSets.top();
2334 [ + + ][ - + ]: 147 : if ((eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) && nCharFmt >= 0 && (size_t)nCharFmt < vColl.size() )
[ # # ][ - + ]
2335 : 0 : eSrcCharSet = vColl[nCharFmt].GetCharSet();
2336 [ + + ][ + - ]: 147 : if ((eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) && StyleExists(nAktColl) && nAktColl < vColl.size())
[ + - ][ + + ]
2337 : 3 : eSrcCharSet = vColl[nAktColl].GetCharSet();
2338 [ - + ]: 147 : if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW)
2339 : : {
2340 : : /*
2341 : : #i22206#/#i52786#
2342 : : The (default) character set used for a run of text is the default
2343 : : character set for the version of Word that last saved the document.
2344 : :
2345 : : This is a bit tentative, more might be required if the concept is correct.
2346 : : When later version of word write older 6/95 documents the charset is
2347 : : correctly set in the character runs involved, so its hard to reproduce
2348 : : documents that require this to be sure of the process involved.
2349 : : */
2350 [ # # ]: 0 : const SvxLanguageItem *pLang = (const SvxLanguageItem*)GetFmtAttr(RES_CHRATR_LANGUAGE);
2351 [ # # ]: 0 : LanguageType eLang = pLang ? pLang->GetLanguage() : LANGUAGE_SYSTEM;
2352 [ # # ]: 0 : ::com::sun::star::lang::Locale aLocale(MsLangId::convertLanguageToLocale(eLang));
2353 [ # # ]: 0 : eSrcCharSet = msfilter::util::getBestTextEncodingFromLocale(aLocale);
2354 : : }
2355 : : }
2356 : 147 : return eSrcCharSet;
2357 : : }
2358 : :
2359 : : //Takashi Ono for CJK
2360 : 0 : CharSet SwWW8ImplReader::GetCurrentCJKCharSet()
2361 : : {
2362 : : /*
2363 : : #i2015
2364 : : If the hard charset is set use it, if not see if there is an open
2365 : : character run that has set the charset, if not then fallback to the
2366 : : current underlying paragraph style.
2367 : : */
2368 : 0 : CharSet eSrcCharSet = eHardCharSet;
2369 [ # # ]: 0 : if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW)
2370 : : {
2371 [ # # ]: 0 : if (!maFontSrcCJKCharSets.empty())
2372 : 0 : eSrcCharSet = maFontSrcCJKCharSets.top();
2373 [ # # ]: 0 : if (!vColl.empty())
2374 : : {
2375 [ # # ][ # # ]: 0 : if ((eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) && nCharFmt >= 0 && (size_t)nCharFmt < vColl.size() )
[ # # ][ # # ]
2376 : 0 : eSrcCharSet = vColl[nCharFmt].GetCJKCharSet();
2377 [ # # ][ # # ]: 0 : if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW && nAktColl < vColl.size())
[ # # ]
2378 : 0 : eSrcCharSet = vColl[nAktColl].GetCJKCharSet();
2379 : : }
2380 [ # # ]: 0 : if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW)
2381 : : { // patch from cmc for #i52786#
2382 : : /*
2383 : : #i22206#/#i52786#
2384 : : The (default) character set used for a run of text is the default
2385 : : character set for the version of Word that last saved the document.
2386 : :
2387 : : This is a bit tentative, more might be required if the concept is correct.
2388 : : When later version of word write older 6/95 documents the charset is
2389 : : correctly set in the character runs involved, so its hard to reproduce
2390 : : documents that require this to be sure of the process involved.
2391 : : */
2392 : : const SvxLanguageItem *pLang =
2393 : 0 : (const SvxLanguageItem*)GetFmtAttr(RES_CHRATR_LANGUAGE);
2394 [ # # ]: 0 : if (pLang)
2395 : : {
2396 [ # # ]: 0 : switch (pLang->GetLanguage())
2397 : : {
2398 : : case LANGUAGE_CZECH:
2399 : 0 : eSrcCharSet = RTL_TEXTENCODING_MS_1250;
2400 : 0 : break;
2401 : : default:
2402 : 0 : eSrcCharSet = RTL_TEXTENCODING_MS_1252;
2403 : 0 : break;
2404 : : }
2405 : : }
2406 : : }
2407 : : }
2408 : 0 : return eSrcCharSet;
2409 : : }
2410 : :
2411 : 0 : void SwWW8ImplReader::PostProcessAttrs()
2412 : : {
2413 [ # # ]: 0 : if (mpPostProcessAttrsInfo != NULL)
2414 : : {
2415 [ # # ]: 0 : SfxItemIter aIter(mpPostProcessAttrsInfo->mItemSet);
2416 : :
2417 : 0 : const SfxPoolItem * pItem = aIter.GetCurItem();
2418 [ # # ]: 0 : if (pItem != NULL)
2419 : : {
2420 [ # # ][ # # ]: 0 : do
[ # # ][ # # ]
2421 : : {
2422 : 0 : pCtrlStck->NewAttr(*mpPostProcessAttrsInfo->mPaM.GetPoint(),
2423 [ # # ]: 0 : *pItem);
2424 : 0 : pCtrlStck->SetAttr(*mpPostProcessAttrsInfo->mPaM.GetMark(),
2425 [ # # ]: 0 : pItem->Which(), true);
2426 : : }
2427 : 0 : while (!aIter.IsAtEnd() && 0 != (pItem = aIter.NextItem()));
2428 : : }
2429 : :
2430 [ # # ][ # # ]: 0 : delete mpPostProcessAttrsInfo;
2431 [ # # ]: 0 : mpPostProcessAttrsInfo = NULL;
2432 : : }
2433 : 0 : }
2434 : :
2435 : : /*
2436 : : #i9241#
2437 : : It appears that some documents that are in a baltic 8 bit encoding which has
2438 : : some undefined characters can have use made of those characters, in which
2439 : : case they default to CP1252. If not then its perhaps that the font encoding
2440 : : is only in use for 6/7 and for 8+ if we are in 8bit mode then the encoding
2441 : : is always 1252.
2442 : :
2443 : : So a encoding converter that on an undefined character attempts to
2444 : : convert from 1252 on the undefined character
2445 : : */
2446 : 4323 : sal_Size Custom8BitToUnicode(rtl_TextToUnicodeConverter hConverter,
2447 : : sal_Char *pIn, sal_Size nInLen, sal_Unicode *pOut, sal_Size nOutLen)
2448 : : {
2449 : : const sal_uInt32 nFlags =
2450 : : RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
2451 : : RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
2452 : : RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE |
2453 : 4323 : RTL_TEXTTOUNICODE_FLAGS_FLUSH;
2454 : :
2455 : : const sal_uInt32 nFlags2 =
2456 : : RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE |
2457 : : RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_IGNORE |
2458 : : RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE |
2459 : 4323 : RTL_TEXTTOUNICODE_FLAGS_FLUSH;
2460 : :
2461 : 4323 : sal_Size nDestChars=0;
2462 : 4323 : sal_Size nConverted=0;
2463 : :
2464 [ - + ]: 4323 : do
2465 : : {
2466 : 4323 : sal_uInt32 nInfo = 0;
2467 : 4323 : sal_Size nThisConverted=0;
2468 : :
2469 : : nDestChars += rtl_convertTextToUnicode(hConverter, 0,
2470 : : pIn+nConverted, nInLen-nConverted,
2471 : : pOut+nDestChars, nOutLen-nDestChars,
2472 [ + - ]: 4323 : nFlags, &nInfo, &nThisConverted);
2473 : :
2474 : : OSL_ENSURE(nInfo == 0, "A character conversion failed!");
2475 : :
2476 : 4323 : nConverted += nThisConverted;
2477 : :
2478 [ + - ][ - + ]: 4323 : if (
2479 : : nInfo & RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR ||
2480 : : nInfo & RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
2481 : : )
2482 : : {
2483 : : sal_Size nOtherConverted;
2484 : : rtl_TextToUnicodeConverter hCP1252Converter =
2485 [ # # ]: 0 : rtl_createTextToUnicodeConverter(RTL_TEXTENCODING_MS_1252);
2486 : : nDestChars += rtl_convertTextToUnicode(hCP1252Converter, 0,
2487 : : pIn+nConverted, 1,
2488 : : pOut+nDestChars, nOutLen-nDestChars,
2489 [ # # ]: 0 : nFlags2, &nInfo, &nOtherConverted);
2490 [ # # ]: 0 : rtl_destroyTextToUnicodeConverter(hCP1252Converter);
2491 : 0 : nConverted+=1;
2492 : : }
2493 : : } while (nConverted < nInLen);
2494 : :
2495 : 4323 : return nDestChars;
2496 : : }
2497 : :
2498 : 0 : bool SwWW8ImplReader::LangUsesHindiNumbers(sal_uInt16 nLang)
2499 : : {
2500 : 0 : bool bResult = false;
2501 : :
2502 [ # # ]: 0 : switch (nLang)
2503 : : {
2504 : : case 0x1401: // Arabic(Algeria)
2505 : : case 0x3c01: // Arabic(Bahrain)
2506 : : case 0xc01: // Arabic(Egypt)
2507 : : case 0x801: // Arabic(Iraq)
2508 : : case 0x2c01: // Arabic (Jordan)
2509 : : case 0x3401: // Arabic(Kuwait)
2510 : : case 0x3001: // Arabic(Lebanon)
2511 : : case 0x1001: // Arabic(Libya)
2512 : : case 0x1801: // Arabic(Morocco)
2513 : : case 0x2001: // Arabic(Oman)
2514 : : case 0x4001: // Arabic(Qatar)
2515 : : case 0x401: // Arabic(Saudi Arabia)
2516 : : case 0x2801: // Arabic(Syria)
2517 : : case 0x1c01: // Arabic(Tunisia)
2518 : : case 0x3801: // Arabic(U.A.E)
2519 : : case 0x2401: // Arabic(Yemen)
2520 : 0 : bResult = true;
2521 : 0 : break;
2522 : : default:
2523 : 0 : break;
2524 : : }
2525 : :
2526 : 0 : return bResult;
2527 : : }
2528 : :
2529 : 0 : sal_Unicode SwWW8ImplReader::TranslateToHindiNumbers(sal_Unicode nChar)
2530 : : {
2531 [ # # ][ # # ]: 0 : if (nChar >= 0x0030 && nChar <= 0x0039)
2532 : 0 : return nChar + 0x0630;
2533 : :
2534 : 0 : return nChar;
2535 : : }
2536 : :
2537 : : // Returnwert: true for no Sonderzeichen
2538 : 12645 : bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, long nEnd, long nCpOfs)
2539 : : {
2540 : 12645 : sal_Size nRequestedStrLen = nEnd - rPos;
2541 : :
2542 : : OSL_ENSURE(nRequestedStrLen, "String is 0");
2543 [ - + ]: 12645 : if (!nRequestedStrLen)
2544 : 0 : return true;
2545 : :
2546 [ + - ]: 12645 : sal_Size nRequestedPos = pSBase->WW8Cp2Fc(nCpOfs+rPos, &bIsUnicode);
2547 [ + - ]: 12645 : bool bValidPos = checkSeek(*pStrm, nRequestedPos);
2548 : : OSL_ENSURE(bValidPos, "Document claimed to have more text than available");
2549 [ - + ]: 12645 : if (!bValidPos)
2550 : : {
2551 : : //Swallow missing range, e.g. #i95550#
2552 : 0 : rPos+=nRequestedStrLen;
2553 : 0 : return true;
2554 : : }
2555 : :
2556 [ + - ][ + + ]: 12645 : sal_Size nAvailableStrLen = pStrm->remainingSize() / (bIsUnicode ? 2 : 1);
2557 : : OSL_ENSURE(nAvailableStrLen, "Document claimed to have more text than available");
2558 [ - + ]: 12645 : if (!nAvailableStrLen)
2559 : : {
2560 : : //Swallow missing range, e.g. #i95550#
2561 : 0 : rPos+=nRequestedStrLen;
2562 : 0 : return true;
2563 : : }
2564 : :
2565 [ + - ]: 12645 : sal_Size nValidStrLen = std::min(nRequestedStrLen, nAvailableStrLen);
2566 : :
2567 : : // Unicode-Flag neu setzen und notfalls File-Pos korrigieren
2568 : : // merke: Seek kostet nicht viel, da inline geprueft wird,
2569 : : // ob die korrekte FilePos nicht schon erreicht ist.
2570 : : xub_StrLen nStrLen;
2571 [ + - ]: 12645 : if (nValidStrLen <= (STRING_MAXLEN-1))
2572 [ + - ]: 12645 : nStrLen = writer_cast<xub_StrLen>(nValidStrLen);
2573 : : else
2574 : 0 : nStrLen = STRING_MAXLEN-1;
2575 : :
2576 : : const CharSet eSrcCharSet = bVer67 ? GetCurrentCharSet() :
2577 [ - + ][ # # ]: 12645 : RTL_TEXTENCODING_MS_1252;
2578 : : const CharSet eSrcCJKCharSet = bVer67 ? GetCurrentCJKCharSet() :
2579 [ - + ][ # # ]: 12645 : RTL_TEXTENCODING_MS_1252;
2580 : :
2581 : : // allocate unicode string data
2582 [ + - ]: 12645 : rtl_uString *pStr = comphelper::string::rtl_uString_alloc(nStrLen);
2583 : 12645 : sal_Unicode* pBuffer = pStr->buffer;
2584 : 12645 : sal_Unicode* pWork = pBuffer;
2585 : :
2586 : 12645 : sal_Char* p8Bits = NULL;
2587 : :
2588 : 12645 : rtl_TextToUnicodeConverter hConverter = 0;
2589 [ + + ][ - + ]: 12645 : if (!bIsUnicode || bVer67)
2590 [ + - ]: 12384 : hConverter = rtl_createTextToUnicodeConverter(eSrcCharSet);
2591 : :
2592 [ + + ]: 12645 : if (!bIsUnicode)
2593 [ + - ]: 12384 : p8Bits = new sal_Char[nStrLen];
2594 : :
2595 : : // read the stream data
2596 : 12645 : sal_uInt8 nBCode = 0;
2597 : : sal_uInt16 nUCode;
2598 : : xub_StrLen nL2;
2599 : :
2600 : 12645 : sal_uInt16 nCTLLang = 0;
2601 [ + - ]: 12645 : const SfxPoolItem * pItem = GetFmtAttr(RES_CHRATR_CTL_LANGUAGE);
2602 [ + - ]: 12645 : if (pItem != NULL)
2603 [ - + ]: 12645 : nCTLLang = dynamic_cast<const SvxLanguageItem *>(pItem)->GetLanguage();
2604 : :
2605 [ + + ]: 406755 : for( nL2 = 0; nL2 < nStrLen; ++nL2, ++pWork )
2606 : : {
2607 [ + + ]: 402864 : if (bIsUnicode)
2608 [ + - ]: 2112 : *pStrm >> nUCode; // unicode --> read 2 bytes
2609 : : else
2610 : : {
2611 [ + - ]: 400752 : *pStrm >> nBCode; // old code --> read 1 byte
2612 : 400752 : nUCode = nBCode;
2613 : : }
2614 : :
2615 [ - + ]: 402864 : if (pStrm->GetError())
2616 : : {
2617 : 0 : rPos = WW8_CP_MAX-10; // -> eof or other error
2618 : 0 : rtl_freeMemory(pStr);
2619 [ # # ]: 0 : delete [] p8Bits;
2620 : 0 : return true;
2621 : : }
2622 : :
2623 [ + + ][ - + ]: 402864 : if ((32 > nUCode) || (0xa0 == nUCode))
2624 : : {
2625 [ + + ][ + - ]: 8754 : pStrm->SeekRel( bIsUnicode ? -2 : -1 );
2626 : 8754 : break; // Sonderzeichen < 32, == 0xa0 gefunden
2627 : : }
2628 : :
2629 [ + + ]: 394110 : if (bIsUnicode)
2630 : : {
2631 [ + - ]: 1965 : if (!bVer67)
2632 : 1965 : *pWork = nUCode;
2633 : : else
2634 : : {
2635 [ # # ]: 0 : if (nUCode >= 0x3000) //0x8000 ?
2636 : : {
2637 : : sal_Char aTest[2];
2638 : 0 : aTest[0] = static_cast< sal_Char >((nUCode & 0xFF00) >> 8);
2639 : 0 : aTest[1] = static_cast< sal_Char >(nUCode & 0x00FF);
2640 [ # # ]: 0 : String aTemp(aTest, 2, eSrcCJKCharSet);
2641 : : OSL_ENSURE(aTemp.Len() == 1, "so much for that theory");
2642 [ # # ]: 0 : *pWork = aTemp.GetChar(0);
2643 : : }
2644 : : else
2645 : : {
2646 : 0 : sal_Char cTest = static_cast< sal_Char >(nUCode & 0x00FF);
2647 [ # # ]: 0 : Custom8BitToUnicode(hConverter, &cTest, 1, pWork, 1);
2648 : : }
2649 : : }
2650 : : }
2651 : : else
2652 : 392145 : p8Bits[nL2] = nBCode;
2653 : : }
2654 : :
2655 [ + + ]: 12645 : if (nL2)
2656 : : {
2657 : 4437 : xub_StrLen nEndUsed = nL2;
2658 : :
2659 [ + + ]: 4437 : if (!bIsUnicode)
2660 [ + - ]: 4323 : nEndUsed = Custom8BitToUnicode(hConverter, p8Bits, nL2, pBuffer, nStrLen);
2661 : :
2662 [ + + ]: 471600 : for( xub_StrLen nI = 0; nI < nStrLen; ++nI, ++pBuffer )
2663 [ - + ][ # # ]: 467163 : if (m_bRegardHindiDigits && bBidi && LangUsesHindiNumbers(nCTLLang))
[ # # ][ - + ]
2664 : 0 : *pBuffer = TranslateToHindiNumbers(*pBuffer);
2665 : :
2666 : 4437 : pStr->buffer[nEndUsed] = 0;
2667 : 4437 : pStr->length = nEndUsed;
2668 : :
2669 [ + - ]: 4437 : emulateMSWordAddTextToParagraph(rtl::OUString(pStr, SAL_NO_ACQUIRE));
2670 : 4437 : pStr = NULL;
2671 : 4437 : rPos += nL2;
2672 [ + - ][ + - ]: 4437 : if (!maApos.back()) //a para end in apo doesn't count
2673 : 4437 : bWasParaEnd = false; //kein CR
2674 : : }
2675 : :
2676 [ + + ]: 12645 : if (hConverter)
2677 [ + - ]: 12384 : rtl_destroyTextToUnicodeConverter(hConverter);
2678 [ + + ]: 12645 : if (pStr)
2679 : 8208 : rtl_uString_release(pStr);
2680 [ + + ]: 12645 : delete [] p8Bits;
2681 : 12645 : return nL2 >= nStrLen;
2682 : : }
2683 : :
2684 : : #define MSASCII SAL_MAX_INT16
2685 : :
2686 : : namespace
2687 : : {
2688 : : //We want to force weak chars inside 0x0020 to 0x007F to LATIN
2689 : 623265 : sal_Int16 lcl_getScriptType(
2690 : : const uno::Reference<i18n::XBreakIterator>& rBI,
2691 : : const rtl::OUString &rString, sal_Int32 nPos)
2692 : : {
2693 : 623265 : sal_Int16 nScript = rBI->getScriptType(rString, nPos);
2694 [ + + ][ + + ]: 623265 : if (nScript == i18n::ScriptType::WEAK && rString[nPos] >= 0x0020 && rString[nPos] <= 0x007F)
[ + + ][ + + ]
2695 : 167982 : nScript = MSASCII;
2696 : 623265 : return nScript;
2697 : : }
2698 : :
2699 : : //We want to know about WEAK segments, so endOfScript isn't
2700 : : //useful, and see lcl_getScriptType anyway
2701 : 116796 : sal_Int32 lcl_endOfScript(
2702 : : const uno::Reference<i18n::XBreakIterator>& rBI,
2703 : : const rtl::OUString &rString, sal_Int32 nPos, sal_Int16 nScript)
2704 : : {
2705 [ + + ]: 511863 : while (nPos < rString.getLength())
2706 : : {
2707 : 506469 : sal_Int16 nNewScript = lcl_getScriptType(rBI, rString, nPos);
2708 [ + + ]: 506469 : if (nScript != nNewScript)
2709 : 111402 : break;
2710 : 395067 : ++nPos;
2711 : : }
2712 : 116796 : return nPos;
2713 : : }
2714 : :
2715 : 56139 : sal_Int32 lcl_getWriterScriptType(
2716 : : const uno::Reference<i18n::XBreakIterator>& rBI,
2717 : : const rtl::OUString &rString, sal_Int32 nPos)
2718 : : {
2719 : 56139 : sal_Int16 nScript = i18n::ScriptType::WEAK;
2720 : :
2721 [ - + ]: 56139 : if (rString.isEmpty())
2722 : 0 : return nScript;
2723 : :
2724 [ + + ]: 112380 : while (nPos >= 0)
2725 : : {
2726 : 112320 : nScript = rBI->getScriptType(rString, nPos);
2727 [ + + ]: 112320 : if (nScript != i18n::ScriptType::WEAK)
2728 : 56079 : break;
2729 : 56241 : --nPos;
2730 : : }
2731 : :
2732 : 56139 : return nScript;
2733 : : }
2734 : :
2735 : 0 : bool samePitchIgnoreUnknown(FontPitch eA, FontPitch eB)
2736 : : {
2737 [ # # ][ # # ]: 0 : return (eA == eB || eA == PITCH_DONTKNOW || eB == PITCH_DONTKNOW);
[ # # ]
2738 : : }
2739 : :
2740 : 0 : bool sameFontIgnoringIrrelevantFields(const SvxFontItem &rA, const SvxFontItem &rB)
2741 : : {
2742 : : //Ignoring CharSet, and ignoring unknown pitch
2743 : 0 : return rA.GetFamilyName() == rB.GetFamilyName() &&
2744 : 0 : rA.GetStyleName() == rB.GetStyleName() &&
2745 : 0 : rA.GetFamily() == rB.GetFamily() &&
2746 [ # # ][ # # : 0 : samePitchIgnoreUnknown(rA.GetPitch(), rB.GetPitch());
# # # # ]
2747 : : }
2748 : : }
2749 : :
2750 : : //In writer we categorize text into CJK, CTL and "Western" for everything else.
2751 : : //Microsoft Word basically categorizes text into East Asian, Complex, ASCII,
2752 : : //NonEastAsian/HighAnsi, with some shared characters and some properties to to
2753 : : //hint as to which way to bias those shared characters.
2754 : : //
2755 : : //That's four categories, we however have three categories. Given that problem
2756 : : //here we would ideally find out "what would word do" to see what font/language
2757 : : //word would assign to characters based on the unicode range they fall into and
2758 : : //hack the word one onto the range we use. However it's unclear what word's
2759 : : //categorization is. So we don't do that here yet.
2760 : : //
2761 : : //Additional to the categorization, when word encounters weak text for ambigious
2762 : : //chars it uses idcthint to indicate which way to bias. We don't have a idcthint
2763 : : //feature in writer.
2764 : : //
2765 : : //So what we currently do here then is to split our text into non-weak/weak
2766 : : //sections and uses word's idcthint to determine what font it would use and
2767 : : //force that on for the segment. Following what we *do* know about word's
2768 : : //categorization, we know that the range 0x0020 and 0x007F is sprmCRgFtc0 in
2769 : : //word, something we map to LATIN, so we consider all weaks chars in that range
2770 : : //to auto-bias to LATIN.
2771 : : //
2772 : : //See https://bugs.freedesktop.org/show_bug.cgi?id=34319 for an example
2773 : 5394 : void SwWW8ImplReader::emulateMSWordAddTextToParagraph(const rtl::OUString& rAddString)
2774 : : {
2775 [ + - ]: 5394 : if (rAddString.isEmpty())
2776 : : return;
2777 : :
2778 [ + - ]: 5394 : uno::Reference<i18n::XBreakIterator> xBI(pBreakIt->GetBreakIter());
2779 [ - + ]: 5394 : if (!xBI.is())
2780 : : {
2781 [ # # ][ # # ]: 0 : simpleAddTextToParagraph(rAddString);
[ # # ]
2782 : : return;
2783 : : }
2784 : :
2785 [ + - ]: 5394 : sal_Int16 nScript = lcl_getScriptType(xBI, rAddString, 0);
2786 : 5394 : sal_Int32 nLen = rAddString.getLength();
2787 : :
2788 : 5394 : rtl::OUString sParagraphText;
2789 : 5394 : const SwCntntNode *pCntNd = pPaM->GetCntntNode();
2790 [ + - ]: 5394 : const SwTxtNode* pNd = pCntNd ? pCntNd->GetTxtNode() : NULL;
2791 [ + - ]: 5394 : if (pNd)
2792 [ + - ]: 5394 : sParagraphText = pNd->GetTxt();
2793 : 5394 : sal_Int32 nParaOffset = sParagraphText.getLength();
2794 : 5394 : sParagraphText = sParagraphText + rAddString;
2795 : :
2796 : 5394 : sal_Int32 nPos = 0;
2797 [ + + ]: 122190 : while (nPos < nLen)
2798 : : {
2799 [ + - ]: 116796 : sal_Int32 nEnd = lcl_endOfScript(xBI, rAddString, nPos, nScript);
2800 [ + - ]: 116796 : if (nEnd < 0)
2801 : : break;
2802 : :
2803 : 116796 : rtl::OUString sChunk(rAddString.copy(nPos, nEnd-nPos));
2804 : 116796 : const sal_uInt16 aIds[] = {RES_CHRATR_FONT, RES_CHRATR_CJK_FONT, RES_CHRATR_CTL_FONT};
2805 : 116796 : const SvxFontItem *pOverriddenItems[] = {NULL, NULL, NULL};
2806 : 116796 : bool aForced[] = {false, false, false};
2807 : :
2808 : 116796 : int nLclIdctHint = 0xFF;
2809 [ + + ]: 116796 : if (nScript == i18n::ScriptType::WEAK)
2810 : 408 : nLclIdctHint = nIdctHint;
2811 [ + + ]: 116388 : else if (nScript == MSASCII) //Force weak chars in ascii range to use LATIN font
2812 : 55731 : nLclIdctHint = 0;
2813 : :
2814 : 116796 : sal_uInt16 nForceFromFontId = 0;
2815 [ + + ]: 116796 : if (nLclIdctHint != 0xFF)
2816 : : {
2817 [ + - - - ]: 56139 : switch (nLclIdctHint)
2818 : : {
2819 : : case 0:
2820 : 56139 : nForceFromFontId = RES_CHRATR_FONT;
2821 : 56139 : break;
2822 : : case 1:
2823 : 0 : nForceFromFontId = RES_CHRATR_CJK_FONT;
2824 : 0 : break;
2825 : : case 2:
2826 : 0 : nForceFromFontId = RES_CHRATR_CTL_FONT;
2827 : 0 : break;
2828 : : default:
2829 : 56139 : break;
2830 : : }
2831 : : }
2832 : :
2833 [ + + ]: 116796 : if (nForceFromFontId != 0)
2834 : : {
2835 : : //Now we know that word would use the nForceFromFontId font for this range
2836 : : //Try and determine what script writer would assign this range to
2837 : :
2838 : : sal_Int32 nWriterScript = lcl_getWriterScriptType(xBI, sParagraphText,
2839 [ + - ]: 56139 : nPos + nParaOffset);
2840 : :
2841 : 56139 : bool bWriterWillUseSameFontAsWordAutomatically = false;
2842 : :
2843 [ + + ]: 56139 : if (nWriterScript != i18n::ScriptType::WEAK)
2844 : : {
2845 [ - + ][ # # ]: 56079 : if (
[ - + ][ # # ]
[ + - ][ + - ]
2846 : : (nWriterScript == i18n::ScriptType::ASIAN && nForceFromFontId == RES_CHRATR_CJK_FONT) ||
2847 : : (nWriterScript == i18n::ScriptType::COMPLEX && nForceFromFontId == RES_CHRATR_CTL_FONT) ||
2848 : : (nWriterScript == i18n::ScriptType::LATIN && nForceFromFontId == RES_CHRATR_FONT)
2849 : : )
2850 : : {
2851 : 56079 : bWriterWillUseSameFontAsWordAutomatically = true;
2852 : : }
2853 : : else
2854 : : {
2855 [ # # ]: 0 : const SvxFontItem *pSourceFont = (const SvxFontItem*)GetFmtAttr(nForceFromFontId);
2856 : 0 : sal_uInt16 nDestId = aIds[nWriterScript-1];
2857 [ # # ]: 0 : const SvxFontItem *pDestFont = (const SvxFontItem*)GetFmtAttr(nDestId);
2858 [ # # ]: 56079 : bWriterWillUseSameFontAsWordAutomatically = sameFontIgnoringIrrelevantFields(*pSourceFont, *pDestFont);
2859 : : }
2860 : : }
2861 : :
2862 : : //Writer won't use the same font as word, so force the issue
2863 [ + + ]: 56139 : if (!bWriterWillUseSameFontAsWordAutomatically)
2864 : : {
2865 [ + - ]: 60 : const SvxFontItem *pSourceFont = (const SvxFontItem*)GetFmtAttr(nForceFromFontId);
2866 : :
2867 [ + + ]: 240 : for (size_t i = 0; i < SAL_N_ELEMENTS(aIds); ++i)
2868 : : {
2869 [ + - ]: 180 : const SvxFontItem *pDestFont = (const SvxFontItem*)GetFmtAttr(aIds[i]);
2870 [ + + ][ + - ]: 180 : aForced[i] = aIds[i] != nForceFromFontId && *pSourceFont != *pDestFont;
[ + + ]
2871 [ + + ]: 180 : if (aForced[i])
2872 : : {
2873 : : pOverriddenItems[i] =
2874 [ + - ]: 33 : (const SvxFontItem*)pCtrlStck->GetStackAttr(*pPaM->GetPoint(), aIds[i]);
2875 : :
2876 [ + - ]: 33 : SvxFontItem aForceFont(*pSourceFont);
2877 : 33 : aForceFont.SetWhich(aIds[i]);
2878 [ + - ][ + - ]: 33 : pCtrlStck->NewAttr(*pPaM->GetPoint(), aForceFont);
2879 : : }
2880 : : }
2881 : : }
2882 : : }
2883 : :
2884 [ + - ][ + - ]: 116796 : simpleAddTextToParagraph(sChunk);
[ + - ]
2885 : :
2886 [ + + ]: 467184 : for (size_t i = 0; i < SAL_N_ELEMENTS(aIds); ++i)
2887 : : {
2888 [ + + ]: 350388 : if (aForced[i])
2889 : : {
2890 [ + - ]: 33 : pCtrlStck->SetAttr(*pPaM->GetPoint(), aIds[i]);
2891 [ - + ]: 33 : if (pOverriddenItems[i])
2892 [ # # ]: 0 : pCtrlStck->NewAttr(*pPaM->GetPoint(), *(pOverriddenItems[i]));
2893 : : }
2894 : : }
2895 : :
2896 : 116796 : nPos = nEnd;
2897 [ + + ]: 116796 : if (nPos < nLen)
2898 [ + - ]: 111402 : nScript = lcl_getScriptType(xBI, rAddString, nPos);
2899 [ + - ]: 122190 : }
2900 : : }
2901 : :
2902 : 116796 : void SwWW8ImplReader::simpleAddTextToParagraph(const String& rAddString)
2903 : : {
2904 [ - + ]: 116796 : if (!rAddString.Len())
2905 : 0 : return;
2906 : :
2907 : : #if OSL_DEBUG_LEVEL > 1
2908 : : {
2909 : : rtl::OString sText(rtl::OUStringToOString(rAddString, RTL_TEXTENCODING_UTF8));
2910 : : SAL_INFO("sw.ww8", "<addTextToParagraph>" << sText.getStr() << "</addTextToParagraph>");
2911 : : }
2912 : : #endif
2913 : :
2914 : 116796 : const SwCntntNode *pCntNd = pPaM->GetCntntNode();
2915 [ + - ]: 116796 : const SwTxtNode* pNd = pCntNd ? pCntNd->GetTxtNode() : NULL;
2916 : :
2917 : : OSL_ENSURE(pNd, "What the hell, where's my text node");
2918 : :
2919 [ - + ]: 116796 : if (!pNd)
2920 : 0 : return;
2921 : :
2922 [ + - ]: 116796 : if ((pNd->GetTxt().Len() + rAddString.Len()) < STRING_MAXLEN-1)
2923 : : {
2924 : 116796 : rDoc.InsertString(*pPaM, rAddString);
2925 : : }
2926 : : else
2927 : : {
2928 : :
2929 [ # # ]: 0 : if (pNd->GetTxt().Len()< STRING_MAXLEN -1)
2930 : : {
2931 : : String sTempStr (rAddString,0,
2932 [ # # ]: 0 : STRING_MAXLEN - pNd->GetTxt().Len() -1);
2933 [ # # ]: 0 : rDoc.InsertString(*pPaM, sTempStr);
2934 : 0 : sTempStr = rAddString.Copy(sTempStr.Len(),
2935 [ # # ][ # # ]: 0 : rAddString.Len() - sTempStr.Len());
[ # # ]
2936 [ # # ]: 0 : AppendTxtNode(*pPaM->GetPoint());
2937 [ # # ][ # # ]: 0 : rDoc.InsertString(*pPaM, sTempStr);
2938 : : }
2939 : : else
2940 : : {
2941 : 0 : AppendTxtNode(*pPaM->GetPoint());
2942 : 0 : rDoc.InsertString(*pPaM, rAddString);
2943 : : }
2944 : : }
2945 : :
2946 : 116796 : bReadTable = false;
2947 : : }
2948 : :
2949 : : // Returnwert: true for para end
2950 : 10299 : bool SwWW8ImplReader::ReadChars(WW8_CP& rPos, WW8_CP nNextAttr, long nTextEnd,
2951 : : long nCpOfs)
2952 : : {
2953 [ + + ]: 10299 : long nEnd = ( nNextAttr < nTextEnd ) ? nNextAttr : nTextEnd;
2954 : :
2955 [ + - ][ + + ]: 10299 : if (bSymbol || bIgnoreText)
2956 : : {
2957 [ - + ]: 3 : if( bSymbol ) // Spezialzeichen einfuegen
2958 : : {
2959 [ # # ]: 0 : for(sal_uInt16 nCh = 0; nCh < nEnd - rPos; ++nCh)
2960 : : {
2961 [ # # ][ # # ]: 0 : rDoc.InsertString( *pPaM, rtl::OUString(cSymbol) );
[ # # ]
2962 : : }
2963 : 0 : pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_FONT );
2964 : : }
2965 : 3 : pStrm->SeekRel( nEnd- rPos );
2966 : 3 : rPos = nEnd; // ignoriere bis Attributende
2967 : 3 : return false;
2968 : : }
2969 : :
2970 : 12648 : while (true)
2971 : : {
2972 [ + + ]: 12645 : if (ReadPlainChars(rPos, nEnd, nCpOfs))
2973 : 3891 : return false; // Fertig
2974 : :
2975 : 8754 : bool bStartLine = ReadChar(rPos, nCpOfs);
2976 : 8754 : rPos++;
2977 [ + + ][ + + ]: 8754 : if (bPgSecBreak || bStartLine || rPos == nEnd) // CR oder Fertig
[ + + ]
2978 : : {
2979 : 6405 : return bStartLine;
2980 : : }
2981 : : }
2982 : : }
2983 : :
2984 : 90 : bool SwWW8ImplReader::HandlePageBreakChar()
2985 : : {
2986 : 90 : bool bParaEndAdded = false;
2987 : : //#i1909# section/page breaks should not occur in tables, word
2988 : : //itself ignores them in this case.
2989 [ + - ]: 90 : if (!nInTable)
2990 : : {
2991 : : //xushanchuan add for issue106569
2992 : 90 : sal_Bool IsTemp=sal_True;
2993 : 90 : SwTxtNode* pTemp = pPaM->GetNode()->GetTxtNode();
2994 [ + + ][ + + ]: 90 : if ( pTemp && !( pTemp->GetTxt().Len() ) && ( bFirstPara || bFirstParaOfPage ) )
[ - + ][ + + ]
[ + - ]
2995 : : {
2996 : 3 : IsTemp = sal_False;
2997 : 3 : AppendTxtNode(*pPaM->GetPoint());
2998 : 3 : pTemp->SetAttr(*GetDfltAttr(RES_PARATR_NUMRULE));
2999 : : }
3000 : : //xushanchuan end
3001 : 90 : bPgSecBreak = true;
3002 : 90 : pCtrlStck->KillUnlockedAttrs(*pPaM->GetPoint());
3003 : : /*
3004 : : If its a 0x0c without a paragraph end before it, act like a
3005 : : paragraph end, but nevertheless, numbering (and perhaps other
3006 : : similiar constructs) do not exist on the para.
3007 : : */
3008 : : //xushanchuan add for issue106569
3009 [ + + ][ + + ]: 90 : if (!bWasParaEnd && IsTemp)
3010 : : //xushanchuan end
3011 : : {
3012 : 3 : bParaEndAdded = true;
3013 [ - + ]: 3 : if (0 >= pPaM->GetPoint()->nContent.GetIndex())
3014 : : {
3015 [ # # ]: 0 : if (SwTxtNode* pTxtNode = pPaM->GetNode()->GetTxtNode())
3016 : : {
3017 : : pTxtNode->SetAttr(
3018 : 0 : *GetDfltAttr(RES_PARATR_NUMRULE));
3019 : : }
3020 : : }
3021 : : }
3022 : : }
3023 : 90 : return bParaEndAdded;
3024 : : }
3025 : :
3026 : 8754 : bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs)
3027 : : {
3028 : 8754 : bool bNewParaEnd = false;
3029 : : // Unicode-Flag neu setzen und notfalls File-Pos korrigieren
3030 : : // merke: Seek kostet nicht viel, da inline geprueft wird,
3031 : : // ob die korrekte FilePos nicht schon erreicht ist.
3032 [ + - ]: 8754 : sal_Size nRequestedPos = pSBase->WW8Cp2Fc(nCpOfs+nPosCp, &bIsUnicode);
3033 [ + - ][ - + ]: 8754 : if (!checkSeek(*pStrm, nRequestedPos))
3034 : 0 : return false;
3035 : :
3036 : 8754 : sal_uInt8 nBCode(0);
3037 : 8754 : sal_uInt16 nWCharVal(0);
3038 [ + + ]: 8754 : if( bIsUnicode )
3039 [ + - ]: 147 : *pStrm >> nWCharVal; // unicode --> read 2 bytes
3040 : : else
3041 : : {
3042 [ + - ]: 8607 : *pStrm >> nBCode; // old code --> read 1 byte
3043 : 8607 : nWCharVal = nBCode;
3044 : : }
3045 : :
3046 : 8754 : sal_Unicode cInsert = '\x0';
3047 : 8754 : bool bRet = false;
3048 : : //xushanchuan add for issue106569
3049 [ + + ]: 8754 : if ( 0xc != nWCharVal )
3050 : 8664 : bFirstParaOfPage = false;
3051 : : //xushanchuan end
3052 [ + - + - : 8754 : switch (nWCharVal)
+ + + + +
- - - + +
+ + + - ]
3053 : : {
3054 : : case 0:
3055 : : {
3056 : : // Seitennummer
3057 : : SwPageNumberField aFld(
3058 : : (SwPageNumberFieldType*)rDoc.GetSysFldType(
3059 [ + - ][ + - ]: 1410 : RES_PAGENUMBERFLD ), PG_RANDOM, SVX_NUM_ARABIC);
3060 [ + - ][ + - ]: 1410 : rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
[ + - ][ + - ]
3061 : : }
3062 : 1410 : break;
3063 : : case 0xe:
3064 : : // if there is only one column word treats a column break like a pagebreak.
3065 [ # # ][ # # ]: 0 : if (maSectionManager.CurrentSectionColCount() < 2)
3066 [ # # ]: 0 : bRet = HandlePageBreakChar();
3067 [ # # ]: 0 : else if (!nInTable)
3068 : : {
3069 : : // Always insert a txtnode for a column break, e.g. ##
3070 : 0 : SwCntntNode *pCntNd=pPaM->GetCntntNode();
3071 [ # # ][ # # ]: 0 : if (pCntNd!=NULL && pCntNd->Len()>0) // if par is empty not break is needed
[ # # ][ # # ]
3072 [ # # ]: 0 : AppendTxtNode(*pPaM->GetPoint());
3073 [ # # ][ # # ]: 0 : rDoc.InsertPoolItem(*pPaM, SvxFmtBreakItem(SVX_BREAK_COLUMN_BEFORE, RES_BREAK), 0);
[ # # ]
3074 : : }
3075 : 0 : break;
3076 : : case 0x7:
3077 : 303 : bNewParaEnd = true;
3078 [ + - ]: 303 : TabCellEnd(); // table cell end (Flags abfragen!)
3079 : 303 : break;
3080 : : case 0xf:
3081 [ # # ]: 0 : if( !bSpec ) // "Satellit"
3082 : 0 : cInsert = '\xa4';
3083 : 0 : break;
3084 : : case 0x14:
3085 [ - + ]: 12 : if( !bSpec ) // "Para-Ende"-Zeichen
3086 : 0 : cInsert = '\xb5';
3087 : 12 : break;
3088 : : case 0x15:
3089 [ - + ]: 12 : if( !bSpec ) // Juristenparagraph
3090 : 0 : cInsert = '\xa7';
3091 : 12 : break;
3092 : : case 0x9:
3093 : 909 : cInsert = '\x9'; // Tab
3094 : 909 : break;
3095 : : case 0xb:
3096 : 42 : cInsert = '\xa'; // Hard NewLine
3097 : 42 : break;
3098 : : case 0xc:
3099 [ + - ]: 90 : bRet = HandlePageBreakChar();
3100 : 90 : break;
3101 : : case 0x1e: // Non-breaking hyphen
3102 [ # # ][ # # ]: 0 : rDoc.InsertString( *pPaM, rtl::OUString(CHAR_HARDHYPHEN) );
[ # # ]
3103 : 0 : break;
3104 : : case 0x1f: // Non-required hyphens
3105 [ # # ][ # # ]: 0 : rDoc.InsertString( *pPaM, rtl::OUString(CHAR_SOFTHYPHEN) );
[ # # ]
3106 : 0 : break;
3107 : : case 0xa0: // Non-breaking spaces
3108 [ # # ][ # # ]: 0 : rDoc.InsertString( *pPaM, rtl::OUString(CHAR_HARDBLANK) );
[ # # ]
3109 : 0 : break;
3110 : : case 0x1:
3111 : : /*
3112 : : Current thinking is that if bObj is set then we have a
3113 : : straightforward "traditional" ole object, otherwise we have a
3114 : : graphic preview of an associated ole2 object (or a simple
3115 : : graphic of course)
3116 : : */
3117 [ + - ][ + + ]: 21 : if (!IsInlineEscherHack())
3118 : : {
3119 : 18 : SwFrmFmt *pResult = 0;
3120 [ - + ]: 18 : if (bObj)
3121 [ # # ][ # # ]: 0 : pResult = ImportOle();
3122 [ + - ]: 18 : else if (bSpec)
3123 [ + - ]: 18 : pResult = ImportGraf();
3124 : :
3125 : : // If we have a bad 0x1 insert a space instead.
3126 [ - + ]: 18 : if (!pResult)
3127 : : {
3128 : 0 : cInsert = ' ';
3129 : : OSL_ENSURE(!bObj && !bEmbeddObj && !nObjLocFc,
3130 : : "WW8: Please report this document, it may have a "
3131 : : "missing graphic");
3132 : : }
3133 : : else
3134 : : {
3135 : : // reset the flags.
3136 : 18 : bObj = bEmbeddObj = false;
3137 : 18 : nObjLocFc = 0;
3138 : : }
3139 : : }
3140 : 21 : break;
3141 : : case 0x8:
3142 [ + - ]: 144 : if( !bObj )
3143 [ + - ]: 144 : Read_GrafLayer( nPosCp );
3144 : 144 : break;
3145 : : case 0xd:
3146 : 5802 : bNewParaEnd = bRet = true;
3147 [ + + ]: 5802 : if (nInTable > 1)
3148 : : {
3149 : : /*
3150 : : #i9666#/#i23161#
3151 : : Yes complex, if there is an entry in the undocumented PLCF
3152 : : which I believe to be a record of cell and row boundaries
3153 : : see if the magic bit which I believe to mean cell end is
3154 : : set. I also think btw that the third byte of the 4 byte
3155 : : value is the level of the cell
3156 : : */
3157 : 324 : WW8PLCFspecial* pTest = pPlcxMan->GetMagicTables();
3158 [ + - ]: 648 : if (pTest && pTest->SeekPosExact(nPosCp+1+nCpOfs) &&
[ + - + - ]
[ + - ][ + - ]
3159 : 324 : pTest->Where() == nPosCp+1+nCpOfs)
3160 : : {
3161 : : WW8_FC nPos;
3162 : : void *pData;
3163 [ + - ]: 324 : pTest->Get(nPos, pData);
3164 : 324 : sal_uInt32 nData = SVBT32ToUInt32(*(SVBT32*)pData);
3165 [ + - ]: 324 : if (nData & 0x2) //Might be how it works
3166 : : {
3167 [ + - ]: 324 : TabCellEnd();
3168 : 324 : bRet = false;
3169 : : }
3170 : : }
3171 [ # # ]: 0 : else if (bWasTabCellEnd)
3172 : : {
3173 [ # # ]: 0 : TabCellEnd();
3174 : 0 : bRet = false;
3175 : : }
3176 : : }
3177 : :
3178 : 5802 : bWasTabCellEnd = false;
3179 : :
3180 : 5802 : break; // line end
3181 : : case 0x5: // Annotation reference
3182 : : case 0x13:
3183 : 3 : break;
3184 : : case 0x2: // Auto-Footnote-Number, should be replaced by SwWW8ImplReader::End_Ftn later
3185 [ + - ]: 6 : if (!maFtnStack.empty())
3186 : 6 : cInsert = 0x2;
3187 : 6 : break;
3188 : : #if OSL_DEBUG_LEVEL > 1
3189 : : default:
3190 : : ::std::clog << "<unknownValue val=\"" << nWCharVal << "\">" << ::std::endl;
3191 : : break;
3192 : : #endif
3193 : : }
3194 : :
3195 [ + + ]: 8754 : if( '\x0' != cInsert )
3196 : : {
3197 : 957 : rtl::OUString sInsert(cInsert);
3198 [ + - ]: 957 : emulateMSWordAddTextToParagraph(sInsert);
3199 : : }
3200 [ + - ][ + + ]: 8754 : if (!maApos.back()) //a para end in apo doesn't count
3201 : 8745 : bWasParaEnd = bNewParaEnd;
3202 : 8754 : return bRet;
3203 : : }
3204 : :
3205 : 10959 : void SwWW8ImplReader::ProcessAktCollChange(WW8PLCFManResult& rRes,
3206 : : bool* pStartAttr, bool bCallProcessSpecial)
3207 : : {
3208 : 10959 : sal_uInt16 nOldColl = nAktColl;
3209 : 10959 : nAktColl = pPlcxMan->GetColl();
3210 : :
3211 : : // Invalid Style-Id
3212 [ + - ][ - + ]: 10959 : if (nAktColl >= vColl.size() || !vColl[nAktColl].pFmt || !vColl[nAktColl].bColl)
[ - + ][ + - ]
3213 : : {
3214 : 0 : nAktColl = 0;
3215 : 0 : bParaAutoBefore = false;
3216 : 0 : bParaAutoAfter = false;
3217 : : }
3218 : : else
3219 : : {
3220 : 10959 : bParaAutoBefore = vColl[nAktColl].bParaAutoBefore;
3221 : 10959 : bParaAutoAfter = vColl[nAktColl].bParaAutoAfter;
3222 : : }
3223 : :
3224 [ - + ]: 10959 : if (nOldColl >= vColl.size())
3225 : 0 : nOldColl = 0; //guess! TODO make sure this is what we want
3226 : :
3227 : 10959 : bool bTabRowEnd = false;
3228 [ + - ][ + + ]: 10959 : if( pStartAttr && bCallProcessSpecial && !bInHyperlink )
[ + - ]
3229 : : {
3230 : : bool bReSync;
3231 : : // Frame / Table / Autonumbering List Level
3232 [ + - ]: 6153 : bTabRowEnd = ProcessSpecial(bReSync, rRes.nAktCp+pPlcxMan->GetCpOfs());
3233 [ + + ]: 6153 : if( bReSync )
3234 [ + - ]: 6153 : *pStartAttr = pPlcxMan->Get( &rRes ); // hole Attribut-Pos neu
3235 : : }
3236 : :
3237 [ + + ][ + - ]: 10959 : if (!bTabRowEnd && StyleExists(nAktColl))
[ + + ]
3238 : : {
3239 : 10890 : SetTxtFmtCollAndListLevel( *pPaM, vColl[ nAktColl ]);
3240 : 10890 : ChkToggleAttr(vColl[ nOldColl ].n81Flags, vColl[ nAktColl ].n81Flags);
3241 : 10890 : ChkToggleBiDiAttr(vColl[nOldColl].n81BiDiFlags,
3242 : 21780 : vColl[nAktColl].n81BiDiFlags);
3243 : : }
3244 : 10959 : }
3245 : :
3246 : 57876 : long SwWW8ImplReader::ReadTextAttr(WW8_CP& rTxtPos, bool& rbStartLine)
3247 : : {
3248 : 57876 : long nSkipChars = 0;
3249 : : WW8PLCFManResult aRes;
3250 : :
3251 : : OSL_ENSURE(pPaM->GetNode()->GetTxtNode(), "Missing txtnode");
3252 [ + - ]: 57876 : bool bStartAttr = pPlcxMan->Get(&aRes); // hole Attribut-Pos
3253 : 57876 : aRes.nAktCp = rTxtPos; // Akt. Cp-Pos
3254 : :
3255 [ + + ][ + - ]: 57876 : bool bNewSection = (aRes.nFlags & MAN_MASK_NEW_SEP) && !bIgnoreText;
3256 [ + + ]: 57876 : if ( bNewSection ) // neue Section
3257 : : {
3258 : : OSL_ENSURE(pPaM->GetNode()->GetTxtNode(), "Missing txtnode");
3259 : : // PageDesc erzeugen und fuellen
3260 [ + - ]: 111 : maSectionManager.CreateSep(rTxtPos, bPgSecBreak);
3261 : : // -> 0xc war ein Sectionbreak, aber
3262 : : // kein Pagebreak;
3263 : 111 : bPgSecBreak = false; // PageDesc erzeugen und fuellen
3264 : : OSL_ENSURE(pPaM->GetNode()->GetTxtNode(), "Missing txtnode");
3265 : : }
3266 : :
3267 : : // neuer Absatz ueber Plcx.Fkp.papx
3268 [ + + ][ + + ]: 57876 : if ( (aRes.nFlags & MAN_MASK_NEW_PAP)|| rbStartLine )
3269 : : {
3270 : : ProcessAktCollChange( aRes, &bStartAttr,
3271 : : MAN_MASK_NEW_PAP == (aRes.nFlags & MAN_MASK_NEW_PAP) &&
3272 [ + + ][ + - ]: 10959 : !bIgnoreText );
[ + - ]
3273 : 10959 : rbStartLine = false;
3274 : : }
3275 : :
3276 : : // position of last CP that's to be ignored
3277 : 57876 : long nSkipPos = -1;
3278 : :
3279 [ + + ]: 57876 : if( 0 < aRes.nSprmId ) // leere Attrs ignorieren
3280 : : {
3281 [ + - ][ + + ]: 35082 : if( ( eFTN > aRes.nSprmId ) || ( 0x0800 <= aRes.nSprmId ) )
3282 : : {
3283 [ + + ]: 69960 : if( bStartAttr ) // WW-Attribute
3284 : : {
3285 [ + - ]: 17790 : if( aRes.nMemLen >= 0 )
3286 [ + - ]: 17790 : ImportSprm(aRes.pMemPos, aRes.nSprmId);
3287 : : }
3288 : : else
3289 [ + - ]: 17190 : EndSprm( aRes.nSprmId ); // Attr ausschalten
3290 : : }
3291 [ + - ]: 102 : else if( aRes.nSprmId < 0x800 ) // eigene Hilfs-Attribute
3292 : : {
3293 [ + + ]: 102 : if (bStartAttr)
3294 : : {
3295 [ + - ]: 57 : nSkipChars = ImportExtSprm(&aRes);
3296 [ + + ][ + - ]: 57 : if (
[ + + ][ - + ]
3297 : : (aRes.nSprmId == eFTN) || (aRes.nSprmId == eEDN) ||
3298 : : (aRes.nSprmId == eFLD) || (aRes.nSprmId == eAND)
3299 : : )
3300 : : {
3301 : : // Felder/Ftn-/End-Note hier ueberlesen
3302 : 45 : rTxtPos += nSkipChars;
3303 : 45 : nSkipPos = rTxtPos-1;
3304 : : }
3305 : : }
3306 : : else
3307 [ + - ]: 35082 : EndExtSprm( aRes.nSprmId );
3308 : : }
3309 : : }
3310 : :
3311 [ + - ][ + - ]: 57876 : pStrm->Seek(pSBase->WW8Cp2Fc( pPlcxMan->GetCpOfs() + rTxtPos, &bIsUnicode));
3312 : :
3313 : : // Find next Attr position (and Skip attributes of field contents if needed)
3314 [ + + ][ + - ]: 57876 : if (nSkipChars && !bIgnoreText)
3315 [ + - ]: 21 : pCtrlStck->MarkAllAttrsOld();
3316 : 57876 : bool bOldIgnoreText = bIgnoreText;
3317 : 57876 : bIgnoreText = true;
3318 : 57876 : sal_uInt16 nOldColl = nAktColl;
3319 : 57876 : bool bDoPlcxManPlusPLus = true;
3320 : : long nNext;
3321 [ + + ]: 58212 : do
3322 : : {
3323 [ + + ]: 58212 : if( bDoPlcxManPlusPLus )
3324 [ + - ]: 57876 : pPlcxMan->advance();
3325 [ + - ]: 58212 : nNext = pPlcxMan->Where();
3326 : :
3327 [ - + ][ # # ]: 58212 : if (mpPostProcessAttrsInfo &&
3328 : : mpPostProcessAttrsInfo->mnCpStart == nNext)
3329 : : {
3330 : 0 : mpPostProcessAttrsInfo->mbCopy = true;
3331 : : }
3332 : :
3333 [ + - ][ + + ]: 58212 : if( (0 <= nNext) && (nSkipPos >= nNext) )
3334 : : {
3335 [ + - ]: 363 : nNext = ReadTextAttr( rTxtPos, rbStartLine );
3336 : 363 : bDoPlcxManPlusPLus = false;
3337 : 363 : bIgnoreText = true;
3338 : : }
3339 : :
3340 [ - + ][ # # ]: 58212 : if (mpPostProcessAttrsInfo &&
3341 : : nNext > mpPostProcessAttrsInfo->mnCpEnd)
3342 : : {
3343 : 0 : mpPostProcessAttrsInfo->mbCopy = false;
3344 : : }
3345 : : }
3346 : : while( nSkipPos >= nNext );
3347 : 57876 : bIgnoreText = bOldIgnoreText;
3348 [ + + ]: 57876 : if( nSkipChars )
3349 : : {
3350 [ + - ]: 21 : pCtrlStck->KillUnlockedAttrs( *pPaM->GetPoint() );
3351 [ + - ][ - + ]: 21 : if( nOldColl != pPlcxMan->GetColl() )
3352 [ # # ]: 0 : ProcessAktCollChange(aRes, 0, false);
3353 : : }
3354 : :
3355 : 57876 : return nNext;
3356 : : }
3357 : :
3358 : 10299 : void SwWW8ImplReader::ReadAttrs(WW8_CP& rNext, WW8_CP& rTxtPos, bool& rbStartLine)
3359 : : {
3360 [ + + ]: 10299 : if( rTxtPos >= rNext )
3361 : : { // Stehen Attribute an ?
3362 : :
3363 [ + + ]: 57513 : do
3364 : : {
3365 : 57513 : rNext = ReadTextAttr( rTxtPos, rbStartLine );
3366 : : }
3367 : : while( rTxtPos >= rNext );
3368 : :
3369 : : }
3370 [ + + ]: 99 : else if ( rbStartLine )
3371 : : {
3372 : : // keine Attribute, aber trotzdem neue Zeile
3373 : : // wenn eine Zeile mit einem Seitenumbruch aufhoert und sich keine
3374 : : // Absatzattribute / Absatzvorlagen aendern, ist das Zeilenende
3375 : : // nicht im Plcx.Fkp.papx eingetragen, d.h. ( nFlags & MAN_MASK_NEW_PAP )
3376 : : // ist false. Deshalb muss als Sonderbehandlung hier die Vorlage gesetzt
3377 : : // werden.
3378 [ + - ][ + - ]: 72 : if (!bCpxStyle && nAktColl < vColl.size())
[ + - ]
3379 : 72 : SetTxtFmtCollAndListLevel(*pPaM, vColl[nAktColl]);
3380 : 72 : rbStartLine = false;
3381 : : }
3382 : 10299 : }
3383 : :
3384 : : // CloseAttrEnds zum Lesen nur der Attributenden am Ende eines Textes oder
3385 : : // Textbereiches ( Kopfzeile, Fussnote, ...). Attributanfaenge, Felder
3386 : : // werden ignoriert.
3387 : 144 : void SwWW8ImplReader::CloseAttrEnds()
3388 : : {
3389 : : //If there are any unclosed sprms then copy them to
3390 : : //another stack and close the ones that must be closed
3391 [ + - ][ + - ]: 144 : std::stack<sal_uInt16> aStack;
3392 [ + - ]: 144 : pPlcxMan->TransferOpenSprms(aStack);
3393 : :
3394 [ + - ][ + + ]: 918 : while (!aStack.empty())
3395 : : {
3396 [ + - ]: 774 : sal_uInt16 nSprmId = aStack.top();
3397 [ + + ][ + - ]: 774 : if ((0 < nSprmId) && (( eFTN > nSprmId) || (0x0800 <= nSprmId)))
[ + - ]
3398 [ + - ]: 600 : EndSprm(nSprmId);
3399 [ + - ]: 774 : aStack.pop();
3400 : : }
3401 : :
3402 [ + - ]: 144 : EndSpecial();
3403 : 144 : }
3404 : :
3405 : 144 : bool SwWW8ImplReader::ReadText(long nStartCp, long nTextLen, ManTypes nType)
3406 : : {
3407 : 144 : bool bJoined=false;
3408 : :
3409 : 144 : bool bStartLine = true;
3410 : 144 : short nCrCount = 0;
3411 : 144 : short nDistance = 0;
3412 : :
3413 : 144 : bWasParaEnd = false;
3414 : 144 : nAktColl = 0;
3415 : 144 : pAktItemSet = 0;
3416 : 144 : nCharFmt = -1;
3417 : 144 : bSpec = false;
3418 : 144 : bPgSecBreak = false;
3419 : :
3420 [ + - ][ + - ]: 144 : pPlcxMan = new WW8PLCFMan( pSBase, nType, nStartCp );
3421 : 144 : long nCpOfs = pPlcxMan->GetCpOfs(); // Offset fuer Header/Footer, Footnote
3422 : :
3423 [ + - ]: 144 : WW8_CP nNext = pPlcxMan->Where();
3424 : 144 : SwTxtNode* pPreviousNode = 0;
3425 : 144 : sal_uInt8 nDropLines = 0;
3426 : 144 : SwCharFmt* pNewSwCharFmt = 0;
3427 : 144 : const SwCharFmt* pFmt = 0;
3428 [ + - ][ + - ]: 144 : pStrm->Seek( pSBase->WW8Cp2Fc( nStartCp + nCpOfs, &bIsUnicode ) );
3429 : :
3430 : 144 : WW8_CP l = nStartCp;
3431 [ + + ]: 10443 : while ( l<nStartCp+nTextLen )
3432 : : {
3433 [ + - ]: 10299 : ReadAttrs( nNext, l, bStartLine );// behandelt auch Section-Breaks
3434 : : OSL_ENSURE(pPaM->GetNode()->GetTxtNode(), "Missing txtnode");
3435 : :
3436 [ - + ]: 10299 : if (mpPostProcessAttrsInfo != NULL)
3437 [ # # ]: 0 : PostProcessAttrs();
3438 : :
3439 [ - + ]: 10299 : if( l>= nStartCp + nTextLen )
3440 : 0 : break;
3441 : :
3442 [ + - ]: 10299 : bStartLine = ReadChars(l, nNext, nStartCp+nTextLen, nCpOfs);
3443 : :
3444 : : // If the previous paragraph was a dropcap then do not
3445 : : // create a new txtnode and join the two paragraphs together
3446 : :
3447 [ + + ][ + - ]: 10299 : if (bStartLine && !pPreviousNode) // Zeilenende
3448 [ + - ]: 5481 : AppendTxtNode(*pPaM->GetPoint());
3449 : :
3450 [ - + ][ # # ]: 10299 : if (pPreviousNode && bStartLine)
3451 : : {
3452 : 0 : SwTxtNode* pEndNd = pPaM->GetNode()->GetTxtNode();
3453 : 0 : const xub_StrLen nDropCapLen = pPreviousNode->GetTxt().Len();
3454 : :
3455 : : // Need to reset the font size and text position for the dropcap
3456 : : {
3457 [ # # ]: 0 : SwPaM aTmp(*pEndNd, 0, *pEndNd, nDropCapLen+1);
3458 [ # # ][ # # ]: 0 : pCtrlStck->Delete(aTmp);
3459 : : }
3460 : :
3461 : : // Get the default document dropcap which we can use as our template
3462 : : const SwFmtDrop* defaultDrop =
3463 [ # # ]: 0 : (const SwFmtDrop*) GetFmtAttr(RES_PARATR_DROP);
3464 [ # # ]: 0 : SwFmtDrop aDrop(*defaultDrop);
3465 : :
3466 : 0 : aDrop.GetLines() = nDropLines;
3467 : 0 : aDrop.GetDistance() = nDistance;
3468 [ # # ]: 0 : aDrop.GetChars() = writer_cast<sal_uInt8>(nDropCapLen);
3469 : : // Word has no concept of a "whole word dropcap"
3470 : 0 : aDrop.GetWholeWord() = false;
3471 : :
3472 [ # # ]: 0 : if (pFmt)
3473 [ # # ]: 0 : aDrop.SetCharFmt(const_cast<SwCharFmt*>(pFmt));
3474 [ # # ]: 0 : else if(pNewSwCharFmt)
3475 [ # # ]: 0 : aDrop.SetCharFmt(const_cast<SwCharFmt*>(pNewSwCharFmt));
3476 : :
3477 [ # # ]: 0 : SwPosition aStart(*pEndNd);
3478 [ # # ]: 0 : pCtrlStck->NewAttr(aStart, aDrop);
3479 [ # # ]: 0 : pCtrlStck->SetAttr(*pPaM->GetPoint(), RES_PARATR_DROP);
3480 [ # # ][ # # ]: 0 : pPreviousNode = 0;
3481 : : }
3482 [ - + ]: 10299 : else if (bDropCap)
3483 : : {
3484 : : // If we have found a dropcap store the textnode
3485 : 0 : pPreviousNode = pPaM->GetNode()->GetTxtNode();
3486 : :
3487 : : const sal_uInt8 *pDCS;
3488 : :
3489 [ # # ]: 0 : if (bVer67)
3490 [ # # ]: 0 : pDCS = pPlcxMan->GetPapPLCF()->HasSprm(46);
3491 : : else
3492 [ # # ]: 0 : pDCS = pPlcxMan->GetPapPLCF()->HasSprm(0x442C);
3493 : :
3494 [ # # ]: 0 : if (pDCS)
3495 : 0 : nDropLines = (*pDCS) >> 3;
3496 : : else // There is no Drop Cap Specifier hence no dropcap
3497 : 0 : pPreviousNode = 0;
3498 : :
3499 [ # # ][ # # ]: 0 : if (const sal_uInt8 *pDistance = pPlcxMan->GetPapPLCF()->HasSprm(0x842F))
3500 : 0 : nDistance = SVBT16ToShort( pDistance );
3501 : : else
3502 : 0 : nDistance = 0;
3503 : :
3504 : 0 : const SwFmtCharFmt *pSwFmtCharFmt = 0;
3505 : :
3506 [ # # ]: 0 : if(pAktItemSet)
3507 [ # # ]: 0 : pSwFmtCharFmt = &(ItemGet<SwFmtCharFmt>(*pAktItemSet, RES_TXTATR_CHARFMT));
3508 : :
3509 [ # # ]: 0 : if(pSwFmtCharFmt)
3510 : 0 : pFmt = pSwFmtCharFmt->GetCharFmt();
3511 : :
3512 [ # # ][ # # ]: 0 : if(pAktItemSet && !pFmt)
3513 : : {
3514 [ # # ][ # # ]: 0 : rtl::OUString sPrefix(rtl::OUStringBuffer("WW8Dropcap").append(nDropCap++).makeStringAndClear());
3515 [ # # ][ # # ]: 0 : pNewSwCharFmt = rDoc.MakeCharFmt(sPrefix, (SwCharFmt*)rDoc.GetDfltCharFmt());
[ # # ]
3516 [ # # ]: 0 : pAktItemSet->ClearItem(RES_CHRATR_ESCAPEMENT);
3517 [ # # ]: 0 : pNewSwCharFmt->SetFmtAttr( *pAktItemSet );
3518 : : }
3519 : :
3520 [ # # ][ # # ]: 0 : delete pAktItemSet;
3521 : 0 : pAktItemSet = 0;
3522 : 0 : bDropCap=false;
3523 : : }
3524 : :
3525 [ + + ][ + + ]: 10299 : if (bStartLine || bWasTabRowEnd)
3526 : : {
3527 : : // alle 64 CRs aufrufen not for Header u. ae.
3528 [ + + ][ + + ]: 5604 : if ((nCrCount++ & 0x40) == 0 && nType == MAN_MAINTEXT)
[ + + ]
3529 : : {
3530 : 3375 : nProgress = (sal_uInt16)( l * 100 / nTextLen );
3531 [ + - ]: 3375 : ::SetProgressState(nProgress, mpDocShell); // Update
3532 : : }
3533 : : }
3534 : :
3535 : : // If we have encountered a 0x0c which indicates either section of
3536 : : // pagebreak then look it up to see if it is a section break, and
3537 : : // if it is not then insert a page break. If it is a section break
3538 : : // it will be handled as such in the ReadAttrs of the next loop
3539 [ + + ]: 10299 : if (bPgSecBreak)
3540 : : {
3541 : : // We need only to see if a section is ending at this cp,
3542 : : // the plcf will already be sitting on the correct location
3543 : : // if it is there.
3544 : 90 : WW8PLCFxDesc aTemp;
3545 : 90 : aTemp.nStartPos = aTemp.nEndPos = WW8_CP_MAX;
3546 [ + - ]: 90 : if (pPlcxMan->GetSepPLCF())
3547 [ + - ]: 90 : pPlcxMan->GetSepPLCF()->GetSprms(&aTemp);
3548 [ + + ][ + - ]: 90 : if ((aTemp.nStartPos != l) && (aTemp.nEndPos != l))
3549 : : {
3550 : : // #i39251# - insert text node for page break, if no one inserted.
3551 : : // #i43118# - refine condition: the anchor
3552 : : // control stack has to have entries, otherwise it's not needed
3553 : : // to insert a text node.
3554 [ + - ][ + - ]: 81 : if (!bStartLine && !pAnchorStck->empty())
[ - + ][ - + ]
3555 : : {
3556 [ # # ]: 0 : AppendTxtNode(*pPaM->GetPoint());
3557 : : }
3558 : : rDoc.InsertPoolItem(*pPaM,
3559 [ + - ][ + - ]: 81 : SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK), 0);
[ + - ]
3560 : 81 : bFirstParaOfPage = true;//xushanchuan add for issue106569
3561 : 90 : bPgSecBreak = false;
3562 : : }
3563 : : }
3564 : : }
3565 : :
3566 [ + + ]: 144 : if (pPaM->GetPoint()->nContent.GetIndex())
3567 [ + - ]: 3 : AppendTxtNode(*pPaM->GetPoint());
3568 : :
3569 [ + - ]: 144 : if (!bInHyperlink)
3570 [ + - ]: 144 : bJoined = JoinNode(*pPaM);
3571 : :
3572 [ + - ]: 144 : CloseAttrEnds();
3573 : :
3574 [ + - ][ + - ]: 144 : delete pPlcxMan, pPlcxMan = 0;
3575 : 144 : return bJoined;
3576 : : }
3577 : :
3578 : : /***************************************************************************
3579 : : # class SwWW8ImplReader
3580 : : #**************************************************************************/
3581 : :
3582 : 108 : SwWW8ImplReader::SwWW8ImplReader(sal_uInt8 nVersionPara, SvStorage* pStorage,
3583 : : SvStream* pSt, SwDoc& rD, const String& rBaseURL, bool bNewDoc) :
3584 : 108 : mpDocShell(rD.GetDocShell()),
3585 : : pStg(pStorage),
3586 : : pStrm(pSt),
3587 : : pTableStream(0),
3588 : : pDataStream(0),
3589 : : rDoc(rD),
3590 : : maSectionManager(*this),
3591 : : m_aExtraneousParas(rD),
3592 : : maInsertedTables(rD),
3593 : : maSectionNameGenerator(rD, rtl::OUString("WW")),
3594 : : maGrfNameGenerator(bNewDoc, rtl::OUString('G')),
3595 : : maParaStyleMapper(rD),
3596 : : maCharStyleMapper(rD),
3597 : : maTxtNodesHavingFirstLineOfstSet(), // #i103711#
3598 : : maTxtNodesHavingLeftIndentSet(), // #i105414#
3599 : : pMSDffManager(0),
3600 : : mpAtnNames(0),
3601 : : sBaseURL(rBaseURL),
3602 : : m_bRegardHindiDigits( false ),
3603 : : mbNewDoc(bNewDoc),
3604 : : nDropCap(0),
3605 : : nIdctHint(0),
3606 : : bBidi(false),
3607 [ + - ][ + - ]: 108 : bReadTable(false)
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
3608 : : {
3609 [ + - ]: 108 : pStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
3610 : 108 : nWantedVersion = nVersionPara;
3611 : 108 : pCtrlStck = 0;
3612 : 108 : mpRedlineStack = 0;
3613 : 108 : pReffedStck = 0;
3614 : 108 : pReffingStck = 0;
3615 : 108 : pAnchorStck = 0;
3616 : 108 : pFonts = 0;
3617 : 108 : pSBase = 0;
3618 : 108 : pPlcxMan = 0;
3619 : 108 : pStyles = 0;
3620 : 108 : pAktColl = 0;
3621 : 108 : pLstManager = 0;
3622 : 108 : pAktItemSet = 0;
3623 : 108 : pDfltTxtFmtColl = 0;
3624 : 108 : pStandardFmtColl = 0;
3625 : 108 : pHdFt = 0;
3626 : 108 : pWFlyPara = 0;
3627 : 108 : pSFlyPara = 0;
3628 : 108 : pFlyFmtOfJustInsertedGraphic = 0;
3629 : 108 : pFmtOfJustInsertedApo = 0;
3630 : 108 : pPreviousNumPaM = 0;
3631 : 108 : pPrevNumRule = 0;
3632 : 108 : nAktColl = 0;
3633 : 108 : nObjLocFc = nPicLocFc = 0;
3634 : 108 : nInTable=0;
3635 : : bReadNoTbl = bPgSecBreak = bSpec = bObj = bTxbxFlySection
3636 : : = bHasBorder = bSymbol = bIgnoreText
3637 : 108 : = bWasTabRowEnd = bWasTabCellEnd = false;
3638 : : bShdTxtCol = bCharShdTxtCol = bAnl = bHdFtFtnEdn = bFtnEdn
3639 : : = bIsHeader = bIsFooter = bIsUnicode = bCpxStyle = bStyNormal =
3640 : 108 : bWWBugNormal = false;
3641 : :
3642 : 108 : mpPostProcessAttrsInfo = 0;
3643 : :
3644 : 108 : bNoAttrImport = bEmbeddObj = false;
3645 : 108 : bAktAND_fNumberAcross = false;
3646 : 108 : bNoLnNumYet = true;
3647 : 108 : bInHyperlink = false;
3648 : 108 : bWasParaEnd = false;
3649 : 108 : bDropCap = false;
3650 : 108 : bFirstPara = true;
3651 : 108 : bFirstParaOfPage = false;//xushanchuan add for issue106569
3652 : 108 : bParaAutoBefore = false;
3653 : 108 : bParaAutoAfter = false;
3654 : 108 : nProgress = 0;
3655 : 108 : nSwNumLevel = nWwNumType = 0xff;
3656 : 108 : pTableDesc = 0;
3657 : 108 : pNumOlst = 0;
3658 : 108 : pNode_FLY_AT_PARA = 0;
3659 : 108 : pDrawModel = 0;
3660 : 108 : pDrawPg = 0;
3661 : 108 : mpDrawEditEngine = 0;
3662 : 108 : pWWZOrder = 0;
3663 : 108 : pFormImpl = 0;
3664 : 108 : mpChosenOutlineNumRule = 0;
3665 : 108 : pNumFldType = 0;
3666 : 108 : nFldNum = 0;
3667 : :
3668 : 108 : nLFOPosition = USHRT_MAX;
3669 : 108 : nListLevel = WW8ListManager::nMaxLevel;
3670 : 108 : eHardCharSet = RTL_TEXTENCODING_DONTKNOW;
3671 : :
3672 : 108 : nPgChpDelim = nPgChpLevel = 0;
3673 : :
3674 [ + - ]: 108 : maApos.push_back(false);
3675 : 108 : }
3676 : :
3677 : 789 : void SwWW8ImplReader::DeleteStk(SwFltControlStack* pStck)
3678 : : {
3679 [ + - ]: 789 : if( pStck )
3680 : : {
3681 : 789 : pStck->SetAttr( *pPaM->GetPoint(), 0, false);
3682 : 789 : pStck->SetAttr( *pPaM->GetPoint(), 0, false);
3683 [ + - ]: 789 : delete pStck;
3684 : : }
3685 : : else
3686 : : {
3687 : : OSL_ENSURE( !this, "WW-Stack bereits geloescht" );
3688 : : }
3689 : 789 : }
3690 : :
3691 : 324 : void wwSectionManager::SetSegmentToPageDesc(const wwSection &rSection,
3692 : : bool bTitlePage, bool bIgnoreCols)
3693 : : {
3694 [ + + ]: 324 : SwPageDesc &rPage = bTitlePage ? *rSection.mpTitlePage : *rSection.mpPage;
3695 : :
3696 [ + - ]: 324 : SetNumberingType(rSection, rPage);
3697 : :
3698 : 324 : SwFrmFmt &rFmt = rPage.GetMaster();
3699 : :
3700 [ + + ][ + + ]: 324 : if (mrReader.pWDop->fUseBackGroundInAllmodes && mrReader.pMSDffManager)
3701 : : {
3702 [ + - ]: 15 : Rectangle aRect(0, 0, 100, 100); //A dummy, we don't care about the size
3703 [ + - ]: 15 : SvxMSDffImportData aData(aRect);
3704 : 15 : SdrObject* pObject = 0;
3705 [ + - ][ + - ]: 15 : if (mrReader.pMSDffManager->GetShape(0x401, pObject, aData))
3706 : : {
3707 : : // Only handle shape if it is a background shape
3708 [ + - ][ + - ]: 15 : if ((aData.begin()->nFlags & 0x400) != 0)
[ + + ]
3709 : : {
3710 [ + - ]: 9 : SfxItemSet aSet(rFmt.GetAttrSet());
3711 : : mrReader.MatchSdrItemsIntoFlySet(pObject, aSet, mso_lineSimple,
3712 [ + - ]: 9 : mso_lineSolid, mso_sptRectangle, aRect);
3713 [ + - ][ + - ]: 9 : rFmt.SetFmtAttr(aSet.Get(RES_BACKGROUND));
[ + - ]
3714 : : }
3715 [ + - ]: 15 : }
3716 : : }
3717 : 324 : wwULSpaceData aULData;
3718 [ + - ]: 324 : GetPageULData(rSection, bTitlePage, aULData);
3719 [ + - ]: 324 : SetPageULSpaceItems(rFmt, aULData, rSection);
3720 : :
3721 [ + - ]: 324 : SetPage(rPage, rFmt, rSection, bIgnoreCols);
3722 : :
3723 : 324 : bool bSetBorder = false;
3724 [ + - - - ]: 324 : switch (rSection.maSep.pgbApplyTo)
3725 : : {
3726 : : case 0:
3727 : : case 3:
3728 : 324 : bSetBorder = true;
3729 : 324 : break;
3730 : : case 1:
3731 : 0 : bSetBorder = bTitlePage;
3732 : 0 : break;
3733 : : case 2:
3734 : 0 : bSetBorder = !bTitlePage;
3735 : 0 : break;
3736 : : }
3737 [ + - ]: 324 : if (bSetBorder)
3738 [ + - ]: 324 : mrReader.SetPageBorder(rFmt, rSection);
3739 : :
3740 [ + - ]: 324 : mrReader.SetDocumentGrid(rFmt, rSection);
3741 : 324 : }
3742 : :
3743 : 108 : void wwSectionManager::SetUseOn(wwSection &rSection)
3744 : : {
3745 : : bool bEven = (rSection.maSep.grpfIhdt & (WW8_HEADER_EVEN|WW8_FOOTER_EVEN)) ?
3746 : 108 : true : false;
3747 : :
3748 : : bool bMirror = mrReader.pWDop->fMirrorMargins ||
3749 [ + - ][ - + ]: 108 : mrReader.pWDop->doptypography.f2on1;
3750 : :
3751 [ - + ]: 108 : UseOnPage eUseBase = bMirror ? nsUseOnPage::PD_MIRROR : nsUseOnPage::PD_ALL;
3752 : 108 : UseOnPage eUse = eUseBase;
3753 [ + - ]: 108 : if (!bEven)
3754 : 108 : eUse = (UseOnPage)(eUse | nsUseOnPage::PD_HEADERSHARE | nsUseOnPage::PD_FOOTERSHARE);
3755 : 108 : eUse = (UseOnPage)(eUse | nsUseOnPage::PD_FIRSTSHARE);
3756 : :
3757 : : OSL_ENSURE(rSection.mpPage, "Makes no sense to call me with no pages to set");
3758 [ + - ]: 108 : if (rSection.mpPage)
3759 : 108 : rSection.mpPage->WriteUseOn(eUse);
3760 [ + - ]: 108 : if (rSection.mpTitlePage)
3761 : : {
3762 : : rSection.mpTitlePage->WriteUseOn(
3763 : 108 : (UseOnPage) (eUseBase | nsUseOnPage::PD_HEADERSHARE | nsUseOnPage::PD_FOOTERSHARE | nsUseOnPage::PD_FIRSTSHARE));
3764 : : }
3765 : 108 : }
3766 : :
3767 : : //Set the page descriptor on this node, handle the different cases for a text
3768 : : //node or a table
3769 : 108 : void GiveNodePageDesc(SwNodeIndex &rIdx, const SwFmtPageDesc &rPgDesc,
3770 : : SwDoc &rDoc)
3771 : : {
3772 : : /*
3773 : : If its a table here, apply the pagebreak to the table
3774 : : properties, otherwise we add it to the para at this
3775 : : position
3776 : : */
3777 [ + + ]: 108 : if (rIdx.GetNode().IsTableNode())
3778 : : {
3779 : : SwTable& rTable =
3780 : 18 : rIdx.GetNode().GetTableNode()->GetTable();
3781 : 18 : SwFrmFmt* pApply = rTable.GetFrmFmt();
3782 : : OSL_ENSURE(pApply, "impossible");
3783 [ + - ]: 18 : if (pApply)
3784 : 18 : pApply->SetFmtAttr(rPgDesc);
3785 : : }
3786 : : else
3787 : : {
3788 [ + - ]: 90 : SwPosition aPamStart(rIdx);
3789 : : aPamStart.nContent.Assign(
3790 [ + - ][ + - ]: 90 : rIdx.GetNode().GetCntntNode(), 0);
3791 [ + - ]: 90 : SwPaM aPage(aPamStart);
3792 : :
3793 [ + - ][ + - ]: 90 : rDoc.InsertPoolItem(aPage, rPgDesc, 0);
[ + - ]
3794 : : }
3795 : 108 : }
3796 : :
3797 : : //Map a word section with to either one or two writer page descriptors
3798 : : //depending on if the word section has a title page
3799 : 108 : SwFmtPageDesc wwSectionManager::SetSwFmtPageDesc(mySegIter &rIter,
3800 : : mySegIter &rStart, bool bIgnoreCols)
3801 : : {
3802 [ + - ]: 108 : SwFmtPageDesc aEmpty;
3803 : : // Always read title page header/footer data - it could be used by following sections
3804 : : {
3805 [ + - ][ + + ]: 108 : if (IsNewDoc() && rIter == rStart)
[ + + ]
3806 : : {
3807 : 102 : rIter->mpTitlePage =
3808 [ + - ]: 102 : mrReader.rDoc.GetPageDescFromPool(RES_POOLPAGE_FIRST);
3809 : : }
3810 : : else
3811 : : {
3812 : : sal_uInt16 nPos = mrReader.rDoc.MakePageDesc(
3813 : : ViewShell::GetShellRes()->GetPageDescName(mnDesc, ShellResource::FIRST_PAGE)
3814 [ + - ][ + - ]: 6 : , 0, false);
[ + - ][ + - ]
3815 [ + - ]: 6 : rIter->mpTitlePage = &mrReader.rDoc.GetPageDesc(nPos);
3816 : : }
3817 : : OSL_ENSURE(rIter->mpTitlePage, "no page!");
3818 [ - + ]: 108 : if (!rIter->mpTitlePage)
3819 [ # # ]: 0 : return aEmpty;
3820 : :
3821 [ + - ]: 108 : SetSegmentToPageDesc(*rIter, true, bIgnoreCols);
3822 : : }
3823 : :
3824 [ + - ][ + + ]: 108 : if (IsNewDoc() && rIter == rStart)
[ + + ]
3825 : : {
3826 : 102 : rIter->mpPage =
3827 [ + - ]: 102 : mrReader.rDoc.GetPageDescFromPool(RES_POOLPAGE_STANDARD);
3828 : : }
3829 : : else
3830 : : {
3831 : : sal_uInt16 nPos = mrReader.rDoc.MakePageDesc(
3832 : : ViewShell::GetShellRes()->GetPageDescName(mnDesc, ShellResource::NORMAL_PAGE),
3833 [ + - ][ + - ]: 6 : rIter->mpTitlePage, false);
[ + - ][ + - ]
3834 [ + - ]: 6 : rIter->mpPage = &mrReader.rDoc.GetPageDesc(nPos);
3835 : : }
3836 : : OSL_ENSURE(rIter->mpPage, "no page!");
3837 [ - + ]: 108 : if (!rIter->mpPage)
3838 [ # # ]: 0 : return aEmpty;
3839 : :
3840 : : //Set page before hd/ft
3841 : 108 : const wwSection *pPrevious = 0;
3842 [ + + ]: 108 : if (rIter != rStart)
3843 [ + - ]: 6 : pPrevious = &(*(rIter-1));
3844 [ + - ][ + - ]: 108 : SetHdFt(*rIter, std::distance(rStart, rIter), pPrevious);
3845 : 108 : SetUseOn(*rIter);
3846 : :
3847 : : //Set hd/ft after set page
3848 [ + - ]: 108 : if (rIter->mpTitlePage)
3849 [ + - ]: 108 : SetSegmentToPageDesc(*rIter, true, bIgnoreCols);
3850 [ + - ]: 108 : SetSegmentToPageDesc(*rIter, false, bIgnoreCols);
3851 : :
3852 : 108 : SwFmtPageDesc aRet(rIter->HasTitlePage() ?
3853 [ + - ][ - + ]: 108 : rIter->mpTitlePage : rIter->mpPage);
3854 : :
3855 : 108 : rIter->mpPage->SetFollow(rIter->mpPage);
3856 : :
3857 [ + - ]: 108 : if (rIter->mpTitlePage)
3858 : 108 : rIter->mpTitlePage->SetFollow(rIter->mpPage);
3859 : :
3860 [ - + ]: 108 : if (rIter->PageRestartNo())
3861 : 0 : aRet.SetNumOffset(rIter->PageStartAt());
3862 : :
3863 : 108 : ++mnDesc;
3864 [ + - ][ + - ]: 108 : return aRet;
[ + - ]
3865 : : }
3866 : :
3867 : 216 : bool wwSectionManager::IsNewDoc() const
3868 : : {
3869 : 216 : return mrReader.mbNewDoc;
3870 : : }
3871 : :
3872 : 102 : void wwSectionManager::InsertSegments()
3873 : : {
3874 [ + - ]: 102 : const SvtFilterOptions& rOpt = SvtFilterOptions::Get();
3875 [ + - ]: 102 : sal_Bool bUseEnhFields = rOpt.IsUseEnhancedFields();
3876 : 102 : mySegIter aEnd = maSegments.end();
3877 : 102 : mySegIter aStart = maSegments.begin();
3878 [ + - ][ + + ]: 213 : for (mySegIter aIter = aStart; aIter != aEnd; ++aIter)
3879 : : {
3880 : : // If the section is of type "New column" (0x01), then simply insert a column break.
3881 : : // But only if there actually are columns on the page, otherwise a column break
3882 : : // seems to be handled like a page break by MSO.
3883 [ + + ][ + + ]: 111 : if ( aIter->maSep.bkc == 1 && aIter->maSep.ccolM1 > 0 )
[ + + ]
3884 : : {
3885 [ + - ]: 3 : SwPaM start( aIter->maStart );
3886 [ + - ][ + - ]: 3 : mrReader.rDoc.InsertPoolItem( start, SvxFmtBreakItem(SVX_BREAK_COLUMN_BEFORE, RES_BREAK), 0);
[ + - ]
3887 [ + - ]: 3 : continue;
3888 : : }
3889 : :
3890 [ + - ]: 108 : mySegIter aNext = aIter+1;
3891 [ + + ][ + - ]: 108 : mySegIter aPrev = (aIter == aStart) ? aIter : aIter-1;
3892 : :
3893 : : // If two following sections are different in following properties, Word will interprete a continuous
3894 : : // section break between them as if it was a section break next page.
3895 : 108 : bool bThisAndPreviousAreCompatible = ((aIter->GetPageWidth() == aPrev->GetPageWidth()) &&
3896 [ + - ][ + - ]: 108 : (aIter->GetPageHeight() == aPrev->GetPageHeight()) && (aIter->IsLandScape() == aPrev->IsLandScape()));
[ + - ]
3897 : :
3898 [ + + ][ - + ]: 108 : bool bInsertSection = (aIter != aStart) ? (aIter->IsContinous() && bThisAndPreviousAreCompatible): false;
[ # # ]
3899 : 108 : bool bInsertPageDesc = !bInsertSection;
3900 : 108 : bool bProtected = SectionIsProtected(*aIter); // do we really need this ?? I guess I have a different logic in editshell which disales this...
3901 [ - + ][ # # ]: 108 : if (bUseEnhFields && mrReader.pWDop->fProtEnabled && aIter->IsNotProtected())
[ - + ][ + - ]
3902 : : {
3903 : : // here we have the special case that the whole document is protected, with the execption of this section.
3904 : : // I want to address this when I do the section rework, so for the moment we disable the overall protection then...
3905 [ # # ]: 0 : mrReader.rDoc.set(IDocumentSettingAccess::PROTECT_FORM, false );
3906 : : }
3907 : :
3908 : :
3909 [ + - ]: 108 : if (bInsertPageDesc)
3910 : : {
3911 : : /*
3912 : : If a cont section follows this section then we won't be
3913 : : creating a page desc with 2+ cols as we cannot host a one
3914 : : col section in a 2+ col pagedesc and make it look like
3915 : : word. But if the current section actually has columns then
3916 : : we are forced to insert a section here as well as a page
3917 : : descriptor.
3918 : : */
3919 : :
3920 : 108 : bool bIgnoreCols = false;
3921 : 117 : bool bThisAndNextAreCompatible = (aNext != aEnd) ? ((aIter->GetPageWidth() == aNext->GetPageWidth()) &&
3922 [ + - ][ + - ]: 117 : (aIter->GetPageHeight() == aNext->GetPageHeight()) && (aIter->IsLandScape() == aNext->IsLandScape())) : true;
[ + + + - ]
3923 : :
3924 [ + + ][ - + ]: 108 : if (((aNext != aEnd && aNext->IsContinous() && bThisAndNextAreCompatible) || bProtected))
[ # # ][ - + ]
[ - + ]
3925 : : {
3926 : 0 : bIgnoreCols = true;
3927 [ # # ][ # # ]: 0 : if ((aIter->NoCols() > 1) || bProtected)
[ # # ]
3928 : 0 : bInsertSection = true;
3929 : : }
3930 : :
3931 [ + - ]: 108 : SwFmtPageDesc aDesc(SetSwFmtPageDesc(aIter, aStart, bIgnoreCols));
3932 [ - + ]: 108 : if (!aDesc.GetPageDesc())
3933 : 0 : continue;
3934 : :
3935 : : // special case handling for odd/even section break
3936 : : // a) as before create a new page style for the section break
3937 : : // b) set Layout of generated page style to right/left ( according
3938 : : // to section break odd/even )
3939 : : // c) create a new style to follow the break page style
3940 [ + - ][ - + ]: 108 : if ( aIter->maSep.bkc == 3 || aIter->maSep.bkc == 4 )
[ - + ]
3941 : : {
3942 : : // SetSwFmtPageDesc calls some methods that could
3943 : : // modify aIter (e.g. wwSection ).
3944 : : // Since we call SetSwFmtPageDesc below to generate the
3945 : : // 'Following' style of the Break style, it is safer
3946 : : // to take a copy of the contents of aIter.
3947 [ # # ]: 0 : wwSection aTmpSection = *aIter;
3948 : : // create a new following page style
3949 [ # # ]: 0 : SwFmtPageDesc aFollow(SetSwFmtPageDesc(aIter, aStart, bIgnoreCols));
3950 : : // restore any contents of aIter trashed by SetSwFmtPageDesc
3951 [ # # ]: 0 : *aIter = aTmpSection;
3952 : :
3953 : : // Handle the section break
3954 : 0 : UseOnPage eUseOnPage = nsUseOnPage::PD_LEFT;
3955 [ # # ]: 0 : if ( aIter->maSep.bkc == 4 ) // Odd ( right ) Section break
3956 : 0 : eUseOnPage = nsUseOnPage::PD_RIGHT;
3957 : :
3958 : 0 : aDesc.GetPageDesc()->WriteUseOn( eUseOnPage );
3959 [ # # ][ # # ]: 0 : aDesc.GetPageDesc()->SetFollow( aFollow.GetPageDesc() );
3960 : : }
3961 : :
3962 [ + - ][ + - ]: 108 : GiveNodePageDesc(aIter->maStart, aDesc, mrReader.rDoc);
[ + - ]
3963 : : }
3964 : :
3965 : 108 : SwTxtNode* pTxtNd = 0;
3966 [ - + ]: 108 : if (bInsertSection)
3967 : : {
3968 : : //Start getting the bounds of this section
3969 [ # # ]: 0 : SwPaM aSectPaM(*mrReader.pPaM);
3970 [ # # ]: 0 : SwNodeIndex aAnchor(aSectPaM.GetPoint()->nNode);
3971 [ # # ]: 0 : if (aNext != aEnd)
3972 : : {
3973 [ # # ]: 0 : aAnchor = aNext->maStart;
3974 [ # # ]: 0 : aSectPaM.GetPoint()->nNode = aAnchor;
3975 : 0 : aSectPaM.GetPoint()->nContent.Assign(
3976 [ # # ][ # # ]: 0 : aNext->maStart.GetNode().GetCntntNode(), 0);
3977 [ # # ]: 0 : aSectPaM.Move(fnMoveBackward);
3978 : : }
3979 : :
3980 : 0 : const SwPosition* pPos = aSectPaM.GetPoint();
3981 : 0 : SwTxtNode const*const pSttNd = pPos->nNode.GetNode().GetTxtNode();
3982 [ # # ][ # # ]: 0 : const SwTableNode* pTableNd = pSttNd ? pSttNd->FindTableNode() : 0;
3983 [ # # ]: 0 : if (pTableNd)
3984 : : {
3985 : : pTxtNd =
3986 [ # # ]: 0 : mrReader.rDoc.GetNodes().MakeTxtNode(aAnchor,
3987 [ # # ][ # # ]: 0 : mrReader.rDoc.GetTxtCollFromPool( RES_POOLCOLL_TEXT ));
3988 : :
3989 [ # # ][ # # ]: 0 : aSectPaM.GetPoint()->nNode = SwNodeIndex(*pTxtNd);
[ # # ]
3990 : 0 : aSectPaM.GetPoint()->nContent.Assign(
3991 [ # # ][ # # ]: 0 : aSectPaM.GetCntntNode(), 0);
3992 : : }
3993 : :
3994 [ # # ]: 0 : aSectPaM.SetMark();
3995 : :
3996 [ # # ]: 0 : aSectPaM.GetPoint()->nNode = aIter->maStart;
3997 : 0 : aSectPaM.GetPoint()->nContent.Assign(
3998 [ # # ][ # # ]: 0 : aSectPaM.GetCntntNode(), 0);
3999 : : //End getting the bounds of this section, quite a job eh ?
4000 : :
4001 [ # # ]: 0 : SwSectionFmt *pRet = InsertSection(aSectPaM, *aIter);
4002 : : //The last section if continous is always unbalanced
4003 [ # # ]: 0 : if (pRet)
4004 : : {
4005 : : //Set the columns to be UnBalanced if that compatability option
4006 : : //is set
4007 [ # # ]: 0 : if (mrReader.pWDop->fNoColumnBalance)
4008 [ # # ][ # # ]: 0 : pRet->SetFmtAttr(SwFmtNoBalancedColumns(true));
[ # # ]
4009 : : else
4010 : : {
4011 : : //Otherwise set to unbalanced if the following section is
4012 : : //not continuous, (which also means that the last section
4013 : : //is unbalanced)
4014 [ # # ][ # # ]: 0 : if (aNext == aEnd || !aNext->IsContinous())
[ # # ]
4015 [ # # ][ # # ]: 0 : pRet->SetFmtAttr(SwFmtNoBalancedColumns(true));
[ # # ]
4016 : : }
4017 : : }
4018 : :
4019 : 0 : bool bHasOwnHdFt = false;
4020 : : /*
4021 : : In this nightmare scenario the continuous section has its own
4022 : : headers and footers so we will try and find a hard page break
4023 : : between here and the end of the section and put the headers and
4024 : : footers there.
4025 : : */
4026 [ # # ]: 0 : if (!bInsertPageDesc)
4027 : : {
4028 : : bHasOwnHdFt =
4029 : : mrReader.HasOwnHeaderFooter(
4030 : 0 : aIter->maSep.grpfIhdt & ~(WW8_HEADER_FIRST | WW8_FOOTER_FIRST),
4031 : 0 : aIter->maSep.grpfIhdt, std::distance(aStart, aIter)
4032 [ # # # # ]: 0 : );
4033 : : }
4034 [ # # ]: 0 : if (bHasOwnHdFt)
4035 : : {
4036 : : // #i40766# Need to cache the page descriptor in case there is
4037 : : // no page break in the section
4038 : 0 : SwPageDesc *pOrig = aIter->mpPage;
4039 : 0 : SwPageDesc *pOrigTitle = aIter->mpTitlePage;
4040 : 0 : bool bFailed = true;
4041 [ # # ]: 0 : SwFmtPageDesc aDesc(SetSwFmtPageDesc(aIter, aStart, true));
4042 [ # # ]: 0 : if (aDesc.GetPageDesc())
4043 : : {
4044 [ # # ]: 0 : sal_uLong nStart = aSectPaM.Start()->nNode.GetIndex();
4045 [ # # ]: 0 : sal_uLong nEnd = aSectPaM.End()->nNode.GetIndex();
4046 [ # # ]: 0 : for(; nStart <= nEnd; ++nStart)
4047 : : {
4048 [ # # ][ # # ]: 0 : SwNode* pNode = mrReader.rDoc.GetNodes()[nStart];
4049 [ # # ]: 0 : if (!pNode)
4050 : 0 : continue;
4051 [ # # ][ # # ]: 0 : if (sw::util::HasPageBreak(*pNode))
4052 : : {
4053 [ # # ]: 0 : SwNodeIndex aIdx(*pNode);
4054 [ # # ]: 0 : GiveNodePageDesc(aIdx, aDesc, mrReader.rDoc);
4055 : 0 : bFailed = false;
4056 [ # # ]: 0 : break;
4057 : : }
4058 : : }
4059 : : }
4060 [ # # ]: 0 : if(bFailed)
4061 : : {
4062 : 0 : aIter->mpPage = pOrig;
4063 : 0 : aIter->mpTitlePage = pOrigTitle;
4064 [ # # ]: 0 : }
4065 [ # # ][ # # ]: 0 : }
4066 : : }
4067 : :
4068 [ - + ]: 108 : if (pTxtNd)
4069 : : {
4070 [ # # ]: 0 : SwNodeIndex aIdx(*pTxtNd);
4071 [ # # ]: 0 : SwPaM aTest(aIdx);
4072 [ # # ]: 0 : mrReader.rDoc.DelFullPara(aTest);
4073 [ # # ][ # # ]: 111 : pTxtNd = 0;
4074 : : }
4075 : : }
4076 : 102 : }
4077 : :
4078 : 210 : void wwExtraneousParas::delete_all_from_doc()
4079 : : {
4080 : : typedef std::vector<SwTxtNode*>::iterator myParaIter;
4081 : 210 : myParaIter aEnd = m_aTxtNodes.end();
4082 [ # # ][ + - ]: 210 : for (myParaIter aI = m_aTxtNodes.begin(); aI != aEnd; ++aI)
[ - + ]
4083 : : {
4084 [ # # ]: 0 : SwTxtNode *pTxtNode = *aI;
4085 [ # # ]: 0 : SwNodeIndex aIdx(*pTxtNode);
4086 [ # # ]: 0 : SwPaM aTest(aIdx);
4087 [ # # ]: 0 : m_rDoc.DelFullPara(aTest);
4088 [ # # ][ # # ]: 0 : }
4089 : 210 : m_aTxtNodes.clear();
4090 : 210 : }
4091 : :
4092 : 102 : void SwWW8ImplReader::StoreMacroCmds()
4093 : : {
4094 [ + + ]: 102 : if (pWwFib->lcbCmds)
4095 : : {
4096 [ + - ]: 87 : pTableStream->Seek(pWwFib->fcCmds);
4097 : :
4098 [ + - ]: 87 : uno::Reference < embed::XStorage > xRoot(mpDocShell->GetStorage());
4099 : :
4100 [ + + ]: 87 : if (!xRoot.is())
4101 : 102 : return;
4102 : :
4103 : : try
4104 : : {
4105 : : uno::Reference < io::XStream > xStream =
4106 [ + - ][ + - ]: 9 : xRoot->openStreamElement( rtl::OUString(SL::aMSMacroCmds), embed::ElementModes::READWRITE );
4107 [ + - ]: 9 : SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( xStream );
4108 : :
4109 [ + - ]: 9 : sal_uInt8 *pBuffer = new sal_uInt8[pWwFib->lcbCmds];
4110 [ + - ]: 9 : pWwFib->lcbCmds = pTableStream->Read(pBuffer, pWwFib->lcbCmds);
4111 [ + - ]: 9 : pStream->Write(pBuffer, pWwFib->lcbCmds);
4112 [ + - ]: 9 : delete[] pBuffer;
4113 [ + - ][ + - ]: 9 : delete pStream;
[ # # ]
4114 : : }
4115 [ # # ]: 0 : catch ( const uno::Exception& )
4116 : : {
4117 [ + + ]: 87 : }
4118 : : }
4119 : : }
4120 : :
4121 : 102 : void SwWW8ImplReader::ReadDocVars()
4122 : : {
4123 [ + - ]: 102 : std::vector<String> aDocVarStrings;
4124 [ + - ]: 102 : std::vector<ww::bytes> aDocVarStringIds;
4125 [ + - ]: 102 : std::vector<String> aDocValueStrings;
4126 : 102 : WW8ReadSTTBF(!bVer67, *pTableStream, pWwFib->fcStwUser,
4127 : : pWwFib->lcbStwUser, bVer67 ? 2 : 0, eStructCharSet,
4128 [ - + ][ + - ]: 102 : aDocVarStrings, &aDocVarStringIds, &aDocValueStrings);
4129 [ + - ]: 102 : if (!bVer67) {
4130 : : using namespace ::com::sun::star;
4131 : :
4132 : : uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
4133 [ + - ][ + - ]: 102 : mpDocShell->GetModel(), uno::UNO_QUERY_THROW);
4134 : : uno::Reference<document::XDocumentProperties> xDocProps(
4135 [ + - ][ + - ]: 102 : xDPS->getDocumentProperties());
4136 : : OSL_ENSURE(xDocProps.is(), "DocumentProperties is null");
4137 : : uno::Reference<beans::XPropertyContainer> xUserDefinedProps =
4138 [ + - ][ + - ]: 102 : xDocProps->getUserDefinedProperties();
4139 : : OSL_ENSURE(xUserDefinedProps.is(), "UserDefinedProperties is null");
4140 : :
4141 [ - + ]: 102 : for(size_t i=0; i<aDocVarStrings.size(); i++)
4142 : : {
4143 : 0 : uno::Any aDefaultValue;
4144 [ # # ][ # # ]: 0 : ::rtl::OUString name(aDocVarStrings[i]);
4145 : 0 : uno::Any aValue;
4146 [ # # ][ # # ]: 0 : aValue <<= ::rtl::OUString(aDocValueStrings[i]);
[ # # ][ # # ]
4147 : : try {
4148 [ # # ]: 0 : xUserDefinedProps->addProperty( name,
4149 : : beans::PropertyAttribute::REMOVEABLE,
4150 [ # # ]: 0 : aValue );
4151 [ # # ]: 0 : } catch (const uno::Exception &) {
4152 : : // ignore
4153 : : }
4154 : 102 : }
4155 : 102 : }
4156 : 102 : }
4157 : :
4158 : : //-----------------------------------------
4159 : : // Document Info
4160 : : //-----------------------------------------
4161 : :
4162 : 102 : void SwWW8ImplReader::ReadDocInfo()
4163 : : {
4164 [ + - ]: 102 : if( pStg )
4165 : : {
4166 : : uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
4167 [ + - ][ + - ]: 102 : mpDocShell->GetModel(), uno::UNO_QUERY_THROW);
4168 : : uno::Reference<document::XDocumentProperties> xDocProps(
4169 [ + - ][ + - ]: 102 : xDPS->getDocumentProperties());
4170 : : OSL_ENSURE(xDocProps.is(), "DocumentProperties is null");
4171 : :
4172 [ + - ]: 102 : if (xDocProps.is()) {
4173 [ - + ]: 102 : if ( pWwFib->fDot )
4174 : : {
4175 : 0 : rtl::OUString sTemplateURL;
4176 : 0 : SfxMedium* pMedium = mpDocShell->GetMedium();
4177 [ # # ]: 0 : if ( pMedium )
4178 : : {
4179 [ # # ]: 0 : rtl::OUString aName = pMedium->GetName();
4180 [ # # ]: 0 : INetURLObject aURL( aName );
4181 [ # # ]: 0 : sTemplateURL = aURL.GetMainURL(INetURLObject::DECODE_TO_IURI);
4182 [ # # ]: 0 : if ( !sTemplateURL.isEmpty() )
4183 [ # # ][ # # ]: 0 : xDocProps->setTemplateURL( sTemplateURL );
[ # # ]
4184 : 0 : }
4185 : : }
4186 [ + + ]: 102 : else if (pWwFib->lcbSttbfAssoc) // not a template, and has a SttbfAssoc
4187 : : {
4188 : 87 : long nCur = pTableStream->Tell();
4189 [ + - ]: 87 : Sttb aSttb;
4190 [ + - ]: 87 : pTableStream->Seek( pWwFib->fcSttbfAssoc ); // point at tgc record
4191 [ + - ]: 87 : if (!aSttb.Read( *pTableStream ) )
4192 : : OSL_TRACE("** Read of SttbAssoc data failed!!!! ");
4193 [ + - ]: 87 : pTableStream->Seek( nCur ); // return to previous position, is that necessary?
4194 : : #if DEBUG
4195 : : aSttb.Print( stderr );
4196 : : #endif
4197 [ + - ][ + - ]: 87 : String sPath = aSttb.getStringAtIndex( 0x1 );
4198 : 87 : rtl::OUString aURL;
4199 : : // attempt to convert to url ( won't work for obvious reasons on linux
4200 [ - + ]: 87 : if ( sPath.Len() )
4201 [ # # ][ # # ]: 0 : ::utl::LocalFileHelper::ConvertPhysicalNameToURL( sPath, aURL );
4202 [ + - ]: 87 : if (aURL.isEmpty())
4203 [ + - ][ + - ]: 87 : xDocProps->setTemplateURL( aURL );
4204 : : else
4205 [ # # ][ # # ]: 87 : xDocProps->setTemplateURL( sPath );
[ # # ][ + - ]
4206 : :
4207 : : }
4208 [ + - ]: 102 : sfx2::LoadOlePropertySet(xDocProps, pStg);
4209 : 102 : }
4210 : : }
4211 : 102 : }
4212 : :
4213 : 102 : void lcl_createTemplateToProjectEntry( const uno::Reference< container::XNameContainer >& xPrjNameCache, const rtl::OUString& sTemplatePathOrURL, const rtl::OUString& sVBAProjName )
4214 : : {
4215 [ + + ]: 102 : if ( xPrjNameCache.is() )
4216 : : {
4217 [ + - ]: 36 : INetURLObject aObj;
4218 [ + - ]: 36 : aObj.SetURL( sTemplatePathOrURL );
4219 : 36 : bool bIsURL = aObj.GetProtocol() != INET_PROT_NOT_VALID;
4220 : 36 : rtl::OUString aURL;
4221 [ - + ]: 36 : if ( bIsURL )
4222 : 0 : aURL = sTemplatePathOrURL;
4223 : : else
4224 : : {
4225 [ + - ]: 36 : osl::FileBase::getFileURLFromSystemPath( sTemplatePathOrURL, aURL );
4226 [ + - ]: 36 : aObj.SetURL( aURL );
4227 : : }
4228 : : try
4229 : : {
4230 [ + - ]: 36 : rtl::OUString templateNameWithExt = aObj.GetLastName();
4231 : 36 : rtl::OUString templateName;
4232 : 36 : sal_Int32 nIndex = templateNameWithExt.lastIndexOf( '.' );
4233 [ - + ]: 36 : if ( nIndex != -1 )
4234 : : {
4235 : 0 : templateName = templateNameWithExt.copy( 0, nIndex );
4236 [ # # ][ # # ]: 0 : xPrjNameCache->insertByName( templateName, uno::makeAny( sVBAProjName ) );
[ # # ]
4237 [ # # ]: 36 : }
4238 : : }
4239 [ # # ]: 0 : catch( const uno::Exception& )
4240 : : {
4241 [ + - ]: 36 : }
4242 : : }
4243 : 102 : }
4244 : :
4245 : : class WW8Customizations
4246 : : {
4247 : : SvStream* mpTableStream;
4248 : : WW8Fib mWw8Fib;
4249 : : public:
4250 : : WW8Customizations( SvStream*, WW8Fib& );
4251 : : bool Import( SwDocShell* pShell );
4252 : : };
4253 : :
4254 : 102 : WW8Customizations::WW8Customizations( SvStream* pTableStream, WW8Fib& rFib ) : mpTableStream(pTableStream), mWw8Fib( rFib )
4255 : : {
4256 : 102 : }
4257 : :
4258 : 102 : bool WW8Customizations::Import( SwDocShell* pShell )
4259 : : {
4260 [ + + ]: 102 : if ( mWw8Fib.lcbCmds == 0 )
4261 : 15 : return false;
4262 [ + - ]: 87 : Tcg aTCG;
4263 : 87 : long nCur = mpTableStream->Tell();
4264 [ + - ]: 87 : mpTableStream->Seek( mWw8Fib.fcCmds ); // point at tgc record
4265 [ + - ]: 87 : bool bReadResult = aTCG.Read( *mpTableStream );
4266 [ + - ]: 87 : mpTableStream->Seek( nCur ); // return to previous position, is that necessary?
4267 [ + + ]: 87 : if ( !bReadResult )
4268 : : {
4269 : : OSL_TRACE("** Read of Customization data failed!!!! ");
4270 : 9 : return false;
4271 : : }
4272 : : #if DEBUG
4273 : : aTCG.Print( stderr );
4274 : : #endif
4275 [ + - ][ + - ]: 102 : return aTCG.ImportCustomToolBar( *pShell );
4276 : : }
4277 : :
4278 : 102 : bool SwWW8ImplReader::ReadGlobalTemplateSettings( const rtl::OUString& sCreatedFrom, const uno::Reference< container::XNameContainer >& xPrjNameCache )
4279 : : {
4280 [ + - ]: 102 : SvtPathOptions aPathOpt;
4281 [ + - ][ + - ]: 102 : String aAddinPath = aPathOpt.GetAddinPath();
4282 [ + - ]: 102 : uno::Sequence< rtl::OUString > sGlobalTemplates;
4283 : :
4284 : : // first get the autoload addins in the directory STARTUP
4285 [ + - ][ + - ]: 102 : uno::Reference<ucb::XSimpleFileAccess2> xSFA(ucb::SimpleFileAccess::create(::comphelper::getProcessComponentContext()));
4286 : :
4287 [ + - ][ + - ]: 102 : if( xSFA->isFolder( aAddinPath ) )
[ - + ][ + - ]
4288 [ # # ][ # # ]: 0 : sGlobalTemplates = xSFA->getFolderContents( aAddinPath, sal_False );
[ # # ][ # # ]
[ # # ]
4289 : :
4290 : 102 : sal_Int32 nEntries = sGlobalTemplates.getLength();
4291 : 102 : bool bRes = true;
4292 [ - + ]: 102 : for ( sal_Int32 i=0; i<nEntries; ++i )
4293 : : {
4294 [ # # ]: 0 : INetURLObject aObj;
4295 [ # # ][ # # ]: 0 : aObj.SetURL( sGlobalTemplates[ i ] );
4296 : 0 : bool bIsURL = aObj.GetProtocol() != INET_PROT_NOT_VALID;
4297 : 0 : rtl::OUString aURL;
4298 [ # # ]: 0 : if ( bIsURL )
4299 [ # # ]: 0 : aURL = sGlobalTemplates[ i ];
4300 : : else
4301 [ # # ][ # # ]: 0 : osl::FileBase::getFileURLFromSystemPath( sGlobalTemplates[ i ], aURL );
4302 [ # # ][ # # ]: 0 : if ( !aURL.endsWithIgnoreAsciiCase( ".dot" ) || ( !sCreatedFrom.isEmpty() && sCreatedFrom.equals( aURL ) ) )
[ # # ][ # # ]
4303 : 0 : continue; // don't try and read the same document as ourselves
4304 : :
4305 [ # # ][ # # ]: 0 : SotStorageRef rRoot = new SotStorage( aURL, STREAM_STD_READWRITE, STORAGE_TRANSACTED );
[ # # ][ # # ]
4306 : :
4307 [ # # ]: 0 : BasicProjImportHelper aBasicImporter( *mpDocShell );
4308 : : // Import vba via oox filter
4309 [ # # ][ # # ]: 0 : aBasicImporter.import( mpDocShell->GetMedium()->GetInputStream() );
4310 [ # # ][ # # ]: 0 : lcl_createTemplateToProjectEntry( xPrjNameCache, aURL, aBasicImporter.getProjectName() );
4311 : : // Read toolbars & menus
4312 [ # # ][ # # ]: 0 : SvStorageStreamRef refMainStream = rRoot->OpenSotStream( rtl::OUString( "WordDocument" ));
[ # # ]
4313 [ # # ]: 0 : refMainStream->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
4314 [ # # ]: 0 : WW8Fib aWwFib( *refMainStream, 8 );
4315 [ # # ][ # # ]: 0 : SvStorageStreamRef xTableStream = rRoot->OpenSotStream(rtl::OUString::createFromAscii( aWwFib.fWhichTblStm ? SL::a1Table : SL::a0Table), STREAM_STD_READ);
[ # # ][ # # ]
4316 : :
4317 [ # # ][ # # ]: 0 : if (xTableStream.Is() && SVSTREAM_OK == xTableStream->GetError())
[ # # ]
4318 : : {
4319 [ # # ]: 0 : xTableStream->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
4320 : 0 : WW8Customizations aGblCustomisations( xTableStream, aWwFib );
4321 [ # # ]: 0 : aGblCustomisations.Import( mpDocShell );
4322 : : }
4323 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
4324 [ + - ][ + - ]: 102 : return bRes;
[ + - ]
4325 : : }
4326 : :
4327 : 102 : sal_uLong SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos)
4328 : : {
4329 : 102 : sal_uLong nErrRet = 0;
4330 : :
4331 [ + - ][ + - ]: 102 : if (mbNewDoc && pStg && !pGloss)
[ + - ]
4332 [ + - ]: 102 : ReadDocInfo();
4333 : :
4334 [ + - ][ + - ]: 102 : ::ww8::WW8FibData * pFibData = new ::ww8::WW8FibData();
4335 : :
4336 [ - + ]: 102 : if (pWwFib->fReadOnlyRecommended)
4337 [ # # ]: 0 : pFibData->setReadOnlyRecommended(true);
4338 : : else
4339 [ + - ]: 102 : pFibData->setReadOnlyRecommended(false);
4340 : :
4341 [ - + ]: 102 : if (pWwFib->fWriteReservation)
4342 [ # # ]: 0 : pFibData->setWriteReservation(true);
4343 : : else
4344 [ + - ]: 102 : pFibData->setWriteReservation(false);
4345 : :
4346 [ + - ]: 102 : ::sw::tExternalDataPointer pExternalFibData(pFibData);
4347 : :
4348 [ + - ][ + - ]: 102 : rDoc.setExternalData(::sw::FIB, pExternalFibData);
[ + - ]
4349 : :
4350 : : ::sw::tExternalDataPointer pSttbfAsoc
4351 [ + - ][ + - ]: 102 : (new ::ww8::WW8Sttb<ww8::WW8Struct>(*pTableStream, pWwFib->fcSttbfAssoc, pWwFib->lcbSttbfAssoc));
[ + - ]
4352 : :
4353 [ + - ][ + - ]: 102 : rDoc.setExternalData(::sw::STTBF_ASSOC, pSttbfAsoc);
[ + - ]
4354 : :
4355 [ + - ][ - + ]: 102 : if (pWwFib->fWriteReservation || pWwFib->fReadOnlyRecommended)
4356 : : {
4357 : 0 : SwDocShell * pDocShell = rDoc.GetDocShell();
4358 [ # # ]: 0 : if (pDocShell)
4359 [ # # ]: 0 : pDocShell->SetReadOnlyUI(sal_True);
4360 : : }
4361 : :
4362 [ + - ][ + - ]: 102 : pPaM = new SwPaM(rPos);
4363 : :
4364 [ + - ][ + - ]: 102 : pCtrlStck = new SwWW8FltControlStack( &rDoc, nFieldFlags, *this );
4365 : :
4366 [ + - ][ + - ]: 102 : mpRedlineStack = new sw::util::RedlineStack(rDoc);
4367 : :
4368 : : /*
4369 : : RefFldStck: Keeps track of bookmarks which may be inserted as
4370 : : variables intstead.
4371 : : */
4372 [ + - ][ + - ]: 102 : pReffedStck = new SwFltEndStack(&rDoc, nFieldFlags);
4373 [ + - ][ + - ]: 102 : pReffingStck = new SwWW8FltRefStack(&rDoc, nFieldFlags);
4374 : :
4375 [ + - ][ + - ]: 102 : pAnchorStck = new SwWW8FltAnchorStack(&rDoc, nFieldFlags);
4376 : :
4377 : 102 : sal_uInt16 nPageDescOffset = rDoc.GetPageDescCnt();
4378 : :
4379 [ + - ][ + - ]: 102 : SwNodeIndex aSttNdIdx( rDoc.GetNodes() );
4380 [ + - ]: 102 : SwRelNumRuleSpaces aRelNumRule(rDoc, mbNewDoc);
4381 : :
4382 : 102 : sal_uInt16 eMode = nsRedlineMode_t::REDLINE_SHOW_INSERT;
4383 : :
4384 [ + - ][ + - ]: 102 : mpSprmParser = new wwSprmParser(pWwFib->GetFIBVersion());
[ + - ]
4385 : :
4386 : : // praktische Hilfsvariablen besetzen:
4387 : 102 : bVer6 = (6 == pWwFib->nVersion);
4388 : 102 : bVer7 = (7 == pWwFib->nVersion);
4389 [ + - ][ - + ]: 102 : bVer67 = bVer6 || bVer7;
4390 : 102 : bVer8 = (8 == pWwFib->nVersion);
4391 : :
4392 [ + - ]: 102 : eTextCharSet = WW8Fib::GetFIBCharset(pWwFib->chse);
4393 [ + - ]: 102 : eStructCharSet = WW8Fib::GetFIBCharset(pWwFib->chseTables);
4394 : :
4395 : 102 : bWWBugNormal = pWwFib->nProduct == 0xc03d;
4396 : :
4397 [ - + ]: 102 : if (!mbNewDoc)
4398 [ # # ]: 0 : aSttNdIdx = pPaM->GetPoint()->nNode;
4399 : :
4400 [ + - ]: 102 : ::StartProgress(STR_STATSTR_W4WREAD, 0, 100, mpDocShell);
4401 : :
4402 : : // read Font Table
4403 [ + - ][ + - ]: 102 : pFonts = new WW8Fonts( *pTableStream, *pWwFib );
4404 : :
4405 : : // Document Properties
4406 : : pWDop = new WW8Dop( *pTableStream, pWwFib->nFib, pWwFib->fcDop,
4407 [ + - ][ + - ]: 102 : pWwFib->lcbDop );
4408 : :
4409 [ + - ]: 102 : if (mbNewDoc)
4410 [ + - ]: 102 : ImportDop();
4411 : :
4412 : : /*
4413 : : Import revisioning data: author names
4414 : : */
4415 [ + + ]: 102 : if( pWwFib->lcbSttbfRMark )
4416 : : {
4417 : : ReadRevMarkAuthorStrTabl( *pTableStream,
4418 : : pWwFib->fcSttbfRMark,
4419 [ + - ]: 72 : pWwFib->lcbSttbfRMark, rDoc );
4420 : : }
4421 : :
4422 : : // M.M. Initialize our String/ID map for Linked Sections
4423 [ + - ]: 102 : std::vector<String> aLinkStrings;
4424 [ + - ]: 102 : std::vector<ww::bytes> aStringIds;
4425 : :
4426 : 102 : WW8ReadSTTBF(!bVer67, *pTableStream, pWwFib->fcSttbFnm,
4427 : : pWwFib->lcbSttbFnm, bVer67 ? 2 : 0, eStructCharSet,
4428 [ - + ][ + - ]: 102 : aLinkStrings, &aStringIds);
4429 : :
4430 [ - + ][ # # ]: 102 : for (size_t i=0; i < aLinkStrings.size() && i < aStringIds.size(); ++i)
[ - + ]
4431 : : {
4432 [ # # ]: 0 : ww::bytes stringId = aStringIds[i];
4433 [ # # ]: 0 : WW8_STRINGID *stringIdStruct = (WW8_STRINGID*)(&stringId[0]);
4434 [ # # ]: 0 : aLinkStringMap[SVBT16ToShort(stringIdStruct->nStringId)] =
4435 [ # # ][ # # ]: 0 : aLinkStrings[i];
4436 : 0 : }
4437 : :
4438 [ + - ]: 102 : ReadDocVars(); // import document variables as meta information.
4439 : :
4440 [ + - ]: 102 : ::SetProgressState(nProgress, mpDocShell); // Update
4441 : :
4442 [ + - ][ + - ]: 102 : pLstManager = new WW8ListManager( *pTableStream, *this );
4443 : :
4444 : : /*
4445 : : zuerst(!) alle Styles importieren (siehe WW8PAR2.CXX)
4446 : : VOR dem Import der Listen !!
4447 : : */
4448 [ + - ]: 102 : ::SetProgressState(nProgress, mpDocShell); // Update
4449 [ + - ][ + - ]: 102 : pStyles = new WW8RStyle( *pWwFib, this ); // Styles
4450 [ + - ]: 102 : pStyles->Import();
4451 : :
4452 : : /*
4453 : : zu guter Letzt: (siehe ebenfalls WW8PAR3.CXX)
4454 : : ===============
4455 : : alle Styles durchgehen und ggfs. zugehoeriges Listen-Format
4456 : : anhaengen NACH dem Import der Styles und NACH dem Import der
4457 : : Listen !!
4458 : : */
4459 [ + - ]: 102 : ::SetProgressState(nProgress, mpDocShell); // Update
4460 [ + - ]: 102 : pStyles->PostProcessStyles();
4461 : :
4462 [ + - ]: 102 : if (!vColl.empty())
4463 [ + - ]: 102 : SetOutLineStyles();
4464 : :
4465 [ + - ][ + - ]: 102 : pSBase = new WW8ScannerBase(pStrm,pTableStream,pDataStream,pWwFib);
4466 : :
4467 : : static const SvxExtNumType eNumTA[16] =
4468 : : {
4469 : : SVX_NUM_ARABIC, SVX_NUM_ROMAN_UPPER, SVX_NUM_ROMAN_LOWER,
4470 : : SVX_NUM_CHARS_UPPER_LETTER_N, SVX_NUM_CHARS_LOWER_LETTER_N,
4471 : : SVX_NUM_ARABIC, SVX_NUM_ARABIC, SVX_NUM_ARABIC,
4472 : : SVX_NUM_ARABIC, SVX_NUM_ARABIC, SVX_NUM_ARABIC,
4473 : : SVX_NUM_ARABIC, SVX_NUM_ARABIC, SVX_NUM_ARABIC,
4474 : : SVX_NUM_ARABIC, SVX_NUM_ARABIC
4475 : : };
4476 : :
4477 [ + + ]: 102 : if (pSBase->AreThereFootnotes())
4478 : : {
4479 : : static const SwFtnNum eNumA[4] =
4480 : : {
4481 : : FTNNUM_DOC, FTNNUM_CHAPTER, FTNNUM_PAGE, FTNNUM_DOC
4482 : : };
4483 : :
4484 [ + - ]: 3 : SwFtnInfo aInfo;
4485 [ + - ]: 3 : aInfo = rDoc.GetFtnInfo(); // Copy-Ctor privat
4486 : :
4487 : 3 : aInfo.ePos = FTNPOS_PAGE;
4488 : 3 : aInfo.eNum = eNumA[pWDop->rncFtn];
4489 : 3 : aInfo.aFmt.SetNumberingType( static_cast< sal_uInt16 >(eNumTA[pWDop->nfcFtnRef]) );
4490 [ + - ]: 3 : if( pWDop->nFtn )
4491 : 3 : aInfo.nFtnOffset = pWDop->nFtn - 1;
4492 [ + - ][ + - ]: 3 : rDoc.SetFtnInfo( aInfo );
4493 : : }
4494 [ - + ]: 102 : if( pSBase->AreThereEndnotes() )
4495 : : {
4496 [ # # ]: 0 : SwEndNoteInfo aInfo;
4497 [ # # ]: 0 : aInfo = rDoc.GetEndNoteInfo(); // parallel zu Ftn
4498 : :
4499 : 0 : aInfo.aFmt.SetNumberingType( static_cast< sal_uInt16 >(eNumTA[pWDop->nfcEdnRef]) );
4500 [ # # ]: 0 : if( pWDop->nEdn )
4501 : 0 : aInfo.nFtnOffset = pWDop->nEdn - 1;
4502 [ # # ][ # # ]: 0 : rDoc.SetEndNoteInfo( aInfo );
4503 : : }
4504 : :
4505 [ + + ]: 102 : if( pWwFib->lcbPlcfhdd )
4506 [ + - ][ + - ]: 45 : pHdFt = new WW8PLCF_HdFt( pTableStream, *pWwFib, *pWDop );
4507 : :
4508 [ - + ]: 102 : if (!mbNewDoc)
4509 : : {
4510 : : // in ein Dokument einfuegen ?
4511 : : // Da immer ganze Zeile eingelesen werden, muessen
4512 : : // evtl. Zeilen eingefuegt / aufgebrochen werden
4513 : : //
4514 : 0 : const SwPosition* pPos = pPaM->GetPoint();
4515 : 0 : SwTxtNode const*const pSttNd = pPos->nNode.GetNode().GetTxtNode();
4516 : :
4517 : 0 : sal_uInt16 nCntPos = pPos->nContent.GetIndex();
4518 : :
4519 : : // EinfuegePos nicht in leerer Zeile
4520 [ # # ][ # # ]: 0 : if( nCntPos && pSttNd->GetTxt().Len() )
[ # # ]
4521 [ # # ]: 0 : rDoc.SplitNode( *pPos, false ); // neue Zeile erzeugen
4522 : :
4523 [ # # ]: 0 : if( pSttNd->GetTxt().Len() )
4524 : : { // EinfuegePos nicht am Ende der Zeile
4525 [ # # ]: 0 : rDoc.SplitNode( *pPos, false ); // neue Zeile
4526 [ # # ]: 0 : pPaM->Move( fnMoveBackward ); // gehe in leere Zeile
4527 : : }
4528 : :
4529 : : // verhinder das Einlesen von Tabellen in Fussnoten / Tabellen
4530 : 0 : sal_uLong nNd = pPos->nNode.GetIndex();
4531 [ # # ]: 0 : bReadNoTbl = 0 != pSttNd->FindTableNode() ||
4532 [ # # ]: 0 : ( nNd < rDoc.GetNodes().GetEndOfInserts().GetIndex() &&
4533 [ # # ]: 0 : rDoc.GetNodes().GetEndOfInserts().StartOfSectionIndex()
4534 [ # # # # : 0 : < nNd );
# # ]
4535 : :
4536 : : }
4537 : :
4538 [ + - ]: 102 : ::SetProgressState(nProgress, mpDocShell); // Update
4539 : :
4540 : : // loop for each glossary entry and add dummy section node
4541 [ - + ]: 102 : if (pGloss)
4542 : : {
4543 [ # # ]: 0 : WW8PLCF aPlc(*pTableStream, pWwFib->fcPlcfglsy, pWwFib->lcbPlcfglsy, 0);
4544 : :
4545 : : WW8_CP nStart, nEnd;
4546 : : void* pDummy;
4547 : :
4548 [ # # ]: 0 : for (int i = 0; i < pGloss->GetNoStrings(); ++i, aPlc.advance())
4549 : : {
4550 [ # # ][ # # ]: 0 : SwNodeIndex aIdx( rDoc.GetNodes().GetEndOfContent());
4551 : : SwTxtFmtColl* pColl =
4552 : : rDoc.GetTxtCollFromPool(RES_POOLCOLL_STANDARD,
4553 [ # # ]: 0 : false);
4554 : : SwStartNode *pNode =
4555 [ # # ]: 0 : rDoc.GetNodes().MakeTextSection(aIdx,
4556 [ # # ]: 0 : SwNormalStartNode,pColl);
4557 [ # # ]: 0 : pPaM->GetPoint()->nNode = pNode->GetIndex()+1;
4558 [ # # ][ # # ]: 0 : pPaM->GetPoint()->nContent.Assign(pPaM->GetCntntNode(),0);
4559 [ # # ]: 0 : aPlc.Get( nStart, nEnd, pDummy );
4560 [ # # ]: 0 : ReadText(nStart,nEnd-nStart-1,MAN_MAINTEXT);
4561 [ # # ]: 0 : }
4562 : : }
4563 : : else //ordinary case
4564 : : {
4565 [ + - ][ + - ]: 102 : if (mbNewDoc && pStg && !pGloss) /*meaningless for a glossary, cmc*/
[ + - ]
4566 : : {
4567 : 102 : mpDocShell->SetIsTemplate( pWwFib->fDot ); // point at tgc record
4568 [ + - ][ + - ]: 102 : uno::Reference< document::XDocumentInfoSupplier > xDocInfoSupp( mpDocShell->GetModel(), uno::UNO_QUERY_THROW );
4569 [ + - ][ + - ]: 102 : uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSupp( xDocInfoSupp->getDocumentInfo(), uno::UNO_QUERY_THROW );
[ + - ]
4570 [ + - ][ + - ]: 102 : uno::Reference< document::XDocumentProperties > xDocProps( xDocPropSupp->getDocumentProperties(), uno::UNO_QUERY_THROW );
[ + - ]
4571 : :
4572 [ + - ][ + - ]: 102 : rtl::OUString sCreatedFrom = xDocProps->getTemplateURL();
4573 : 102 : uno::Reference< container::XNameContainer > xPrjNameCache;
4574 [ + - ][ + - ]: 102 : uno::Reference< lang::XMultiServiceFactory> xSF(mpDocShell->GetModel(), uno::UNO_QUERY);
4575 [ + - ]: 102 : if ( xSF.is() )
4576 [ + - ][ + - ]: 102 : xPrjNameCache.set( xSF->createInstance( "ooo.vba.VBAProjectNameProvider" ), uno::UNO_QUERY );
[ + - ]
4577 : :
4578 : : // Read Global templates
4579 [ + - ]: 102 : ReadGlobalTemplateSettings( sCreatedFrom, xPrjNameCache );
4580 : :
4581 : : // Create and insert Word vba Globals
4582 : 102 : uno::Any aGlobs;
4583 [ + - ]: 102 : uno::Sequence< uno::Any > aArgs(1);
4584 [ + - ][ + - ]: 102 : aArgs[ 0 ] <<= mpDocShell->GetModel();
[ + - ]
4585 [ + - ][ + - ]: 102 : aGlobs <<= ::comphelper::getProcessServiceFactory()->createInstanceWithArguments( "ooo.vba.word.Globals", aArgs );
[ + - ][ + - ]
4586 : :
4587 : : #ifndef DISABLE_SCRIPTING
4588 [ + - ]: 102 : BasicManager *pBasicMan = mpDocShell->GetBasicManager();
4589 [ + - ]: 102 : if (pBasicMan)
4590 [ + - ]: 102 : pBasicMan->SetGlobalUNOConstant( "VBAGlobals", aGlobs );
4591 : : #endif
4592 [ + - ]: 102 : BasicProjImportHelper aBasicImporter( *mpDocShell );
4593 : : // Import vba via oox filter
4594 [ + - ][ + - ]: 102 : bool bRet = aBasicImporter.import( mpDocShell->GetMedium()->GetInputStream() );
4595 : :
4596 [ + - ][ + - ]: 102 : lcl_createTemplateToProjectEntry( xPrjNameCache, sCreatedFrom, aBasicImporter.getProjectName() );
4597 : 102 : WW8Customizations aCustomisations( pTableStream, *pWwFib );
4598 [ + - ]: 102 : aCustomisations.Import( mpDocShell );
4599 : :
4600 [ - + ]: 102 : if( bRet )
4601 : 0 : rDoc.SetContainsMSVBasic(true);
4602 : :
4603 [ + - ][ + - ]: 102 : StoreMacroCmds();
[ + - ]
4604 : : }
4605 [ + - ]: 102 : ReadText(0, pWwFib->ccpText, MAN_MAINTEXT);
4606 : :
4607 : : }
4608 : :
4609 [ + - ]: 102 : ::SetProgressState(nProgress, mpDocShell); // Update
4610 : :
4611 [ + + ][ + - ]: 102 : if (pDrawPg && pMSDffManager && pMSDffManager->GetShapeOrders())
[ + - ][ + + ]
4612 : : {
4613 : : // Hilfsarray zum Verketten der (statt SdrTxtObj) eingefuegten
4614 : : // Rahmen
4615 [ + - ]: 27 : SvxMSDffShapeTxBxSort aTxBxSort;
4616 : :
4617 : : // korrekte Z-Order der eingelesen Escher-Objekte sicherstellen
4618 : 27 : sal_uInt16 nShapeCount = pMSDffManager->GetShapeOrders()->size();
4619 : :
4620 [ + + ]: 582 : for (sal_uInt16 nShapeNum=0; nShapeNum < nShapeCount; nShapeNum++)
4621 : : {
4622 : : SvxMSDffShapeOrder *pOrder =
4623 : 555 : (*pMSDffManager->GetShapeOrders())[nShapeNum];
4624 : : // Pointer in neues Sort-Array einfuegen
4625 [ + - ][ + + ]: 555 : if (pOrder->nTxBxComp && pOrder->pFly)
4626 [ + - ]: 3 : aTxBxSort.insert(pOrder);
4627 : : }
4628 : : // zu verkettende Rahmen jetzt verketten
4629 [ + + ]: 27 : if( !aTxBxSort.empty() )
4630 : : {
4631 [ + - ]: 3 : SwFmtChain aChain;
4632 [ + + ]: 6 : for( SvxMSDffShapeTxBxSort::iterator it = aTxBxSort.begin(); it != aTxBxSort.end(); ++it )
4633 : : {
4634 : 3 : SvxMSDffShapeOrder *pOrder = *it;
4635 : :
4636 : : // Fly-Frame-Formate initialisieren
4637 : 3 : SwFlyFrmFmt* pFlyFmt = pOrder->pFly;
4638 : 3 : SwFlyFrmFmt* pNextFlyFmt = 0;
4639 : 3 : SwFlyFrmFmt* pPrevFlyFmt = 0;
4640 : : // ggfs. Nachfolger ermitteln
4641 : 3 : SvxMSDffShapeTxBxSort::iterator tmpIter1 = it;
4642 : 3 : ++tmpIter1;
4643 [ - + ]: 3 : if( tmpIter1 != aTxBxSort.end() )
4644 : : {
4645 : 0 : SvxMSDffShapeOrder *pNextOrder = *tmpIter1;
4646 [ # # ]: 0 : if ((0xFFFF0000 & pOrder->nTxBxComp)
4647 : : == (0xFFFF0000 & pNextOrder->nTxBxComp))
4648 : 0 : pNextFlyFmt = pNextOrder->pFly;
4649 : : }
4650 : : // ggfs. Vorgaenger ermitteln
4651 [ - + ]: 3 : if( it != aTxBxSort.begin() )
4652 : : {
4653 : 0 : SvxMSDffShapeTxBxSort::iterator tmpIter2 = it;
4654 : 0 : --tmpIter2;
4655 : 0 : SvxMSDffShapeOrder *pPrevOrder = *tmpIter2;
4656 [ # # ]: 0 : if ((0xFFFF0000 & pOrder->nTxBxComp)
4657 : : == (0xFFFF0000 & pPrevOrder->nTxBxComp))
4658 : 0 : pPrevFlyFmt = pPrevOrder->pFly;
4659 : : }
4660 : : // Falls Nachfolger oder Vorgaenger vorhanden,
4661 : : // die Verkettung am Fly-Frame-Format eintragen
4662 [ + - ][ - + ]: 3 : if (pNextFlyFmt || pPrevFlyFmt)
4663 : : {
4664 [ # # ]: 0 : aChain.SetNext( pNextFlyFmt );
4665 [ # # ]: 0 : aChain.SetPrev( pPrevFlyFmt );
4666 [ # # ]: 0 : pFlyFmt->SetFmtAttr( aChain );
4667 : : }
4668 [ + - ]: 3 : }
4669 : :
4670 : 27 : }
4671 : :
4672 : : }
4673 : :
4674 [ + - ]: 102 : if (mbNewDoc)
4675 : : {
4676 [ - + ]: 102 : if( pWDop->fRevMarking )
4677 : 0 : eMode |= nsRedlineMode_t::REDLINE_ON;
4678 [ + + ]: 102 : if( pWDop->fRMView )
4679 : 99 : eMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE;
4680 : : }
4681 : :
4682 [ + - ]: 102 : maInsertedTables.DelAndMakeTblFrms();
4683 [ + - ]: 102 : maSectionManager.InsertSegments();
4684 : :
4685 : 102 : vColl.clear();
4686 : :
4687 : 102 : DELETEZ( pStyles );
4688 : :
4689 [ + + ]: 102 : if( pFormImpl )
4690 [ + - ]: 42 : DeleteFormImpl();
4691 [ + - ]: 102 : GrafikDtor();
4692 [ + + ][ + - ]: 102 : DELETEZ( pMSDffManager );
4693 [ + + ]: 102 : DELETEZ( pHdFt );
4694 [ + - ][ + - ]: 102 : DELETEZ( pLstManager );
4695 [ + - ][ + - ]: 102 : DELETEZ( pSBase );
4696 : 102 : delete pWDop;
4697 [ + - ][ + - ]: 102 : DELETEZ( pFonts );
4698 [ - + ]: 102 : delete mpAtnNames;
4699 : 102 : delete mpSprmParser;
4700 [ + - ]: 102 : ::EndProgress(mpDocShell);
4701 : :
4702 : 102 : pDataStream = 0;
4703 : 102 : pTableStream = 0;
4704 : :
4705 [ + - ]: 102 : DeleteCtrlStk();
4706 [ + - ]: 102 : mpRedlineStack->closeall(*pPaM->GetPoint());
4707 [ + - ][ + - ]: 102 : delete mpRedlineStack;
4708 [ + - ]: 102 : DeleteAnchorStk();
4709 [ + - ]: 102 : DeleteRefStks();
4710 : :
4711 : : //remove extra paragraphs after attribute ctrl
4712 : : //stacks etc. are destroyed, and before fields
4713 : : //are updated
4714 [ + - ]: 102 : m_aExtraneousParas.delete_all_from_doc();
4715 : :
4716 [ + - ]: 102 : UpdateFields();
4717 : :
4718 : : // delete the pam before the call for hide all redlines (Bug 73683)
4719 [ + - ]: 102 : if (mbNewDoc)
4720 [ + - ]: 102 : rDoc.SetRedlineMode((RedlineMode_t)( eMode ));
4721 : :
4722 [ + - ]: 102 : UpdatePageDescs(rDoc, nPageDescOffset);
4723 : :
4724 [ + - ][ + - ]: 102 : delete pPaM, pPaM = 0;
4725 [ + - ][ + - ]: 102 : return nErrRet;
[ + - ][ + - ]
4726 : : }
4727 : :
4728 : 102 : sal_uLong SwWW8ImplReader::SetSubStreams(SvStorageStreamRef &rTableStream,
4729 : : SvStorageStreamRef &rDataStream)
4730 : : {
4731 : 102 : sal_uLong nErrRet = 0;
4732 : : // 6 stands for "6 OR 7", 7 stand for "ONLY 7"
4733 [ - + - ]: 102 : switch (pWwFib->nVersion)
4734 : : {
4735 : : case 6:
4736 : : case 7:
4737 : 0 : pTableStream = pStrm;
4738 : 0 : pDataStream = pStrm;
4739 : 0 : break;
4740 : : case 8:
4741 [ - + ]: 102 : if(!pStg)
4742 : : {
4743 : : OSL_ENSURE( pStg, "Version 8 muss immer einen Storage haben!" );
4744 : 0 : nErrRet = ERR_SWG_READ_ERROR;
4745 : 0 : break;
4746 : : }
4747 : :
4748 : : rTableStream = pStg->OpenSotStream( rtl::OUString::createFromAscii(
4749 : : pWwFib->fWhichTblStm ? SL::a1Table : SL::a0Table),
4750 [ + - ][ + - ]: 102 : STREAM_STD_READ);
[ + - ][ + - ]
[ + - ]
4751 : :
4752 : 102 : pTableStream = &rTableStream;
4753 : 102 : pTableStream->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
4754 : :
4755 : : rDataStream = pStg->OpenSotStream(rtl::OUString(SL::aData),
4756 [ + - ][ + - ]: 102 : STREAM_STD_READ | STREAM_NOCREATE );
[ + - ][ + - ]
4757 : :
4758 [ + + ][ + + ]: 102 : if (rDataStream.Is() && SVSTREAM_OK == rDataStream->GetError())
[ + - ]
4759 : : {
4760 : 42 : pDataStream = &rDataStream;
4761 : 42 : pDataStream->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
4762 : : }
4763 : : else
4764 : 60 : pDataStream = pStrm;
4765 : 102 : break;
4766 : : default:
4767 : : // Programm-Fehler!
4768 : : OSL_ENSURE( !this, "Es wurde vergessen, nVersion zu kodieren!" );
4769 : 0 : nErrRet = ERR_SWG_READ_ERROR;
4770 : 0 : break;
4771 : : }
4772 : 102 : return nErrRet;
4773 : : }
4774 : :
4775 : : namespace
4776 : : {
4777 : 0 : utl::TempFile *MakeTemp(SvFileStream &rSt)
4778 : : {
4779 [ # # ]: 0 : utl::TempFile *pT = new utl::TempFile;
4780 : 0 : pT->EnableKillingFile();
4781 [ # # ]: 0 : rSt.Open(pT->GetFileName(), STREAM_READWRITE | STREAM_SHARE_DENYWRITE);
4782 : 0 : return pT;
4783 : : }
4784 : :
4785 : : #define WW_BLOCKSIZE 0x200
4786 : :
4787 : 0 : void DecryptRC4(msfilter::MSCodec_Std97& rCtx, SvStream &rIn, SvStream &rOut)
4788 : : {
4789 [ # # ]: 0 : rIn.Seek(STREAM_SEEK_TO_END);
4790 : 0 : const sal_Size nLen = rIn.Tell();
4791 [ # # ]: 0 : rIn.Seek(0);
4792 : :
4793 : : sal_uInt8 in[WW_BLOCKSIZE];
4794 [ # # ]: 0 : for (sal_Size nI = 0, nBlock = 0; nI < nLen; nI += WW_BLOCKSIZE, ++nBlock)
4795 : : {
4796 : 0 : sal_Size nBS = (nLen - nI > WW_BLOCKSIZE) ? WW_BLOCKSIZE : nLen - nI;
4797 [ # # ]: 0 : nBS = rIn.Read(in, nBS);
4798 [ # # ]: 0 : rCtx.InitCipher(nBlock);
4799 [ # # ]: 0 : rCtx.Decode(in, nBS, in, nBS);
4800 [ # # ]: 0 : rOut.Write(in, nBS);
4801 : : }
4802 : 0 : }
4803 : :
4804 : 0 : void DecryptXOR(msfilter::MSCodec_XorWord95 &rCtx, SvStream &rIn, SvStream &rOut)
4805 : : {
4806 : 0 : sal_Size nSt = rIn.Tell();
4807 [ # # ]: 0 : rIn.Seek(STREAM_SEEK_TO_END);
4808 : 0 : sal_Size nLen = rIn.Tell();
4809 [ # # ]: 0 : rIn.Seek(nSt);
4810 : :
4811 [ # # ]: 0 : rCtx.InitCipher();
4812 [ # # ]: 0 : rCtx.Skip(nSt);
4813 : :
4814 : : sal_uInt8 in[0x4096];
4815 [ # # ]: 0 : for (sal_Size nI = nSt; nI < nLen; nI += 0x4096)
4816 : : {
4817 : 0 : sal_Size nBS = (nLen - nI > 0x4096 ) ? 0x4096 : nLen - nI;
4818 [ # # ]: 0 : nBS = rIn.Read(in, nBS);
4819 [ # # ]: 0 : rCtx.Decode(in, nBS);
4820 [ # # ]: 0 : rOut.Write(in, nBS);
4821 : : }
4822 : 0 : }
4823 : :
4824 : : //moan, copy and paste :-(
4825 : 0 : String QueryPasswordForMedium(SfxMedium& rMedium)
4826 : : {
4827 [ # # ]: 0 : String aPassw;
4828 : :
4829 : : using namespace com::sun::star;
4830 : :
4831 [ # # ]: 0 : const SfxItemSet* pSet = rMedium.GetItemSet();
4832 : : const SfxPoolItem *pPasswordItem;
4833 : :
4834 [ # # ][ # # ]: 0 : if(pSet && SFX_ITEM_SET == pSet->GetItemState(SID_PASSWORD, sal_True, &pPasswordItem))
[ # # ][ # # ]
4835 [ # # ]: 0 : aPassw = ((const SfxStringItem *)pPasswordItem)->GetValue();
4836 : : else
4837 : : {
4838 : : try
4839 : : {
4840 [ # # ]: 0 : uno::Reference< task::XInteractionHandler > xHandler( rMedium.GetInteractionHandler() );
4841 [ # # ]: 0 : if( xHandler.is() )
4842 : : {
4843 : : ::comphelper::DocPasswordRequest* pRequest = new ::comphelper::DocPasswordRequest(
4844 : : ::comphelper::DocPasswordRequestType_MS, task::PasswordRequestMode_PASSWORD_ENTER,
4845 [ # # ][ # # ]: 0 : INetURLObject( rMedium.GetOrigURL() ).GetName( INetURLObject::DECODE_WITH_CHARSET ) );
[ # # ][ # # ]
[ # # ]
4846 [ # # ]: 0 : uno::Reference< task::XInteractionRequest > xRequest( pRequest );
4847 : :
4848 [ # # ][ # # ]: 0 : xHandler->handle( xRequest );
4849 : :
4850 [ # # ][ # # ]: 0 : if( pRequest->isPassword() )
4851 [ # # ][ # # ]: 0 : aPassw = pRequest->getPassword();
4852 [ # # ]: 0 : }
4853 : : }
4854 [ # # ]: 0 : catch( const uno::Exception& )
4855 : : {
4856 : : }
4857 : : }
4858 : :
4859 : 0 : return aPassw;
4860 : : }
4861 : :
4862 : 0 : uno::Sequence< beans::NamedValue > InitXorWord95Codec( ::msfilter::MSCodec_XorWord95& rCodec, SfxMedium& rMedium, WW8Fib* pWwFib )
4863 : : {
4864 : 0 : uno::Sequence< beans::NamedValue > aEncryptionData;
4865 [ # # ][ # # ]: 0 : SFX_ITEMSET_ARG( rMedium.GetItemSet(), pEncryptionData, SfxUnoAnyItem, SID_ENCRYPTIONDATA, sal_False );
[ # # ]
4866 [ # # ][ # # ]: 0 : if ( pEncryptionData && ( pEncryptionData->GetValue() >>= aEncryptionData ) && !rCodec.InitCodec( aEncryptionData ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
4867 [ # # ]: 0 : aEncryptionData.realloc( 0 );
4868 : :
4869 [ # # ]: 0 : if ( !aEncryptionData.getLength() )
4870 : : {
4871 [ # # ]: 0 : String sUniPassword = QueryPasswordForMedium( rMedium );
4872 : :
4873 : : rtl::OString sPassword(rtl::OUStringToOString(sUniPassword,
4874 [ # # ][ # # ]: 0 : WW8Fib::GetFIBCharset(pWwFib->chseTables)));
[ # # ]
4875 : :
4876 : 0 : sal_Int32 nLen = sPassword.getLength();
4877 [ # # ]: 0 : if( nLen <= 15 )
4878 : : {
4879 : : sal_uInt8 pPassword[16];
4880 : 0 : memcpy(pPassword, sPassword.getStr(), nLen);
4881 : 0 : memset(pPassword+nLen, 0, sizeof(pPassword)-nLen);
4882 : :
4883 [ # # ]: 0 : rCodec.InitKey( pPassword );
4884 [ # # ][ # # ]: 0 : aEncryptionData = rCodec.GetEncryptionData();
[ # # ]
4885 : :
4886 : : // the export supports RC4 algorithm only, so we have to
4887 : : // generate the related EncryptionData as well, so that Save
4888 : : // can export the document without asking for a password;
4889 : : // as result there will be EncryptionData for both algorithms
4890 : : // in the MediaDescriptor
4891 [ # # ]: 0 : ::msfilter::MSCodec_Std97 aCodec97;
4892 : :
4893 : : // Generate random number with a seed of time as salt.
4894 : : TimeValue aTime;
4895 [ # # ]: 0 : osl_getSystemTime( &aTime );
4896 : 0 : rtlRandomPool aRandomPool = rtl_random_createPool();
4897 : 0 : rtl_random_addBytes ( aRandomPool, &aTime, 8 );
4898 : :
4899 : : sal_uInt8 pDocId[ 16 ];
4900 : 0 : rtl_random_getBytes( aRandomPool, pDocId, 16 );
4901 : :
4902 : 0 : rtl_random_destroyPool( aRandomPool );
4903 : :
4904 : : sal_uInt16 pStd97Pass[16];
4905 : 0 : memset( pStd97Pass, 0, sizeof( pStd97Pass ) );
4906 [ # # ]: 0 : for (xub_StrLen nChar = 0; nChar < nLen; ++nChar )
4907 : 0 : pStd97Pass[nChar] = sUniPassword.GetChar(nChar);
4908 : :
4909 [ # # ]: 0 : aCodec97.InitKey( pStd97Pass, pDocId );
4910 : :
4911 : : // merge the EncryptionData, there should be no conflicts
4912 [ # # ]: 0 : ::comphelper::SequenceAsHashMap aEncryptionHash( aEncryptionData );
4913 [ # # ][ # # ]: 0 : aEncryptionHash.update( ::comphelper::SequenceAsHashMap( aCodec97.GetEncryptionData() ) );
[ # # ][ # # ]
[ # # ]
4914 [ # # ][ # # ]: 0 : aEncryptionHash >> aEncryptionData;
[ # # ]
4915 [ # # ]: 0 : }
4916 : : }
4917 : :
4918 : 0 : return aEncryptionData;
4919 : : }
4920 : :
4921 : 0 : uno::Sequence< beans::NamedValue > InitStd97Codec( ::msfilter::MSCodec_Std97& rCodec, sal_uInt8 pDocId[16], SfxMedium& rMedium )
4922 : : {
4923 : 0 : uno::Sequence< beans::NamedValue > aEncryptionData;
4924 [ # # ][ # # ]: 0 : SFX_ITEMSET_ARG( rMedium.GetItemSet(), pEncryptionData, SfxUnoAnyItem, SID_ENCRYPTIONDATA, sal_False );
[ # # ]
4925 [ # # ][ # # ]: 0 : if ( pEncryptionData && ( pEncryptionData->GetValue() >>= aEncryptionData ) && !rCodec.InitCodec( aEncryptionData ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
4926 [ # # ]: 0 : aEncryptionData.realloc( 0 );
4927 : :
4928 [ # # ]: 0 : if ( !aEncryptionData.getLength() )
4929 : : {
4930 [ # # ]: 0 : String sUniPassword = QueryPasswordForMedium( rMedium );
4931 : :
4932 : 0 : xub_StrLen nLen = sUniPassword.Len();
4933 [ # # ]: 0 : if ( nLen <= 15 )
4934 : : {
4935 : : sal_Unicode pPassword[16];
4936 : 0 : memset( pPassword, 0, sizeof( pPassword ) );
4937 [ # # ]: 0 : for (xub_StrLen nChar = 0; nChar < nLen; ++nChar )
4938 : 0 : pPassword[nChar] = sUniPassword.GetChar(nChar);
4939 : :
4940 [ # # ]: 0 : rCodec.InitKey( pPassword, pDocId );
4941 [ # # ][ # # ]: 0 : aEncryptionData = rCodec.GetEncryptionData();
[ # # ]
4942 [ # # ]: 0 : }
4943 : : }
4944 : :
4945 : 0 : return aEncryptionData;
4946 : : }
4947 : : }
4948 : :
4949 : 102 : sal_uLong SwWW8ImplReader::LoadThroughDecryption(SwPaM& rPaM ,WW8Glossary *pGloss)
4950 : : {
4951 : 102 : sal_uLong nErrRet = 0;
4952 [ - + ]: 102 : if (pGloss)
4953 : 0 : pWwFib = pGloss->GetFib();
4954 : : else
4955 [ + - ][ + - ]: 102 : pWwFib = new WW8Fib(*pStrm, nWantedVersion);
4956 : :
4957 [ - + ]: 102 : if (pWwFib->nFibError)
4958 : 0 : nErrRet = ERR_SWG_READ_ERROR;
4959 : :
4960 : 102 : SvStorageStreamRef xTableStream, xDataStream;
4961 : :
4962 [ + - ]: 102 : if (!nErrRet)
4963 [ + - ]: 102 : nErrRet = SetSubStreams(xTableStream, xDataStream);
4964 : :
4965 : 102 : utl::TempFile *pTempMain = 0;
4966 : 102 : utl::TempFile *pTempTable = 0;
4967 : 102 : utl::TempFile *pTempData = 0;
4968 [ + - ]: 102 : SvFileStream aDecryptMain;
4969 [ + - ]: 102 : SvFileStream aDecryptTable;
4970 [ + - ]: 102 : SvFileStream aDecryptData;
4971 : :
4972 : 102 : bool bDecrypt = false;
4973 : 102 : enum {RC4, XOR, Other} eAlgo = Other;
4974 [ - + ][ # # ]: 102 : if (pWwFib->fEncrypted && !nErrRet)
4975 : : {
4976 [ # # ]: 0 : if (!pGloss)
4977 : : {
4978 : 0 : bDecrypt = true;
4979 [ # # ]: 0 : if (8 != pWwFib->nVersion)
4980 : 0 : eAlgo = XOR;
4981 : : else
4982 : : {
4983 [ # # ]: 0 : if (pWwFib->nKey != 0)
4984 : 0 : eAlgo = XOR;
4985 : : else
4986 : : {
4987 [ # # ]: 0 : pTableStream->Seek(0);
4988 : : sal_uInt32 nEncType;
4989 [ # # ]: 0 : *pTableStream >> nEncType;
4990 [ # # ]: 0 : if (nEncType == 0x10001)
4991 : 0 : eAlgo = RC4;
4992 : : }
4993 : : }
4994 : : }
4995 : : }
4996 : :
4997 [ - + ]: 102 : if (bDecrypt)
4998 : : {
4999 : 0 : nErrRet = ERRCODE_SVX_WRONGPASS;
5000 : 0 : SfxMedium* pMedium = mpDocShell->GetMedium();
5001 : :
5002 [ # # ]: 0 : if ( pMedium )
5003 : : {
5004 [ # # # ]: 0 : switch (eAlgo)
5005 : : {
5006 : : default:
5007 : 0 : nErrRet = ERRCODE_SVX_READ_FILTER_CRYPT;
5008 : 0 : break;
5009 : : case XOR:
5010 : : {
5011 [ # # ]: 0 : msfilter::MSCodec_XorWord95 aCtx;
5012 [ # # ]: 0 : uno::Sequence< beans::NamedValue > aEncryptionData = InitXorWord95Codec( aCtx, *pMedium, pWwFib );
5013 : :
5014 : : // if initialization has failed the EncryptionData should be empty
5015 [ # # ][ # # ]: 0 : if ( aEncryptionData.getLength() && aCtx.VerifyKey( pWwFib->nKey, pWwFib->nHash ) )
[ # # ][ # # ]
5016 : : {
5017 : 0 : nErrRet = 0;
5018 [ # # ]: 0 : pTempMain = MakeTemp(aDecryptMain);
5019 : :
5020 [ # # ]: 0 : pStrm->Seek(0);
5021 : : size_t nUnencryptedHdr =
5022 [ # # ]: 0 : (8 == pWwFib->nVersion) ? 0x44 : 0x34;
5023 [ # # ]: 0 : sal_uInt8 *pIn = new sal_uInt8[nUnencryptedHdr];
5024 [ # # ]: 0 : nUnencryptedHdr = pStrm->Read(pIn, nUnencryptedHdr);
5025 [ # # ]: 0 : aDecryptMain.Write(pIn, nUnencryptedHdr);
5026 [ # # ]: 0 : delete [] pIn;
5027 : :
5028 [ # # ]: 0 : DecryptXOR(aCtx, *pStrm, aDecryptMain);
5029 : :
5030 [ # # ][ # # ]: 0 : if (!pTableStream || pTableStream == pStrm)
5031 : 0 : pTableStream = &aDecryptMain;
5032 : : else
5033 : : {
5034 [ # # ]: 0 : pTempTable = MakeTemp(aDecryptTable);
5035 [ # # ]: 0 : DecryptXOR(aCtx, *pTableStream, aDecryptTable);
5036 : 0 : pTableStream = &aDecryptTable;
5037 : : }
5038 : :
5039 [ # # ][ # # ]: 0 : if (!pDataStream || pDataStream == pStrm)
5040 : 0 : pDataStream = &aDecryptMain;
5041 : : else
5042 : : {
5043 [ # # ]: 0 : pTempData = MakeTemp(aDecryptData);
5044 [ # # ]: 0 : DecryptXOR(aCtx, *pDataStream, aDecryptData);
5045 : 0 : pDataStream = &aDecryptData;
5046 : : }
5047 : :
5048 [ # # ][ # # ]: 0 : pMedium->GetItemSet()->ClearItem( SID_PASSWORD );
5049 [ # # ][ # # ]: 0 : pMedium->GetItemSet()->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( aEncryptionData ) ) );
[ # # ][ # # ]
[ # # ]
5050 [ # # ][ # # ]: 0 : }
5051 : : }
5052 : 0 : break;
5053 : : case RC4:
5054 : : {
5055 : : sal_uInt8 aDocId[ 16 ];
5056 : : sal_uInt8 aSaltData[ 16 ];
5057 : : sal_uInt8 aSaltHash[ 16 ];
5058 : :
5059 : : bool bCouldReadHeaders =
5060 [ # # ]: 0 : checkRead(*pTableStream, aDocId, 16) &&
5061 [ # # ]: 0 : checkRead(*pTableStream, aSaltData, 16) &&
5062 [ # # ][ # # ]: 0 : checkRead(*pTableStream, aSaltHash, 16);
[ # # ][ # # ]
5063 : :
5064 [ # # ]: 0 : msfilter::MSCodec_Std97 aCtx;
5065 : : // if initialization has failed the EncryptionData should be empty
5066 [ # # ]: 0 : uno::Sequence< beans::NamedValue > aEncryptionData;
5067 [ # # ]: 0 : if (bCouldReadHeaders)
5068 [ # # ][ # # ]: 0 : aEncryptionData = InitStd97Codec( aCtx, aDocId, *pMedium );
[ # # ]
5069 [ # # ][ # # ]: 0 : if ( aEncryptionData.getLength() && aCtx.VerifyKey( aSaltData, aSaltHash ) )
[ # # ][ # # ]
5070 : : {
5071 : 0 : nErrRet = 0;
5072 : :
5073 [ # # ]: 0 : pTempMain = MakeTemp(aDecryptMain);
5074 : :
5075 [ # # ]: 0 : pStrm->Seek(0);
5076 : 0 : sal_Size nUnencryptedHdr = 0x44;
5077 [ # # ]: 0 : sal_uInt8 *pIn = new sal_uInt8[nUnencryptedHdr];
5078 [ # # ]: 0 : nUnencryptedHdr = pStrm->Read(pIn, nUnencryptedHdr);
5079 : :
5080 [ # # ]: 0 : DecryptRC4(aCtx, *pStrm, aDecryptMain);
5081 : :
5082 [ # # ]: 0 : aDecryptMain.Seek(0);
5083 [ # # ]: 0 : aDecryptMain.Write(pIn, nUnencryptedHdr);
5084 [ # # ]: 0 : delete [] pIn;
5085 : :
5086 : :
5087 [ # # ]: 0 : pTempTable = MakeTemp(aDecryptTable);
5088 [ # # ]: 0 : DecryptRC4(aCtx, *pTableStream, aDecryptTable);
5089 : 0 : pTableStream = &aDecryptTable;
5090 : :
5091 [ # # ][ # # ]: 0 : if (!pDataStream || pDataStream == pStrm)
5092 : 0 : pDataStream = &aDecryptMain;
5093 : : else
5094 : : {
5095 [ # # ]: 0 : pTempData = MakeTemp(aDecryptData);
5096 [ # # ]: 0 : DecryptRC4(aCtx, *pDataStream, aDecryptData);
5097 : 0 : pDataStream = &aDecryptData;
5098 : : }
5099 : :
5100 [ # # ][ # # ]: 0 : pMedium->GetItemSet()->ClearItem( SID_PASSWORD );
5101 [ # # ][ # # ]: 0 : pMedium->GetItemSet()->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( aEncryptionData ) ) );
[ # # ][ # # ]
[ # # ]
5102 [ # # ][ # # ]: 0 : }
5103 : : }
5104 : 0 : break;
5105 : : }
5106 : : }
5107 : :
5108 [ # # ]: 0 : if (nErrRet == 0)
5109 : : {
5110 : 0 : pStrm = &aDecryptMain;
5111 : :
5112 : 0 : delete pWwFib;
5113 [ # # ][ # # ]: 0 : pWwFib = new WW8Fib(*pStrm, nWantedVersion);
5114 [ # # ]: 0 : if (pWwFib->nFibError)
5115 : 0 : nErrRet = ERR_SWG_READ_ERROR;
5116 : : }
5117 : : }
5118 : :
5119 [ + - ]: 102 : if (!nErrRet)
5120 [ + - ]: 102 : nErrRet = CoreLoad(pGloss, *rPaM.GetPoint());
5121 : :
5122 [ - + ][ # # ]: 102 : delete pTempMain;
5123 [ - + ][ # # ]: 102 : delete pTempTable;
5124 [ - + ][ # # ]: 102 : delete pTempData;
5125 : :
5126 [ + - ]: 102 : if (!pGloss)
5127 : 102 : delete pWwFib;
5128 [ + - ][ + - ]: 102 : return nErrRet;
[ + - ][ + - ]
[ + - ]
5129 : : }
5130 : :
5131 : : class outlineeq : public std::unary_function<const SwTxtFmtColl*, bool>
5132 : : {
5133 : : private:
5134 : : sal_uInt8 mnNum;
5135 : : public:
5136 : 33 : outlineeq(sal_uInt8 nNum) : mnNum(nNum) {}
5137 : 582 : bool operator()(const SwTxtFmtColl *pTest) const
5138 : : {
5139 [ + + ][ - + ]: 582 : return pTest->IsAssignedToListLevelOfOutlineStyle() && pTest->GetAssignedOutlineStyleLevel() == mnNum; //<-end,zhaojianwei
5140 : : }
5141 : : };
5142 : :
5143 : 102 : void SwWW8ImplReader::SetOutLineStyles()
5144 : : {
5145 : : /*
5146 : : #i3674# & #101291# Load new document and insert document cases.
5147 : : */
5148 [ + - ]: 102 : SwNumRule aOutlineRule(*rDoc.GetOutlineNumRule());
5149 : : // #i53044,i53213#
5150 : : // <mpChosenOutlineNumRule> has to be set to point to local variable
5151 : : // <aOutlineRule>, because its used below to be compared this <&aOutlineRule>.
5152 : : // But at the end of the method <mpChosenOutlineNumRule> has to be set to
5153 : : // <rDoc.GetOutlineNumRule()>, because <aOutlineRule> will be destroyed.
5154 : 102 : mpChosenOutlineNumRule = &aOutlineRule;
5155 : :
5156 [ + - ]: 102 : sw::ParaStyles aOutLined(sw::util::GetParaStyles(rDoc));
5157 : : // #i98791# - sorting algorithm adjusted
5158 [ + - ]: 102 : sw::util::SortByAssignedOutlineStyleListLevel(aOutLined);
5159 : :
5160 : : typedef sw::ParaStyleIter myParaStyleIter;
5161 : : /*
5162 : : If we are inserted into a document then don't clobber existing existing
5163 : : levels.
5164 : : */
5165 : 102 : sal_uInt16 nFlagsStyleOutlLevel = 0;
5166 [ - + ]: 102 : if (!mbNewDoc)
5167 : : {
5168 : : // #i70748# - backward iteration needed due to the outline level attribute
5169 : 0 : sw::ParaStyles::reverse_iterator aEnd = aOutLined.rend();
5170 [ # # ][ # # ]: 0 : for ( sw::ParaStyles::reverse_iterator aIter = aOutLined.rbegin(); aIter < aEnd; ++aIter)
[ # # ]
5171 : : {
5172 [ # # ][ # # ]: 0 : if ((*aIter)->IsAssignedToListLevelOfOutlineStyle())
5173 [ # # ][ # # ]: 0 : nFlagsStyleOutlLevel |= 1 << (*aIter)->GetAssignedOutlineStyleLevel();//<-end,zhaojianwei
5174 : : else
5175 : 0 : break;
5176 : : }
5177 : : }
5178 : : else
5179 : : {
5180 : : /*
5181 : : Only import *one* of the possible multiple outline numbering rules, so
5182 : : pick the one that affects most styles. If we're not importing a new
5183 : : document, we got to stick with what is already there.
5184 : : */
5185 : : // use index in text format collection array <vColl>
5186 : : // as key of the outline numbering map <aRuleMap>
5187 : : // instead of the memory pointer of the outline numbering rule
5188 : : // to assure that, if two outline numbering rule affect the same
5189 : : // count of text formats, always the same outline numbering rule is chosen.
5190 [ + - ]: 102 : std::map<sal_uInt16, int>aRuleMap;
5191 : : typedef std::map<sal_uInt16, int>::iterator myIter;
5192 [ + + ]: 2220 : for (sal_uInt16 nI = 0; nI < vColl.size(); ++nI)
5193 : : {
5194 : 2118 : SwWW8StyInf& rSI = vColl[ nI ];
5195 [ + + ][ + - ]: 2118 : if (
[ + + ]
5196 : : (MAXLEVEL > rSI.nOutlineLevel) && rSI.pOutlineNumrule &&
5197 : : rSI.pFmt
5198 : : )
5199 : : {
5200 [ + - ]: 33 : myIter aIter = aRuleMap.find(nI);
5201 [ + - ][ + - ]: 33 : if (aIter == aRuleMap.end())
5202 : : {
5203 [ + - ]: 33 : aRuleMap[nI] = 1;
5204 : : }
5205 : : else
5206 [ # # ]: 33 : ++(aIter->second);
5207 : : }
5208 : : }
5209 : :
5210 : 102 : int nMax = 0;
5211 : 102 : myIter aEnd2 = aRuleMap.end();
5212 [ + - ][ + - ]: 135 : for (myIter aIter = aRuleMap.begin(); aIter != aEnd2; ++aIter)
[ + + ]
5213 : : {
5214 [ + - ][ + + ]: 33 : if (aIter->second > nMax)
5215 : : {
5216 [ + - ]: 15 : nMax = aIter->second;
5217 [ + - ][ + - ]: 15 : if(aIter->first < vColl.size())
5218 [ + - ]: 15 : mpChosenOutlineNumRule = vColl[ aIter->first ].pOutlineNumrule;
5219 : : else
5220 : 0 : mpChosenOutlineNumRule = 0; //TODO make sure this is what we want
5221 : : }
5222 : : }
5223 : :
5224 : : OSL_ENSURE(mpChosenOutlineNumRule, "Impossible");
5225 [ + - ]: 102 : if (mpChosenOutlineNumRule)
5226 [ + - ]: 102 : aOutlineRule = *mpChosenOutlineNumRule;
5227 : :
5228 [ + + ]: 102 : if (mpChosenOutlineNumRule != &aOutlineRule)
5229 : : {
5230 : : // #i70748# - backward iteration needed due to the outline level attribute
5231 : 15 : sw::ParaStyles::reverse_iterator aEnd = aOutLined.rend();
5232 [ + - ][ + - ]: 75 : for ( sw::ParaStyles::reverse_iterator aIter = aOutLined.rbegin(); aIter < aEnd; ++aIter)
[ + - ]
5233 : : {
5234 [ + - ][ + + ]: 60 : if((*aIter)->IsAssignedToListLevelOfOutlineStyle())
5235 [ + - ][ + - ]: 45 : (*aIter)->DeleteAssignmentToListLevelOfOutlineStyle(); //<-end
5236 : :
5237 : : else
5238 : 15 : break;
5239 : : }
5240 : 102 : }
5241 : : }
5242 : :
5243 : 102 : sal_uInt16 nOldFlags = nFlagsStyleOutlLevel;
5244 : :
5245 [ + + ]: 2220 : for (sal_uInt16 nI = 0; nI < vColl.size(); ++nI)
5246 : : {
5247 : 2118 : SwWW8StyInf& rSI = vColl[nI];
5248 : :
5249 [ + + ]: 2118 : if (rSI.IsOutlineNumbered())
5250 : : {
5251 : 33 : sal_uInt16 nAktFlags = 1 << rSI.nOutlineLevel;
5252 [ + - ][ - + ]: 33 : if (
5253 : : (nAktFlags & nFlagsStyleOutlLevel) ||
5254 : : (rSI.pOutlineNumrule != mpChosenOutlineNumRule)
5255 : : )
5256 : : {
5257 : : /*
5258 : : If our spot is already taken by something we can't replace
5259 : : then don't insert and remove our outline level.
5260 : : */
5261 : : rSI.pFmt->SetFmtAttr(
5262 [ # # ][ # # ]: 0 : SwNumRuleItem( rSI.pOutlineNumrule->GetName() ) );
[ # # ]
5263 [ # # ]: 0 : ((SwTxtFmtColl*)rSI.pFmt)->DeleteAssignmentToListLevelOfOutlineStyle();//#outline level,zhaojianwei
5264 : : }
5265 : : else
5266 : : {
5267 : : /*
5268 : : If there is a style already set for this outline
5269 : : numbering level and its not a style set by us already
5270 : : then we can remove it outline numbering.
5271 : : (its one of the default headings in a new document
5272 : : so we can clobber it)
5273 : : Of course if we are being inserted into a document that
5274 : : already has some set we can't do this, thats covered by
5275 : : the list of level in nFlagsStyleOutlLevel to ignore.
5276 : : */
5277 : 33 : outlineeq aCmp(rSI.nOutlineLevel);
5278 : : myParaStyleIter aResult = std::find_if(aOutLined.begin(),
5279 [ + - ]: 33 : aOutLined.end(), aCmp);
5280 : :
5281 : 33 : myParaStyleIter aEnd = aOutLined.end();
5282 [ + - ][ - + ]: 33 : while (aResult != aEnd && aCmp(*aResult))
[ # # ][ # # ]
[ # # ][ - + ]
5283 : : {
5284 [ # # ][ # # ]: 0 : (*aResult)->DeleteAssignmentToListLevelOfOutlineStyle();
5285 [ # # ]: 0 : ++aResult;
5286 : : }
5287 : :
5288 : : /*
5289 : : #i1886#
5290 : : I believe that when a list is registered onto a winword
5291 : : style which is an outline numbering style (i.e.
5292 : : nOutlineLevel is set) that the style of numbering is for
5293 : : the level is indexed by the *list* level that was
5294 : : registered on that style, and not the outlinenumbering
5295 : : level, which is probably a logical sequencing, and not a
5296 : : physical mapping into the list style reged on that outline
5297 : : style.
5298 : : */
5299 : 33 : sal_uInt8 nFromLevel = rSI.nListLevel;
5300 : 33 : sal_uInt8 nToLevel = rSI.nOutlineLevel;
5301 [ + - ]: 33 : const SwNumFmt& rRule=rSI.pOutlineNumrule->Get(nFromLevel);
5302 [ + - ]: 33 : aOutlineRule.Set(nToLevel, rRule);
5303 [ + - ]: 33 : ((SwTxtFmtColl*)rSI.pFmt)->AssignToListLevelOfOutlineStyle(nToLevel); //<-end,zhaojianwei
5304 : : // If there are more styles on this level ignore them
5305 : 33 : nFlagsStyleOutlLevel |= nAktFlags;
5306 : : }
5307 : : }
5308 : : }
5309 [ + + ]: 102 : if (nOldFlags != nFlagsStyleOutlLevel)
5310 [ + - ]: 15 : rDoc.SetOutlineNumRule(aOutlineRule);
5311 : : // #i53044,i53213#
5312 [ + + ]: 102 : if ( mpChosenOutlineNumRule == &aOutlineRule )
5313 : : {
5314 : 87 : mpChosenOutlineNumRule = rDoc.GetOutlineNumRule();
5315 [ + - ]: 102 : }
5316 : 102 : }
5317 : :
5318 : 0 : const String* SwWW8ImplReader::GetAnnotationAuthor(sal_uInt16 nIdx)
5319 : : {
5320 [ # # ][ # # ]: 0 : if (!mpAtnNames && pWwFib->lcbGrpStAtnOwners)
5321 : : {
5322 : : // Authoren bestimmen: steht im TableStream
5323 [ # # ]: 0 : mpAtnNames = new ::std::vector<String>;
5324 : 0 : SvStream& rStrm = *pTableStream;
5325 : :
5326 : 0 : long nOldPos = rStrm.Tell();
5327 : 0 : rStrm.Seek( pWwFib->fcGrpStAtnOwners );
5328 : :
5329 : 0 : long nRead = 0, nCount = pWwFib->lcbGrpStAtnOwners;
5330 [ # # ]: 0 : while (nRead < nCount)
5331 : : {
5332 [ # # ]: 0 : if( bVer67 )
5333 : : {
5334 : : mpAtnNames->push_back(read_uInt8_PascalString(rStrm,
5335 [ # # ]: 0 : RTL_TEXTENCODING_MS_1252));
5336 [ # # ]: 0 : nRead += mpAtnNames->rbegin()->Len() + 1; // Laenge + sal_uInt8 Count
5337 : : }
5338 : : else
5339 : : {
5340 [ # # ]: 0 : mpAtnNames->push_back(read_uInt16_PascalString(rStrm));
5341 : : // UNICode: doppelte Laenge + sal_uInt16 Count
5342 [ # # ]: 0 : nRead += mpAtnNames->rbegin()->Len() * 2 + 2;
5343 : : }
5344 : : }
5345 : 0 : rStrm.Seek( nOldPos );
5346 : : }
5347 : :
5348 : 0 : const String *pRet = 0;
5349 [ # # ][ # # ]: 0 : if (mpAtnNames && nIdx < mpAtnNames->size())
[ # # ]
5350 : 0 : pRet = &((*mpAtnNames)[nIdx]);
5351 : 0 : return pRet;
5352 : : }
5353 : :
5354 : 108 : sal_uLong SwWW8ImplReader::LoadDoc( SwPaM& rPaM,WW8Glossary *pGloss)
5355 : : {
5356 : 108 : sal_uLong nErrRet = 0;
5357 : :
5358 : : {
5359 : : static const sal_Char* aNames[ 13 ] = {
5360 : : "WinWord/WW", "WinWord/WW8", "WinWord/WWFT",
5361 : : "WinWord/WWFLX", "WinWord/WWFLY",
5362 : : "WinWord/WWF",
5363 : : "WinWord/WWFA0", "WinWord/WWFA1", "WinWord/WWFA2",
5364 : : "WinWord/WWFB0", "WinWord/WWFB1", "WinWord/WWFB2",
5365 : : "WinWord/RegardHindiDigits"
5366 : : };
5367 : : sal_uInt32 aVal[ 13 ];
5368 : :
5369 [ + - ]: 108 : SwFilterOptions aOpt( 13, aNames, aVal );
5370 : :
5371 : 108 : nIniFlags = aVal[ 0 ];
5372 : 108 : nIniFlags1= aVal[ 1 ];
5373 : : // schiebt Flys um x twips nach rechts o. links
5374 : 108 : nIniFlyDx = aVal[ 3 ];
5375 : 108 : nIniFlyDy = aVal[ 4 ];
5376 : :
5377 : 108 : nFieldFlags = aVal[ 5 ];
5378 : 108 : nFieldTagAlways[0] = aVal[ 6 ];
5379 : 108 : nFieldTagAlways[1] = aVal[ 7 ];
5380 : 108 : nFieldTagAlways[2] = aVal[ 8 ];
5381 : 108 : nFieldTagBad[0] = aVal[ 9 ];
5382 : 108 : nFieldTagBad[1] = aVal[ 10 ];
5383 : 108 : nFieldTagBad[2] = aVal[ 11 ];
5384 [ + - ]: 108 : m_bRegardHindiDigits = aVal[ 12 ] > 0;
5385 : : }
5386 : :
5387 : 108 : sal_uInt16 nMagic(0);
5388 [ + - ]: 108 : *pStrm >> nMagic;
5389 : :
5390 : : // beachte: 6 steht fuer "6 ODER 7", 7 steht fuer "NUR 7"
5391 [ - + - ]: 108 : switch (nWantedVersion)
5392 : : {
5393 : : case 6:
5394 : : case 7:
5395 [ # # ][ # # ]: 0 : if (
[ # # ][ # # ]
5396 : : (0xa5dc != nMagic && 0xa5db != nMagic) &&
5397 : : (nMagic < 0xa697 || nMagic > 0xa699)
5398 : : )
5399 : : {
5400 : : // teste auf eigenen 97-Fake!
5401 [ # # ][ # # ]: 0 : if (pStg && 0xa5ec == nMagic)
5402 : : {
5403 : 0 : sal_uLong nCurPos = pStrm->Tell();
5404 [ # # ][ # # ]: 0 : if (pStrm->Seek(nCurPos + 22))
5405 : : {
5406 : : sal_uInt32 nfcMin;
5407 [ # # ]: 0 : *pStrm >> nfcMin;
5408 [ # # ]: 0 : if (0x300 != nfcMin)
5409 : 0 : nErrRet = ERR_WW6_NO_WW6_FILE_ERR;
5410 : : }
5411 [ # # ]: 0 : pStrm->Seek( nCurPos );
5412 : : }
5413 : : else
5414 : 0 : nErrRet = ERR_WW6_NO_WW6_FILE_ERR;
5415 : : }
5416 : 0 : break;
5417 : : case 8:
5418 [ + + ]: 108 : if (0xa5ec != nMagic)
5419 : 6 : nErrRet = ERR_WW8_NO_WW8_FILE_ERR;
5420 : 108 : break;
5421 : : default:
5422 : 0 : nErrRet = ERR_WW8_NO_WW8_FILE_ERR;
5423 : : OSL_ENSURE( !this, "Es wurde vergessen, nVersion zu kodieren!" );
5424 : 0 : break;
5425 : : }
5426 : :
5427 [ + + ]: 108 : if (!nErrRet)
5428 [ + - ]: 102 : nErrRet = LoadThroughDecryption(rPaM ,pGloss);
5429 : :
5430 [ + - ]: 108 : rDoc.PropagateOutlineRule();
5431 : :
5432 : 108 : return nErrRet;
5433 : : }
5434 : :
5435 : 12 : extern "C" SAL_DLLPUBLIC_EXPORT Reader* SAL_CALL ImportDOC()
5436 : : {
5437 [ + - ]: 12 : return new WW8Reader();
5438 : : }
5439 : :
5440 : 108 : sal_uLong WW8Reader::OpenMainStream( SvStorageStreamRef& rRef, sal_uInt16& rBuffSize )
5441 : : {
5442 : 108 : sal_uLong nRet = ERR_SWG_READ_ERROR;
5443 : : OSL_ENSURE( pStg, "wo ist mein Storage?" );
5444 [ + - ][ + - ]: 108 : rRef = pStg->OpenSotStream( rtl::OUString("WordDocument"), STREAM_READ | STREAM_SHARE_DENYALL);
[ + - ][ + - ]
5445 : :
5446 [ + - ]: 108 : if( rRef.Is() )
5447 : : {
5448 [ + - ]: 108 : if( SVSTREAM_OK == rRef->GetError() )
5449 : : {
5450 : 108 : sal_uInt16 nOld = rRef->GetBufferSize();
5451 : 108 : rRef->SetBufferSize( rBuffSize );
5452 : 108 : rBuffSize = nOld;
5453 : 108 : nRet = 0;
5454 : : }
5455 : : else
5456 : 0 : nRet = rRef->GetError();
5457 : : }
5458 : 108 : return nRet;
5459 : : }
5460 : :
5461 : 111 : sal_uLong WW8Reader::Read(SwDoc &rDoc, const String& rBaseURL, SwPaM &rPam, const String & /* FileName */)
5462 : : {
5463 : 111 : sal_uInt16 nOldBuffSize = 32768;
5464 : 111 : bool bNew = !bInsertMode; // Neues Doc ( kein Einfuegen )
5465 : :
5466 : :
5467 : 111 : SvStorageStreamRef refStrm; // damit uns keiner den Stream klaut
5468 : 111 : SvStream* pIn = pStrm;
5469 : :
5470 : 111 : sal_uLong nRet = 0;
5471 : 111 : sal_uInt8 nVersion = 8;
5472 : :
5473 [ + - ]: 111 : String sFltName = GetFltName();
5474 [ + - ][ - + ]: 111 : if( sFltName.EqualsAscii( "WW6" ) )
5475 : : {
5476 [ # # ]: 0 : if (pStrm)
5477 : 0 : nVersion = 6;
5478 : : else
5479 : : {
5480 : : OSL_ENSURE(!this, "WinWord 95 Reader-Read ohne Stream");
5481 : 0 : nRet = ERR_SWG_READ_ERROR;
5482 : : }
5483 : : }
5484 : : else
5485 : : {
5486 [ + - ][ - + ]: 111 : if( sFltName.EqualsAscii( "CWW6" ) )
5487 : 0 : nVersion = 6;
5488 [ + - ][ - + ]: 111 : else if( sFltName.EqualsAscii( "CWW7" ) )
5489 : 0 : nVersion = 7;
5490 : :
5491 [ + + ]: 111 : if( pStg )
5492 : : {
5493 [ + - ]: 108 : nRet = OpenMainStream( refStrm, nOldBuffSize );
5494 : 108 : pIn = &refStrm;
5495 : : }
5496 : : else
5497 : : {
5498 : : OSL_ENSURE(!this, "WinWord 95/97 Reader-Read ohne Storage");
5499 : 3 : nRet = ERR_SWG_READ_ERROR;
5500 : : }
5501 : : }
5502 : :
5503 [ + + ]: 111 : if( !nRet )
5504 : : {
5505 [ + - ]: 108 : if (bNew)
5506 : : {
5507 : : // MIB 27.09.96: Umrandung uns Abstaende aus Frm-Vorlagen entf.
5508 [ + - ]: 108 : Reader::ResetFrmFmts( rDoc );
5509 : : }
5510 : : SwWW8ImplReader* pRdr = new SwWW8ImplReader(nVersion, pStg, pIn, rDoc,
5511 [ + - ]: 108 : rBaseURL, bNew);
[ + - # # ]
5512 : : try
5513 : : {
5514 [ + - ]: 108 : nRet = pRdr->LoadDoc( rPam );
5515 : : }
5516 : 0 : catch( const std::exception& )
5517 : : {
5518 : 0 : nRet = ERR_WW8_NO_WW8_FILE_ERR;
5519 : : }
5520 [ + - ][ + - ]: 108 : delete pRdr;
5521 : :
5522 [ + - ]: 108 : if( refStrm.Is() )
5523 : : {
5524 [ + - ]: 108 : refStrm->SetBufferSize( nOldBuffSize );
5525 [ + - ]: 108 : refStrm.Clear();
5526 : : }
5527 [ # # ]: 0 : else if (pIn)
5528 [ # # ]: 0 : pIn->ResetError();
5529 : :
5530 : : }
5531 [ + - ][ + - ]: 111 : return nRet;
5532 : : }
5533 : :
5534 : 333 : int WW8Reader::GetReaderType()
5535 : : {
5536 : 333 : return SW_STORAGE_READER | SW_STREAM_READER;
5537 : : }
5538 : :
5539 : 0 : sal_Bool WW8Reader::HasGlossaries() const
5540 : : {
5541 : 0 : return true;
5542 : : }
5543 : :
5544 : 0 : sal_Bool WW8Reader::ReadGlossaries(SwTextBlocks& rBlocks, sal_Bool bSaveRelFiles) const
5545 : : {
5546 : 0 : bool bRet=false;
5547 : :
5548 : 0 : WW8Reader *pThis = const_cast<WW8Reader *>(this);
5549 : :
5550 : 0 : sal_uInt16 nOldBuffSize = 32768;
5551 : 0 : SvStorageStreamRef refStrm;
5552 [ # # ][ # # ]: 0 : if (!pThis->OpenMainStream(refStrm, nOldBuffSize))
5553 : : {
5554 [ # # ]: 0 : WW8Glossary aGloss( refStrm, 8, pStg );
5555 [ # # ][ # # ]: 0 : bRet = aGloss.Load( rBlocks, bSaveRelFiles ? true : false);
5556 : : }
5557 [ # # ]: 0 : return bRet ? true : false;
5558 : : }
5559 : :
5560 : 3 : sal_Bool SwMSDffManager::GetOLEStorageName(long nOLEId, String& rStorageName,
5561 : : SvStorageRef& rSrcStorage, uno::Reference < embed::XStorage >& rDestStorage) const
5562 : : {
5563 : 3 : bool bRet = false;
5564 : :
5565 : 3 : sal_Int32 nPictureId = 0;
5566 [ + - ]: 3 : if (rReader.pStg)
5567 : : {
5568 : : // dann holen wir uns mal ueber den TextBox-PLCF die richtigen
5569 : : // Char Start-/End-Positionen. In dem Bereich sollte dann
5570 : : // das EinbettenFeld und die entsprechenden Sprms zu finden
5571 : : // sein. Wir brauchen hier aber nur das Sprm fuer die Picture Id
5572 : 3 : long nOldPos = rReader.pStrm->Tell();
5573 : : {
5574 : : // #i32596# - consider return value of method
5575 : : // <rReader.GetTxbxTextSttEndCp(..)>. If it returns false, method
5576 : : // wasn't successful. Thus, continue in this case.
5577 : : // Note: Ask MM for initialization of <nStartCp> and <nEndCp>.
5578 : : // Note: Ask MM about assertions in method <rReader.GetTxbxTextSttEndCp(..)>.
5579 : : WW8_CP nStartCp, nEndCp;
5580 [ + - ][ + - ]: 3 : if ( rReader.GetTxbxTextSttEndCp(nStartCp, nEndCp,
5581 : : static_cast<sal_uInt16>((nOLEId >> 16) & 0xFFFF),
5582 : 3 : static_cast<sal_uInt16>(nOLEId & 0xFFFF)) )
5583 : : {
5584 : : WW8PLCFxSaveAll aSave;
5585 : 3 : memset( &aSave, 0, sizeof( aSave ) );
5586 [ + - ]: 3 : rReader.pPlcxMan->SaveAllPLCFx( aSave );
5587 : :
5588 : 3 : nStartCp += rReader.nDrawCpO;
5589 : 3 : nEndCp += rReader.nDrawCpO;
5590 : 3 : WW8PLCFx_Cp_FKP* pChp = rReader.pPlcxMan->GetChpPLCF();
5591 [ + - ][ + - ]: 3 : wwSprmParser aSprmParser(rReader.pWwFib->GetFIBVersion());
5592 [ + - ][ + + ]: 12 : while (nStartCp <= nEndCp && !nPictureId)
[ + + ]
5593 : : {
5594 : 9 : WW8PLCFxDesc aDesc;
5595 [ + - ]: 9 : pChp->SeekPos( nStartCp );
5596 [ + - ]: 9 : pChp->GetSprms( &aDesc );
5597 : :
5598 [ + + ][ + - ]: 9 : if (aDesc.nSprmsLen && aDesc.pMemPos) // Attribut(e) vorhanden
5599 : : {
5600 : 6 : long nLen = aDesc.nSprmsLen;
5601 : 6 : const sal_uInt8* pSprm = aDesc.pMemPos;
5602 : :
5603 [ + + ][ + + ]: 15 : while (nLen >= 2 && !nPictureId)
[ + + ]
5604 : : {
5605 [ + - ]: 9 : sal_uInt16 nId = aSprmParser.GetSprmId(pSprm);
5606 [ + - ]: 9 : sal_uInt16 nSL = aSprmParser.GetSprmSize(nId, pSprm);
5607 : :
5608 [ - + ]: 9 : if( nLen < nSL )
5609 : 0 : break; // nicht mehr genug Bytes uebrig
5610 : :
5611 [ + + ][ + - ]: 9 : if( 0x6A03 == nId && 0 < nLen )
5612 : : {
5613 : : nPictureId = SVBT32ToUInt32(pSprm +
5614 [ + - ]: 3 : aSprmParser.DistanceToData(nId));
5615 : 3 : bRet = true;
5616 : : }
5617 : 9 : pSprm += nSL;
5618 : 9 : nLen -= nSL;
5619 : : }
5620 : : }
5621 : 9 : nStartCp = aDesc.nEndPos;
5622 : : }
5623 : :
5624 [ + - ]: 3 : rReader.pPlcxMan->RestoreAllPLCFx( aSave );
5625 : : }
5626 : : }
5627 : 3 : rReader.pStrm->Seek( nOldPos );
5628 : : }
5629 : :
5630 [ + - ]: 3 : if( bRet )
5631 : : {
5632 : 3 : rStorageName = '_';
5633 [ + - ]: 3 : rStorageName += rtl::OUString::valueOf(nPictureId);
5634 : : rSrcStorage = rReader.pStg->OpenSotStorage(rtl::OUString(
5635 [ + - ][ + - ]: 3 : SL::aObjectPool));
[ + - ][ + - ]
5636 [ - + ]: 3 : if (!rReader.mpDocShell)
5637 : 0 : bRet=false;
5638 : : else
5639 [ + - ]: 3 : rDestStorage = rReader.mpDocShell->GetStorage();
5640 : : }
5641 : 3 : return bRet;
5642 : : }
5643 : :
5644 : 144 : sal_Bool SwMSDffManager::ShapeHasText(sal_uLong, sal_uLong) const
5645 : : {
5646 : : // Zur Zeit des Einlesens einer einzelnen Box, die womoeglich Teil einer
5647 : : // Gruppe ist, liegen noch nicht genuegend Informationen vor, um
5648 : : // entscheiden zu koennen, ob wir sie nicht doch als Textfeld benoetigen.
5649 : : // Also vorsichtshalber mal alle umwandeln:
5650 : 144 : return true;
5651 : : }
5652 : :
5653 : 5694 : bool SwWW8ImplReader::InEqualOrHigherApo(int nLvl) const
5654 : : {
5655 [ + + ]: 5694 : if (nLvl)
5656 : 174 : --nLvl;
5657 : : // #i60827#
5658 : : // check size of <maApos> to assure that <maApos.begin() + nLvl> can be performed.
5659 [ + + ]: 5694 : if ( sal::static_int_cast< sal_Int32>(nLvl) >= sal::static_int_cast< sal_Int32>(maApos.size()) )
5660 : : {
5661 : 9 : return false;
5662 : : }
5663 [ + - ][ + - ]: 5685 : mycApoIter aIter = std::find(maApos.begin() + nLvl, maApos.end(), true);
5664 [ + - ][ + + ]: 5685 : if (aIter != maApos.end())
5665 : 9 : return true;
5666 : : else
5667 : 5694 : return false;
5668 : : }
5669 : :
5670 : 456 : bool SwWW8ImplReader::InEqualApo(int nLvl) const
5671 : : {
5672 : : //If we are in a table, see if an apo was inserted at the level below
5673 : : //the table.
5674 [ + + ]: 456 : if (nLvl)
5675 : 117 : --nLvl;
5676 [ + - ][ - + ]: 456 : if (nLvl < 0 || static_cast<size_t>(nLvl) >= maApos.size())
[ - + ]
5677 : 0 : return false;
5678 : 456 : return maApos[nLvl];
5679 : : }
5680 : :
5681 : : namespace sw
5682 : : {
5683 : : namespace hack
5684 : : {
5685 : 21 : Position::Position(const SwPosition &rPos)
5686 : 21 : : maPtNode(rPos.nNode), mnPtCntnt(rPos.nContent.GetIndex())
5687 : : {
5688 : 21 : }
5689 : :
5690 : 21 : Position::Position(const Position &rPos)
5691 : 21 : : maPtNode(rPos.maPtNode), mnPtCntnt(rPos.mnPtCntnt)
5692 : : {
5693 : 21 : }
5694 : :
5695 : 0 : Position::operator SwPosition() const
5696 : : {
5697 : 0 : SwPosition aRet(maPtNode);
5698 [ # # ][ # # ]: 0 : aRet.nContent.Assign(maPtNode.GetNode().GetCntntNode(), mnPtCntnt);
5699 : 0 : return aRet;
5700 : : }
5701 : : }
5702 [ + - ][ + - ]: 54 : }
5703 : :
5704 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|