1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ww8graf2.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
36 #ifndef __SGI_STL_ITERATOR
39 #include <hintids.hxx>
40 #include <svtools/urihelper.hxx>
41 #include <svx/impgrf.hxx>
42 #include <svx/svdpage.hxx>
43 #include <svx/svdmodel.hxx>
44 #include <svx/svdograf.hxx>
45 #include <svx/svdoole2.hxx>
46 #include <svx/opaqitem.hxx>
47 #include <svx/msdffimp.hxx>
48 #include <sfx2/app.hxx>
49 #include <sfx2/docfile.hxx>
50 #include <sfx2/fcontnr.hxx>
51 #include <dcontact.hxx>
52 #include <grfatr.hxx> // class SwCropGrf
53 #include <fmtflcnt.hxx>
54 #include <fmtanchr.hxx>
56 #include <fltshell.hxx>
59 #include <ndtxt.hxx> // class SwTxtNode
60 #include <mdiexp.hxx> // Progress
61 #include "writerwordglue.hxx"
62 #include "ww8struc.hxx"
63 #include "ww8scan.hxx"
64 #include "ww8par.hxx" // class SwWWImplReader
65 #include "ww8par2.hxx" // struct WWFlyPara
66 #include "ww8graf.hxx"
68 using namespace ::com::sun::star
;
69 using namespace sw::types
;
71 wwZOrderer::wwZOrderer(const sw::util::SetLayer
&rSetLayer
, SdrPage
* pDrawPg
,
72 const SvxMSDffShapeOrders
*pShapeOrders
)
73 : maSetLayer(rSetLayer
), mnInlines(0), mpDrawPg(pDrawPg
),
74 mpShapeOrders(pShapeOrders
)
76 mnNoInitialObjects
= mpDrawPg
->GetObjCount();
77 ASSERT(mpDrawPg
,"Missing draw page impossible!");
80 void wwZOrderer::InsideEscher(ULONG nSpId
)
82 maIndexes
.push(GetEscherObjectIdx(nSpId
));
85 void wwZOrderer::OutsideEscher()
90 // --> OD 2004-12-13 #117915# - consider new parameter <_bInHeaderFooter>
91 void wwZOrderer::InsertEscherObject( SdrObject
* pObject
,
93 const bool _bInHeaderFooter
)
95 ULONG nInsertPos
= GetEscherObjectPos( nSpId
, _bInHeaderFooter
);
97 InsertObject(pObject
, nInsertPos
+ mnNoInitialObjects
+ mnInlines
);
100 wwZOrderer::myeiter
wwZOrderer::MapEscherIdxToIter(ULONG nIdx
)
102 myeiter aIter
= maEscherLayer
.begin();
103 myeiter aEnd
= maEscherLayer
.end();
104 while (aIter
!= aEnd
)
106 if (aIter
->mnEscherShapeOrder
== nIdx
)
113 USHORT
wwZOrderer::GetEscherObjectIdx(ULONG nSpId
)
116 USHORT nShapeCount
= mpShapeOrders
? mpShapeOrders
->Count() : 0;
117 // First, find out what position this shape is in in the Escher order.
118 for (USHORT nShapePos
=0; nShapePos
< nShapeCount
; nShapePos
++)
120 const SvxMSDffShapeOrder
*pOrder
= mpShapeOrders
->GetObject(nShapePos
);
121 if (pOrder
->nShapeId
== nSpId
)
130 // --> OD 2004-12-13 #117915# - consider new parameter <_bInHeaderFooter>
131 ULONG
wwZOrderer::GetEscherObjectPos( ULONG nSpId
,
132 const bool _bInHeaderFooter
)
135 #97824# EscherObjects have their own ordering which needs to be matched to
136 the actual ordering that should be used when inserting them into the
139 USHORT nFound
= GetEscherObjectIdx(nSpId
);
140 // Match the ordering position from the ShapeOrders to the ordering of all
141 // objects in the document, there is a complexity when escherobjects
142 // contain inlines objects, we need to consider thsose as part of the
145 myeiter aIter
= maEscherLayer
.begin();
146 myeiter aEnd
= maEscherLayer
.end();
147 // --> OD 2004-12-13 #117915# - skip objects in page header|footer, if
148 // current object isn't in page header|footer
149 if ( !_bInHeaderFooter
)
151 while ( aIter
!= aEnd
)
153 if ( !aIter
->mbInHeaderFooter
)
157 nRet
+= aIter
->mnNoInlines
+ 1;
162 while (aIter
!= aEnd
)
164 // --> OD 2004-12-13 #117915# - insert object in page header|footer
165 // before objects in page body
166 if ( _bInHeaderFooter
&& !aIter
->mbInHeaderFooter
)
171 if ( aIter
->mnEscherShapeOrder
> nFound
)
173 nRet
+= aIter
->mnNoInlines
+1;
176 maEscherLayer
.insert(aIter
, EscherShape( nFound
, _bInHeaderFooter
) );
181 // InsertObj() fuegt das Objekt in die Sw-Page ein und merkt sich die Z-Pos in
183 void wwZOrderer::InsertDrawingObject(SdrObject
* pObj
, short nWwHeight
)
185 ULONG nPos
= GetDrawingObjectPos(nWwHeight
);
186 if (nWwHeight
& 0x2000) // Heaven ?
187 maSetLayer
.SendObjectToHeaven(*pObj
);
189 maSetLayer
.SendObjectToHell(*pObj
);
191 InsertObject(pObj
, nPos
+ mnNoInitialObjects
+ mnInlines
);
194 void wwZOrderer::InsertTextLayerObject(SdrObject
* pObject
)
196 maSetLayer
.SendObjectToHeaven(*pObject
);
197 if (maIndexes
.empty())
199 InsertObject(pObject
, mnNoInitialObjects
+ mnInlines
);
204 //If we are inside an escher objects, place us just after that
205 //escher obj, and increment its inline count
206 USHORT nIdx
= maIndexes
.top();
207 myeiter aEnd
= MapEscherIdxToIter(nIdx
);
210 myeiter aIter
= maEscherLayer
.begin();
211 while (aIter
!= aEnd
)
213 nInsertPos
+= aIter
->mnNoInlines
+1;
217 ASSERT(aEnd
!= maEscherLayer
.end(), "Something very wrong here");
218 if (aEnd
!= maEscherLayer
.end())
221 nInsertPos
+= aEnd
->mnNoInlines
;
224 InsertObject(pObject
, mnNoInitialObjects
+ mnInlines
+ nInsertPos
);
228 // Parallel zu dem Obj-Array im Dokument baue ich ein Array auf,
229 // dass die Ww-Height ( -> Wer ueberdeckt wen ) beinhaltet.
230 // Anhand dieses VARARR wird die Einfuegeposition ermittelt.
231 // Der Offset bei Datei in bestehendes Dokument mit Grafiklayer einfuegen
232 // muss der Aufrufer den Index um mnNoInitialObjects erhoeht werden, damit die
233 // neuen Objekte am Ende landen ( Einfuegen ist dann schneller )
234 ULONG
wwZOrderer::GetDrawingObjectPos(short nWwHeight
)
236 myditer aIter
= maDrawHeight
.begin();
237 myditer aEnd
= maDrawHeight
.end();
239 while (aIter
!= aEnd
)
241 if ((*aIter
& 0x1fff) > (nWwHeight
& 0x1fff))
246 aIter
= maDrawHeight
.insert(aIter
, nWwHeight
);
247 return std::distance(maDrawHeight
.begin(), aIter
);
250 bool wwZOrderer::InsertObject(SdrObject
* pObject
, ULONG nPos
)
252 if (!pObject
->IsInserted())
254 mpDrawPg
->InsertObject(pObject
, nPos
);
260 #ifdef __WW8_NEEDS_COPY
261 extern void WW8PicShadowToReal( WW8_PIC_SHADOW
* pPicS
, WW8_PIC
* pPic
);
262 #endif // defined __WW8_NEEDS_COPY
264 bool SwWW8ImplReader::GetPictGrafFromStream(Graphic
& rGraphic
, SvStream
& rSrc
)
266 return 0 == ::GetGrfFilter()->ImportGraphic(rGraphic
, aEmptyStr
, rSrc
,
267 GRFILTER_FORMAT_DONTKNOW
);
270 bool SwWW8ImplReader::ReadGrafFile(String
& rFileName
, Graphic
*& rpGraphic
,
271 const WW8_PIC
& rPic
, SvStream
* pSt
, ULONG nFilePos
, bool* pbInDoc
)
272 { // Grafik in File schreiben
273 *pbInDoc
= true; // default
275 ULONG nPosFc
= nFilePos
+ rPic
.cbHeader
;
279 case 94: // BMP-File ( nicht embeddet ) oder GIF
280 case 99: // TIFF-File ( nicht embeddet )
282 // Name als P-String einlesen
283 rFileName
= WW8ReadPString(*pSt
, eStructCharSet
, 0);
285 rFileName
= URIHelper::SmartRel2Abs(
286 INetURLObject(sBaseURL
), rFileName
,
287 URIHelper::GetMaybeFileHdl());
288 *pbInDoc
= false; // Datei anschliessend nicht loeschen
289 return rFileName
.Len() != 0; // Einlesen OK
294 bool bOk
= ReadWindowMetafile( *pSt
, aWMF
, NULL
) ? true : false;
296 if (!bOk
|| pSt
->GetError() || !aWMF
.GetActionCount())
299 if (pWwFib
->envr
!= 1) // !MAC als Creator
302 /* SJ: #i40742#, we will use the prefsize from the mtf directly.
303 The scaling has been done in former days, because the wmf filter was sometimes not
304 able to calculate the proper prefsize (especially if the wmf fileheader was missing)
307 aWMF.SetPrefMapMode( MapMode( MAP_100TH_MM ) );
308 // MetaFile auf neue Groesse skalieren und
309 // neue Groesse am MetaFile setzen
310 if (rPic.MFP.xExt && rPic.MFP.yExt)
312 Size aOldSiz(aWMF.GetPrefSize());
313 Size aNewSiz(rPic.MFP.xExt, rPic.MFP.yExt );
314 Fraction aFracX(aNewSiz.Width(), aOldSiz.Width());
315 Fraction aFracY(aNewSiz.Height(), aOldSiz.Height());
317 aWMF.Scale(aFracX, aFracY);
318 aWMF.SetPrefSize(aNewSiz);
321 rpGraphic
= new Graphic( aWMF
);
325 // MAC - Word als Creator
326 // im WMF steht nur "Benutzen sie Word 6.0c" Mac-Pict steht dahinter
327 // allerdings ohne die ersten 512 Bytes, bei einem MAC-PICT egal sind (
328 // werden nicht ausgewertet )
330 long nData
= rPic
.lcb
- ( pSt
->Tell() - nPosFc
);
333 rpGraphic
= new Graphic();
334 if (0 == (bOk
= SwWW8ImplReader::GetPictGrafFromStream(*rpGraphic
, *pSt
)))
337 return bOk
; // Grafik drin
342 INT16 nCL
, nCR
, nCT
, nCB
;
343 long nWidth
, nHeight
;
345 WW8PicDesc( const WW8_PIC
& rPic
);
348 WW8PicDesc::WW8PicDesc( const WW8_PIC
& rPic
)
350 //See #i21190# before fiddling with this method
351 long nOriWidth
= rPic
.dxaGoal
; //Size in 1/100 mm before crop
352 long nOriHeight
= rPic
.dyaGoal
;
354 nCL
= rPic
.dxaCropLeft
;
355 nCR
= rPic
.dxaCropRight
;
356 nCT
= rPic
.dyaCropTop
;
357 nCB
= rPic
.dyaCropBottom
;
359 long nAktWidth
= nOriWidth
- (nCL
+ nCR
); // Size after crop
360 long nAktHeight
= nOriHeight
- (nCT
+ nCB
);
365 nWidth
= nAktWidth
* rPic
.mx
/ 1000; // Writer Size
366 nHeight
= nAktHeight
* rPic
.my
/ 1000;
369 void SwWW8ImplReader::ReplaceObj(const SdrObject
&rReplaceObj
,
372 // SdrGrafObj anstatt des SdrTextObj in dessen Gruppe einsetzen
373 if (SdrObject
* pGroupObject
= rReplaceObj
.GetUpGroup())
375 SdrObjList
* pObjectList
= pGroupObject
->GetSubList();
377 rSubObj
.SetLogicRect(rReplaceObj
.GetCurrentBoundRect());
378 rSubObj
.SetLayer(rReplaceObj
.GetLayer());
380 // altes Objekt raus aus Gruppen-Liste und neues rein
381 // (dies tauscht es ebenfalls in der Drawing-Page aus)
382 pObjectList
->ReplaceObject(&rSubObj
, rReplaceObj
.GetOrdNum());
386 ASSERT( !this, "Impossible!");
390 // MakeGrafNotInCntnt setzt eine nicht-Zeichengebundene Grafik
391 // ( bGrafApo == true)
392 SwFlyFrmFmt
* SwWW8ImplReader::MakeGrafNotInCntnt(const WW8PicDesc
& rPD
,
393 const Graphic
* pGraph
, const String
& rFileName
, const SfxItemSet
& rGrfSet
)
396 UINT32 nWidth
= rPD
.nWidth
;
397 UINT32 nHeight
= rPD
.nHeight
;
399 // Vertikale Verschiebung durch Zeilenabstand
400 INT32 nNetHeight
= nHeight
+ rPD
.nCT
+ rPD
.nCB
;
401 if( pSFlyPara
->nLineSpace
&& pSFlyPara
->nLineSpace
> nNetHeight
)
403 (USHORT
)( pSFlyPara
->nYPos
+ pSFlyPara
->nLineSpace
- nNetHeight
);
405 WW8FlySet
aFlySet(*this, pWFlyPara
, pSFlyPara
, true);
407 SwFmtAnchor
aAnchor(pSFlyPara
->eAnchor
);
408 aAnchor
.SetAnchor(pPaM
->GetPoint());
409 aFlySet
.Put(aAnchor
);
411 aFlySet
.Put( SwFmtFrmSize( ATT_FIX_SIZE
, nWidth
, nHeight
) );
413 SwFlyFrmFmt
* pFlyFmt
= rDoc
.Insert(*pPaM
, rFileName
, aEmptyStr
, pGraph
,
414 &aFlySet
, &rGrfSet
, NULL
);
416 // Damit die Frames bei Einfuegen in existierendes Doc erzeugt werden:
417 if (rDoc
.GetRootFrm() &&
418 (FLY_AT_CNTNT
== pFlyFmt
->GetAnchor().GetAnchorId()))
426 // MakeGrafInCntnt fuegt zeichengebundene Grafiken ein
427 SwFrmFmt
* SwWW8ImplReader::MakeGrafInCntnt(const WW8_PIC
& rPic
,
428 const WW8PicDesc
& rPD
, const Graphic
* pGraph
, const String
& rFileName
,
429 const SfxItemSet
& rGrfSet
)
431 WW8FlySet
aFlySet(*this, pPaM
, rPic
, rPD
.nWidth
, rPD
.nHeight
);
433 SwFrmFmt
* pFlyFmt
= 0;
435 if (!rFileName
.Len() && nObjLocFc
) // dann sollte ists ein OLE-Object
436 pFlyFmt
= ImportOle(pGraph
, &aFlySet
, &rGrfSet
);
438 if( !pFlyFmt
) // dann eben als Graphic
441 pFlyFmt
= rDoc
.Insert( *pPaM
, rFileName
, aEmptyStr
, pGraph
, &aFlySet
,
445 // Grafik im Rahmen ? ok, Rahmen auf Bildgroesse vergroessern
446 // ( nur wenn Auto-Breite )
448 pSFlyPara
->BoxUpWidth( rPD
.nWidth
);
452 SwFrmFmt
* SwWW8ImplReader::ImportGraf1(WW8_PIC
& rPic
, SvStream
* pSt
,
456 if( pSt
->IsEof() || rPic
.fError
|| rPic
.MFP
.mm
== 99 )
462 bool bOk
= ReadGrafFile(aFileName
, pGraph
, rPic
, pSt
, nFilePos
, &bInDoc
);
467 return 0; // Grafik nicht korrekt eingelesen
470 WW8PicDesc
aPD( rPic
);
472 SwAttrSet
aGrfSet( rDoc
.GetAttrPool(), RES_GRFATR_BEGIN
, RES_GRFATR_END
-1);
473 if( aPD
.nCL
|| aPD
.nCR
|| aPD
.nCT
|| aPD
.nCB
)
475 SwCropGrf
aCrop( aPD
.nCL
, aPD
.nCR
, aPD
.nCT
, aPD
.nCB
) ;
476 aGrfSet
.Put( aCrop
);
479 if( pWFlyPara
&& pWFlyPara
->bGrafApo
)
480 pRet
= MakeGrafNotInCntnt(aPD
,pGraph
,aFileName
,aGrfSet
);
482 pRet
= MakeGrafInCntnt(rPic
,aPD
,pGraph
,aFileName
,aGrfSet
);
487 void SwWW8ImplReader::PicRead(SvStream
*pDataStream
, WW8_PIC
*pPic
,
490 //Only the first 0x2e bytes are the same between version 6/7 and 8+
491 #ifdef __WW8_NEEDS_COPY
492 WW8_PIC_SHADOW aPicS
;
493 pDataStream
->Read( &aPicS
, sizeof( aPicS
) );
494 WW8PicShadowToReal( &aPicS
, pPic
);
496 pDataStream
->Read( pPic
, 0x2E);
497 #endif // defined __WW8_NEEDS_COPY
498 for (int i
=0;i
<4;i
++)
499 pDataStream
->Read( &pPic
->rgbrc
[i
], bVer67
? 2 : 4);
500 *pDataStream
>> pPic
->dxaOrigin
;
501 *pDataStream
>> pPic
->dyaOrigin
;
503 pDataStream
->SeekRel(2); //cProps
506 SwFrmFmt
* SwWW8ImplReader::ImportGraf(SdrTextObj
* pTextObj
,
507 SwFrmFmt
* pOldFlyFmt
)
511 ((pStrm
== pDataStream
) && !nPicLocFc
) ||
512 (nIniFlags
& WW8FL_NO_GRAF
)
518 ::SetProgressState(nProgress
, mpDocShell
); // Update
523 kleiner Spass von Microsoft: manchmal existiert ein Stream Namens DATA
524 Dieser enthaelt dann den PICF und die entsprechende Grafik !!!
525 Wir mappen ansonsten die Variable pDataStream auf pStream.
528 ULONG nOldPos
= pDataStream
->Tell();
530 pDataStream
->Seek( nPicLocFc
);
531 PicRead( pDataStream
, &aPic
, bVer67
);
533 // Plausibilitaetstest ist noetig, da z.B. bei CheckBoxen im
534 // Feld-Result ein WMF-aehnliches Struct vorkommt.
535 if ((aPic
.lcb
>= 58) && !pDataStream
->GetError())
537 if( pFlyFmtOfJustInsertedGraphic
)
539 // Soeben haben wir einen Grafik-Link ins Doc inserted.
540 // Wir muessen ihn jetzt noch Positioniern und Skalieren.
542 WW8PicDesc
aPD( aPic
);
544 WW8FlySet
aFlySet( *this, pPaM
, aPic
, aPD
.nWidth
, aPD
.nHeight
);
546 //JP 17.1.2002: the correct anchor is set in Read_F_IncludePicture
547 // and the current PaM point's behind the position if
548 // it is anchored in content; because this anchor add
549 // a character into the textnode.
550 // IussueZilla task 2806
552 pFlyFmtOfJustInsertedGraphic
->GetAnchor().GetAnchorId() )
553 aFlySet
.ClearItem( RES_ANCHOR
);
555 pFlyFmtOfJustInsertedGraphic
->SetFmtAttr( aFlySet
);
557 pFlyFmtOfJustInsertedGraphic
= 0;
559 else if((0x64 == aPic
.MFP
.mm
) || (0x66 == aPic
.MFP
.mm
))
561 // verlinkte Grafik im Escher-Objekt
562 SdrObject
* pObject
= 0;
564 //#i17200#, a bit of guesswork I'm afraid
565 if (aPic
.dxaGoal
== 1000 && aPic
.mx
== 1) //100% hack ?
567 aPic
.mx
= msword_cast
<sal_uInt16
>(
568 maSectionManager
.GetPageWidth() -
569 maSectionManager
.GetPageRight() -
570 maSectionManager
.GetPageLeft());
573 WW8PicDesc
aPD( aPic
);
576 pMSDffManager
= new SwMSDffManager(*this);
579 Disable use of main stream as fallback stream for inline direct
580 blips as it is known that they are directly after the record
581 header, testing for existance in main stream may lead to an
582 incorrect fallback graphic being found if other escher graphics
583 have been inserted in the document
585 pMSDffManager
->DisableFallbackStream();
586 if( !pMSDffManager
->GetModel() )
587 pMSDffManager
->SetModel(pDrawModel
, 1440);
589 if (0x66 == aPic
.MFP
.mm
)
591 //These ones have names prepended
593 *pDataStream
>> nNameLen
;
594 pDataStream
->SeekRel( nNameLen
);
597 Rectangle aChildRect
;
598 Rectangle
aClientRect( 0,0, aPD
.nWidth
, aPD
.nHeight
);
599 SvxMSDffImportData
aData( aClientRect
);
600 pObject
= pMSDffManager
->ImportObj(*pDataStream
, &aData
, aClientRect
, aChildRect
);
604 SfxItemSet
aAttrSet( rDoc
.GetAttrPool(), RES_FRMATR_BEGIN
,
607 SvxMSDffImportRec
*pRecord
=
608 (aData
.HasRecords() && (1 == aData
.GetRecCount() ) ) ?
609 aData
.GetRecord( 0 ) : 0;
613 //A graphic of this type in this location is always
614 //inline, and uses the pic in the same mould as ww6
616 if (pWFlyPara
&& pWFlyPara
->bGrafApo
)
618 WW8FlySet
aFlySet(*this, pWFlyPara
, pSFlyPara
, true);
620 SwFmtAnchor
aAnchor(pSFlyPara
->eAnchor
);
621 aAnchor
.SetAnchor(pPaM
->GetPoint());
622 aFlySet
.Put(aAnchor
);
624 aAttrSet
.Put(aFlySet
);
628 WW8FlySet
aFlySet( *this, pPaM
, aPic
, aPD
.nWidth
,
631 aAttrSet
.Put(aFlySet
);
634 Rectangle
aInnerDist( pRecord
->nDxTextLeft
,
635 pRecord
->nDyTextTop
, pRecord
->nDxTextRight
,
636 pRecord
->nDyTextBottom
);
638 MatchSdrItemsIntoFlySet( pObject
, aAttrSet
,
639 pRecord
->eLineStyle
, pRecord
->eShapeType
,
642 //Groesse aus der WinWord PIC-Struktur als
643 //Grafik-Groesse nehmen
644 aAttrSet
.Put( SwFmtFrmSize( ATT_FIX_SIZE
, aPD
.nWidth
,
649 SfxItemSet
aGrSet( rDoc
.GetAttrPool(), RES_GRFATR_BEGIN
,
652 if( aPD
.nCL
|| aPD
.nCR
|| aPD
.nCT
|| aPD
.nCB
)
654 SwCropGrf
aCrop( aPD
.nCL
, aPD
.nCR
, aPD
.nCT
, aPD
.nCB
);
659 MatchEscherMirrorIntoFlySet(*pRecord
, aGrSet
);
661 // ggfs. altes AttrSet uebernehmen und
662 // horiz. Positionierungs-Relation korrigieren
665 aAttrSet
.Put( pOldFlyFmt
->GetAttrSet() );
666 const SwFmtHoriOrient
&rHori
= pOldFlyFmt
->GetHoriOrient();
667 if( text::RelOrientation::FRAME
== rHori
.GetRelationOrient() )
669 aAttrSet
.Put( SwFmtHoriOrient( rHori
.GetPos(),
670 text::HoriOrientation::NONE
, text::RelOrientation::PAGE_PRINT_AREA
) );
674 bool bTextObjWasGrouped
= false;
675 if (pOldFlyFmt
&& pTextObj
&& pTextObj
->GetUpGroup())
676 bTextObjWasGrouped
= true;
678 if (bTextObjWasGrouped
)
679 ReplaceObj(*pTextObj
, *pObject
);
682 if (UINT16(OBJ_OLE2
) == pObject
->GetObjIdentifier())
684 // the size from BLIP, if there is any, should be already set
685 pRet
= InsertOle(*((SdrOle2Obj
*)pObject
), aAttrSet
, aGrSet
);
689 if (SdrGrafObj
* pGraphObject
= PTR_CAST(SdrGrafObj
, pObject
))
691 // Nun den Link bzw. die Grafik ins Doc stopfen
692 const Graphic
& rGraph
= pGraphObject
->GetGraphic();
694 if (nObjLocFc
) // is it a OLE-Object?
695 pRet
= ImportOle(&rGraph
, &aAttrSet
, &aGrSet
, pObject
->GetBLIPSizeRectangle());
699 pRet
= rDoc
.Insert(*pPaM
, aEmptyStr
, aEmptyStr
,
700 &rGraph
, &aAttrSet
, &aGrSet
, NULL
);
704 pRet
= rDoc
.Insert(*pPaM
, *pObject
, &aAttrSet
, NULL
);
708 // also nur, wenn wir ein *Insert* gemacht haben
712 SetAttributesAtGrfNode(pRecord
, pRet
, 0);
715 // removed pObject->HasSetName() usage since always returned true,
716 // also removed else-part and wrote an informing mail to Henning Brinkmann
717 // about this to clarify.
718 pRet
->SetName(pObject
->GetName());
720 // Zeiger auf neues Objekt ermitteln und Z-Order-Liste
721 // entsprechend korrigieren (oder Eintrag loeschen)
722 if (SdrObject
* pOurNewObject
= CreateContactObject(pRet
))
724 if (pOurNewObject
!= pObject
)
726 pMSDffManager
->ExchangeInShapeOrder( pObject
, 0, 0,
729 // altes SdrGrafObj aus der Page loeschen und
731 if (pObject
->GetPage())
732 pDrawPg
->RemoveObject(pObject
->GetOrdNum());
733 SdrObject::Free( pObject
);
737 pMSDffManager
->RemoveFromShapeOrder( pObject
);
740 pMSDffManager
->RemoveFromShapeOrder( pObject
);
742 // auch das ggfs. Page loeschen, falls nicht gruppiert,
743 if (pTextObj
&& !bTextObjWasGrouped
&& pTextObj
->GetPage())
744 pDrawPg
->RemoveObject( pTextObj
->GetOrdNum() );
746 pMSDffManager
->EnableFallbackStream();
748 else if (aPic
.lcb
>= 58)
749 pRet
= ImportGraf1(aPic
, pDataStream
, nPicLocFc
);
751 pDataStream
->Seek( nOldPos
);
755 SdrObject
* pOurNewObject
= CreateContactObject(pRet
);
756 pWWZOrder
->InsertTextLayerObject(pOurNewObject
);
759 return AddAutoAnchor(pRet
);
762 #ifdef __WW8_NEEDS_COPY
764 void WW8PicShadowToReal( WW8_PIC_SHADOW
* pPicS
, WW8_PIC
* pPic
)
766 pPic
->lcb
= SVBT32ToUInt32( pPicS
->lcb
);
767 pPic
->cbHeader
= SVBT16ToShort( pPicS
->cbHeader
);
768 pPic
->MFP
.mm
= SVBT16ToShort( pPicS
->MFP
.mm
);
769 pPic
->MFP
.xExt
= SVBT16ToShort( pPicS
->MFP
.xExt
);
770 pPic
->MFP
.yExt
= SVBT16ToShort( pPicS
->MFP
.yExt
);
771 pPic
->MFP
.hMF
= SVBT16ToShort( pPicS
->MFP
.hMF
);
772 for( USHORT i
= 0; i
< 14 ; i
++ )
773 pPic
->rcWinMF
[i
] = SVBT8ToByte( pPicS
->rcWinMF
[i
] );
774 pPic
->dxaGoal
= SVBT16ToShort( pPicS
->dxaGoal
);
775 pPic
->dyaGoal
= SVBT16ToShort( pPicS
->dyaGoal
);
776 pPic
->mx
= SVBT16ToShort( pPicS
->mx
);
777 pPic
->my
= SVBT16ToShort( pPicS
->my
);
778 pPic
->dxaCropLeft
= SVBT16ToShort( pPicS
->dxaCropLeft
);
779 pPic
->dyaCropTop
= SVBT16ToShort( pPicS
->dyaCropTop
);
780 pPic
->dxaCropRight
= SVBT16ToShort( pPicS
->dxaCropRight
);
781 pPic
->dyaCropBottom
= SVBT16ToShort( pPicS
->dyaCropBottom
);
782 pPic
->brcl
= pPicS
->aBits1
[0] & 0x0f;
783 pPic
->fFrameEmpty
= (pPicS
->aBits1
[0] & 0x10) >> 4;
784 pPic
->fBitmap
= (pPicS
->aBits1
[0] & 0x20) >> 5;
785 pPic
->fDrawHatch
= (pPicS
->aBits1
[0] & 0x40) >> 6;
786 pPic
->fError
= (pPicS
->aBits1
[0] & 0x80) >> 7;
787 pPic
->bpp
= pPicS
->aBits2
[0];
790 void WW8FSPAShadowToReal( WW8_FSPA_SHADOW
* pFSPAS
, WW8_FSPA
* pFSPA
)
792 //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.
793 //long nXaLeft; //left of rectangle enclosing shape relative to the origin of the shape
794 //long nYaTop; //top of rectangle enclosing shape relative to the origin of the shape
795 //long nXaRight; //right of rectangle enclosing shape relative to the origin of the shape
796 //long nYaBottom;//bottom of the rectangle enclosing shape relative to the origin of the shape
802 //USHORT bRcaSimple:1;
803 //USHORT bAnchorLock:1;
804 //long nTxbx; //count of textboxes in shape (undo doc only)
807 pFSPA
->nSpId
= SVBT32ToUInt32( pFSPAS
->nSpId
);
808 pFSPA
->nXaLeft
= SVBT32ToUInt32( pFSPAS
->nXaLeft
);
809 pFSPA
->nYaTop
= SVBT32ToUInt32( pFSPAS
->nYaTop
);
810 pFSPA
->nXaRight
= SVBT32ToUInt32( pFSPAS
->nXaRight
);
811 pFSPA
->nYaBottom
= SVBT32ToUInt32( pFSPAS
->nYaBottom
);
813 USHORT nBits
= SVBT16ToShort( pFSPAS
->aBits1
);
815 pFSPA
->bHdr
= 0 != ( nBits
& 0x0001 );
816 pFSPA
->nbx
= ( nBits
& 0x0006 ) >> 1;
817 pFSPA
->nby
= ( nBits
& 0x0018 ) >> 3;
818 pFSPA
->nwr
= ( nBits
& 0x01E0 ) >> 5;
819 pFSPA
->nwrk
= ( nBits
& 0x1E00 ) >> 9;
820 pFSPA
->bRcaSimple
= 0 != ( nBits
& 0x2000 );
821 pFSPA
->bBelowText
= 0 != ( nBits
& 0x4000 );
822 pFSPA
->bAnchorLock
= 0 != ( nBits
& 0x8000 );
823 pFSPA
->nTxbx
= SVBT32ToUInt32( pFSPAS
->nTxbx
);
825 #endif // defined __WW8_NEEDS_COPY
827 /* vi:set tabstop=4 shiftwidth=4 expandtab: */