LibreOffice Module sw (master) 1
ww8graf2.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <iterator>
21#include <numeric>
22#include <hintids.hxx>
23#include <svl/urihelper.hxx>
24#include <svx/svdpage.hxx>
25#include <svx/svdograf.hxx>
26#include <svx/svdoole2.hxx>
28#include <grfatr.hxx>
29#include <fmtanchr.hxx>
30#include <fmtcntnt.hxx>
31#include <frmfmt.hxx>
32#include <pam.hxx>
33#include <doc.hxx>
35#include <mdiexp.hxx>
36#include "writerwordglue.hxx"
37#include "ww8struc.hxx"
38#include "ww8scan.hxx"
39#include "ww8par.hxx"
40#include "ww8par2.hxx"
41#include "ww8graf.hxx"
42#include <vcl/gdimtf.hxx>
43#include <vcl/graphicfilter.hxx>
44#include <vcl/wmf.hxx>
45
46using namespace ::com::sun::star;
47using namespace sw::types;
48
50 const SvxMSDffShapeOrders *pShapeOrders)
51 : maSetLayer(rSetLayer), mnInlines(0), mpDrawPg(pDrawPg),
52 mpShapeOrders(pShapeOrders)
53{
55 OSL_ENSURE(mpDrawPg,"Missing draw page impossible!");
56}
57
59{
60 maIndexes.push(GetEscherObjectIdx(nSpId));
61}
62
64{
65 maIndexes.pop();
66}
67
68// consider new parameter <_bInHeaderFooter>
70 sal_uLong nSpId,
71 const bool bInHellLayer,
72 const bool _bInHeaderFooter )
73{
74 sal_uLong nInsertPos = GetEscherObjectPos( nSpId, bInHellLayer, _bInHeaderFooter );
76}
77
79{
80 return std::find_if(maEscherLayer.begin(), maEscherLayer.end(),
81 [nIdx](const EscherShape& rShape) { return rShape.mnEscherShapeOrder == nIdx; });
82}
83
85{
86 sal_uInt16 nFound=0;
87 sal_uInt16 nShapeCount = mpShapeOrders ? mpShapeOrders->size() : 0;
88 // First, find out what position this shape is in the Escher order.
89 for (sal_uInt16 nShapePos=0; nShapePos < nShapeCount; nShapePos++)
90 {
91 const SvxMSDffShapeOrder& rOrder = *(*mpShapeOrders)[nShapePos];
92 if (rOrder.nShapeId == nSpId)
93 {
94 nFound = nShapePos;
95 break;
96 }
97 }
98 return nFound;
99}
100
101// consider new parameter <_bInHeaderFooter>
103 const bool bInHellLayer,
104 const bool _bInHeaderFooter )
105{
106 /*
107 EscherObjects have their own ordering which needs to be matched to
108 the actual ordering that should be used when inserting them into the
109 document.
110 */
111 sal_uInt16 nFound = GetEscherObjectIdx(nSpId);
112 // Match the ordering position from the ShapeOrders to the ordering of all
113 // objects in the document, there is a complexity when escherobjects
114 // contain inlines objects, we need to consider those as part of the
115 // escher count
116 sal_uLong nRet=0;
117 myeiter aIter = maEscherLayer.begin();
118 myeiter aEnd = maEscherLayer.end();
119 // skip objects in page header|footer,
120 // if current object isn't in page header|footer
121 if ( !_bInHeaderFooter )
122 {
123 while ( aIter != aEnd )
124 {
125 if ( !aIter->mbInHeaderFooter )
126 {
127 break;
128 }
129 nRet += aIter->mnNoInlines + 1;
130 ++aIter;
131 }
132 }
133 if (!bInHellLayer)
134 {
135 while (aIter != aEnd)
136 {
137 if (!aIter->mbInHellLayer || (_bInHeaderFooter && !aIter->mbInHeaderFooter))
138 break;
139 nRet += aIter->mnNoInlines + 1;
140 ++aIter;
141 }
142 }
143 while (aIter != aEnd)
144 {
145 // insert object in page header|footer
146 // before objects in page body
147 if ( _bInHeaderFooter && !aIter->mbInHeaderFooter )
148 {
149 break;
150 }
151 if ( bInHellLayer && !aIter->mbInHellLayer )
152 break;
153
154 if ( aIter->mnEscherShapeOrder > nFound )
155 break;
156 nRet += aIter->mnNoInlines+1;
157 ++aIter;
158 }
159 maEscherLayer.insert(aIter, EscherShape( nFound, bInHellLayer, _bInHeaderFooter ) );
160 return nRet;
161}
162
163// InsertObj() adds the object into the Sw-Page and memorize the Z-position
164// in a VarArr
165void wwZOrderer::InsertDrawingObject(SdrObject* pObj, short nWwHeight)
166{
168 if (nWwHeight & 0x2000) // Heaven ?
170 else
172
174}
175
177{
179 if (maIndexes.empty())
180 {
182 ++mnInlines;
183 }
184 else
185 {
186 //If we are inside an escher objects, place us just after that
187 //escher obj, and increment its inline count
188 sal_uInt16 nIdx = maIndexes.top();
189 myeiter aEnd = MapEscherIdxToIter(nIdx);
190
191 sal_uLong nInsertPos = std::accumulate(maEscherLayer.begin(), aEnd, sal_uLong(0),
192 [](const sal_uLong nPos, const EscherShape& rShape) { return nPos + rShape.mnNoInlines + 1; });
193
194 OSL_ENSURE(aEnd != maEscherLayer.end(), "Something very wrong here");
195 if (aEnd != maEscherLayer.end())
196 {
197 aEnd->mnNoInlines++;
198 nInsertPos += aEnd->mnNoInlines;
199 }
200
202 }
203}
204
205/* Parallel to the Obj-array in the document I also build an array which
206 * contains the Ww-height (-> what covers what).
207 * Based on this VARARR the position where the insertion happens is
208 * determined.
209 * When inserting the offset in an existing document with a graphic layer the
210 * caller has to increment the index by mnNoInitialObjects, so that the new
211 * objects are added at the end (inserting is faster then)
212 */
214{
215 auto aIter = std::find_if(
216 maDrawHeight.begin(), maDrawHeight.end(),
217 [nWwHeight](short aHeight){ return (aHeight & 0x1fff) > (nWwHeight & 0x1fff); });
218
219 aIter = maDrawHeight.insert(aIter, nWwHeight);
220 return std::distance(maDrawHeight.begin(), aIter);
221}
222
224{
225 if (!pObject->IsInserted())
226 {
228 }
229}
230
231static void WW8PicShadowToReal( WW8_PIC_SHADOW const * pPicS, WW8_PIC* pPic );
232
234{
235 return ERRCODE_NONE == GraphicFilter::GetGraphicFilter().ImportGraphic(rGraphic, u"", rSrc);
236}
237
238bool SwWW8ImplReader::ReadGrafFile(OUString& rFileName, std::optional<Graphic>& roGraphic,
239 const WW8_PIC& rPic, SvStream* pSt, sal_uLong nFilePos, bool* pbInDoc)
240{ // Write the graphic to the file
241 *pbInDoc = true; // default
242
243 sal_uLong nPosFc = nFilePos + rPic.cbHeader;
244
245 switch (rPic.MFP.mm)
246 {
247 case 94: // BMP-file ( not embedded ) or GIF
248 case 99: // TIFF-file ( not embedded )
249 pSt->Seek(nPosFc);
250 // read name as P-string
251 rFileName = read_uInt8_PascalString(*pSt, m_eStructCharSet);
252 if (!rFileName.isEmpty())
253 rFileName = URIHelper::SmartRel2Abs(
254 INetURLObject(m_sBaseURL), rFileName,
256 *pbInDoc = false; // Don't delete the file afterwards
257 return !rFileName.isEmpty(); // read was successful
258 }
259
260 //skip duplicate graphics when fuzzing
261 if (m_bFuzzing)
262 {
263 if (!m_aGrafPosSet.insert(nPosFc).second)
264 return false;
265 }
266
267 GDIMetaFile aWMF;
268 bool bOk = checkSeek(*pSt, nPosFc) && ReadWindowMetafile( *pSt, aWMF );
269
270 if (!bOk || pSt->GetError() || !aWMF.GetActionSize())
271 return false;
272
273 if (m_xWwFib->m_envr != 1) // !MAC as creator
274 {
275 roGraphic.emplace(aWMF);
276 return true;
277 }
278
279 // MAC - word as creator
280 // The WMF only says "Please use Word 6.0c" and Mac-Pict follows but without
281 // the first 512 Bytes which are not relevant in a MAC-PICT (they are not
282 // interpreted)
283 bOk = false;
284 tools::Long nData = rPic.lcb - ( pSt->Tell() - nPosFc );
285 if (nData > 0)
286 {
287 roGraphic.emplace();
288 bOk = SwWW8ImplReader::GetPictGrafFromStream(*roGraphic, *pSt);
289 if (!bOk)
290 roGraphic.reset();
291 }
292 return bOk; // Contains graphic
293}
294
296{
297 sal_Int16 nCL, nCR, nCT, nCB;
299
300 explicit WW8PicDesc( const WW8_PIC& rPic );
301};
302
304 : nCL(rPic.dxaCropLeft),
305 nCR(rPic.dxaCropRight),
306 nCT(rPic.dyaCropTop),
307 nCB(rPic.dyaCropBottom)
308{
309 //See #i21190# before fiddling with this method
310 tools::Long nOriWidth = rPic.dxaGoal; //Size in 1/100 mm before crop
311 tools::Long nOriHeight = rPic.dyaGoal;
312
313
314 tools::Long nCurrentWidth = nOriWidth - (nCL + nCR); // Size after crop
315 tools::Long nCurrentHeight = nOriHeight - (nCT + nCB);
316 if (!nCurrentWidth)
317 nCurrentWidth = 1;
318 if (!nCurrentHeight)
319 nCurrentHeight = 1;
320 nWidth = nCurrentWidth * rPic.mx / 1000; // Writer Size
321 nHeight = nCurrentHeight * rPic.my / 1000;
322}
323
325 SdrObject &rSubObj)
326{
327 // Insert SdrGrafObj instead of SdrTextObj into this group
328 if (SdrObject* pGroupObject = rReplaceObj.getParentSdrObjectFromSdrObject())
329 {
330 SdrObjList* pObjectList = pGroupObject->GetSubList();
331
332 rSubObj.SetLogicRect(rReplaceObj.GetCurrentBoundRect());
333 rSubObj.SetLayer(rReplaceObj.GetLayer());
334
335 // remove old object from group-list and add new one
336 // (this also exchanges it in the drawing page)
337 pObjectList->ReplaceObject(&rSubObj, rReplaceObj.GetOrdNum());
338 }
339 else
340 {
341 OSL_ENSURE( false, "Impossible!");
342 }
343}
344
345// MakeGrafNotInContent inserts a non character bound graphic
346// ( bGrafApo == true)
348 const Graphic* pGraph, const OUString& rFileName, const SfxItemSet& rGrfSet)
349{
350
351 sal_uInt32 nWidth = rPD.nWidth;
352 sal_uInt32 nHeight = rPD.nHeight;
353
354 // Vertical shift through line spacing
355 sal_Int32 nNetHeight = nHeight + rPD.nCT + rPD.nCB;
356 if (m_xSFlyPara->nLineSpace && m_xSFlyPara->nLineSpace > nNetHeight)
357 m_xSFlyPara->nYPos =
358 o3tl::narrowing<sal_uInt16>( m_xSFlyPara->nYPos + m_xSFlyPara->nLineSpace - nNetHeight );
359
360 WW8FlySet aFlySet(*this, m_xWFlyPara.get(), m_xSFlyPara.get(), true);
361
363 aAnchor.SetAnchor(m_pPaM->GetPoint());
364 aFlySet.Put(aAnchor);
365
366 aFlySet.Put( SwFormatFrameSize( SwFrameSize::Fixed, nWidth, nHeight ) );
367
368 SwFlyFrameFormat *const pFlyFormat =
370 *m_pPaM, rFileName, OUString(), pGraph,
371 &aFlySet, &rGrfSet, nullptr);
372
373 // So the frames are generated when inserted in an existing doc:
375 (RndStdIds::FLY_AT_PARA == pFlyFormat->GetAnchor().GetAnchorId()))
376 {
377 pFlyFormat->MakeFrames();
378 }
379 return pFlyFormat;
380}
381
382// MakeGrafInContent inserts a character bound graphic
384 const WW8PicDesc& rPD, const Graphic* pGraph, const OUString& rFileName,
385 const SfxItemSet& rGrfSet)
386{
387 WW8FlySet aFlySet(*this, m_pPaM, rPic, rPD.nWidth, rPD.nHeight);
388
389 SwFrameFormat* pFlyFormat = nullptr;
390
391 if (rFileName.isEmpty() && m_nObjLocFc) // then it should be an OLE-Object
392 pFlyFormat = ImportOle(pGraph, &aFlySet, &rGrfSet);
393
394 if( !pFlyFormat ) // then just as graphic
395 {
396
398 *m_pPaM, rFileName, OUString(), pGraph, &aFlySet,
399 &rGrfSet, nullptr);
400 }
401
402 // Resize the frame to the size of the picture if graphic is inside a frame
403 // (only if auto-width)
404 if (m_xSFlyPara)
405 m_xSFlyPara->BoxUpWidth( rPD.nWidth );
406 return pFlyFormat;
407}
408
410 sal_uLong nFilePos )
411{
412 SwFrameFormat* pRet = nullptr;
413 if( pSt->eof() || rPic.fError || rPic.MFP.mm == 99 )
414 return nullptr;
415
416 OUString aFileName;
417 bool bInDoc;
418 std::optional<Graphic> oGraph;
419 bool bOk = ReadGrafFile(aFileName, oGraph, rPic, pSt, nFilePos, &bInDoc);
420
421 if (!bOk)
422 {
423 return nullptr; // Graphic could not be read correctly
424 }
425
426 WW8PicDesc aPD( rPic );
427
429 if( aPD.nCL || aPD.nCR || aPD.nCT || aPD.nCB )
430 {
431 SwCropGrf aCrop( aPD.nCL, aPD.nCR, aPD.nCT, aPD.nCB) ;
432 aGrfSet.Put( aCrop );
433 }
434
435 if (m_xWFlyPara && m_xWFlyPara->bGrafApo)
436 pRet = MakeGrafNotInContent(aPD, oGraph ? &*oGraph : nullptr, aFileName, aGrfSet);
437 else
438 pRet = MakeGrafInContent(rPic, aPD, oGraph ? &*oGraph : nullptr, aFileName, aGrfSet);
439 return pRet;
440}
441
443 bool bVer67)
444{
445 //Only the first 0x2e bytes are the same between version 6/7 and 8+
446 WW8_PIC_SHADOW aPicS{};
447 pDataStream->ReadBytes( &aPicS, sizeof( aPicS ) );
448 WW8PicShadowToReal( &aPicS, pPic );
449 for (WW8_BRC & i : pPic->rgbrc)
450 pDataStream->ReadBytes(&i, bVer67 ? 2 : 4);
451 pDataStream->ReadInt16( pPic->dxaOrigin );
452 pDataStream->ReadInt16( pPic->dyaOrigin );
453 bool bOk = pDataStream->good();
454 if (!bVer67)
455 pDataStream->SeekRel(2); //cProps
456 return bOk;
457}
458
459namespace
460{
461 SwNodeType GetNodeType(SwFrameFormat const &rSource)
462 {
463 const SwNodeIndex* pNodeIndex = rSource.GetContent().GetContentIdx();
464 if (!pNodeIndex)
465 return SwNodeType::NONE;
466 const SwNode& rCSttNd = pNodeIndex->GetNode();
467 SwNodeRange aRg(rCSttNd, SwNodeOffset(1), *rCSttNd.EndOfSectionNode());
468 return aRg.aStart.GetNode().GetNodeType();
469 }
470}
471
473 SwFrameFormat const * pOldFlyFormat)
474{
475 SwFrameFormat* pRet = nullptr;
476 if (
477 ((m_pStrm == m_pDataStream ) && !m_nPicLocFc) ||
479 )
480 {
481 return nullptr;
482 }
483
485
486 GraphicCtor();
487
488 /*
489 * Little joke from Microsoft: sometimes a stream named DATA exists. This
490 * stream then contains the PICF and the corresponding graphic!
491 * We otherwise map the variable pDataStream to pStream.
492 */
493 auto nOldPos = m_pDataStream->Tell();
494 WW8_PIC aPic;
495 bool bValid = checkSeek(*m_pDataStream, m_nPicLocFc) &&
497
498 // Sanity check is needed because for example check boxes in field results
499 // contain a WMF-like struct
500 if (bValid && aPic.lcb >= 58)
501 {
503 {
504 // We just added a graphic-link into the doc. Now we need to set
505 // its position and scale it.
506 WW8PicDesc aPD( aPic );
507
508 WW8FlySet aFlySet( *this, m_pPaM, aPic, aPD.nWidth, aPD.nHeight );
509
510 // the correct anchor is set in Read_F_IncludePicture and the
511 // current PaM point is after the position if it is anchored in
512 // content; because this anchor add a character into the textnode.
513 // #i2806#
514 if (RndStdIds::FLY_AS_CHAR ==
516 {
517 aFlySet.ClearItem( RES_ANCHOR );
518 }
519
521
523 }
524 else if((0x64 == aPic.MFP.mm) || (0x66 == aPic.MFP.mm))
525 {
526 // linked graphic in ESCHER-Object
528
529 WW8PicDesc aPD( aPic );
530 if (!m_xMSDffManager)
532 /* ##835##
533 * Disable use of main stream as fallback stream for inline direct
534 * blips as it is known that they are directly after the record
535 * header, testing for existence in main stream may lead to an
536 * incorrect fallback graphic being found if other escher graphics
537 * have been inserted in the document
538 */
539 m_xMSDffManager->DisableFallbackStream();
540 if (!m_xMSDffManager->GetModel())
541 m_xMSDffManager->SetModel(m_pDrawModel, 1440);
542
543 if (0x66 == aPic.MFP.mm)
544 {
545 //These ones have names prepended
546 sal_uInt8 nNameLen=0;
547 m_pDataStream->ReadUChar( nNameLen );
548 m_pDataStream->SeekRel( nNameLen );
549 }
550
551 tools::Rectangle aClientRect( 0,0, aPD.nWidth, aPD.nHeight);
552 SvxMSDffImportData aData( aClientRect );
553 pObject = m_xMSDffManager->ImportObj(*m_pDataStream, aData, aClientRect, tools::Rectangle(), /*nCalledByGroup*/0, /*pShapeId*/nullptr );
554 if (pObject)
555 {
556 // for the frame
558
559 SvxMSDffImportRec const*const pRecord = (1 == aData.size())
560 ? aData.begin()->get() : nullptr;
561
562 if( pRecord )
563 {
564
565 // Horizontal rule may have its width given as % of page
566 // width (-1 is used if not given, 0 means the object has
567 // fixed width).
568 // Additionally, if it's a horizontal rule without width
569 // given, assume 100.0% width.
570 int relativeWidth = pRecord->relativeHorizontalWidth;
571 if( relativeWidth == -1 )
572 relativeWidth = pRecord->isHorizontalRule ? 1000 : 0;
573 if( relativeWidth != 0 )
574 {
575 const sal_Int16 nScale = aPic.dxaGoal ? aPic.dxaGoal : 1000;
576 aPic.mx = msword_cast<sal_uInt16>(
579 m_aSectionManager.GetPageLeft()) * relativeWidth / nScale;
580 aPD = WW8PicDesc( aPic );
581 // This SetSnapRect() call adjusts the size of the
582 // object itself, no idea why it's this call (or even
583 // what the call actually does), but that's what
584 // ImportGraf() (called by ImportObj()) uses.
585 pObject->SetSnapRect( tools::Rectangle( 0, 0, aPD.nWidth, aPD.nHeight ));
586 }
587
588 // A graphic of this type in this location is always
589 // inline, and uses the pic in the same module as ww6
590 // graphics.
591 if (m_xWFlyPara && m_xWFlyPara->bGrafApo)
592 {
593 WW8FlySet aFlySet(*this, m_xWFlyPara.get(), m_xSFlyPara.get(), true);
594
596 aAnchor.SetAnchor(m_pPaM->GetPoint());
597 aFlySet.Put(aAnchor);
598
599 aAttrSet.Put(aFlySet);
600 }
601 else
602 {
603 WW8FlySet aFlySet( *this, m_pPaM, aPic, aPD.nWidth,
604 aPD.nHeight );
605
606 aAttrSet.Put(aFlySet);
607 }
608 // Modified for i120716,for graf importing from MS Word 2003
609 // binary format, there is no border distance.
610 tools::Rectangle aInnerDist(0,0,0,0);
611 MatchSdrItemsIntoFlySet( pObject.get(), aAttrSet,
612 pRecord->eLineStyle, pRecord->eLineDashing,
613 pRecord->eShapeType, aInnerDist );
614
615 // Set the size from the WinWord PIC-structure as graphic
616 // size
617 aAttrSet.Put( SwFormatFrameSize( SwFrameSize::Fixed, aPD.nWidth,
618 aPD.nHeight ) );
619 }
620
621 // for the graphic
623
624 if( aPD.nCL || aPD.nCR || aPD.nCT || aPD.nCB )
625 {
626 SwCropGrf aCrop( aPD.nCL, aPD.nCR, aPD.nCT, aPD.nCB );
627 aGrSet.Put( aCrop );
628 }
629
630 if (pRecord)
631 MatchEscherMirrorIntoFlySet(*pRecord, aGrSet);
632
633 // if necessary adopt old AttrSet and correct horizontal
634 // positioning relation
635 if( pOldFlyFormat )
636 {
637 aAttrSet.Put( pOldFlyFormat->GetAttrSet() );
638 const SwFormatHoriOrient &rHori = pOldFlyFormat->GetHoriOrient();
639 if( text::RelOrientation::FRAME == rHori.GetRelationOrient() )
640 {
641 aAttrSet.Put( SwFormatHoriOrient( rHori.GetPos(),
642 text::HoriOrientation::NONE, text::RelOrientation::PAGE_PRINT_AREA ) );
643 }
644 }
645
646 bool bTextObjWasGrouped = false;
647 if (pOldFlyFormat && pTextObj && pTextObj->getParentSdrObjectFromSdrObject())
648 bTextObjWasGrouped = true;
649
650 if (bTextObjWasGrouped)
651 ReplaceObj(*pTextObj, *pObject);
652 else
653 {
654 if (SdrObjKind::OLE2 == pObject->GetObjIdentifier())
655 {
656 // the size from BLIP, if there is any, should be already set
657 pRet = InsertOle(*static_cast<SdrOle2Obj*>(pObject.get()), aAttrSet, &aGrSet);
658 }
659 else
660 {
661 if (SdrGrafObj* pGraphObject = dynamic_cast<SdrGrafObj*>( pObject.get()) )
662 {
663 // Now add the link or rather the graphic to the doc
664 const Graphic& rGraph = pGraphObject->GetGraphic();
665
666 if (m_nObjLocFc) // is it an OLE-Object?
667 pRet = ImportOle(&rGraph, &aAttrSet, &aGrSet, pObject->GetBLIPSizeRectangle());
668
669 if (!pRet)
670 {
672 *m_pPaM, OUString(), OUString(),
673 &rGraph, &aAttrSet, &aGrSet, nullptr );
674 }
675 }
676 else
678 }
679 }
680
681 // only if we made an *Insert*
682 if (pRet)
683 {
684 if (pRecord)
685 SetAttributesAtGrfNode(*pRecord, *pRet, nullptr);
686
687 OUString aObjectName(pObject->GetName());
688 if (aObjectName.isEmpty() || !m_rDoc.FindFlyByName(aObjectName, GetNodeType(*pRet)))
689 pRet->SetFormatName(aObjectName);
690 else
691 m_aGrfNameGenerator.SetUniqueGraphName(pRet, aObjectName);
692
693 // determine the pointer to the new object and update
694 // Z-order-list accordingly (or delete entry)
695 if (SdrObject* pOurNewObject = CreateContactObject(pRet))
696 {
697 if (pOurNewObject != pObject.get())
698 {
699 m_xMSDffManager->ExchangeInShapeOrder( pObject.get(), 0,
700 pOurNewObject );
701
702 // delete and destroy old SdrGrafObj from page
703 if (pObject->getSdrPageFromSdrObject())
704 m_pDrawPg->RemoveObject(pObject->GetOrdNum());
705 pObject.clear();
706 }
707 }
708 else
709 m_xMSDffManager->RemoveFromShapeOrder( pObject.get() );
710 }
711 else
712 m_xMSDffManager->RemoveFromShapeOrder( pObject.get() );
713
714 // also delete this from the page if not grouped
715 if (pTextObj && !bTextObjWasGrouped && pTextObj->getSdrPageFromSdrObject())
716 m_pDrawPg->RemoveObject( pTextObj->GetOrdNum() );
717 }
718 m_xMSDffManager->EnableFallbackStream();
719 }
720 else if (aPic.lcb >= 58)
722 }
723 m_pDataStream->Seek( nOldPos );
724
725 if (pRet)
726 {
727 SdrObject* pOurNewObject = CreateContactObject(pRet);
728 m_xWWZOrder->InsertTextLayerObject(pOurNewObject);
729 }
730
731 return AddAutoAnchor(pRet);
732}
733
734void WW8PicShadowToReal( WW8_PIC_SHADOW const * pPicS, WW8_PIC * pPic )
735{
736 pPic->lcb = SVBT32ToUInt32( pPicS->lcb );
737 pPic->cbHeader = SVBT16ToUInt16( pPicS->cbHeader );
738 pPic->MFP.mm = SVBT16ToUInt16( pPicS->MFP.mm );
739 pPic->MFP.xExt = SVBT16ToUInt16( pPicS->MFP.xExt );
740 pPic->MFP.yExt = SVBT16ToUInt16( pPicS->MFP.yExt );
741 pPic->MFP.hMF = SVBT16ToUInt16( pPicS->MFP.hMF );
742 for( sal_uInt16 i = 0; i < 14 ; i++ )
743 pPic->rcWinMF[i] = pPicS->rcWinMF[i];
744 pPic->dxaGoal = SVBT16ToUInt16( pPicS->dxaGoal );
745 pPic->dyaGoal = SVBT16ToUInt16( pPicS->dyaGoal );
746 pPic->mx = SVBT16ToUInt16( pPicS->mx );
747 pPic->my = SVBT16ToUInt16( pPicS->my );
748 pPic->dxaCropLeft = SVBT16ToUInt16( pPicS->dxaCropLeft );
749 pPic->dyaCropTop = SVBT16ToUInt16( pPicS->dyaCropTop );
750 pPic->dxaCropRight = SVBT16ToUInt16( pPicS->dxaCropRight );
751 pPic->dyaCropBottom = SVBT16ToUInt16( pPicS->dyaCropBottom );
752 pPic->brcl = pPicS->aBits1 & 0x0f;
753 pPic->fFrameEmpty = (pPicS->aBits1 & 0x10) >> 4;
754 pPic->fBitmap = (pPicS->aBits1 & 0x20) >> 5;
755 pPic->fDrawHatch = (pPicS->aBits1 & 0x40) >> 6;
756 pPic->fError = (pPicS->aBits1 & 0x80) >> 7;
757 pPic->bpp = pPicS->aBits2;
758}
759
761{
762 rFSPA.nSpId = SVBT32ToUInt32(rFSPAS.nSpId);
763 rFSPA.nXaLeft = SVBT32ToUInt32(rFSPAS.nXaLeft);
764 rFSPA.nYaTop = SVBT32ToUInt32(rFSPAS.nYaTop);
765 rFSPA.nXaRight = SVBT32ToUInt32(rFSPAS.nXaRight);
766 rFSPA.nYaBottom = SVBT32ToUInt32(rFSPAS.nYaBottom);
767
768 sal_uInt16 nBits = SVBT16ToUInt16(rFSPAS.aBits1);
769
770 rFSPA.bHdr = sal_uInt16(0 != (nBits & 0x0001));
771 rFSPA.nbx = (nBits & 0x0006) >> 1;
772 rFSPA.nby = (nBits & 0x0018) >> 3;
773 rFSPA.nwr = (nBits & 0x01E0) >> 5;
774 rFSPA.nwrk = (nBits & 0x1E00) >> 9;
775 rFSPA.bRcaSimple = sal_uInt16(0 != (nBits & 0x2000));
776 rFSPA.bBelowText = sal_uInt16(0 != (nBits & 0x4000));
777 rFSPA.bAnchorLock = sal_uInt16(0 != (nBits & 0x8000));
778 rFSPA.nTxbx = SVBT32ToUInt32(rFSPAS.nTxbx);
779}
780
781/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
size_t GetActionSize() const
static GraphicFilter & GetGraphicFilter()
ErrCode ImportGraphic(Graphic &rGraphic, const INetURLObject &rPath, sal_uInt16 nFormat=GRFILTER_FORMAT_DONTKNOW, sal_uInt16 *pDeterminedFormat=nullptr, GraphicFilterImportFlags nImportFlags=GraphicFilterImportFlags::NONE)
virtual SwDrawFrameFormat * InsertDrawObj(const SwPaM &rRg, SdrObject &rDrawObj, const SfxItemSet &rFlyAttrSet)=0
Insert a DrawObject.
virtual SwFlyFrameFormat * InsertGraphic(const SwPaM &rRg, const OUString &rGrfName, const OUString &rFltName, const Graphic *pGraphic, const SfxItemSet *pFlyAttrSet, const SfxItemSet *pGrfAttrSet, SwFrameFormat *)=0
Insert graphic or formula.
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
virtual rtl::Reference< SdrObject > ReplaceObject(SdrObject *pNewObj, size_t nObjNum)
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
size_t GetObjCount() const
virtual rtl::Reference< SdrObject > RemoveObject(size_t nObjNum)
sal_uInt32 GetOrdNum() const
virtual const tools::Rectangle & GetCurrentBoundRect() const
virtual void SetLogicRect(const tools::Rectangle &rRect)
SdrPage * getSdrPageFromSdrObject() const
SdrObject * getParentSdrObjectFromSdrObject() const
virtual SdrLayerID GetLayer() const
virtual void SetLayer(SdrLayerID nLayer)
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_uInt64 Tell() const
bool good() const
SvStream & ReadInt16(sal_Int16 &rInt16)
bool eof() const
sal_uInt64 Seek(sal_uInt64 nPos)
std::size_t ReadBytes(void *pData, std::size_t nSize)
sal_uInt64 SeekRel(sal_Int64 nPos)
ErrCode GetError() const
SvStream & ReadUChar(unsigned char &rChar)
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:316
const SwFlyFrameFormat * FindFlyByName(const OUString &rName, SwNodeType nNdTyp=SwNodeType::NONE) const
Definition: doclay.cxx:1388
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:406
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1322
virtual void MakeFrames() override
Creates the views.
Definition: atrfrm.cxx:2934
FlyAnchors.
Definition: fmtanchr.hxx:37
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1586
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:67
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
SwTwips GetPos() const
Definition: fmtornt.hxx:92
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:88
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:83
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:136
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:108
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:447
const SwFormatContent & GetContent(bool=true) const
Definition: fmtcntnt.hxx:55
Style of a layout element.
Definition: frmfmt.hxx:62
virtual void SetFormatName(const OUString &rNewName, bool bBroadcast=false) override
Definition: atrfrm.cxx:2568
Marks a node in the document model.
Definition: ndindex.hxx:31
SwNode & GetNode() const
Definition: ndindex.hxx:136
Base class of the Writer document model elements.
Definition: node.hxx:84
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:711
const SwPosition * GetPoint() const
Definition: pam.hxx:261
SwPaM * m_pPaM
Definition: ww8par.hxx:1129
SwDocShell * m_pDocShell
Definition: ww8par.hxx:1106
OUString m_sBaseURL
Definition: ww8par.hxx:1300
bool ReadGrafFile(OUString &rFileName, std::optional< Graphic > &rpGraphic, const WW8_PIC &rPic, SvStream *pSt, sal_uLong nFilePos, bool *pDelIt)
Definition: ww8graf2.cxx:238
SwFrameFormat * ImportGraf1(WW8_PIC const &rPic, SvStream *pSt, sal_uLong nFilePos)
Definition: ww8graf2.cxx:409
SwFrameFormat * ImportOle(const Graphic *=nullptr, const SfxItemSet *pFlySet=nullptr, const SfxItemSet *pGrfSet=nullptr, const tools::Rectangle &aVisArea=tools::Rectangle())
Definition: ww8par4.cxx:239
static void ReplaceObj(const SdrObject &rReplaceTextObj, SdrObject &rSubObj)
Definition: ww8graf2.cxx:324
void SetAttributesAtGrfNode(const SvxMSDffImportRec &rRecord, const SwFrameFormat &rFlyFormat, WW8_FSPA const *pF)
Definition: ww8graf.cxx:2128
SwDoc & m_rDoc
Definition: ww8par.hxx:1127
std::unique_ptr< WW8SwFlyPara > m_xSFlyPara
Definition: ww8par.hxx:1276
std::unique_ptr< WW8FlyPara > m_xWFlyPara
Definition: ww8par.hxx:1275
SvStream * m_pStrm
Definition: ww8par.hxx:1122
SwFlyFrameFormat * InsertOle(SdrOle2Obj &rObject, const SfxItemSet &rFlySet, const SfxItemSet *rGrfSet)
Definition: ww8par4.cxx:195
std::shared_ptr< WW8Fib > m_xWwFib
Definition: ww8par.hxx:1253
wwSectionManager m_aSectionManager
Definition: ww8par.hxx:1184
SwFrameFormat * ImportGraf(SdrTextObj const *pTextObj=nullptr, SwFrameFormat const *pFlyFormat=nullptr)
Definition: ww8graf2.cxx:472
bool m_bSkipImages
Definition: ww8par.hxx:1342
SwFlyFrameFormat * MakeGrafNotInContent(const WW8PicDesc &rPD, const Graphic *pGraph, const OUString &rFileName, const SfxItemSet &rGrfSet)
Definition: ww8graf2.cxx:347
SwFlyFrameFormat * m_pFlyFormatOfJustInsertedGraphic
Definition: ww8par.hxx:1233
SdrPage * m_pDrawPg
Definition: ww8par.hxx:1286
SdrModel * m_pDrawModel
Definition: ww8par.hxx:1285
std::unique_ptr< SwMSDffManager > m_xMSDffManager
Definition: ww8par.hxx:1292
SvStream * m_pDataStream
Definition: ww8par.hxx:1124
wwFrameNamer m_aGrfNameGenerator
Definition: ww8par.hxx:1212
void GraphicCtor()
Definition: ww8graf.cxx:3186
std::unique_ptr< wwZOrderer > m_xWWZOrder
Definition: ww8par.hxx:1288
sal_uLong m_nObjLocFc
Definition: ww8par.hxx:1314
std::set< sal_uLong > m_aGrafPosSet
Definition: ww8par.hxx:1249
SdrObject * CreateContactObject(SwFrameFormat *pFlyFormat)
Definition: ww8graf.cxx:2229
rtl_TextEncoding m_eStructCharSet
Definition: ww8par.hxx:1320
sal_uInt16 m_nProgress
Definition: ww8par.hxx:1322
friend class SwMSDffManager
Definition: ww8par.hxx:1114
SwFrameFormat * AddAutoAnchor(SwFrameFormat *pFormat)
Definition: ww8graf.cxx:2850
static bool GetPictGrafFromStream(Graphic &rGraphic, SvStream &rSrc)
Definition: ww8graf2.cxx:233
sal_uInt32 m_nIniFlags
Definition: ww8par.hxx:1303
SwFrameFormat * MakeGrafInContent(const WW8_PIC &rPic, const WW8PicDesc &rPD, const Graphic *pGraph, const OUString &rFileName, const SfxItemSet &rGrfSet)
Definition: ww8graf2.cxx:383
static SAL_WARN_UNUSED_RESULT bool PicRead(SvStream *pDataStream, WW8_PIC *pPic, bool bVer67)
Definition: ww8graf2.cxx:442
void MatchSdrItemsIntoFlySet(SdrObject const *pSdrObj, SfxItemSet &aFlySet, MSO_LineStyle eLineStyle, MSO_LineDashing eDashing, MSO_SPT eShapeType, tools::Rectangle &rInnerDist)
Definition: ww8graf.cxx:1682
sal_uLong m_nPicLocFc
Definition: ww8par.hxx:1313
Make setting a drawing object's layer in a Writer document easy.
void SendObjectToHeaven(SdrObject &rObject) const
Make Object lives in the top layer.
void SendObjectToHell(SdrObject &rObject) const
Make Object live in the bottom drawing layer.
void SetUniqueGraphName(SwFrameFormat *pFrameFormat, std::u16string_view rFixedPart)
Definition: ww8graf.cxx:165
sal_uInt32 GetPageWidth() const
Definition: ww8par2.cxx:155
sal_uInt32 GetPageRight() const
Definition: ww8par2.cxx:150
sal_uInt32 GetPageLeft() const
Definition: ww8par2.cxx:145
void InsertTextLayerObject(SdrObject *pObject)
Definition: ww8graf2.cxx:176
const SvxMSDffShapeOrders * mpShapeOrders
Definition: ww8graf.hxx:69
sal_uLong GetEscherObjectPos(sal_uLong nSpId, const bool bInHellLayer, const bool _bInHeaderFooter)
Definition: ww8graf2.cxx:102
sal_uLong GetDrawingObjectPos(short nWwHeight)
Definition: ww8graf2.cxx:213
void InsideEscher(sal_uLong nIndex)
Definition: ww8graf2.cxx:58
void InsertObject(SdrObject *pObject, sal_uLong nPos)
Definition: ww8graf2.cxx:223
sw::util::SetLayer maSetLayer
Definition: ww8graf.hxx:64
SdrPage * mpDrawPg
Definition: ww8graf.hxx:68
myeiter MapEscherIdxToIter(sal_uLong nIdx)
Definition: ww8graf2.cxx:78
void InsertDrawingObject(SdrObject *pObj, short nWwHeight)
Definition: ww8graf2.cxx:165
void OutsideEscher()
Definition: ww8graf2.cxx:63
std::vector< EscherShape >::iterator myeiter
Definition: ww8graf.hxx:58
std::vector< short > maDrawHeight
Definition: ww8graf.hxx:60
sal_uInt16 GetEscherObjectIdx(sal_uLong nSpId)
Definition: ww8graf2.cxx:84
std::stack< sal_uInt16 > maIndexes
Definition: ww8graf.hxx:62
wwZOrderer(const sw::util::SetLayer &rSetLayer, SdrPage *pDrawPg, const SvxMSDffShapeOrders *pShapeOrders)
Definition: ww8graf2.cxx:49
sal_uLong mnNoInitialObjects
Definition: ww8graf.hxx:66
sal_uLong mnInlines
Definition: ww8graf.hxx:67
std::vector< EscherShape > maEscherLayer
Definition: ww8graf.hxx:57
void InsertEscherObject(SdrObject *pObject, sal_uLong nSpId, const bool bInHellLayer, const bool _bInHeaderFooter)
Definition: ww8graf2.cxx:69
float u
EmbeddedObjectRef * pObject
#define ERRCODE_NONE
@ Fixed
Frame cannot be moved in Var-direction.
constexpr sal_uInt16 RES_FRMATR_BEGIN(RES_PARATR_LIST_END)
constexpr sal_uInt16 RES_FRMATR_END(133)
constexpr sal_uInt16 RES_GRFATR_BEGIN(RES_FRMATR_END)
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(104)
constexpr sal_uInt16 RES_GRFATR_END(150)
sal_uInt16 nPos
void SetProgressState(tools::Long nPosition, SwDocShell const *pDocShell)
Definition: mainwn.cxx:82
std::vector< std::unique_ptr< SvxMSDffShapeOrder > > SvxMSDffShapeOrders
constexpr OUStringLiteral aData
Definition: ww8scan.hxx:48
SVL_DLLPUBLIC Link< OUString *, bool > const & GetMaybeFileHdl()
SVL_DLLPUBLIC OUString SmartRel2Abs(INetURLObject const &rTheBaseURIRef, OUString const &rTheRelURIRef, Link< OUString *, bool > const &rMaybeFileHdl=Link< OUString *, bool >(), bool bCheckFileExists=true, bool bIgnoreFragment=false, INetURLObject::EncodeMechanism eEncodeMechanism=INetURLObject::EncodeMechanism::WasEncoded, INetURLObject::DecodeMechanism eDecodeMechanism=INetURLObject::DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
int i
long Long
SwNodeType
Definition: ndtyp.hxx:28
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
Definition: nodeoffset.hxx:16
sal_uIntPtr sal_uLong
TOOLS_DLLPUBLIC bool checkSeek(SvStream &rSt, sal_uInt64 nOffset)
sal_uLong mnNoInlines
Definition: ww8graf.hxx:35
MSO_LineDashing eLineDashing
MSO_LineStyle eLineStyle
sal_Int16 nCL
Definition: ww8graf2.cxx:297
tools::Long nWidth
Definition: ww8graf2.cxx:298
WW8PicDesc(const WW8_PIC &rPic)
Definition: ww8graf2.cxx:303
sal_Int16 nCB
Definition: ww8graf2.cxx:297
tools::Long nHeight
Definition: ww8graf2.cxx:298
sal_Int16 nCR
Definition: ww8graf2.cxx:297
sal_Int16 nCT
Definition: ww8graf2.cxx:297
static constexpr RndStdIds eAnchor
Definition: ww8par2.hxx:58
SVBT32 nYaBottom
Definition: ww8struc.hxx:959
sal_Int32 nYaBottom
Definition: ww8struc.hxx:910
sal_uInt16 nby
Definition: ww8struc.hxx:919
sal_Int32 nXaRight
Definition: ww8struc.hxx:909
sal_uInt16 bHdr
Definition: ww8struc.hxx:911
sal_Int32 nXaLeft
Definition: ww8struc.hxx:907
sal_Int32 nSpId
Definition: ww8struc.hxx:906
sal_uInt16 nwrk
Definition: ww8struc.hxx:933
sal_Int32 nTxbx
Definition: ww8struc.hxx:948
sal_Int32 nYaTop
Definition: ww8struc.hxx:908
sal_uInt16 bBelowText
Definition: ww8struc.hxx:941
sal_uInt16 bRcaSimple
Definition: ww8struc.hxx:939
sal_uInt16 nbx
Definition: ww8struc.hxx:913
sal_uInt16 nwr
Definition: ww8struc.hxx:924
sal_uInt16 bAnchorLock
Definition: ww8struc.hxx:945
sal_uInt8 rcWinMF[14]
Definition: ww8struc.hxx:492
SVBT16 dxaCropRight
Definition: ww8struc.hxx:500
sal_uInt8 aBits2
Definition: ww8struc.hxx:503
SVBT16 dyaGoal
Definition: ww8struc.hxx:495
sal_uInt8 aBits1
Definition: ww8struc.hxx:502
struct WW8_PIC_SHADOW::@17 MFP
SVBT16 dxaGoal
Definition: ww8struc.hxx:494
SVBT16 dxaCropLeft
Definition: ww8struc.hxx:498
SVBT16 dyaCropTop
Definition: ww8struc.hxx:499
SVBT16 dyaCropBottom
Definition: ww8struc.hxx:501
SVBT16 cbHeader
Definition: ww8struc.hxx:484
sal_uInt16 cbHeader
Definition: ww8struc.hxx:447
sal_Int16 brcl
Definition: ww8struc.hxx:465
sal_Int16 hMF
Definition: ww8struc.hxx:452
sal_Int16 dyaOrigin
Definition: ww8struc.hxx:477
sal_Int16 bpp
Definition: ww8struc.hxx:470
sal_uInt8 rcWinMF[14]
Definition: ww8struc.hxx:455
sal_Int16 dxaCropRight
Definition: ww8struc.hxx:463
sal_Int16 dyaCropBottom
Definition: ww8struc.hxx:464
sal_Int16 dxaOrigin
Definition: ww8struc.hxx:476
sal_Int16 dxaCropLeft
Definition: ww8struc.hxx:461
sal_Int16 dyaCropTop
Definition: ww8struc.hxx:462
struct WW8_PIC::@16 MFP
sal_uInt16 mx
Definition: ww8struc.hxx:459
sal_Int16 xExt
Definition: ww8struc.hxx:450
sal_uInt16 my
Definition: ww8struc.hxx:460
WW8_BRC rgbrc[4]
Definition: ww8struc.hxx:471
sal_Int16 yExt
Definition: ww8struc.hxx:451
sal_Int16 dxaGoal
Definition: ww8struc.hxx:457
sal_Int16 fError
Definition: ww8struc.hxx:469
sal_Int16 fDrawHatch
Definition: ww8struc.hxx:468
sal_Int16 dyaGoal
Definition: ww8struc.hxx:458
sal_Int32 lcb
Definition: ww8struc.hxx:446
sal_Int16 fFrameEmpty
Definition: ww8struc.hxx:466
sal_Int16 fBitmap
Definition: ww8struc.hxx:467
sal_Int16 mm
Definition: ww8struc.hxx:449
unsigned char sal_uInt8
VCL_DLLPUBLIC bool ReadWindowMetafile(SvStream &rStream, GDIMetaFile &rMTF)
static void WW8PicShadowToReal(WW8_PIC_SHADOW const *pPicS, WW8_PIC *pPic)
Definition: ww8graf2.cxx:734
void WW8FSPAShadowToReal(const WW8_FSPA_SHADOW &rFSPAS, WW8_FSPA &rFSPA)
Definition: ww8graf2.cxx:760
void MatchEscherMirrorIntoFlySet(const SvxMSDffImportRec &rRecord, SfxItemSet &rFlySet)
Definition: ww8graf.cxx:3066
#define WW8FL_NO_GRAF
Definition: ww8par.hxx:123
OUString read_uInt8_PascalString(SvStream &rStrm, rtl_TextEncoding eEnc)
Definition: ww8scan.hxx:157