Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <doc.hxx>
30 : : #include "writerhelper.hxx"
31 : : #include <com/sun/star/embed/XClassifiedObject.hpp>
32 : :
33 : : #include <algorithm>
34 : : #include <functional>
35 : : #include <osl/endian.h>
36 : : #include <sot/storage.hxx>
37 : : #include <com/sun/star/drawing/XShape.hpp>
38 : : #include <hintids.hxx>
39 : : #include <svx/svdoole2.hxx>
40 : : #include <filter/msfilter/msdffimp.hxx>
41 : : #include <svx/unoapi.hxx>
42 : :
43 : : #include <sot/exchange.hxx>
44 : : #include <swtypes.hxx>
45 : : #include <fmtanchr.hxx>
46 : : #include <fmtcntnt.hxx>
47 : : #include <dcontact.hxx>
48 : : #include <frmfmt.hxx>
49 : : #include <pam.hxx>
50 : : #include <ndgrf.hxx>
51 : : #include <docsh.hxx> // fuer Ole-Node
52 : : #include <mdiexp.hxx> // Progress
53 : : #include <redline.hxx>
54 : : #include <fltshell.hxx>
55 : : #include <unodraw.hxx>
56 : : #include <shellio.hxx>
57 : : #include <ndole.hxx>
58 : :
59 : : #include <svtools/filter.hxx>
60 : :
61 : : #include "ww8scan.hxx"
62 : : #include "ww8par.hxx"
63 : : #include "ww8par2.hxx" // WWFlyPara::BoxUpWidth()
64 : :
65 : : struct OLE_MFP
66 : : {
67 : : sal_Int16 mm; // 0x6 int
68 : : sal_Int16 xExt; // 0x8 int in 1/100 mm
69 : : sal_Int16 yExt; // 0xa int in 1/100 mm
70 : : sal_Int16 hMF; // 0xc int
71 : : };
72 : :
73 : : using namespace ::com::sun::star;
74 : :
75 : 0 : static bool SwWw8ReadScaling(long& rX, long& rY, SvStorageRef& rSrc1)
76 : : {
77 : : // Skalierungsfaktoren holen:
78 : : // Informationen in PIC-Stream ( durch ausprobieren )
79 : : // 0x0 (l)cb
80 : : // 0x08 .. 0x0a Flags ??
81 : : // 0x08 Inh: 1 / 0
82 : : // 0x09 Inh: 0,8,0x18
83 : : // 0x0a Inh: immer 8, MAP_ANISOTROPIC ???
84 : : // 0x0b Inh: immer 0
85 : : // 0x0c, 0x10 Originalgroesse x,y in 1/100 mm
86 : : // 0x14, 0x16 Originalgroesse x,y in tw
87 : : // 0x2c, 0x30 Skalierung x,y in Promille
88 : : // 0x34, 0x38, 0x3c, 0x40 Crop Left, Top, Right, Bot in tw
89 : :
90 : : SvStorageStreamRef xSrc3 = rSrc1->OpenSotStream( rtl::OUString("\3PIC"),
91 [ # # ][ # # ]: 0 : STREAM_STD_READ | STREAM_NOCREATE);
[ # # ]
92 : 0 : SvStorageStream* pS = xSrc3;
93 [ # # ]: 0 : pS->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
94 [ # # ]: 0 : pS->Seek( STREAM_SEEK_TO_END );
95 : :
96 : : OSL_ENSURE( pS->Tell() >= 76, "+OLE-PIC-Stream is shorter than 76 Byte" );
97 : :
98 : : sal_Int32 nOrgWidth,
99 : : nOrgHeight,
100 : : nScaleX,
101 : : nScaleY,
102 : : nCropLeft,
103 : : nCropTop,
104 : : nCropRight,
105 : : nCropBottom;
106 [ # # ]: 0 : pS->Seek( 0x14 );
107 [ # # ]: 0 : *pS >> nOrgWidth // Original Size in 1/100 mm
108 [ # # ]: 0 : >> nOrgHeight;
109 [ # # ]: 0 : pS->Seek( 0x2c );
110 [ # # ]: 0 : *pS >> nScaleX // Scaling in Promille
111 [ # # ]: 0 : >> nScaleY
112 [ # # ]: 0 : >> nCropLeft // Cropping in 1/100 mm
113 [ # # ]: 0 : >> nCropTop
114 [ # # ]: 0 : >> nCropRight
115 [ # # ]: 0 : >> nCropBottom;
116 : :
117 : 0 : rX = nOrgWidth - nCropLeft - nCropRight;
118 : 0 : rY = nOrgHeight - nCropTop - nCropBottom;
119 [ # # ][ # # ]: 0 : if (10 > nScaleX || 65536 < nScaleX || 10 > nScaleY || 65536 < nScaleY)
[ # # ][ # # ]
120 : : {
121 : : OSL_ENSURE( !pS, "+OLE-Scalinginformation in PIC-Stream wrong" );
122 : 0 : return false;
123 : : }
124 : : else
125 : : {
126 : 0 : rX = (rX * nScaleX) / 1000;
127 : 0 : rY = (rY * nScaleY) / 1000;
128 : : }
129 [ # # ]: 0 : return true;
130 : : }
131 : :
132 : 0 : static bool SwWw6ReadMetaStream(GDIMetaFile& rWMF, OLE_MFP* pMfp,
133 : : SvStorageRef& rSrc1)
134 : : {
135 : : SvStorageStreamRef xSrc2 = rSrc1->OpenSotStream( rtl::OUString("\3META"),
136 [ # # ][ # # ]: 0 : STREAM_STD_READ | STREAM_NOCREATE);
[ # # ]
137 : 0 : SvStorageStream* pSt = xSrc2;
138 [ # # ]: 0 : pSt->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
139 [ # # ]: 0 : sal_uLong nRead = pSt->Read( pMfp, sizeof(*pMfp ) );
140 : : // Mini-Placable-Header lesen
141 [ # # ]: 0 : if (nRead != sizeof(*pMfp))
142 : 0 : return false;
143 : :
144 : : #if defined OSL_BIGENDIAN
145 : : pMfp->mm = OSL_SWAPWORD( pMfp->mm );
146 : : pMfp->xExt = OSL_SWAPWORD( pMfp->xExt );
147 : : pMfp->yExt = OSL_SWAPWORD( pMfp->yExt );
148 : : #endif // OSL_BIGENDIAN
149 : :
150 [ # # ][ # # ]: 0 : if( pMfp->mm == 94 || pMfp->mm == 99 )
151 : : {
152 : : OSL_ENSURE( !pSt, "+OLE: Falscher Metafile-Typ" );
153 : 0 : return false;
154 : : }
155 : 0 : if( pMfp->mm != 8 )
156 : : {
157 : : OSL_ENSURE( !pSt, "+OLE: Falscher Metafile-Typ ( nicht Anisotropic )" );
158 : : }
159 [ # # ][ # # ]: 0 : if( !pMfp->xExt || !pMfp->yExt )
160 : : {
161 : : OSL_ENSURE( !pSt, "+OLE: Groesse von 0 ???" );
162 : 0 : return false;
163 : : }
164 [ # # ]: 0 : bool bOk = ReadWindowMetafile( *pSt, rWMF, NULL ) ? true : false; // WMF lesen
165 : : // *pSt >> aWMF geht nicht ohne placable Header
166 [ # # ][ # # ]: 0 : if (!bOk || pSt->GetError() || rWMF.GetActionSize() == 0)
[ # # ][ # # ]
[ # # ]
167 : : {
168 : : OSL_ENSURE( !pSt, "+OLE: Konnte Metafile nicht lesen" );
169 : 0 : return false;
170 : : }
171 : :
172 [ # # ][ # # ]: 0 : rWMF.SetPrefMapMode( MapMode( MAP_100TH_MM ) );
[ # # ]
173 : :
174 : :
175 : : // MetaFile auf neue Groesse skalieren und
176 : : // neue Groesse am MetaFile setzen
177 : 0 : Size aOldSiz( rWMF.GetPrefSize() );
178 : 0 : Size aNewSiz( pMfp->xExt, pMfp->yExt );
179 [ # # ]: 0 : Fraction aFracX( aNewSiz.Width(), aOldSiz.Width() );
180 [ # # ]: 0 : Fraction aFracY( aNewSiz.Height(), aOldSiz.Height() );
181 : :
182 [ # # ]: 0 : rWMF.Scale( aFracX, aFracY );
183 : 0 : rWMF.SetPrefSize( aNewSiz );
184 : :
185 [ # # ]: 0 : return true;
186 : : }
187 : :
188 : 0 : static bool SwWw6ReadMacPICTStream(Graphic& rGraph, SvStorageRef& rSrc1)
189 : : {
190 : : // 03-META-Stream nicht da. Vielleicht ein 03-PICT ?
191 [ # # ][ # # ]: 0 : SvStorageStreamRef xSrc4 = rSrc1->OpenSotStream(rtl::OUString("\3PICT"));
[ # # ]
192 : 0 : SvStorageStream* pStp = xSrc4;
193 [ # # ]: 0 : pStp->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
194 : : sal_uInt8 aTestA[10]; // Ist der 01Ole-Stream ueberhaupt vorhanden
195 [ # # ]: 0 : sal_uLong nReadTst = pStp->Read( aTestA, sizeof( aTestA ) );
196 [ # # ]: 0 : if (nReadTst != sizeof(aTestA))
197 : 0 : return false;
198 : :
199 [ # # ]: 0 : pStp->Seek( STREAM_SEEK_TO_BEGIN );
200 : :
201 : : // Mac-Pict steht im 03PICT-StorageStream allerdings ohne die ersten 512
202 : : // Bytes, die bei einem MAC-PICT egal sind ( werden nicht ausgewertet )
203 [ # # ][ # # ]: 0 : return SwWW8ImplReader::GetPictGrafFromStream(rGraph, *pStp);
204 : : }
205 : :
206 : 0 : SwFlyFrmFmt* SwWW8ImplReader::InsertOle(SdrOle2Obj &rObject,
207 : : const SfxItemSet &rFlySet, const SfxItemSet &rGrfSet)
208 : : {
209 [ # # ]: 0 : SfxObjectShell *pPersist = rDoc.GetPersist();
210 : : OSL_ENSURE(pPersist, "No persist, cannot insert objects correctly");
211 [ # # ]: 0 : if (!pPersist)
212 : 0 : return 0;
213 : :
214 : 0 : SwFlyFrmFmt *pRet = 0;
215 : :
216 : 0 : SfxItemSet *pMathFlySet = 0;
217 [ # # ][ # # ]: 0 : uno::Reference < embed::XClassifiedObject > xClass( rObject.GetObjRef(), uno::UNO_QUERY );
218 [ # # ]: 0 : if( xClass.is() )
219 : : {
220 [ # # ][ # # ]: 0 : SvGlobalName aClassName( xClass->getClassID() );
[ # # ][ # # ]
221 [ # # ][ # # ]: 0 : if (SotExchange::IsMath(aClassName))
222 : : {
223 : : /*
224 : : StarMath sets it own fixed size, so its counter productive to use the
225 : : size word says it is. i.e. Don't attempt to override its size.
226 : : */
227 [ # # ][ # # ]: 0 : pMathFlySet = new SfxItemSet(rFlySet);
228 [ # # ]: 0 : pMathFlySet->ClearItem(RES_FRM_SIZE);
229 [ # # ]: 0 : }
230 : : }
231 : :
232 : : /*
233 : : Take complete responsibility of the object away from SdrOle2Obj and to
234 : : me here locally. This utility class now owns the object.
235 : : */
236 : :
237 : : // TODO/MBA: is the object inserted multiple times here? Testing!
238 : : // And is it a problem that we now use the same naming scheme as in the other apps?
239 [ # # ]: 0 : sw::hack::DrawingOLEAdaptor aOLEObj(rObject, *pPersist);
240 : 0 : ::rtl::OUString sNewName;
241 [ # # ]: 0 : bool bSuccess = aOLEObj.TransferToDoc(sNewName);
242 : :
243 : : OSL_ENSURE(bSuccess, "Insert OLE failed");
244 [ # # ]: 0 : if (bSuccess)
245 : : {
246 [ # # ]: 0 : const SfxItemSet *pFlySet = pMathFlySet ? pMathFlySet : &rFlySet;
247 [ # # ][ # # ]: 0 : pRet = rDoc.InsertOLE(*pPaM, sNewName, rObject.GetAspect(), pFlySet, &rGrfSet, 0);
[ # # ][ # # ]
248 : : }
249 [ # # ][ # # ]: 0 : delete pMathFlySet;
250 [ # # ]: 0 : return pRet;
251 : : }
252 : :
253 : 0 : SwFrmFmt* SwWW8ImplReader::ImportOle(const Graphic* pGrf,
254 : : const SfxItemSet* pFlySet, const SfxItemSet *pGrfSet, const Rectangle& aVisArea )
255 : : {
256 [ # # ]: 0 : ::SetProgressState(nProgress, mpDocShell); // Update
257 : 0 : SwFrmFmt* pFmt = 0;
258 : :
259 [ # # ]: 0 : GrafikCtor();
260 : :
261 [ # # ]: 0 : Graphic aGraph;
262 [ # # ]: 0 : SdrObject* pRet = ImportOleBase(aGraph, pGrf, pFlySet, aVisArea );
263 : :
264 : : // create flyset
265 : 0 : SfxItemSet* pTempSet = 0;
266 [ # # ]: 0 : if( !pFlySet )
267 : : {
268 : 0 : pTempSet = new SfxItemSet( rDoc.GetAttrPool(), RES_FRMATR_BEGIN,
269 [ # # ][ # # ]: 0 : RES_FRMATR_END-1);
270 : :
271 : 0 : pFlySet = pTempSet;
272 : :
273 : : // Abstand/Umrandung raus
274 [ # # ]: 0 : if (!mbNewDoc)
275 [ # # ]: 0 : Reader::ResetFrmFmtAttrs( *pTempSet );
276 : :
277 [ # # ]: 0 : SwFmtAnchor aAnchor( FLY_AS_CHAR );
278 [ # # ]: 0 : aAnchor.SetAnchor( pPaM->GetPoint() );
279 [ # # ]: 0 : pTempSet->Put( aAnchor );
280 : :
281 : : const Size aSizeTwip = OutputDevice::LogicToLogic(
282 [ # # ][ # # ]: 0 : aGraph.GetPrefSize(), aGraph.GetPrefMapMode(), MAP_TWIP );
[ # # ][ # # ]
[ # # ][ # # ]
283 : :
284 : : pTempSet->Put( SwFmtFrmSize( ATT_FIX_SIZE, aSizeTwip.Width(),
285 [ # # ][ # # ]: 0 : aSizeTwip.Height() ) );
[ # # ]
286 [ # # ][ # # ]: 0 : pTempSet->Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME ));
[ # # ]
287 : :
288 [ # # ]: 0 : if( pSFlyPara )
289 : : {
290 : : // OLE im Rahmen ? ok, Rahmen auf Bildgroesse vergroessern (
291 : : // nur wenn Auto-Breite )
292 [ # # ]: 0 : pSFlyPara->BoxUpWidth( aSizeTwip.Width() );
293 [ # # ]: 0 : }
294 : : }
295 : :
296 [ # # ]: 0 : if (pRet) // Ole-Object wurde eingefuegt
297 : : {
298 [ # # ][ # # ]: 0 : if (pRet->ISA(SdrOle2Obj))
[ # # ]
299 : : {
300 [ # # ]: 0 : pFmt = InsertOle(*((SdrOle2Obj*)pRet), *pFlySet, *pGrfSet);
301 [ # # ]: 0 : SdrObject::Free( pRet ); // das brauchen wir nicht mehr
302 : : }
303 : : else
304 [ # # ]: 0 : pFmt = rDoc.Insert(*pPaM, *pRet, pFlySet, NULL);
305 : : }
306 [ # # ][ # # ]: 0 : else if (
[ # # ]
307 [ # # ]: 0 : GRAPHIC_GDIMETAFILE == aGraph.GetType() ||
308 [ # # ]: 0 : GRAPHIC_BITMAP == aGraph.GetType()
309 : : )
310 : : {
311 : : pFmt = rDoc.Insert(*pPaM, aEmptyStr, aEmptyStr, &aGraph, pFlySet,
312 [ # # ]: 0 : pGrfSet, NULL);
313 : : }
314 [ # # ][ # # ]: 0 : delete pTempSet;
315 [ # # ]: 0 : return pFmt;
316 : : }
317 : :
318 : 0 : bool SwWW8ImplReader::ImportOleWMF(SvStorageRef xSrc1,GDIMetaFile &rWMF,
319 : : long &rX,long &rY)
320 : : {
321 : 0 : bool bOk = false;
322 : : OLE_MFP aMfp;
323 [ # # ][ # # ]: 0 : if( SwWw6ReadMetaStream( rWMF, &aMfp, xSrc1 ) )
324 : : {
325 : : /*
326 : : take scaling factor as found in PIC and apply it to graphic.
327 : : */
328 [ # # ]: 0 : SwWw8ReadScaling( rX, rY, xSrc1 );
329 : 0 : Size aFinalSize, aOrigSize;
330 : 0 : aFinalSize.Width() = rX;
331 : 0 : aFinalSize.Height() = rY;
332 : : aFinalSize = OutputDevice::LogicToLogic(
333 [ # # ][ # # ]: 0 : aFinalSize, MAP_TWIP, rWMF.GetPrefMapMode() );
[ # # ]
334 : 0 : aOrigSize = rWMF.GetPrefSize();
335 [ # # ]: 0 : Fraction aScaleX(aFinalSize.Width(),aOrigSize.Width());
336 [ # # ]: 0 : Fraction aScaleY(aFinalSize.Height(),aOrigSize.Height());
337 [ # # ]: 0 : rWMF.Scale( aScaleX, aScaleY );
338 : 0 : bOk = true;
339 : : }
340 : 0 : return bOk;
341 : : }
342 : :
343 : 0 : SdrObject* SwWW8ImplReader::ImportOleBase( Graphic& rGraph,
344 : : const Graphic* pGrf, const SfxItemSet* pFlySet, const Rectangle& aVisArea )
345 : : {
346 : 0 : SdrObject* pRet = 0;
347 : : OSL_ENSURE( pStg, "ohne storage geht hier fast gar nichts!" );
348 : :
349 [ # # ]: 0 : ::SetProgressState( nProgress, rDoc.GetDocShell() ); // Update
350 : :
351 : 0 : long nX=0, nY=0; // nX, nY is graphic size
352 : 0 : bool bOleOk = true;
353 : :
354 [ # # ]: 0 : String aSrcStgName = rtl::OUString('_');
355 : : // ergibt Name "_4711"
356 [ # # ][ # # ]: 0 : aSrcStgName += String::CreateFromInt32( nObjLocFc );
[ # # ]
357 : :
358 [ # # ][ # # ]: 0 : SvStorageRef xSrc0 = pStg->OpenSotStorage(rtl::OUString(SL::aObjectPool));
[ # # ]
359 : : SvStorageRef xSrc1 = xSrc0->OpenSotStorage( aSrcStgName,
360 [ # # ]: 0 : STREAM_READWRITE| STREAM_SHARE_DENYALL );
361 : :
362 : :
363 [ # # ]: 0 : if (pGrf)
364 : : {
365 [ # # ]: 0 : rGraph = *pGrf;
366 : : const Size aSizeTwip = OutputDevice::LogicToLogic(
367 [ # # ][ # # ]: 0 : rGraph.GetPrefSize(), rGraph.GetPrefMapMode(), MAP_TWIP );
[ # # ][ # # ]
[ # # ][ # # ]
368 : 0 : nX = aSizeTwip.Width();
369 : 0 : nY = aSizeTwip.Height();
370 : : }
371 : : else
372 : : {
373 [ # # ]: 0 : GDIMetaFile aWMF;
374 : :
375 [ # # ][ # # ]: 0 : if (ImportOleWMF(xSrc1,aWMF,nX,nY))
[ # # ]
376 [ # # ][ # # ]: 0 : rGraph = Graphic( aWMF );
[ # # ]
377 [ # # ][ # # ]: 0 : else if( SwWw6ReadMacPICTStream( rGraph, xSrc1 ) )
378 : : {
379 : : // 03-META-Stream nicht da. Vielleicht ein 03-PICT ?
380 : : const Size aSizeTwip = OutputDevice::LogicToLogic(
381 [ # # ][ # # ]: 0 : rGraph.GetPrefSize(), rGraph.GetPrefMapMode(), MAP_TWIP );
[ # # ][ # # ]
[ # # ][ # # ]
382 : 0 : nX = aSizeTwip.Width();
383 : 0 : nY = aSizeTwip.Height();
384 : : // PICT: kein WMF da -> Grafik statt OLE
385 : 0 : bOleOk = false;
386 [ # # ]: 0 : }
387 : : } // StorageStreams wieder zu
388 : :
389 : :
390 [ # # ]: 0 : Rectangle aRect(0, 0, nX, nY);
391 : :
392 [ # # ]: 0 : if (pFlySet)
393 : : {
394 [ # # ]: 0 : if (const SwFmtFrmSize* pSize =
395 [ # # ]: 0 : (const SwFmtFrmSize*)pFlySet->GetItem(RES_FRM_SIZE, false))
396 : : {
397 [ # # ]: 0 : aRect.SetSize(pSize->GetSize());
398 : : }
399 : : }
400 : :
401 [ # # ][ # # ]: 0 : if (!(bIsHeader || bIsFooter))
402 : : {
403 : : //Can't put them in headers/footers :-(
404 : 0 : uno::Reference< drawing::XShape > xRef;
405 : : OSL_ENSURE(pFormImpl, "Impossible");
406 [ # # ][ # # ]: 0 : if (pFormImpl && pFormImpl->ReadOCXStream(xSrc1, &xRef, false))
[ # # ][ # # ]
407 : : {
408 : 0 : pRet = GetSdrObjectFromXShape(xRef);
409 : : OSL_ENSURE(pRet, "Impossible");
410 [ # # ]: 0 : if (pRet)
411 [ # # ]: 0 : pRet->SetLogicRect(aRect);
412 : 0 : return pRet;
413 [ # # ]: 0 : }
414 : : }
415 : :
416 [ # # ][ # # ]: 0 : if (GRAPHIC_GDIMETAFILE == rGraph.GetType() ||
[ # # ][ # # ]
417 [ # # ]: 0 : GRAPHIC_BITMAP == rGraph.GetType())
418 : : {
419 [ # # ]: 0 : ::SetProgressState(nProgress, mpDocShell); // Update
420 : :
421 [ # # ]: 0 : if (bOleOk)
422 : : {
423 : 0 : sal_uLong nOldPos = pDataStream->Tell();
424 [ # # ]: 0 : pDataStream->Seek(STREAM_SEEK_TO_END);
425 : 0 : SvStream *pTmpData = 0;
426 [ # # ]: 0 : if (nObjLocFc < pDataStream->Tell())
427 : : {
428 : 0 : pTmpData = pDataStream;
429 [ # # ]: 0 : pTmpData->Seek( nObjLocFc );
430 : : }
431 : :
432 : 0 : sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
433 : :
434 : : {
435 : : SvStorageStreamRef xObjInfoSrc = xSrc1->OpenSotStream(rtl::OUString("\3ObjInfo"),
436 [ # # ][ # # ]: 0 : STREAM_STD_READ | STREAM_NOCREATE );
[ # # ]
437 [ # # ][ # # ]: 0 : if ( xObjInfoSrc.Is() && !xObjInfoSrc->GetError() )
[ # # ]
438 : : {
439 : 0 : sal_uInt8 nByte = 0;
440 [ # # ]: 0 : *xObjInfoSrc >> nByte;
441 [ # # ]: 0 : if ( ( nByte >> 4 ) & embed::Aspects::MSOLE_ICON )
442 : 0 : nAspect = embed::Aspects::MSOLE_ICON;
443 [ # # ]: 0 : }
444 : : }
445 : :
446 : 0 : ErrCode nError = ERRCODE_NONE;
447 : : pRet = SvxMSDffManager::CreateSdrOLEFromStorage(
448 : : aSrcStgName, xSrc0, mpDocShell->GetStorage(), rGraph, aRect, aVisArea, pTmpData, nError,
449 [ # # ][ # # ]: 0 : SwMSDffManager::GetFilterFlags(), nAspect );
[ # # ]
450 [ # # ]: 0 : pDataStream->Seek( nOldPos );
451 : : }
452 : : }
453 [ # # ][ # # ]: 0 : return pRet;
[ # # ]
454 : : }
455 : :
456 : 72 : void SwWW8ImplReader::ReadRevMarkAuthorStrTabl( SvStream& rStrm,
457 : : sal_Int32 nTblPos, sal_Int32 nTblSiz, SwDoc& rDocOut )
458 : : {
459 [ + - ]: 72 : ::std::vector<String> aAuthorNames;
460 : 72 : WW8ReadSTTBF( !bVer67, rStrm, nTblPos, nTblSiz, bVer67 ? 2 : 0,
461 [ - + ][ + - ]: 72 : eStructCharSet, aAuthorNames );
462 : :
463 : 72 : sal_uInt16 nCount = static_cast< sal_uInt16 >(aAuthorNames.size());
464 [ + + ]: 50061 : for( sal_uInt16 nAuthor = 0; nAuthor < nCount; ++nAuthor )
465 : : {
466 : : // Store author in doc
467 [ + - ][ + - ]: 49989 : sal_uInt16 nSWId = rDocOut.InsertRedlineAuthor(aAuthorNames[nAuthor]);
468 : : // Store matchpair
469 [ + - ]: 49989 : m_aAuthorInfos[nAuthor] = nSWId;
470 : 72 : }
471 : 72 : }
472 : :
473 : : /*
474 : : Revision Marks ( == Redlining )
475 : : */
476 : : // insert or delete content (change char attributes resp.)
477 : 0 : void SwWW8ImplReader::Read_CRevisionMark(RedlineType_t eType,
478 : : const sal_uInt8* pData, short nLen )
479 : : {
480 : : // there *must* be a SprmCIbstRMark[Del] and a SprmCDttmRMark[Del]
481 : : // pointing to the very same char position as our SprmCFRMark[Del]
482 [ # # ]: 0 : if (!pPlcxMan)
483 : 0 : return;
484 : : const sal_uInt8* pSprmCIbstRMark;
485 : : const sal_uInt8* pSprmCDttmRMark;
486 [ # # ]: 0 : if( nsRedlineType_t::REDLINE_FORMAT == eType )
487 : : {
488 : 0 : pSprmCIbstRMark = pData+1;
489 : 0 : pSprmCDttmRMark = pData+3;
490 : : }
491 : : else
492 : : {
493 : : /*
494 : : It is possible to have a number of date stamps for the created time
495 : : of the change, (possibly a word bug) so we must use the "get a full
496 : : list" varient of HasCharSprm and take the last one as the true one.
497 : : */
498 [ # # ]: 0 : std::vector<const sal_uInt8 *> aResult;
499 : 0 : bool bIns = (nsRedlineType_t::REDLINE_INSERT == eType);
500 [ # # ]: 0 : if( bVer67 )
501 : : {
502 [ # # ]: 0 : pPlcxMan->HasCharSprm(69, aResult);
503 [ # # ][ # # ]: 0 : pSprmCIbstRMark = aResult.empty() ? 0 : aResult.back();
504 : 0 : aResult.clear();
505 [ # # ]: 0 : pPlcxMan->HasCharSprm(70, aResult);
506 [ # # ][ # # ]: 0 : pSprmCDttmRMark = aResult.empty() ? 0 : aResult.back();
507 : : }
508 : : else
509 : : {
510 [ # # ][ # # ]: 0 : pPlcxMan->HasCharSprm( bIns ? 0x4804 : 0x4863, aResult);
511 [ # # ][ # # ]: 0 : pSprmCIbstRMark = aResult.empty() ? 0 : aResult.back();
512 : 0 : aResult.clear();
513 [ # # ][ # # ]: 0 : pPlcxMan->HasCharSprm( bIns ? 0x6805 : 0x6864, aResult);
514 [ # # ][ # # ]: 0 : pSprmCDttmRMark = aResult.empty() ? 0 : aResult.back();
515 : 0 : }
516 : : }
517 : :
518 [ # # ]: 0 : if (nLen < 0)
519 : 0 : mpRedlineStack->close(*pPaM->GetPoint(), eType, pTableDesc );
520 : : else
521 : : {
522 : : // start of new revision mark, if not there default to first entry
523 [ # # ]: 0 : sal_uInt16 nWWAutNo = pSprmCIbstRMark ? SVBT16ToShort(pSprmCIbstRMark) : 0;
524 [ # # ]: 0 : sal_uInt32 nWWDate = pSprmCDttmRMark ? SVBT32ToUInt32(pSprmCDttmRMark): 0;
525 [ # # ]: 0 : DateTime aStamp(msfilter::util::DTTM2DateTime(nWWDate));
526 [ # # ]: 0 : sal_uInt16 nAuthorNo = m_aAuthorInfos[nWWAutNo];
527 [ # # ]: 0 : SwFltRedline aNewAttr(eType, nAuthorNo, aStamp);
528 [ # # ][ # # ]: 0 : NewAttr(aNewAttr);
529 : : }
530 : : }
531 : :
532 : : // insert new content
533 : 0 : void SwWW8ImplReader::Read_CFRMark(sal_uInt16 , const sal_uInt8* pData, short nLen)
534 : : {
535 : 0 : Read_CRevisionMark( nsRedlineType_t::REDLINE_INSERT, pData, nLen );
536 : 0 : }
537 : :
538 : : // delete old content
539 : 0 : void SwWW8ImplReader::Read_CFRMarkDel(sal_uInt16 , const sal_uInt8* pData, short nLen)
540 : : {
541 : 0 : Read_CRevisionMark( nsRedlineType_t::REDLINE_DELETE, pData, nLen );
542 : 0 : }
543 : :
544 : : // change properties of content ( == char formating)
545 : 0 : void SwWW8ImplReader::Read_CPropRMark(sal_uInt16 , const sal_uInt8* pData, short nLen)
546 : : {
547 : : // complex (len is always 7)
548 : : // 1 byte - chp.fPropRMark
549 : : // 2 bytes - chp.ibstPropRMark
550 : : // 4 bytes - chp.dttmPropRMark;
551 : 0 : Read_CRevisionMark( nsRedlineType_t::REDLINE_FORMAT, pData, nLen );
552 [ + - ][ + - ]: 54 : }
553 : :
554 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|