View | Details | Raw Unified | Return to issue 3958
Collapse All | Expand All

(-)escher.hxx (+1 lines)
Lines 114-119 Link Here
114
    SwBasicEscherEx(SvStream* pStrm, SwWW8Writer& rWrt, UINT32 nDrawings = 1);
114
    SwBasicEscherEx(SvStream* pStrm, SwWW8Writer& rWrt, UINT32 nDrawings = 1);
115
    INT32 WriteGrfFlyFrame(const SwFrmFmt& rFmt, UINT32 nShapeId);
115
    INT32 WriteGrfFlyFrame(const SwFrmFmt& rFmt, UINT32 nShapeId);
116
    INT32 WriteOLEFlyFrame(const SwFrmFmt& rFmt, UINT32 nShapeId);
116
    INT32 WriteOLEFlyFrame(const SwFrmFmt& rFmt, UINT32 nShapeId);
117
    void WriteEmptyFlyFrame(const SwFrmFmt& rFmt, UINT32 nShapeId);
117
    virtual void WriteFrmExtraData(const SwFrmFmt&);
118
    virtual void WriteFrmExtraData(const SwFrmFmt&);
118
    virtual void WritePictures();
119
    virtual void WritePictures();
119
    virtual ~SwBasicEscherEx();
120
    virtual ~SwBasicEscherEx();
(-)writerhelper.cxx (-52 / +155 lines)
Lines 77-82 Link Here
77
#ifndef _FRMFMT_HXX
77
#ifndef _FRMFMT_HXX
78
#include <frmfmt.hxx>       //SwFrmFmt
78
#include <frmfmt.hxx>       //SwFrmFmt
79
#endif
79
#endif
80
#ifndef _FMTCNTNT_HXX
81
#include <fmtcntnt.hxx>     //SwFmtCntnt
82
#endif
80
#ifndef _FLYPOS_HXX
83
#ifndef _FLYPOS_HXX
81
#include <flypos.hxx>       //SwPosFlyFrms
84
#include <flypos.hxx>       //SwPosFlyFrms
82
#endif
85
#endif
Lines 86-91 Link Here
86
#ifndef _NDTXT_HXX
89
#ifndef _NDTXT_HXX
87
#include <ndtxt.hxx>        //SwTxtNode
90
#include <ndtxt.hxx>        //SwTxtNode
88
#endif
91
#endif
92
#ifndef _NDGRF_HXX
93
#include <ndgrf.hxx>        //SwGrfNode
94
#endif
95
#ifndef _NDNOTXT_HXX
96
#include <ndnotxt.hxx>      //SwNoTxtNode
97
#endif
98
#ifndef _FMTFSIZE_HXX
99
#include <fmtfsize.hxx>     //SwFmtFrmSize
100
#endif
89
#ifndef _SVDOBJ_HXX
101
#ifndef _SVDOBJ_HXX
90
#include <svx/svdobj.hxx>   //SdrObject
102
#include <svx/svdobj.hxx>   //SdrObject
91
#endif
103
#endif
Lines 180-191 Link Here
180
            return (mnNode == rFrame.GetPosition().nNode.GetNode().GetIndex());
192
            return (mnNode == rFrame.GetPosition().nNode.GetNode().GetIndex());
181
        }
193
        }
182
    };
194
    };
195
196
    Size GetSwappedInSize(const SwNoTxtNode& rNd)
197
    {
198
        Size aGrTwipSz(rNd.GetTwipSize());
199
        if ((!aGrTwipSz.Width() || !aGrTwipSz.Height()))
200
        {
201
            SwGrfNode *pGrfNode = const_cast<SwGrfNode*>(rNd.GetGrfNode());
202
            if (pGrfNode && (GRAPHIC_NONE != pGrfNode->GetGrf().GetType()))
203
            {
204
                bool bWasSwappedOut = pGrfNode->GetGrfObj().IsSwappedOut();
205
                pGrfNode->SwapIn();
206
                aGrTwipSz = pGrfNode->GetTwipSize();
207
                if (bWasSwappedOut)
208
                    pGrfNode->SwapOut();
209
            }
210
        }
211
212
        ASSERT(aGrTwipSz.Width() && aGrTwipSz.Height(), "0 x 0 graphic ?");
213
        return aGrTwipSz;
214
    }
183
}
215
}
184
 
216
 
185
namespace sw
217
namespace sw
186
{
218
{
219
    Frame::Frame(const SwFrmFmt &rFmt, const SwPosition &rPos)
220
        : mpFlyFrm(&rFmt), maPos(rPos), meWriterType(eTxtBox), 
221
        mpStartFrameContent(0)
222
    {
223
        switch (rFmt.Which())
224
        {
225
            case RES_FLYFRMFMT:
226
                if (const SwNodeIndex* pIdx = rFmt.GetCntnt().GetCntntIdx())
227
                {
228
                    SwNodeIndex aIdx(*pIdx, 1);
229
                    const SwNode &rNd = aIdx.GetNode();
230
                    switch (rNd.GetNodeType())
231
                    {
232
                        case ND_GRFNODE:
233
                            meWriterType = eGraphic;
234
                            maSize = GetSwappedInSize(*rNd.GetNoTxtNode());
235
                            break;
236
                        case ND_OLENODE:
237
                            meWriterType = eOle;
238
                            maSize = GetSwappedInSize(*rNd.GetNoTxtNode());
239
                            break;
240
                        default:
241
                            {
242
                                meWriterType = eTxtBox;
243
244
                                Rectangle aRect;
245
                                SwRect aLayRect(rFmt.FindLayoutRect());
246
                                /*
247
                                 The Object is not rendered (e.g. something in
248
                                 unused header/footer - so get the values from
249
                                 the format.
250
                                */
251
                                if (aLayRect.IsEmpty())
252
                                    aRect.SetSize(rFmt.GetFrmSize().GetSize());
253
                                else
254
                                    aRect = aLayRect.SVRect();
255
256
                                maSize = aRect.GetSize();
257
                            }
258
                            break;
259
                    }
260
                    mpStartFrameContent = &rNd;
261
                }
262
                else
263
                {
264
                    ASSERT(!this, "Impossible");
265
                    meWriterType = eTxtBox;
266
                }
267
                break;
268
            default:
269
                if (const SdrObject* pObj = rFmt.FindRealSdrObject())
270
                {
271
                    if (pObj->GetObjInventor() == FmFormInventor)
272
                        meWriterType = eFormControl;
273
                    else
274
                        meWriterType = eDrawing;
275
                    maSize = pObj->GetSnapRect().GetSize();
276
                }
277
                else
278
                {
279
                    ASSERT(!this, "Impossible");
280
                    meWriterType = eDrawing;
281
                }
282
                break;
283
        }
284
    }
285
286
    bool Frame::IsInline() const
287
    {
288
        return (mpFlyFrm->GetAnchor().GetAnchorId() == FLY_IN_CNTNT);
289
    }
290
187
    namespace hack
291
    namespace hack
188
    {
292
    {
293
        DrawingOLEAdaptor::DrawingOLEAdaptor(SdrOle2Obj &rObj, 
294
            SvPersist &rPers)
295
            : mxIPRef(rObj.GetObjRef()), 
296
            msOrigPersistName(rObj.GetPersistName()), mrPers(rPers)
297
        {
298
            rObj.SetPersistName(String());
299
            rObj.SetObjRef(SvInPlaceObjectRef());
300
        }
301
302
        bool DrawingOLEAdaptor::TransferToDoc(const String &rName)
303
        {
304
            ASSERT(mxIPRef.Is(), "Transferring invalid object to doc");
305
            if (!mxIPRef.Is())
306
                return false;
307
308
            SvInfoObjectRef refObj = new SvEmbeddedInfoObject(mxIPRef, rName);
309
            bool bSuccess = mrPers.Move(refObj, rName);
310
            if (bSuccess)
311
            {
312
                SvPersist *pO = mxIPRef;
313
                ASSERT(!pO->IsModified(), "Not expected to be modified here");
314
                if (pO->IsModified())
315
                {
316
                    pO->DoSave();
317
                    pO->DoSaveCompleted();
318
                }
319
                mxIPRef.Clear();
320
                bSuccess = mrPers.Unload(pO);
321
            }
322
323
            return bSuccess;
324
        }
325
326
        DrawingOLEAdaptor::~DrawingOLEAdaptor()
327
        {
328
            if (mxIPRef.Is())
329
            {
330
                if (SvInfoObject* pInfo = mrPers.Find(msOrigPersistName))
331
                {
332
                    pInfo->SetDeleted(TRUE);
333
                    pInfo->SetObj(0);
334
                }
335
                mxIPRef->DoClose();
336
                mrPers.Remove(mxIPRef);
337
                mxIPRef.Clear();
338
            }
339
        }
340
    }
341
342
    namespace util
343
    {
189
        void SetLayer::SendObjectToHell(SdrObject &rObject) const
344
        void SetLayer::SendObjectToHell(SdrObject &rObject) const
190
        {
345
        {
191
            SetObjectLayer(rObject, eHell);
346
            SetObjectLayer(rObject, eHell);
Lines 244-301 Link Here
244
        }
399
        }
245
        //SetLayer boilerplate end
400
        //SetLayer boilerplate end
246
401
247
248
        DrawingOLEAdaptor::DrawingOLEAdaptor(SdrOle2Obj &rObj, 
249
            SvPersist &rPers)
250
            : mxIPRef(rObj.GetObjRef()), 
251
            msOrigPersistName(rObj.GetPersistName()), mrPers(rPers)
252
        {
253
            rObj.SetPersistName(String());
254
            rObj.SetObjRef(SvInPlaceObjectRef());
255
        }
256
257
        bool DrawingOLEAdaptor::TransferToDoc(const String &rName)
258
        {
259
            ASSERT(mxIPRef.Is(), "Transferring invalid object to doc");
260
            if (!mxIPRef.Is())
261
                return false;
262
263
            SvInfoObjectRef refObj = new SvEmbeddedInfoObject(mxIPRef, rName);
264
            bool bSuccess = mrPers.Move(refObj, rName);
265
            if (bSuccess)
266
            {
267
                SvPersist *pO = mxIPRef;
268
                ASSERT(!pO->IsModified(), "Not expected to be modified here");
269
                if (pO->IsModified())
270
                {
271
                    pO->DoSave();
272
                    pO->DoSaveCompleted();
273
                }
274
                mxIPRef.Clear();
275
                bSuccess = mrPers.Unload(pO);
276
            }
277
278
            return bSuccess;
279
        }
280
281
        DrawingOLEAdaptor::~DrawingOLEAdaptor()
282
        {
283
            if (mxIPRef.Is())
284
            {
285
                if (SvInfoObject* pInfo = mrPers.Find(msOrigPersistName))
286
                {
287
                    pInfo->SetDeleted(TRUE);
288
                    pInfo->SetObj(0);
289
                }
290
                mxIPRef->DoClose();
291
                mrPers.Remove(mxIPRef);
292
                mxIPRef.Clear();
293
            }
294
        }
295
    }
296
297
    namespace util
298
    {
299
        ParaStyles GetParaStyles(const SwDoc &rDoc)
402
        ParaStyles GetParaStyles(const SwDoc &rDoc)
300
        {
403
        {
301
            ParaStyles aStyles;
404
            ParaStyles aStyles;
(-)writerhelper.hxx (-6 / +87 lines)
Lines 108-128 Link Here
108
    typedef std::vector<SwTxtFmtColl *>::iterator ParaStyleIter;
108
    typedef std::vector<SwTxtFmtColl *>::iterator ParaStyleIter;
109
109
110
110
111
    /** Make exporting a Writer Frame easy
112
113
        In word all frames are effectively anchored to character or as
114
        character. So we must have some content to anchor to. A sw::Frame
115
        wraps the writer frame and is guaranted to have a suitable anchor
116
        position available from it.
117
118
        It provides a more generally unified view of the true contents
119
        of SwFrmFmt in a way that is easy to export.
120
        Provides the best size value to export to word.
121
        Provides an anchor position to export to word with.
122
        Provides a readable way to see if we are anchored "as character"
123
        Provides a simpler way to flag what type of entity this frame describes.
124
125
        
126
127
        @author 
128
        <a href="mailto:cmc@openoffice.org">Caol&aacute;n McNamara</a>
129
    */
111
    class Frame
130
    class Frame
112
    {
131
    {
132
    public:
133
        enum WriterSource {eTxtBox, eGraphic, eOle, eDrawing, eFormControl};
113
    private:
134
    private:
114
        const SwFrmFmt* mpFlyFrm;
135
        const SwFrmFmt* mpFlyFrm;
115
        SwPosition maPos;
136
        SwPosition maPos;
137
        Size maSize;
138
        WriterSource meWriterType;
139
        const SwNode *mpStartFrameContent;
116
    public:
140
    public:
117
        Frame(const SwFrmFmt &rFlyFrm, const SwPosition &rPos)
141
        Frame(const SwFrmFmt &rFlyFrm, const SwPosition &rPos);
118
        : mpFlyFrm(&rFlyFrm), maPos(rPos) {}
142
143
        /** Get the writer SwFrmFmt that this object describes
144
145
            @return 
146
            The wrapped SwFrmFmt
147
        */
119
        const SwFrmFmt &GetFrmFmt() const { return *mpFlyFrm; }
148
        const SwFrmFmt &GetFrmFmt() const { return *mpFlyFrm; }
149
150
        /** Get the position this frame is anchored at
151
152
            @return 
153
            The anchor position of this frame
154
        */
120
        const SwPosition &GetPosition() const { return maPos; }
155
        const SwPosition &GetPosition() const { return maPos; }
156
157
        /** Get the node this frame is anchored into
158
159
            @return 
160
            The SwTxtNode this frame is anchored inside
161
        */
121
        const SwCntntNode *GetCntntNode() const
162
        const SwCntntNode *GetCntntNode() const
122
            { return maPos.nNode.GetNode().GetCntntNode(); }
163
            { return maPos.nNode.GetNode().GetCntntNode(); }
164
165
        /** Get the type of frame that this wraps
166
167
            @return 
168
            a WriterSource which describes the source type of this wrapper
169
        */
170
        WriterSource GetWriterType() const { return meWriterType; }
171
172
        /** Is this frame inline (as character)
173
174
            @return 
175
            whether this is inline or not
176
        */
177
        bool IsInline() const;
178
179
        /** Get the first node of content in the frame
180
         
181
         @return
182
         the first node of content in the frame, might not be any at all.
183
        */
184
        const SwNode *GetContent() const { return mpStartFrameContent; }
185
186
187
        /** Does this sw::Frame refer to the same writer content as another
188
         
189
         @return
190
         if the two sw::Frames are handling the same writer frame
191
        */
192
        bool RefersToSameFrameAs(const Frame &rOther) const
193
        {
194
            return (mpFlyFrm == rOther.mpFlyFrm);
195
        }
196
197
        /** The Size of the contained element
198
         
199
         @return
200
         the best size to use to export to word
201
        */
202
        const Size GetSize() const { return maSize; }
123
    };
203
    };
124
    
204
    
125
    /// STL container of Frames (FrmFmts)
205
    /// STL container of Frames
126
    typedef std::vector<Frame> Frames;
206
    typedef std::vector<Frame> Frames;
127
    /// STL iterator for Frames
207
    /// STL iterator for Frames
128
    typedef std::vector<Frame>::iterator FrameIter;
208
    typedef std::vector<Frame>::iterator FrameIter;
Lines 513-522 Link Here
513
            <a href="mailto:cmc@openoffice.org">Caol&aacute;n McNamara</a>
593
            <a href="mailto:cmc@openoffice.org">Caol&aacute;n McNamara</a>
514
        */
594
        */
515
        bool HasPageBreak(const SwNode &rNode);
595
        bool HasPageBreak(const SwNode &rNode);
516
    }
517
596
518
    namespace hack
597
519
    {
520
        /** Make setting a drawing object's layer in a Writer document easy
598
        /** Make setting a drawing object's layer in a Writer document easy
521
599
522
600
Lines 565-571 Link Here
565
            SetLayer(const SetLayer &rOther) throw();
643
            SetLayer(const SetLayer &rOther) throw();
566
            SetLayer& operator=(const SetLayer &rOther) throw();
644
            SetLayer& operator=(const SetLayer &rOther) throw();
567
        };
645
        };
646
    }
568
647
648
    namespace hack
649
    {
569
        /** Make inserting an OLE object into a Writer document easy
650
        /** Make inserting an OLE object into a Writer document easy
570
651
571
            The rest of Office uses SdrOle2Obj for their OLE objects, Writer
652
            The rest of Office uses SdrOle2Obj for their OLE objects, Writer
(-)wrtw8esh.cxx (-7 / +38 lines)
Lines 826-831 Link Here
826
void SwWW8Writer::AppendFlyInFlys(WW8_CP& rCP, const sw::Frame& rFrmFmt,
826
void SwWW8Writer::AppendFlyInFlys(WW8_CP& rCP, const sw::Frame& rFrmFmt,
827
    const Point& rNdTopLeft)
827
    const Point& rNdTopLeft)
828
{
828
{
829
    ASSERT(bWrtWW8, "this has gone horribly wrong");
829
    ASSERT(!pEscher, "der EscherStream wurde schon geschrieben!");
830
    ASSERT(!pEscher, "der EscherStream wurde schon geschrieben!");
830
    if (pEscher)
831
    if (pEscher)
831
        return ;
832
        return ;
Lines 835-841 Link Here
835
    else
836
    else
836
        pDrwO = pSdrObjs;
837
        pDrwO = pSdrObjs;
837
838
838
    if (pDrwO->Append( *this, rCP, rFrmFmt, rNdTopLeft))
839
    if (rFrmFmt.IsInline())
840
    {
841
        OutField(0, ww::eSHAPE, FieldString(ww::eSHAPE),
842
            WRITEFIELD_START | WRITEFIELD_CMD_START | WRITEFIELD_CMD_END);
843
    }
844
845
    bool bSuccess = pDrwO->Append( *this, rCP, rFrmFmt, rNdTopLeft);
846
    ASSERT(bSuccess, "Couldn't export a graphical element!");
847
848
    if (bSuccess)
839
    {
849
    {
840
        static BYTE __READONLY_DATA aSpec8[] = {
850
        static BYTE __READONLY_DATA aSpec8[] = {
841
            0x03, 0x6a, 0, 0, 0, 0, // sprmCObjLocation
851
            0x03, 0x6a, 0, 0, 0, 0, // sprmCObjLocation
Lines 850-855 Link Here
850
        pChpPlc->AppendFkpEntry( Strm().Tell(), sizeof( aSpec8 ), aSpec8 );
860
        pChpPlc->AppendFkpEntry( Strm().Tell(), sizeof( aSpec8 ), aSpec8 );
851
861
852
        const SwFrmFmt &rFmt = rFrmFmt.GetFrmFmt();
862
        const SwFrmFmt &rFmt = rFrmFmt.GetFrmFmt();
863
864
        //Need dummy picture frame
865
        if (rFrmFmt.IsInline())
866
            OutGrf(rFrmFmt);
867
853
        if (RES_FLYFRMFMT == rFmt.Which())
868
        if (RES_FLYFRMFMT == rFmt.Which())
854
        {
869
        {
855
            const SwNodeIndex* pNdIdx = rFmt.GetCntnt().GetCntntIdx();
870
            const SwNodeIndex* pNdIdx = rFmt.GetCntnt().GetCntntIdx();
Lines 866-871 Link Here
866
            }
881
            }
867
        }
882
        }
868
    }
883
    }
884
885
    if (rFrmFmt.IsInline())
886
        OutField(0, ww::eSHAPE, aEmptyStr, WRITEFIELD_CLOSE);
869
}
887
}
870
888
871
class WW8_SdrAttrIter : public WW8_AttrIter
889
class WW8_SdrAttrIter : public WW8_AttrIter
Lines 1356-1361 Link Here
1356
    GetStream() << 0x80000000;
1374
    GetStream() << 0x80000000;
1357
}
1375
}
1358
1376
1377
void SwBasicEscherEx::WriteEmptyFlyFrame(const SwFrmFmt& rFmt, UINT32 nShapeId)
1378
{
1379
    OpenContainer(ESCHER_SpContainer);
1380
    AddShape(ESCHER_ShpInst_PictureFrame, 0xa00, nShapeId);
1381
    // store anchor attribute
1382
    WriteFrmExtraData(rFmt);
1383
    CloseContainer();   // ESCHER_SpContainer
1384
}
1385
1359
INT32 SwBasicEscherEx::WriteGrfFlyFrame(const SwFrmFmt& rFmt, UINT32 nShapeId)
1386
INT32 SwBasicEscherEx::WriteGrfFlyFrame(const SwFrmFmt& rFmt, UINT32 nShapeId)
1360
{
1387
{
1361
    INT32 nBorderThick=0;
1388
    INT32 nBorderThick=0;
Lines 1969-1979 Link Here
1969
    const SwFmtHoriOrient&  rHoriOri = rFmt.GetHoriOrient();
1996
    const SwFmtHoriOrient&  rHoriOri = rFmt.GetHoriOrient();
1970
    const SwFmtVertOrient&  rVertOri = rFmt.GetVertOrient();
1997
    const SwFmtVertOrient&  rVertOri = rFmt.GetVertOrient();
1971
1998
1972
    const SwHoriOrient eHOri = rHoriOri.GetHoriOrient();
1999
    SwHoriOrient eHOri = rHoriOri.GetHoriOrient();
1973
    const SwVertOrient eVOri = rVertOri.GetVertOrient();
2000
    SwVertOrient eVOri = rVertOri.GetVertOrient();
1974
2001
1975
    SwRelationOrient   eHRel = rHoriOri.GetRelationOrient();
2002
    SwRelationOrient eHRel = rHoriOri.GetRelationOrient();
1976
    SwRelationOrient   eVRel = rVertOri.GetRelationOrient();
2003
    SwRelationOrient eVRel = rVertOri.GetRelationOrient();
1977
2004
1978
    //There must be a problem with page anchoring and draw objects in writer
2005
    //There must be a problem with page anchoring and draw objects in writer
1979
    //must be a problem somewhere.
2006
    //must be a problem somewhere.
Lines 2010-2017 Link Here
2010
            nVIndex = 0x12000000;
2037
            nVIndex = 0x12000000;
2011
            break;
2038
            break;
2012
        case FLY_IN_CNTNT:
2039
        case FLY_IN_CNTNT:
2013
            nHIndex = 0x02000000;
2040
            nHIndex = 0x01000000;
2014
            nVIndex = 0x13000000;
2041
            nVIndex = 0x12000000;
2042
            eHRel = REL_CHAR;
2043
            eHOri = HORI_NONE;
2044
            eVRel = REL_CHAR;
2045
            eVOri = VERT_NONE;
2015
            break;
2046
            break;
2016
        default:
2047
        default:
2017
            nHIndex = 0x01000000; // FLY_AT_CNTNT
2048
            nHIndex = 0x01000000; // FLY_AT_CNTNT
(-)wrtw8nds.cxx (-45 / +54 lines)
Lines 1560-1566 Link Here
1560
    SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
1560
    SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
1561
    SwTxtNode* pNd = &((SwTxtNode&)rNode);
1561
    SwTxtNode* pNd = &((SwTxtNode&)rNode);
1562
1562
1563
    bool bFlyInTable = rWW8Wrt.pFlyFmt && rWW8Wrt.bIsInTable;
1563
    bool bFlyInTable = rWW8Wrt.mpParentFrame && rWW8Wrt.bIsInTable;
1564
1564
1565
    // akt. Style
1565
    // akt. Style
1566
    if( !bFlyInTable )
1566
    if( !bFlyInTable )
Lines 1768-1775 Link Here
1768
1768
1769
    pO->Insert( (BYTE*)&nSty, 2, pO->Count() );     // Style #
1769
    pO->Insert( (BYTE*)&nSty, 2, pO->Count() );     // Style #
1770
1770
1771
    if( rWW8Wrt.pFlyFmt && !rWW8Wrt.bIsInTable )    // Fly-Attrs
1771
    if (rWW8Wrt.mpParentFrame && !rWW8Wrt.bIsInTable)    // Fly-Attrs
1772
        rWW8Wrt.Out_SwFmt(*rWW8Wrt.pFlyFmt, false, false, true);
1772
        rWW8Wrt.Out_SwFmt(rWW8Wrt.mpParentFrame->GetFrmFmt(), false, false, true);
1773
1773
1774
    if( rWW8Wrt.bOutTable )
1774
    if( rWW8Wrt.bOutTable )
1775
    {                                               // Tab-Attr
1775
    {                                               // Tab-Attr
Lines 2059-2065 Link Here
2059
        if (aRect.IsEmpty())
2059
        if (aRect.IsEmpty())
2060
        {
2060
        {
2061
            // dann besorge mal die Seitenbreite ohne Raender !!
2061
            // dann besorge mal die Seitenbreite ohne Raender !!
2062
            const SwFrmFmt* pParentFmt = rWW8Wrt.pFlyFmt ? rWW8Wrt.pFlyFmt :
2062
            const SwFrmFmt* pParentFmt = 
2063
                rWW8Wrt.mpParentFrame ? 
2064
                &(rWW8Wrt.mpParentFrame->GetFrmFmt()) :
2063
                rWrt.pDoc->GetPageDesc(0).GetPageFmtOfNode(rNode, false);
2065
                rWrt.pDoc->GetPageDesc(0).GetPageFmtOfNode(rNode, false);
2064
            aRect = pParentFmt->FindLayoutRect(true);
2066
            aRect = pParentFmt->FindLayoutRect(true);
2065
            if (!(nPageSize = aRect.Width()))
2067
            if (!(nPageSize = aRect.Width()))
Lines 2570-2575 Link Here
2570
2572
2571
void SwWW8Writer::OutWW8FlyFrmsInCntnt( const SwTxtNode& rNd )
2573
void SwWW8Writer::OutWW8FlyFrmsInCntnt( const SwTxtNode& rNd )
2572
{
2574
{
2575
    ASSERT(!bWrtWW8, "I shouldn't be needed for Word >=8");
2576
2573
    if (const SwpHints* pTxtAttrs = rNd.GetpSwpHints())
2577
    if (const SwpHints* pTxtAttrs = rNd.GetpSwpHints())
2574
    {
2578
    {
2575
        for( USHORT n=0; n < pTxtAttrs->Count(); ++n )
2579
        for( USHORT n=0; n < pTxtAttrs->Count(); ++n )
Lines 2601-2608 Link Here
2601
2605
2602
                        // wird in Out_SwFmt() ausgewertet
2606
                        // wird in Out_SwFmt() ausgewertet
2603
                        pFlyOffset = &aOffset;
2607
                        pFlyOffset = &aOffset;
2604
                        pFlyFmt = (SwFlyFrmFmt*)&rFlyFrmFmt;
2608
                        eNewAnchorType = rFlyFrmFmt.GetAnchor().GetAnchorId();
2605
                        eNewAnchorType = pFlyFmt->GetAnchor().GetAnchorId();
2609
                        sw::Frame aFrm(rFlyFrmFmt, SwPosition(rNd));
2610
                        mpParentFrame = &aFrm;
2606
                        // Ok, rausschreiben:
2611
                        // Ok, rausschreiben:
2607
                        WriteText();
2612
                        WriteText();
2608
                    }
2613
                    }
Lines 2618-2648 Link Here
2618
    const SwFrmFmt &rFrmFmt = rFmt.GetFrmFmt();
2623
    const SwFrmFmt &rFrmFmt = rFmt.GetFrmFmt();
2619
    const SwFmtAnchor& rAnch = rFrmFmt.GetAnchor();
2624
    const SwFmtAnchor& rAnch = rFrmFmt.GetAnchor();
2620
2625
2626
    bool bUseInline = !bWrtWW8;
2627
2628
    if (bWrtWW8 && rFmt.IsInline())
2629
    {
2630
        sw::Frame::WriterSource eType = rFmt.GetWriterType();
2631
        if ((eType == sw::Frame::eGraphic) || (eType == sw::Frame::eOle))
2632
            bUseInline = true;
2633
        else
2634
            bUseInline = false;
2635
2636
        /*
2637
         #110185#
2638
         A special case for converting some inline form controls to form fields 
2639
         when in winword 8+ mode
2640
        */
2641
        if ((bUseInline == false) && (eType == sw::Frame::eFormControl))
2642
        {
2643
            if (MiserableFormFieldExportHack(rFrmFmt))
2644
                return ;
2645
        }
2646
2647
    }
2648
2621
    /*
2649
    /*
2622
    ##897##
2650
    ##897##
2623
    Note that something anchored as a character must be
2651
    Note that something anchored as a character must be
2624
    exported using the older WW6 mechanism
2652
    exported using the older WW6 mechanism
2625
    */
2653
    */
2626
    if (!bWrtWW8 || (FLY_IN_CNTNT == rAnch.GetAnchorId()))
2654
    if (bUseInline)
2627
    {
2655
    {
2628
        if (RES_DRAWFRMFMT == rFrmFmt.Which())
2629
        {
2630
            bool bComboBoxHack = false;
2631
            if (bWrtWW8 && (FLY_IN_CNTNT == rAnch.GetAnchorId())) //#110185#
2632
                bComboBoxHack = MiserableFormFieldExportHack(rFrmFmt);
2633
            ASSERT(bComboBoxHack , "OutWW8FlyFrm: DrawInCnt-Baustelle " );
2634
            return ;
2635
        }
2636
2637
        bool bDone = false;
2656
        bool bDone = false;
2638
2657
2639
        // Hole vom Node und vom letzten Node die Position in der Section
2658
        // Hole vom Node und vom letzten Node die Position in der Section
2640
        /*
2641
        const SwFmtCntnt& rFlyCntnt = rFrmFmt.GetCntnt();
2642
2643
        ULONG nStt = rFlyCntnt.GetCntntIdx()->GetIndex()+1;
2644
        ULONG nEnd = pDoc->GetNodes()[ nStt - 1 ]->EndOfSectionIndex();
2645
        */
2646
        const SwNodeIndex* pNodeIndex = rFrmFmt.GetCntnt().GetCntntIdx();
2659
        const SwNodeIndex* pNodeIndex = rFrmFmt.GetCntnt().GetCntntIdx();
2647
2660
2648
        ULONG nStt = pNodeIndex ? pNodeIndex->GetIndex()+1                  : 0;
2661
        ULONG nStt = pNodeIndex ? pNodeIndex->GetIndex()+1                  : 0;
Lines 2651-2661 Link Here
2651
        if( nStt >= nEnd )      // kein Bereich, also kein gueltiger Node
2664
        if( nStt >= nEnd )      // kein Bereich, also kein gueltiger Node
2652
            return;
2665
            return;
2653
2666
2654
        if( !bIsInTable && (FLY_IN_CNTNT == rAnch.GetAnchorId()) )
2667
        if (!bIsInTable && rFmt.IsInline())
2655
        {
2668
        {
2656
            // ein zeichen(!)gebundener Rahmen liegt vor
2669
            //Test to see if this textbox contains only a single graphic/ole
2657
            SwTxtNode* pParTxtNode = rAnch.GetCntntAnchor()->nNode.GetNode().GetTxtNode();
2670
            SwTxtNode* pParTxtNode = rAnch.GetCntntAnchor()->nNode.GetNode().GetTxtNode();
2658
2659
            if( pParTxtNode && !pDoc->GetNodes()[ nStt ]->IsNoTxtNode() )
2671
            if( pParTxtNode && !pDoc->GetNodes()[ nStt ]->IsNoTxtNode() )
2660
                bDone = true;
2672
                bDone = true;
2661
        }
2673
        }
Lines 2671-2677 Link Here
2671
                WW8SaveData aSaveData( *this, nStt, nEnd );
2683
                WW8SaveData aSaveData( *this, nStt, nEnd );
2672
2684
2673
                Point aOffset;
2685
                Point aOffset;
2674
                if( pFlyFmt )
2686
                if (mpParentFrame)
2675
                {
2687
                {
2676
                    /*
2688
                    /*
2677
                    #90804#
2689
                    #90804#
Lines 2685-2717 Link Here
2685
                    eNewAnchorType = FLY_PAGE;
2697
                    eNewAnchorType = FLY_PAGE;
2686
                }
2698
                }
2687
2699
2688
                pFlyFmt = (SwFlyFrmFmt*)&rFrmFmt;
2700
                mpParentFrame = &rFmt;
2689
                if( pFlyFmt )
2701
                if (
2702
                     bIsInTable && (FLY_PAGE != rAnch.GetAnchorId()) && 
2703
                     !pDoc->GetNodes()[ nStt ]->IsNoTxtNode()
2704
                   )
2690
                {
2705
                {
2691
                    if( bIsInTable && (FLY_PAGE != rAnch.GetAnchorId()) &&
2706
                    // Beachten: Flag  bOutTable  wieder setzen,
2692
                        !pDoc->GetNodes()[ nStt ]->IsNoTxtNode() )
2707
                    //           denn wir geben ja ganz normalen Content der
2693
                    {
2708
                    //           Tabelenzelle aus und keinen Rahmen
2694
                        // Beachten: Flag  bOutTable  wieder setzen,
2709
                    //           (Flag wurde oben in  aSaveData()  geloescht)
2695
                        //           denn wir geben ja ganz normalen Content der
2710
                    bOutTable = true;
2696
                        //           Tabelenzelle aus und keinen Rahmen
2711
                    const String& rName = rFrmFmt.GetName();
2697
                        //           (Flag wurde oben in  aSaveData()  geloescht)
2712
                    StartCommentOutput(rName);
2698
                        bOutTable = true;
2713
                    WriteText();
2699
                        const String& rName = pFlyFmt->GetName();
2714
                    EndCommentOutput(rName);
2700
                        StartCommentOutput( rName );
2701
                        WriteText();
2702
                        EndCommentOutput( rName );
2703
                    }
2704
                    else
2705
                        WriteText();
2706
                }
2715
                }
2707
                else
2716
                else
2708
                    ASSERT( !this, "+Fly-Ausgabe ohne FlyFmt" );
2717
                    WriteText();
2709
            }
2718
            }
2710
            // ASSERT( !pFlyFmt, " pFlyFmt ist hinter einem Rahmen nicht 0" );
2711
        }
2719
        }
2712
    }
2720
    }
2713
    else
2721
    else
2714
    {
2722
    {
2723
        ASSERT(bWrtWW8, "this has gone horribly wrong");
2715
        // write as escher
2724
        // write as escher
2716
        WW8_CP nCP = Fc2Cp( Strm().Tell() );
2725
        WW8_CP nCP = Fc2Cp( Strm().Tell() );
2717
        AppendFlyInFlys( nCP, rFmt, rNdTopLeft );
2726
        AppendFlyInFlys( nCP, rFmt, rNdTopLeft );
(-)wrtww8.cxx (-5 / +6 lines)
Lines 1871-1877 Link Here
1871
WW8SaveData::WW8SaveData( SwWW8Writer& rWriter, ULONG nStt, ULONG nEnd )
1871
WW8SaveData::WW8SaveData( SwWW8Writer& rWriter, ULONG nStt, ULONG nEnd )
1872
    : rWrt( rWriter ),
1872
    : rWrt( rWriter ),
1873
    pOldPam( rWrt.pCurPam ), pOldEnd( rWrt.GetEndPaM() ),
1873
    pOldPam( rWrt.pCurPam ), pOldEnd( rWrt.GetEndPaM() ),
1874
    pOldFlyFmt( rWrt.pFlyFmt ), pOldPageDesc( rWrt.pAktPageDesc )
1874
    pOldFlyFmt(rWrt.mpParentFrame), pOldPageDesc( rWrt.pAktPageDesc )
1875
1875
1876
{
1876
{
1877
    pOldFlyOffset = rWrt.pFlyOffset;
1877
    pOldFlyOffset = rWrt.pFlyOffset;
Lines 1920-1926 Link Here
1920
    rWrt.bOutFlyFrmAttrs = bOldFlyFrmAttrs;
1920
    rWrt.bOutFlyFrmAttrs = bOldFlyFrmAttrs;
1921
    rWrt.bStartTOX = bOldStartTOX;
1921
    rWrt.bStartTOX = bOldStartTOX;
1922
    rWrt.bInWriteTOX = bOldInWriteTOX;
1922
    rWrt.bInWriteTOX = bOldInWriteTOX;
1923
    rWrt.pFlyFmt = pOldFlyFmt;
1923
    rWrt.mpParentFrame = pOldFlyFmt;
1924
    rWrt.pAktPageDesc = pOldPageDesc;
1924
    rWrt.pAktPageDesc = pOldPageDesc;
1925
    ASSERT( !rWrt.pO->Count(), " pO ist am Ende von WW8SaveData nicht leer" );
1925
    ASSERT( !rWrt.pO->Count(), " pO ist am Ende von WW8SaveData nicht leer" );
1926
    if( pOOld )
1926
    if( pOOld )
Lines 1946-1953 Link Here
1946
            const SwTxtNode* pTxtNode = pNd->GetTxtNode();
1946
            const SwTxtNode* pTxtNode = pNd->GetTxtNode();
1947
            if( pTxtNode->GetpSwAttrSet() )
1947
            if( pTxtNode->GetpSwAttrSet() )
1948
                Out_SfxBreakItems( *pTxtNode->GetpSwAttrSet(), *pTxtNode );
1948
                Out_SfxBreakItems( *pTxtNode->GetpSwAttrSet(), *pTxtNode );
1949
            if( !bIsInTable )
1949
            // all textframes anchored as character for the winword 7- format
1950
                OutWW8FlyFrmsInCntnt( *pTxtNode ); // als Zeichen gebundene Flys
1950
            if (!bWrtWW8 && !bIsInTable)
1951
                OutWW8FlyFrmsInCntnt(*pTxtNode);
1951
        }
1952
        }
1952
1953
1953
        if( pNd->IsCntntNode() )
1954
        if( pNd->IsCntntNode() )
Lines 2212-2218 Link Here
2212
2213
2213
    bFtnAtTxtEnd = bEndAtTxtEnd = true;
2214
    bFtnAtTxtEnd = bEndAtTxtEnd = true;
2214
2215
2215
    pFlyFmt = 0;
2216
    mpParentFrame = 0;
2216
    pFlyOffset = 0;
2217
    pFlyOffset = 0;
2217
    eNewAnchorType = FLY_PAGE;
2218
    eNewAnchorType = FLY_PAGE;
2218
    nTxtTyp = TXT_MAINTEXT;
2219
    nTxtTyp = TXT_MAINTEXT;
(-)wrtww8.hxx (-23 / +21 lines)
Lines 186-193 Link Here
186
class SvxBrushItem;
186
class SvxBrushItem;
187
187
188
#define WWFL_ULSPACE_LIKE_SWG   0x00000001
188
#define WWFL_ULSPACE_LIKE_SWG   0x00000001
189
#define WWFL_NO_GRAF            0x00000080
190
#define WWFL_NO_OLE             0x00020000
191
189
192
#define GRF_MAGIC_1 0x12    // 3 magic Bytes fuer PicLocFc-Attribute
190
#define GRF_MAGIC_1 0x12    // 3 magic Bytes fuer PicLocFc-Attribute
193
#define GRF_MAGIC_2 0x34
191
#define GRF_MAGIC_2 0x34
Lines 485-492 Link Here
485
    WW8_WrPlcPostIt* pAtn;
483
    WW8_WrPlcPostIt* pAtn;
486
    WW8_WrPlcTxtBoxes *pTxtBxs, *pHFTxtBxs;
484
    WW8_WrPlcTxtBoxes *pTxtBxs, *pHFTxtBxs;
487
485
488
    SwFlyFrmFmt* pFlyFmt;           // liegt der Node in einem FlyFrame, ist
486
    const sw::Frame *mpParentFrame; //If set we are exporting content inside
489
                                    // das Format gesetzt, sonst 0
487
                                    //a frame, e.g. a graphic node
490
488
491
    Point* pFlyOffset;              // zur Justierung eines im Writer als
489
    Point* pFlyOffset;              // zur Justierung eines im Writer als
492
    RndStdIds eNewAnchorType;       // Zeichen gebundenen Flys, der im WW
490
    RndStdIds eNewAnchorType;       // Zeichen gebundenen Flys, der im WW
Lines 589-595 Link Here
589
        const String& rFldCmd, BYTE nMode = WRITEFIELD_ALL);
587
        const String& rFldCmd, BYTE nMode = WRITEFIELD_ALL);
590
    void StartCommentOutput( const String& rName );
588
    void StartCommentOutput( const String& rName );
591
    void EndCommentOutput(   const String& rName );
589
    void EndCommentOutput(   const String& rName );
592
    void OutGrf( const SwNoTxtNode* pNd );
590
    void OutGrf(const sw::Frame &rFrame);
593
    bool TestOleNeedsGraphic(const SwAttrSet& rSet, SvStorageRef xOleStg,
591
    bool TestOleNeedsGraphic(const SwAttrSet& rSet, SvStorageRef xOleStg,
594
        SvStorageRef xObjStg, String &rStorageName, SwOLENode *pOLENd);
592
        SvStorageRef xObjStg, String &rStorageName, SwOLENode *pOLENd);
595
    void AppendBookmarks( const SwTxtNode& rNd, xub_StrLen nAktPos,
593
    void AppendBookmarks( const SwTxtNode& rNd, xub_StrLen nAktPos,
Lines 861-880 Link Here
861
class GraphicDetails
859
class GraphicDetails
862
{
860
{
863
public:
861
public:
864
    const SwNoTxtNode* mpNd;    // Positionen der SwGrfNodes und SwOleNodes
862
    const sw::Frame maFly;      // Umgebende FlyFrms dazu
865
    const SwFlyFrmFmt* mpFly;   // Umgebende FlyFrms dazu
863
    ULONG mnPos;                // FilePos der Grafiken
866
    ULONG mnPos;        // FilePos der Grafiken
864
    UINT16 mnWid;               // Breite der Grafiken
867
    UINT16 mnWid;       // Breite der Grafiken
865
    UINT16 mnHei;               // Hoehe der Grafiken
868
    UINT16 mnHei;       // Hoehe der Grafiken
866
    GraphicDetails(const sw::Frame &rFly, UINT16 nWid, UINT16 nHei)
869
    GraphicDetails(const SwNoTxtNode* pNd, const SwFlyFrmFmt* pFly, 
867
        : maFly(rFly), mnPos(0), mnWid(nWid), mnHei(nHei)
870
        UINT16 nWid, UINT16 nHei)
871
    : mpNd(pNd), mpFly(pFly), mnPos(0), mnWid(nWid), mnHei(nHei)
872
    {}
868
    {}
873
869
874
    bool operator==(const GraphicDetails& rIn) const
870
    bool operator==(const GraphicDetails& rIn) const
875
    {
871
    {
876
        return 
872
        return (
877
           ((mpNd == rIn.mpNd) && (mnWid == rIn.mnWid) && (mnHei == rIn.mnHei));
873
                 (mnWid == rIn.mnWid) && (mnHei == rIn.mnHei) &&
874
                 (maFly.RefersToSameFrameAs(rIn.maFly))
875
               );
878
    }
876
    }
879
};
877
};
880
878
Lines 887-905 Link Here
887
    typedef std::vector<GraphicDetails>::iterator myiter;
885
    typedef std::vector<GraphicDetails>::iterator myiter;
888
    USHORT mnIdx;       // Index in File-Positionen
886
    USHORT mnIdx;       // Index in File-Positionen
889
887
890
    void WritePICFHeader(SvStream& rStrm, const SwNoTxtNode* pNd,
888
    void WritePICFHeader(SvStream& rStrm, const sw::Frame &rFly, 
891
        const SwFlyFrmFmt* pFly, UINT16 mm, UINT16 nWidth, UINT16 nHeight);
889
            UINT16 mm, UINT16 nWidth, UINT16 nHeight, 
892
    void WriteGraphicNode(SvStream& rStrm, const SwNoTxtNode* pGrfNd,
890
            const SwAttrSet* pAttrSet = 0);
893
        const SwFlyFrmFmt* pFly, UINT16 nWidth, UINT16 nHeight);
891
    void WriteGraphicNode(SvStream& rStrm, const GraphicDetails &rItem);
894
    void WriteGrfFromGrfNode(SvStream& rStrm, const SwGrfNode* pNd,
892
    void WriteGrfFromGrfNode(SvStream& rStrm, const SwGrfNode &rNd,
895
        const SwFlyFrmFmt* pFly, UINT16 nWidth, UINT16 nHeight);
893
        const sw::Frame &rFly, UINT16 nWidth, UINT16 nHeight);
896
894
897
    //No copying
895
    //No copying
898
    SwWW8WrGrf(const SwWW8WrGrf&);
896
    SwWW8WrGrf(const SwWW8WrGrf&);
899
    SwWW8WrGrf& operator=(const SwWW8WrGrf&);
897
    SwWW8WrGrf& operator=(const SwWW8WrGrf&);
900
public:
898
public:
901
    SwWW8WrGrf(SwWW8Writer& rW) : rWrt(rW), mnIdx(0) {}
899
    SwWW8WrGrf(SwWW8Writer& rW) : rWrt(rW), mnIdx(0) {}
902
    void Insert(const SwNoTxtNode* pNd, const SwFlyFrmFmt* pFly);
900
    void Insert(const sw::Frame &rFly);
903
    void Write();
901
    void Write();
904
    ULONG GetFPos() 
902
    ULONG GetFPos() 
905
        { return (mnIdx < maDetails.size()) ? maDetails[mnIdx++].mnPos : 0; }
903
        { return (mnIdx < maDetails.size()) ? maDetails[mnIdx++].mnPos : 0; }
Lines 969-975 Link Here
969
    RndStdIds eOldAnchorType;
967
    RndStdIds eOldAnchorType;
970
    WW8Bytes* pOOld;
968
    WW8Bytes* pOOld;
971
    SwPaM* pOldPam, *pOldEnd;
969
    SwPaM* pOldPam, *pOldEnd;
972
    SwFlyFrmFmt* pOldFlyFmt;
970
    const sw::Frame* pOldFlyFmt;
973
    const SwPageDesc* pOldPageDesc;
971
    const SwPageDesc* pOldPageDesc;
974
972
975
    BYTE bOldWriteAll : 1;
973
    BYTE bOldWriteAll : 1;
(-)wrtww8gr.cxx (-270 / +279 lines)
Lines 172-180 Link Here
172
Writer& OutWW8_SwGrfNode( Writer& rWrt, SwCntntNode& rNode )
172
Writer& OutWW8_SwGrfNode( Writer& rWrt, SwCntntNode& rNode )
173
{
173
{
174
    SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
174
    SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
175
    rWW8Wrt.OutGrf( rNode.GetGrfNode() );
175
    ASSERT(rWW8Wrt.mpParentFrame, "frame not set!");
176
176
    if (rWW8Wrt.mpParentFrame)
177
    rWW8Wrt.pFib->fHasPic = 1;
177
    {
178
        rWW8Wrt.OutGrf(*rWW8Wrt.mpParentFrame);
179
        rWW8Wrt.pFib->fHasPic = 1;
180
    }
178
181
179
    return rWrt;
182
    return rWrt;
180
}
183
}
Lines 259-409 Link Here
259
{
262
{
260
    using namespace ww;
263
    using namespace ww;
261
    SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
264
    SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
262
    if( !(rWW8Wrt.GetIniFlags() & WWFL_NO_OLE ) )
265
    BYTE *pSpecOLE;
266
    BYTE *pDataAdr;
267
    short nSize;
268
    static BYTE aSpecOLE_WW8[] = {
269
            0x03, 0x6a, 0, 0, 0, 0, // sprmCPicLocation
270
            0x0a, 0x08, 1,          // sprmCFOLE2
271
            0x56, 0x08, 1           // sprmCFObj
272
        };
273
    static BYTE aSpecOLE_WW6[] = {
274
            68, 4, 0, 0, 0, 0,      // sprmCPicLocation (len is 4)
275
            75, 1,                  // sprmCFOLE2
276
            118, 1                  // sprmCFObj
277
        };
278
279
    if( rWW8Wrt.bWrtWW8 )
263
    {
280
    {
264
        BYTE *pSpecOLE;
281
        pSpecOLE = aSpecOLE_WW8;
265
        BYTE *pDataAdr;
282
        nSize = sizeof( aSpecOLE_WW8 );
266
        short nSize;
283
    }
267
        static BYTE aSpecOLE_WW8[] = {
284
    else
268
                0x03, 0x6a, 0, 0, 0, 0, // sprmCPicLocation
285
    {
269
                0x0a, 0x08, 1,          // sprmCFOLE2
286
        pSpecOLE = aSpecOLE_WW6;
270
                0x56, 0x08, 1           // sprmCFObj
287
        nSize = sizeof( aSpecOLE_WW6 );
271
            };
288
    }
272
        static BYTE aSpecOLE_WW6[] = {
289
    pDataAdr = pSpecOLE + 2; //WW6 sprm is 1 but has 1 byte len as well.
273
                68, 4, 0, 0, 0, 0,      // sprmCPicLocation (len is 4)
290
    SwOLENode *pOLENd = rNode.GetOLENode();
274
                75, 1,                  // sprmCFOLE2
275
                118, 1                  // sprmCFObj
276
            };
277
291
278
        if( rWW8Wrt.bWrtWW8 )
292
    SvStorageRef xObjStg = rWW8Wrt.GetStorage().OpenStorage(
279
        {
293
        CREATE_CONST_ASC(SL::aObjectPool), STREAM_READWRITE | 
280
            pSpecOLE = aSpecOLE_WW8;
294
        STREAM_SHARE_DENYALL );
281
            nSize = sizeof( aSpecOLE_WW8 );
295
282
        }
296
    if( xObjStg.Is()  )
283
        else
297
    {
284
        {
298
        SvInPlaceObjectRef xObj(pOLENd->GetOLEObj().GetOleRef());
285
            pSpecOLE = aSpecOLE_WW6;
299
        if( xObj.Is() )
286
            nSize = sizeof( aSpecOLE_WW6 );
300
        {
287
        }
301
            SvInPlaceObject *pObj = &xObj;
288
        pDataAdr = pSpecOLE + 2; //WW6 sprm is 1 but has 1 byte len as well.
302
            UINT32 nPictureId = (UINT32)pObj;
289
        SwOLENode *pOLENd = rNode.GetOLENode();
303
            Set_UInt32(pDataAdr, nPictureId);
304
305
            WW8OleMap *pMap = new WW8OleMap(nPictureId);
306
            bool bDuplicate = false;
307
            WW8OleMaps &rOleMap = rWW8Wrt.GetOLEMap();
308
            USHORT nPos;
309
            if ( rOleMap.Seek_Entry(pMap, &nPos) )
310
            {
311
                bDuplicate = true;
312
                delete pMap;
313
            }
314
            else if( 0 == rOleMap.Insert( pMap) )
315
                delete pMap;
290
316
291
        SvStorageRef xObjStg = rWW8Wrt.GetStorage().OpenStorage(
317
            String sStorageName( '_' );
292
            CREATE_CONST_ASC(SL::aObjectPool), STREAM_READWRITE | 
318
            sStorageName += String::CreateFromInt32( nPictureId );
293
            STREAM_SHARE_DENYALL );
319
            SvStorageRef xOleStg = xObjStg->OpenStorage( sStorageName,
294
320
                                STREAM_READWRITE| STREAM_SHARE_DENYALL );
295
        if( xObjStg.Is()  )
321
            if( xOleStg.Is() )
296
        {
322
            {
297
            SvInPlaceObjectRef xObj(pOLENd->GetOLEObj().GetOleRef());
323
                /*
298
            if( xObj.Is() )
324
                If this object storage has been written already don't
299
            {
325
                waste time rewriting it
300
                SvInPlaceObject *pObj = &xObj;
326
                */
301
                UINT32 nPictureId = (UINT32)pObj;
327
                if (!bDuplicate)
302
                Set_UInt32(pDataAdr, nPictureId);
328
                    rWW8Wrt.GetOLEExp().ExportOLEObject(*pObj, *xOleStg);
303
329
304
                WW8OleMap *pMap = new WW8OleMap(nPictureId);
330
                // write as embedded field - the other things will be done
305
                bool bDuplicate = false;
331
                // in the escher export
306
                WW8OleMaps &rOleMap = rWW8Wrt.GetOLEMap();
332
                String sServer(FieldString(eEMBED));
307
                USHORT nPos;
333
                sServer += xOleStg->GetUserName();
308
                if ( rOleMap.Seek_Entry(pMap, &nPos) )
334
                sServer += ' ';
309
                {
335
310
                    bDuplicate = true;
336
                rWW8Wrt.OutField(0, eEMBED, sServer, WRITEFIELD_START |
311
                    delete pMap;
337
                    WRITEFIELD_CMD_START | WRITEFIELD_CMD_END);
312
                }
338
313
                else if( 0 == rOleMap.Insert( pMap) )
339
                rWW8Wrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(),
314
                    delete pMap;
340
                        nSize, pSpecOLE );
341
342
                bool bEndCR = true;
343
                /*
344
                In the word filter we only need a preview image for
345
                floating images, and then only (the usual case) if the
346
                object doesn't contain enough information to reconstruct
347
                what we need. 
348
                
349
                We don't need a graphic for inline objects, so we don't
350
                even need the overhead of a graphic in that case.
351
                */
352
                bool bGraphicNeeded = false;
315
353
316
                String sStorageName( '_' );
354
                if (rWW8Wrt.mpParentFrame)
317
                sStorageName += String::CreateFromInt32( nPictureId );
318
                SvStorageRef xOleStg = xObjStg->OpenStorage( sStorageName,
319
                                    STREAM_READWRITE| STREAM_SHARE_DENYALL );
320
                if( xOleStg.Is() )
321
                {
355
                {
322
                    /*
356
                    bGraphicNeeded = true;
323
                    If this object storage has been written already don't
324
                    waste time rewriting it
325
                    */
326
                    if (!bDuplicate)
327
                        rWW8Wrt.GetOLEExp().ExportOLEObject(*pObj, *xOleStg);
328
329
                    // write as embedded field - the other things will be done
330
                    // in the escher export
331
                    String sServer(FieldString(eEMBED));
332
                    sServer += xOleStg->GetUserName();
333
                    sServer += ' ';
334
335
                    rWW8Wrt.OutField(0, eEMBED, sServer, WRITEFIELD_START |
336
                        WRITEFIELD_CMD_START | WRITEFIELD_CMD_END);
337
357
338
                    rWW8Wrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(),
358
                    if (rWW8Wrt.mpParentFrame->IsInline())
339
                            nSize, pSpecOLE );
340
341
                    bool bEndCR = true;
342
                    /*
343
                    In the word filter we only need a preview image for
344
                    floating images, and then only (the usual case) if the
345
                    object doesn't contain enough information to reconstruct
346
                    what we need. 
347
                    
348
                    We don't need a graphic for inline objects, so we don't
349
                    even need the overhead of a graphic in that case.
350
                    */
351
                    bool bGraphicNeeded = false;
352
353
                    if (rWW8Wrt.pFlyFmt)
354
                    {
359
                    {
355
                        bGraphicNeeded = true;
360
                        const SwAttrSet& rSet = 
356
361
                            rWW8Wrt.mpParentFrame->GetFrmFmt().GetAttrSet();
357
                        const SwAttrSet& rSet = rWW8Wrt.pFlyFmt->GetAttrSet();
362
                        bEndCR = false;
358
                        if (rSet.GetAnchor(false).GetAnchorId() == FLY_IN_CNTNT)
363
                        bGraphicNeeded = rWW8Wrt.TestOleNeedsGraphic(rSet,
359
                        {
364
                            xOleStg, xObjStg, sStorageName, pOLENd);
360
                            bEndCR = false;
361
                            bGraphicNeeded = rWW8Wrt.TestOleNeedsGraphic(rSet,
362
                                xOleStg, xObjStg, sStorageName, pOLENd);
363
                        }
364
                    }
365
                    }
366
                }
365
367
366
                    if (!bGraphicNeeded)
368
                if (!bGraphicNeeded)
367
                        rWW8Wrt.WriteChar(0x1);
369
                    rWW8Wrt.WriteChar(0x1);
368
                    else
370
                else
369
                    {
371
                {
370
                        /*
372
                    /*
371
                        ##897##
373
                    ##897##
372
                        We need to insert the graphic representation of
374
                    We need to insert the graphic representation of
373
                        this object for the inline case, otherwise word
375
                    this object for the inline case, otherwise word
374
                        has no place to find the dimensions of the ole
376
                    has no place to find the dimensions of the ole
375
                        object, and will not be able to draw it
377
                    object, and will not be able to draw it
376
                        */
378
                    */
377
                        rWW8Wrt.OutGrf(rNode.GetOLENode());
379
                    rWW8Wrt.OutGrf(*rWW8Wrt.mpParentFrame);
378
                    }
380
                }
379
381
380
                    rWW8Wrt.OutField(0, eEMBED, aEmptyStr, 
382
                rWW8Wrt.OutField(0, eEMBED, aEmptyStr, 
381
                        WRITEFIELD_END | WRITEFIELD_CLOSE);
383
                    WRITEFIELD_END | WRITEFIELD_CLOSE);
382
384
383
                    if (bEndCR) //No newline in inline case
385
                if (bEndCR) //No newline in inline case
384
                        rWW8Wrt.WriteCR();
386
                    rWW8Wrt.WriteCR();
385
                }
386
            }
387
            }
387
        }
388
        }
388
        else    //Only for the case that ole objects are not to be exported
389
            rWW8Wrt.OutGrf( rNode.GetOLENode() );
390
    }
389
    }
391
    return rWrt;
390
    return rWrt;
392
}
391
}
393
392
394
void SwWW8Writer::OutGrf( const SwNoTxtNode* pNd )
393
void SwWW8Writer::OutGrf(const sw::Frame &rFrame)
395
{
394
{
396
    if( nIniFlags & WWFL_NO_GRAF )
397
        return;     // Iniflags: kein Grafik-Export
398
399
    if( !pFlyFmt )              // Grafik mit eigenem Frame ( eigentlich immer )
400
    {
401
        ASSERT( !this, "+Grafik ohne umgebenden Fly" );
402
        return ;
403
    }
404
405
    // GrfNode fuer spaeteres rausschreiben der Grafik merken
395
    // GrfNode fuer spaeteres rausschreiben der Grafik merken
406
    pGrf->Insert( pNd, pFlyFmt );
396
    pGrf->Insert(rFrame);
407
397
408
    pChpPlc->AppendFkpEntry( pStrm->Tell(), pO->Count(), pO->GetData() );
398
    pChpPlc->AppendFkpEntry( pStrm->Tell(), pO->Count(), pO->GetData() );
409
    pO->Remove( 0, pO->Count() );                   // leeren
399
    pO->Remove( 0, pO->Count() );                   // leeren
Lines 413-422 Link Here
413
    BYTE aArr[ 18 ];
403
    BYTE aArr[ 18 ];
414
    BYTE* pArr = aArr;
404
    BYTE* pArr = aArr;
415
405
416
    RndStdIds eAn = pFlyFmt->GetAttrSet().GetAnchor(false).GetAnchorId();
406
    const SwFrmFmt &rFlyFmt = rFrame.GetFrmFmt();
407
    RndStdIds eAn = rFlyFmt.GetAttrSet().GetAnchor(false).GetAnchorId();
417
    if( eAn == FLY_IN_CNTNT )
408
    if( eAn == FLY_IN_CNTNT )
418
    {
409
    {
419
        SwVertOrient eVert = pFlyFmt->GetVertOrient().GetVertOrient();
410
        SwVertOrient eVert = rFlyFmt.GetVertOrient().GetVertOrient();
420
        if ((eVert == VERT_CHAR_CENTER) || (eVert == VERT_LINE_CENTER))
411
        if ((eVert == VERT_CHAR_CENTER) || (eVert == VERT_LINE_CENTER))
421
        {
412
        {
422
            bool bVert = false;
413
            bool bVert = false;
Lines 430-436 Link Here
430
            }
421
            }
431
            if (!bVert)
422
            if (!bVert)
432
            {
423
            {
433
                SwTwips nHeight = pFlyFmt->GetFrmSize().GetHeight();
424
                SwTwips nHeight = rFlyFmt.GetFrmSize().GetHeight();
434
                nHeight/=20; //nHeight was in twips, want it in half points, but
425
                nHeight/=20; //nHeight was in twips, want it in half points, but
435
                             //then half of total height.
426
                             //then half of total height.
436
                long nFontHeight = ((const SvxFontHeightItem&)
427
                long nFontHeight = ((const SvxFontHeightItem&)
Lines 480-486 Link Here
480
        bool bOldGrf = bOutGrf;
471
        bool bOldGrf = bOutGrf;
481
        bOutGrf = true;
472
        bOutGrf = true;
482
473
483
        Out_SwFmt(*pFlyFmt, false, false, true);            // Fly-Attrs
474
        Out_SwFmt(rFrame.GetFrmFmt(), false, false, true); // Fly-Attrs
484
475
485
        bOutGrf = bOldGrf;
476
        bOutGrf = bOldGrf;
486
        pPapPlc->AppendFkpEntry( pStrm->Tell(), pO->Count(), pO->GetData() );
477
        pPapPlc->AppendFkpEntry( pStrm->Tell(), pO->Count(), pO->GetData() );
Lines 488-539 Link Here
488
    }
479
    }
489
}
480
}
490
481
491
static Size lcl_GetSwappedInSize(const SwNoTxtNode& rNd)
482
void SwWW8WrGrf::Insert(const sw::Frame &rFly)
492
{
483
{
493
    Size aGrTwipSz(rNd.GetTwipSize());
484
    const SwNoTxtNode *pNd = 
494
    //JP 05.12.98: falls die Grafik noch nie angezeigt wurde und es sich
485
        rFly.GetContent() ? rFly.GetContent()->GetNoTxtNode() : 0;
495
    //              um eine gelinkte handelt, so ist keine Size gesetzt. In
496
    //              diesem Fall sollte man sie mal reinswappen.
497
    if (
498
         (!aGrTwipSz.Width() || !aGrTwipSz.Height()) &&
499
         rNd.IsGrfNode() &&
500
         GRAPHIC_NONE != ((const SwGrfNode&)rNd).GetGrf().GetType()
501
       )
502
    {
503
        ((SwGrfNode&)rNd).SwapIn();
504
        aGrTwipSz = rNd.GetTwipSize();
505
    }
506
507
    return aGrTwipSz;
508
}
509
486
510
void SwWW8WrGrf::Insert( const SwNoTxtNode* pNd, const SwFlyFrmFmt* pFly )
511
{
512
    UINT16 nWidth;
487
    UINT16 nWidth;
513
    UINT16 nHeight;
488
    UINT16 nHeight;
514
    if( rWrt.nFlyWidth > 0 && rWrt.nFlyHeight > 0 )
489
    if (rWrt.nFlyWidth > 0 && rWrt.nFlyHeight > 0)
515
    {
490
    {
516
        nWidth = (UINT16)rWrt.nFlyWidth;
491
        nWidth = rWrt.nFlyWidth;
517
        nHeight = (UINT16)rWrt.nFlyHeight;
492
        nHeight = rWrt.nFlyHeight;
518
    }
493
    }
519
    else if (pNd)
494
    else
520
    {
495
    { 
521
        Size aGrTwipSz(lcl_GetSwappedInSize(*pNd));
496
        Size aSize(rFly.GetSize());
522
        nWidth = (UINT16)aGrTwipSz.Width();
497
        nWidth = aSize.Width();
523
        nHeight = (UINT16)aGrTwipSz.Height();
498
        nHeight = aSize.Height();
524
    }
499
    }
525
500
    maDetails.push_back(GraphicDetails(rFly, nWidth, nHeight));
526
    maDetails.push_back(GraphicDetails(pNd, pFly, nWidth, nHeight));
527
}
501
}
528
502
529
void SwWW8WrGrf::WritePICFHeader(SvStream& rStrm, const SwNoTxtNode* pNd,
503
void SwWW8WrGrf::WritePICFHeader(SvStream& rStrm, const sw::Frame &rFly, 
530
    const SwFlyFrmFmt* pFly, UINT16 mm, UINT16 nWidth, UINT16 nHeight)
504
    UINT16 mm, UINT16 nWidth, UINT16 nHeight, const SwAttrSet* pAttrSet)
531
{
505
{
532
    INT16 nXSizeAdd = 0, nYSizeAdd = 0;
506
    INT16 nXSizeAdd = 0, nYSizeAdd = 0;
533
    INT16 nCropL = 0, nCropR = 0, nCropT = 0, nCropB = 0;
507
    INT16 nCropL = 0, nCropR = 0, nCropT = 0, nCropB = 0;
534
508
535
            // Crop-AttributInhalt in Header schreiben ( falls vorhanden )
509
            // Crop-AttributInhalt in Header schreiben ( falls vorhanden )
536
    const SwAttrSet* pAttrSet = pNd->GetpSwAttrSet();
537
    const SfxPoolItem* pItem;
510
    const SfxPoolItem* pItem;
538
    if (pAttrSet && (SFX_ITEM_ON
511
    if (pAttrSet && (SFX_ITEM_ON
539
        == pAttrSet->GetItemState(RES_GRFATR_CROPGRF, false, &pItem)))
512
        == pAttrSet->GetItemState(RES_GRFATR_CROPGRF, false, &pItem)))
Lines 547-615 Link Here
547
        nYSizeAdd -= (INT16)( rCr.GetTop() + rCr.GetBottom() );
520
        nYSizeAdd -= (INT16)( rCr.GetTop() + rCr.GetBottom() );
548
    }
521
    }
549
522
550
    Size aGrTwipSz(lcl_GetSwappedInSize(*pNd));
523
    Size aGrTwipSz(rFly.GetSize());
551
    bool bWrtWW8 = rWrt.bWrtWW8;
524
    bool bWrtWW8 = rWrt.bWrtWW8;
552
    UINT16 nHdrLen = bWrtWW8 ? 0x44 : 0x3A;
525
    UINT16 nHdrLen = bWrtWW8 ? 0x44 : 0x3A;
553
526
554
    BYTE aArr[ 0x44 ] = { 0 };
527
    BYTE aArr[ 0x44 ] = { 0 };
555
528
556
    BYTE* pArr = aArr + 0x2E;  //Do borders first
529
    BYTE* pArr = aArr + 0x2E;  //Do borders first
557
    if( pFly )
530
531
    const SwAttrSet& rAttrSet = rFly.GetFrmFmt().GetAttrSet();
532
    if (SFX_ITEM_ON == rAttrSet.GetItemState(RES_BOX, false, &pItem))
558
    {
533
    {
559
        const SwAttrSet& rAttrSet = pFly->GetAttrSet();
534
        const SvxBoxItem* pBox = (const SvxBoxItem*)pItem;
560
        if (SFX_ITEM_ON == rAttrSet.GetItemState(RES_BOX, false, &pItem))
535
        if( pBox )
561
        {
536
        {
562
            const SvxBoxItem* pBox = (const SvxBoxItem*)pItem;
537
            bool bShadow = false;               // Shadow ?
563
            if( pBox )
538
            const SvxShadowItem* pSI = 
539
                sw::util::HasItem<SvxShadowItem>(rAttrSet, RES_SHADOW);
540
            if (pSI)
564
            {
541
            {
565
                bool bShadow = false;               // Shadow ?
542
                bShadow = (pSI->GetLocation() != SVX_SHADOW_NONE) && 
566
                const SvxShadowItem* pSI = 
543
                    (pSI->GetWidth() != 0);
567
                    sw::util::HasItem<SvxShadowItem>(rAttrSet, RES_SHADOW);
544
            }
568
                if (pSI)
545
546
            BYTE aLnArr[4] = { BOX_LINE_TOP, BOX_LINE_LEFT,
547
                                BOX_LINE_BOTTOM, BOX_LINE_RIGHT };
548
            for( BYTE i = 0; i < 4; ++i )
549
            {
550
                const SvxBorderLine* pLn = pBox->GetLine( aLnArr[ i ] );
551
                WW8_BRC aBrc;
552
                if (pLn)
569
                {
553
                {
570
                    bShadow = (pSI->GetLocation() != SVX_SHADOW_NONE) && 
554
                    aBrc = rWrt.TranslateBorderLine( *pLn,
571
                        (pSI->GetWidth() != 0);
555
                        pBox->GetDistance( aLnArr[ i ] ), bShadow );
572
                }
556
                }
573
557
574
                BYTE aLnArr[4] = { BOX_LINE_TOP, BOX_LINE_LEFT,
558
                //use importer logic to determine how large the exported
575
                                    BOX_LINE_BOTTOM, BOX_LINE_RIGHT };
559
                //border will really be in word and adjust accordingly
576
                for( BYTE i = 0; i < 4; ++i )
560
                short nSpacing;
561
                short nThick = aBrc.DetermineBorderProperties(!bWrtWW8,
562
                    &nSpacing);
563
                switch (aLnArr[ i ])
577
                {
564
                {
578
                    const SvxBorderLine* pLn = pBox->GetLine( aLnArr[ i ] );
565
                    case BOX_LINE_TOP:
579
                    WW8_BRC aBrc;
566
                    case BOX_LINE_BOTTOM:
580
                    if (pLn)
567
                        nHeight -= bShadow ? nThick*2 : nThick;
581
                    {
568
                        nHeight -= nSpacing;
582
                        aBrc = rWrt.TranslateBorderLine( *pLn,
569
                        break;
583
                            pBox->GetDistance( aLnArr[ i ] ), bShadow );
570
                    case BOX_LINE_LEFT:
584
                    }
571
                    case BOX_LINE_RIGHT:
572
                    default:
573
                        nWidth -= bShadow ? nThick*2 : nThick;
574
                        nWidth -= nSpacing;
575
                        break;
576
                }
577
                memcpy( pArr, &aBrc.aBits1, 2);
578
                pArr+=2;
585
579
586
                    //use importer logic to determine how large the exported
580
                if( bWrtWW8 )
587
                    //border will really be in word and adjust accordingly
581
                {
588
                    short nSpacing;
582
                    memcpy( pArr, &aBrc.aBits2, 2);
589
                    short nThick = aBrc.DetermineBorderProperties(!bWrtWW8,
590
                        &nSpacing);
591
                    switch (aLnArr[ i ])
592
                    {
593
                        case BOX_LINE_TOP:
594
                        case BOX_LINE_BOTTOM:
595
                            nHeight -= bShadow ? nThick*2 : nThick;
596
                            nHeight -= nSpacing;
597
                            break;
598
                        case BOX_LINE_LEFT:
599
                        case BOX_LINE_RIGHT:
600
                        default:
601
                            nWidth -= bShadow ? nThick*2 : nThick;
602
                            nWidth -= nSpacing;
603
                            break;
604
                    }
605
                    memcpy( pArr, &aBrc.aBits1, 2);
606
                    pArr+=2;
583
                    pArr+=2;
607
608
                    if( bWrtWW8 )
609
                    {
610
                        memcpy( pArr, &aBrc.aBits2, 2);
611
                        pArr+=2;
612
                    }
613
                }
584
                }
614
            }
585
            }
615
        }
586
        }
Lines 662-675 Link Here
662
    rStrm.Write( aArr, nHdrLen );
633
    rStrm.Write( aArr, nHdrLen );
663
}
634
}
664
635
665
void SwWW8WrGrf::WriteGrfFromGrfNode(SvStream& rStrm, const SwGrfNode* pGrfNd,
636
void SwWW8WrGrf::WriteGrfFromGrfNode(SvStream& rStrm, const SwGrfNode &rGrfNd,
666
    const SwFlyFrmFmt* pFly, UINT16 nWidth, UINT16 nHeight)
637
    const sw::Frame &rFly, UINT16 nWidth, UINT16 nHeight)
667
{
638
{
668
    if (pGrfNd->IsLinkedFile())     // Linked File
639
    if (rGrfNd.IsLinkedFile())     // Linked File
669
    {
640
    {
670
        String aFileN, aFiltN;
641
        String aFileN, aFiltN;
671
        UINT16 mm;
642
        UINT16 mm;
672
        pGrfNd->GetFileFilterNms( &aFileN, &aFiltN );
643
        rGrfNd.GetFileFilterNms( &aFileN, &aFiltN );
673
644
674
        aFileN = INetURLObject::AbsToRel( aFileN, INetURLObject::WAS_ENCODED,
645
        aFileN = INetURLObject::AbsToRel( aFileN, INetURLObject::WAS_ENCODED,
675
                                        INetURLObject::DECODE_UNAMBIGUOUS);
646
                                        INetURLObject::DECODE_UNAMBIGUOUS);
Lines 686-710 Link Here
686
//      else
657
//      else
687
            mm = 94;                    // 94 = BMP, GIF
658
            mm = 94;                    // 94 = BMP, GIF
688
659
689
        WritePICFHeader(rStrm, pGrfNd, pFly, mm, nWidth, nHeight);  // Header
660
        WritePICFHeader(rStrm, rFly, mm, nWidth, nHeight, 
661
            rGrfNd.GetpSwAttrSet());
690
        rStrm << (BYTE)aFileN.Len();    // Pascal-String schreiben
662
        rStrm << (BYTE)aFileN.Len();    // Pascal-String schreiben
691
        SwWW8Writer::WriteString8(rStrm, aFileN, false, 
663
        SwWW8Writer::WriteString8(rStrm, aFileN, false, 
692
            RTL_TEXTENCODING_MS_1252);
664
            RTL_TEXTENCODING_MS_1252);
693
    }
665
    }
694
    else                                // Embedded File oder DDE oder so was
666
    else                                // Embedded File oder DDE oder so was
695
    {
667
    {
696
        if (rWrt.bWrtWW8 && pFly)
668
        if (rWrt.bWrtWW8)
697
        {
669
        {
698
            WritePICFHeader(rStrm, pGrfNd, pFly, 0x64, nWidth, nHeight);
670
            WritePICFHeader(rStrm, rFly, 0x64, nWidth, nHeight, 
671
                rGrfNd.GetpSwAttrSet());
699
            SwBasicEscherEx aInlineEscher(&rStrm, rWrt);
672
            SwBasicEscherEx aInlineEscher(&rStrm, rWrt);
700
            aInlineEscher.WriteGrfFlyFrame(*pFly, 0x401);
673
            aInlineEscher.WriteGrfFlyFrame(rFly.GetFrmFmt(), 0x401);
701
            aInlineEscher.WritePictures();
674
            aInlineEscher.WritePictures();
702
        }
675
        }
703
        else
676
        else
704
        {
677
        {
705
            Graphic& rGrf = (Graphic&)(pGrfNd->GetGrf());
678
            Graphic& rGrf = const_cast<Graphic&>(rGrfNd.GetGrf());
706
            bool bSwapped = rGrf.IsSwapOut() ? true : false;
679
            bool bSwapped = rGrf.IsSwapOut() ? true : false;
707
            ((SwGrfNode*)pGrfNd)->SwapIn(); // immer ueber den Node einswappen!
680
            // immer ueber den Node einswappen!
681
            const_cast<SwGrfNode&>(rGrfNd).SwapIn();
708
682
709
            GDIMetaFile aMeta;
683
            GDIMetaFile aMeta;
710
            switch (rGrf.GetType())
684
            switch (rGrf.GetType())
Lines 727-733 Link Here
727
                    return;
701
                    return;
728
            }
702
            }
729
703
730
            WritePICFHeader(rStrm, pGrfNd, pFly, 8, nWidth, nHeight);
704
            WritePICFHeader(rStrm, rFly, 8, nWidth, nHeight, 
705
                rGrfNd.GetpSwAttrSet());
731
            WriteWindowMetafileBits(rStrm, aMeta);
706
            WriteWindowMetafileBits(rStrm, aMeta);
732
707
733
            if (bSwapped) 
708
            if (bSwapped) 
Lines 736-758 Link Here
736
    }
711
    }
737
}
712
}
738
713
739
void SwWW8WrGrf::WriteGraphicNode(SvStream& rStrm, const SwNoTxtNode* pNd,
714
void SwWW8WrGrf::WriteGraphicNode(SvStream& rStrm, const GraphicDetails &rItem)
740
    const SwFlyFrmFmt* pFly, UINT16 nWidth, UINT16 nHeight)
741
{
715
{
742
    if (!pNd || (!pNd->IsGrfNode() && !pNd->IsOLENode()))
716
    UINT16 nWidth = rItem.mnWid;
743
        return;
717
    UINT16 nHeight = rItem.mnHei;
744
745
    UINT32 nPos = rStrm.Tell();         // Grafik-Anfang merken
718
    UINT32 nPos = rStrm.Tell();         // Grafik-Anfang merken
746
719
747
    if (pNd->IsGrfNode())
720
    const sw::Frame &rFly = rItem.maFly;
748
        WriteGrfFromGrfNode(rStrm, pNd->GetGrfNode(), pFly, nWidth, nHeight);
721
    switch (rFly.GetWriterType())
749
    else if (pNd->IsOLENode())
750
    {
722
    {
751
#ifdef OLE_PREVIEW_AS_EMF
723
        case sw::Frame::eGraphic:
752
        if (!rWrt.bWrtWW8)
753
        {
724
        {
725
            const SwNode *pNode = rItem.maFly.GetContent();
726
            const SwGrfNode *pNd = pNode ? pNode->GetGrfNode() : 0;
727
            ASSERT(pNd, "Impossible");
728
            if (pNd)
729
                WriteGrfFromGrfNode(rStrm, *pNd, rItem.maFly, nWidth, nHeight);
730
        }
731
        break;
732
        case sw::Frame::eOle:
733
        {
734
#ifdef OLE_PREVIEW_AS_EMF
735
            const SwNode *pNode = rItem.maFly.GetContent();
736
            const SwOLENode *pNd = pNode ? pNode->GetOLENode() : 0;
737
            ASSERT(pNd, "Impossible");
738
            if (!rWrt.bWrtWW8)
739
            {
740
                SwOLENode *pOleNd = const_cast<SwOLENode*>(pNd);
741
                ASSERT( pOleNd, " Wer hat den OleNode versteckt ?" );
742
                SwOLEObj&                   rSObj= pOleNd->GetOLEObj();
743
                const SvInPlaceObjectRef    rObj(  rSObj.GetOleRef() );
744
745
                GDIMetaFile aMtf;
746
                rObj->GetGDIMetaFile(aMtf);
747
748
                aMtf.WindStart();
749
                aMtf.Play(Application::GetDefaultDevice(), Point(0, 0), 
750
                    Size(2880, 2880));
751
                
752
                WritePICFHeader(rStrm, rFly, 8, nWidth, nHeight, 
753
                    pNd->GetpSwAttrSet());
754
                WriteWindowMetafileBits(rStrm, aMtf);
755
            }
756
            else
757
            {
758
                //Convert this ole2 preview in ww8+ to an EMF for better unicode
759
                //support (note that at this moment this breaks StarSymbol
760
                //using graphics because I need to embed starsymbol in exported
761
                //documents.
762
                WritePICFHeader(rStrm, rFly, 0x64, nWidth, nHeight, 
763
                    pNd->GetpSwAttrSet());
764
                SwBasicEscherEx aInlineEscher(&rStrm, rWrt);
765
                aInlineEscher.WriteOLEFlyFrame(rFly.GetFrmFmt(), 0x401);
766
                aInlineEscher.WritePictures();
767
            }
768
#else
754
            // cast away const
769
            // cast away const
755
            SwOLENode *pOleNd = ((SwNoTxtNode*)pNd)->GetOLENode(); 
770
            SwOLENode *pOleNd = const_cast<SwOLENode*>(pNd);
756
            ASSERT( pOleNd, " Wer hat den OleNode versteckt ?" );
771
            ASSERT( pOleNd, " Wer hat den OleNode versteckt ?" );
757
            SwOLEObj&                   rSObj= pOleNd->GetOLEObj();
772
            SwOLEObj&                   rSObj= pOleNd->GetOLEObj();
758
            const SvInPlaceObjectRef    rObj(  rSObj.GetOleRef() );
773
            const SvInPlaceObjectRef    rObj(  rSObj.GetOleRef() );
Lines 760-801 Link Here
760
            GDIMetaFile aMtf;
775
            GDIMetaFile aMtf;
761
            rObj->GetGDIMetaFile(aMtf);
776
            rObj->GetGDIMetaFile(aMtf);
762
777
778
            Size aS(aMtf.GetPrefSize());
763
            aMtf.WindStart();
779
            aMtf.WindStart();
764
            aMtf.Play(Application::GetDefaultDevice(), Point(0, 0), 
780
            aMtf.Play(Application::GetDefaultDevice(), Point(0, 0), 
765
                Size(2880, 2880));
781
                Size(2880, 2880));
766
            
767
            WritePICFHeader(rStrm, pNd, pFly, 8, nWidth, nHeight);  // Header
768
            WriteWindowMetafileBits(rStrm, aMtf);
769
        }
770
        else
771
        {
772
            //Convert this ole2 preview in ww8+ to an EMF for better unicode
773
            //support (note that at this moment this breaks StarSymbol
774
            //using graphics because I need to embed starsymbol in exported
775
            //documents.
776
            WritePICFHeader(rStrm, pNd, pFly, 0x64, nWidth, nHeight);
777
            SwBasicEscherEx aInlineEscher(&rStrm, rWrt);
778
            aInlineEscher.WriteOLEFlyFrame(*pFly, 0x401);
779
            aInlineEscher.WritePictures();
780
        }
781
#else
782
        // cast away const
783
        SwOLENode *pOleNd = ((SwNoTxtNode*)pNd)->GetOLENode(); 
784
        ASSERT( pOleNd, " Wer hat den OleNode versteckt ?" );
785
        SwOLEObj&                   rSObj= pOleNd->GetOLEObj();
786
        const SvInPlaceObjectRef    rObj(  rSObj.GetOleRef() );
787
788
        GDIMetaFile aMtf;
789
        rObj->GetGDIMetaFile(aMtf);
790
791
        Size aS(aMtf.GetPrefSize());
792
        aMtf.WindStart();
793
        aMtf.Play(Application::GetDefaultDevice(), Point(0, 0), 
794
            Size(2880, 2880));
795
782
796
        WritePICFHeader( rStrm, pNd, pFly, 8, nWidth, nHeight );    // Header
783
            WritePICFHeader(rStrm, rFly, 8, nWidth, nHeight, 
797
        WriteWindowMetafileBits( rStrm, aMtf );         // eigentliche Grafik
784
                pNd->GetpSwAttrSet());
785
            WriteWindowMetafileBits(rStrm, aMtf);
798
#endif
786
#endif
787
        }
788
        break;
789
        case sw::Frame::eDrawing:
790
        case sw::Frame::eTxtBox:
791
            ASSERT(rWrt.bWrtWW8, 
792
                "You can't try and export these in WW8 format, a filter bug");
793
            /*
794
            #i3958# We only export an empty dummy picture frame here, this is
795
            what word does the escher export should contain an anchored to
796
            character element which is drawn over this dummy and the whole
797
            shebang surrounded with a SHAPE field. This isn't *my* hack :-),
798
            its what word does.
799
            */
800
            if (rWrt.bWrtWW8)
801
            {
802
                WritePICFHeader(rStrm, rFly, 0x64, nWidth, nHeight);
803
                SwBasicEscherEx aInlineEscher(&rStrm, rWrt);
804
                aInlineEscher.WriteEmptyFlyFrame(rFly.GetFrmFmt(), 0x401);
805
            }
806
            break;
807
        default:
808
            ASSERT(!this, 
809
           "Some inline export not implemented, remind cmc before we ship :-)");
810
            break;
799
    }
811
    }
800
812
801
    UINT32 nPos2 = rStrm.Tell();                    // Ende merken
813
    UINT32 nPos2 = rStrm.Tell();                    // Ende merken
Lines 819-826 Link Here
819
    myiter aEnd = maDetails.end();
831
    myiter aEnd = maDetails.end();
820
    for (myiter aIter = maDetails.begin(); aIter != aEnd; ++aIter)
832
    for (myiter aIter = maDetails.begin(); aIter != aEnd; ++aIter)
821
    {
833
    {
822
        const SwNoTxtNode* pNd = aIter->mpNd;
823
824
        UINT32 nPos = rStrm.Tell();                 // auf 4 Bytes alignen
834
        UINT32 nPos = rStrm.Tell();                 // auf 4 Bytes alignen
825
        if( nPos & 0x3 )
835
        if( nPos & 0x3 )
826
            SwWW8Writer::FillCount( rStrm, 4 - ( nPos & 0x3 ) );
836
            SwWW8Writer::FillCount( rStrm, 4 - ( nPos & 0x3 ) );
Lines 839-846 Link Here
839
        if (!bDuplicated)
849
        if (!bDuplicated)
840
        {
850
        {
841
            aIter->mnPos = rStrm.Tell();
851
            aIter->mnPos = rStrm.Tell();
842
            WriteGraphicNode(rStrm, pNd, aIter->mpFly, aIter->mnWid, 
852
            WriteGraphicNode(rStrm, *aIter);
843
                aIter->mnHei);
844
        }
853
        }
845
    }
854
    }
846
}
855
}
(-)ww8atr.cxx (-34 / +32 lines)
Lines 774-806 Link Here
774
    case RES_CHRFMT:
774
    case RES_CHRFMT:
775
        break;
775
        break;
776
    case RES_FLYFRMFMT:
776
    case RES_FLYFRMFMT:
777
        if( bFlyFmt )
777
        if (bFlyFmt)
778
        {
778
        {
779
            SfxItemSet aSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN,
779
            ASSERT(mpParentFrame, "No parent frame, all broken");
780
                                                RES_FRMATR_END-1 );
781
            aSet.Set( pFlyFmt->GetAttrSet() );
782
780
783
            // Fly als Zeichen werden bei uns zu Absatz-gebundenen
781
            if (mpParentFrame)
784
            // jetzt den Abstand vom Absatz-Rand setzen
785
            if( pFlyOffset )
786
            {
782
            {
787
                aSet.Put( SwFmtVertOrient( pFlyOffset->Y() ));
783
                const SwFrmFmt &rFmt = mpParentFrame->GetFrmFmt();
788
                aSet.Put( SwFmtHoriOrient( pFlyOffset->X() ));
784
                
789
                SwFmtAnchor aAnchor(pFlyFmt->GetAnchor());
785
                SfxItemSet aSet(pDoc->GetAttrPool(), RES_FRMATR_BEGIN,
790
                aAnchor.SetType(eNewAnchorType);
786
                    RES_FRMATR_END-1);
791
                aSet.Put( aAnchor );
787
                aSet.Set(rFmt.GetAttrSet());
792
            }
788
789
                // Fly als Zeichen werden bei uns zu Absatz-gebundenen
790
                // jetzt den Abstand vom Absatz-Rand setzen
791
                if (pFlyOffset)
792
                {
793
                    aSet.Put(SwFmtHoriOrient(pFlyOffset->X()));
794
                    aSet.Put(SwFmtVertOrient(pFlyOffset->Y()));
795
                    SwFmtAnchor aAnchor(rFmt.GetAnchor());
796
                    aAnchor.SetType(eNewAnchorType);
797
                    aSet.Put(aAnchor);
798
                }
793
799
794
            if( SFX_ITEM_SET != aSet.GetItemState( RES_SURROUND ))
800
                if (SFX_ITEM_SET != aSet.GetItemState(RES_SURROUND))
795
                aSet.Put( SwFmtSurround( SURROUND_NONE ) );
801
                    aSet.Put(SwFmtSurround(SURROUND_NONE));
796
802
797
            bOutFlyFrmAttrs = true;
803
                bOutFlyFrmAttrs = true;
798
            //script doesn't matter if not exporting chp
804
                //script doesn't matter if not exporting chp
799
            Out_SfxItemSet(aSet, true, false,
805
                Out_SfxItemSet(aSet, true, false,
800
                com::sun::star::i18n::ScriptType::LATIN);
806
                    com::sun::star::i18n::ScriptType::LATIN);
801
            bOutFlyFrmAttrs = false;
807
                bOutFlyFrmAttrs = false;
802
808
803
            bCallOutSet = false;
809
                bCallOutSet = false;
810
            }
804
        }
811
        }
805
        break;
812
        break;
806
    default:
813
    default:
Lines 3110-3116 Link Here
3110
            break;
3117
            break;
3111
        }
3118
        }
3112
    }
3119
    }
3113
    else if( !rWW8Wrt.pFlyFmt )
3120
    else if (!rWW8Wrt.mpParentFrame)
3114
    {
3121
    {
3115
        BYTE nC = 0;
3122
        BYTE nC = 0;
3116
        bool bBefore = false;
3123
        bool bBefore = false;
Lines 3506-3514 Link Here
3506
Writer& OutWW8_SwFmtHoriOrient( Writer& rWrt, const SfxPoolItem& rHt )
3513
Writer& OutWW8_SwFmtHoriOrient( Writer& rWrt, const SfxPoolItem& rHt )
3507
{
3514
{
3508
    SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
3515
    SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
3509
    if( !rWW8Wrt.pFlyFmt )
3516
    if (!rWW8Wrt.mpParentFrame)
3510
    {
3517
    {
3511
        ASSERT( rWW8Wrt.pFlyFmt, "HoriOrient ohne pFlyFmt !!" );
3518
        ASSERT(rWW8Wrt.mpParentFrame, "HoriOrient without mpParentFrame !!");
3512
        return rWrt;
3519
        return rWrt;
3513
    }
3520
    }
3514
3521
Lines 3524-3538 Link Here
3524
                                nPos = (short)rFlyHori.GetPos();
3531
                                nPos = (short)rFlyHori.GetPos();
3525
                                if( !nPos )
3532
                                if( !nPos )
3526
                                    nPos = 1;   // WW: 0 ist reserviert
3533
                                    nPos = 1;   // WW: 0 ist reserviert
3527
#if 0
3528
// ist nicht noetig, da Bindung an Absatz als hor. Bindung an die
3529
// Spalte exportiert wird, da so das Verhalten bei Mehrspaltigkeit
3530
// am AEhnlichsten ist.
3531
                                RndStdIds eAn = rWW8Wrt.pFlyFmt->GetAttrSet().
3532
                                                GetAnchor().GetAnchorId();
3533
                                if( eAn == FLY_AT_CNTNT || eAn == FLY_IN_CNTNT )
3534
                                    nPos += GetPageL( rWW8Wrt );
3535
#endif
3536
                           }
3534
                           }
3537
                           break;
3535
                           break;
3538
3536
Lines 3558-3564 Link Here
3558
static Writer& OutWW8_SwFmtAnchor( Writer& rWrt, const SfxPoolItem& rHt )
3556
static Writer& OutWW8_SwFmtAnchor( Writer& rWrt, const SfxPoolItem& rHt )
3559
{
3557
{
3560
    SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
3558
    SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
3561
    ASSERT( rWW8Wrt.pFlyFmt, "Anker ohne pFlyFmt !!" );
3559
    ASSERT(rWW8Wrt.mpParentFrame, "Anchor without mpParentFrame !!");
3562
3560
3563
    if( rWW8Wrt.bOutFlyFrmAttrs )
3561
    if( rWW8Wrt.bOutFlyFrmAttrs )
3564
    {
3562
    {
(-)ww8graf.cxx (-2 / +2 lines)
Lines 2716-2722 Link Here
2716
2716
2717
        if (!bDone)
2717
        if (!bDone)
2718
        {
2718
        {
2719
            sw::hack::SetLayer aSetLayer(rDoc);
2719
            sw::util::SetLayer aSetLayer(rDoc);
2720
            if (pF->bBelowText || pRecord->bDrawHell)
2720
            if (pF->bBelowText || pRecord->bDrawHell)
2721
                aSetLayer.SendObjectToHell(*pObject);
2721
                aSetLayer.SendObjectToHell(*pObject);
2722
            else
2722
            else
Lines 3092-3098 Link Here
3092
    ASSERT(pDrawModel, "Kann DrawModel nicht anlegen");
3092
    ASSERT(pDrawModel, "Kann DrawModel nicht anlegen");
3093
    pDrawPg = pDrawModel->GetPage(0);
3093
    pDrawPg = pDrawModel->GetPage(0);
3094
3094
3095
    pWWZOrder = new wwZOrderer(sw::hack::SetLayer(rDoc), pDrawPg,
3095
    pWWZOrder = new wwZOrderer(sw::util::SetLayer(rDoc), pDrawPg,
3096
        pMSDffManager ? pMSDffManager->GetShapeOrders() : 0);
3096
        pMSDffManager ? pMSDffManager->GetShapeOrders() : 0);
3097
}
3097
}
3098
3098
(-)ww8graf.hxx (-2 / +2 lines)
Lines 95-101 Link Here
95
95
96
    std::stack<USHORT> maIndexes;
96
    std::stack<USHORT> maIndexes;
97
97
98
    sw::hack::SetLayer maSetLayer;
98
    sw::util::SetLayer maSetLayer;
99
99
100
    ULONG mnNoInitialObjects;
100
    ULONG mnNoInitialObjects;
101
    ULONG mnInlines;
101
    ULONG mnInlines;
Lines 108-114 Link Here
108
    ULONG GetDrawingObjectPos(short nWwHeight);
108
    ULONG GetDrawingObjectPos(short nWwHeight);
109
    bool InsertObject(SdrObject *pObject, ULONG nPos);
109
    bool InsertObject(SdrObject *pObject, ULONG nPos);
110
public:
110
public:
111
    wwZOrderer(const sw::hack::SetLayer &rSetLayer, SdrPage* pDrawPg, 
111
    wwZOrderer(const sw::util::SetLayer &rSetLayer, SdrPage* pDrawPg, 
112
        const SvxMSDffShapeOrders *pShapeOrders);
112
        const SvxMSDffShapeOrders *pShapeOrders);
113
    void InsertTextLayerObject(SdrObject* pObject);
113
    void InsertTextLayerObject(SdrObject* pObject);
114
    /*
114
    /*
(-)ww8graf2.cxx (-1 / +1 lines)
Lines 168-174 Link Here
168
#include "ww8graf.hxx"
168
#include "ww8graf.hxx"
169
#endif
169
#endif
170
170
171
wwZOrderer::wwZOrderer(const sw::hack::SetLayer &rSetLayer, SdrPage* pDrawPg,
171
wwZOrderer::wwZOrderer(const sw::util::SetLayer &rSetLayer, SdrPage* pDrawPg,
172
    const SvxMSDffShapeOrders *pShapeOrders)
172
    const SvxMSDffShapeOrders *pShapeOrders)
173
    : maSetLayer(rSetLayer), mnInlines(0), mpDrawPg(pDrawPg), 
173
    : maSetLayer(rSetLayer), mnInlines(0), mpDrawPg(pDrawPg), 
174
    mpShapeOrders(pShapeOrders)
174
    mpShapeOrders(pShapeOrders)

Return to issue 3958