1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5efeef26fSAndrew Rist * distributed with this work for additional information
6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10efeef26fSAndrew Rist *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist *
13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist * software distributed under the License is distributed on an
15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17efeef26fSAndrew Rist * specific language governing permissions and limitations
18efeef26fSAndrew Rist * under the License.
19efeef26fSAndrew Rist *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
27cdf0e10cSrcweir
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include <iterator>
30cdf0e10cSrcweir #include <hintids.hxx>
31cdf0e10cSrcweir #include <svl/urihelper.hxx>
32cdf0e10cSrcweir #include <svx/svdpage.hxx>
33cdf0e10cSrcweir #include <svx/svdmodel.hxx>
34cdf0e10cSrcweir #include <svx/svdograf.hxx>
35cdf0e10cSrcweir #include <svx/svdoole2.hxx>
36cdf0e10cSrcweir #include <editeng/opaqitem.hxx>
37cdf0e10cSrcweir #include <filter/msfilter/msdffimp.hxx>
38cdf0e10cSrcweir #include <sfx2/app.hxx>
39cdf0e10cSrcweir #include <sfx2/docfile.hxx>
40cdf0e10cSrcweir #include <sfx2/fcontnr.hxx>
41cdf0e10cSrcweir #include <grfatr.hxx> // class SwCropGrf
42cdf0e10cSrcweir #include <fmtflcnt.hxx>
43cdf0e10cSrcweir #include <fmtanchr.hxx>
44cdf0e10cSrcweir #include <frmfmt.hxx>
45cdf0e10cSrcweir #include <fltshell.hxx>
46cdf0e10cSrcweir #include <pam.hxx>
47cdf0e10cSrcweir #include <doc.hxx>
48cdf0e10cSrcweir #include <ndtxt.hxx> // class SwTxtNode
49cdf0e10cSrcweir #include <mdiexp.hxx> // Progress
50cdf0e10cSrcweir #include "writerwordglue.hxx"
51cdf0e10cSrcweir #include "ww8struc.hxx"
52cdf0e10cSrcweir #include "ww8scan.hxx"
53cdf0e10cSrcweir #include "ww8par.hxx" // class SwWWImplReader
54cdf0e10cSrcweir #include "ww8par2.hxx" // struct WWFlyPara
55cdf0e10cSrcweir #include "ww8graf.hxx"
56cdf0e10cSrcweir #include <svtools/filter.hxx>
57cdf0e10cSrcweir
58cdf0e10cSrcweir using namespace ::com::sun::star;
59cdf0e10cSrcweir using namespace sw::types;
60cdf0e10cSrcweir
wwZOrderer(const sw::util::SetLayer & rSetLayer,SdrPage * pDrawPg,const SvxMSDffShapeOrders * pShapeOrders)61cdf0e10cSrcweir wwZOrderer::wwZOrderer(const sw::util::SetLayer &rSetLayer, SdrPage* pDrawPg,
62cdf0e10cSrcweir const SvxMSDffShapeOrders *pShapeOrders)
63cdf0e10cSrcweir : maSetLayer(rSetLayer), mnInlines(0), mpDrawPg(pDrawPg),
64cdf0e10cSrcweir mpShapeOrders(pShapeOrders)
65cdf0e10cSrcweir {
66cdf0e10cSrcweir mnNoInitialObjects = mpDrawPg->GetObjCount();
67cdf0e10cSrcweir ASSERT(mpDrawPg,"Missing draw page impossible!");
68cdf0e10cSrcweir }
69cdf0e10cSrcweir
InsideEscher(sal_uLong nSpId)70cdf0e10cSrcweir void wwZOrderer::InsideEscher(sal_uLong nSpId)
71cdf0e10cSrcweir {
72cdf0e10cSrcweir maIndexes.push(GetEscherObjectIdx(nSpId));
73cdf0e10cSrcweir }
74cdf0e10cSrcweir
OutsideEscher()75cdf0e10cSrcweir void wwZOrderer::OutsideEscher()
76cdf0e10cSrcweir {
77cdf0e10cSrcweir maIndexes.pop();
78cdf0e10cSrcweir }
79cdf0e10cSrcweir
80cdf0e10cSrcweir // --> OD 2004-12-13 #117915# - consider new parameter <_bInHeaderFooter>
InsertEscherObject(SdrObject * pObject,sal_uLong nSpId,const bool _bInHeaderFooter)81cdf0e10cSrcweir void wwZOrderer::InsertEscherObject( SdrObject* pObject,
82cdf0e10cSrcweir sal_uLong nSpId,
83cdf0e10cSrcweir const bool _bInHeaderFooter )
84cdf0e10cSrcweir {
85cdf0e10cSrcweir sal_uLong nInsertPos = GetEscherObjectPos( nSpId, _bInHeaderFooter );
86cdf0e10cSrcweir // <--
87cdf0e10cSrcweir InsertObject(pObject, nInsertPos + mnNoInitialObjects + mnInlines);
88cdf0e10cSrcweir }
89cdf0e10cSrcweir
MapEscherIdxToIter(sal_uLong nIdx)90cdf0e10cSrcweir wwZOrderer::myeiter wwZOrderer::MapEscherIdxToIter(sal_uLong nIdx)
91cdf0e10cSrcweir {
92cdf0e10cSrcweir myeiter aIter = maEscherLayer.begin();
93cdf0e10cSrcweir myeiter aEnd = maEscherLayer.end();
94cdf0e10cSrcweir while (aIter != aEnd)
95cdf0e10cSrcweir {
96cdf0e10cSrcweir if (aIter->mnEscherShapeOrder == nIdx)
97cdf0e10cSrcweir break;
98cdf0e10cSrcweir ++aIter;
99cdf0e10cSrcweir }
100cdf0e10cSrcweir return aIter;
101cdf0e10cSrcweir }
102cdf0e10cSrcweir
GetEscherObjectIdx(sal_uLong nSpId)103cdf0e10cSrcweir sal_uInt16 wwZOrderer::GetEscherObjectIdx(sal_uLong nSpId)
104cdf0e10cSrcweir {
105cdf0e10cSrcweir sal_uInt16 nFound=0;
106cdf0e10cSrcweir sal_uInt16 nShapeCount = mpShapeOrders ? mpShapeOrders->Count() : 0;
107cdf0e10cSrcweir // First, find out what position this shape is in in the Escher order.
108cdf0e10cSrcweir for (sal_uInt16 nShapePos=0; nShapePos < nShapeCount; nShapePos++)
109cdf0e10cSrcweir {
110cdf0e10cSrcweir const SvxMSDffShapeOrder *pOrder = mpShapeOrders->GetObject(nShapePos);
111cdf0e10cSrcweir if (pOrder->nShapeId == nSpId)
112cdf0e10cSrcweir {
113cdf0e10cSrcweir nFound = nShapePos;
114cdf0e10cSrcweir break;
115cdf0e10cSrcweir }
116cdf0e10cSrcweir }
117cdf0e10cSrcweir return nFound;
118cdf0e10cSrcweir }
119cdf0e10cSrcweir
120cdf0e10cSrcweir // --> OD 2004-12-13 #117915# - consider new parameter <_bInHeaderFooter>
GetEscherObjectPos(sal_uLong nSpId,const bool _bInHeaderFooter)121cdf0e10cSrcweir sal_uLong wwZOrderer::GetEscherObjectPos( sal_uLong nSpId,
122cdf0e10cSrcweir const bool _bInHeaderFooter )
123cdf0e10cSrcweir {
124cdf0e10cSrcweir /*
125cdf0e10cSrcweir #97824# EscherObjects have their own ordering which needs to be matched to
126cdf0e10cSrcweir the actual ordering that should be used when inserting them into the
127cdf0e10cSrcweir document.
128cdf0e10cSrcweir */
129cdf0e10cSrcweir sal_uInt16 nFound = GetEscherObjectIdx(nSpId);
130cdf0e10cSrcweir // Match the ordering position from the ShapeOrders to the ordering of all
131cdf0e10cSrcweir // objects in the document, there is a complexity when escherobjects
132cdf0e10cSrcweir // contain inlines objects, we need to consider thsose as part of the
133cdf0e10cSrcweir // escher count
134cdf0e10cSrcweir sal_uLong nRet=0;
135cdf0e10cSrcweir myeiter aIter = maEscherLayer.begin();
136cdf0e10cSrcweir myeiter aEnd = maEscherLayer.end();
137cdf0e10cSrcweir // --> OD 2004-12-13 #117915# - skip objects in page header|footer, if
138cdf0e10cSrcweir // current object isn't in page header|footer
139cdf0e10cSrcweir if ( !_bInHeaderFooter )
140cdf0e10cSrcweir {
141cdf0e10cSrcweir while ( aIter != aEnd )
142cdf0e10cSrcweir {
143cdf0e10cSrcweir if ( !aIter->mbInHeaderFooter )
144cdf0e10cSrcweir {
145cdf0e10cSrcweir break;
146cdf0e10cSrcweir }
147cdf0e10cSrcweir nRet += aIter->mnNoInlines + 1;
148cdf0e10cSrcweir ++aIter;
149cdf0e10cSrcweir }
150cdf0e10cSrcweir }
151cdf0e10cSrcweir // <--
152cdf0e10cSrcweir while (aIter != aEnd)
153cdf0e10cSrcweir {
154cdf0e10cSrcweir // --> OD 2004-12-13 #117915# - insert object in page header|footer
155cdf0e10cSrcweir // before objects in page body
156cdf0e10cSrcweir if ( _bInHeaderFooter && !aIter->mbInHeaderFooter )
157cdf0e10cSrcweir {
158cdf0e10cSrcweir break;
159cdf0e10cSrcweir }
160cdf0e10cSrcweir // <--
161cdf0e10cSrcweir if ( aIter->mnEscherShapeOrder > nFound )
162cdf0e10cSrcweir break;
163cdf0e10cSrcweir nRet += aIter->mnNoInlines+1;
164cdf0e10cSrcweir ++aIter;
165cdf0e10cSrcweir }
166cdf0e10cSrcweir maEscherLayer.insert(aIter, EscherShape( nFound, _bInHeaderFooter ) );
167cdf0e10cSrcweir return nRet;
168cdf0e10cSrcweir }
169cdf0e10cSrcweir // <--
170cdf0e10cSrcweir
171cdf0e10cSrcweir // InsertObj() fuegt das Objekt in die Sw-Page ein und merkt sich die Z-Pos in
172cdf0e10cSrcweir // einem VarArr
InsertDrawingObject(SdrObject * pObj,short nWwHeight)173cdf0e10cSrcweir void wwZOrderer::InsertDrawingObject(SdrObject* pObj, short nWwHeight)
174cdf0e10cSrcweir {
175cdf0e10cSrcweir sal_uLong nPos = GetDrawingObjectPos(nWwHeight);
176cdf0e10cSrcweir if (nWwHeight & 0x2000) // Heaven ?
177cdf0e10cSrcweir maSetLayer.SendObjectToHeaven(*pObj);
178cdf0e10cSrcweir else
179cdf0e10cSrcweir maSetLayer.SendObjectToHell(*pObj);
180cdf0e10cSrcweir
181cdf0e10cSrcweir InsertObject(pObj, nPos + mnNoInitialObjects + mnInlines);
182cdf0e10cSrcweir }
183cdf0e10cSrcweir
InsertTextLayerObject(SdrObject * pObject)184cdf0e10cSrcweir void wwZOrderer::InsertTextLayerObject(SdrObject* pObject)
185cdf0e10cSrcweir {
186cdf0e10cSrcweir maSetLayer.SendObjectToHeaven(*pObject);
187cdf0e10cSrcweir if (maIndexes.empty())
188cdf0e10cSrcweir {
189cdf0e10cSrcweir InsertObject(pObject, mnNoInitialObjects + mnInlines);
190cdf0e10cSrcweir ++mnInlines;
191cdf0e10cSrcweir }
192cdf0e10cSrcweir else
193cdf0e10cSrcweir {
194cdf0e10cSrcweir //If we are inside an escher objects, place us just after that
195cdf0e10cSrcweir //escher obj, and increment its inline count
196cdf0e10cSrcweir sal_uInt16 nIdx = maIndexes.top();
197cdf0e10cSrcweir myeiter aEnd = MapEscherIdxToIter(nIdx);
198cdf0e10cSrcweir
199cdf0e10cSrcweir sal_uLong nInsertPos=0;
200cdf0e10cSrcweir myeiter aIter = maEscherLayer.begin();
201cdf0e10cSrcweir while (aIter != aEnd)
202cdf0e10cSrcweir {
203cdf0e10cSrcweir nInsertPos += aIter->mnNoInlines+1;
204cdf0e10cSrcweir ++aIter;
205cdf0e10cSrcweir }
206cdf0e10cSrcweir
207cdf0e10cSrcweir ASSERT(aEnd != maEscherLayer.end(), "Something very wrong here");
208cdf0e10cSrcweir if (aEnd != maEscherLayer.end())
209cdf0e10cSrcweir {
210cdf0e10cSrcweir aEnd->mnNoInlines++;
211cdf0e10cSrcweir nInsertPos += aEnd->mnNoInlines;
212cdf0e10cSrcweir }
213cdf0e10cSrcweir
214cdf0e10cSrcweir InsertObject(pObject, mnNoInitialObjects + mnInlines + nInsertPos);
215cdf0e10cSrcweir }
216cdf0e10cSrcweir }
217cdf0e10cSrcweir
218cdf0e10cSrcweir // Parallel zu dem Obj-Array im Dokument baue ich ein Array auf,
219cdf0e10cSrcweir // dass die Ww-Height ( -> Wer ueberdeckt wen ) beinhaltet.
220cdf0e10cSrcweir // Anhand dieses VARARR wird die Einfuegeposition ermittelt.
221cdf0e10cSrcweir // Der Offset bei Datei in bestehendes Dokument mit Grafiklayer einfuegen
222cdf0e10cSrcweir // muss der Aufrufer den Index um mnNoInitialObjects erhoeht werden, damit die
223cdf0e10cSrcweir // neuen Objekte am Ende landen ( Einfuegen ist dann schneller )
GetDrawingObjectPos(short nWwHeight)224cdf0e10cSrcweir sal_uLong wwZOrderer::GetDrawingObjectPos(short nWwHeight)
225cdf0e10cSrcweir {
226cdf0e10cSrcweir myditer aIter = maDrawHeight.begin();
227cdf0e10cSrcweir myditer aEnd = maDrawHeight.end();
228cdf0e10cSrcweir
229cdf0e10cSrcweir while (aIter != aEnd)
230cdf0e10cSrcweir {
231cdf0e10cSrcweir if ((*aIter & 0x1fff) > (nWwHeight & 0x1fff))
232cdf0e10cSrcweir break;
233cdf0e10cSrcweir ++aIter;
234cdf0e10cSrcweir }
235cdf0e10cSrcweir
236cdf0e10cSrcweir aIter = maDrawHeight.insert(aIter, nWwHeight);
237cdf0e10cSrcweir return std::distance(maDrawHeight.begin(), aIter);
238cdf0e10cSrcweir }
239cdf0e10cSrcweir
InsertObject(SdrObject * pObject,sal_uLong nPos)240cdf0e10cSrcweir bool wwZOrderer::InsertObject(SdrObject* pObject, sal_uLong nPos)
241cdf0e10cSrcweir {
242cdf0e10cSrcweir if (!pObject->IsInserted())
243cdf0e10cSrcweir {
244cdf0e10cSrcweir mpDrawPg->InsertObject(pObject, nPos);
245cdf0e10cSrcweir return true;
246cdf0e10cSrcweir }
247cdf0e10cSrcweir return false;
248cdf0e10cSrcweir }
249cdf0e10cSrcweir
250cdf0e10cSrcweir #ifdef __WW8_NEEDS_COPY
251cdf0e10cSrcweir extern void WW8PicShadowToReal( WW8_PIC_SHADOW* pPicS, WW8_PIC* pPic );
252cdf0e10cSrcweir #endif // defined __WW8_NEEDS_COPY
253cdf0e10cSrcweir
GetPictGrafFromStream(Graphic & rGraphic,SvStream & rSrc)254cdf0e10cSrcweir bool SwWW8ImplReader::GetPictGrafFromStream(Graphic& rGraphic, SvStream& rSrc)
255cdf0e10cSrcweir {
256cdf0e10cSrcweir return 0 == GraphicFilter::GetGraphicFilter()->ImportGraphic(rGraphic, aEmptyStr, rSrc,
257cdf0e10cSrcweir GRFILTER_FORMAT_DONTKNOW);
258cdf0e10cSrcweir }
259cdf0e10cSrcweir
ReadGrafFile(String & rFileName,Graphic * & rpGraphic,const WW8_PIC & rPic,SvStream * pSt,sal_uLong nFilePos,bool * pbInDoc)260cdf0e10cSrcweir bool SwWW8ImplReader::ReadGrafFile(String& rFileName, Graphic*& rpGraphic,
261cdf0e10cSrcweir const WW8_PIC& rPic, SvStream* pSt, sal_uLong nFilePos, bool* pbInDoc)
262cdf0e10cSrcweir { // Grafik in File schreiben
263cdf0e10cSrcweir *pbInDoc = true; // default
264cdf0e10cSrcweir
265cdf0e10cSrcweir sal_uLong nPosFc = nFilePos + rPic.cbHeader;
266cdf0e10cSrcweir
267cdf0e10cSrcweir switch (rPic.MFP.mm)
268cdf0e10cSrcweir {
269cdf0e10cSrcweir case 94: // BMP-File ( nicht embeddet ) oder GIF
270cdf0e10cSrcweir case 99: // TIFF-File ( nicht embeddet )
271cdf0e10cSrcweir pSt->Seek(nPosFc);
272cdf0e10cSrcweir // Name als P-String einlesen
273cdf0e10cSrcweir rFileName = WW8ReadPString(*pSt, eStructCharSet, 0);
274cdf0e10cSrcweir if (rFileName.Len())
275cdf0e10cSrcweir rFileName = URIHelper::SmartRel2Abs(
276cdf0e10cSrcweir INetURLObject(sBaseURL), rFileName,
277cdf0e10cSrcweir URIHelper::GetMaybeFileHdl());
278cdf0e10cSrcweir *pbInDoc = false; // Datei anschliessend nicht loeschen
279cdf0e10cSrcweir return rFileName.Len() != 0; // Einlesen OK
280cdf0e10cSrcweir }
281cdf0e10cSrcweir
282cdf0e10cSrcweir GDIMetaFile aWMF;
283cdf0e10cSrcweir pSt->Seek( nPosFc );
284cdf0e10cSrcweir bool bOk = ReadWindowMetafile( *pSt, aWMF, NULL ) ? true : false;
285cdf0e10cSrcweir
286cdf0e10cSrcweir if (!bOk || pSt->GetError() || !aWMF.GetActionCount())
287cdf0e10cSrcweir return false;
288cdf0e10cSrcweir
289cdf0e10cSrcweir if (pWwFib->envr != 1) // !MAC als Creator
290cdf0e10cSrcweir {
291cdf0e10cSrcweir
292cdf0e10cSrcweir /* SJ: #i40742#, we will use the prefsize from the mtf directly.
293cdf0e10cSrcweir The scaling has been done in former days, because the wmf filter was sometimes not
294cdf0e10cSrcweir able to calculate the proper prefsize (especially if the wmf fileheader was missing)
295cdf0e10cSrcweir
296cdf0e10cSrcweir
297cdf0e10cSrcweir aWMF.SetPrefMapMode( MapMode( MAP_100TH_MM ) );
298cdf0e10cSrcweir // MetaFile auf neue Groesse skalieren und
299cdf0e10cSrcweir // neue Groesse am MetaFile setzen
300cdf0e10cSrcweir if (rPic.MFP.xExt && rPic.MFP.yExt)
301cdf0e10cSrcweir {
302cdf0e10cSrcweir Size aOldSiz(aWMF.GetPrefSize());
303cdf0e10cSrcweir Size aNewSiz(rPic.MFP.xExt, rPic.MFP.yExt );
304cdf0e10cSrcweir Fraction aFracX(aNewSiz.Width(), aOldSiz.Width());
305cdf0e10cSrcweir Fraction aFracY(aNewSiz.Height(), aOldSiz.Height());
306cdf0e10cSrcweir
307cdf0e10cSrcweir aWMF.Scale(aFracX, aFracY);
308cdf0e10cSrcweir aWMF.SetPrefSize(aNewSiz);
309cdf0e10cSrcweir }
310cdf0e10cSrcweir */
311cdf0e10cSrcweir rpGraphic = new Graphic( aWMF );
312cdf0e10cSrcweir return true;
313cdf0e10cSrcweir }
314cdf0e10cSrcweir
315cdf0e10cSrcweir // MAC - Word als Creator
316cdf0e10cSrcweir // im WMF steht nur "Benutzen sie Word 6.0c" Mac-Pict steht dahinter
317cdf0e10cSrcweir // allerdings ohne die ersten 512 Bytes, bei einem MAC-PICT egal sind (
318cdf0e10cSrcweir // werden nicht ausgewertet )
319cdf0e10cSrcweir bOk = false;
320cdf0e10cSrcweir long nData = rPic.lcb - ( pSt->Tell() - nPosFc );
321cdf0e10cSrcweir if (nData > 0)
322cdf0e10cSrcweir {
323cdf0e10cSrcweir rpGraphic = new Graphic();
324cdf0e10cSrcweir if (0 == (bOk = SwWW8ImplReader::GetPictGrafFromStream(*rpGraphic, *pSt)))
325cdf0e10cSrcweir DELETEZ(rpGraphic);
326cdf0e10cSrcweir }
327cdf0e10cSrcweir return bOk; // Grafik drin
328cdf0e10cSrcweir }
329cdf0e10cSrcweir
330cdf0e10cSrcweir struct WW8PicDesc
331cdf0e10cSrcweir {
332cdf0e10cSrcweir sal_Int16 nCL, nCR, nCT, nCB;
333cdf0e10cSrcweir long nWidth, nHeight;
334cdf0e10cSrcweir
335cdf0e10cSrcweir WW8PicDesc( const WW8_PIC& rPic );
336cdf0e10cSrcweir };
337cdf0e10cSrcweir
WW8PicDesc(const WW8_PIC & rPic)338cdf0e10cSrcweir WW8PicDesc::WW8PicDesc( const WW8_PIC& rPic )
339cdf0e10cSrcweir {
340cdf0e10cSrcweir //See #i21190# before fiddling with this method
341cdf0e10cSrcweir long nOriWidth = rPic.dxaGoal; //Size in 1/100 mm before crop
342cdf0e10cSrcweir long nOriHeight = rPic.dyaGoal;
343cdf0e10cSrcweir
344cdf0e10cSrcweir nCL = rPic.dxaCropLeft;
345cdf0e10cSrcweir nCR = rPic.dxaCropRight;
346cdf0e10cSrcweir nCT = rPic.dyaCropTop;
347cdf0e10cSrcweir nCB = rPic.dyaCropBottom;
348cdf0e10cSrcweir
349cdf0e10cSrcweir long nAktWidth = nOriWidth - (nCL + nCR); // Size after crop
350cdf0e10cSrcweir long nAktHeight = nOriHeight - (nCT + nCB);
351cdf0e10cSrcweir if (!nAktWidth)
352cdf0e10cSrcweir nAktWidth = 1;
353cdf0e10cSrcweir if (!nAktHeight)
354cdf0e10cSrcweir nAktHeight = 1;
355cdf0e10cSrcweir nWidth = nAktWidth * rPic.mx / 1000; // Writer Size
356cdf0e10cSrcweir nHeight = nAktHeight * rPic.my / 1000;
357cdf0e10cSrcweir }
358cdf0e10cSrcweir
ReplaceObj(const SdrObject & rReplaceObj,SdrObject & rSubObj)359cdf0e10cSrcweir void SwWW8ImplReader::ReplaceObj(const SdrObject &rReplaceObj,
360cdf0e10cSrcweir SdrObject &rSubObj)
361cdf0e10cSrcweir {
362cdf0e10cSrcweir // SdrGrafObj anstatt des SdrTextObj in dessen Gruppe einsetzen
363cdf0e10cSrcweir if (SdrObject* pGroupObject = rReplaceObj.GetUpGroup())
364cdf0e10cSrcweir {
365cdf0e10cSrcweir SdrObjList* pObjectList = pGroupObject->GetSubList();
366cdf0e10cSrcweir
367cdf0e10cSrcweir rSubObj.SetLogicRect(rReplaceObj.GetCurrentBoundRect());
368cdf0e10cSrcweir rSubObj.SetLayer(rReplaceObj.GetLayer());
369cdf0e10cSrcweir
370cdf0e10cSrcweir // altes Objekt raus aus Gruppen-Liste und neues rein
371cdf0e10cSrcweir // (dies tauscht es ebenfalls in der Drawing-Page aus)
372cdf0e10cSrcweir pObjectList->ReplaceObject(&rSubObj, rReplaceObj.GetOrdNum());
373cdf0e10cSrcweir }
374cdf0e10cSrcweir else
375cdf0e10cSrcweir {
376cdf0e10cSrcweir ASSERT( !this, "Impossible!");
377cdf0e10cSrcweir }
378cdf0e10cSrcweir }
379cdf0e10cSrcweir
380cdf0e10cSrcweir // MakeGrafNotInCntnt setzt eine nicht-Zeichengebundene Grafik
381cdf0e10cSrcweir // ( bGrafApo == true)
MakeGrafNotInCntnt(const WW8PicDesc & rPD,const Graphic * pGraph,const String & rFileName,const SfxItemSet & rGrfSet)382cdf0e10cSrcweir SwFlyFrmFmt* SwWW8ImplReader::MakeGrafNotInCntnt(const WW8PicDesc& rPD,
383cdf0e10cSrcweir const Graphic* pGraph, const String& rFileName, const SfxItemSet& rGrfSet)
384cdf0e10cSrcweir {
385cdf0e10cSrcweir
386cdf0e10cSrcweir sal_uInt32 nWidth = rPD.nWidth;
387cdf0e10cSrcweir sal_uInt32 nHeight = rPD.nHeight;
388cdf0e10cSrcweir
389cdf0e10cSrcweir // Vertikale Verschiebung durch Zeilenabstand
390cdf0e10cSrcweir sal_Int32 nNetHeight = nHeight + rPD.nCT + rPD.nCB;
391cdf0e10cSrcweir if( pSFlyPara->nLineSpace && pSFlyPara->nLineSpace > nNetHeight )
392cdf0e10cSrcweir pSFlyPara->nYPos =
393cdf0e10cSrcweir (sal_uInt16)( pSFlyPara->nYPos + pSFlyPara->nLineSpace - nNetHeight );
394cdf0e10cSrcweir
395cdf0e10cSrcweir WW8FlySet aFlySet(*this, pWFlyPara, pSFlyPara, true);
396cdf0e10cSrcweir
397cdf0e10cSrcweir SwFmtAnchor aAnchor(pSFlyPara->eAnchor);
398cdf0e10cSrcweir aAnchor.SetAnchor(pPaM->GetPoint());
399cdf0e10cSrcweir aFlySet.Put(aAnchor);
400cdf0e10cSrcweir
401cdf0e10cSrcweir aFlySet.Put( SwFmtFrmSize( ATT_FIX_SIZE, nWidth, nHeight ) );
402cdf0e10cSrcweir
403cdf0e10cSrcweir SwFlyFrmFmt* pFlyFmt = rDoc.Insert(*pPaM, rFileName, aEmptyStr, pGraph,
404cdf0e10cSrcweir &aFlySet, &rGrfSet, NULL);
405cdf0e10cSrcweir
406cdf0e10cSrcweir // Damit die Frames bei Einfuegen in existierendes Doc erzeugt werden:
407cdf0e10cSrcweir if (rDoc.GetCurrentViewShell() && //swmod 071108//swmod 071225
408cdf0e10cSrcweir (FLY_AT_PARA == pFlyFmt->GetAnchor().GetAnchorId()))
409cdf0e10cSrcweir {
410cdf0e10cSrcweir pFlyFmt->MakeFrms();
411cdf0e10cSrcweir }
412cdf0e10cSrcweir return pFlyFmt;
413cdf0e10cSrcweir }
414cdf0e10cSrcweir
415cdf0e10cSrcweir
416cdf0e10cSrcweir // MakeGrafInCntnt fuegt zeichengebundene Grafiken ein
MakeGrafInCntnt(const WW8_PIC & rPic,const WW8PicDesc & rPD,const Graphic * pGraph,const String & rFileName,const SfxItemSet & rGrfSet)417cdf0e10cSrcweir SwFrmFmt* SwWW8ImplReader::MakeGrafInCntnt(const WW8_PIC& rPic,
418cdf0e10cSrcweir const WW8PicDesc& rPD, const Graphic* pGraph, const String& rFileName,
419cdf0e10cSrcweir const SfxItemSet& rGrfSet)
420cdf0e10cSrcweir {
421cdf0e10cSrcweir WW8FlySet aFlySet(*this, pPaM, rPic, rPD.nWidth, rPD.nHeight);
422cdf0e10cSrcweir
423cdf0e10cSrcweir SwFrmFmt* pFlyFmt = 0;
424cdf0e10cSrcweir
425cdf0e10cSrcweir if (!rFileName.Len() && nObjLocFc) // dann sollte ists ein OLE-Object
426cdf0e10cSrcweir pFlyFmt = ImportOle(pGraph, &aFlySet, &rGrfSet);
427cdf0e10cSrcweir
428cdf0e10cSrcweir if( !pFlyFmt ) // dann eben als Graphic
429cdf0e10cSrcweir {
430cdf0e10cSrcweir
431cdf0e10cSrcweir pFlyFmt = rDoc.Insert( *pPaM, rFileName, aEmptyStr, pGraph, &aFlySet,
432cdf0e10cSrcweir &rGrfSet, NULL);
433cdf0e10cSrcweir }
434cdf0e10cSrcweir
435cdf0e10cSrcweir // Grafik im Rahmen ? ok, Rahmen auf Bildgroesse vergroessern
436cdf0e10cSrcweir // ( nur wenn Auto-Breite )
437cdf0e10cSrcweir if( pSFlyPara )
438cdf0e10cSrcweir pSFlyPara->BoxUpWidth( rPD.nWidth );
439cdf0e10cSrcweir return pFlyFmt;
440cdf0e10cSrcweir }
441cdf0e10cSrcweir
ImportGraf1(WW8_PIC & rPic,SvStream * pSt,sal_uLong nFilePos)442cdf0e10cSrcweir SwFrmFmt* SwWW8ImplReader::ImportGraf1(WW8_PIC& rPic, SvStream* pSt,
443cdf0e10cSrcweir sal_uLong nFilePos )
444cdf0e10cSrcweir {
445cdf0e10cSrcweir SwFrmFmt* pRet = 0;
446cdf0e10cSrcweir if( pSt->IsEof() || rPic.fError || rPic.MFP.mm == 99 )
447cdf0e10cSrcweir return 0;
448cdf0e10cSrcweir
449cdf0e10cSrcweir String aFileName;
450cdf0e10cSrcweir bool bInDoc;
451cdf0e10cSrcweir Graphic* pGraph = 0;
452cdf0e10cSrcweir bool bOk = ReadGrafFile(aFileName, pGraph, rPic, pSt, nFilePos, &bInDoc);
453cdf0e10cSrcweir
454cdf0e10cSrcweir if (!bOk)
455cdf0e10cSrcweir {
456cdf0e10cSrcweir delete pGraph;
457cdf0e10cSrcweir return 0; // Grafik nicht korrekt eingelesen
458cdf0e10cSrcweir }
459cdf0e10cSrcweir
460cdf0e10cSrcweir WW8PicDesc aPD( rPic );
461cdf0e10cSrcweir
462cdf0e10cSrcweir SwAttrSet aGrfSet( rDoc.GetAttrPool(), RES_GRFATR_BEGIN, RES_GRFATR_END-1);
463cdf0e10cSrcweir if( aPD.nCL || aPD.nCR || aPD.nCT || aPD.nCB )
464cdf0e10cSrcweir {
465cdf0e10cSrcweir SwCropGrf aCrop( aPD.nCL, aPD.nCR, aPD.nCT, aPD.nCB) ;
466cdf0e10cSrcweir aGrfSet.Put( aCrop );
467cdf0e10cSrcweir }
468cdf0e10cSrcweir
469cdf0e10cSrcweir if( pWFlyPara && pWFlyPara->bGrafApo )
470cdf0e10cSrcweir pRet = MakeGrafNotInCntnt(aPD,pGraph,aFileName,aGrfSet);
471cdf0e10cSrcweir else
472cdf0e10cSrcweir pRet = MakeGrafInCntnt(rPic,aPD,pGraph,aFileName,aGrfSet);
473cdf0e10cSrcweir delete pGraph;
474cdf0e10cSrcweir return pRet;
475cdf0e10cSrcweir }
476cdf0e10cSrcweir
PicRead(SvStream * pDataStream,WW8_PIC * pPic,bool bVer67)477cdf0e10cSrcweir void SwWW8ImplReader::PicRead(SvStream *pDataStream, WW8_PIC *pPic,
478cdf0e10cSrcweir bool bVer67)
479cdf0e10cSrcweir {
480cdf0e10cSrcweir //Only the first 0x2e bytes are the same between version 6/7 and 8+
481cdf0e10cSrcweir #ifdef __WW8_NEEDS_COPY
482cdf0e10cSrcweir WW8_PIC_SHADOW aPicS;
483cdf0e10cSrcweir pDataStream->Read( &aPicS, sizeof( aPicS ) );
484cdf0e10cSrcweir WW8PicShadowToReal( &aPicS, pPic );
485cdf0e10cSrcweir #else
486cdf0e10cSrcweir pDataStream->Read( pPic, 0x2E);
487cdf0e10cSrcweir #endif // defined __WW8_NEEDS_COPY
488cdf0e10cSrcweir for (int i=0;i<4;i++)
489cdf0e10cSrcweir pDataStream->Read( &pPic->rgbrc[i], bVer67 ? 2 : 4);
490cdf0e10cSrcweir *pDataStream >> pPic->dxaOrigin;
491cdf0e10cSrcweir *pDataStream >> pPic->dyaOrigin;
492cdf0e10cSrcweir if (!bVer67)
493cdf0e10cSrcweir pDataStream->SeekRel(2); //cProps
494cdf0e10cSrcweir }
495cdf0e10cSrcweir
ImportGraf(SdrTextObj * pTextObj,SwFrmFmt * pOldFlyFmt)496cdf0e10cSrcweir SwFrmFmt* SwWW8ImplReader::ImportGraf(SdrTextObj* pTextObj,
497cdf0e10cSrcweir SwFrmFmt* pOldFlyFmt)
498cdf0e10cSrcweir {
499cdf0e10cSrcweir SwFrmFmt* pRet = 0;
500cdf0e10cSrcweir if (
501cdf0e10cSrcweir ((pStrm == pDataStream ) && !nPicLocFc) ||
502cdf0e10cSrcweir (nIniFlags & WW8FL_NO_GRAF)
503cdf0e10cSrcweir )
504cdf0e10cSrcweir {
505cdf0e10cSrcweir return 0;
506cdf0e10cSrcweir }
507cdf0e10cSrcweir
508cdf0e10cSrcweir ::SetProgressState(nProgress, mpDocShell); // Update
509cdf0e10cSrcweir
510cdf0e10cSrcweir GrafikCtor();
511cdf0e10cSrcweir
512cdf0e10cSrcweir /*
513cdf0e10cSrcweir kleiner Spass von Microsoft: manchmal existiert ein Stream Namens DATA
514cdf0e10cSrcweir Dieser enthaelt dann den PICF und die entsprechende Grafik !!!
515cdf0e10cSrcweir Wir mappen ansonsten die Variable pDataStream auf pStream.
516cdf0e10cSrcweir */
517cdf0e10cSrcweir
518cdf0e10cSrcweir sal_uLong nOldPos = pDataStream->Tell();
519cdf0e10cSrcweir WW8_PIC aPic;
520cdf0e10cSrcweir pDataStream->Seek( nPicLocFc );
521cdf0e10cSrcweir PicRead( pDataStream, &aPic, bVer67);
522cdf0e10cSrcweir
523cdf0e10cSrcweir // Plausibilitaetstest ist noetig, da z.B. bei CheckBoxen im
524cdf0e10cSrcweir // Feld-Result ein WMF-aehnliches Struct vorkommt.
525cdf0e10cSrcweir if ((aPic.lcb >= 58) && !pDataStream->GetError())
526cdf0e10cSrcweir {
527cdf0e10cSrcweir if( pFlyFmtOfJustInsertedGraphic )
528cdf0e10cSrcweir {
529cdf0e10cSrcweir // Soeben haben wir einen Grafik-Link ins Doc inserted.
530cdf0e10cSrcweir // Wir muessen ihn jetzt noch Positioniern und Skalieren.
531cdf0e10cSrcweir //
532cdf0e10cSrcweir WW8PicDesc aPD( aPic );
533cdf0e10cSrcweir
534cdf0e10cSrcweir WW8FlySet aFlySet( *this, pPaM, aPic, aPD.nWidth, aPD.nHeight );
535cdf0e10cSrcweir
536cdf0e10cSrcweir //JP 17.1.2002: the correct anchor is set in Read_F_IncludePicture
537cdf0e10cSrcweir // and the current PaM point's behind the position if
538cdf0e10cSrcweir // it is anchored in content; because this anchor add
539cdf0e10cSrcweir // a character into the textnode.
540cdf0e10cSrcweir // IussueZilla task 2806
541cdf0e10cSrcweir if (FLY_AS_CHAR ==
542cdf0e10cSrcweir pFlyFmtOfJustInsertedGraphic->GetAnchor().GetAnchorId() )
543cdf0e10cSrcweir {
544cdf0e10cSrcweir aFlySet.ClearItem( RES_ANCHOR );
545cdf0e10cSrcweir }
546cdf0e10cSrcweir
547cdf0e10cSrcweir pFlyFmtOfJustInsertedGraphic->SetFmtAttr( aFlySet );
548cdf0e10cSrcweir
549cdf0e10cSrcweir pFlyFmtOfJustInsertedGraphic = 0;
550cdf0e10cSrcweir }
551cdf0e10cSrcweir else if((0x64 == aPic.MFP.mm) || (0x66 == aPic.MFP.mm))
552cdf0e10cSrcweir {
553cdf0e10cSrcweir // verlinkte Grafik im Escher-Objekt
554cdf0e10cSrcweir SdrObject* pObject = 0;
555cdf0e10cSrcweir
556cdf0e10cSrcweir //#i17200#, a bit of guesswork I'm afraid
557cdf0e10cSrcweir if (aPic.dxaGoal == 1000 && aPic.mx == 1) //100% hack ?
558cdf0e10cSrcweir {
559cdf0e10cSrcweir aPic.mx = msword_cast<sal_uInt16>(
560cdf0e10cSrcweir maSectionManager.GetPageWidth() -
561cdf0e10cSrcweir maSectionManager.GetPageRight() -
562cdf0e10cSrcweir maSectionManager.GetPageLeft());
563cdf0e10cSrcweir }
564cdf0e10cSrcweir
565cdf0e10cSrcweir WW8PicDesc aPD( aPic );
566cdf0e10cSrcweir String aGrName;
567cdf0e10cSrcweir if (!pMSDffManager)
568cdf0e10cSrcweir pMSDffManager = new SwMSDffManager(*this);
569cdf0e10cSrcweir /*
570cdf0e10cSrcweir ##835##
571cdf0e10cSrcweir Disable use of main stream as fallback stream for inline direct
572cdf0e10cSrcweir blips as it is known that they are directly after the record
573cdf0e10cSrcweir header, testing for existance in main stream may lead to an
574cdf0e10cSrcweir incorrect fallback graphic being found if other escher graphics
575cdf0e10cSrcweir have been inserted in the document
576cdf0e10cSrcweir */
577cdf0e10cSrcweir pMSDffManager->DisableFallbackStream();
578cdf0e10cSrcweir if( !pMSDffManager->GetModel() )
579cdf0e10cSrcweir pMSDffManager->SetModel(pDrawModel, 1440);
580cdf0e10cSrcweir
581cdf0e10cSrcweir if (0x66 == aPic.MFP.mm)
582cdf0e10cSrcweir {
583cdf0e10cSrcweir //These ones have names prepended
584cdf0e10cSrcweir sal_uInt8 nNameLen=0;
585cdf0e10cSrcweir *pDataStream >> nNameLen;
586cdf0e10cSrcweir pDataStream->SeekRel( nNameLen );
587cdf0e10cSrcweir }
588cdf0e10cSrcweir
589cdf0e10cSrcweir Rectangle aChildRect;
590cdf0e10cSrcweir Rectangle aClientRect( 0,0, aPD.nWidth, aPD.nHeight);
591cdf0e10cSrcweir SvxMSDffImportData aData( aClientRect );
592cdf0e10cSrcweir pObject = pMSDffManager->ImportObj(*pDataStream, &aData, aClientRect, aChildRect );
593cdf0e10cSrcweir if (pObject)
594cdf0e10cSrcweir {
595cdf0e10cSrcweir // fuer den Rahmen
596cdf0e10cSrcweir SfxItemSet aAttrSet( rDoc.GetAttrPool(), RES_FRMATR_BEGIN,
597cdf0e10cSrcweir RES_FRMATR_END-1 );
598cdf0e10cSrcweir
599cdf0e10cSrcweir SvxMSDffImportRec *pRecord =
600cdf0e10cSrcweir (aData.HasRecords() && (1 == aData.GetRecCount() ) ) ?
601cdf0e10cSrcweir aData.GetRecord( 0 ) : 0;
602cdf0e10cSrcweir
603cdf0e10cSrcweir if( pRecord )
604cdf0e10cSrcweir {
605cdf0e10cSrcweir //A graphic of this type in this location is always
606cdf0e10cSrcweir //inline, and uses the pic in the same mould as ww6
607cdf0e10cSrcweir //graphics.
608cdf0e10cSrcweir if (pWFlyPara && pWFlyPara->bGrafApo)
609cdf0e10cSrcweir {
610cdf0e10cSrcweir WW8FlySet aFlySet(*this, pWFlyPara, pSFlyPara, true);
611cdf0e10cSrcweir
612cdf0e10cSrcweir SwFmtAnchor aAnchor(pSFlyPara->eAnchor);
613cdf0e10cSrcweir aAnchor.SetAnchor(pPaM->GetPoint());
614cdf0e10cSrcweir aFlySet.Put(aAnchor);
615cdf0e10cSrcweir
616cdf0e10cSrcweir aAttrSet.Put(aFlySet);
617cdf0e10cSrcweir }
618cdf0e10cSrcweir else
619cdf0e10cSrcweir {
620cdf0e10cSrcweir WW8FlySet aFlySet( *this, pPaM, aPic, aPD.nWidth,
621cdf0e10cSrcweir aPD.nHeight );
622cdf0e10cSrcweir
623cdf0e10cSrcweir aAttrSet.Put(aFlySet);
624cdf0e10cSrcweir }
625cdc81fd4SJian Hong Cheng //Modified for i120717,for graf importing from MS Word 2003 binary format,
6269e9ad155SJian Hong Cheng //there is no border distance.
6279e9ad155SJian Hong Cheng /*Rectangle aInnerDist( pRecord->nDxTextLeft,
628cdf0e10cSrcweir pRecord->nDyTextTop, pRecord->nDxTextRight,
6299e9ad155SJian Hong Cheng pRecord->nDyTextBottom );*/
6309e9ad155SJian Hong Cheng
6319e9ad155SJian Hong Cheng Rectangle aInnerDist(0,0,0,0);
6329e9ad155SJian Hong Cheng //End
633cdf0e10cSrcweir MatchSdrItemsIntoFlySet( pObject, aAttrSet,
634cdf0e10cSrcweir pRecord->eLineStyle, pRecord->eShapeType,
635cdf0e10cSrcweir aInnerDist );
636cdf0e10cSrcweir
637cdf0e10cSrcweir //Groesse aus der WinWord PIC-Struktur als
638cdf0e10cSrcweir //Grafik-Groesse nehmen
639cdf0e10cSrcweir aAttrSet.Put( SwFmtFrmSize( ATT_FIX_SIZE, aPD.nWidth,
640cdf0e10cSrcweir aPD.nHeight ) );
641cdf0e10cSrcweir }
642cdf0e10cSrcweir
643cdf0e10cSrcweir // for the Grafik
644cdf0e10cSrcweir SfxItemSet aGrSet( rDoc.GetAttrPool(), RES_GRFATR_BEGIN,
645cdf0e10cSrcweir RES_GRFATR_END-1 );
646cdf0e10cSrcweir
647cdf0e10cSrcweir if( aPD.nCL || aPD.nCR || aPD.nCT || aPD.nCB )
648cdf0e10cSrcweir {
649cdf0e10cSrcweir SwCropGrf aCrop( aPD.nCL, aPD.nCR, aPD.nCT, aPD.nCB );
650cdf0e10cSrcweir aGrSet.Put( aCrop );
651cdf0e10cSrcweir }
652cdf0e10cSrcweir
653cdf0e10cSrcweir if (pRecord)
654cdf0e10cSrcweir MatchEscherMirrorIntoFlySet(*pRecord, aGrSet);
655cdf0e10cSrcweir
656cdf0e10cSrcweir // ggfs. altes AttrSet uebernehmen und
657cdf0e10cSrcweir // horiz. Positionierungs-Relation korrigieren
658cdf0e10cSrcweir if( pOldFlyFmt )
659cdf0e10cSrcweir {
660cdf0e10cSrcweir aAttrSet.Put( pOldFlyFmt->GetAttrSet() );
661cdf0e10cSrcweir const SwFmtHoriOrient &rHori = pOldFlyFmt->GetHoriOrient();
662cdf0e10cSrcweir if( text::RelOrientation::FRAME == rHori.GetRelationOrient() )
663cdf0e10cSrcweir {
664cdf0e10cSrcweir aAttrSet.Put( SwFmtHoriOrient( rHori.GetPos(),
665cdf0e10cSrcweir text::HoriOrientation::NONE, text::RelOrientation::PAGE_PRINT_AREA ) );
666cdf0e10cSrcweir }
667cdf0e10cSrcweir }
668cdf0e10cSrcweir
669cdf0e10cSrcweir bool bTextObjWasGrouped = false;
670cdf0e10cSrcweir if (pOldFlyFmt && pTextObj && pTextObj->GetUpGroup())
671cdf0e10cSrcweir bTextObjWasGrouped = true;
672cdf0e10cSrcweir
673cdf0e10cSrcweir if (bTextObjWasGrouped)
674cdf0e10cSrcweir ReplaceObj(*pTextObj, *pObject);
675cdf0e10cSrcweir else
676cdf0e10cSrcweir {
677cdf0e10cSrcweir if (sal_uInt16(OBJ_OLE2) == pObject->GetObjIdentifier())
678cdf0e10cSrcweir {
679cdf0e10cSrcweir // the size from BLIP, if there is any, should be already set
680cdf0e10cSrcweir pRet = InsertOle(*((SdrOle2Obj*)pObject), aAttrSet, aGrSet);
681cdf0e10cSrcweir }
682cdf0e10cSrcweir else
683cdf0e10cSrcweir {
684cdf0e10cSrcweir if (SdrGrafObj* pGraphObject = PTR_CAST(SdrGrafObj, pObject))
685cdf0e10cSrcweir {
686cdf0e10cSrcweir // Nun den Link bzw. die Grafik ins Doc stopfen
687cdf0e10cSrcweir const Graphic& rGraph = pGraphObject->GetGraphic();
688cdf0e10cSrcweir
689cdf0e10cSrcweir if (nObjLocFc) // is it a OLE-Object?
690cdf0e10cSrcweir pRet = ImportOle(&rGraph, &aAttrSet, &aGrSet, pObject->GetBLIPSizeRectangle());
691cdf0e10cSrcweir
692cdf0e10cSrcweir if (!pRet)
693cdf0e10cSrcweir {
694cdf0e10cSrcweir pRet = rDoc.Insert(*pPaM, aEmptyStr, aEmptyStr,
695cdf0e10cSrcweir &rGraph, &aAttrSet, &aGrSet, NULL );
696cdf0e10cSrcweir }
697cdf0e10cSrcweir }
698cdf0e10cSrcweir else
699*5222b95bSOliver-Rainer Wittmann pRet = rDoc.InsertDrawObj(*pPaM, *pObject, aAttrSet );
700cdf0e10cSrcweir }
701cdf0e10cSrcweir }
702cdf0e10cSrcweir
703cdf0e10cSrcweir // also nur, wenn wir ein *Insert* gemacht haben
704cdf0e10cSrcweir if (pRet)
705cdf0e10cSrcweir {
706cdf0e10cSrcweir if (pRecord)
707cdf0e10cSrcweir SetAttributesAtGrfNode(pRecord, pRet, 0);
708cdf0e10cSrcweir
709cdf0e10cSrcweir // #i68101#
710cdf0e10cSrcweir // removed pObject->HasSetName() usage since always returned true,
711cdf0e10cSrcweir // also removed else-part and wrote an informing mail to Henning Brinkmann
712cdf0e10cSrcweir // about this to clarify.
713cdf0e10cSrcweir pRet->SetName(pObject->GetName());
714cdf0e10cSrcweir
715cdf0e10cSrcweir // Zeiger auf neues Objekt ermitteln und Z-Order-Liste
716cdf0e10cSrcweir // entsprechend korrigieren (oder Eintrag loeschen)
717cdf0e10cSrcweir if (SdrObject* pOurNewObject = CreateContactObject(pRet))
718cdf0e10cSrcweir {
719cdf0e10cSrcweir if (pOurNewObject != pObject)
720cdf0e10cSrcweir {
721cdf0e10cSrcweir pMSDffManager->ExchangeInShapeOrder( pObject, 0, 0,
722cdf0e10cSrcweir pOurNewObject );
723cdf0e10cSrcweir
724cdf0e10cSrcweir // altes SdrGrafObj aus der Page loeschen und
725cdf0e10cSrcweir // zerstoeren
726cdf0e10cSrcweir if (pObject->GetPage())
727cdf0e10cSrcweir pDrawPg->RemoveObject(pObject->GetOrdNum());
728cdf0e10cSrcweir SdrObject::Free( pObject );
729cdf0e10cSrcweir }
730cdf0e10cSrcweir }
731cdf0e10cSrcweir else
732cdf0e10cSrcweir pMSDffManager->RemoveFromShapeOrder( pObject );
733cdf0e10cSrcweir }
734cdf0e10cSrcweir else
735cdf0e10cSrcweir pMSDffManager->RemoveFromShapeOrder( pObject );
736cdf0e10cSrcweir
737cdf0e10cSrcweir // auch das ggfs. Page loeschen, falls nicht gruppiert,
738cdf0e10cSrcweir if (pTextObj && !bTextObjWasGrouped && pTextObj->GetPage())
739cdf0e10cSrcweir pDrawPg->RemoveObject( pTextObj->GetOrdNum() );
740cdf0e10cSrcweir }
741cdf0e10cSrcweir pMSDffManager->EnableFallbackStream();
742cdf0e10cSrcweir }
743cdf0e10cSrcweir else if (aPic.lcb >= 58)
744cdf0e10cSrcweir pRet = ImportGraf1(aPic, pDataStream, nPicLocFc);
745cdf0e10cSrcweir }
746cdf0e10cSrcweir pDataStream->Seek( nOldPos );
747cdf0e10cSrcweir
748cdf0e10cSrcweir if (pRet)
749cdf0e10cSrcweir {
750cdf0e10cSrcweir SdrObject* pOurNewObject = CreateContactObject(pRet);
751cdf0e10cSrcweir pWWZOrder->InsertTextLayerObject(pOurNewObject);
752cdf0e10cSrcweir }
753cdf0e10cSrcweir
754cdf0e10cSrcweir return AddAutoAnchor(pRet);
755cdf0e10cSrcweir }
756cdf0e10cSrcweir
757cdf0e10cSrcweir #ifdef __WW8_NEEDS_COPY
758cdf0e10cSrcweir
WW8PicShadowToReal(WW8_PIC_SHADOW * pPicS,WW8_PIC * pPic)759cdf0e10cSrcweir void WW8PicShadowToReal( WW8_PIC_SHADOW * pPicS, WW8_PIC * pPic )
760cdf0e10cSrcweir {
761cdf0e10cSrcweir pPic->lcb = SVBT32ToUInt32( pPicS->lcb );
762cdf0e10cSrcweir pPic->cbHeader = SVBT16ToShort( pPicS->cbHeader );
763cdf0e10cSrcweir pPic->MFP.mm = SVBT16ToShort( pPicS->MFP.mm );
764cdf0e10cSrcweir pPic->MFP.xExt = SVBT16ToShort( pPicS->MFP.xExt );
765cdf0e10cSrcweir pPic->MFP.yExt = SVBT16ToShort( pPicS->MFP.yExt );
766cdf0e10cSrcweir pPic->MFP.hMF = SVBT16ToShort( pPicS->MFP.hMF );
767cdf0e10cSrcweir for( sal_uInt16 i = 0; i < 14 ; i++ )
768cdf0e10cSrcweir pPic->rcWinMF[i] = SVBT8ToByte( pPicS->rcWinMF[i] );
769cdf0e10cSrcweir pPic->dxaGoal = SVBT16ToShort( pPicS->dxaGoal );
770cdf0e10cSrcweir pPic->dyaGoal = SVBT16ToShort( pPicS->dyaGoal );
771cdf0e10cSrcweir pPic->mx = SVBT16ToShort( pPicS->mx );
772cdf0e10cSrcweir pPic->my = SVBT16ToShort( pPicS->my );
773cdf0e10cSrcweir pPic->dxaCropLeft = SVBT16ToShort( pPicS->dxaCropLeft );
774cdf0e10cSrcweir pPic->dyaCropTop = SVBT16ToShort( pPicS->dyaCropTop );
775cdf0e10cSrcweir pPic->dxaCropRight = SVBT16ToShort( pPicS->dxaCropRight );
776cdf0e10cSrcweir pPic->dyaCropBottom = SVBT16ToShort( pPicS->dyaCropBottom );
777cdf0e10cSrcweir pPic->brcl = pPicS->aBits1[0] & 0x0f;
778cdf0e10cSrcweir pPic->fFrameEmpty = (pPicS->aBits1[0] & 0x10) >> 4;
779cdf0e10cSrcweir pPic->fBitmap = (pPicS->aBits1[0] & 0x20) >> 5;
780cdf0e10cSrcweir pPic->fDrawHatch = (pPicS->aBits1[0] & 0x40) >> 6;
781cdf0e10cSrcweir pPic->fError = (pPicS->aBits1[0] & 0x80) >> 7;
782cdf0e10cSrcweir pPic->bpp = pPicS->aBits2[0];
783cdf0e10cSrcweir }
784cdf0e10cSrcweir
WW8FSPAShadowToReal(WW8_FSPA_SHADOW * pFSPAS,WW8_FSPA * pFSPA)785cdf0e10cSrcweir void WW8FSPAShadowToReal( WW8_FSPA_SHADOW * pFSPAS, WW8_FSPA * pFSPA )
786cdf0e10cSrcweir {
787cdf0e10cSrcweir //long nSpId; //Shape Identifier. Used in conjunction with the office art data (found via fcDggInfo in the FIB) to find the actual data for this shape.
788cdf0e10cSrcweir //long nXaLeft; //left of rectangle enclosing shape relative to the origin of the shape
789cdf0e10cSrcweir //long nYaTop; //top of rectangle enclosing shape relative to the origin of the shape
790cdf0e10cSrcweir //long nXaRight; //right of rectangle enclosing shape relative to the origin of the shape
791cdf0e10cSrcweir //long nYaBottom;//bottom of the rectangle enclosing shape relative to the origin of the shape
792cdf0e10cSrcweir //sal_uInt16 bHdr:1;
793cdf0e10cSrcweir //sal_uInt16 nbx:2;
794cdf0e10cSrcweir //sal_uInt16 nby:2;
795cdf0e10cSrcweir //sal_uInt16 nwr:4;
796cdf0e10cSrcweir //sal_uInt16 nwrk:4;
797cdf0e10cSrcweir //sal_uInt16 bRcaSimple:1;
798cdf0e10cSrcweir //sal_uInt16 bAnchorLock:1;
799cdf0e10cSrcweir //long nTxbx; //count of textboxes in shape (undo doc only)
800cdf0e10cSrcweir
801cdf0e10cSrcweir
802cdf0e10cSrcweir pFSPA->nSpId = SVBT32ToUInt32( pFSPAS->nSpId );
803cdf0e10cSrcweir pFSPA->nXaLeft = SVBT32ToUInt32( pFSPAS->nXaLeft );
804cdf0e10cSrcweir pFSPA->nYaTop = SVBT32ToUInt32( pFSPAS->nYaTop );
805cdf0e10cSrcweir pFSPA->nXaRight = SVBT32ToUInt32( pFSPAS->nXaRight );
806cdf0e10cSrcweir pFSPA->nYaBottom = SVBT32ToUInt32( pFSPAS->nYaBottom );
807cdf0e10cSrcweir
808cdf0e10cSrcweir sal_uInt16 nBits = SVBT16ToShort( pFSPAS->aBits1 );
809cdf0e10cSrcweir
810cdf0e10cSrcweir pFSPA->bHdr = 0 != ( nBits & 0x0001 );
811cdf0e10cSrcweir pFSPA->nbx = ( nBits & 0x0006 ) >> 1;
812cdf0e10cSrcweir pFSPA->nby = ( nBits & 0x0018 ) >> 3;
813cdf0e10cSrcweir pFSPA->nwr = ( nBits & 0x01E0 ) >> 5;
814cdf0e10cSrcweir pFSPA->nwrk = ( nBits & 0x1E00 ) >> 9;
815cdf0e10cSrcweir pFSPA->bRcaSimple = 0 != ( nBits & 0x2000 );
816cdf0e10cSrcweir pFSPA->bBelowText = 0 != ( nBits & 0x4000 );
817cdf0e10cSrcweir pFSPA->bAnchorLock = 0 != ( nBits & 0x8000 );
818cdf0e10cSrcweir pFSPA->nTxbx = SVBT32ToUInt32( pFSPAS->nTxbx );
819cdf0e10cSrcweir }
820cdf0e10cSrcweir #endif // defined __WW8_NEEDS_COPY
821cdf0e10cSrcweir
822cdf0e10cSrcweir /* vi:set tabstop=4 shiftwidth=4 expandtab: */
823