1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <hintids.hxx>
23 #include <svl/urihelper.hxx>
24 #include <svx/svdpage.hxx>
25 #include <svx/svdmodel.hxx>
26 #include <svx/svdograf.hxx>
27 #include <svx/svdoole2.hxx>
28 #include <editeng/opaqitem.hxx>
29 #include <filter/msfilter/msdffimp.hxx>
30 #include <sfx2/app.hxx>
31 #include <sfx2/docfile.hxx>
32 #include <sfx2/fcontnr.hxx>
33 #include <grfatr.hxx> // class SwCropGrf
34 #include <fmtflcnt.hxx>
35 #include <fmtanchr.hxx>
37 #include <fltshell.hxx>
40 #include <ndtxt.hxx> // class SwTxtNode
41 #include <mdiexp.hxx> // Progress
42 #include "writerwordglue.hxx"
43 #include "ww8struc.hxx"
44 #include "ww8scan.hxx"
45 #include "ww8par.hxx" // class SwWWImplReader
46 #include "ww8par2.hxx" // struct WWFlyPara
47 #include "ww8graf.hxx"
48 #include <vcl/graphicfilter.hxx>
49 #include <vcl/wmf.hxx>
51 using namespace ::com::sun::star
;
52 using namespace sw::types
;
54 wwZOrderer::wwZOrderer(const sw::util::SetLayer
&rSetLayer
, SdrPage
* pDrawPg
,
55 const SvxMSDffShapeOrders
*pShapeOrders
)
56 : maSetLayer(rSetLayer
), mnInlines(0), mpDrawPg(pDrawPg
),
57 mpShapeOrders(pShapeOrders
)
59 mnNoInitialObjects
= mpDrawPg
->GetObjCount();
60 OSL_ENSURE(mpDrawPg
,"Missing draw page impossible!");
63 void wwZOrderer::InsideEscher(sal_uLong nSpId
)
65 maIndexes
.push(GetEscherObjectIdx(nSpId
));
68 void wwZOrderer::OutsideEscher()
73 // consider new parameter <_bInHeaderFooter>
74 void wwZOrderer::InsertEscherObject( SdrObject
* pObject
,
76 const bool _bInHeaderFooter
)
78 sal_uLong nInsertPos
= GetEscherObjectPos( nSpId
, _bInHeaderFooter
);
79 InsertObject(pObject
, nInsertPos
+ mnNoInitialObjects
+ mnInlines
);
82 wwZOrderer::myeiter
wwZOrderer::MapEscherIdxToIter(sal_uLong nIdx
)
84 myeiter aIter
= maEscherLayer
.begin();
85 myeiter aEnd
= maEscherLayer
.end();
88 if (aIter
->mnEscherShapeOrder
== nIdx
)
95 sal_uInt16
wwZOrderer::GetEscherObjectIdx(sal_uLong nSpId
)
98 sal_uInt16 nShapeCount
= mpShapeOrders
? mpShapeOrders
->size() : 0;
99 // First, find out what position this shape is in in the Escher order.
100 for (sal_uInt16 nShapePos
=0; nShapePos
< nShapeCount
; nShapePos
++)
102 const SvxMSDffShapeOrder
& rOrder
= *(*mpShapeOrders
)[nShapePos
];
103 if (rOrder
.nShapeId
== nSpId
)
112 // consider new parameter <_bInHeaderFooter>
113 sal_uLong
wwZOrderer::GetEscherObjectPos( sal_uLong nSpId
,
114 const bool _bInHeaderFooter
)
117 EscherObjects have their own ordering which needs to be matched to
118 the actual ordering that should be used when inserting them into the
121 sal_uInt16 nFound
= GetEscherObjectIdx(nSpId
);
122 // Match the ordering position from the ShapeOrders to the ordering of all
123 // objects in the document, there is a complexity when escherobjects
124 // contain inlines objects, we need to consider thsose as part of the
127 myeiter aIter
= maEscherLayer
.begin();
128 myeiter aEnd
= maEscherLayer
.end();
129 // skip objects in page header|footer,
130 // if current object isn't in page header|footer
131 if ( !_bInHeaderFooter
)
133 while ( aIter
!= aEnd
)
135 if ( !aIter
->mbInHeaderFooter
)
139 nRet
+= aIter
->mnNoInlines
+ 1;
143 while (aIter
!= aEnd
)
145 // insert object in page header|footer
146 // before objects in page body
147 if ( _bInHeaderFooter
&& !aIter
->mbInHeaderFooter
)
151 if ( aIter
->mnEscherShapeOrder
> nFound
)
153 nRet
+= aIter
->mnNoInlines
+1;
156 maEscherLayer
.insert(aIter
, EscherShape( nFound
, _bInHeaderFooter
) );
160 // InsertObj() fuegt das Objekt in die Sw-Page ein und merkt sich die Z-Pos in
162 void wwZOrderer::InsertDrawingObject(SdrObject
* pObj
, short nWwHeight
)
164 sal_uLong nPos
= GetDrawingObjectPos(nWwHeight
);
165 if (nWwHeight
& 0x2000) // Heaven ?
166 maSetLayer
.SendObjectToHeaven(*pObj
);
168 maSetLayer
.SendObjectToHell(*pObj
);
170 InsertObject(pObj
, nPos
+ mnNoInitialObjects
+ mnInlines
);
173 void wwZOrderer::InsertTextLayerObject(SdrObject
* pObject
)
175 maSetLayer
.SendObjectToHeaven(*pObject
);
176 if (maIndexes
.empty())
178 InsertObject(pObject
, mnNoInitialObjects
+ mnInlines
);
183 //If we are inside an escher objects, place us just after that
184 //escher obj, and increment its inline count
185 sal_uInt16 nIdx
= maIndexes
.top();
186 myeiter aEnd
= MapEscherIdxToIter(nIdx
);
188 sal_uLong nInsertPos
=0;
189 myeiter aIter
= maEscherLayer
.begin();
190 while (aIter
!= aEnd
)
192 nInsertPos
+= aIter
->mnNoInlines
+1;
196 OSL_ENSURE(aEnd
!= maEscherLayer
.end(), "Something very wrong here");
197 if (aEnd
!= maEscherLayer
.end())
200 nInsertPos
+= aEnd
->mnNoInlines
;
203 InsertObject(pObject
, mnNoInitialObjects
+ mnInlines
+ nInsertPos
);
207 // Parallel zu dem Obj-Array im Dokument baue ich ein Array auf,
208 // dass die Ww-Height ( -> Wer ueberdeckt wen ) beinhaltet.
209 // Anhand dieses VARARR wird die Einfuegeposition ermittelt.
210 // Der Offset bei Datei in bestehendes Dokument mit Grafiklayer einfuegen
211 // muss der Aufrufer den Index um mnNoInitialObjects erhoeht werden, damit die
212 // neuen Objekte am Ende landen ( Einfuegen ist dann schneller )
213 sal_uLong
wwZOrderer::GetDrawingObjectPos(short nWwHeight
)
215 myditer aIter
= maDrawHeight
.begin();
216 myditer aEnd
= maDrawHeight
.end();
218 while (aIter
!= aEnd
)
220 if ((*aIter
& 0x1fff) > (nWwHeight
& 0x1fff))
225 aIter
= maDrawHeight
.insert(aIter
, nWwHeight
);
226 return std::distance(maDrawHeight
.begin(), aIter
);
229 bool wwZOrderer::InsertObject(SdrObject
* pObject
, sal_uLong nPos
)
231 if (!pObject
->IsInserted())
233 mpDrawPg
->InsertObject(pObject
, nPos
);
239 #ifdef __WW8_NEEDS_COPY
240 extern void WW8PicShadowToReal( WW8_PIC_SHADOW
* pPicS
, WW8_PIC
* pPic
);
241 #endif // defined __WW8_NEEDS_COPY
243 bool SwWW8ImplReader::GetPictGrafFromStream(Graphic
& rGraphic
, SvStream
& rSrc
)
245 return 0 == GraphicFilter::GetGraphicFilter().ImportGraphic(rGraphic
, aEmptyStr
, rSrc
,
246 GRFILTER_FORMAT_DONTKNOW
);
249 bool SwWW8ImplReader::ReadGrafFile(String
& rFileName
, Graphic
*& rpGraphic
,
250 const WW8_PIC
& rPic
, SvStream
* pSt
, sal_uLong nFilePos
, bool* pbInDoc
)
251 { // Grafik in File schreiben
252 *pbInDoc
= true; // default
254 sal_uLong nPosFc
= nFilePos
+ rPic
.cbHeader
;
258 case 94: // BMP-File ( nicht embeddet ) oder GIF
259 case 99: // TIFF-File ( nicht embeddet )
261 // Name als P-String einlesen
262 rFileName
= read_uInt8_PascalString(*pSt
, eStructCharSet
);
264 rFileName
= URIHelper::SmartRel2Abs(
265 INetURLObject(sBaseURL
), rFileName
,
266 URIHelper::GetMaybeFileHdl());
267 *pbInDoc
= false; // Datei anschliessend nicht loeschen
268 return rFileName
.Len() != 0; // Einlesen OK
273 bool bOk
= ReadWindowMetafile( *pSt
, aWMF
, NULL
) ? true : false;
275 if (!bOk
|| pSt
->GetError() || !aWMF
.GetActionSize())
278 if (pWwFib
->envr
!= 1) // !MAC als Creator
280 rpGraphic
= new Graphic( aWMF
);
284 // MAC - Word als Creator
285 // im WMF steht nur "Benutzen sie Word 6.0c" Mac-Pict steht dahinter
286 // allerdings ohne die ersten 512 Bytes, bei einem MAC-PICT egal sind (
287 // werden nicht ausgewertet )
289 long nData
= rPic
.lcb
- ( pSt
->Tell() - nPosFc
);
292 rpGraphic
= new Graphic();
293 if (0 == (bOk
= SwWW8ImplReader::GetPictGrafFromStream(*rpGraphic
, *pSt
)))
296 return bOk
; // Grafik drin
301 sal_Int16 nCL
, nCR
, nCT
, nCB
;
302 long nWidth
, nHeight
;
304 WW8PicDesc( const WW8_PIC
& rPic
);
307 WW8PicDesc::WW8PicDesc( const WW8_PIC
& rPic
)
309 //See #i21190# before fiddling with this method
310 long nOriWidth
= rPic
.dxaGoal
; //Size in 1/100 mm before crop
311 long nOriHeight
= rPic
.dyaGoal
;
313 nCL
= rPic
.dxaCropLeft
;
314 nCR
= rPic
.dxaCropRight
;
315 nCT
= rPic
.dyaCropTop
;
316 nCB
= rPic
.dyaCropBottom
;
318 long nAktWidth
= nOriWidth
- (nCL
+ nCR
); // Size after crop
319 long nAktHeight
= nOriHeight
- (nCT
+ nCB
);
324 nWidth
= nAktWidth
* rPic
.mx
/ 1000; // Writer Size
325 nHeight
= nAktHeight
* rPic
.my
/ 1000;
328 void SwWW8ImplReader::ReplaceObj(const SdrObject
&rReplaceObj
,
331 // SdrGrafObj anstatt des SdrTextObj in dessen Gruppe einsetzen
332 if (SdrObject
* pGroupObject
= rReplaceObj
.GetUpGroup())
334 SdrObjList
* pObjectList
= pGroupObject
->GetSubList();
336 rSubObj
.SetLogicRect(rReplaceObj
.GetCurrentBoundRect());
337 rSubObj
.SetLayer(rReplaceObj
.GetLayer());
339 // altes Objekt raus aus Gruppen-Liste und neues rein
340 // (dies tauscht es ebenfalls in der Drawing-Page aus)
341 pObjectList
->ReplaceObject(&rSubObj
, rReplaceObj
.GetOrdNum());
345 OSL_ENSURE( !this, "Impossible!");
349 // MakeGrafNotInCntnt setzt eine nicht-Zeichengebundene Grafik
350 // ( bGrafApo == true)
351 SwFlyFrmFmt
* SwWW8ImplReader::MakeGrafNotInCntnt(const WW8PicDesc
& rPD
,
352 const Graphic
* pGraph
, const String
& rFileName
, const SfxItemSet
& rGrfSet
)
355 sal_uInt32 nWidth
= rPD
.nWidth
;
356 sal_uInt32 nHeight
= rPD
.nHeight
;
358 // Vertikale Verschiebung durch Zeilenabstand
359 sal_Int32 nNetHeight
= nHeight
+ rPD
.nCT
+ rPD
.nCB
;
360 if( pSFlyPara
->nLineSpace
&& pSFlyPara
->nLineSpace
> nNetHeight
)
362 (sal_uInt16
)( pSFlyPara
->nYPos
+ pSFlyPara
->nLineSpace
- nNetHeight
);
364 WW8FlySet
aFlySet(*this, pWFlyPara
, pSFlyPara
, true);
366 SwFmtAnchor
aAnchor(pSFlyPara
->eAnchor
);
367 aAnchor
.SetAnchor(pPaM
->GetPoint());
368 aFlySet
.Put(aAnchor
);
370 aFlySet
.Put( SwFmtFrmSize( ATT_FIX_SIZE
, nWidth
, nHeight
) );
372 SwFlyFrmFmt
* pFlyFmt
= rDoc
.Insert(*pPaM
, rFileName
, aEmptyStr
, pGraph
,
373 &aFlySet
, &rGrfSet
, NULL
);
375 // Damit die Frames bei Einfuegen in existierendes Doc erzeugt werden:
376 if (rDoc
.GetCurrentViewShell() && //swmod 071108//swmod 071225
377 (FLY_AT_PARA
== pFlyFmt
->GetAnchor().GetAnchorId()))
385 // MakeGrafInCntnt fuegt zeichengebundene Grafiken ein
386 SwFrmFmt
* SwWW8ImplReader::MakeGrafInCntnt(const WW8_PIC
& rPic
,
387 const WW8PicDesc
& rPD
, const Graphic
* pGraph
, const String
& rFileName
,
388 const SfxItemSet
& rGrfSet
)
390 WW8FlySet
aFlySet(*this, pPaM
, rPic
, rPD
.nWidth
, rPD
.nHeight
);
392 SwFrmFmt
* pFlyFmt
= 0;
394 if (!rFileName
.Len() && nObjLocFc
) // dann sollte ists ein OLE-Object
395 pFlyFmt
= ImportOle(pGraph
, &aFlySet
, &rGrfSet
);
397 if( !pFlyFmt
) // dann eben als Graphic
400 pFlyFmt
= rDoc
.Insert( *pPaM
, rFileName
, aEmptyStr
, pGraph
, &aFlySet
,
404 // Grafik im Rahmen ? ok, Rahmen auf Bildgroesse vergroessern
405 // ( nur wenn Auto-Breite )
407 pSFlyPara
->BoxUpWidth( rPD
.nWidth
);
411 SwFrmFmt
* SwWW8ImplReader::ImportGraf1(WW8_PIC
& rPic
, SvStream
* pSt
,
415 if( pSt
->IsEof() || rPic
.fError
|| rPic
.MFP
.mm
== 99 )
421 bool bOk
= ReadGrafFile(aFileName
, pGraph
, rPic
, pSt
, nFilePos
, &bInDoc
);
426 return 0; // Grafik nicht korrekt eingelesen
429 WW8PicDesc
aPD( rPic
);
431 SwAttrSet
aGrfSet( rDoc
.GetAttrPool(), RES_GRFATR_BEGIN
, RES_GRFATR_END
-1);
432 if( aPD
.nCL
|| aPD
.nCR
|| aPD
.nCT
|| aPD
.nCB
)
434 SwCropGrf
aCrop( aPD
.nCL
, aPD
.nCR
, aPD
.nCT
, aPD
.nCB
) ;
435 aGrfSet
.Put( aCrop
);
438 if( pWFlyPara
&& pWFlyPara
->bGrafApo
)
439 pRet
= MakeGrafNotInCntnt(aPD
,pGraph
,aFileName
,aGrfSet
);
441 pRet
= MakeGrafInCntnt(rPic
,aPD
,pGraph
,aFileName
,aGrfSet
);
446 void SwWW8ImplReader::PicRead(SvStream
*pDataStream
, WW8_PIC
*pPic
,
449 //Only the first 0x2e bytes are the same between version 6/7 and 8+
450 #ifdef __WW8_NEEDS_COPY
451 WW8_PIC_SHADOW aPicS
;
452 pDataStream
->Read( &aPicS
, sizeof( aPicS
) );
453 WW8PicShadowToReal( &aPicS
, pPic
);
455 pDataStream
->Read( pPic
, 0x2E);
456 #endif // defined __WW8_NEEDS_COPY
457 for (int i
=0;i
<4;i
++)
458 pDataStream
->Read( &pPic
->rgbrc
[i
], bVer67
? 2 : 4);
459 *pDataStream
>> pPic
->dxaOrigin
;
460 *pDataStream
>> pPic
->dyaOrigin
;
462 pDataStream
->SeekRel(2); //cProps
465 SwFrmFmt
* SwWW8ImplReader::ImportGraf(SdrTextObj
* pTextObj
,
466 SwFrmFmt
* pOldFlyFmt
)
470 ((pStrm
== pDataStream
) && !nPicLocFc
) ||
471 (nIniFlags
& WW8FL_NO_GRAF
)
477 ::SetProgressState(nProgress
, mpDocShell
); // Update
482 kleiner Spass von Microsoft: manchmal existiert ein Stream Namens DATA
483 Dieser enthaelt dann den PICF und die entsprechende Grafik !!!
484 Wir mappen ansonsten die Variable pDataStream auf pStream.
487 sal_uLong nOldPos
= pDataStream
->Tell();
489 pDataStream
->Seek( nPicLocFc
);
490 PicRead( pDataStream
, &aPic
, bVer67
);
492 // Plausibilitaetstest ist noetig, da z.B. bei CheckBoxen im
493 // Feld-Result ein WMF-aehnliches Struct vorkommt.
494 if ((aPic
.lcb
>= 58) && !pDataStream
->GetError())
496 if( pFlyFmtOfJustInsertedGraphic
)
498 // Soeben haben wir einen Grafik-Link ins Doc inserted.
499 // Wir muessen ihn jetzt noch Positioniern und Skalieren.
501 WW8PicDesc
aPD( aPic
);
503 WW8FlySet
aFlySet( *this, pPaM
, aPic
, aPD
.nWidth
, aPD
.nHeight
);
505 // the correct anchor is set in Read_F_IncludePicture and the current PaM point's
506 // behind the position if it is anchored in content; because this anchor add
507 // a character into the textnode. IussueZilla task 2806
509 pFlyFmtOfJustInsertedGraphic
->GetAnchor().GetAnchorId() )
511 aFlySet
.ClearItem( RES_ANCHOR
);
514 pFlyFmtOfJustInsertedGraphic
->SetFmtAttr( aFlySet
);
516 pFlyFmtOfJustInsertedGraphic
= 0;
518 else if((0x64 == aPic
.MFP
.mm
) || (0x66 == aPic
.MFP
.mm
))
520 // verlinkte Grafik im Escher-Objekt
521 SdrObject
* pObject
= 0;
523 WW8PicDesc
aPD( aPic
);
525 pMSDffManager
= new SwMSDffManager(*this);
528 Disable use of main stream as fallback stream for inline direct
529 blips as it is known that they are directly after the record
530 header, testing for existance in main stream may lead to an
531 incorrect fallback graphic being found if other escher graphics
532 have been inserted in the document
534 pMSDffManager
->DisableFallbackStream();
535 if( !pMSDffManager
->GetModel() )
536 pMSDffManager
->SetModel(pDrawModel
, 1440);
538 if (0x66 == aPic
.MFP
.mm
)
540 //These ones have names prepended
541 sal_uInt8 nNameLen
=0;
542 *pDataStream
>> nNameLen
;
543 pDataStream
->SeekRel( nNameLen
);
546 Rectangle aChildRect
;
547 Rectangle
aClientRect( 0,0, aPD
.nWidth
, aPD
.nHeight
);
548 SvxMSDffImportData
aData( aClientRect
);
549 pObject
= pMSDffManager
->ImportObj(*pDataStream
, &aData
, aClientRect
, aChildRect
);
553 SfxItemSet
aAttrSet( rDoc
.GetAttrPool(), RES_FRMATR_BEGIN
,
556 SvxMSDffImportRec
const*const pRecord
= (1 == aData
.size())
557 ? &*aData
.begin() : 0;
562 // Horizontal rule may have its width given as % of page width
563 // (-1 is used if not given, 0 means the object has fixed width).
564 // Additionally, if it's a horizontal rule without width given,
565 // assume 100.0% width.
566 int relativeWidth
= pRecord
->relativeHorizontalWidth
;
567 if( relativeWidth
== -1 )
568 relativeWidth
= pRecord
->isHorizontalRule
? 1000 : 0;
569 if( relativeWidth
!= 0 )
571 aPic
.mx
= msword_cast
<sal_uInt16
>(
572 maSectionManager
.GetPageWidth() -
573 maSectionManager
.GetPageRight() -
574 maSectionManager
.GetPageLeft()) * relativeWidth
/ 1000;
575 aPD
= WW8PicDesc( aPic
);
576 // This SetSnapRect() call adjusts the size of the object itself,
577 // no idea why it's this call (or even what the call actually does),
578 // but that's what ImportGraf() (called by ImportObj()) uses.
579 pObject
->SetSnapRect( Rectangle( 0, 0, aPD
.nWidth
, aPD
.nHeight
));
582 //A graphic of this type in this location is always
583 //inline, and uses the pic in the same mould as ww6
585 if (pWFlyPara
&& pWFlyPara
->bGrafApo
)
587 WW8FlySet
aFlySet(*this, pWFlyPara
, pSFlyPara
, true);
589 SwFmtAnchor
aAnchor(pSFlyPara
->eAnchor
);
590 aAnchor
.SetAnchor(pPaM
->GetPoint());
591 aFlySet
.Put(aAnchor
);
593 aAttrSet
.Put(aFlySet
);
597 WW8FlySet
aFlySet( *this, pPaM
, aPic
, aPD
.nWidth
,
600 aAttrSet
.Put(aFlySet
);
602 //Modified for i120716,for graf importing from MS Word 2003 binary format,
603 //there is no border distance.
604 Rectangle
aInnerDist(0,0,0,0);
605 MatchSdrItemsIntoFlySet( pObject
, aAttrSet
,
606 pRecord
->eLineStyle
, pRecord
->eLineDashing
,
607 pRecord
->eShapeType
, aInnerDist
);
609 //Groesse aus der WinWord PIC-Struktur als
610 //Grafik-Groesse nehmen
611 aAttrSet
.Put( SwFmtFrmSize( ATT_FIX_SIZE
, aPD
.nWidth
,
616 SfxItemSet
aGrSet( rDoc
.GetAttrPool(), RES_GRFATR_BEGIN
,
619 if( aPD
.nCL
|| aPD
.nCR
|| aPD
.nCT
|| aPD
.nCB
)
621 SwCropGrf
aCrop( aPD
.nCL
, aPD
.nCR
, aPD
.nCT
, aPD
.nCB
);
626 MatchEscherMirrorIntoFlySet(*pRecord
, aGrSet
);
628 // ggfs. altes AttrSet uebernehmen und
629 // horiz. Positionierungs-Relation korrigieren
632 aAttrSet
.Put( pOldFlyFmt
->GetAttrSet() );
633 const SwFmtHoriOrient
&rHori
= pOldFlyFmt
->GetHoriOrient();
634 if( text::RelOrientation::FRAME
== rHori
.GetRelationOrient() )
636 aAttrSet
.Put( SwFmtHoriOrient( rHori
.GetPos(),
637 text::HoriOrientation::NONE
, text::RelOrientation::PAGE_PRINT_AREA
) );
641 bool bTextObjWasGrouped
= false;
642 if (pOldFlyFmt
&& pTextObj
&& pTextObj
->GetUpGroup())
643 bTextObjWasGrouped
= true;
645 if (bTextObjWasGrouped
)
646 ReplaceObj(*pTextObj
, *pObject
);
649 if (sal_uInt16(OBJ_OLE2
) == pObject
->GetObjIdentifier())
651 // the size from BLIP, if there is any, should be already set
652 pRet
= InsertOle(*((SdrOle2Obj
*)pObject
), aAttrSet
, aGrSet
);
656 if (SdrGrafObj
* pGraphObject
= PTR_CAST(SdrGrafObj
, pObject
))
658 // Nun den Link bzw. die Grafik ins Doc stopfen
659 const Graphic
& rGraph
= pGraphObject
->GetGraphic();
661 if (nObjLocFc
) // is it a OLE-Object?
662 pRet
= ImportOle(&rGraph
, &aAttrSet
, &aGrSet
, pObject
->GetBLIPSizeRectangle());
666 pRet
= rDoc
.Insert(*pPaM
, aEmptyStr
, aEmptyStr
,
667 &rGraph
, &aAttrSet
, &aGrSet
, NULL
);
671 pRet
= rDoc
.Insert(*pPaM
, *pObject
, &aAttrSet
, NULL
);
675 // also nur, wenn wir ein *Insert* gemacht haben
679 SetAttributesAtGrfNode(pRecord
, pRet
, 0);
682 // removed pObject->HasSetName() usage since always returned true,
683 // also removed else-part and wrote an informing mail to Henning Brinkmann
684 // about this to clarify.
685 pRet
->SetName(pObject
->GetName());
687 // Zeiger auf neues Objekt ermitteln und Z-Order-Liste
688 // entsprechend korrigieren (oder Eintrag loeschen)
689 if (SdrObject
* pOurNewObject
= CreateContactObject(pRet
))
691 if (pOurNewObject
!= pObject
)
693 pMSDffManager
->ExchangeInShapeOrder( pObject
, 0, 0,
696 // altes SdrGrafObj aus der Page loeschen und
698 if (pObject
->GetPage())
699 pDrawPg
->RemoveObject(pObject
->GetOrdNum());
700 SdrObject::Free( pObject
);
704 pMSDffManager
->RemoveFromShapeOrder( pObject
);
707 pMSDffManager
->RemoveFromShapeOrder( pObject
);
709 // auch das ggfs. Page loeschen, falls nicht gruppiert,
710 if (pTextObj
&& !bTextObjWasGrouped
&& pTextObj
->GetPage())
711 pDrawPg
->RemoveObject( pTextObj
->GetOrdNum() );
713 pMSDffManager
->EnableFallbackStream();
715 else if (aPic
.lcb
>= 58)
716 pRet
= ImportGraf1(aPic
, pDataStream
, nPicLocFc
);
718 pDataStream
->Seek( nOldPos
);
722 SdrObject
* pOurNewObject
= CreateContactObject(pRet
);
723 pWWZOrder
->InsertTextLayerObject(pOurNewObject
);
726 return AddAutoAnchor(pRet
);
729 #ifdef __WW8_NEEDS_COPY
731 void WW8PicShadowToReal( WW8_PIC_SHADOW
* pPicS
, WW8_PIC
* pPic
)
733 pPic
->lcb
= SVBT32ToUInt32( pPicS
->lcb
);
734 pPic
->cbHeader
= SVBT16ToShort( pPicS
->cbHeader
);
735 pPic
->MFP
.mm
= SVBT16ToShort( pPicS
->MFP
.mm
);
736 pPic
->MFP
.xExt
= SVBT16ToShort( pPicS
->MFP
.xExt
);
737 pPic
->MFP
.yExt
= SVBT16ToShort( pPicS
->MFP
.yExt
);
738 pPic
->MFP
.hMF
= SVBT16ToShort( pPicS
->MFP
.hMF
);
739 for( sal_uInt16 i
= 0; i
< 14 ; i
++ )
740 pPic
->rcWinMF
[i
] = SVBT8ToByte( pPicS
->rcWinMF
[i
] );
741 pPic
->dxaGoal
= SVBT16ToShort( pPicS
->dxaGoal
);
742 pPic
->dyaGoal
= SVBT16ToShort( pPicS
->dyaGoal
);
743 pPic
->mx
= SVBT16ToShort( pPicS
->mx
);
744 pPic
->my
= SVBT16ToShort( pPicS
->my
);
745 pPic
->dxaCropLeft
= SVBT16ToShort( pPicS
->dxaCropLeft
);
746 pPic
->dyaCropTop
= SVBT16ToShort( pPicS
->dyaCropTop
);
747 pPic
->dxaCropRight
= SVBT16ToShort( pPicS
->dxaCropRight
);
748 pPic
->dyaCropBottom
= SVBT16ToShort( pPicS
->dyaCropBottom
);
749 pPic
->brcl
= pPicS
->aBits1
[0] & 0x0f;
750 pPic
->fFrameEmpty
= (pPicS
->aBits1
[0] & 0x10) >> 4;
751 pPic
->fBitmap
= (pPicS
->aBits1
[0] & 0x20) >> 5;
752 pPic
->fDrawHatch
= (pPicS
->aBits1
[0] & 0x40) >> 6;
753 pPic
->fError
= (pPicS
->aBits1
[0] & 0x80) >> 7;
754 pPic
->bpp
= pPicS
->aBits2
[0];
757 void WW8FSPAShadowToReal( WW8_FSPA_SHADOW
* pFSPAS
, WW8_FSPA
* pFSPA
)
759 pFSPA
->nSpId
= SVBT32ToUInt32( pFSPAS
->nSpId
);
760 pFSPA
->nXaLeft
= SVBT32ToUInt32( pFSPAS
->nXaLeft
);
761 pFSPA
->nYaTop
= SVBT32ToUInt32( pFSPAS
->nYaTop
);
762 pFSPA
->nXaRight
= SVBT32ToUInt32( pFSPAS
->nXaRight
);
763 pFSPA
->nYaBottom
= SVBT32ToUInt32( pFSPAS
->nYaBottom
);
765 sal_uInt16 nBits
= SVBT16ToShort( pFSPAS
->aBits1
);
767 pFSPA
->bHdr
= 0 != ( nBits
& 0x0001 );
768 pFSPA
->nbx
= ( nBits
& 0x0006 ) >> 1;
769 pFSPA
->nby
= ( nBits
& 0x0018 ) >> 3;
770 pFSPA
->nwr
= ( nBits
& 0x01E0 ) >> 5;
771 pFSPA
->nwrk
= ( nBits
& 0x1E00 ) >> 9;
772 pFSPA
->bRcaSimple
= 0 != ( nBits
& 0x2000 );
773 pFSPA
->bBelowText
= 0 != ( nBits
& 0x4000 );
774 pFSPA
->bAnchorLock
= 0 != ( nBits
& 0x8000 );
775 pFSPA
->nTxbx
= SVBT32ToUInt32( pFSPAS
->nTxbx
);
777 #endif // defined __WW8_NEEDS_COPY
779 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */