? mylog ? mypatch ? mycunningpatch ? patch.part.1 ? mycoolpatch ? patch.part.2 ? stor ? sprms.cxx ? silly.amount.of.changes.patch.4 ? silly.amount.of.changes.patch.3 ? attempt.1 ? patch.for.ama.for.footers.headers ? output ? part.1 ? part.2 Index: escher.hxx =================================================================== RCS file: /cvs/sw/sw/source/filter/ww8/escher.hxx,v retrieving revision 1.7 diff -u -r1.7 escher.hxx --- escher.hxx 25 Sep 2003 07:40:09 -0000 1.7 +++ escher.hxx 23 Oct 2003 14:03:37 -0000 @@ -114,6 +114,7 @@ SwBasicEscherEx(SvStream* pStrm, SwWW8Writer& rWrt, UINT32 nDrawings = 1); INT32 WriteGrfFlyFrame(const SwFrmFmt& rFmt, UINT32 nShapeId); INT32 WriteOLEFlyFrame(const SwFrmFmt& rFmt, UINT32 nShapeId); + void WriteEmptyFlyFrame(const SwFrmFmt& rFmt, UINT32 nShapeId); virtual void WriteFrmExtraData(const SwFrmFmt&); virtual void WritePictures(); virtual ~SwBasicEscherEx(); Index: writerhelper.cxx =================================================================== RCS file: /cvs/sw/sw/source/filter/ww8/writerhelper.cxx,v retrieving revision 1.3.22.1 diff -u -r1.3.22.1 writerhelper.cxx --- writerhelper.cxx 21 Oct 2003 15:42:52 -0000 1.3.22.1 +++ writerhelper.cxx 23 Oct 2003 14:03:37 -0000 @@ -77,6 +77,9 @@ #ifndef _FRMFMT_HXX #include //SwFrmFmt #endif +#ifndef _FMTCNTNT_HXX +#include //SwFmtCntnt +#endif #ifndef _FLYPOS_HXX #include //SwPosFlyFrms #endif @@ -86,6 +89,15 @@ #ifndef _NDTXT_HXX #include //SwTxtNode #endif +#ifndef _NDGRF_HXX +#include //SwGrfNode +#endif +#ifndef _NDNOTXT_HXX +#include //SwNoTxtNode +#endif +#ifndef _FMTFSIZE_HXX +#include //SwFmtFrmSize +#endif #ifndef _SVDOBJ_HXX #include //SdrObject #endif @@ -180,12 +192,155 @@ return (mnNode == rFrame.GetPosition().nNode.GetNode().GetIndex()); } }; + + Size GetSwappedInSize(const SwNoTxtNode& rNd) + { + Size aGrTwipSz(rNd.GetTwipSize()); + if ((!aGrTwipSz.Width() || !aGrTwipSz.Height())) + { + SwGrfNode *pGrfNode = const_cast(rNd.GetGrfNode()); + if (pGrfNode && (GRAPHIC_NONE != pGrfNode->GetGrf().GetType())) + { + bool bWasSwappedOut = pGrfNode->GetGrfObj().IsSwappedOut(); + pGrfNode->SwapIn(); + aGrTwipSz = pGrfNode->GetTwipSize(); + if (bWasSwappedOut) + pGrfNode->SwapOut(); + } + } + + ASSERT(aGrTwipSz.Width() && aGrTwipSz.Height(), "0 x 0 graphic ?"); + return aGrTwipSz; + } } namespace sw { + Frame::Frame(const SwFrmFmt &rFmt, const SwPosition &rPos) + : mpFlyFrm(&rFmt), maPos(rPos), meWriterType(eTxtBox), + mpStartFrameContent(0) + { + switch (rFmt.Which()) + { + case RES_FLYFRMFMT: + if (const SwNodeIndex* pIdx = rFmt.GetCntnt().GetCntntIdx()) + { + SwNodeIndex aIdx(*pIdx, 1); + const SwNode &rNd = aIdx.GetNode(); + switch (rNd.GetNodeType()) + { + case ND_GRFNODE: + meWriterType = eGraphic; + maSize = GetSwappedInSize(*rNd.GetNoTxtNode()); + break; + case ND_OLENODE: + meWriterType = eOle; + maSize = GetSwappedInSize(*rNd.GetNoTxtNode()); + break; + default: + { + meWriterType = eTxtBox; + + Rectangle aRect; + SwRect aLayRect(rFmt.FindLayoutRect()); + /* + The Object is not rendered (e.g. something in + unused header/footer - so get the values from + the format. + */ + if (aLayRect.IsEmpty()) + aRect.SetSize(rFmt.GetFrmSize().GetSize()); + else + aRect = aLayRect.SVRect(); + + maSize = aRect.GetSize(); + } + break; + } + mpStartFrameContent = &rNd; + } + else + { + ASSERT(!this, "Impossible"); + meWriterType = eTxtBox; + } + break; + default: + if (const SdrObject* pObj = rFmt.FindRealSdrObject()) + { + if (pObj->GetObjInventor() == FmFormInventor) + meWriterType = eFormControl; + else + meWriterType = eDrawing; + maSize = pObj->GetSnapRect().GetSize(); + } + else + { + ASSERT(!this, "Impossible"); + meWriterType = eDrawing; + } + break; + } + } + + bool Frame::IsInline() const + { + return (mpFlyFrm->GetAnchor().GetAnchorId() == FLY_IN_CNTNT); + } + namespace hack { + DrawingOLEAdaptor::DrawingOLEAdaptor(SdrOle2Obj &rObj, + SvPersist &rPers) + : mxIPRef(rObj.GetObjRef()), + msOrigPersistName(rObj.GetPersistName()), mrPers(rPers) + { + rObj.SetPersistName(String()); + rObj.SetObjRef(SvInPlaceObjectRef()); + } + + bool DrawingOLEAdaptor::TransferToDoc(const String &rName) + { + ASSERT(mxIPRef.Is(), "Transferring invalid object to doc"); + if (!mxIPRef.Is()) + return false; + + SvInfoObjectRef refObj = new SvEmbeddedInfoObject(mxIPRef, rName); + bool bSuccess = mrPers.Move(refObj, rName); + if (bSuccess) + { + SvPersist *pO = mxIPRef; + ASSERT(!pO->IsModified(), "Not expected to be modified here"); + if (pO->IsModified()) + { + pO->DoSave(); + pO->DoSaveCompleted(); + } + mxIPRef.Clear(); + bSuccess = mrPers.Unload(pO); + } + + return bSuccess; + } + + DrawingOLEAdaptor::~DrawingOLEAdaptor() + { + if (mxIPRef.Is()) + { + if (SvInfoObject* pInfo = mrPers.Find(msOrigPersistName)) + { + pInfo->SetDeleted(TRUE); + pInfo->SetObj(0); + } + mxIPRef->DoClose(); + mrPers.Remove(mxIPRef); + mxIPRef.Clear(); + } + } + } + + namespace util + { void SetLayer::SendObjectToHell(SdrObject &rObject) const { SetObjectLayer(rObject, eHell); @@ -244,58 +399,6 @@ } //SetLayer boilerplate end - - DrawingOLEAdaptor::DrawingOLEAdaptor(SdrOle2Obj &rObj, - SvPersist &rPers) - : mxIPRef(rObj.GetObjRef()), - msOrigPersistName(rObj.GetPersistName()), mrPers(rPers) - { - rObj.SetPersistName(String()); - rObj.SetObjRef(SvInPlaceObjectRef()); - } - - bool DrawingOLEAdaptor::TransferToDoc(const String &rName) - { - ASSERT(mxIPRef.Is(), "Transferring invalid object to doc"); - if (!mxIPRef.Is()) - return false; - - SvInfoObjectRef refObj = new SvEmbeddedInfoObject(mxIPRef, rName); - bool bSuccess = mrPers.Move(refObj, rName); - if (bSuccess) - { - SvPersist *pO = mxIPRef; - ASSERT(!pO->IsModified(), "Not expected to be modified here"); - if (pO->IsModified()) - { - pO->DoSave(); - pO->DoSaveCompleted(); - } - mxIPRef.Clear(); - bSuccess = mrPers.Unload(pO); - } - - return bSuccess; - } - - DrawingOLEAdaptor::~DrawingOLEAdaptor() - { - if (mxIPRef.Is()) - { - if (SvInfoObject* pInfo = mrPers.Find(msOrigPersistName)) - { - pInfo->SetDeleted(TRUE); - pInfo->SetObj(0); - } - mxIPRef->DoClose(); - mrPers.Remove(mxIPRef); - mxIPRef.Clear(); - } - } - } - - namespace util - { ParaStyles GetParaStyles(const SwDoc &rDoc) { ParaStyles aStyles; Index: writerhelper.hxx =================================================================== RCS file: /cvs/sw/sw/source/filter/ww8/writerhelper.hxx,v retrieving revision 1.3.22.1 diff -u -r1.3.22.1 writerhelper.hxx --- writerhelper.hxx 21 Oct 2003 15:42:52 -0000 1.3.22.1 +++ writerhelper.hxx 23 Oct 2003 14:03:37 -0000 @@ -108,21 +108,101 @@ typedef std::vector::iterator ParaStyleIter; + /** Make exporting a Writer Frame easy + + In word all frames are effectively anchored to character or as + character. So we must have some content to anchor to. A sw::Frame + wraps the writer frame and is guaranted to have a suitable anchor + position available from it. + + It provides a more generally unified view of the true contents + of SwFrmFmt in a way that is easy to export. + Provides the best size value to export to word. + Provides an anchor position to export to word with. + Provides a readable way to see if we are anchored "as character" + Provides a simpler way to flag what type of entity this frame describes. + + + + @author + Caolán McNamara + */ class Frame { + public: + enum WriterSource {eTxtBox, eGraphic, eOle, eDrawing, eFormControl}; private: const SwFrmFmt* mpFlyFrm; SwPosition maPos; + Size maSize; + WriterSource meWriterType; + const SwNode *mpStartFrameContent; public: - Frame(const SwFrmFmt &rFlyFrm, const SwPosition &rPos) - : mpFlyFrm(&rFlyFrm), maPos(rPos) {} + Frame(const SwFrmFmt &rFlyFrm, const SwPosition &rPos); + + /** Get the writer SwFrmFmt that this object describes + + @return + The wrapped SwFrmFmt + */ const SwFrmFmt &GetFrmFmt() const { return *mpFlyFrm; } + + /** Get the position this frame is anchored at + + @return + The anchor position of this frame + */ const SwPosition &GetPosition() const { return maPos; } + + /** Get the node this frame is anchored into + + @return + The SwTxtNode this frame is anchored inside + */ const SwCntntNode *GetCntntNode() const { return maPos.nNode.GetNode().GetCntntNode(); } + + /** Get the type of frame that this wraps + + @return + a WriterSource which describes the source type of this wrapper + */ + WriterSource GetWriterType() const { return meWriterType; } + + /** Is this frame inline (as character) + + @return + whether this is inline or not + */ + bool IsInline() const; + + /** Get the first node of content in the frame + + @return + the first node of content in the frame, might not be any at all. + */ + const SwNode *GetContent() const { return mpStartFrameContent; } + + + /** Does this sw::Frame refer to the same writer content as another + + @return + if the two sw::Frames are handling the same writer frame + */ + bool RefersToSameFrameAs(const Frame &rOther) const + { + return (mpFlyFrm == rOther.mpFlyFrm); + } + + /** The Size of the contained element + + @return + the best size to use to export to word + */ + const Size GetSize() const { return maSize; } }; - /// STL container of Frames (FrmFmts) + /// STL container of Frames typedef std::vector Frames; /// STL iterator for Frames typedef std::vector::iterator FrameIter; @@ -513,10 +593,8 @@ Caolán McNamara */ bool HasPageBreak(const SwNode &rNode); - } - namespace hack - { + /** Make setting a drawing object's layer in a Writer document easy @@ -565,7 +643,10 @@ SetLayer(const SetLayer &rOther) throw(); SetLayer& operator=(const SetLayer &rOther) throw(); }; + } + namespace hack + { /** Make inserting an OLE object into a Writer document easy The rest of Office uses SdrOle2Obj for their OLE objects, Writer Index: wrtw8esh.cxx =================================================================== RCS file: /cvs/sw/sw/source/filter/ww8/wrtw8esh.cxx,v retrieving revision 1.66.22.1 diff -u -r1.66.22.1 wrtw8esh.cxx --- wrtw8esh.cxx 21 Oct 2003 15:42:52 -0000 1.66.22.1 +++ wrtw8esh.cxx 23 Oct 2003 14:03:38 -0000 @@ -826,6 +826,7 @@ void SwWW8Writer::AppendFlyInFlys(WW8_CP& rCP, const sw::Frame& rFrmFmt, const Point& rNdTopLeft) { + ASSERT(bWrtWW8, "this has gone horribly wrong"); ASSERT(!pEscher, "der EscherStream wurde schon geschrieben!"); if (pEscher) return ; @@ -835,7 +836,16 @@ else pDrwO = pSdrObjs; - if (pDrwO->Append( *this, rCP, rFrmFmt, rNdTopLeft)) + if (rFrmFmt.IsInline()) + { + OutField(0, ww::eSHAPE, FieldString(ww::eSHAPE), + WRITEFIELD_START | WRITEFIELD_CMD_START | WRITEFIELD_CMD_END); + } + + bool bSuccess = pDrwO->Append( *this, rCP, rFrmFmt, rNdTopLeft); + ASSERT(bSuccess, "Couldn't export a graphical element!"); + + if (bSuccess) { static BYTE __READONLY_DATA aSpec8[] = { 0x03, 0x6a, 0, 0, 0, 0, // sprmCObjLocation @@ -850,6 +860,11 @@ pChpPlc->AppendFkpEntry( Strm().Tell(), sizeof( aSpec8 ), aSpec8 ); const SwFrmFmt &rFmt = rFrmFmt.GetFrmFmt(); + + //Need dummy picture frame + if (rFrmFmt.IsInline()) + OutGrf(rFrmFmt); + if (RES_FLYFRMFMT == rFmt.Which()) { const SwNodeIndex* pNdIdx = rFmt.GetCntnt().GetCntntIdx(); @@ -866,6 +881,9 @@ } } } + + if (rFrmFmt.IsInline()) + OutField(0, ww::eSHAPE, aEmptyStr, WRITEFIELD_CLOSE); } class WW8_SdrAttrIter : public WW8_AttrIter @@ -1356,6 +1374,15 @@ GetStream() << 0x80000000; } +void SwBasicEscherEx::WriteEmptyFlyFrame(const SwFrmFmt& rFmt, UINT32 nShapeId) +{ + OpenContainer(ESCHER_SpContainer); + AddShape(ESCHER_ShpInst_PictureFrame, 0xa00, nShapeId); + // store anchor attribute + WriteFrmExtraData(rFmt); + CloseContainer(); // ESCHER_SpContainer +} + INT32 SwBasicEscherEx::WriteGrfFlyFrame(const SwFrmFmt& rFmt, UINT32 nShapeId) { INT32 nBorderThick=0; @@ -1969,11 +1996,11 @@ const SwFmtHoriOrient& rHoriOri = rFmt.GetHoriOrient(); const SwFmtVertOrient& rVertOri = rFmt.GetVertOrient(); - const SwHoriOrient eHOri = rHoriOri.GetHoriOrient(); - const SwVertOrient eVOri = rVertOri.GetVertOrient(); + SwHoriOrient eHOri = rHoriOri.GetHoriOrient(); + SwVertOrient eVOri = rVertOri.GetVertOrient(); - SwRelationOrient eHRel = rHoriOri.GetRelationOrient(); - SwRelationOrient eVRel = rVertOri.GetRelationOrient(); + SwRelationOrient eHRel = rHoriOri.GetRelationOrient(); + SwRelationOrient eVRel = rVertOri.GetRelationOrient(); //There must be a problem with page anchoring and draw objects in writer //must be a problem somewhere. @@ -2010,8 +2037,12 @@ nVIndex = 0x12000000; break; case FLY_IN_CNTNT: - nHIndex = 0x02000000; - nVIndex = 0x13000000; + nHIndex = 0x01000000; + nVIndex = 0x12000000; + eHRel = REL_CHAR; + eHOri = HORI_NONE; + eVRel = REL_CHAR; + eVOri = VERT_NONE; break; default: nHIndex = 0x01000000; // FLY_AT_CNTNT Index: wrtw8nds.cxx =================================================================== RCS file: /cvs/sw/sw/source/filter/ww8/wrtw8nds.cxx,v retrieving revision 1.55.22.2 diff -u -r1.55.22.2 wrtw8nds.cxx --- wrtw8nds.cxx 21 Oct 2003 16:11:51 -0000 1.55.22.2 +++ wrtw8nds.cxx 23 Oct 2003 14:03:38 -0000 @@ -1560,7 +1560,7 @@ SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; SwTxtNode* pNd = &((SwTxtNode&)rNode); - bool bFlyInTable = rWW8Wrt.pFlyFmt && rWW8Wrt.bIsInTable; + bool bFlyInTable = rWW8Wrt.mpParentFrame && rWW8Wrt.bIsInTable; // akt. Style if( !bFlyInTable ) @@ -1768,8 +1768,8 @@ pO->Insert( (BYTE*)&nSty, 2, pO->Count() ); // Style # - if( rWW8Wrt.pFlyFmt && !rWW8Wrt.bIsInTable ) // Fly-Attrs - rWW8Wrt.Out_SwFmt(*rWW8Wrt.pFlyFmt, false, false, true); + if (rWW8Wrt.mpParentFrame && !rWW8Wrt.bIsInTable) // Fly-Attrs + rWW8Wrt.Out_SwFmt(rWW8Wrt.mpParentFrame->GetFrmFmt(), false, false, true); if( rWW8Wrt.bOutTable ) { // Tab-Attr @@ -2059,7 +2059,9 @@ if (aRect.IsEmpty()) { // dann besorge mal die Seitenbreite ohne Raender !! - const SwFrmFmt* pParentFmt = rWW8Wrt.pFlyFmt ? rWW8Wrt.pFlyFmt : + const SwFrmFmt* pParentFmt = + rWW8Wrt.mpParentFrame ? + &(rWW8Wrt.mpParentFrame->GetFrmFmt()) : rWrt.pDoc->GetPageDesc(0).GetPageFmtOfNode(rNode, false); aRect = pParentFmt->FindLayoutRect(true); if (!(nPageSize = aRect.Width())) @@ -2570,6 +2572,8 @@ void SwWW8Writer::OutWW8FlyFrmsInCntnt( const SwTxtNode& rNd ) { + ASSERT(!bWrtWW8, "I shouldn't be needed for Word >=8"); + if (const SwpHints* pTxtAttrs = rNd.GetpSwpHints()) { for( USHORT n=0; n < pTxtAttrs->Count(); ++n ) @@ -2601,8 +2605,9 @@ // wird in Out_SwFmt() ausgewertet pFlyOffset = &aOffset; - pFlyFmt = (SwFlyFrmFmt*)&rFlyFrmFmt; - eNewAnchorType = pFlyFmt->GetAnchor().GetAnchorId(); + eNewAnchorType = rFlyFrmFmt.GetAnchor().GetAnchorId(); + sw::Frame aFrm(rFlyFrmFmt, SwPosition(rNd)); + mpParentFrame = &aFrm; // Ok, rausschreiben: WriteText(); } @@ -2618,31 +2623,39 @@ const SwFrmFmt &rFrmFmt = rFmt.GetFrmFmt(); const SwFmtAnchor& rAnch = rFrmFmt.GetAnchor(); + bool bUseInline = !bWrtWW8; + + if (bWrtWW8 && rFmt.IsInline()) + { + sw::Frame::WriterSource eType = rFmt.GetWriterType(); + if ((eType == sw::Frame::eGraphic) || (eType == sw::Frame::eOle)) + bUseInline = true; + else + bUseInline = false; + + /* + #110185# + A special case for converting some inline form controls to form fields + when in winword 8+ mode + */ + if ((bUseInline == false) && (eType == sw::Frame::eFormControl)) + { + if (MiserableFormFieldExportHack(rFrmFmt)) + return ; + } + + } + /* ##897## Note that something anchored as a character must be exported using the older WW6 mechanism */ - if (!bWrtWW8 || (FLY_IN_CNTNT == rAnch.GetAnchorId())) + if (bUseInline) { - if (RES_DRAWFRMFMT == rFrmFmt.Which()) - { - bool bComboBoxHack = false; - if (bWrtWW8 && (FLY_IN_CNTNT == rAnch.GetAnchorId())) //#110185# - bComboBoxHack = MiserableFormFieldExportHack(rFrmFmt); - ASSERT(bComboBoxHack , "OutWW8FlyFrm: DrawInCnt-Baustelle " ); - return ; - } - bool bDone = false; // Hole vom Node und vom letzten Node die Position in der Section - /* - const SwFmtCntnt& rFlyCntnt = rFrmFmt.GetCntnt(); - - ULONG nStt = rFlyCntnt.GetCntntIdx()->GetIndex()+1; - ULONG nEnd = pDoc->GetNodes()[ nStt - 1 ]->EndOfSectionIndex(); - */ const SwNodeIndex* pNodeIndex = rFrmFmt.GetCntnt().GetCntntIdx(); ULONG nStt = pNodeIndex ? pNodeIndex->GetIndex()+1 : 0; @@ -2651,11 +2664,10 @@ if( nStt >= nEnd ) // kein Bereich, also kein gueltiger Node return; - if( !bIsInTable && (FLY_IN_CNTNT == rAnch.GetAnchorId()) ) + if (!bIsInTable && rFmt.IsInline()) { - // ein zeichen(!)gebundener Rahmen liegt vor + //Test to see if this textbox contains only a single graphic/ole SwTxtNode* pParTxtNode = rAnch.GetCntntAnchor()->nNode.GetNode().GetTxtNode(); - if( pParTxtNode && !pDoc->GetNodes()[ nStt ]->IsNoTxtNode() ) bDone = true; } @@ -2671,7 +2683,7 @@ WW8SaveData aSaveData( *this, nStt, nEnd ); Point aOffset; - if( pFlyFmt ) + if (mpParentFrame) { /* #90804# @@ -2685,33 +2697,30 @@ eNewAnchorType = FLY_PAGE; } - pFlyFmt = (SwFlyFrmFmt*)&rFrmFmt; - if( pFlyFmt ) + mpParentFrame = &rFmt; + if ( + bIsInTable && (FLY_PAGE != rAnch.GetAnchorId()) && + !pDoc->GetNodes()[ nStt ]->IsNoTxtNode() + ) { - if( bIsInTable && (FLY_PAGE != rAnch.GetAnchorId()) && - !pDoc->GetNodes()[ nStt ]->IsNoTxtNode() ) - { - // Beachten: Flag bOutTable wieder setzen, - // denn wir geben ja ganz normalen Content der - // Tabelenzelle aus und keinen Rahmen - // (Flag wurde oben in aSaveData() geloescht) - bOutTable = true; - const String& rName = pFlyFmt->GetName(); - StartCommentOutput( rName ); - WriteText(); - EndCommentOutput( rName ); - } - else - WriteText(); + // Beachten: Flag bOutTable wieder setzen, + // denn wir geben ja ganz normalen Content der + // Tabelenzelle aus und keinen Rahmen + // (Flag wurde oben in aSaveData() geloescht) + bOutTable = true; + const String& rName = rFrmFmt.GetName(); + StartCommentOutput(rName); + WriteText(); + EndCommentOutput(rName); } else - ASSERT( !this, "+Fly-Ausgabe ohne FlyFmt" ); + WriteText(); } - // ASSERT( !pFlyFmt, " pFlyFmt ist hinter einem Rahmen nicht 0" ); } } else { + ASSERT(bWrtWW8, "this has gone horribly wrong"); // write as escher WW8_CP nCP = Fc2Cp( Strm().Tell() ); AppendFlyInFlys( nCP, rFmt, rNdTopLeft ); Index: wrtww8.cxx =================================================================== RCS file: /cvs/sw/sw/source/filter/ww8/wrtww8.cxx,v retrieving revision 1.58.2.1 diff -u -r1.58.2.1 wrtww8.cxx --- wrtww8.cxx 21 Oct 2003 15:42:54 -0000 1.58.2.1 +++ wrtww8.cxx 23 Oct 2003 14:03:39 -0000 @@ -1871,7 +1871,7 @@ WW8SaveData::WW8SaveData( SwWW8Writer& rWriter, ULONG nStt, ULONG nEnd ) : rWrt( rWriter ), pOldPam( rWrt.pCurPam ), pOldEnd( rWrt.GetEndPaM() ), - pOldFlyFmt( rWrt.pFlyFmt ), pOldPageDesc( rWrt.pAktPageDesc ) + pOldFlyFmt(rWrt.mpParentFrame), pOldPageDesc( rWrt.pAktPageDesc ) { pOldFlyOffset = rWrt.pFlyOffset; @@ -1920,7 +1920,7 @@ rWrt.bOutFlyFrmAttrs = bOldFlyFrmAttrs; rWrt.bStartTOX = bOldStartTOX; rWrt.bInWriteTOX = bOldInWriteTOX; - rWrt.pFlyFmt = pOldFlyFmt; + rWrt.mpParentFrame = pOldFlyFmt; rWrt.pAktPageDesc = pOldPageDesc; ASSERT( !rWrt.pO->Count(), " pO ist am Ende von WW8SaveData nicht leer" ); if( pOOld ) @@ -1946,8 +1946,9 @@ const SwTxtNode* pTxtNode = pNd->GetTxtNode(); if( pTxtNode->GetpSwAttrSet() ) Out_SfxBreakItems( *pTxtNode->GetpSwAttrSet(), *pTxtNode ); - if( !bIsInTable ) - OutWW8FlyFrmsInCntnt( *pTxtNode ); // als Zeichen gebundene Flys + // all textframes anchored as character for the winword 7- format + if (!bWrtWW8 && !bIsInTable) + OutWW8FlyFrmsInCntnt(*pTxtNode); } if( pNd->IsCntntNode() ) @@ -2212,7 +2213,7 @@ bFtnAtTxtEnd = bEndAtTxtEnd = true; - pFlyFmt = 0; + mpParentFrame = 0; pFlyOffset = 0; eNewAnchorType = FLY_PAGE; nTxtTyp = TXT_MAINTEXT; Index: wrtww8.hxx =================================================================== RCS file: /cvs/sw/sw/source/filter/ww8/wrtww8.hxx,v retrieving revision 1.52.22.1 diff -u -r1.52.22.1 wrtww8.hxx --- wrtww8.hxx 21 Oct 2003 15:42:54 -0000 1.52.22.1 +++ wrtww8.hxx 23 Oct 2003 14:03:39 -0000 @@ -186,8 +186,6 @@ class SvxBrushItem; #define WWFL_ULSPACE_LIKE_SWG 0x00000001 -#define WWFL_NO_GRAF 0x00000080 -#define WWFL_NO_OLE 0x00020000 #define GRF_MAGIC_1 0x12 // 3 magic Bytes fuer PicLocFc-Attribute #define GRF_MAGIC_2 0x34 @@ -485,8 +483,8 @@ WW8_WrPlcPostIt* pAtn; WW8_WrPlcTxtBoxes *pTxtBxs, *pHFTxtBxs; - SwFlyFrmFmt* pFlyFmt; // liegt der Node in einem FlyFrame, ist - // das Format gesetzt, sonst 0 + const sw::Frame *mpParentFrame; //If set we are exporting content inside + //a frame, e.g. a graphic node Point* pFlyOffset; // zur Justierung eines im Writer als RndStdIds eNewAnchorType; // Zeichen gebundenen Flys, der im WW @@ -589,7 +587,7 @@ const String& rFldCmd, BYTE nMode = WRITEFIELD_ALL); void StartCommentOutput( const String& rName ); void EndCommentOutput( const String& rName ); - void OutGrf( const SwNoTxtNode* pNd ); + void OutGrf(const sw::Frame &rFrame); bool TestOleNeedsGraphic(const SwAttrSet& rSet, SvStorageRef xOleStg, SvStorageRef xObjStg, String &rStorageName, SwOLENode *pOLENd); void AppendBookmarks( const SwTxtNode& rNd, xub_StrLen nAktPos, @@ -861,20 +859,20 @@ class GraphicDetails { public: - const SwNoTxtNode* mpNd; // Positionen der SwGrfNodes und SwOleNodes - const SwFlyFrmFmt* mpFly; // Umgebende FlyFrms dazu - ULONG mnPos; // FilePos der Grafiken - UINT16 mnWid; // Breite der Grafiken - UINT16 mnHei; // Hoehe der Grafiken - GraphicDetails(const SwNoTxtNode* pNd, const SwFlyFrmFmt* pFly, - UINT16 nWid, UINT16 nHei) - : mpNd(pNd), mpFly(pFly), mnPos(0), mnWid(nWid), mnHei(nHei) + const sw::Frame maFly; // Umgebende FlyFrms dazu + ULONG mnPos; // FilePos der Grafiken + UINT16 mnWid; // Breite der Grafiken + UINT16 mnHei; // Hoehe der Grafiken + GraphicDetails(const sw::Frame &rFly, UINT16 nWid, UINT16 nHei) + : maFly(rFly), mnPos(0), mnWid(nWid), mnHei(nHei) {} bool operator==(const GraphicDetails& rIn) const { - return - ((mpNd == rIn.mpNd) && (mnWid == rIn.mnWid) && (mnHei == rIn.mnHei)); + return ( + (mnWid == rIn.mnWid) && (mnHei == rIn.mnHei) && + (maFly.RefersToSameFrameAs(rIn.maFly)) + ); } }; @@ -887,19 +885,19 @@ typedef std::vector::iterator myiter; USHORT mnIdx; // Index in File-Positionen - void WritePICFHeader(SvStream& rStrm, const SwNoTxtNode* pNd, - const SwFlyFrmFmt* pFly, UINT16 mm, UINT16 nWidth, UINT16 nHeight); - void WriteGraphicNode(SvStream& rStrm, const SwNoTxtNode* pGrfNd, - const SwFlyFrmFmt* pFly, UINT16 nWidth, UINT16 nHeight); - void WriteGrfFromGrfNode(SvStream& rStrm, const SwGrfNode* pNd, - const SwFlyFrmFmt* pFly, UINT16 nWidth, UINT16 nHeight); + void WritePICFHeader(SvStream& rStrm, const sw::Frame &rFly, + UINT16 mm, UINT16 nWidth, UINT16 nHeight, + const SwAttrSet* pAttrSet = 0); + void WriteGraphicNode(SvStream& rStrm, const GraphicDetails &rItem); + void WriteGrfFromGrfNode(SvStream& rStrm, const SwGrfNode &rNd, + const sw::Frame &rFly, UINT16 nWidth, UINT16 nHeight); //No copying SwWW8WrGrf(const SwWW8WrGrf&); SwWW8WrGrf& operator=(const SwWW8WrGrf&); public: SwWW8WrGrf(SwWW8Writer& rW) : rWrt(rW), mnIdx(0) {} - void Insert(const SwNoTxtNode* pNd, const SwFlyFrmFmt* pFly); + void Insert(const sw::Frame &rFly); void Write(); ULONG GetFPos() { return (mnIdx < maDetails.size()) ? maDetails[mnIdx++].mnPos : 0; } @@ -969,7 +967,7 @@ RndStdIds eOldAnchorType; WW8Bytes* pOOld; SwPaM* pOldPam, *pOldEnd; - SwFlyFrmFmt* pOldFlyFmt; + const sw::Frame* pOldFlyFmt; const SwPageDesc* pOldPageDesc; BYTE bOldWriteAll : 1; Index: wrtww8gr.cxx =================================================================== RCS file: /cvs/sw/sw/source/filter/ww8/wrtww8gr.cxx,v retrieving revision 1.32 diff -u -r1.32 wrtww8gr.cxx --- wrtww8gr.cxx 25 Sep 2003 07:43:17 -0000 1.32 +++ wrtww8gr.cxx 23 Oct 2003 14:03:39 -0000 @@ -172,9 +172,12 @@ Writer& OutWW8_SwGrfNode( Writer& rWrt, SwCntntNode& rNode ) { SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; - rWW8Wrt.OutGrf( rNode.GetGrfNode() ); - - rWW8Wrt.pFib->fHasPic = 1; + ASSERT(rWW8Wrt.mpParentFrame, "frame not set!"); + if (rWW8Wrt.mpParentFrame) + { + rWW8Wrt.OutGrf(*rWW8Wrt.mpParentFrame); + rWW8Wrt.pFib->fHasPic = 1; + } return rWrt; } @@ -259,151 +262,138 @@ { using namespace ww; SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; - if( !(rWW8Wrt.GetIniFlags() & WWFL_NO_OLE ) ) + BYTE *pSpecOLE; + BYTE *pDataAdr; + short nSize; + static BYTE aSpecOLE_WW8[] = { + 0x03, 0x6a, 0, 0, 0, 0, // sprmCPicLocation + 0x0a, 0x08, 1, // sprmCFOLE2 + 0x56, 0x08, 1 // sprmCFObj + }; + static BYTE aSpecOLE_WW6[] = { + 68, 4, 0, 0, 0, 0, // sprmCPicLocation (len is 4) + 75, 1, // sprmCFOLE2 + 118, 1 // sprmCFObj + }; + + if( rWW8Wrt.bWrtWW8 ) { - BYTE *pSpecOLE; - BYTE *pDataAdr; - short nSize; - static BYTE aSpecOLE_WW8[] = { - 0x03, 0x6a, 0, 0, 0, 0, // sprmCPicLocation - 0x0a, 0x08, 1, // sprmCFOLE2 - 0x56, 0x08, 1 // sprmCFObj - }; - static BYTE aSpecOLE_WW6[] = { - 68, 4, 0, 0, 0, 0, // sprmCPicLocation (len is 4) - 75, 1, // sprmCFOLE2 - 118, 1 // sprmCFObj - }; + pSpecOLE = aSpecOLE_WW8; + nSize = sizeof( aSpecOLE_WW8 ); + } + else + { + pSpecOLE = aSpecOLE_WW6; + nSize = sizeof( aSpecOLE_WW6 ); + } + pDataAdr = pSpecOLE + 2; //WW6 sprm is 1 but has 1 byte len as well. + SwOLENode *pOLENd = rNode.GetOLENode(); - if( rWW8Wrt.bWrtWW8 ) - { - pSpecOLE = aSpecOLE_WW8; - nSize = sizeof( aSpecOLE_WW8 ); - } - else - { - pSpecOLE = aSpecOLE_WW6; - nSize = sizeof( aSpecOLE_WW6 ); - } - pDataAdr = pSpecOLE + 2; //WW6 sprm is 1 but has 1 byte len as well. - SwOLENode *pOLENd = rNode.GetOLENode(); + SvStorageRef xObjStg = rWW8Wrt.GetStorage().OpenStorage( + CREATE_CONST_ASC(SL::aObjectPool), STREAM_READWRITE | + STREAM_SHARE_DENYALL ); + + if( xObjStg.Is() ) + { + SvInPlaceObjectRef xObj(pOLENd->GetOLEObj().GetOleRef()); + if( xObj.Is() ) + { + SvInPlaceObject *pObj = &xObj; + UINT32 nPictureId = (UINT32)pObj; + Set_UInt32(pDataAdr, nPictureId); + + WW8OleMap *pMap = new WW8OleMap(nPictureId); + bool bDuplicate = false; + WW8OleMaps &rOleMap = rWW8Wrt.GetOLEMap(); + USHORT nPos; + if ( rOleMap.Seek_Entry(pMap, &nPos) ) + { + bDuplicate = true; + delete pMap; + } + else if( 0 == rOleMap.Insert( pMap) ) + delete pMap; - SvStorageRef xObjStg = rWW8Wrt.GetStorage().OpenStorage( - CREATE_CONST_ASC(SL::aObjectPool), STREAM_READWRITE | - STREAM_SHARE_DENYALL ); - - if( xObjStg.Is() ) - { - SvInPlaceObjectRef xObj(pOLENd->GetOLEObj().GetOleRef()); - if( xObj.Is() ) - { - SvInPlaceObject *pObj = &xObj; - UINT32 nPictureId = (UINT32)pObj; - Set_UInt32(pDataAdr, nPictureId); - - WW8OleMap *pMap = new WW8OleMap(nPictureId); - bool bDuplicate = false; - WW8OleMaps &rOleMap = rWW8Wrt.GetOLEMap(); - USHORT nPos; - if ( rOleMap.Seek_Entry(pMap, &nPos) ) - { - bDuplicate = true; - delete pMap; - } - else if( 0 == rOleMap.Insert( pMap) ) - delete pMap; + String sStorageName( '_' ); + sStorageName += String::CreateFromInt32( nPictureId ); + SvStorageRef xOleStg = xObjStg->OpenStorage( sStorageName, + STREAM_READWRITE| STREAM_SHARE_DENYALL ); + if( xOleStg.Is() ) + { + /* + If this object storage has been written already don't + waste time rewriting it + */ + if (!bDuplicate) + rWW8Wrt.GetOLEExp().ExportOLEObject(*pObj, *xOleStg); + + // write as embedded field - the other things will be done + // in the escher export + String sServer(FieldString(eEMBED)); + sServer += xOleStg->GetUserName(); + sServer += ' '; + + rWW8Wrt.OutField(0, eEMBED, sServer, WRITEFIELD_START | + WRITEFIELD_CMD_START | WRITEFIELD_CMD_END); + + rWW8Wrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(), + nSize, pSpecOLE ); + + bool bEndCR = true; + /* + In the word filter we only need a preview image for + floating images, and then only (the usual case) if the + object doesn't contain enough information to reconstruct + what we need. + + We don't need a graphic for inline objects, so we don't + even need the overhead of a graphic in that case. + */ + bool bGraphicNeeded = false; - String sStorageName( '_' ); - sStorageName += String::CreateFromInt32( nPictureId ); - SvStorageRef xOleStg = xObjStg->OpenStorage( sStorageName, - STREAM_READWRITE| STREAM_SHARE_DENYALL ); - if( xOleStg.Is() ) + if (rWW8Wrt.mpParentFrame) { - /* - If this object storage has been written already don't - waste time rewriting it - */ - if (!bDuplicate) - rWW8Wrt.GetOLEExp().ExportOLEObject(*pObj, *xOleStg); - - // write as embedded field - the other things will be done - // in the escher export - String sServer(FieldString(eEMBED)); - sServer += xOleStg->GetUserName(); - sServer += ' '; - - rWW8Wrt.OutField(0, eEMBED, sServer, WRITEFIELD_START | - WRITEFIELD_CMD_START | WRITEFIELD_CMD_END); + bGraphicNeeded = true; - rWW8Wrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(), - nSize, pSpecOLE ); - - bool bEndCR = true; - /* - In the word filter we only need a preview image for - floating images, and then only (the usual case) if the - object doesn't contain enough information to reconstruct - what we need. - - We don't need a graphic for inline objects, so we don't - even need the overhead of a graphic in that case. - */ - bool bGraphicNeeded = false; - - if (rWW8Wrt.pFlyFmt) + if (rWW8Wrt.mpParentFrame->IsInline()) { - bGraphicNeeded = true; - - const SwAttrSet& rSet = rWW8Wrt.pFlyFmt->GetAttrSet(); - if (rSet.GetAnchor(false).GetAnchorId() == FLY_IN_CNTNT) - { - bEndCR = false; - bGraphicNeeded = rWW8Wrt.TestOleNeedsGraphic(rSet, - xOleStg, xObjStg, sStorageName, pOLENd); - } + const SwAttrSet& rSet = + rWW8Wrt.mpParentFrame->GetFrmFmt().GetAttrSet(); + bEndCR = false; + bGraphicNeeded = rWW8Wrt.TestOleNeedsGraphic(rSet, + xOleStg, xObjStg, sStorageName, pOLENd); } + } - if (!bGraphicNeeded) - rWW8Wrt.WriteChar(0x1); - else - { - /* - ##897## - We need to insert the graphic representation of - this object for the inline case, otherwise word - has no place to find the dimensions of the ole - object, and will not be able to draw it - */ - rWW8Wrt.OutGrf(rNode.GetOLENode()); - } + if (!bGraphicNeeded) + rWW8Wrt.WriteChar(0x1); + else + { + /* + ##897## + We need to insert the graphic representation of + this object for the inline case, otherwise word + has no place to find the dimensions of the ole + object, and will not be able to draw it + */ + rWW8Wrt.OutGrf(*rWW8Wrt.mpParentFrame); + } - rWW8Wrt.OutField(0, eEMBED, aEmptyStr, - WRITEFIELD_END | WRITEFIELD_CLOSE); + rWW8Wrt.OutField(0, eEMBED, aEmptyStr, + WRITEFIELD_END | WRITEFIELD_CLOSE); - if (bEndCR) //No newline in inline case - rWW8Wrt.WriteCR(); - } + if (bEndCR) //No newline in inline case + rWW8Wrt.WriteCR(); } } - else //Only for the case that ole objects are not to be exported - rWW8Wrt.OutGrf( rNode.GetOLENode() ); } return rWrt; } -void SwWW8Writer::OutGrf( const SwNoTxtNode* pNd ) +void SwWW8Writer::OutGrf(const sw::Frame &rFrame) { - if( nIniFlags & WWFL_NO_GRAF ) - return; // Iniflags: kein Grafik-Export - - if( !pFlyFmt ) // Grafik mit eigenem Frame ( eigentlich immer ) - { - ASSERT( !this, "+Grafik ohne umgebenden Fly" ); - return ; - } - // GrfNode fuer spaeteres rausschreiben der Grafik merken - pGrf->Insert( pNd, pFlyFmt ); + pGrf->Insert(rFrame); pChpPlc->AppendFkpEntry( pStrm->Tell(), pO->Count(), pO->GetData() ); pO->Remove( 0, pO->Count() ); // leeren @@ -413,10 +403,11 @@ BYTE aArr[ 18 ]; BYTE* pArr = aArr; - RndStdIds eAn = pFlyFmt->GetAttrSet().GetAnchor(false).GetAnchorId(); + const SwFrmFmt &rFlyFmt = rFrame.GetFrmFmt(); + RndStdIds eAn = rFlyFmt.GetAttrSet().GetAnchor(false).GetAnchorId(); if( eAn == FLY_IN_CNTNT ) { - SwVertOrient eVert = pFlyFmt->GetVertOrient().GetVertOrient(); + SwVertOrient eVert = rFlyFmt.GetVertOrient().GetVertOrient(); if ((eVert == VERT_CHAR_CENTER) || (eVert == VERT_LINE_CENTER)) { bool bVert = false; @@ -430,7 +421,7 @@ } if (!bVert) { - SwTwips nHeight = pFlyFmt->GetFrmSize().GetHeight(); + SwTwips nHeight = rFlyFmt.GetFrmSize().GetHeight(); nHeight/=20; //nHeight was in twips, want it in half points, but //then half of total height. long nFontHeight = ((const SvxFontHeightItem&) @@ -480,7 +471,7 @@ bool bOldGrf = bOutGrf; bOutGrf = true; - Out_SwFmt(*pFlyFmt, false, false, true); // Fly-Attrs + Out_SwFmt(rFrame.GetFrmFmt(), false, false, true); // Fly-Attrs bOutGrf = bOldGrf; pPapPlc->AppendFkpEntry( pStrm->Tell(), pO->Count(), pO->GetData() ); @@ -488,52 +479,34 @@ } } -static Size lcl_GetSwappedInSize(const SwNoTxtNode& rNd) +void SwWW8WrGrf::Insert(const sw::Frame &rFly) { - Size aGrTwipSz(rNd.GetTwipSize()); - //JP 05.12.98: falls die Grafik noch nie angezeigt wurde und es sich - // um eine gelinkte handelt, so ist keine Size gesetzt. In - // diesem Fall sollte man sie mal reinswappen. - if ( - (!aGrTwipSz.Width() || !aGrTwipSz.Height()) && - rNd.IsGrfNode() && - GRAPHIC_NONE != ((const SwGrfNode&)rNd).GetGrf().GetType() - ) - { - ((SwGrfNode&)rNd).SwapIn(); - aGrTwipSz = rNd.GetTwipSize(); - } - - return aGrTwipSz; -} + const SwNoTxtNode *pNd = + rFly.GetContent() ? rFly.GetContent()->GetNoTxtNode() : 0; -void SwWW8WrGrf::Insert( const SwNoTxtNode* pNd, const SwFlyFrmFmt* pFly ) -{ UINT16 nWidth; UINT16 nHeight; - if( rWrt.nFlyWidth > 0 && rWrt.nFlyHeight > 0 ) + if (rWrt.nFlyWidth > 0 && rWrt.nFlyHeight > 0) { - nWidth = (UINT16)rWrt.nFlyWidth; - nHeight = (UINT16)rWrt.nFlyHeight; + nWidth = rWrt.nFlyWidth; + nHeight = rWrt.nFlyHeight; } - else if (pNd) - { - Size aGrTwipSz(lcl_GetSwappedInSize(*pNd)); - nWidth = (UINT16)aGrTwipSz.Width(); - nHeight = (UINT16)aGrTwipSz.Height(); + else + { + Size aSize(rFly.GetSize()); + nWidth = aSize.Width(); + nHeight = aSize.Height(); } - - maDetails.push_back(GraphicDetails(pNd, pFly, nWidth, nHeight)); + maDetails.push_back(GraphicDetails(rFly, nWidth, nHeight)); } -void SwWW8WrGrf::WritePICFHeader(SvStream& rStrm, const SwNoTxtNode* pNd, - const SwFlyFrmFmt* pFly, UINT16 mm, UINT16 nWidth, UINT16 nHeight) +void SwWW8WrGrf::WritePICFHeader(SvStream& rStrm, const sw::Frame &rFly, + UINT16 mm, UINT16 nWidth, UINT16 nHeight, const SwAttrSet* pAttrSet) { INT16 nXSizeAdd = 0, nYSizeAdd = 0; INT16 nCropL = 0, nCropR = 0, nCropT = 0, nCropB = 0; // Crop-AttributInhalt in Header schreiben ( falls vorhanden ) - const SwAttrSet* pAttrSet = pNd->GetpSwAttrSet(); const SfxPoolItem* pItem; if (pAttrSet && (SFX_ITEM_ON == pAttrSet->GetItemState(RES_GRFATR_CROPGRF, false, &pItem))) @@ -547,69 +520,67 @@ nYSizeAdd -= (INT16)( rCr.GetTop() + rCr.GetBottom() ); } - Size aGrTwipSz(lcl_GetSwappedInSize(*pNd)); + Size aGrTwipSz(rFly.GetSize()); bool bWrtWW8 = rWrt.bWrtWW8; UINT16 nHdrLen = bWrtWW8 ? 0x44 : 0x3A; BYTE aArr[ 0x44 ] = { 0 }; BYTE* pArr = aArr + 0x2E; //Do borders first - if( pFly ) + + const SwAttrSet& rAttrSet = rFly.GetFrmFmt().GetAttrSet(); + if (SFX_ITEM_ON == rAttrSet.GetItemState(RES_BOX, false, &pItem)) { - const SwAttrSet& rAttrSet = pFly->GetAttrSet(); - if (SFX_ITEM_ON == rAttrSet.GetItemState(RES_BOX, false, &pItem)) + const SvxBoxItem* pBox = (const SvxBoxItem*)pItem; + if( pBox ) { - const SvxBoxItem* pBox = (const SvxBoxItem*)pItem; - if( pBox ) + bool bShadow = false; // Shadow ? + const SvxShadowItem* pSI = + sw::util::HasItem(rAttrSet, RES_SHADOW); + if (pSI) { - bool bShadow = false; // Shadow ? - const SvxShadowItem* pSI = - sw::util::HasItem(rAttrSet, RES_SHADOW); - if (pSI) + bShadow = (pSI->GetLocation() != SVX_SHADOW_NONE) && + (pSI->GetWidth() != 0); + } + + BYTE aLnArr[4] = { BOX_LINE_TOP, BOX_LINE_LEFT, + BOX_LINE_BOTTOM, BOX_LINE_RIGHT }; + for( BYTE i = 0; i < 4; ++i ) + { + const SvxBorderLine* pLn = pBox->GetLine( aLnArr[ i ] ); + WW8_BRC aBrc; + if (pLn) { - bShadow = (pSI->GetLocation() != SVX_SHADOW_NONE) && - (pSI->GetWidth() != 0); + aBrc = rWrt.TranslateBorderLine( *pLn, + pBox->GetDistance( aLnArr[ i ] ), bShadow ); } - BYTE aLnArr[4] = { BOX_LINE_TOP, BOX_LINE_LEFT, - BOX_LINE_BOTTOM, BOX_LINE_RIGHT }; - for( BYTE i = 0; i < 4; ++i ) + //use importer logic to determine how large the exported + //border will really be in word and adjust accordingly + short nSpacing; + short nThick = aBrc.DetermineBorderProperties(!bWrtWW8, + &nSpacing); + switch (aLnArr[ i ]) { - const SvxBorderLine* pLn = pBox->GetLine( aLnArr[ i ] ); - WW8_BRC aBrc; - if (pLn) - { - aBrc = rWrt.TranslateBorderLine( *pLn, - pBox->GetDistance( aLnArr[ i ] ), bShadow ); - } + case BOX_LINE_TOP: + case BOX_LINE_BOTTOM: + nHeight -= bShadow ? nThick*2 : nThick; + nHeight -= nSpacing; + break; + case BOX_LINE_LEFT: + case BOX_LINE_RIGHT: + default: + nWidth -= bShadow ? nThick*2 : nThick; + nWidth -= nSpacing; + break; + } + memcpy( pArr, &aBrc.aBits1, 2); + pArr+=2; - //use importer logic to determine how large the exported - //border will really be in word and adjust accordingly - short nSpacing; - short nThick = aBrc.DetermineBorderProperties(!bWrtWW8, - &nSpacing); - switch (aLnArr[ i ]) - { - case BOX_LINE_TOP: - case BOX_LINE_BOTTOM: - nHeight -= bShadow ? nThick*2 : nThick; - nHeight -= nSpacing; - break; - case BOX_LINE_LEFT: - case BOX_LINE_RIGHT: - default: - nWidth -= bShadow ? nThick*2 : nThick; - nWidth -= nSpacing; - break; - } - memcpy( pArr, &aBrc.aBits1, 2); + if( bWrtWW8 ) + { + memcpy( pArr, &aBrc.aBits2, 2); pArr+=2; - - if( bWrtWW8 ) - { - memcpy( pArr, &aBrc.aBits2, 2); - pArr+=2; - } } } } @@ -662,14 +633,14 @@ rStrm.Write( aArr, nHdrLen ); } -void SwWW8WrGrf::WriteGrfFromGrfNode(SvStream& rStrm, const SwGrfNode* pGrfNd, - const SwFlyFrmFmt* pFly, UINT16 nWidth, UINT16 nHeight) +void SwWW8WrGrf::WriteGrfFromGrfNode(SvStream& rStrm, const SwGrfNode &rGrfNd, + const sw::Frame &rFly, UINT16 nWidth, UINT16 nHeight) { - if (pGrfNd->IsLinkedFile()) // Linked File + if (rGrfNd.IsLinkedFile()) // Linked File { String aFileN, aFiltN; UINT16 mm; - pGrfNd->GetFileFilterNms( &aFileN, &aFiltN ); + rGrfNd.GetFileFilterNms( &aFileN, &aFiltN ); aFileN = INetURLObject::AbsToRel( aFileN, INetURLObject::WAS_ENCODED, INetURLObject::DECODE_UNAMBIGUOUS); @@ -686,25 +657,28 @@ // else mm = 94; // 94 = BMP, GIF - WritePICFHeader(rStrm, pGrfNd, pFly, mm, nWidth, nHeight); // Header + WritePICFHeader(rStrm, rFly, mm, nWidth, nHeight, + rGrfNd.GetpSwAttrSet()); rStrm << (BYTE)aFileN.Len(); // Pascal-String schreiben SwWW8Writer::WriteString8(rStrm, aFileN, false, RTL_TEXTENCODING_MS_1252); } else // Embedded File oder DDE oder so was { - if (rWrt.bWrtWW8 && pFly) + if (rWrt.bWrtWW8) { - WritePICFHeader(rStrm, pGrfNd, pFly, 0x64, nWidth, nHeight); + WritePICFHeader(rStrm, rFly, 0x64, nWidth, nHeight, + rGrfNd.GetpSwAttrSet()); SwBasicEscherEx aInlineEscher(&rStrm, rWrt); - aInlineEscher.WriteGrfFlyFrame(*pFly, 0x401); + aInlineEscher.WriteGrfFlyFrame(rFly.GetFrmFmt(), 0x401); aInlineEscher.WritePictures(); } else { - Graphic& rGrf = (Graphic&)(pGrfNd->GetGrf()); + Graphic& rGrf = const_cast(rGrfNd.GetGrf()); bool bSwapped = rGrf.IsSwapOut() ? true : false; - ((SwGrfNode*)pGrfNd)->SwapIn(); // immer ueber den Node einswappen! + // immer ueber den Node einswappen! + const_cast(rGrfNd).SwapIn(); GDIMetaFile aMeta; switch (rGrf.GetType()) @@ -727,7 +701,8 @@ return; } - WritePICFHeader(rStrm, pGrfNd, pFly, 8, nWidth, nHeight); + WritePICFHeader(rStrm, rFly, 8, nWidth, nHeight, + rGrfNd.GetpSwAttrSet()); WriteWindowMetafileBits(rStrm, aMeta); if (bSwapped) @@ -736,23 +711,63 @@ } } -void SwWW8WrGrf::WriteGraphicNode(SvStream& rStrm, const SwNoTxtNode* pNd, - const SwFlyFrmFmt* pFly, UINT16 nWidth, UINT16 nHeight) +void SwWW8WrGrf::WriteGraphicNode(SvStream& rStrm, const GraphicDetails &rItem) { - if (!pNd || (!pNd->IsGrfNode() && !pNd->IsOLENode())) - return; - + UINT16 nWidth = rItem.mnWid; + UINT16 nHeight = rItem.mnHei; UINT32 nPos = rStrm.Tell(); // Grafik-Anfang merken - if (pNd->IsGrfNode()) - WriteGrfFromGrfNode(rStrm, pNd->GetGrfNode(), pFly, nWidth, nHeight); - else if (pNd->IsOLENode()) + const sw::Frame &rFly = rItem.maFly; + switch (rFly.GetWriterType()) { -#ifdef OLE_PREVIEW_AS_EMF - if (!rWrt.bWrtWW8) + case sw::Frame::eGraphic: { + const SwNode *pNode = rItem.maFly.GetContent(); + const SwGrfNode *pNd = pNode ? pNode->GetGrfNode() : 0; + ASSERT(pNd, "Impossible"); + if (pNd) + WriteGrfFromGrfNode(rStrm, *pNd, rItem.maFly, nWidth, nHeight); + } + break; + case sw::Frame::eOle: + { +#ifdef OLE_PREVIEW_AS_EMF + const SwNode *pNode = rItem.maFly.GetContent(); + const SwOLENode *pNd = pNode ? pNode->GetOLENode() : 0; + ASSERT(pNd, "Impossible"); + if (!rWrt.bWrtWW8) + { + SwOLENode *pOleNd = const_cast(pNd); + ASSERT( pOleNd, " Wer hat den OleNode versteckt ?" ); + SwOLEObj& rSObj= pOleNd->GetOLEObj(); + const SvInPlaceObjectRef rObj( rSObj.GetOleRef() ); + + GDIMetaFile aMtf; + rObj->GetGDIMetaFile(aMtf); + + aMtf.WindStart(); + aMtf.Play(Application::GetDefaultDevice(), Point(0, 0), + Size(2880, 2880)); + + WritePICFHeader(rStrm, rFly, 8, nWidth, nHeight, + pNd->GetpSwAttrSet()); + WriteWindowMetafileBits(rStrm, aMtf); + } + else + { + //Convert this ole2 preview in ww8+ to an EMF for better unicode + //support (note that at this moment this breaks StarSymbol + //using graphics because I need to embed starsymbol in exported + //documents. + WritePICFHeader(rStrm, rFly, 0x64, nWidth, nHeight, + pNd->GetpSwAttrSet()); + SwBasicEscherEx aInlineEscher(&rStrm, rWrt); + aInlineEscher.WriteOLEFlyFrame(rFly.GetFrmFmt(), 0x401); + aInlineEscher.WritePictures(); + } +#else // cast away const - SwOLENode *pOleNd = ((SwNoTxtNode*)pNd)->GetOLENode(); + SwOLENode *pOleNd = const_cast(pNd); ASSERT( pOleNd, " Wer hat den OleNode versteckt ?" ); SwOLEObj& rSObj= pOleNd->GetOLEObj(); const SvInPlaceObjectRef rObj( rSObj.GetOleRef() ); @@ -760,42 +775,39 @@ GDIMetaFile aMtf; rObj->GetGDIMetaFile(aMtf); + Size aS(aMtf.GetPrefSize()); aMtf.WindStart(); aMtf.Play(Application::GetDefaultDevice(), Point(0, 0), Size(2880, 2880)); - - WritePICFHeader(rStrm, pNd, pFly, 8, nWidth, nHeight); // Header - WriteWindowMetafileBits(rStrm, aMtf); - } - else - { - //Convert this ole2 preview in ww8+ to an EMF for better unicode - //support (note that at this moment this breaks StarSymbol - //using graphics because I need to embed starsymbol in exported - //documents. - WritePICFHeader(rStrm, pNd, pFly, 0x64, nWidth, nHeight); - SwBasicEscherEx aInlineEscher(&rStrm, rWrt); - aInlineEscher.WriteOLEFlyFrame(*pFly, 0x401); - aInlineEscher.WritePictures(); - } -#else - // cast away const - SwOLENode *pOleNd = ((SwNoTxtNode*)pNd)->GetOLENode(); - ASSERT( pOleNd, " Wer hat den OleNode versteckt ?" ); - SwOLEObj& rSObj= pOleNd->GetOLEObj(); - const SvInPlaceObjectRef rObj( rSObj.GetOleRef() ); - - GDIMetaFile aMtf; - rObj->GetGDIMetaFile(aMtf); - - Size aS(aMtf.GetPrefSize()); - aMtf.WindStart(); - aMtf.Play(Application::GetDefaultDevice(), Point(0, 0), - Size(2880, 2880)); - WritePICFHeader( rStrm, pNd, pFly, 8, nWidth, nHeight ); // Header - WriteWindowMetafileBits( rStrm, aMtf ); // eigentliche Grafik + WritePICFHeader(rStrm, rFly, 8, nWidth, nHeight, + pNd->GetpSwAttrSet()); + WriteWindowMetafileBits(rStrm, aMtf); #endif + } + break; + case sw::Frame::eDrawing: + case sw::Frame::eTxtBox: + ASSERT(rWrt.bWrtWW8, + "You can't try and export these in WW8 format, a filter bug"); + /* + #i3958# We only export an empty dummy picture frame here, this is + what word does the escher export should contain an anchored to + character element which is drawn over this dummy and the whole + shebang surrounded with a SHAPE field. This isn't *my* hack :-), + its what word does. + */ + if (rWrt.bWrtWW8) + { + WritePICFHeader(rStrm, rFly, 0x64, nWidth, nHeight); + SwBasicEscherEx aInlineEscher(&rStrm, rWrt); + aInlineEscher.WriteEmptyFlyFrame(rFly.GetFrmFmt(), 0x401); + } + break; + default: + ASSERT(!this, + "Some inline export not implemented, remind cmc before we ship :-)"); + break; } UINT32 nPos2 = rStrm.Tell(); // Ende merken @@ -819,8 +831,6 @@ myiter aEnd = maDetails.end(); for (myiter aIter = maDetails.begin(); aIter != aEnd; ++aIter) { - const SwNoTxtNode* pNd = aIter->mpNd; - UINT32 nPos = rStrm.Tell(); // auf 4 Bytes alignen if( nPos & 0x3 ) SwWW8Writer::FillCount( rStrm, 4 - ( nPos & 0x3 ) ); @@ -839,8 +849,7 @@ if (!bDuplicated) { aIter->mnPos = rStrm.Tell(); - WriteGraphicNode(rStrm, pNd, aIter->mpFly, aIter->mnWid, - aIter->mnHei); + WriteGraphicNode(rStrm, *aIter); } } } Index: ww8atr.cxx =================================================================== RCS file: /cvs/sw/sw/source/filter/ww8/ww8atr.cxx,v retrieving revision 1.68.22.2 diff -u -r1.68.22.2 ww8atr.cxx --- ww8atr.cxx 21 Oct 2003 15:42:54 -0000 1.68.22.2 +++ ww8atr.cxx 23 Oct 2003 14:03:40 -0000 @@ -774,33 +774,40 @@ case RES_CHRFMT: break; case RES_FLYFRMFMT: - if( bFlyFmt ) + if (bFlyFmt) { - SfxItemSet aSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN, - RES_FRMATR_END-1 ); - aSet.Set( pFlyFmt->GetAttrSet() ); + ASSERT(mpParentFrame, "No parent frame, all broken"); - // Fly als Zeichen werden bei uns zu Absatz-gebundenen - // jetzt den Abstand vom Absatz-Rand setzen - if( pFlyOffset ) + if (mpParentFrame) { - aSet.Put( SwFmtVertOrient( pFlyOffset->Y() )); - aSet.Put( SwFmtHoriOrient( pFlyOffset->X() )); - SwFmtAnchor aAnchor(pFlyFmt->GetAnchor()); - aAnchor.SetType(eNewAnchorType); - aSet.Put( aAnchor ); - } + const SwFrmFmt &rFmt = mpParentFrame->GetFrmFmt(); + + SfxItemSet aSet(pDoc->GetAttrPool(), RES_FRMATR_BEGIN, + RES_FRMATR_END-1); + aSet.Set(rFmt.GetAttrSet()); + + // Fly als Zeichen werden bei uns zu Absatz-gebundenen + // jetzt den Abstand vom Absatz-Rand setzen + if (pFlyOffset) + { + aSet.Put(SwFmtHoriOrient(pFlyOffset->X())); + aSet.Put(SwFmtVertOrient(pFlyOffset->Y())); + SwFmtAnchor aAnchor(rFmt.GetAnchor()); + aAnchor.SetType(eNewAnchorType); + aSet.Put(aAnchor); + } - if( SFX_ITEM_SET != aSet.GetItemState( RES_SURROUND )) - aSet.Put( SwFmtSurround( SURROUND_NONE ) ); + if (SFX_ITEM_SET != aSet.GetItemState(RES_SURROUND)) + aSet.Put(SwFmtSurround(SURROUND_NONE)); - bOutFlyFrmAttrs = true; - //script doesn't matter if not exporting chp - Out_SfxItemSet(aSet, true, false, - com::sun::star::i18n::ScriptType::LATIN); - bOutFlyFrmAttrs = false; + bOutFlyFrmAttrs = true; + //script doesn't matter if not exporting chp + Out_SfxItemSet(aSet, true, false, + com::sun::star::i18n::ScriptType::LATIN); + bOutFlyFrmAttrs = false; - bCallOutSet = false; + bCallOutSet = false; + } } break; default: @@ -3110,7 +3117,7 @@ break; } } - else if( !rWW8Wrt.pFlyFmt ) + else if (!rWW8Wrt.mpParentFrame) { BYTE nC = 0; bool bBefore = false; @@ -3506,9 +3513,9 @@ Writer& OutWW8_SwFmtHoriOrient( Writer& rWrt, const SfxPoolItem& rHt ) { SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; - if( !rWW8Wrt.pFlyFmt ) + if (!rWW8Wrt.mpParentFrame) { - ASSERT( rWW8Wrt.pFlyFmt, "HoriOrient ohne pFlyFmt !!" ); + ASSERT(rWW8Wrt.mpParentFrame, "HoriOrient without mpParentFrame !!"); return rWrt; } @@ -3524,15 +3531,6 @@ nPos = (short)rFlyHori.GetPos(); if( !nPos ) nPos = 1; // WW: 0 ist reserviert -#if 0 -// ist nicht noetig, da Bindung an Absatz als hor. Bindung an die -// Spalte exportiert wird, da so das Verhalten bei Mehrspaltigkeit -// am AEhnlichsten ist. - RndStdIds eAn = rWW8Wrt.pFlyFmt->GetAttrSet(). - GetAnchor().GetAnchorId(); - if( eAn == FLY_AT_CNTNT || eAn == FLY_IN_CNTNT ) - nPos += GetPageL( rWW8Wrt ); -#endif } break; @@ -3558,7 +3556,7 @@ static Writer& OutWW8_SwFmtAnchor( Writer& rWrt, const SfxPoolItem& rHt ) { SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; - ASSERT( rWW8Wrt.pFlyFmt, "Anker ohne pFlyFmt !!" ); + ASSERT(rWW8Wrt.mpParentFrame, "Anchor without mpParentFrame !!"); if( rWW8Wrt.bOutFlyFrmAttrs ) { Index: ww8graf.cxx =================================================================== RCS file: /cvs/sw/sw/source/filter/ww8/ww8graf.cxx,v retrieving revision 1.106 diff -u -r1.106 ww8graf.cxx --- ww8graf.cxx 25 Sep 2003 07:44:06 -0000 1.106 +++ ww8graf.cxx 23 Oct 2003 14:03:40 -0000 @@ -2716,7 +2716,7 @@ if (!bDone) { - sw::hack::SetLayer aSetLayer(rDoc); + sw::util::SetLayer aSetLayer(rDoc); if (pF->bBelowText || pRecord->bDrawHell) aSetLayer.SendObjectToHell(*pObject); else @@ -3092,7 +3092,7 @@ ASSERT(pDrawModel, "Kann DrawModel nicht anlegen"); pDrawPg = pDrawModel->GetPage(0); - pWWZOrder = new wwZOrderer(sw::hack::SetLayer(rDoc), pDrawPg, + pWWZOrder = new wwZOrderer(sw::util::SetLayer(rDoc), pDrawPg, pMSDffManager ? pMSDffManager->GetShapeOrders() : 0); } Index: ww8graf.hxx =================================================================== RCS file: /cvs/sw/sw/source/filter/ww8/ww8graf.hxx,v retrieving revision 1.13 diff -u -r1.13 ww8graf.hxx --- ww8graf.hxx 1 Sep 2003 12:42:37 -0000 1.13 +++ ww8graf.hxx 23 Oct 2003 14:03:40 -0000 @@ -95,7 +95,7 @@ std::stack maIndexes; - sw::hack::SetLayer maSetLayer; + sw::util::SetLayer maSetLayer; ULONG mnNoInitialObjects; ULONG mnInlines; @@ -108,7 +108,7 @@ ULONG GetDrawingObjectPos(short nWwHeight); bool InsertObject(SdrObject *pObject, ULONG nPos); public: - wwZOrderer(const sw::hack::SetLayer &rSetLayer, SdrPage* pDrawPg, + wwZOrderer(const sw::util::SetLayer &rSetLayer, SdrPage* pDrawPg, const SvxMSDffShapeOrders *pShapeOrders); void InsertTextLayerObject(SdrObject* pObject); /* Index: ww8graf2.cxx =================================================================== RCS file: /cvs/sw/sw/source/filter/ww8/ww8graf2.cxx,v retrieving revision 1.51.24.1 diff -u -r1.51.24.1 ww8graf2.cxx --- ww8graf2.cxx 22 Oct 2003 08:26:17 -0000 1.51.24.1 +++ ww8graf2.cxx 23 Oct 2003 14:03:40 -0000 @@ -168,7 +168,7 @@ #include "ww8graf.hxx" #endif -wwZOrderer::wwZOrderer(const sw::hack::SetLayer &rSetLayer, SdrPage* pDrawPg, +wwZOrderer::wwZOrderer(const sw::util::SetLayer &rSetLayer, SdrPage* pDrawPg, const SvxMSDffShapeOrders *pShapeOrders) : maSetLayer(rSetLayer), mnInlines(0), mpDrawPg(pDrawPg), mpShapeOrders(pShapeOrders)